sound/soc/codecs/rt5670.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt5670.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt5670.c- Extension
.c- Size
- 103971 bytes
- Lines
- 3346
- 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.
- 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/pm_runtime.hlinux/i2c.hlinux/platform_device.hlinux/acpi.hlinux/spi/spi.hlinux/dmi.hsound/core.hsound/pcm.hsound/pcm_params.hsound/jack.hsound/soc.hsound/soc-dapm.hsound/initval.hsound/tlv.hrl6231.hrt5670.hrt5670-dsp.h
Detected Declarations
function rt5670_volatile_registerfunction rt5670_readable_registerfunction rt5670_headset_detectfunction rt5670_jack_suspendfunction rt5670_jack_resumefunction rt5670_button_detectfunction rt5670_irq_detectionfunction rt5670_set_jack_detectfunction rt5670_update_ad_da_mixer_dac1_m_bitsfunction rt5670_dac1_playback_switch_getfunction rt5670_dac1_playback_switch_putfunction set_dmic_clkfunction is_sys_clk_from_pllfunction is_using_asrcfunction can_use_asrcfunction rt5670_sel_asrc_clk_srcfunction rt5670_put_dac1_mix_dac1_switchfunction rt5670_hp_power_eventfunction rt5670_hp_eventfunction rt5670_spk_eventfunction rt5670_bst1_eventfunction rt5670_bst2_eventfunction rt5670_hw_paramsfunction rt5670_set_dai_fmtfunction rt5670_set_codec_sysclkfunction rt5670_set_dai_pllfunction rt5670_set_tdm_slotfunction rt5670_set_bclk_ratiofunction rt5670_set_bias_levelfunction rt5670_probefunction rt5670_removefunction rt5670_suspendfunction rt5670_resumefunction rt5670_quirk_cbfunction rt5670_i2c_probefunction rt5670_i2c_removeexport rt5670_jack_suspendexport rt5670_jack_resumeexport rt5670_set_jack_detectexport rt5670_sel_asrc_clk_srcexport rt5670_components
Annotated Snippet
if (val == 0x1 || val == 0x2) {
rt5670->jack_type = SND_JACK_HEADSET;
/* for push button */
snd_soc_component_update_bits(component, RT5670_INT_IRQ_ST, 0x8, 0x8);
snd_soc_component_update_bits(component, RT5670_IL_CMD, 0x40, 0x40);
snd_soc_component_read(component, RT5670_IL_CMD);
} else {
snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x4);
rt5670->jack_type = SND_JACK_HEADPHONE;
snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
snd_soc_dapm_sync(dapm);
}
} else {
snd_soc_component_update_bits(component, RT5670_INT_IRQ_ST, 0x8, 0x0);
snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x4);
rt5670->jack_type = 0;
snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
snd_soc_dapm_sync(dapm);
}
return rt5670->jack_type;
}
void rt5670_jack_suspend(struct snd_soc_component *component)
{
struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component);
rt5670->jack_type_saved = rt5670->jack_type;
rt5670_headset_detect(component, 0);
}
EXPORT_SYMBOL_GPL(rt5670_jack_suspend);
void rt5670_jack_resume(struct snd_soc_component *component)
{
struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component);
if (rt5670->jack_type_saved)
rt5670_headset_detect(component, 1);
}
EXPORT_SYMBOL_GPL(rt5670_jack_resume);
static int rt5670_button_detect(struct snd_soc_component *component)
{
int btn_type, val;
val = snd_soc_component_read(component, RT5670_IL_CMD);
btn_type = val & 0xff80;
snd_soc_component_write(component, RT5670_IL_CMD, val);
if (btn_type != 0) {
msleep(20);
val = snd_soc_component_read(component, RT5670_IL_CMD);
snd_soc_component_write(component, RT5670_IL_CMD, val);
}
return btn_type;
}
static int rt5670_irq_detection(void *data)
{
struct rt5670_priv *rt5670 = (struct rt5670_priv *)data;
struct snd_soc_jack_gpio *gpio = &rt5670->hp_gpio;
struct snd_soc_jack *jack = rt5670->jack;
int val, btn_type, report = jack->status;
if (rt5670->jd_mode == 1) /* 2 port */
val = snd_soc_component_read(rt5670->component, RT5670_A_JD_CTRL1) & 0x0070;
else
val = snd_soc_component_read(rt5670->component, RT5670_A_JD_CTRL1) & 0x0020;
switch (val) {
/* jack in */
case 0x30: /* 2 port */
case 0x0: /* 1 port or 2 port */
if (rt5670->jack_type == 0) {
report = rt5670_headset_detect(rt5670->component, 1);
/* for push button and jack out */
gpio->debounce_time = 25;
break;
}
btn_type = 0;
if (snd_soc_component_read(rt5670->component, RT5670_INT_IRQ_ST) & 0x4) {
/* button pressed */
report = SND_JACK_HEADSET;
btn_type = rt5670_button_detect(rt5670->component);
switch (btn_type) {
case 0x2000: /* up */
report |= SND_JACK_BTN_1;
break;
case 0x0400: /* center */
report |= SND_JACK_BTN_0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/delay.h`, `linux/pm.h`, `linux/pm_runtime.h`, `linux/i2c.h`, `linux/platform_device.h`.
- Detected declarations: `function rt5670_volatile_register`, `function rt5670_readable_register`, `function rt5670_headset_detect`, `function rt5670_jack_suspend`, `function rt5670_jack_resume`, `function rt5670_button_detect`, `function rt5670_irq_detection`, `function rt5670_set_jack_detect`, `function rt5670_update_ad_da_mixer_dac1_m_bits`, `function rt5670_dac1_playback_switch_get`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.