sound/pci/ac97/ac97_patch.c

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

File Facts

System
Linux kernel
Corpus path
sound/pci/ac97/ac97_patch.c
Extension
.c
Size
125879 bytes
Lines
3916
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

struct vt1618_uaj_item {
	unsigned short mask;
	unsigned short shift;
	const char * const items[4];
};

/* This list reflects the vt1618 docs for Vendor Defined Register 0x60. */

static const struct vt1618_uaj_item vt1618_uaj[3] = {
	{
		/* speaker jack */
		.mask  = 0x03,
		.shift = 0,
		.items = {
			"Speaker Out", "DAC Unmixed Out", "Line In", "Mic In"
		}
	},
	{
		/* line jack */
		.mask  = 0x0c,
		.shift = 2,
		.items = {
			"Surround Out", "DAC Unmixed Out", "Line In", "Mic In"
		}
	},
	{
		/* mic jack */
		.mask  = 0x30,
		.shift = 4,
		.items = {
			"Center LFE Out", "DAC Unmixed Out", "Line In", "Mic In"
		},
	},
};

static int snd_ac97_vt1618_UAJ_info(struct snd_kcontrol *kcontrol,
				    struct snd_ctl_elem_info *uinfo)
{
	return snd_ctl_enum_info(uinfo, 1, 4,
				 vt1618_uaj[kcontrol->private_value].items);
}

/* All of the vt1618 Universal Audio Jack twiddlers are on
 * Vendor Defined Register 0x60, page 0. The bits, and thus
 * the mask, are the only thing that changes
 */
static int snd_ac97_vt1618_UAJ_get(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_value *ucontrol)
{
	unsigned short datpag, uaj;
	struct snd_ac97 *pac97 = snd_kcontrol_chip(kcontrol);

	guard(mutex)(&pac97->page_mutex);

	datpag = snd_ac97_read(pac97, AC97_INT_PAGING) & AC97_PAGE_MASK;
	snd_ac97_update_bits(pac97, AC97_INT_PAGING, AC97_PAGE_MASK, 0);

	uaj = snd_ac97_read(pac97, 0x60) &
		vt1618_uaj[kcontrol->private_value].mask;

	snd_ac97_update_bits(pac97, AC97_INT_PAGING, AC97_PAGE_MASK, datpag);

	ucontrol->value.enumerated.item[0] = uaj >>
		vt1618_uaj[kcontrol->private_value].shift;

	return 0;
}

static int snd_ac97_vt1618_UAJ_put(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_value *ucontrol)
{
	return ac97_update_bits_page(snd_kcontrol_chip(kcontrol), 0x60,
				     vt1618_uaj[kcontrol->private_value].mask,
				     ucontrol->value.enumerated.item[0]<<
				     vt1618_uaj[kcontrol->private_value].shift,
				     0);
}

/* config aux in jack - not found on 3 jack motherboards or soundcards */

static int snd_ac97_vt1618_aux_info(struct snd_kcontrol *kcontrol,
				     struct snd_ctl_elem_info *uinfo)
{
	static const char * const txt_aux[] = {"Aux In", "Back Surr Out"};

	return snd_ctl_enum_info(uinfo, 1, 2, txt_aux);
}

static int snd_ac97_vt1618_aux_get(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_value *ucontrol)

Annotation

Implementation Notes