sound/soc/codecs/twl4030.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/twl4030.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/twl4030.c- Extension
.c- Size
- 68833 bytes
- Lines
- 2206
- 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/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/init.hlinux/mfd/twl.hlinux/mfd/twl4030-audio.hlinux/module.hlinux/moduleparam.hlinux/of.hlinux/pm.hlinux/platform_device.hlinux/slab.hsound/core.hsound/initval.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/tlv.h
Detected Declarations
struct twl4030_board_paramsstruct twl4030_privfunction tw4030_init_ctl_cachefunction twl4030_readfunction twl4030_can_write_to_chipfunction twl4030_writefunction twl4030_wait_msfunction twl4030_codec_enablefunction twl4030_get_board_param_valuesfunction twl4030_get_board_paramsfunction twl4030_init_chipfunction twl4030_apll_enablefunction handsfree_rampfunction handsfreelpga_eventfunction handsfreerpga_eventfunction vibramux_eventfunction apll_eventfunction aif_eventfunction headset_rampfunction headsetlpga_eventfunction headsetrpga_eventfunction digimic_eventfunction TWLfunction snd_soc_put_volsw_twl4030function snd_soc_get_volsw_r2_twl4030function snd_soc_put_volsw_r2_twl4030function snd_soc_put_twl4030_opmode_enum_doublefunction twl4030_set_bias_levelfunction twl4030_constraintsfunction twl4030_tdm_enablefunction twl4030_startupfunction twl4030_shutdownfunction twl4030_hw_paramsfunction twl4030_set_dai_sysclkfunction twl4030_set_dai_fmtfunction twl4030_set_tristatefunction twl4030_voice_enablefunction twl4030_voice_startupfunction twl4030_voice_shutdownfunction twl4030_voice_hw_paramsfunction twl4030_voice_set_dai_sysclkfunction twl4030_voice_set_dai_fmtfunction twl4030_voice_set_tristatefunction twl4030_soc_probefunction twl4030_codec_probe
Annotated Snippet
struct twl4030_board_params {
unsigned int digimic_delay; /* in ms */
unsigned int ramp_delay_value;
unsigned int offset_cncl_path;
unsigned int hs_extmute:1;
struct gpio_desc *hs_extmute_gpio;
};
/* codec private data */
struct twl4030_priv {
unsigned int codec_powered;
/* reference counts of AIF/APLL users */
unsigned int apll_enabled;
struct snd_pcm_substream *master_substream;
struct snd_pcm_substream *slave_substream;
unsigned int configured;
unsigned int rate;
unsigned int sample_bits;
unsigned int channels;
unsigned int sysclk;
/* Output (with associated amp) states */
u8 hsl_enabled, hsr_enabled;
u8 earpiece_enabled;
u8 predrivel_enabled, predriver_enabled;
u8 carkitl_enabled, carkitr_enabled;
u8 ctl_cache[TWL4030_REG_PRECKR_CTL - TWL4030_REG_EAR_CTL + 1];
struct twl4030_board_params *board_params;
};
static void tw4030_init_ctl_cache(struct twl4030_priv *twl4030)
{
int i;
u8 byte;
for (i = TWL4030_REG_EAR_CTL; i <= TWL4030_REG_PRECKR_CTL; i++) {
twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, i);
twl4030->ctl_cache[i - TWL4030_REG_EAR_CTL] = byte;
}
}
static unsigned int twl4030_read(struct snd_soc_component *component, unsigned int reg)
{
struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component);
u8 value = 0;
if (reg >= TWL4030_CACHEREGNUM)
return -EIO;
switch (reg) {
case TWL4030_REG_EAR_CTL:
case TWL4030_REG_PREDL_CTL:
case TWL4030_REG_PREDR_CTL:
case TWL4030_REG_PRECKL_CTL:
case TWL4030_REG_PRECKR_CTL:
case TWL4030_REG_HS_GAIN_SET:
value = twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL];
break;
default:
twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &value, reg);
break;
}
return value;
}
static bool twl4030_can_write_to_chip(struct twl4030_priv *twl4030,
unsigned int reg)
{
bool write_to_reg = false;
/* Decide if the given register can be written */
switch (reg) {
case TWL4030_REG_EAR_CTL:
if (twl4030->earpiece_enabled)
write_to_reg = true;
break;
case TWL4030_REG_PREDL_CTL:
if (twl4030->predrivel_enabled)
write_to_reg = true;
break;
case TWL4030_REG_PREDR_CTL:
if (twl4030->predriver_enabled)
write_to_reg = true;
break;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/init.h`, `linux/mfd/twl.h`, `linux/mfd/twl4030-audio.h`, `linux/module.h`, `linux/moduleparam.h`.
- Detected declarations: `struct twl4030_board_params`, `struct twl4030_priv`, `function tw4030_init_ctl_cache`, `function twl4030_read`, `function twl4030_can_write_to_chip`, `function twl4030_write`, `function twl4030_wait_ms`, `function twl4030_codec_enable`, `function twl4030_get_board_param_values`, `function twl4030_get_board_params`.
- 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.