sound/soc/codecs/rt5682s.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt5682s.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt5682s.c- Extension
.c- Size
- 102446 bytes
- Lines
- 3350
- 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/i2c.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/rt5682s.hrt5682s.h
Detected Declarations
function rt5682s_apply_patch_listfunction rt5682s_volatile_registerfunction rt5682s_readable_registerfunction rt5682s_resetfunction rt5682s_button_detectfunction rt5682s_sar_power_modefunction rt5682s_enable_push_button_irqfunction rt5682s_disable_push_button_irqfunction rt5682s_headset_detectfunction rt5682s_jack_detect_handlerfunction rt5682s_jd_check_handlerfunction rt5682s_irqfunction rt5682s_set_jack_detectfunction rt5682s_sel_asrc_clk_srcfunction rt5682s_div_selfunction get_clk_infofunction set_dmic_clkfunction rt5682s_set_pllb_powerfunction set_pllb_eventfunction rt5682s_set_filter_clkfunction set_filter_clkfunction set_dmic_powerfunction rt5682s_set_i2sfunction set_i2s_eventfunction is_sys_clk_from_pllafunction is_sys_clk_from_pllbfunction is_using_asrcfunction rt5682s_hp_amp_eventfunction rt5682s_stereo1_adc_mixl_eventfunction sar_power_eventfunction rt5682s_set_tdm_slotfunction rt5682s_hw_paramsfunction rt5682s_set_dai_fmtfunction rt5682s_set_component_sysclkfunction find_pll_inter_combinationfunction rt5682s_set_component_pllfunction rt5682s_set_bclk1_ratiofunction rt5682s_set_bclk2_ratiofunction rt5682s_set_bias_levelfunction rt5682s_clk_checkfunction rt5682s_wclk_preparefunction rt5682s_wclk_unpreparefunction rt5682s_wclk_recalc_ratefunction rt5682s_wclk_determine_ratefunction rt5682s_wclk_set_ratefunction rt5682s_bclk_recalc_ratefunction rt5682s_bclk_get_factorfunction rt5682s_bclk_determine_rate
Annotated Snippet
switch (val) {
case 0x1:
case 0x2:
jack_type = SND_JACK_HEADSET;
snd_soc_component_write(component, RT5682S_SAR_IL_CMD_3, 0x024c);
snd_soc_component_update_bits(component, RT5682S_CBJ_CTRL_1,
RT5682S_FAST_OFF_MASK, RT5682S_FAST_OFF_DIS);
snd_soc_component_update_bits(component, RT5682S_SAR_IL_CMD_1,
RT5682S_SAR_SEL_MB1_2_MASK, val << RT5682S_SAR_SEL_MB1_2_SFT);
rt5682s_enable_push_button_irq(component);
rt5682s_sar_power_mode(component, SAR_PWR_SAVING);
break;
default:
jack_type = SND_JACK_HEADPHONE;
break;
}
snd_soc_component_update_bits(component, RT5682S_HP_CHARGE_PUMP_2,
RT5682S_OSW_L_MASK | RT5682S_OSW_R_MASK,
RT5682S_OSW_L_EN | RT5682S_OSW_R_EN);
usleep_range(35000, 40000);
} else {
rt5682s_sar_power_mode(component, SAR_PWR_OFF);
rt5682s_disable_push_button_irq(component);
snd_soc_component_update_bits(component, RT5682S_CBJ_CTRL_1,
RT5682S_TRIG_JD_MASK, RT5682S_TRIG_JD_LOW);
if (!rt5682s->wclk_enabled) {
snd_soc_component_update_bits(component,
RT5682S_PWR_ANLG_1, RT5682S_PWR_VREF2 | RT5682S_PWR_MB, 0);
}
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_3,
RT5682S_PWR_CBJ, 0);
snd_soc_component_update_bits(component, RT5682S_CBJ_CTRL_1,
RT5682S_FAST_OFF_MASK, RT5682S_FAST_OFF_DIS);
snd_soc_component_update_bits(component, RT5682S_CBJ_CTRL_3,
RT5682S_CBJ_IN_BUF_MASK, RT5682S_CBJ_IN_BUF_DIS);
jack_type = 0;
}
dev_dbg(component->dev, "jack_type = %d\n", jack_type);
return jack_type;
}
static void rt5682s_jack_detect_handler(struct work_struct *work)
{
struct rt5682s_priv *rt5682s =
container_of(work, struct rt5682s_priv, jack_detect_work.work);
struct snd_soc_dapm_context *dapm;
int val, btn_type;
if (!rt5682s->component ||
!snd_soc_card_is_instantiated(rt5682s->component->card)) {
/* card not yet ready, try later */
mod_delayed_work(system_power_efficient_wq,
&rt5682s->jack_detect_work, msecs_to_jiffies(15));
return;
}
dapm = snd_soc_component_to_dapm(rt5682s->component);
snd_soc_dapm_mutex_lock(dapm);
mutex_lock(&rt5682s->calibrate_mutex);
mutex_lock(&rt5682s->wclk_mutex);
val = snd_soc_component_read(rt5682s->component, RT5682S_AJD1_CTRL)
& RT5682S_JDH_RS_MASK;
if (!val) {
/* jack in */
if (rt5682s->jack_type == 0) {
/* jack was out, report jack type */
rt5682s->jack_type = rt5682s_headset_detect(rt5682s->component, 1);
rt5682s->irq_work_delay_time = 0;
} else if ((rt5682s->jack_type & SND_JACK_HEADSET) == SND_JACK_HEADSET) {
/* jack is already in, report button event */
rt5682s->jack_type = SND_JACK_HEADSET;
btn_type = rt5682s_button_detect(rt5682s->component);
/**
* rt5682s can report three kinds of button behavior,
* one click, double click and hold. However,
* currently we will report button pressed/released
* event. So all the three button behaviors are
* treated as button pressed.
*/
switch (btn_type) {
case 0x8000:
case 0x4000:
case 0x2000:
rt5682s->jack_type |= SND_JACK_BTN_0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/delay.h`, `linux/pm.h`, `linux/i2c.h`, `linux/platform_device.h`, `linux/spi/spi.h`.
- Detected declarations: `function rt5682s_apply_patch_list`, `function rt5682s_volatile_register`, `function rt5682s_readable_register`, `function rt5682s_reset`, `function rt5682s_button_detect`, `function rt5682s_sar_power_mode`, `function rt5682s_enable_push_button_irq`, `function rt5682s_disable_push_button_irq`, `function rt5682s_headset_detect`, `function rt5682s_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.
- 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.