sound/soc/codecs/cs42l84.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/cs42l84.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/cs42l84.c- Extension
.c- Size
- 33523 bytes
- Lines
- 1126
- 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/bitfield.hlinux/bits.hlinux/module.hlinux/moduleparam.hlinux/kernel.hlinux/init.hlinux/delay.hlinux/i2c.hlinux/gpio.hlinux/regmap.hlinux/slab.hlinux/acpi.hlinux/platform_device.hlinux/property.hlinux/regulator/consumer.hlinux/gpio/consumer.hlinux/of_device.hsound/core.hsound/jack.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-dapm.hsound/initval.hsound/tlv.hcs42l84.hcirrus_legacy.h
Detected Declarations
struct cs42l84_privatestruct cs42l84_pll_paramsstruct cs42l84_irq_paramsfunction cs42l84_volatile_registerfunction cs42l84_put_dac_volfunction cs42l84_get_dac_volfunction cs42l84_set_jackfunction cs42l84_component_probefunction cs42l84_pll_configfunction cs42l84_set_dai_fmtfunction cs42l84_pcm_hw_paramsfunction cs42l84_set_sysclkfunction cs42l84_mute_streamfunction cs42l84_detect_hsfunction cs42l84_revert_hsfunction cs42l84_set_interrupt_masksfunction cs42l84_irq_threadfunction cs42l84_setup_plug_detectfunction cs42l84_i2c_probefunction cs42l84_i2c_remove
Annotated Snippet
struct cs42l84_private {
struct regmap *regmap;
struct device *dev;
struct gpio_desc *reset_gpio;
struct snd_soc_jack *jack;
struct mutex irq_lock;
u8 tip_state;
u8 ring_state;
int pll_config;
int bclk;
u8 pll_mclk_f;
u32 srate;
u8 stream_use;
int hs_type;
};
static bool cs42l84_volatile_register(struct device *dev, unsigned int reg)
{
switch (reg) {
case CS42L84_DEVID ... CS42L84_DEVID+5:
case CS42L84_TSRS_PLUG_INT_STATUS:
case CS42L84_PLL_LOCK_STATUS:
case CS42L84_TSRS_PLUG_STATUS:
case CS42L84_HS_DET_STATUS2:
return true;
default:
return false;
}
}
static const struct regmap_config cs42l84_regmap = {
.reg_bits = 16,
.val_bits = 8,
.volatile_reg = cs42l84_volatile_register,
.max_register = 0x73fe,
.cache_type = REGCACHE_MAPLE,
.use_single_read = true,
.use_single_write = true,
};
static int cs42l84_put_dac_vol(struct snd_kcontrol *kctl,
struct snd_ctl_elem_value *val)
{
struct snd_soc_component *component = snd_kcontrol_chip(kctl);
struct soc_mixer_control *mc = (struct soc_mixer_control *) kctl->private_value;
int vola, volb;
int ret, ret2, updated = 0;
vola = val->value.integer.value[0] + mc->min;
volb = val->value.integer.value[1] + mc->min;
if (vola < mc->min || vola > mc->max || volb < mc->min || volb > mc->max)
return -EINVAL;
ret = snd_soc_component_update_bits(component, CS42L84_FRZ_CTL,
CS42L84_FRZ_CTL_ENGAGE,
CS42L84_FRZ_CTL_ENGAGE);
if (ret < 0)
goto bail;
updated |= ret;
ret = snd_soc_component_update_bits(component, CS42L84_DAC_CHA_VOL_LSB,
0xff, vola & 0xff);
if (ret < 0)
goto bail;
updated |= ret;
ret = snd_soc_component_update_bits(component, CS42L84_DAC_CHA_VOL_MSB,
0xff, (vola >> 8) & 0x01);
if (ret < 0)
goto bail;
updated |= ret;
ret = snd_soc_component_update_bits(component, CS42L84_DAC_CHB_VOL_LSB,
0xff, volb & 0xff);
if (ret < 0)
goto bail;
updated |= ret;
ret = snd_soc_component_update_bits(component, CS42L84_DAC_CHB_VOL_MSB,
0xff, (volb >> 8) & 0x01);
if (ret < 0)
goto bail;
ret |= updated;
bail:
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/kernel.h`, `linux/init.h`, `linux/delay.h`, `linux/i2c.h`.
- Detected declarations: `struct cs42l84_private`, `struct cs42l84_pll_params`, `struct cs42l84_irq_params`, `function cs42l84_volatile_register`, `function cs42l84_put_dac_vol`, `function cs42l84_get_dac_vol`, `function cs42l84_set_jack`, `function cs42l84_component_probe`, `function cs42l84_pll_config`, `function cs42l84_set_dai_fmt`.
- 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.