Lines Matching refs:amd
347 static __inline__ void amd7930_idle(struct snd_amd7930 *amd) in amd7930_idle() argument
351 spin_lock_irqsave(&amd->lock, flags); in amd7930_idle()
352 sbus_writeb(AMR_INIT, amd->regs + AMD7930_CR); in amd7930_idle()
353 sbus_writeb(0, amd->regs + AMD7930_DR); in amd7930_idle()
354 spin_unlock_irqrestore(&amd->lock, flags); in amd7930_idle()
358 static __inline__ void amd7930_enable_ints(struct snd_amd7930 *amd) in amd7930_enable_ints() argument
362 spin_lock_irqsave(&amd->lock, flags); in amd7930_enable_ints()
363 sbus_writeb(AMR_INIT, amd->regs + AMD7930_CR); in amd7930_enable_ints()
364 sbus_writeb(AM_INIT_ACTIVE, amd->regs + AMD7930_DR); in amd7930_enable_ints()
365 spin_unlock_irqrestore(&amd->lock, flags); in amd7930_enable_ints()
369 static __inline__ void amd7930_disable_ints(struct snd_amd7930 *amd) in amd7930_disable_ints() argument
373 spin_lock_irqsave(&amd->lock, flags); in amd7930_disable_ints()
374 sbus_writeb(AMR_INIT, amd->regs + AMD7930_CR); in amd7930_disable_ints()
375 sbus_writeb(AM_INIT_ACTIVE | AM_INIT_DISABLE_INTS, amd->regs + AMD7930_DR); in amd7930_disable_ints()
376 spin_unlock_irqrestore(&amd->lock, flags); in amd7930_disable_ints()
382 static void __amd7930_write_map(struct snd_amd7930 *amd) in __amd7930_write_map() argument
384 struct amd7930_map *map = &amd->map; in __amd7930_write_map()
386 sbus_writeb(AMR_MAP_GX, amd->regs + AMD7930_CR); in __amd7930_write_map()
387 sbus_writeb(((map->gx >> 0) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
388 sbus_writeb(((map->gx >> 8) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
390 sbus_writeb(AMR_MAP_GR, amd->regs + AMD7930_CR); in __amd7930_write_map()
391 sbus_writeb(((map->gr >> 0) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
392 sbus_writeb(((map->gr >> 8) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
394 sbus_writeb(AMR_MAP_STGR, amd->regs + AMD7930_CR); in __amd7930_write_map()
395 sbus_writeb(((map->stgr >> 0) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
396 sbus_writeb(((map->stgr >> 8) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
398 sbus_writeb(AMR_MAP_GER, amd->regs + AMD7930_CR); in __amd7930_write_map()
399 sbus_writeb(((map->ger >> 0) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
400 sbus_writeb(((map->ger >> 8) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
402 sbus_writeb(AMR_MAP_MMR1, amd->regs + AMD7930_CR); in __amd7930_write_map()
403 sbus_writeb(map->mmr1, amd->regs + AMD7930_DR); in __amd7930_write_map()
405 sbus_writeb(AMR_MAP_MMR2, amd->regs + AMD7930_CR); in __amd7930_write_map()
406 sbus_writeb(map->mmr2, amd->regs + AMD7930_DR); in __amd7930_write_map()
476 static void __amd7930_update_map(struct snd_amd7930 *amd) in __amd7930_update_map() argument
478 struct amd7930_map *map = &amd->map; in __amd7930_update_map()
481 map->gx = gx_coeff[amd->rgain]; in __amd7930_update_map()
482 map->stgr = gx_coeff[amd->mgain]; in __amd7930_update_map()
483 level = (amd->pgain * (256 + ARRAY_SIZE(ger_coeff))) >> 8; in __amd7930_update_map()
491 __amd7930_write_map(amd); in __amd7930_update_map()
496 struct snd_amd7930 *amd = dev_id; in snd_amd7930_interrupt() local
500 spin_lock(&amd->lock); in snd_amd7930_interrupt()
504 ir = sbus_readb(amd->regs + AMD7930_IR); in snd_amd7930_interrupt()
508 if (amd->flags & AMD7930_FLAG_PLAYBACK) { in snd_amd7930_interrupt()
509 if (amd->p_left > 0) { in snd_amd7930_interrupt()
510 byte = *(amd->p_cur++); in snd_amd7930_interrupt()
511 amd->p_left--; in snd_amd7930_interrupt()
512 sbus_writeb(byte, amd->regs + AMD7930_BBTB); in snd_amd7930_interrupt()
513 if (amd->p_left == 0) in snd_amd7930_interrupt()
516 sbus_writeb(0, amd->regs + AMD7930_BBTB); in snd_amd7930_interrupt()
517 } else if (amd->flags & AMD7930_FLAG_CAPTURE) { in snd_amd7930_interrupt()
518 byte = sbus_readb(amd->regs + AMD7930_BBRB); in snd_amd7930_interrupt()
519 if (amd->c_left > 0) { in snd_amd7930_interrupt()
520 *(amd->c_cur++) = byte; in snd_amd7930_interrupt()
521 amd->c_left--; in snd_amd7930_interrupt()
522 if (amd->c_left == 0) in snd_amd7930_interrupt()
527 spin_unlock(&amd->lock); in snd_amd7930_interrupt()
530 snd_pcm_period_elapsed(amd->playback_substream); in snd_amd7930_interrupt()
532 snd_pcm_period_elapsed(amd->capture_substream); in snd_amd7930_interrupt()
537 static int snd_amd7930_trigger(struct snd_amd7930 *amd, unsigned int flag, int cmd) in snd_amd7930_trigger() argument
542 spin_lock_irqsave(&amd->lock, flags); in snd_amd7930_trigger()
544 if (!(amd->flags & flag)) { in snd_amd7930_trigger()
545 amd->flags |= flag; in snd_amd7930_trigger()
548 sbus_writeb(AMR_MUX_MCR4, amd->regs + AMD7930_CR); in snd_amd7930_trigger()
549 sbus_writeb(AM_MUX_MCR4_ENABLE_INTS, amd->regs + AMD7930_DR); in snd_amd7930_trigger()
552 if (amd->flags & flag) { in snd_amd7930_trigger()
553 amd->flags &= ~flag; in snd_amd7930_trigger()
556 sbus_writeb(AMR_MUX_MCR4, amd->regs + AMD7930_CR); in snd_amd7930_trigger()
557 sbus_writeb(0, amd->regs + AMD7930_DR); in snd_amd7930_trigger()
562 spin_unlock_irqrestore(&amd->lock, flags); in snd_amd7930_trigger()
570 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_playback_trigger() local
571 return snd_amd7930_trigger(amd, AMD7930_FLAG_PLAYBACK, cmd); in snd_amd7930_playback_trigger()
577 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_capture_trigger() local
578 return snd_amd7930_trigger(amd, AMD7930_FLAG_CAPTURE, cmd); in snd_amd7930_capture_trigger()
583 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_playback_prepare() local
589 spin_lock_irqsave(&amd->lock, flags); in snd_amd7930_playback_prepare()
591 amd->flags |= AMD7930_FLAG_PLAYBACK; in snd_amd7930_playback_prepare()
594 amd->p_orig = amd->p_cur = runtime->dma_area; in snd_amd7930_playback_prepare()
595 amd->p_left = size; in snd_amd7930_playback_prepare()
598 new_mmr1 = amd->map.mmr1; in snd_amd7930_playback_prepare()
603 if (new_mmr1 != amd->map.mmr1) { in snd_amd7930_playback_prepare()
604 amd->map.mmr1 = new_mmr1; in snd_amd7930_playback_prepare()
605 __amd7930_update_map(amd); in snd_amd7930_playback_prepare()
608 spin_unlock_irqrestore(&amd->lock, flags); in snd_amd7930_playback_prepare()
615 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_capture_prepare() local
621 spin_lock_irqsave(&amd->lock, flags); in snd_amd7930_capture_prepare()
623 amd->flags |= AMD7930_FLAG_CAPTURE; in snd_amd7930_capture_prepare()
626 amd->c_orig = amd->c_cur = runtime->dma_area; in snd_amd7930_capture_prepare()
627 amd->c_left = size; in snd_amd7930_capture_prepare()
630 new_mmr1 = amd->map.mmr1; in snd_amd7930_capture_prepare()
635 if (new_mmr1 != amd->map.mmr1) { in snd_amd7930_capture_prepare()
636 amd->map.mmr1 = new_mmr1; in snd_amd7930_capture_prepare()
637 __amd7930_update_map(amd); in snd_amd7930_capture_prepare()
640 spin_unlock_irqrestore(&amd->lock, flags); in snd_amd7930_capture_prepare()
647 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_playback_pointer() local
650 if (!(amd->flags & AMD7930_FLAG_PLAYBACK)) in snd_amd7930_playback_pointer()
652 ptr = amd->p_cur - amd->p_orig; in snd_amd7930_playback_pointer()
658 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_capture_pointer() local
661 if (!(amd->flags & AMD7930_FLAG_CAPTURE)) in snd_amd7930_capture_pointer()
664 ptr = amd->c_cur - amd->c_orig; in snd_amd7930_capture_pointer()
691 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_playback_open() local
694 amd->playback_substream = substream; in snd_amd7930_playback_open()
701 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_capture_open() local
704 amd->capture_substream = substream; in snd_amd7930_capture_open()
711 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_playback_close() local
713 amd->playback_substream = NULL; in snd_amd7930_playback_close()
719 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_capture_close() local
721 amd->capture_substream = NULL; in snd_amd7930_capture_close()
758 static int __devinit snd_amd7930_pcm(struct snd_amd7930 *amd) in snd_amd7930_pcm() argument
763 if ((err = snd_pcm_new(amd->card, in snd_amd7930_pcm()
773 pcm->private_data = amd; in snd_amd7930_pcm()
775 strcpy(pcm->name, amd->card->shortname); in snd_amd7930_pcm()
776 amd->pcm = pcm; in snd_amd7930_pcm()
801 struct snd_amd7930 *amd = snd_kcontrol_chip(kctl); in snd_amd7930_get_volume() local
807 swval = &amd->mgain; in snd_amd7930_get_volume()
810 swval = &amd->rgain; in snd_amd7930_get_volume()
814 swval = &amd->pgain; in snd_amd7930_get_volume()
825 struct snd_amd7930 *amd = snd_kcontrol_chip(kctl); in snd_amd7930_put_volume() local
832 swval = &amd->mgain; in snd_amd7930_put_volume()
835 swval = &amd->rgain; in snd_amd7930_put_volume()
839 swval = &amd->pgain; in snd_amd7930_put_volume()
843 spin_lock_irqsave(&amd->lock, flags); in snd_amd7930_put_volume()
847 __amd7930_update_map(amd); in snd_amd7930_put_volume()
852 spin_unlock_irqrestore(&amd->lock, flags); in snd_amd7930_put_volume()
887 static int __devinit snd_amd7930_mixer(struct snd_amd7930 *amd) in snd_amd7930_mixer() argument
892 if (snd_BUG_ON(!amd || !amd->card)) in snd_amd7930_mixer()
895 card = amd->card; in snd_amd7930_mixer()
900 snd_ctl_new1(&amd7930_controls[idx], amd))) < 0) in snd_amd7930_mixer()
907 static int snd_amd7930_free(struct snd_amd7930 *amd) in snd_amd7930_free() argument
909 struct platform_device *op = amd->op; in snd_amd7930_free()
911 amd7930_idle(amd); in snd_amd7930_free()
913 if (amd->irq) in snd_amd7930_free()
914 free_irq(amd->irq, amd); in snd_amd7930_free()
916 if (amd->regs) in snd_amd7930_free()
917 of_iounmap(&op->resource[0], amd->regs, in snd_amd7930_free()
920 kfree(amd); in snd_amd7930_free()
927 struct snd_amd7930 *amd = device->device_data; in snd_amd7930_dev_free() local
929 return snd_amd7930_free(amd); in snd_amd7930_dev_free()
941 struct snd_amd7930 *amd; in snd_amd7930_create() local
946 amd = kzalloc(sizeof(*amd), GFP_KERNEL); in snd_amd7930_create()
947 if (amd == NULL) in snd_amd7930_create()
950 spin_lock_init(&amd->lock); in snd_amd7930_create()
951 amd->card = card; in snd_amd7930_create()
952 amd->op = op; in snd_amd7930_create()
954 amd->regs = of_ioremap(&op->resource[0], 0, in snd_amd7930_create()
956 if (!amd->regs) { in snd_amd7930_create()
962 amd7930_idle(amd); in snd_amd7930_create()
965 IRQF_DISABLED | IRQF_SHARED, "amd7930", amd)) { in snd_amd7930_create()
968 snd_amd7930_free(amd); in snd_amd7930_create()
971 amd->irq = irq; in snd_amd7930_create()
973 amd7930_enable_ints(amd); in snd_amd7930_create()
975 spin_lock_irqsave(&amd->lock, flags); in snd_amd7930_create()
977 amd->rgain = 128; in snd_amd7930_create()
978 amd->pgain = 200; in snd_amd7930_create()
979 amd->mgain = 0; in snd_amd7930_create()
981 memset(&amd->map, 0, sizeof(amd->map)); in snd_amd7930_create()
982 amd->map.mmr1 = (AM_MAP_MMR1_GX | AM_MAP_MMR1_GER | in snd_amd7930_create()
984 amd->map.mmr2 = (AM_MAP_MMR2_LS | AM_MAP_MMR2_AINB); in snd_amd7930_create()
986 __amd7930_update_map(amd); in snd_amd7930_create()
989 sbus_writeb(AMR_MUX_MCR1, amd->regs + AMD7930_CR); in snd_amd7930_create()
991 amd->regs + AMD7930_DR); in snd_amd7930_create()
993 spin_unlock_irqrestore(&amd->lock, flags); in snd_amd7930_create()
996 amd, &snd_amd7930_dev_ops)) < 0) { in snd_amd7930_create()
997 snd_amd7930_free(amd); in snd_amd7930_create()
1001 *ramd = amd; in snd_amd7930_create()
1010 struct snd_amd7930 *amd; in amd7930_sbus_probe() local
1036 irq, dev_num, &amd)) < 0) in amd7930_sbus_probe()
1039 if ((err = snd_amd7930_pcm(amd)) < 0) in amd7930_sbus_probe()
1042 if ((err = snd_amd7930_mixer(amd)) < 0) in amd7930_sbus_probe()
1048 amd->next = amd7930_list; in amd7930_sbus_probe()
1049 amd7930_list = amd; in amd7930_sbus_probe()