[PATCH v7 6/7] ASoC: meson: g12a-toacodec: fix the S4 source mux read-back
From: christian . koever-draxl
Date: Sun Oct 25 2026 - 15:38:29 EST
From: Christian Stefan Kövér-Draxl <ckoever@xxxxxxxxxx>
The S4 widget reuses the SM1 mux, whose enum reads the data selector at
bits 19:18, while the S4 match data writes it at bits 20:19: the S4 lane
selector is three bits wide instead of two, which moves the data
selector up by one bit.
Writes therefore land in the right place but reads come from the wrong
bits: selecting I2S C programs the hardware correctly, yet the control
reports I2S A. alsactl then stores the wrong value and breaks the
routing when it restores it on the next boot.
Give S4 its own enum at the right offset.
Signed-off-by: Christian Stefan Kövér-Draxl <ckoever@xxxxxxxxxx>
---
sound/soc/meson/g12a-toacodec.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/sound/soc/meson/g12a-toacodec.c b/sound/soc/meson/g12a-toacodec.c
index 204bf8654d2e..db7a4470395f 100644
--- a/sound/soc/meson/g12a-toacodec.c
+++ b/sound/soc/meson/g12a-toacodec.c
@@ -21,6 +21,8 @@
#define TOACODEC_CTRL0 0x0
#define CTRL0_ENABLE_SHIFT 31
+#define CTRL0_DAT_SEL_S4_MSB 20
+#define CTRL0_DAT_SEL_S4_LSB 19
#define CTRL0_DAT_SEL_SM1_MSB 19
#define CTRL0_DAT_SEL_SM1_LSB 18
#define CTRL0_DAT_SEL_MSB 15
@@ -126,6 +128,19 @@ static const struct snd_kcontrol_new sm1_toacodec_mux =
snd_soc_dapm_get_enum_double,
g12a_toacodec_mux_put_enum);
+/*
+ * The S4 lane selector is one bit wider than the SM1 one, which pushes the
+ * data selector up by one bit as well.
+ */
+static SOC_ENUM_SINGLE_DECL(s4_toacodec_mux_enum, TOACODEC_CTRL0,
+ CTRL0_DAT_SEL_S4_LSB,
+ g12a_toacodec_mux_texts);
+
+static const struct snd_kcontrol_new s4_toacodec_mux =
+ SOC_DAPM_ENUM_EXT("Source", s4_toacodec_mux_enum,
+ snd_soc_dapm_get_enum_double,
+ g12a_toacodec_mux_put_enum);
+
static const struct snd_kcontrol_new g12a_toacodec_out_enable =
SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0,
CTRL0_ENABLE_SHIFT, 1, 0);
@@ -146,7 +161,7 @@ static const struct snd_soc_dapm_widget sm1_toacodec_widgets[] = {
static const struct snd_soc_dapm_widget s4_toacodec_widgets[] = {
SND_SOC_DAPM_MUX("SRC", TOACODEC_CTRL0, CTRL0_BCLK_ENABLE_SHIFT, 0,
- &sm1_toacodec_mux),
+ &s4_toacodec_mux),
SND_SOC_DAPM_SWITCH("OUT EN", TOACODEC_CTRL0, CTRL0_MCLK_ENABLE_SHIFT, 0,
&g12a_toacodec_out_enable),
};
--
2.56.0