Lines Matching full:amd

18  * Thanks to the AMD engineer who was able to get us the AMD79C30
347 /* Idle the AMD7930 chip. The amd->lock is not held. */
348 static __inline__ void amd7930_idle(struct snd_amd7930 *amd) in amd7930_idle() argument
352 spin_lock_irqsave(&amd->lock, flags); in amd7930_idle()
353 sbus_writeb(AMR_INIT, amd->regs + AMD7930_CR); in amd7930_idle()
354 sbus_writeb(0, amd->regs + AMD7930_DR); in amd7930_idle()
355 spin_unlock_irqrestore(&amd->lock, flags); in amd7930_idle()
358 /* Enable chip interrupts. The amd->lock is not held. */
359 static __inline__ void amd7930_enable_ints(struct snd_amd7930 *amd) in amd7930_enable_ints() argument
363 spin_lock_irqsave(&amd->lock, flags); in amd7930_enable_ints()
364 sbus_writeb(AMR_INIT, amd->regs + AMD7930_CR); in amd7930_enable_ints()
365 sbus_writeb(AM_INIT_ACTIVE, amd->regs + AMD7930_DR); in amd7930_enable_ints()
366 spin_unlock_irqrestore(&amd->lock, flags); in amd7930_enable_ints()
369 /* Disable chip interrupts. The amd->lock is not held. */
370 static __inline__ void amd7930_disable_ints(struct snd_amd7930 *amd) in amd7930_disable_ints() argument
374 spin_lock_irqsave(&amd->lock, flags); in amd7930_disable_ints()
375 sbus_writeb(AMR_INIT, amd->regs + AMD7930_CR); in amd7930_disable_ints()
376 sbus_writeb(AM_INIT_ACTIVE | AM_INIT_DISABLE_INTS, amd->regs + AMD7930_DR); in amd7930_disable_ints()
377 spin_unlock_irqrestore(&amd->lock, flags); in amd7930_disable_ints()
381 * The amd->lock is held and local interrupts are disabled.
383 static void __amd7930_write_map(struct snd_amd7930 *amd) in __amd7930_write_map() argument
385 struct amd7930_map *map = &amd->map; in __amd7930_write_map()
387 sbus_writeb(AMR_MAP_GX, amd->regs + AMD7930_CR); in __amd7930_write_map()
388 sbus_writeb(((map->gx >> 0) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
389 sbus_writeb(((map->gx >> 8) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
391 sbus_writeb(AMR_MAP_GR, amd->regs + AMD7930_CR); in __amd7930_write_map()
392 sbus_writeb(((map->gr >> 0) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
393 sbus_writeb(((map->gr >> 8) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
395 sbus_writeb(AMR_MAP_STGR, amd->regs + AMD7930_CR); in __amd7930_write_map()
396 sbus_writeb(((map->stgr >> 0) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
397 sbus_writeb(((map->stgr >> 8) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
399 sbus_writeb(AMR_MAP_GER, amd->regs + AMD7930_CR); in __amd7930_write_map()
400 sbus_writeb(((map->ger >> 0) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
401 sbus_writeb(((map->ger >> 8) & 0xff), amd->regs + AMD7930_DR); in __amd7930_write_map()
403 sbus_writeb(AMR_MAP_MMR1, amd->regs + AMD7930_CR); in __amd7930_write_map()
404 sbus_writeb(map->mmr1, amd->regs + AMD7930_DR); in __amd7930_write_map()
406 sbus_writeb(AMR_MAP_MMR2, amd->regs + AMD7930_CR); in __amd7930_write_map()
407 sbus_writeb(map->mmr2, amd->regs + AMD7930_DR); in __amd7930_write_map()
475 * The amd->lock is held and local interrupts are disabled.
477 static void __amd7930_update_map(struct snd_amd7930 *amd) in __amd7930_update_map() argument
479 struct amd7930_map *map = &amd->map; in __amd7930_update_map()
482 map->gx = gx_coeff[amd->rgain]; in __amd7930_update_map()
483 map->stgr = gx_coeff[amd->mgain]; in __amd7930_update_map()
484 level = (amd->pgain * (256 + ARRAY_SIZE(ger_coeff))) >> 8; in __amd7930_update_map()
492 __amd7930_write_map(amd); in __amd7930_update_map()
497 struct snd_amd7930 *amd = dev_id; in snd_amd7930_interrupt() local
501 spin_lock(&amd->lock); in snd_amd7930_interrupt()
505 ir = sbus_readb(amd->regs + AMD7930_IR); in snd_amd7930_interrupt()
509 if (amd->flags & AMD7930_FLAG_PLAYBACK) { in snd_amd7930_interrupt()
510 if (amd->p_left > 0) { in snd_amd7930_interrupt()
511 byte = *(amd->p_cur++); in snd_amd7930_interrupt()
512 amd->p_left--; in snd_amd7930_interrupt()
513 sbus_writeb(byte, amd->regs + AMD7930_BBTB); in snd_amd7930_interrupt()
514 if (amd->p_left == 0) in snd_amd7930_interrupt()
517 sbus_writeb(0, amd->regs + AMD7930_BBTB); in snd_amd7930_interrupt()
518 } else if (amd->flags & AMD7930_FLAG_CAPTURE) { in snd_amd7930_interrupt()
519 byte = sbus_readb(amd->regs + AMD7930_BBRB); in snd_amd7930_interrupt()
520 if (amd->c_left > 0) { in snd_amd7930_interrupt()
521 *(amd->c_cur++) = byte; in snd_amd7930_interrupt()
522 amd->c_left--; in snd_amd7930_interrupt()
523 if (amd->c_left == 0) in snd_amd7930_interrupt()
528 spin_unlock(&amd->lock); in snd_amd7930_interrupt()
531 snd_pcm_period_elapsed(amd->playback_substream); in snd_amd7930_interrupt()
533 snd_pcm_period_elapsed(amd->capture_substream); in snd_amd7930_interrupt()
538 static int snd_amd7930_trigger(struct snd_amd7930 *amd, unsigned int flag, int cmd) in snd_amd7930_trigger() argument
543 spin_lock_irqsave(&amd->lock, flags); in snd_amd7930_trigger()
545 if (!(amd->flags & flag)) { in snd_amd7930_trigger()
546 amd->flags |= flag; in snd_amd7930_trigger()
549 sbus_writeb(AMR_MUX_MCR4, amd->regs + AMD7930_CR); in snd_amd7930_trigger()
550 sbus_writeb(AM_MUX_MCR4_ENABLE_INTS, amd->regs + AMD7930_DR); in snd_amd7930_trigger()
553 if (amd->flags & flag) { in snd_amd7930_trigger()
554 amd->flags &= ~flag; in snd_amd7930_trigger()
557 sbus_writeb(AMR_MUX_MCR4, amd->regs + AMD7930_CR); in snd_amd7930_trigger()
558 sbus_writeb(0, amd->regs + AMD7930_DR); in snd_amd7930_trigger()
563 spin_unlock_irqrestore(&amd->lock, flags); in snd_amd7930_trigger()
571 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_playback_trigger() local
572 return snd_amd7930_trigger(amd, AMD7930_FLAG_PLAYBACK, cmd); in snd_amd7930_playback_trigger()
578 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_capture_trigger() local
579 return snd_amd7930_trigger(amd, AMD7930_FLAG_CAPTURE, cmd); in snd_amd7930_capture_trigger()
584 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_playback_prepare() local
590 spin_lock_irqsave(&amd->lock, flags); in snd_amd7930_playback_prepare()
592 amd->flags |= AMD7930_FLAG_PLAYBACK; in snd_amd7930_playback_prepare()
595 amd->p_orig = amd->p_cur = runtime->dma_area; in snd_amd7930_playback_prepare()
596 amd->p_left = size; in snd_amd7930_playback_prepare()
599 new_mmr1 = amd->map.mmr1; in snd_amd7930_playback_prepare()
604 if (new_mmr1 != amd->map.mmr1) { in snd_amd7930_playback_prepare()
605 amd->map.mmr1 = new_mmr1; in snd_amd7930_playback_prepare()
606 __amd7930_update_map(amd); in snd_amd7930_playback_prepare()
609 spin_unlock_irqrestore(&amd->lock, flags); in snd_amd7930_playback_prepare()
616 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_capture_prepare() local
622 spin_lock_irqsave(&amd->lock, flags); in snd_amd7930_capture_prepare()
624 amd->flags |= AMD7930_FLAG_CAPTURE; in snd_amd7930_capture_prepare()
627 amd->c_orig = amd->c_cur = runtime->dma_area; in snd_amd7930_capture_prepare()
628 amd->c_left = size; in snd_amd7930_capture_prepare()
631 new_mmr1 = amd->map.mmr1; in snd_amd7930_capture_prepare()
636 if (new_mmr1 != amd->map.mmr1) { in snd_amd7930_capture_prepare()
637 amd->map.mmr1 = new_mmr1; in snd_amd7930_capture_prepare()
638 __amd7930_update_map(amd); in snd_amd7930_capture_prepare()
641 spin_unlock_irqrestore(&amd->lock, flags); in snd_amd7930_capture_prepare()
648 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_playback_pointer() local
651 if (!(amd->flags & AMD7930_FLAG_PLAYBACK)) in snd_amd7930_playback_pointer()
653 ptr = amd->p_cur - amd->p_orig; in snd_amd7930_playback_pointer()
659 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_capture_pointer() local
662 if (!(amd->flags & AMD7930_FLAG_CAPTURE)) in snd_amd7930_capture_pointer()
665 ptr = amd->c_cur - amd->c_orig; in snd_amd7930_capture_pointer()
692 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_playback_open() local
695 amd->playback_substream = substream; in snd_amd7930_playback_open()
702 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_capture_open() local
705 amd->capture_substream = substream; in snd_amd7930_capture_open()
712 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_playback_close() local
714 amd->playback_substream = NULL; in snd_amd7930_playback_close()
720 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); in snd_amd7930_capture_close() local
722 amd->capture_substream = NULL; in snd_amd7930_capture_close()
759 static int snd_amd7930_pcm(struct snd_amd7930 *amd) in snd_amd7930_pcm() argument
764 if ((err = snd_pcm_new(amd->card, in snd_amd7930_pcm()
774 pcm->private_data = amd; in snd_amd7930_pcm()
776 strcpy(pcm->name, amd->card->shortname); in snd_amd7930_pcm()
777 amd->pcm = pcm; in snd_amd7930_pcm()
802 struct snd_amd7930 *amd = snd_kcontrol_chip(kctl); in snd_amd7930_get_volume() local
808 swval = &amd->mgain; in snd_amd7930_get_volume()
811 swval = &amd->rgain; in snd_amd7930_get_volume()
815 swval = &amd->pgain; in snd_amd7930_get_volume()
826 struct snd_amd7930 *amd = snd_kcontrol_chip(kctl); in snd_amd7930_put_volume() local
833 swval = &amd->mgain; in snd_amd7930_put_volume()
836 swval = &amd->rgain; in snd_amd7930_put_volume()
840 swval = &amd->pgain; in snd_amd7930_put_volume()
844 spin_lock_irqsave(&amd->lock, flags); in snd_amd7930_put_volume()
848 __amd7930_update_map(amd); in snd_amd7930_put_volume()
853 spin_unlock_irqrestore(&amd->lock, flags); in snd_amd7930_put_volume()
888 static int snd_amd7930_mixer(struct snd_amd7930 *amd) in snd_amd7930_mixer() argument
893 if (snd_BUG_ON(!amd || !amd->card)) in snd_amd7930_mixer()
896 card = amd->card; in snd_amd7930_mixer()
901 snd_ctl_new1(&amd7930_controls[idx], amd))) < 0) in snd_amd7930_mixer()
908 static int snd_amd7930_free(struct snd_amd7930 *amd) in snd_amd7930_free() argument
910 struct platform_device *op = amd->op; in snd_amd7930_free()
912 amd7930_idle(amd); in snd_amd7930_free()
914 if (amd->irq) in snd_amd7930_free()
915 free_irq(amd->irq, amd); in snd_amd7930_free()
917 if (amd->regs) in snd_amd7930_free()
918 of_iounmap(&op->resource[0], amd->regs, in snd_amd7930_free()
921 kfree(amd); in snd_amd7930_free()
928 struct snd_amd7930 *amd = device->device_data; in snd_amd7930_dev_free() local
930 return snd_amd7930_free(amd); in snd_amd7930_dev_free()
942 struct snd_amd7930 *amd; in snd_amd7930_create() local
947 amd = kzalloc(sizeof(*amd), GFP_KERNEL); in snd_amd7930_create()
948 if (amd == NULL) in snd_amd7930_create()
951 spin_lock_init(&amd->lock); in snd_amd7930_create()
952 amd->card = card; in snd_amd7930_create()
953 amd->op = op; in snd_amd7930_create()
955 amd->regs = of_ioremap(&op->resource[0], 0, in snd_amd7930_create()
957 if (!amd->regs) { in snd_amd7930_create()
960 kfree(amd); in snd_amd7930_create()
964 amd7930_idle(amd); in snd_amd7930_create()
967 IRQF_SHARED, "amd7930", amd)) { in snd_amd7930_create()
970 snd_amd7930_free(amd); in snd_amd7930_create()
973 amd->irq = irq; in snd_amd7930_create()
975 amd7930_enable_ints(amd); in snd_amd7930_create()
977 spin_lock_irqsave(&amd->lock, flags); in snd_amd7930_create()
979 amd->rgain = 128; in snd_amd7930_create()
980 amd->pgain = 200; in snd_amd7930_create()
981 amd->mgain = 0; in snd_amd7930_create()
983 memset(&amd->map, 0, sizeof(amd->map)); in snd_amd7930_create()
984 amd->map.mmr1 = (AM_MAP_MMR1_GX | AM_MAP_MMR1_GER | in snd_amd7930_create()
986 amd->map.mmr2 = (AM_MAP_MMR2_LS | AM_MAP_MMR2_AINB); in snd_amd7930_create()
988 __amd7930_update_map(amd); in snd_amd7930_create()
991 sbus_writeb(AMR_MUX_MCR1, amd->regs + AMD7930_CR); in snd_amd7930_create()
993 amd->regs + AMD7930_DR); in snd_amd7930_create()
995 spin_unlock_irqrestore(&amd->lock, flags); in snd_amd7930_create()
998 amd, &snd_amd7930_dev_ops)) < 0) { in snd_amd7930_create()
999 snd_amd7930_free(amd); in snd_amd7930_create()
1003 *ramd = amd; in snd_amd7930_create()
1012 struct snd_amd7930 *amd; in amd7930_sbus_probe() local
1038 irq, dev_num, &amd)) < 0) in amd7930_sbus_probe()
1041 if ((err = snd_amd7930_pcm(amd)) < 0) in amd7930_sbus_probe()
1044 if ((err = snd_amd7930_mixer(amd)) < 0) in amd7930_sbus_probe()
1050 amd->next = amd7930_list; in amd7930_sbus_probe()
1051 amd7930_list = amd; in amd7930_sbus_probe()