Lines Matching full:amd

18  * Thanks to the AMD engineer who was able to get us the AMD79C30
346 /* Idle the AMD7930 chip. The amd->lock is not held. */
347 static __inline__ void amd7930_idle(struct snd_amd7930 *amd)
349 guard(spinlock_irqsave)(&amd->lock);
350 sbus_writeb(AMR_INIT, amd->regs + AMD7930_CR);
351 sbus_writeb(0, amd->regs + AMD7930_DR);
354 /* Enable chip interrupts. The amd->lock is not held. */
355 static __inline__ void amd7930_enable_ints(struct snd_amd7930 *amd)
357 guard(spinlock_irqsave)(&amd->lock);
358 sbus_writeb(AMR_INIT, amd->regs + AMD7930_CR);
359 sbus_writeb(AM_INIT_ACTIVE, amd->regs + AMD7930_DR);
362 /* Disable chip interrupts. The amd->lock is not held. */
363 static __inline__ void amd7930_disable_ints(struct snd_amd7930 *amd)
365 guard(spinlock_irqsave)(&amd->lock);
366 sbus_writeb(AMR_INIT, amd->regs + AMD7930_CR);
367 sbus_writeb(AM_INIT_ACTIVE | AM_INIT_DISABLE_INTS, amd->regs + AMD7930_DR);
371 * The amd->lock is held and local interrupts are disabled.
373 static void __amd7930_write_map(struct snd_amd7930 *amd)
375 struct amd7930_map *map = &amd->map;
377 sbus_writeb(AMR_MAP_GX, amd->regs + AMD7930_CR);
378 sbus_writeb(((map->gx >> 0) & 0xff), amd->regs + AMD7930_DR);
379 sbus_writeb(((map->gx >> 8) & 0xff), amd->regs + AMD7930_DR);
381 sbus_writeb(AMR_MAP_GR, amd->regs + AMD7930_CR);
382 sbus_writeb(((map->gr >> 0) & 0xff), amd->regs + AMD7930_DR);
383 sbus_writeb(((map->gr >> 8) & 0xff), amd->regs + AMD7930_DR);
385 sbus_writeb(AMR_MAP_STGR, amd->regs + AMD7930_CR);
386 sbus_writeb(((map->stgr >> 0) & 0xff), amd->regs + AMD7930_DR);
387 sbus_writeb(((map->stgr >> 8) & 0xff), amd->regs + AMD7930_DR);
389 sbus_writeb(AMR_MAP_GER, amd->regs + AMD7930_CR);
390 sbus_writeb(((map->ger >> 0) & 0xff), amd->regs + AMD7930_DR);
391 sbus_writeb(((map->ger >> 8) & 0xff), amd->regs + AMD7930_DR);
393 sbus_writeb(AMR_MAP_MMR1, amd->regs + AMD7930_CR);
394 sbus_writeb(map->mmr1, amd->regs + AMD7930_DR);
396 sbus_writeb(AMR_MAP_MMR2, amd->regs + AMD7930_CR);
397 sbus_writeb(map->mmr2, amd->regs + AMD7930_DR);
465 * The amd->lock is held and local interrupts are disabled.
467 static void __amd7930_update_map(struct snd_amd7930 *amd)
469 struct amd7930_map *map = &amd->map;
472 map->gx = gx_coeff[amd->rgain];
473 map->stgr = gx_coeff[amd->mgain];
474 level = (amd->pgain * (256 + ARRAY_SIZE(ger_coeff))) >> 8;
482 __amd7930_write_map(amd);
487 struct snd_amd7930 *amd = dev_id;
491 scoped_guard(spinlock, &amd->lock) {
494 ir = sbus_readb(amd->regs + AMD7930_IR);
498 if (amd->flags & AMD7930_FLAG_PLAYBACK) {
499 if (amd->p_left > 0) {
500 byte = *(amd->p_cur++);
501 amd->p_left--;
502 sbus_writeb(byte, amd->regs + AMD7930_BBTB);
503 if (amd->p_left == 0)
506 sbus_writeb(0, amd->regs + AMD7930_BBTB);
507 } else if (amd->flags & AMD7930_FLAG_CAPTURE) {
508 byte = sbus_readb(amd->regs + AMD7930_BBRB);
509 if (amd->c_left > 0) {
510 *(amd->c_cur++) = byte;
511 amd->c_left--;
512 if (amd->c_left == 0)
520 snd_pcm_period_elapsed(amd->playback_substream);
522 snd_pcm_period_elapsed(amd->capture_substream);
527 static int snd_amd7930_trigger(struct snd_amd7930 *amd, unsigned int flag, int cmd)
531 guard(spinlock_irqsave)(&amd->lock);
533 if (!(amd->flags & flag)) {
534 amd->flags |= flag;
537 sbus_writeb(AMR_MUX_MCR4, amd->regs + AMD7930_CR);
538 sbus_writeb(AM_MUX_MCR4_ENABLE_INTS, amd->regs + AMD7930_DR);
541 if (amd->flags & flag) {
542 amd->flags &= ~flag;
545 sbus_writeb(AMR_MUX_MCR4, amd->regs + AMD7930_CR);
546 sbus_writeb(0, amd->regs + AMD7930_DR);
558 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream);
559 return snd_amd7930_trigger(amd, AMD7930_FLAG_PLAYBACK, cmd);
565 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream);
566 return snd_amd7930_trigger(amd, AMD7930_FLAG_CAPTURE, cmd);
571 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream);
576 guard(spinlock_irqsave)(&amd->lock);
578 amd->flags |= AMD7930_FLAG_PLAYBACK;
581 amd->p_orig = amd->p_cur = runtime->dma_area;
582 amd->p_left = size;
585 new_mmr1 = amd->map.mmr1;
590 if (new_mmr1 != amd->map.mmr1) {
591 amd->map.mmr1 = new_mmr1;
592 __amd7930_update_map(amd);
600 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream);
605 guard(spinlock_irqsave)(&amd->lock);
607 amd->flags |= AMD7930_FLAG_CAPTURE;
610 amd->c_orig = amd->c_cur = runtime->dma_area;
611 amd->c_left = size;
614 new_mmr1 = amd->map.mmr1;
619 if (new_mmr1 != amd->map.mmr1) {
620 amd->map.mmr1 = new_mmr1;
621 __amd7930_update_map(amd);
629 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream);
632 if (!(amd->flags & AMD7930_FLAG_PLAYBACK))
634 ptr = amd->p_cur - amd->p_orig;
640 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream);
643 if (!(amd->flags & AMD7930_FLAG_CAPTURE))
646 ptr = amd->c_cur - amd->c_orig;
673 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream);
676 amd->playback_substream = substream;
683 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream);
686 amd->capture_substream = substream;
693 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream);
695 amd->playback_substream = NULL;
701 struct snd_amd7930 *amd = snd_pcm_substream_chip(substream);
703 amd->capture_substream = NULL;
723 static int snd_amd7930_pcm(struct snd_amd7930 *amd)
728 if ((err = snd_pcm_new(amd->card,
738 pcm->private_data = amd;
740 strscpy(pcm->name, amd->card->shortname);
741 amd->pcm = pcm;
765 struct snd_amd7930 *amd = snd_kcontrol_chip(kctl);
771 swval = &amd->mgain;
774 swval = &amd->rgain;
778 swval = &amd->pgain;
789 struct snd_amd7930 *amd = snd_kcontrol_chip(kctl);
795 swval = &amd->mgain;
798 swval = &amd->rgain;
802 swval = &amd->pgain;
806 guard(spinlock_irqsave)(&amd->lock);
810 __amd7930_update_map(amd);
848 static int snd_amd7930_mixer(struct snd_amd7930 *amd)
853 if (snd_BUG_ON(!amd || !amd->card))
856 card = amd->card;
861 snd_ctl_new1(&amd7930_controls[idx], amd))) < 0)
868 static int snd_amd7930_free(struct snd_amd7930 *amd)
870 struct platform_device *op = amd->op;
872 amd7930_idle(amd);
874 if (amd->irq)
875 free_irq(amd->irq, amd);
877 if (amd->regs)
878 of_iounmap(&op->resource[0], amd->regs,
881 kfree(amd);
888 struct snd_amd7930 *amd = device->device_data;
890 return snd_amd7930_free(amd);
902 struct snd_amd7930 *amd;
906 amd = kzalloc(sizeof(*amd), GFP_KERNEL);
907 if (amd == NULL)
910 spin_lock_init(&amd->lock);
911 amd->card = card;
912 amd->op = op;
914 amd->regs = of_ioremap(&op->resource[0], 0,
916 if (!amd->regs) {
919 kfree(amd);
923 amd7930_idle(amd);
926 IRQF_SHARED, "amd7930", amd)) {
929 snd_amd7930_free(amd);
932 amd->irq = irq;
934 amd7930_enable_ints(amd);
936 scoped_guard(spinlock_irqsave, &amd->lock) {
937 amd->rgain = 128;
938 amd->pgain = 200;
939 amd->mgain = 0;
941 memset(&amd->map, 0, sizeof(amd->map));
942 amd->map.mmr1 = (AM_MAP_MMR1_GX | AM_MAP_MMR1_GER |
944 amd->map.mmr2 = (AM_MAP_MMR2_LS | AM_MAP_MMR2_AINB);
946 __amd7930_update_map(amd);
949 sbus_writeb(AMR_MUX_MCR1, amd->regs + AMD7930_CR);
951 amd->regs + AMD7930_DR);
955 amd, &snd_amd7930_dev_ops);
957 snd_amd7930_free(amd);
961 *ramd = amd;
970 struct snd_amd7930 *amd;
996 irq, dev_num, &amd)) < 0)
999 err = snd_amd7930_pcm(amd);
1003 err = snd_amd7930_mixer(amd);
1011 amd->next = amd7930_list;
1012 amd7930_list = amd;