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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/i2c.hlinux/interrupt.hlinux/irq.hlinux/module.hsound/jack.hsound/pcm_params.hsound/soc.hsound/soc-dapm.hsound/tlv.hes8326.h
Detected Declarations
struct es8326_privstruct _coeff_divfunction es8326_crosstalk1_getfunction es8326_crosstalk1_setfunction es8326_crosstalk2_getfunction es8326_crosstalk2_setfunction es8326_hplvol_getfunction es8326_hplvol_setfunction es8326_hprvol_getfunction es8326_hprvol_setfunction es8326_volatile_registerfunction es8326_writeable_registerfunction get_coefffunction es8326_set_dai_sysclkfunction es8326_set_dai_fmtfunction es8326_pcm_hw_paramsfunction es8326_mutefunction es8326_set_bias_levelfunction es8326_enable_micbiasfunction es8326_disable_micbiasfunction es8326_jack_button_handlerfunction es8326_jack_detect_handlerfunction es8326_irqfunction es8326_calibratefunction es8326_initfunction es8326_resumefunction es8326_suspendfunction es8326_probefunction es8326_enable_jack_detectfunction es8326_disable_jack_detectfunction es8326_set_jackfunction es8326_removefunction es8326_i2c_probefunction es8326_i2c_shutdownfunction es8326_i2c_remove
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
- Immediate include surface: `linux/clk.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/module.h`, `sound/jack.h`, `sound/pcm_params.h`, `sound/soc.h`.
- Detected declarations: `struct es8326_priv`, `struct _coeff_div`, `function es8326_crosstalk1_get`, `function es8326_crosstalk1_set`, `function es8326_crosstalk2_get`, `function es8326_crosstalk2_set`, `function es8326_hplvol_get`, `function es8326_hplvol_set`, `function es8326_hprvol_get`, `function es8326_hprvol_set`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.