sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c- Extension
.c- Size
- 25476 bytes
- Lines
- 900
- 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/module.hlinux/of.hlinux/pinctrl/consumer.hsound/jack.hsound/pcm_params.hsound/soc.h../../codecs/rt1015.h../../codecs/ts3a227e.h../common/mtk-afe-platform-driver.hmt8183-afe-common.h
Detected Declarations
struct mt8183_mt6358_ts3a227_max98357_privenum PINCTRL_PIN_STATEfunction mt8183_mt6358_i2s_hw_paramsfunction mt8183_mt6358_rt1015_i2s_hw_paramsfunction for_each_rtd_codec_daisfunction mt8183_i2s_hw_params_fixupfunction mt8183_rt1015_i2s_hw_params_fixupfunction mt8183_mt6358_startupfunction mt8183_mt6358_ts3a227_max98357_bt_sco_startupfunction mt8183_mt6358_tdm_startupfunction mt8183_mt6358_tdm_shutdownfunction mt8183_mt6358_ts3a227_max98357_wov_startupfunction mt8183_mt6358_ts3a227_max98357_wov_shutdownfunction mt8183_mt6358_ts3a227_max98357_hdmi_initfunction mt8183_bt_initfunction mt8183_i2s2_initfunction mt8183_mt6358_ts3a227_max98357_headset_initfunction mt8183_mt6358_ts3a227_max98357_dev_probefunction for_each_card_prelinks
Annotated Snippet
struct mt8183_mt6358_ts3a227_max98357_priv {
struct pinctrl *pinctrl;
struct pinctrl_state *pin_states[PIN_STATE_MAX];
struct snd_soc_jack headset_jack, hdmi_jack;
};
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_mt6358_rt1015_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;
struct snd_soc_card *card = rtd->card;
struct snd_soc_dai *codec_dai;
int ret, i;
for_each_rtd_codec_dais(rtd, i, codec_dai) {
ret = snd_soc_dai_set_pll(codec_dai, 0, RT1015_PLL_S_BCLK,
rate * 64, rate * 256);
if (ret < 0) {
dev_err(card->dev, "failed to set pll\n");
return ret;
}
ret = snd_soc_dai_set_sysclk(codec_dai, RT1015_SCLK_S_PLL,
rate * 256, SND_SOC_CLOCK_IN);
if (ret < 0) {
dev_err(card->dev, "failed to set sysclk\n");
return ret;
}
}
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_rt1015_i2s_ops = {
.hw_params = mt8183_mt6358_rt1015_i2s_hw_params,
};
static int mt8183_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params)
{
dev_dbg(rtd->dev, "%s(), fix format to S32_LE\n", __func__);
/* fix BE i2s format to S32_LE, clean param mask first */
snd_mask_reset_range(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT),
0, (__force unsigned int)SNDRV_PCM_FORMAT_LAST);
params_set_format(params, SNDRV_PCM_FORMAT_S32_LE);
return 0;
}
static int mt8183_rt1015_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params)
{
dev_dbg(rtd->dev, "%s(), fix format to S24_LE\n", __func__);
/* fix BE i2s format to S24_LE, clean param mask first */
snd_mask_reset_range(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT),
0, (__force unsigned int)SNDRV_PCM_FORMAT_LAST);
params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
return 0;
}
static int
mt8183_mt6358_startup(struct snd_pcm_substream *substream)
{
static const unsigned int rates[] = {
48000,
};
Annotation
- Immediate include surface: `linux/module.h`, `linux/of.h`, `linux/pinctrl/consumer.h`, `sound/jack.h`, `sound/pcm_params.h`, `sound/soc.h`, `../../codecs/rt1015.h`, `../../codecs/ts3a227e.h`.
- Detected declarations: `struct mt8183_mt6358_ts3a227_max98357_priv`, `enum PINCTRL_PIN_STATE`, `function mt8183_mt6358_i2s_hw_params`, `function mt8183_mt6358_rt1015_i2s_hw_params`, `function for_each_rtd_codec_dais`, `function mt8183_i2s_hw_params_fixup`, `function mt8183_rt1015_i2s_hw_params_fixup`, `function mt8183_mt6358_startup`, `function mt8183_mt6358_ts3a227_max98357_bt_sco_startup`, `function mt8183_mt6358_tdm_startup`.
- 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.