Re: [PATCH v7 3/5] ASoC: meson: g12a-toacodec: Add S4 tocodec driver

From: Jiebing Chen

Date: Wed Oct 21 2026 - 22:27:17 EST



在 2026/10/21 23:08, Jerome Brunet 写道:
[ EXTERNAL EMAIL ]

The S4 requires additional clock control bits to be turn on while enabled.
The S4 has 8 TDM lanes, instead of 4 on previous SoC.
Update the widget accordingly.

Signed-off-by: Jiebing Chen <jiebing.chen@xxxxxxxxxxx>
---
sound/soc/meson/g12a-toacodec.c | 49 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)

diff --git a/sound/soc/meson/g12a-toacodec.c b/sound/soc/meson/g12a-toacodec.c
index 21941ee552c5..9cfed3702354 100644
--- a/sound/soc/meson/g12a-toacodec.c
+++ b/sound/soc/meson/g12a-toacodec.c
@@ -41,6 +41,9 @@
#define CTRL0_BCLK_SEL_LSB 4
#define CTRL0_MCLK_SEL GENMASK(2, 0)

+#define CTRL0_BCLK_ENABLE_SHIFT 30
+#define CTRL0_MCLK_ENABLE_SHIFT 29
Please follow the indentation convention in place (2 spaces)
Noted with thanks

+
#define TOACODEC_OUT_CHMAX 2

struct g12a_toacodec {
@@ -141,6 +144,16 @@ static const struct snd_soc_dapm_widget sm1_toacodec_widgets[] = {
&g12a_toacodec_out_enable),
};

+static const struct snd_soc_dapm_widget s4_toacodec_widgets[] = {
+ SND_SOC_DAPM_MUX("SRC", SND_SOC_NOPM, 0, 0,
+ &sm1_toacodec_mux),
+ SND_SOC_DAPM_SWITCH("OUT EN", SND_SOC_NOPM, 0, 0,
+ &g12a_toacodec_out_enable),
+ SND_SOC_DAPM_SUPPLY("I2S BCLK Gate", TOACODEC_CTRL0, CTRL0_BCLK_ENABLE_SHIFT, 0, NULL, 0),
+ SND_SOC_DAPM_SUPPLY("I2S MCLK Gate", TOACODEC_CTRL0, CTRL0_MCLK_ENABLE_SHIFT, 0, NULL, 0),
BCLK Gate => BCLK EN, same for MCLK
Thanks for pointing this out. I’ll fix it.

+
+};
+
static int g12a_toacodec_input_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
@@ -226,6 +239,16 @@ static const struct snd_soc_dapm_route g12a_toacodec_routes[] = {
{ "OUT Capture", NULL, "OUT EN" },
};

+static const struct snd_soc_dapm_route s4_toacodec_routes[] = {
+ { "SRC", "I2S A", "IN A Playback" },
+ { "SRC", "I2S B", "IN B Playback" },
+ { "SRC", "I2S C", "IN C Playback" },
+ { "OUT EN", "Switch", "SRC" },
+ { "OUT Capture", NULL, "OUT EN" },
+ { "OUT EN", NULL, "I2S BCLK Gate" },
+ { "I2S BCLK Gate", NULL, "I2S MCLK Gate" },
Audio signal does not go through those Gate elements
They should be supply path connected to OUT EN.
Thanks for your guidance. Is it correct to use the method below?

{"OUT EN", NULL, "I2S BCLK EN" },
{"OUT EN", NULL, "I2S MCLK EN" },


--
Jerome