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.

Dependency Surface

Detected Declarations

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

Implementation Notes