sound/soc/codecs/da7213.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/da7213.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/da7213.c- Extension
.c- Size
- 74689 bytes
- Lines
- 2293
- 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.
- 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/acpi.hlinux/of.hlinux/property.hlinux/clk.hlinux/delay.hlinux/i2c.hlinux/regmap.hlinux/slab.hlinux/module.hsound/pcm.hsound/pcm_params.hlinux/pm_runtime.hlinux/units.hsound/soc.hsound/initval.hsound/tlv.hsound/da7213.hda7213.h
Detected Declarations
function da7213_volsw_locked_getfunction da7213_volsw_locked_putfunction da7213_enum_locked_getfunction da7213_enum_locked_putfunction da7213_get_alc_datafunction da7213_alc_calib_manfunction da7213_alc_calib_autofunction da7213_alc_calibfunction da7213_put_mixin_gainfunction da7213_put_alc_swfunction da7213_tonegen_freq_getfunction da7213_tonegen_freq_putfunction da7213_dai_eventfunction da7213_volatile_registerfunction da7213_hw_paramsfunction da7213_set_dai_fmtfunction da7213_mutefunction da7213_set_component_sysclkfunction _da7213_set_component_pllfunction da7213_set_component_pllfunction da7213_set_auto_pllfunction da7213_set_bias_levelfunction da7213_of_micbias_lvlfunction da7213_of_dmic_data_selfunction da7213_of_dmic_samplephasefunction da7213_of_dmic_clkratefunction da7213_probefunction da7213_runtime_suspendfunction da7213_runtime_resumefunction da7213_suspendfunction da7213_resumefunction da7213_power_offfunction da7213_i2c_probefunction da7213_i2c_remove
Annotated Snippet
if (!da7213->alc_en) {
da7213_alc_calib(component);
da7213->alc_en = true;
}
} else {
da7213->alc_en = false;
}
return snd_soc_put_volsw(kcontrol, ucontrol);
}
/* ToneGen */
static int da7213_tonegen_freq_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
struct soc_mixer_control *mixer_ctrl =
(struct soc_mixer_control *) kcontrol->private_value;
unsigned int reg = mixer_ctrl->reg;
__le16 val;
int ret;
mutex_lock(&da7213->ctrl_lock);
ret = regmap_raw_read(da7213->regmap, reg, &val, sizeof(val));
mutex_unlock(&da7213->ctrl_lock);
if (ret)
return ret;
/*
* Frequency value spans two 8-bit registers, lower then upper byte.
* Therefore we need to convert to host endianness here.
*/
ucontrol->value.integer.value[0] = le16_to_cpu(val);
return 0;
}
static int da7213_tonegen_freq_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
struct soc_mixer_control *mixer_ctrl =
(struct soc_mixer_control *) kcontrol->private_value;
unsigned int reg = mixer_ctrl->reg;
__le16 val_new, val_old;
int ret;
/*
* Frequency value spans two 8-bit registers, lower then upper byte.
* Therefore we need to convert to little endian here to align with
* HW registers.
*/
val_new = cpu_to_le16(ucontrol->value.integer.value[0]);
mutex_lock(&da7213->ctrl_lock);
ret = regmap_raw_read(da7213->regmap, reg, &val_old, sizeof(val_old));
if (ret == 0 && (val_old != val_new))
ret = regmap_raw_write(da7213->regmap, reg,
&val_new, sizeof(val_new));
mutex_unlock(&da7213->ctrl_lock);
if (ret < 0)
return ret;
return val_old != val_new;
}
/*
* KControls
*/
static const struct snd_kcontrol_new da7213_snd_controls[] = {
/* Volume controls */
SOC_SINGLE_TLV("Mic 1 Volume", DA7213_MIC_1_GAIN,
DA7213_MIC_AMP_GAIN_SHIFT, DA7213_MIC_AMP_GAIN_MAX,
DA7213_NO_INVERT, mic_vol_tlv),
SOC_SINGLE_TLV("Mic 2 Volume", DA7213_MIC_2_GAIN,
DA7213_MIC_AMP_GAIN_SHIFT, DA7213_MIC_AMP_GAIN_MAX,
DA7213_NO_INVERT, mic_vol_tlv),
SOC_DOUBLE_R_TLV("Aux Volume", DA7213_AUX_L_GAIN, DA7213_AUX_R_GAIN,
DA7213_AUX_AMP_GAIN_SHIFT, DA7213_AUX_AMP_GAIN_MAX,
DA7213_NO_INVERT, aux_vol_tlv),
SOC_DOUBLE_R_EXT_TLV("Mixin PGA Volume", DA7213_MIXIN_L_GAIN,
DA7213_MIXIN_R_GAIN, DA7213_MIXIN_AMP_GAIN_SHIFT,
DA7213_MIXIN_AMP_GAIN_MAX, DA7213_NO_INVERT,
snd_soc_get_volsw_2r, da7213_put_mixin_gain,
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/of.h`, `linux/property.h`, `linux/clk.h`, `linux/delay.h`, `linux/i2c.h`, `linux/regmap.h`, `linux/slab.h`.
- Detected declarations: `function da7213_volsw_locked_get`, `function da7213_volsw_locked_put`, `function da7213_enum_locked_get`, `function da7213_enum_locked_put`, `function da7213_get_alc_data`, `function da7213_alc_calib_man`, `function da7213_alc_calib_auto`, `function da7213_alc_calib`, `function da7213_put_mixin_gain`, `function da7213_put_alc_sw`.
- 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.
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.