sound/soc/codecs/rt5682.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt5682.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt5682.c- Extension
.c- Size
- 92382 bytes
- Lines
- 3186
- 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.
- 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/pm_runtime.hlinux/platform_device.hlinux/spi/spi.hlinux/acpi.hlinux/gpio/consumer.hlinux/mutex.hsound/core.hsound/pcm.hsound/pcm_params.hsound/jack.hsound/soc.hsound/soc-dapm.hsound/initval.hsound/tlv.hsound/rt5682.hrl6231.hrt5682.h
Detected Declarations
function rt5682_apply_patch_listfunction rt5682_volatile_registerfunction rt5682_readable_registerfunction rt5682_resetfunction rt5682_sel_asrc_clk_srcfunction rt5682_button_detectfunction rt5682_enable_push_button_irqfunction rt5682_headset_detectfunction rt5682_set_jack_detectfunction rt5682_jack_detect_handlerfunction rt5682_div_selfunction set_dmic_clkfunction set_filter_clkfunction is_sys_clk_from_pll1function is_sys_clk_from_pll2function is_using_asrcfunction rt5682_hp_eventfunction set_dmic_powerfunction rt5682_set_verffunction rt5682_set_tdm_slotfunction rt5682_hw_paramsfunction rt5682_set_dai_fmtfunction rt5682_set_component_sysclkfunction rt5682_set_component_pllfunction rt5682_set_bclk1_ratiofunction rt5682_set_bclk2_ratiofunction rt5682_set_bias_levelfunction rt5682_clk_checkfunction rt5682_wclk_preparefunction rt5682_wclk_unpreparefunction rt5682_wclk_recalc_ratefunction rt5682_wclk_determine_ratefunction rt5682_wclk_set_ratefunction rt5682_bclk_recalc_ratefunction rt5682_bclk_get_factorfunction rt5682_bclk_determine_ratefunction rt5682_bclk_set_ratefunction rt5682_register_dai_clksfunction rt5682_probefunction rt5682_removefunction rt5682_suspendfunction rt5682_resumefunction rt5682_parse_dtfunction rt5682_get_ldo1function rt5682_calibrateexport rt5682_supply_namesexport rt5682_apply_patch_listexport rt5682_reg
Annotated Snippet
while (val == 0 && count < 50) {
usleep_range(10000, 15000);
val = snd_soc_component_read(component,
RT5682_CBJ_CTRL_2) & RT5682_JACK_TYPE_MASK;
count++;
}
switch (val) {
case 0x1:
case 0x2:
rt5682->jack_type = SND_JACK_HEADSET;
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
RT5682_FAST_OFF_MASK, RT5682_FAST_OFF_EN);
rt5682_enable_push_button_irq(component, true);
break;
default:
rt5682->jack_type = SND_JACK_HEADPHONE;
break;
}
snd_soc_component_update_bits(component,
RT5682_HP_CHARGE_PUMP_1,
RT5682_OSW_L_MASK | RT5682_OSW_R_MASK,
RT5682_OSW_L_EN | RT5682_OSW_R_EN);
snd_soc_component_update_bits(component, RT5682_MICBIAS_2,
RT5682_PWR_CLK25M_MASK | RT5682_PWR_CLK1M_MASK,
RT5682_PWR_CLK25M_PU | RT5682_PWR_CLK1M_PU);
} else {
rt5682_enable_push_button_irq(component, false);
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW);
if (!snd_soc_dapm_get_pin_status(dapm, "MICBIAS") &&
!snd_soc_dapm_get_pin_status(dapm, "PLL1") &&
!snd_soc_dapm_get_pin_status(dapm, "PLL2B"))
snd_soc_component_update_bits(component,
RT5682_PWR_ANLG_1, RT5682_PWR_MB, 0);
if (!snd_soc_dapm_get_pin_status(dapm, "Vref2") &&
!snd_soc_dapm_get_pin_status(dapm, "PLL1") &&
!snd_soc_dapm_get_pin_status(dapm, "PLL2B"))
snd_soc_component_update_bits(component,
RT5682_PWR_ANLG_1, RT5682_PWR_VREF2, 0);
snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
RT5682_PWR_CBJ, 0);
snd_soc_component_update_bits(component, RT5682_MICBIAS_2,
RT5682_PWR_CLK25M_MASK | RT5682_PWR_CLK1M_MASK,
RT5682_PWR_CLK25M_PD | RT5682_PWR_CLK1M_PD);
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
RT5682_FAST_OFF_MASK, RT5682_FAST_OFF_DIS);
rt5682->jack_type = 0;
}
dev_dbg(component->dev, "jack_type = %d\n", rt5682->jack_type);
return rt5682->jack_type;
}
static int rt5682_set_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *hs_jack, void *data)
{
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
rt5682->hs_jack = hs_jack;
if (rt5682->is_sdw && !rt5682->first_hw_init)
return 0;
if (!hs_jack) {
regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,
RT5682_JD1_EN_MASK, RT5682_JD1_DIS);
regmap_update_bits(rt5682->regmap, RT5682_RC_CLK_CTRL,
RT5682_POW_JDH | RT5682_POW_JDL, 0);
cancel_delayed_work_sync(&rt5682->jack_detect_work);
return 0;
}
if (!rt5682->is_sdw) {
switch (rt5682->pdata.jd_src) {
case RT5682_JD1:
snd_soc_component_update_bits(component,
RT5682_CBJ_CTRL_5, 0x0700, 0x0600);
snd_soc_component_update_bits(component,
RT5682_CBJ_CTRL_2, RT5682_EXT_JD_SRC,
RT5682_EXT_JD_SRC_MANUAL);
snd_soc_component_write(component, RT5682_CBJ_CTRL_1,
0xd142);
snd_soc_component_update_bits(component,
RT5682_CBJ_CTRL_3, RT5682_CBJ_IN_BUF_EN,
RT5682_CBJ_IN_BUF_EN);
snd_soc_component_update_bits(component,
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/delay.h`, `linux/pm.h`, `linux/pm_runtime.h`, `linux/platform_device.h`, `linux/spi/spi.h`.
- Detected declarations: `function rt5682_apply_patch_list`, `function rt5682_volatile_register`, `function rt5682_readable_register`, `function rt5682_reset`, `function rt5682_sel_asrc_clk_src`, `function rt5682_button_detect`, `function rt5682_enable_push_button_irq`, `function rt5682_headset_detect`, `function rt5682_set_jack_detect`, `function rt5682_jack_detect_handler`.
- 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.
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.