sound/soc/codecs/es8328.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/es8328.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/es8328.c- Extension
.c- Size
- 25140 bytes
- Lines
- 917
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/delay.hlinux/module.hlinux/pm.hlinux/regmap.hlinux/slab.hlinux/regulator/consumer.hsound/core.hsound/initval.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/tlv.hes8328.h
Detected Declarations
struct es8328_privenum sgtl5000_regulator_suppliesfunction es8328_set_deemphfunction es8328_get_deemphfunction es8328_put_deemphfunction es8328_mutefunction es8328_startupfunction es8328_hw_paramsfunction es8328_set_sysclkfunction es8328_set_dai_fmtfunction es8328_set_bias_levelfunction es8328_suspendfunction es8328_resumefunction es8328_component_probefunction es8328_removefunction es8328_probeexport es8328_regmap_configexport es8328_probe
Annotated Snippet
struct es8328_priv {
struct regmap *regmap;
struct clk *clk;
int playback_fs;
bool deemph;
int mclkdiv2;
const struct snd_pcm_hw_constraint_list *sysclk_constraints;
const int *mclk_ratios;
bool provider;
struct regulator_bulk_data supplies[ES8328_SUPPLY_NUM];
};
/*
* ES8328 Controls
*/
static const char * const adcpol_txt[] = {"Normal", "L Invert", "R Invert",
"L + R Invert"};
static SOC_ENUM_SINGLE_DECL(adcpol,
ES8328_ADCCONTROL6, 6, adcpol_txt);
static const DECLARE_TLV_DB_SCALE(play_tlv, -3000, 100, 0);
static const DECLARE_TLV_DB_SCALE(dac_adc_tlv, -9600, 50, 0);
static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0);
static const DECLARE_TLV_DB_SCALE(mic_tlv, 0, 300, 0);
static const struct {
int rate;
unsigned int val;
} deemph_settings[] = {
{ 0, ES8328_DACCONTROL6_DEEMPH_OFF },
{ 32000, ES8328_DACCONTROL6_DEEMPH_32k },
{ 44100, ES8328_DACCONTROL6_DEEMPH_44_1k },
{ 48000, ES8328_DACCONTROL6_DEEMPH_48k },
};
static int es8328_set_deemph(struct snd_soc_component *component)
{
struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component);
int val, i, best;
/*
* If we're using deemphasis select the nearest available sample
* rate.
*/
if (es8328->deemph) {
best = 0;
for (i = 1; i < ARRAY_SIZE(deemph_settings); i++) {
if (abs(deemph_settings[i].rate - es8328->playback_fs) <
abs(deemph_settings[best].rate - es8328->playback_fs))
best = i;
}
val = deemph_settings[best].val;
} else {
val = ES8328_DACCONTROL6_DEEMPH_OFF;
}
dev_dbg(component->dev, "Set deemphasis %d\n", val);
return snd_soc_component_update_bits(component, ES8328_DACCONTROL6,
ES8328_DACCONTROL6_DEEMPH_MASK, val);
}
static int es8328_get_deemph(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = es8328->deemph;
return 0;
}
static int es8328_put_deemph(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component);
unsigned int deemph = ucontrol->value.integer.value[0];
int ret;
if (deemph > 1)
return -EINVAL;
if (es8328->deemph == deemph)
return 0;
es8328->deemph = deemph;
ret = es8328_set_deemph(component);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/module.h`, `linux/pm.h`, `linux/regmap.h`, `linux/slab.h`, `linux/regulator/consumer.h`, `sound/core.h`.
- Detected declarations: `struct es8328_priv`, `enum sgtl5000_regulator_supplies`, `function es8328_set_deemph`, `function es8328_get_deemph`, `function es8328_put_deemph`, `function es8328_mute`, `function es8328_startup`, `function es8328_hw_params`, `function es8328_set_sysclk`, `function es8328_set_dai_fmt`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration implementation candidate.
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.