sound/pci/ice1712/maya44.c

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

File Facts

System
Linux kernel
Corpus path
sound/pci/ice1712/maya44.c
Extension
.c
Size
19596 bytes
Lines
743
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 snd_wm8776 {
	unsigned char addr;
	unsigned short regs[WM8776_NUM_REGS];
	unsigned char volumes[WM_NUM_VOLS][2];
	unsigned int switch_bits;
};

struct snd_maya44 {
	struct snd_ice1712 *ice;
	struct snd_wm8776 wm[2];
	struct mutex mutex;
};


/* write the given register and save the data to the cache */
static void wm8776_write(struct snd_ice1712 *ice, struct snd_wm8776 *wm,
			 unsigned char reg, unsigned short val)
{
	/*
	 * WM8776 registers are up to 9 bits wide, bit 8 is placed in the LSB
	 * of the address field
	 */
	snd_vt1724_write_i2c(ice, wm->addr,
			     (reg << 1) | ((val >> 8) & 1),
			     val & 0xff);
	wm->regs[reg] = val;
}

/*
 * update the given register with and/or mask and save the data to the cache
 */
static int wm8776_write_bits(struct snd_ice1712 *ice, struct snd_wm8776 *wm,
			     unsigned char reg,
			     unsigned short mask, unsigned short val)
{
	val |= wm->regs[reg] & ~mask;
	if (val != wm->regs[reg]) {
		wm8776_write(ice, wm, reg, val);
		return 1;
	}
	return 0;
}


/*
 * WM8776 volume controls
 */

struct maya_vol_info {
	unsigned int maxval;		/* volume range: 0..maxval */
	unsigned char regs[2];		/* left and right registers */
	unsigned short mask;		/* value mask */
	unsigned short offset;		/* zero-value offset */
	unsigned short mute;		/* mute bit */
	unsigned short update;		/* update bits */
	unsigned char mux_bits[2];	/* extra bits for ADC mute */
};

static const struct maya_vol_info vol_info[WM_NUM_VOLS] = {
	[WM_VOL_HP] = {
		.maxval = 80,
		.regs = { WM8776_REG_HEADPHONE_L, WM8776_REG_HEADPHONE_R },
		.mask = 0x7f,
		.offset = 0x30,
		.mute = 0x00,
		.update = 0x180,	/* update and zero-cross enable */
	},
	[WM_VOL_DAC] = {
		.maxval = 255,
		.regs = { WM8776_REG_DAC_ATTEN_L, WM8776_REG_DAC_ATTEN_R },
		.mask = 0xff,
		.offset = 0x01,
		.mute = 0x00,
		.update = 0x100,	/* zero-cross enable */
	},
	[WM_VOL_ADC] = {
		.maxval = 91,
		.regs = { WM8776_REG_ADC_ATTEN_L, WM8776_REG_ADC_ATTEN_R },
		.mask = 0xff,
		.offset = 0xa5,
		.mute = 0xa5,
		.update = 0x100,	/* update */
		.mux_bits = { 0x80, 0x40 }, /* ADCMUX bits */
	},
};

/*
 * dB tables
 */
/* headphone output: mute, -73..+6db (1db step) */

Annotation

Implementation Notes