sound/soc/codecs/twl6040.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/twl6040.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/twl6040.c- Extension
.c- Size
- 32200 bytes
- Lines
- 1178
- 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.
- 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/module.hlinux/moduleparam.hlinux/init.hlinux/delay.hlinux/pm.hlinux/platform_device.hlinux/slab.hlinux/mfd/twl6040.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-dapm.hsound/initval.hsound/tlv.htwl6040.h
Detected Declarations
struct twl6040_jack_datastruct twl6040_dataenum twl6040_dai_idfunction twl6040_readfunction twl6040_can_write_to_chipfunction twl6040_update_dl12_cachefunction twl6040_writefunction twl6040_init_chipfunction headset_power_modefunction twl6040_hs_dac_eventfunction twl6040_ep_drv_eventfunction twl6040_hs_jack_reportfunction twl6040_hs_jack_detectfunction twl6040_accessory_workfunction twl6040_audio_handlerfunction twl6040_soc_dapm_put_vibra_enumfunction twl6040_headset_power_get_enumfunction twl6040_headset_power_put_enumfunction twl6040_pll_get_enumfunction twl6040_pll_put_enumfunction twl6040_get_dl1_gainfunction twl6040_get_clk_idfunction twl6040_get_trim_valuefunction twl6040_get_hs_step_sizefunction twl6040_set_bias_levelfunction twl6040_startupfunction twl6040_hw_paramsfunction twl6040_preparefunction twl6040_set_dai_sysclkfunction twl6040_mute_pathfunction twl6040_mute_streamfunction twl6040_probefunction twl6040_removefunction twl6040_codec_probeexport twl6040_hs_jack_detectexport twl6040_get_dl1_gainexport twl6040_get_clk_idexport twl6040_get_trim_valueexport twl6040_get_hs_step_size
Annotated Snippet
struct twl6040_jack_data {
struct snd_soc_jack *jack;
struct delayed_work work;
int report;
};
/* codec private data */
struct twl6040_data {
int plug_irq;
int codec_powered;
int pll;
int pll_power_mode;
int hs_power_mode;
int hs_power_mode_locked;
bool dl1_unmuted;
bool dl2_unmuted;
u8 dl12_cache[TWL6040_REG_HFRCTL - TWL6040_REG_HSLCTL + 1];
unsigned int clk_in;
unsigned int sysclk;
struct twl6040_jack_data hs_jack;
struct snd_soc_component *component;
struct mutex mutex;
};
/* set of rates for each pll: low-power and high-performance */
static const unsigned int lp_rates[] = {
8000,
11250,
16000,
22500,
32000,
44100,
48000,
88200,
96000,
};
static const unsigned int hp_rates[] = {
8000,
16000,
32000,
48000,
96000,
};
static const struct snd_pcm_hw_constraint_list sysclk_constraints[] = {
{ .count = ARRAY_SIZE(lp_rates), .list = lp_rates, },
{ .count = ARRAY_SIZE(hp_rates), .list = hp_rates, },
};
#define to_twl6040(component) dev_get_drvdata((component)->dev->parent)
static unsigned int twl6040_read(struct snd_soc_component *component, unsigned int reg)
{
struct twl6040_data *priv = snd_soc_component_get_drvdata(component);
struct twl6040 *twl6040 = to_twl6040(component);
u8 value;
if (reg >= TWL6040_CACHEREGNUM)
return -EIO;
switch (reg) {
case TWL6040_REG_HSLCTL:
case TWL6040_REG_HSRCTL:
case TWL6040_REG_EARCTL:
case TWL6040_REG_HFLCTL:
case TWL6040_REG_HFRCTL:
value = priv->dl12_cache[reg - TWL6040_REG_HSLCTL];
break;
default:
value = twl6040_reg_read(twl6040, reg);
break;
}
return value;
}
static bool twl6040_can_write_to_chip(struct snd_soc_component *component,
unsigned int reg)
{
struct twl6040_data *priv = snd_soc_component_get_drvdata(component);
switch (reg) {
case TWL6040_REG_HSLCTL:
case TWL6040_REG_HSRCTL:
case TWL6040_REG_EARCTL:
/* DL1 path */
return priv->dl1_unmuted;
case TWL6040_REG_HFLCTL:
case TWL6040_REG_HFRCTL:
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/delay.h`, `linux/pm.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/mfd/twl6040.h`.
- Detected declarations: `struct twl6040_jack_data`, `struct twl6040_data`, `enum twl6040_dai_id`, `function twl6040_read`, `function twl6040_can_write_to_chip`, `function twl6040_update_dl12_cache`, `function twl6040_write`, `function twl6040_init_chip`, `function headset_power_mode`, `function twl6040_hs_dac_event`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.