Skip to content

Commit 91ab967

Browse files
wenliangwupull[bot]
authored andcommitted
ASoC: mediatek: mt8188-mt6359: support dynamic pinctrl
To avoid power leakage, it is recommended to replace the default pinctrl state with dynamic pinctrl since certain audio pinmux functions can remain in a HIGH state even when audio is disabled. Linking pinctrl with DAPM using SND_SOC_DAPM_PINCTRL will ensure that audio pins remain in GPIO mode by default and only switch to an audio function when necessary. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230825024935.10878-2-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 30e21d8 commit 91ab967

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

sound/soc/mediatek/mt8188/mt8188-mt6359.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ static const struct snd_soc_dapm_widget mt8188_mt6359_widgets[] = {
246246
SND_SOC_DAPM_MIC("Headset Mic", NULL),
247247
SND_SOC_DAPM_SINK("HDMI"),
248248
SND_SOC_DAPM_SINK("DP"),
249+
250+
/* dynamic pinctrl */
251+
SND_SOC_DAPM_PINCTRL("ETDM_SPK_PIN", "aud_etdm_spk_on", "aud_etdm_spk_off"),
252+
SND_SOC_DAPM_PINCTRL("ETDM_HP_PIN", "aud_etdm_hp_on", "aud_etdm_hp_off"),
253+
SND_SOC_DAPM_PINCTRL("MTKAIF_PIN", "aud_mtkaif_on", "aud_mtkaif_off"),
249254
};
250255

251256
static const struct snd_kcontrol_new mt8188_mt6359_controls[] = {
@@ -267,6 +272,7 @@ static int mt8188_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)
267272
snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
268273
struct snd_soc_component *cmpnt_codec =
269274
asoc_rtd_to_codec(rtd, 0)->component;
275+
struct snd_soc_dapm_widget *pin_w = NULL, *w;
270276
struct mtk_base_afe *afe;
271277
struct mt8188_afe_private *afe_priv;
272278
struct mtkaif_param *param;
@@ -306,6 +312,18 @@ static int mt8188_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)
306312
return 0;
307313
}
308314

315+
for_each_card_widgets(rtd->card, w) {
316+
if (!strcmp(w->name, "MTKAIF_PIN")) {
317+
pin_w = w;
318+
break;
319+
}
320+
}
321+
322+
if (pin_w)
323+
dapm_pinctrl_event(pin_w, NULL, SND_SOC_DAPM_PRE_PMU);
324+
else
325+
dev_dbg(afe->dev, "%s(), no pinmux widget, please check if default on\n", __func__);
326+
309327
pm_runtime_get_sync(afe->dev);
310328
mt6359_mtkaif_calibration_enable(cmpnt_codec);
311329

@@ -403,6 +421,9 @@ static int mt8188_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)
403421
for (i = 0; i < MT8188_MTKAIF_MISO_NUM; i++)
404422
param->mtkaif_phase_cycle[i] = mtkaif_phase_cycle[i];
405423

424+
if (pin_w)
425+
dapm_pinctrl_event(pin_w, NULL, SND_SOC_DAPM_POST_PMD);
426+
406427
dev_dbg(afe->dev, "%s(), end, calibration ok %d\n",
407428
__func__, param->mtkaif_calibration_ok);
408429

0 commit comments

Comments
 (0)