sound/soc/codecs/es8326.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/es8326.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/es8326.c
Extension
.c
Size
47489 bytes
Lines
1387
Domain
Driver Families
Bucket
sound/soc
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 es8326_priv {
	struct clk *mclk;
	struct i2c_client *i2c;
	struct regmap *regmap;
	struct snd_soc_component *component;
	struct delayed_work jack_detect_work;
	struct delayed_work button_press_work;
	struct snd_soc_jack *jack;
	int irq;
	/* The lock protects the situation that an irq is generated
	 * while enabling or disabling or during an irq.
	 */
	struct mutex lock;
	u8 jack_pol;
	u8 interrupt_src;
	u8 interrupt_clk;
	u8 hpl_vol;
	u8 hpr_vol;
	bool jd_inverted;
	unsigned int sysclk;

	bool calibrated;
	int version;
	int hp;
	int jack_remove_retry;
};

static int es8326_crosstalk1_get(struct snd_kcontrol *kcontrol,
		struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
	unsigned int crosstalk_h, crosstalk_l;
	unsigned int crosstalk;

	regmap_read(es8326->regmap, ES8326_DAC_RAMPRATE, &crosstalk_h);
	regmap_read(es8326->regmap, ES8326_DAC_CROSSTALK, &crosstalk_l);
	crosstalk_h &= 0x20;
	crosstalk_l &= 0xf0;
	crosstalk = crosstalk_h >> 1 | crosstalk_l >> 4;
	ucontrol->value.integer.value[0] = crosstalk;

	return 0;
}

static int es8326_crosstalk1_set(struct snd_kcontrol *kcontrol,
		struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
	unsigned int crosstalk_h, crosstalk_l;
	unsigned int crosstalk;

	crosstalk = ucontrol->value.integer.value[0];
	regmap_read(es8326->regmap, ES8326_DAC_CROSSTALK, &crosstalk_l);
	crosstalk_h = (crosstalk & 0x10) << 1;
	crosstalk_l &= 0x0f;
	crosstalk_l |= (crosstalk & 0x0f) << 4;
	regmap_update_bits(es8326->regmap, ES8326_DAC_RAMPRATE,
			0x20, crosstalk_h);
	regmap_write(es8326->regmap, ES8326_DAC_CROSSTALK, crosstalk_l);

	return 0;
}

static int es8326_crosstalk2_get(struct snd_kcontrol *kcontrol,
		struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
	unsigned int crosstalk_h, crosstalk_l;
	unsigned int crosstalk;

	regmap_read(es8326->regmap, ES8326_DAC_RAMPRATE, &crosstalk_h);
	regmap_read(es8326->regmap, ES8326_DAC_CROSSTALK, &crosstalk_l);
	crosstalk_h &= 0x10;
	crosstalk_l &= 0x0f;
	crosstalk = crosstalk_h  | crosstalk_l;
	ucontrol->value.integer.value[0] = crosstalk;

	return 0;
}

static int es8326_crosstalk2_set(struct snd_kcontrol *kcontrol,
		struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
	struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
	unsigned int crosstalk_h, crosstalk_l;
	unsigned int crosstalk;

Annotation

Implementation Notes