sound/soc/mediatek/mt8365/mt8365-dai-adda.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8365/mt8365-dai-adda.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8365/mt8365-dai-adda.c- Extension
.c- Size
- 8808 bytes
- Lines
- 306
- 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/bitops.hlinux/regmap.hsound/pcm_params.hmt8365-afe-clk.hmt8365-afe-common.h../common/mtk-dai-adda-common.h
Detected Declarations
function mt8365_dai_set_adda_outfunction mt8365_dai_set_adda_infunction mt8365_dai_enable_adda_onfunction mt8365_dai_disable_adda_onfunction mt8365_dai_set_adda_out_enablefunction mt8365_dai_set_adda_in_enablefunction mt8365_dai_int_adda_startupfunction mt8365_dai_int_adda_shutdownfunction mt8365_dai_int_adda_preparefunction mt8365_dai_adda_register
Annotated Snippet
else if (adda_afe_on_ref_cnt < 0) {
adda_afe_on_ref_cnt = 0;
dev_warn(afe->dev, "Abnormal adda_on ref count. Force it to 0\n");
}
return 0;
}
static void mt8365_dai_set_adda_out_enable(struct mtk_base_afe *afe,
bool enable)
{
regmap_update_bits(afe->regmap, AFE_ADDA_DL_SRC2_CON0, 0x1, enable);
if (enable)
mt8365_dai_enable_adda_on(afe);
else
mt8365_dai_disable_adda_on(afe);
}
static void mt8365_dai_set_adda_in_enable(struct mtk_base_afe *afe, bool enable)
{
if (enable) {
regmap_update_bits(afe->regmap, AFE_ADDA_UL_SRC_CON0, 0x1, 0x1);
mt8365_dai_enable_adda_on(afe);
/* enable aud_pad_top fifo */
regmap_update_bits(afe->regmap, AFE_AUD_PAD_TOP,
0xffffffff, 0x31);
} else {
/* disable aud_pad_top fifo */
regmap_update_bits(afe->regmap, AFE_AUD_PAD_TOP,
0xffffffff, 0x30);
regmap_update_bits(afe->regmap, AFE_ADDA_UL_SRC_CON0, 0x1, 0x0);
/* de suggest disable ADDA_UL_SRC at least wait 125us */
usleep_range(150, 300);
mt8365_dai_disable_adda_on(afe);
}
}
static int mt8365_dai_int_adda_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
unsigned int stream = substream->stream;
mt8365_afe_enable_main_clk(afe);
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
mt8365_afe_enable_top_cg(afe, MT8365_TOP_CG_DAC);
mt8365_afe_enable_top_cg(afe, MT8365_TOP_CG_DAC_PREDIS);
} else if (stream == SNDRV_PCM_STREAM_CAPTURE) {
mt8365_afe_enable_top_cg(afe, MT8365_TOP_CG_ADC);
}
return 0;
}
static void mt8365_dai_int_adda_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
struct mt8365_afe_private *afe_priv = afe->platform_priv;
struct mt8365_be_dai_data *be =
&afe_priv->be_data[dai->id - MT8365_AFE_BACKEND_BASE];
unsigned int stream = substream->stream;
if (be->prepared[stream]) {
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
mt8365_dai_set_adda_out_enable(afe, false);
mt8365_afe_set_i2s_out_enable(afe, false);
} else {
mt8365_dai_set_adda_in_enable(afe, false);
}
be->prepared[stream] = false;
}
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
mt8365_afe_disable_top_cg(afe, MT8365_TOP_CG_DAC_PREDIS);
mt8365_afe_disable_top_cg(afe, MT8365_TOP_CG_DAC);
} else if (stream == SNDRV_PCM_STREAM_CAPTURE) {
mt8365_afe_disable_top_cg(afe, MT8365_TOP_CG_ADC);
}
mt8365_afe_disable_main_clk(afe);
}
static int mt8365_dai_int_adda_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
struct mt8365_afe_private *afe_priv = afe->platform_priv;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/regmap.h`, `sound/pcm_params.h`, `mt8365-afe-clk.h`, `mt8365-afe-common.h`, `../common/mtk-dai-adda-common.h`.
- Detected declarations: `function mt8365_dai_set_adda_out`, `function mt8365_dai_set_adda_in`, `function mt8365_dai_enable_adda_on`, `function mt8365_dai_disable_adda_on`, `function mt8365_dai_set_adda_out_enable`, `function mt8365_dai_set_adda_in_enable`, `function mt8365_dai_int_adda_startup`, `function mt8365_dai_int_adda_shutdown`, `function mt8365_dai_int_adda_prepare`, `function mt8365_dai_adda_register`.
- 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.