sound/soc/intel/boards/sof_rt5682.c
Source file repositories/reference/linux-study-clean/sound/soc/intel/boards/sof_rt5682.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/intel/boards/sof_rt5682.c- Extension
.c- Size
- 24915 bytes
- Lines
- 943
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/i2c.hlinux/input.hlinux/module.hlinux/platform_device.hlinux/clk.hlinux/dmi.hsound/core.hsound/jack.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/sof.hsound/rt5682.hsound/rt5682s.hsound/soc-acpi.h../../codecs/rt5682.h../../codecs/rt5682s.h../../codecs/rt5645.h../common/soc-intel-quirks.hsof_board_helpers.hsof_maxim_common.hsof_realtek_common.hsof_ti_common.h
Detected Declarations
function sof_rt5682_quirk_cbfunction sof_rt5682_codec_initfunction sof_rt5682_codec_exitfunction sof_rt5682_hw_paramsfunction sof_card_late_probefunction rt5650_spk_initfunction sof_card_dai_links_createfunction sof_audio_probe
Annotated Snippet
if (mclk_freq <= 0) {
dev_err(rtd->dev, "invalid mclk freq %d\n", mclk_freq);
return -EINVAL;
}
/* need to enable ASRC function for 24MHz mclk rate */
if (mclk_freq == 24000000) {
dev_info(rtd->dev, "enable ASRC\n");
switch (ctx->codec_type) {
case CODEC_RT5650:
rt5645_sel_asrc_clk_src(component,
RT5645_DA_STEREO_FILTER |
RT5645_AD_STEREO_FILTER,
RT5645_CLK_SEL_I2S1_ASRC);
rt5645_sel_asrc_clk_src(component,
RT5645_DA_MONO_L_FILTER |
RT5645_DA_MONO_R_FILTER,
RT5645_CLK_SEL_I2S2_ASRC);
break;
case CODEC_RT5682:
rt5682_sel_asrc_clk_src(component,
RT5682_DA_STEREO1_FILTER |
RT5682_AD_STEREO1_FILTER,
RT5682_CLK_SEL_I2S1_ASRC);
break;
case CODEC_RT5682S:
rt5682s_sel_asrc_clk_src(component,
RT5682S_DA_STEREO1_FILTER |
RT5682S_AD_STEREO1_FILTER,
RT5682S_CLK_SEL_I2S1_ASRC);
break;
default:
dev_err(rtd->dev, "invalid codec type %d\n",
ctx->codec_type);
return -EINVAL;
}
}
if (ctx->rt5682.is_legacy_cpu) {
/*
* The firmware might enable the clock at
* boot (this information may or may not
* be reflected in the enable clock register).
* To change the rate we must disable the clock
* first to cover these cases. Due to common
* clock framework restrictions that do not allow
* to disable a clock that has not been enabled,
* we need to enable the clock first.
*/
ret = clk_prepare_enable(ctx->rt5682.mclk);
if (!ret)
clk_disable_unprepare(ctx->rt5682.mclk);
ret = clk_set_rate(ctx->rt5682.mclk, 19200000);
if (ret)
dev_err(rtd->dev, "unable to set MCLK rate\n");
}
}
/*
* Headset buttons map to the google Reference headset.
* These can be configured by userspace.
*/
ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
SND_JACK_HEADSET | SND_JACK_BTN_0 |
SND_JACK_BTN_1 | SND_JACK_BTN_2 |
SND_JACK_BTN_3,
jack,
jack_pins,
ARRAY_SIZE(jack_pins));
if (ret) {
dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
return ret;
}
snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
if (ctx->codec_type == CODEC_RT5650) {
extra_jack_data = SND_JACK_MICROPHONE | SND_JACK_BTN_0;
ret = snd_soc_component_set_jack(component, jack, &extra_jack_data);
} else
ret = snd_soc_component_set_jack(component, jack, NULL);
if (ret) {
dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/input.h`, `linux/module.h`, `linux/platform_device.h`, `linux/clk.h`, `linux/dmi.h`, `sound/core.h`, `sound/jack.h`.
- Detected declarations: `function sof_rt5682_quirk_cb`, `function sof_rt5682_codec_init`, `function sof_rt5682_codec_exit`, `function sof_rt5682_hw_params`, `function sof_card_late_probe`, `function rt5650_spk_init`, `function sof_card_dai_links_create`, `function sof_audio_probe`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source 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.