sound/soc/codecs/rt5651.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt5651.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt5651.c- Extension
.c- Size
- 71196 bytes
- Lines
- 2293
- 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.
- 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/init.hlinux/delay.hlinux/pm.hlinux/gpio/consumer.hlinux/i2c.hlinux/regmap.hlinux/platform_device.hlinux/spi/spi.hlinux/acpi.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-dapm.hsound/initval.hsound/tlv.hsound/jack.hrl6231.hrt5651.h
Detected Declarations
function rt5651_volatile_registerfunction rt5651_readable_registerfunction set_dmic_clkfunction rt5651_amp_power_eventfunction rt5651_hp_eventfunction rt5651_hp_post_eventfunction rt5651_bst1_eventfunction rt5651_bst2_eventfunction rt5651_bst3_eventfunction rt5651_hw_paramsfunction rt5651_set_dai_fmtfunction rt5651_set_dai_sysclkfunction rt5651_set_dai_pllfunction rt5651_set_bias_levelfunction rt5651_enable_micbias1_for_ovcdfunction rt5651_disable_micbias1_for_ovcdfunction rt5651_enable_micbias1_ovcd_irqfunction rt5651_disable_micbias1_ovcd_irqfunction rt5651_clear_micbias1_ovcdfunction rt5651_micbias1_ovcdfunction rt5651_jack_insertedfunction rt5651_start_button_press_workfunction rt5651_button_press_workfunction rt5651_detect_headsetfunction rt5651_support_button_pressfunction rt5651_jack_detect_workfunction rt5651_irqfunction rt5651_cancel_workfunction rt5651_enable_jack_detectfunction rt5651_disable_jack_detectfunction rt5651_set_jackfunction snd_soc_register_cardfunction rt5651_probefunction rt5651_suspendfunction rt5651_resumefunction rt5651_apply_properties
Annotated Snippet
if (SND_SOC_BIAS_STANDBY == snd_soc_dapm_get_bias_level(dapm)) {
if (snd_soc_component_read(component, RT5651_PLL_MODE_1) & 0x9200)
snd_soc_component_update_bits(component, RT5651_D_MISC,
0xc00, 0xc00);
}
break;
case SND_SOC_BIAS_STANDBY:
if (SND_SOC_BIAS_OFF == snd_soc_dapm_get_bias_level(dapm)) {
snd_soc_component_update_bits(component, RT5651_PWR_ANLG1,
RT5651_PWR_VREF1 | RT5651_PWR_MB |
RT5651_PWR_BG | RT5651_PWR_VREF2,
RT5651_PWR_VREF1 | RT5651_PWR_MB |
RT5651_PWR_BG | RT5651_PWR_VREF2);
usleep_range(10000, 15000);
snd_soc_component_update_bits(component, RT5651_PWR_ANLG1,
RT5651_PWR_FV1 | RT5651_PWR_FV2,
RT5651_PWR_FV1 | RT5651_PWR_FV2);
snd_soc_component_update_bits(component, RT5651_D_MISC, 0x1, 0x1);
}
break;
case SND_SOC_BIAS_OFF:
snd_soc_component_write(component, RT5651_D_MISC, 0x0010);
snd_soc_component_write(component, RT5651_PWR_DIG1, 0x0000);
snd_soc_component_write(component, RT5651_PWR_DIG2, 0x0000);
snd_soc_component_write(component, RT5651_PWR_VOL, 0x0000);
snd_soc_component_write(component, RT5651_PWR_MIXER, 0x0000);
/* Do not touch the LDO voltage select bits on bias-off */
snd_soc_component_update_bits(component, RT5651_PWR_ANLG1,
~RT5651_PWR_LDO_DVO_MASK, 0);
/* Leave PLL1 and jack-detect power as is, all others off */
snd_soc_component_update_bits(component, RT5651_PWR_ANLG2,
~(RT5651_PWR_PLL | RT5651_PWR_JD_M), 0);
break;
default:
break;
}
return 0;
}
static void rt5651_enable_micbias1_for_ovcd(struct snd_soc_component *component)
{
struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
snd_soc_dapm_mutex_lock(dapm);
snd_soc_dapm_force_enable_pin_unlocked(dapm, "LDO");
snd_soc_dapm_force_enable_pin_unlocked(dapm, "micbias1");
/* OVCD is unreliable when used with RCCLK as sysclk-source */
snd_soc_dapm_force_enable_pin_unlocked(dapm, "Platform Clock");
snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
}
static void rt5651_disable_micbias1_for_ovcd(struct snd_soc_component *component)
{
struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
snd_soc_dapm_mutex_lock(dapm);
snd_soc_dapm_disable_pin_unlocked(dapm, "Platform Clock");
snd_soc_dapm_disable_pin_unlocked(dapm, "micbias1");
snd_soc_dapm_disable_pin_unlocked(dapm, "LDO");
snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
}
static void rt5651_enable_micbias1_ovcd_irq(struct snd_soc_component *component)
{
struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component);
snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2,
RT5651_IRQ_MB1_OC_MASK, RT5651_IRQ_MB1_OC_NOR);
rt5651->ovcd_irq_enabled = true;
}
static void rt5651_disable_micbias1_ovcd_irq(struct snd_soc_component *component)
{
struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component);
snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2,
RT5651_IRQ_MB1_OC_MASK, RT5651_IRQ_MB1_OC_BP);
rt5651->ovcd_irq_enabled = false;
}
static void rt5651_clear_micbias1_ovcd(struct snd_soc_component *component)
{
snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2,
RT5651_MB1_OC_CLR, 0);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/delay.h`, `linux/pm.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/regmap.h`, `linux/platform_device.h`.
- Detected declarations: `function rt5651_volatile_register`, `function rt5651_readable_register`, `function set_dmic_clk`, `function rt5651_amp_power_event`, `function rt5651_hp_event`, `function rt5651_hp_post_event`, `function rt5651_bst1_event`, `function rt5651_bst2_event`, `function rt5651_bst3_event`, `function rt5651_hw_params`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source 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.