sound/pci/ak4531_codec.c

Source file repositories/reference/linux-study-clean/sound/pci/ak4531_codec.c

File Facts

System
Linux kernel
Corpus path
sound/pci/ak4531_codec.c
Extension
.c
Size
16472 bytes
Lines
468
Domain
Driver Families
Bucket
sound/pci
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (err < 0) {
			snd_ak4531_free(ak4531);
			return err;
		}
	}
	snd_ak4531_proc_init(card, ak4531);
	err = snd_device_new(card, SNDRV_DEV_CODEC, ak4531, &ops);
	if (err < 0) {
		snd_ak4531_free(ak4531);
		return err;
	}

#if 0
	snd_ak4531_dump(ak4531);
#endif
	if (rak4531)
		*rak4531 = ak4531;
	return 0;
}

/*
 * power management
 */
#ifdef CONFIG_PM
void snd_ak4531_suspend(struct snd_ak4531 *ak4531)
{
	/* mute */
	ak4531->write(ak4531, AK4531_LMASTER, 0x9f);
	ak4531->write(ak4531, AK4531_RMASTER, 0x9f);
	/* powerdown */
	ak4531->write(ak4531, AK4531_RESET, 0x01);
}

void snd_ak4531_resume(struct snd_ak4531 *ak4531)
{
	int idx;

	/* initialize */
	ak4531->write(ak4531, AK4531_RESET, 0x03);
	udelay(100);
	ak4531->write(ak4531, AK4531_CLOCK, 0x00);
	/* restore mixer registers */
	for (idx = 0; idx <= 0x19; idx++) {
		if (idx == AK4531_RESET || idx == AK4531_CLOCK)
			continue;
		ak4531->write(ak4531, idx, ak4531->regs[idx]);
	}
}
#endif

/*
 * /proc interface
 */

static void snd_ak4531_proc_read(struct snd_info_entry *entry, 
				 struct snd_info_buffer *buffer)
{
	struct snd_ak4531 *ak4531 = entry->private_data;

	snd_iprintf(buffer, "Asahi Kasei AK4531\n\n");
	snd_iprintf(buffer, "Recording source   : %s\n"
		    "MIC gain           : %s\n",
		    ak4531->regs[AK4531_AD_IN] & 1 ? "external" : "mixer",
		    ak4531->regs[AK4531_MIC_GAIN] & 1 ? "+30dB" : "+0dB");
}

static void
snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak4531)
{
	snd_card_ro_proc_new(card, "ak4531", ak4531, snd_ak4531_proc_read);
}

Annotation

Implementation Notes