sound/soc/codecs/es8316.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/es8316.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/es8316.c- Extension
.c- Size
- 29225 bytes
- Lines
- 934
- 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/module.hlinux/acpi.hlinux/clk.hlinux/delay.hlinux/i2c.hlinux/mod_devicetable.hlinux/mutex.hlinux/regmap.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-dapm.hsound/tlv.hsound/jack.hes8316.h
Detected Declarations
struct es8316_privfunction es8316_set_dai_sysclkfunction es8316_set_dai_fmtfunction es8316_pcm_startupfunction es8316_pcm_hw_paramsfunction es8316_mutefunction es8316_enable_micbias_for_mic_gnd_short_detectfunction es8316_disable_micbias_for_mic_gnd_short_detectfunction es8316_irqfunction es8316_enable_jack_detectfunction es8316_disable_jack_detectfunction es8316_set_jackfunction es8316_probefunction es8316_removefunction es8316_resumefunction es8316_suspendfunction es8316_volatile_regfunction es8316_i2c_probe
Annotated Snippet
struct es8316_priv {
struct mutex lock;
struct clk *mclk;
struct regmap *regmap;
struct snd_soc_component *component;
struct snd_soc_jack *jack;
int irq;
unsigned int sysclk;
/* ES83xx supports halving the MCLK so it supports twice as many rates
*/
unsigned int allowed_rates[ARRAY_SIZE(supported_mclk_lrck_ratios) * 2];
struct snd_pcm_hw_constraint_list sysclk_constraints;
bool jd_inverted;
};
/*
* ES8316 controls
*/
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(dac_vol_tlv, -9600, 50, 1);
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(adc_vol_tlv, -9600, 50, 1);
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(alc_max_gain_tlv, -650, 150, 0);
static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(alc_min_gain_tlv, -1200, 150, 0);
static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(alc_target_tlv,
0, 10, TLV_DB_SCALE_ITEM(-1650, 150, 0),
11, 11, TLV_DB_SCALE_ITEM(-150, 0, 0),
);
static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(hpmixer_gain_tlv,
0, 4, TLV_DB_SCALE_ITEM(-1200, 150, 0),
8, 11, TLV_DB_SCALE_ITEM(-450, 150, 0),
);
static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(adc_pga_gain_tlv,
0, 0, TLV_DB_SCALE_ITEM(-350, 0, 0),
1, 1, TLV_DB_SCALE_ITEM(0, 0, 0),
2, 2, TLV_DB_SCALE_ITEM(250, 0, 0),
3, 3, TLV_DB_SCALE_ITEM(450, 0, 0),
4, 7, TLV_DB_SCALE_ITEM(700, 300, 0),
8, 10, TLV_DB_SCALE_ITEM(1800, 300, 0),
);
static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(hpout_vol_tlv,
0, 0, TLV_DB_SCALE_ITEM(-4800, 0, 0),
1, 3, TLV_DB_SCALE_ITEM(-2400, 1200, 0),
);
static const char * const ng_type_txt[] =
{ "Constant PGA Gain", "Mute ADC Output" };
static const struct soc_enum ng_type =
SOC_ENUM_SINGLE(ES8316_ADC_ALC_NG, 6, 2, ng_type_txt);
static const char * const adcpol_txt[] = { "Normal", "Invert" };
static const struct soc_enum adcpol =
SOC_ENUM_SINGLE(ES8316_ADC_MUTE, 1, 2, adcpol_txt);
static const char *const dacpol_txt[] =
{ "Normal", "R Invert", "L Invert", "L + R Invert" };
static const struct soc_enum dacpol =
SOC_ENUM_SINGLE(ES8316_DAC_SET1, 0, 4, dacpol_txt);
static const struct snd_kcontrol_new es8316_snd_controls[] = {
SOC_DOUBLE_TLV("Headphone Playback Volume", ES8316_CPHP_ICAL_VOL,
4, 0, 3, 1, hpout_vol_tlv),
SOC_DOUBLE_TLV("Headphone Mixer Volume", ES8316_HPMIX_VOL,
4, 0, 11, 0, hpmixer_gain_tlv),
SOC_ENUM("Playback Polarity", dacpol),
SOC_DOUBLE_R_TLV("DAC Playback Volume", ES8316_DAC_VOLL,
ES8316_DAC_VOLR, 0, 0xc0, 1, dac_vol_tlv),
SOC_SINGLE("DAC Soft Ramp Switch", ES8316_DAC_SET1, 4, 1, 1),
SOC_SINGLE("DAC Soft Ramp Rate", ES8316_DAC_SET1, 2, 3, 0),
SOC_SINGLE("DAC Notch Filter Switch", ES8316_DAC_SET2, 6, 1, 0),
SOC_SINGLE("DAC Double Fs Switch", ES8316_DAC_SET2, 7, 1, 0),
SOC_SINGLE("DAC Stereo Enhancement", ES8316_DAC_SET3, 0, 7, 0),
SOC_SINGLE("DAC Mono Mix Switch", ES8316_DAC_SET3, 3, 1, 0),
SOC_ENUM("Capture Polarity", adcpol),
SOC_SINGLE("Mic Boost Switch", ES8316_ADC_D2SEPGA, 0, 1, 0),
SOC_SINGLE_TLV("ADC Capture Volume", ES8316_ADC_VOLUME,
0, 0xc0, 1, adc_vol_tlv),
SOC_SINGLE_TLV("ADC PGA Gain Volume", ES8316_ADC_PGAGAIN,
4, 10, 0, adc_pga_gain_tlv),
SOC_SINGLE("ADC Soft Ramp Switch", ES8316_ADC_MUTE, 4, 1, 0),
SOC_SINGLE("ADC Double Fs Switch", ES8316_ADC_DMIC, 4, 1, 0),
SOC_SINGLE("ALC Capture Switch", ES8316_ADC_ALC1, 6, 1, 0),
SOC_SINGLE_TLV("ALC Capture Max Volume", ES8316_ADC_ALC1, 0, 28, 0,
alc_max_gain_tlv),
SOC_SINGLE_TLV("ALC Capture Min Volume", ES8316_ADC_ALC2, 0, 28, 0,
alc_min_gain_tlv),
Annotation
- Immediate include surface: `linux/module.h`, `linux/acpi.h`, `linux/clk.h`, `linux/delay.h`, `linux/i2c.h`, `linux/mod_devicetable.h`, `linux/mutex.h`, `linux/regmap.h`.
- Detected declarations: `struct es8316_priv`, `function es8316_set_dai_sysclk`, `function es8316_set_dai_fmt`, `function es8316_pcm_startup`, `function es8316_pcm_hw_params`, `function es8316_mute`, `function es8316_enable_micbias_for_mic_gnd_short_detect`, `function es8316_disable_micbias_for_mic_gnd_short_detect`, `function es8316_irq`, `function es8316_enable_jack_detect`.
- 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.