[PATCH] ASoC: mediatek: mt8195: Fix ETDM3_OUT DAI startup error

From: Louis-Alexis Eyraud

Date: Thu Nov 12 2026 - 06:35:10 EST


mtk_dai_hdmitx_dptx_startup(), used by both ETDM3_OUT and DPTX DAI as
startup callbacks, calls mtk_dai_etdm_enable_mclk() to enable the MCLK
clock linked to the giveb DAI.
For ETDM3_OUT DAI case, mtk_dai_etdm_enable_mclk() always returns
EINVAL error because no clock divider is mapped for this DAI in
mtk_dai_etdm_get_clkdiv_id_by_dai_id(), contrary to DPTX DAI that has
one mapped, and this lookup failure is processed as an error.

Since commit 1d6f1785d903 ("ASoC: mediatek: mt8195: Fix HDMI TX startup
error handling"), mtk_dai_hdmitx_dptx_startup() now propagates the
error returned by mtk_dai_etdm_enable_mclk() and it leads the ETDM3_OUT
DAI startup to fail systematically. The error was previously present
but since it was silently ignored, the startup sequence could continue
anyway.

Same thing also occurs in mtk_dai_hdmitx_dptx_shutdown(), when calling
mtk_dai_etdm_disable_mclk(), that also returns EINVAL for this DAI and
for the same reason. But its return code is not checked in
mtk_dai_hdmitx_dptx_shutdown, so the error has no effect.

Since there is no need to enable or disable the MCLK for ETDM3_OUT DAI,
and no benefit to handle a systematic error, that could be avoided in
the first place, add dedicated startup and shutdown callbacks to only
perform the needed actions for this DAI.

Fixes: 1d6f1785d903 ("ASoC: mediatek: mt8195: Fix HDMI TX startup error handling")
Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@xxxxxxxxxxxxx>
---
The patch has been tested on Mediatek Genio 1200-EVK board, that
integrates a MT8395 SoC (variant of MT8195) with a kernel based on
linux-next tree (tag: next-20261111) plus patch [1].

Note that the issue root cause was also detected by Sashiko during its
"ASoC: mediatek: mt8195: Fix HDMI TX startup error handling" patch
review ([2]).

[1]: https://lore.kernel.org/linux-sound/20261109102536.357134-1-ghidoliemanuele@xxxxxxxxx/
[2]: https://sashiko.dev/#/patchset/20261014112752.683032-1-phucduc.bui%40gmail.com?part=14
---
sound/soc/mediatek/mt8195/mt8195-dai-etdm.c | 30 +++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c b/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c
index 5fe40299ec80..1806ddc46708 100644
--- a/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c
+++ b/sound/soc/mediatek/mt8195/mt8195-dai-etdm.c
@@ -2355,6 +2355,32 @@ static void mtk_dai_hdmitx_dptx_shutdown(struct snd_pcm_substream *substream,
mt8195_afe_disable_clk(afe, afe_priv->clk[cg_id]);
}

+static int mtk_dai_etdm3_startup(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+ struct mt8195_afe_private *afe_priv = afe->platform_priv;
+ int cg_id = mtk_dai_etdm_get_cg_id_by_dai_id(dai->id);
+
+ if (cg_id < 0)
+ return -EINVAL;
+
+ return mt8195_afe_enable_clk(afe, afe_priv->clk[cg_id]);
+}
+
+static void mtk_dai_etdm3_shutdown(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
+ struct mt8195_afe_private *afe_priv = afe->platform_priv;
+ int cg_id = mtk_dai_etdm_get_cg_id_by_dai_id(dai->id);
+
+ if (cg_id < 0)
+ return;
+
+ mt8195_afe_disable_clk(afe, afe_priv->clk[cg_id]);
+}
+
static unsigned int mtk_dai_get_dptx_ch_en(unsigned int channel)
{
switch (channel) {
@@ -2541,8 +2567,8 @@ static const struct snd_soc_dai_ops mtk_dai_hdmitx_dptx_ops = {

static const struct snd_soc_dai_ops mtk_dai_hdmitx_dptx_ops2 = {
.probe = mtk_dai_etdm_probe,
- .startup = mtk_dai_hdmitx_dptx_startup,
- .shutdown = mtk_dai_hdmitx_dptx_shutdown,
+ .startup = mtk_dai_etdm3_startup,
+ .shutdown = mtk_dai_etdm3_shutdown,
.hw_params = mtk_dai_hdmitx_dptx_hw_params,
.trigger = mtk_dai_hdmitx_dptx_trigger,
.set_sysclk = mtk_dai_hdmitx_dptx_set_sysclk,

---
base-commit: 6aa7dbf8ad5ebd3babf53a4d6209018f86939f17
change-id: 20261112-mt8195-dai-etdm-fix-startup-285e69075f3e

Best regards,
--
Louis-Alexis Eyraud <louisalexis.eyraud@xxxxxxxxxxxxx>