sound/soc/codecs/max9867.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/max9867.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/max9867.c- Extension
.c- Size
- 20763 bytes
- Lines
- 719
- 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.
- 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/i2c.hlinux/module.hlinux/regmap.hsound/pcm_params.hsound/soc.hsound/tlv.hmax9867.h
Detected Declarations
struct max9867_privenum max9867_adc_dacfunction max9867_adc_dac_eventfunction max9867_filter_getfunction max9867_filter_setfunction max9867_startupfunction max9867_dai_hw_paramsfunction PCLKfunction max9867_mutefunction max9867_set_dai_sysclkfunction max9867_dai_set_fmtfunction max9867_suspendfunction max9867_resumefunction max9867_set_bias_levelfunction max9867_volatile_registerfunction max9867_i2c_probe
Annotated Snippet
struct max9867_priv {
struct clk *mclk;
struct regmap *regmap;
const struct snd_pcm_hw_constraint_list *constraints;
unsigned int sysclk, pclk;
bool provider, dsp_a;
unsigned int adc_dac_active;
};
static const char *const max9867_spmode[] = {
"Stereo Diff", "Mono Diff",
"Stereo Cap", "Mono Cap",
"Stereo Single", "Mono Single",
"Stereo Single Fast", "Mono Single Fast"
};
static const char *const max9867_filter_text[] = {"IIR", "FIR"};
static const char *const max9867_adc_dac_filter_text[] = {
"Disabled",
"Elliptical/16/256",
"Butterworth/16/500",
"Elliptical/8/256",
"Butterworth/8/500",
"Butterworth/8-24"
};
enum max9867_adc_dac {
MAX9867_ADC_LEFT,
MAX9867_ADC_RIGHT,
MAX9867_DAC_LEFT,
MAX9867_DAC_RIGHT,
};
static int max9867_adc_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
enum max9867_adc_dac adc_dac;
if (!snd_soc_dapm_widget_name_cmp(w, "ADCL"))
adc_dac = MAX9867_ADC_LEFT;
else if (!snd_soc_dapm_widget_name_cmp(w, "ADCR"))
adc_dac = MAX9867_ADC_RIGHT;
else if (!snd_soc_dapm_widget_name_cmp(w, "DACL"))
adc_dac = MAX9867_DAC_LEFT;
else if (!snd_soc_dapm_widget_name_cmp(w, "DACR"))
adc_dac = MAX9867_DAC_RIGHT;
else
return 0;
if (SND_SOC_DAPM_EVENT_ON(event))
max9867->adc_dac_active |= BIT(adc_dac);
else if (SND_SOC_DAPM_EVENT_OFF(event))
max9867->adc_dac_active &= ~BIT(adc_dac);
return 0;
}
static int max9867_filter_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
unsigned int reg;
int ret;
ret = regmap_read(max9867->regmap, MAX9867_CODECFLTR, ®);
if (ret)
return -EINVAL;
if (reg & MAX9867_CODECFLTR_MODE)
ucontrol->value.enumerated.item[0] = 1;
else
ucontrol->value.enumerated.item[0] = 0;
return 0;
}
static int max9867_filter_set(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
unsigned int reg, mode = ucontrol->value.enumerated.item[0];
int ret;
if (mode > 1)
return -EINVAL;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/i2c.h`, `linux/module.h`, `linux/regmap.h`, `sound/pcm_params.h`, `sound/soc.h`, `sound/tlv.h`.
- Detected declarations: `struct max9867_priv`, `enum max9867_adc_dac`, `function max9867_adc_dac_event`, `function max9867_filter_get`, `function max9867_filter_set`, `function max9867_startup`, `function max9867_dai_hw_params`, `function PCLK`, `function max9867_mute`, `function max9867_set_dai_sysclk`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source 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.