sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c- Extension
.c- Size
- 24607 bytes
- Lines
- 888
- 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.
- 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/input.hlinux/module.hlinux/of.hlinux/pinctrl/consumer.hsound/jack.hsound/pcm_params.hsound/soc.h../../codecs/da7219.h../../codecs/rt1015.h../common/mtk-afe-platform-driver.hmt8183-afe-common.h
Detected Declarations
struct mt8183_da7219_max98357_privfunction mt8183_mt6358_i2s_hw_paramsfunction mt8183_da7219_i2s_hw_paramsfunction for_each_rtd_codec_daisfunction mt8183_da7219_hw_freefunction for_each_rtd_codec_daisfunction mt8183_da7219_rt1015_i2s_hw_paramsfunction for_each_rtd_codec_daisfunction mt8183_i2s_hw_params_fixupfunction mt8183_rt1015_i2s_hw_params_fixupfunction mt8183_da7219_max98357_startupfunction mt8183_da7219_max98357_bt_sco_startupfunction mt8183_da7219_max98357_hdmi_initfunction mt8183_bt_initfunction mt8183_da7219_initfunction mt8183_da7219_max98357_headset_initfunction mt8183_da7219_max98357_dev_probefunction for_each_card_prelinks
Annotated Snippet
struct mt8183_da7219_max98357_priv {
struct snd_soc_jack headset_jack, hdmi_jack;
};
static struct snd_soc_jack_pin mt8183_da7219_max98357_jack_pins[] = {
{
.pin = "Headphones",
.mask = SND_JACK_HEADPHONE,
},
{
.pin = "Headset Mic",
.mask = SND_JACK_MICROPHONE,
},
{
.pin = "Line Out",
.mask = SND_JACK_LINEOUT,
},
};
static int mt8183_mt6358_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
unsigned int rate = params_rate(params);
unsigned int mclk_fs_ratio = 128;
unsigned int mclk_fs = rate * mclk_fs_ratio;
return snd_soc_dai_set_sysclk(snd_soc_rtd_to_cpu(rtd, 0),
0, mclk_fs, SND_SOC_CLOCK_OUT);
}
static const struct snd_soc_ops mt8183_mt6358_i2s_ops = {
.hw_params = mt8183_mt6358_i2s_hw_params,
};
static int mt8183_da7219_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_dai *codec_dai;
unsigned int rate = params_rate(params);
unsigned int mclk_fs_ratio = 256;
unsigned int mclk_fs = rate * mclk_fs_ratio;
unsigned int freq;
int ret = 0, j;
ret = snd_soc_dai_set_sysclk(snd_soc_rtd_to_cpu(rtd, 0), 0,
mclk_fs, SND_SOC_CLOCK_OUT);
if (ret < 0)
dev_err(rtd->dev, "failed to set cpu dai sysclk\n");
for_each_rtd_codec_dais(rtd, j, codec_dai) {
if (!strcmp(codec_dai->component->name, DA7219_DEV_NAME)) {
ret = snd_soc_dai_set_sysclk(codec_dai,
DA7219_CLKSRC_MCLK,
mclk_fs,
SND_SOC_CLOCK_IN);
if (ret < 0)
dev_err(rtd->dev, "failed to set sysclk\n");
if ((rate % 8000) == 0)
freq = DA7219_PLL_FREQ_OUT_98304;
else
freq = DA7219_PLL_FREQ_OUT_90316;
ret = snd_soc_dai_set_pll(codec_dai, 0,
DA7219_SYSCLK_PLL_SRM,
0, freq);
if (ret)
dev_err(rtd->dev, "failed to start PLL: %d\n",
ret);
}
}
return ret;
}
static int mt8183_da7219_hw_free(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_dai *codec_dai;
int ret = 0, j;
for_each_rtd_codec_dais(rtd, j, codec_dai) {
if (!strcmp(codec_dai->component->name, DA7219_DEV_NAME)) {
ret = snd_soc_dai_set_pll(codec_dai,
0, DA7219_SYSCLK_MCLK, 0, 0);
if (ret < 0) {
dev_err(rtd->dev, "failed to stop PLL: %d\n",
ret);
Annotation
- Immediate include surface: `linux/input.h`, `linux/module.h`, `linux/of.h`, `linux/pinctrl/consumer.h`, `sound/jack.h`, `sound/pcm_params.h`, `sound/soc.h`, `../../codecs/da7219.h`.
- Detected declarations: `struct mt8183_da7219_max98357_priv`, `function mt8183_mt6358_i2s_hw_params`, `function mt8183_da7219_i2s_hw_params`, `function for_each_rtd_codec_dais`, `function mt8183_da7219_hw_free`, `function for_each_rtd_codec_dais`, `function mt8183_da7219_rt1015_i2s_hw_params`, `function for_each_rtd_codec_dais`, `function mt8183_i2s_hw_params_fixup`, `function mt8183_rt1015_i2s_hw_params_fixup`.
- 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.