Skip to contentSkip to conversation

ASoC: wcd938x: enable t14s audio headset

PATCH Applied [email protected] 7 participants 26 messages Mar 27, 2025 – May 17, 2025

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

v6 cover ASoC: wcd938x: enable t14s audio headset

From: Srinivas Kandagatla <[email protected]>

On Lenovo ThinkPad T14s, the headset is connected via a HiFi Switch to support CTIA and OMTP headsets. This switch is used to minimise pop and click during headset type switching.

This patchset adds required bindings and changes to codec and dts to tnable the regulator required to power this switch along with wiring up gpio that control the headset switching.

Without this patchset, there will be lots of noise on headset and mic will not we functional.

Merge strategy:
- mux bindings and mux patches can go independently
- ASoC codec patches with bindings can go independently.
- dts needs can go in parallel to Codec bindings.

Changes since v5:
- add flag to check if mux is selected or not and conditionally do deselect.
Also proposed mux exclusive apis https://lkml.org/lkml/2025/3/26/955
However, this patchset can go as it is without exclusive apis We cal always do the cleanup later.

Changes since v4:
- do not rely on as-is idle mux state, exclusively get mux

Changes since v3:
- rearranged mux deselct to do better error handling.
- reused mux_state for gpios as well.
- removed tested by on bindings

Changes since v2:
- udpated bindings as suggested by Rob and Krzysztof
- cleaned up swap_gnd_mic callback
- updated mux gpio to use dev_err_probe.
- added Tested-by and reviewed-by tags

Changes since v1:
- moved to using mux-controls.
- fixed typo in regulator naming.

Srinivas Kandagatla (6):
dt-bindings: mux: add optional regulator binding to gpio mux
mux: gpio: add optional regulator support
ASoC: codecs: wcd-mbhc: cleanup swap_gnd_mic api
ASoC: dt-bindings: wcd93xx: add bindings for audio mux controlling hp
ASoC: codecs: wcd938x: add mux control support for hp audio mux
arm64: dts: qcom: x1e78100-t14s: Enable audio headset support

 .../devicetree/bindings/mux/gpio-mux.yaml     |  4 ++
 .../bindings/sound/qcom,wcd938x.yaml          |  6 ++
 .../qcom/x1e78100-lenovo-thinkpad-t14s.dtsi   | 25 ++++++++
 drivers/mux/gpio.c                            |  5 ++
 sound/soc/codecs/Kconfig                      |  1 +
 sound/soc/codecs/wcd-mbhc-v2.c                |  2 +-
 sound/soc/codecs/wcd-mbhc-v2.h                |  2 +-
 sound/soc/codecs/wcd937x.c                    |  2 +-
 sound/soc/codecs/wcd938x.c                    | 57 +++++++++++++++----
 sound/soc/codecs/wcd939x.c                    |  2 +-
 10 files changed, 90 insertions(+), 16 deletions(-)
Signature · 1 line
2.39.5
#1 lore raw

PATCH v6 1/6 dt-bindings: mux: add optional regulator binding to gpio mux

From: Srinivas Kandagatla <[email protected]>

On some platforms to minimise pop and click during switching between CTIA and OMTP headset an additional HiFi Mux Switch is used. Most common case is that this switch is switched on by default, but on some platforms this needs a regulator enable. One such platform is Lenovo T14s.

This patch adds required bindings in gpio-mux to add such optional regulator.

---
 Documentation/devicetree/bindings/mux/gpio-mux.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/mux/gpio-mux.yaml +4 -0
index b597c1f2c577..ef7e33ec85d4 100644
@@ -25,6 +25,10 @@ properties:
     description:
       List of gpios used to control the multiplexer, least significant bit first.
 
+  mux-supply:
+    description:
+      Regulator to power on the multiplexer.
+
   '#mux-control-cells':
     enum: [ 0, 1 ]
 
Signature · 1 line
2.39.5
#2 lore raw

Re: (subset) [PATCH v6 1/6] dt-bindings: mux: add optional regulator binding to gpio mux

Quoted 9 lines · On Thu, 27 Mar 2025 10:06:28 +0000, [email protected] wrote:

On some platforms to minimise pop and click during switching between CTIA and OMTP headset an additional HiFi Mux Switch is used. Most common case is that this switch is switched on by default, but on some platforms this needs a regulator enable. One such platform is Lenovo T14s.

This patch adds required bindings in gpio-mux to add such optional regulator.

[...]

Applied, thanks!

[1/6] dt-bindings: mux: add optional regulator binding to gpio mux

      https://git.kernel.org/krzk/linux/c/e9c695067b68da6b39e0d70cd4a061d0f70050d3

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>
#3 lore raw

PATCH v6 2/6 mux: gpio: add optional regulator support

In reply to [email protected]

From: Srinivas Kandagatla <[email protected]>

Some of the external muxes needs powering up using a regulator. This is the case with Lenovo T14s laptop which has a external audio mux to handle US/EURO headsets.

Add support to the driver to handle this optional regulator.

---
 drivers/mux/gpio.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mux/gpio.c +5 -0
index cc5f2c1861d4..d1607f287755 100644
@@ -15,6 +15,7 @@
 #include <linux/mux/driver.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
+#include <linux/regulator/consumer.h>
 
 struct mux_gpio {
 	struct gpio_descs *gpios;
@@ -82,6 +83,10 @@ static int mux_gpio_probe(struct platform_device *pdev)
 		mux_chip->mux->idle_state = idle_state;
 	}
 
+	ret = devm_regulator_get_enable_optional(dev, "mux");
+	if (ret && ret != -ENODEV)
+		return dev_err_probe(dev, ret, "Couldn't retrieve/enable gpio mux supply\n");
+
 	ret = devm_mux_chip_register(dev, mux_chip);
 	if (ret < 0)
 		return ret;
Signature · 1 line
2.39.5
maintainer
#4 lore raw

Re: [PATCH v6 2/6] mux: gpio: add optional regulator support

Quoted 5 lines · On Thu, Mar 27, 2025 at 10:06:29AM +0000, [email protected] wrote:

From: Srinivas Kandagatla <[email protected]>

Some of the external muxes needs powering up using a regulator. This is the case with Lenovo T14s laptop which has a external audio mux to handle US/EURO headsets.

The ASoC bits of this series look fine, what's the plan with the mux bits? It looks like the two parts can just get merged independently.

#5 lore raw

Re: [PATCH v6 2/6] mux: gpio: add optional regulator support

Quoted 9 lines · Mark Brown
Quoted 5 lines · On Thu, Mar 27, 2025 at 10:06:29AM +0000, [email protected] wrote:

From: Srinivas Kandagatla <[email protected]>

Some of the external muxes needs powering up using a regulator. This is the case with Lenovo T14s laptop which has a external audio mux to handle US/EURO headsets.

The ASoC bits of this series look fine, what's the plan with the mux bits? It looks like the two parts can just get merged independently.

ASoC bits and codec bindings can go independently, there is no compile time dependency.

--srini

Reviewed-by Tested-by on v6 2/6
#6 lore raw

Re: [PATCH v6 2/6] mux: gpio: add optional regulator support

In reply to [email protected]
Quoted 12 lines · Srinivas Kandagatla

From: Srinivas Kandagatla <[email protected]>

Some of the external muxes needs powering up using a regulator. This is the case with Lenovo T14s laptop which has a external audio mux to handle US/EURO headsets.

Add support to the driver to handle this optional regulator.

drivers/mux/gpio.c static int mux_gpio_probe(struct platform_device *pdev) · line 88

Quoted 6 lines
drivers/mux/gpio.c +3 -0
@@ -82,6 +83,10 @@ static int mux_gpio_probe(struct platform_device *pdev)
 		mux_chip->mux->idle_state = idle_state;
 	}
 
+	ret = devm_regulator_get_enable_optional(dev, "mux");
+	if (ret && ret != -ENODEV)
+		return dev_err_probe(dev, ret, "Couldn't retrieve/enable gpio mux supply\n");

nit: "failed to get/enable mux supply" may be more consistent with the other (non-capitalised error) messages and avoids repeating "gpio mux" which will be added by driver core.

drivers/mux/gpio.c static int mux_gpio_probe(struct platform_device *pdev) · line 92

Quoted 4 lines
drivers/mux/gpio.c +1 -0
+
 	ret = devm_mux_chip_register(dev, mux_chip);
 	if (ret < 0)
 		return ret;

Either way:

#7 lore raw

Re: [PATCH v6 2/6] mux: gpio: add optional regulator support

Quoted 29 lines · Johan Hovold
Quoted 12 lines · Srinivas Kandagatla

From: Srinivas Kandagatla <[email protected]>

Some of the external muxes needs powering up using a regulator. This is the case with Lenovo T14s laptop which has a external audio mux to handle US/EURO headsets.

Add support to the driver to handle this optional regulator.

drivers/mux/gpio.c static int mux_gpio_probe(struct platform_device *pdev) · line 88

Quoted 6 lines
drivers/mux/gpio.c +3 -0
@@ -82,6 +83,10 @@ static int mux_gpio_probe(struct platform_device *pdev)
 		mux_chip->mux->idle_state = idle_state;
 	}
 
+	ret = devm_regulator_get_enable_optional(dev, "mux");
+	if (ret && ret != -ENODEV)
+		return dev_err_probe(dev, ret, "Couldn't retrieve/enable gpio mux supply\n");

nit: "failed to get/enable mux supply" may be more consistent with the other (non-capitalised error) messages and avoids repeating "gpio mux" which will be added by driver core.

drivers/mux/gpio.c static int mux_gpio_probe(struct platform_device *pdev) · line 92

Quoted 4 lines
drivers/mux/gpio.c +1 -0
+
 	ret = devm_mux_chip_register(dev, mux_chip);
 	if (ret < 0)
 		return ret;
Quoted 4 lines

Either way:

Can someone please pick this one and the binding update up for 6.16?

I see you recently volunteered to do so, Krzysztof? [1]

Johan

[1] https://lore.kernel.org/all/[email protected]/

#8 lore raw

Re: [PATCH v6 2/6] mux: gpio: add optional regulator support

Quoted 9 lines · Johan Hovold
Quoted 9 lines

nit: "failed to get/enable mux supply" may be more consistent with the other (non-capitalised error) messages and avoids repeating "gpio mux" which will be added by driver core.

Quoted 4 lines
drivers/mux/gpio.c +1 -0
+
 	ret = devm_mux_chip_register(dev, mux_chip);
 	if (ret < 0)
 		return ret;
Quoted 8 lines
Quoted 4 lines

Either way:

Can someone please pick this one and the binding update up for 6.16?

I see you recently volunteered to do so, Krzysztof? [1]

Sure, thanks for ping. I'll take with your change in err msg.

Quoted 4 lines

Johan

[1] https://lore.kernel.org/all/[email protected]/

Best regards,
Krzysztof

#9 lore raw

Re: (subset) [PATCH v6 2/6] mux: gpio: add optional regulator support

In reply to [email protected]
Quoted 8 lines · On Thu, 27 Mar 2025 10:06:29 +0000, [email protected] wrote:

Some of the external muxes needs powering up using a regulator. This is the case with Lenovo T14s laptop which has a external audio mux to handle US/EURO headsets.

Add support to the driver to handle this optional regulator.

[...]

Applied, thanks!

[2/6] mux: gpio: add optional regulator support

      https://git.kernel.org/krzk/linux/c/12d3c69ba2734b5908e0ac8ac2dcbd0cc28fef3a

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>
#10 lore raw

PATCH v6 3/6 ASoC: codecs: wcd-mbhc: cleanup swap_gnd_mic api

In reply to [email protected]

From: Srinivas Kandagatla <[email protected]>

Remove confusing and unused argument in swap_gnd_mic api, the second argument active is not really used, and always set to true in the mbhc drivers.

The callback itself is used to toggle the gnd_mic lines when a cross connection is detected by mbhc circuits, so there is no need of this argument.

---
 sound/soc/codecs/wcd-mbhc-v2.c | 2 +-
 sound/soc/codecs/wcd-mbhc-v2.h | 2 +-
 sound/soc/codecs/wcd937x.c     | 2 +-
 sound/soc/codecs/wcd938x.c     | 2 +-
 sound/soc/codecs/wcd939x.c     | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
sound/soc/codecs/wcd-mbhc-v2.c +1 -1
index d589a212b768..4b7c3d6080a1 100644
@@ -1260,7 +1260,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
 			if (pt_gnd_mic_swap_cnt == mbhc->swap_thr) {
 				/* US_EU gpio present, flip switch */
 				if (mbhc->cfg->swap_gnd_mic) {
-					if (mbhc->cfg->swap_gnd_mic(component, true))
+					if (mbhc->cfg->swap_gnd_mic(component))
 						continue;
 				}
 			}
sound/soc/codecs/wcd-mbhc-v2.h +1 -1
index b977e8f87d7c..a5d52b9643f5 100644
@@ -194,7 +194,7 @@ struct wcd_mbhc_config {
 	int num_btn;
 	bool mono_stero_detection;
 	bool typec_analog_mux;
-	bool (*swap_gnd_mic)(struct snd_soc_component *component, bool active);
+	bool (*swap_gnd_mic)(struct snd_soc_component *component);
 	bool hs_ext_micbias;
 	bool gnd_det_en;
 	uint32_t linein_th;
sound/soc/codecs/wcd937x.c +1 -1
index c9d5e67bf66e..b2fb8520c823 100644
@@ -2646,7 +2646,7 @@ static void wcd937x_dt_parse_micbias_info(struct device *dev, struct wcd937x_pri
 		dev_warn(dev, "Micbias3 DT property not found\n");
 }
 
-static bool wcd937x_swap_gnd_mic(struct snd_soc_component *component, bool active)
+static bool wcd937x_swap_gnd_mic(struct snd_soc_component *component)
 {
 	int value;
 	struct wcd937x_priv *wcd937x;
sound/soc/codecs/wcd938x.c +1 -1
index f2a4f3262bdb..dfaa3de31164 100644
@@ -3235,7 +3235,7 @@ static void wcd938x_dt_parse_micbias_info(struct device *dev, struct wcd938x_pri
 		dev_info(dev, "%s: Micbias4 DT property not found\n", __func__);
 }
 
-static bool wcd938x_swap_gnd_mic(struct snd_soc_component *component, bool active)
+static bool wcd938x_swap_gnd_mic(struct snd_soc_component *component)
 {
 	int value;
 
sound/soc/codecs/wcd939x.c +1 -1
index 4a417a92514d..546aa88a398c 100644
@@ -3215,7 +3215,7 @@ static void wcd939x_dt_parse_micbias_info(struct device *dev, struct wcd939x_pri
 }
 
 #if IS_ENABLED(CONFIG_TYPEC)
-static bool wcd939x_swap_gnd_mic(struct snd_soc_component *component, bool active)
+static bool wcd939x_swap_gnd_mic(struct snd_soc_component *component)
 {
 	struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component);
 
Signature · 1 line
2.39.5
Reviewed-by on v6 3/6
#11 lore raw

Re: [PATCH v6 3/6] ASoC: codecs: wcd-mbhc: cleanup swap_gnd_mic api

Quoted 10 lines · On Thu, Mar 27, 2025 at 10:06:30AM +0000, [email protected] wrote:

From: Srinivas Kandagatla <[email protected]>

Remove confusing and unused argument in swap_gnd_mic api, the second argument active is not really used, and always set to true in the mbhc drivers.

The callback itself is used to toggle the gnd_mic lines when a cross connection is detected by mbhc circuits, so there is no need of this argument.

Quoted 8 lines
---
 sound/soc/codecs/wcd-mbhc-v2.c | 2 +-
 sound/soc/codecs/wcd-mbhc-v2.h | 2 +-
 sound/soc/codecs/wcd937x.c     | 2 +-
 sound/soc/codecs/wcd938x.c     | 2 +-
 sound/soc/codecs/wcd939x.c     | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
Signature · 2 lines
With best wishes
Dmitry
#12 lore raw

PATCH v6 4/6 ASoC: dt-bindings: wcd93xx: add bindings for audio mux controlling hp

In reply to [email protected]

From: Srinivas Kandagatla <[email protected]>

On some platforms to minimise pop and click during switching between CTIA and OMTP headset an additional HiFi mux is used. Most common case is that this switch is switched on by default, but on some platforms this needs a regulator enable.

Move to using mux-controls so that both the gpio and regulators can be driven correctly, rather than adding regulator handing in the codec.

This patch adds required bindings to add such mux controls.

---
 Documentation/devicetree/bindings/sound/qcom,wcd938x.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/sound/qcom,wcd938x.yaml +6 -0
index 10531350c336..ab1c6285dbf8 100644
@@ -23,9 +23,15 @@ properties:
       - qcom,wcd9380-codec
       - qcom,wcd9385-codec
 
+  mux-controls:
+    description: A reference to the audio mux switch for
+      switching CTIA/OMTP Headset types
+    maxItems: 1
+
   us-euro-gpios:
     description: GPIO spec for swapping gnd and mic segments
     maxItems: 1
+    deprecated: true
 
 required:
   - compatible
Signature · 1 line
2.39.5
#13 lore raw

PATCH v6 5/6 ASoC: codecs: wcd938x: add mux control support for hp audio mux

In reply to [email protected]

From: Srinivas Kandagatla <[email protected]>

On some platforms to minimise pop and click during switching between CTIA and OMTP headset an additional HiFi mux is used. Most common case is that this switch is switched on by default, but on some platforms this needs a regulator enable.

move to using mux control to enable both regulator and handle gpios, deprecate the usage of gpio.

---
 sound/soc/codecs/Kconfig   |  1 +
 sound/soc/codecs/wcd938x.c | 55 ++++++++++++++++++++++++++++++--------
 2 files changed, 45 insertions(+), 11 deletions(-)
sound/soc/codecs/Kconfig +1 -0
index ee35f3aa5521..a2829d76e108 100644
@@ -2226,6 +2226,7 @@ config SND_SOC_WCD938X
 	tristate
 	depends on SOUNDWIRE || !SOUNDWIRE
 	select SND_SOC_WCD_CLASSH
+	select MULTIPLEXER
 
 config SND_SOC_WCD938X_SDW
 	tristate "WCD9380/WCD9385 Codec - SDW"
sound/soc/codecs/wcd938x.c +44 -11

94 lines not on this page · raw message

Signature · 1 line
2.39.5
Reviewed-by on v6 5/6
#14 lore raw

Re: [PATCH v6 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux

Quoted 10 lines · On Thu, Mar 27, 2025 at 10:06:32AM +0000, [email protected] wrote:

From: Srinivas Kandagatla <[email protected]>

On some platforms to minimise pop and click during switching between CTIA and OMTP headset an additional HiFi mux is used. Most common case is that this switch is switched on by default, but on some platforms this needs a regulator enable.

move to using mux control to enable both regulator and handle gpios, deprecate the usage of gpio.

Quoted 7 lines
---
 sound/soc/codecs/Kconfig   |  1 +
 sound/soc/codecs/wcd938x.c | 55 ++++++++++++++++++++++++++++++--------
 2 files changed, 45 insertions(+), 11 deletions(-)
Signature · 2 lines
With best wishes
Dmitry
Tested-by on v6 5/6
#15 lore raw

Re: [PATCH v6 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux

In reply to [email protected]
Quoted 7 lines · Srinivas Kandagatla

From: Srinivas Kandagatla <[email protected]>

On some platforms to minimise pop and click during switching between CTIA and OMTP headset an additional HiFi mux is used. Most common case is that this switch is switched on by default, but on some platforms this needs a regulator enable.

Quoted 5 lines

move to using mux control to enable both regulator and handle gpios, deprecate the usage of gpio.

#16 lore raw

Re: [PATCH v6 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux

In reply to [email protected]
Quoted 14 lines · Srinivas Kandagatla

From: Srinivas Kandagatla <[email protected]>

On some platforms to minimise pop and click during switching between CTIA and OMTP headset an additional HiFi mux is used. Most common case is that this switch is switched on by default, but on some platforms this needs a regulator enable.

move to using mux control to enable both regulator and handle gpios, deprecate the usage of gpio.

sound/soc/codecs/wcd938x.c static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device · line 3279

Quoted 9 lines
sound/soc/codecs/wcd938x.c +1 -5
@@ -3261,11 +3276,26 @@ static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device
 		return dev_err_probe(dev, wcd938x->reset_gpio,
 				     "Failed to get reset gpio\n");
 
-	wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro",
-						GPIOD_OUT_LOW);
-	if (IS_ERR(wcd938x->us_euro_gpio))
-		return dev_err_probe(dev, PTR_ERR(wcd938x->us_euro_gpio),
-				     "us-euro swap Control GPIO not found\n");
+	wcd938x->us_euro_mux = devm_mux_control_get(dev, NULL);

Running with this patch on the CRD I noticed that this now prints an error as there is no optional mux (or gpio) defined:

wcd938x_codec audio-codec: /audio-codec: failed to get mux-control (0)

You need to suppress that error in mux_get() to allow for optional muxes to be looked up like this.

Quoted 9 lines
sound/soc/codecs/wcd938x.c +9 -0
+	if (IS_ERR(wcd938x->us_euro_mux)) {
+		if (PTR_ERR(wcd938x->us_euro_mux) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+
+		/* mux is optional and now fallback to using gpio */
+		wcd938x->us_euro_mux = NULL;
+		wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro", GPIOD_OUT_LOW);
+		if (IS_ERR(wcd938x->us_euro_gpio))
+			return dev_err_probe(dev, PTR_ERR(wcd938x->us_euro_gpio),

sound/soc/codecs/wcd938x.c static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device · line 3298

Quoted 10 lines
sound/soc/codecs/wcd938x.c +10 -0
+					     "us-euro swap Control GPIO not found\n");
+	} else {
+		ret = mux_control_try_select(wcd938x->us_euro_mux, wcd938x->mux_state);
+		if (ret) {
+			dev_err(dev, "Error (%d) Unable to select us/euro mux state\n", ret);
+			wcd938x->mux_setup_done = false;
+			return ret;
+		}
+		wcd938x->mux_setup_done = true;
+	}

Johan

#17 lore raw

Re: [PATCH v6 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux

Quoted 18 lines · Johan Hovold
Quoted 17 lines · Srinivas Kandagatla

From: Srinivas Kandagatla <[email protected]>

On some platforms to minimise pop and click during switching between CTIA and OMTP headset an additional HiFi mux is used. Most common case is that this switch is switched on by default, but on some platforms this needs a regulator enable.

move to using mux control to enable both regulator and handle gpios, deprecate the usage of gpio.

sound/soc/codecs/wcd938x.c +0 -0
@@ -3261,11 +3276,26 @@ static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device
  		return dev_err_probe(dev, wcd938x->reset_gpio,
  				     "Failed to get reset gpio\n");
 
Quoted 7 lines

sound/soc/codecs/wcd938x.c static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device · line 3279

Quoted 6 lines
sound/soc/codecs/wcd938x.c +1 -5
-	wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro",
-						GPIOD_OUT_LOW);
-	if (IS_ERR(wcd938x->us_euro_gpio))
-		return dev_err_probe(dev, PTR_ERR(wcd938x->us_euro_gpio),
-				     "us-euro swap Control GPIO not found\n");
+	wcd938x->us_euro_mux = devm_mux_control_get(dev, NULL);

Thanks Johan,

Quoted 4 lines

Running with this patch on the CRD I noticed that this now prints an error as there is no optional mux (or gpio) defined:

wcd938x_codec audio-codec: /audio-codec: failed to get mux-control (0)

This is not from codec driver, mux control is throwing up this.

Quoted 3 lines

You need to suppress that error in mux_get() to allow for optional muxes to be looked up like this.

I have a plan for this,

I proposed some changes to mux api for exclusive apis at https://lkml.org/lkml/2025/3/26/955

This should also allow us to easily add an optional api, which I plan to do once i get some feedback on this patch.

--srini

Quoted 22 lines
Quoted 10 lines
sound/soc/codecs/wcd938x.c +9 -0
+	if (IS_ERR(wcd938x->us_euro_mux)) {
+		if (PTR_ERR(wcd938x->us_euro_mux) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+
+		/* mux is optional and now fallback to using gpio */
+		wcd938x->us_euro_mux = NULL;
+		wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro", GPIOD_OUT_LOW);
+		if (IS_ERR(wcd938x->us_euro_gpio))
+			return dev_err_probe(dev, PTR_ERR(wcd938x->us_euro_gpio),

sound/soc/codecs/wcd938x.c static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device · line 3298

Quoted 10 lines
sound/soc/codecs/wcd938x.c +10 -0
+					     "us-euro swap Control GPIO not found\n");
+	} else {
+		ret = mux_control_try_select(wcd938x->us_euro_mux, wcd938x->mux_state);
+		if (ret) {
+			dev_err(dev, "Error (%d) Unable to select us/euro mux state\n", ret);
+			wcd938x->mux_setup_done = false;
+			return ret;
+		}
+		wcd938x->mux_setup_done = true;
+	}

Johan

#18 lore raw

Re: [PATCH v6 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux

Quoted 29 lines · Srinivas Kandagatla
Quoted 28 lines · Johan Hovold
Quoted 14 lines · Srinivas Kandagatla

From: Srinivas Kandagatla <[email protected]>

On some platforms to minimise pop and click during switching between CTIA and OMTP headset an additional HiFi mux is used. Most common case is that this switch is switched on by default, but on some platforms this needs a regulator enable.

move to using mux control to enable both regulator and handle gpios, deprecate the usage of gpio.

sound/soc/codecs/wcd938x.c static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device · line 3279

Quoted 9 lines
sound/soc/codecs/wcd938x.c +1 -5
@@ -3261,11 +3276,26 @@ static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device
  		return dev_err_probe(dev, wcd938x->reset_gpio,
  				     "Failed to get reset gpio\n");
 
-	wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro",
-						GPIOD_OUT_LOW);
-	if (IS_ERR(wcd938x->us_euro_gpio))
-		return dev_err_probe(dev, PTR_ERR(wcd938x->us_euro_gpio),
-				     "us-euro swap Control GPIO not found\n");
+	wcd938x->us_euro_mux = devm_mux_control_get(dev, NULL);

Running with this patch on the CRD I noticed that this now prints an error as there is no optional mux (or gpio) defined:

Quoted 3 lines
Quoted 1 line

wcd938x_codec audio-codec: /audio-codec: failed to get mux-control (0)

This is not from codec driver, mux control is throwing up this.

Yeah, the error is printed by the mux code, but it's this codec change that starts triggering it.

Quoted 10 lines
Quoted 2 lines

You need to suppress that error in mux_get() to allow for optional muxes to be looked up like this.

I have a plan for this,

I proposed some changes to mux api for exclusive apis at
https://lkml.org/lkml/2025/3/26/955

This should also allow us to easily add an optional api, which I plan to do once i get some feedback on this patch.

It may just be as simple as demoting that dev_err() in mux_get() to dev_dbg() and possibly make sure any callers log errors themselves.

A quick grep shows there are only 12 users or so and most of them already seem to be logging mux lookup errors.

Johan

#19 lore raw

Re: [PATCH v6 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux

In reply to Srinivas Kandagatla
Quoted 37 lines · Srinivas Kandagatla
Quoted 14 lines · Johan Hovold
Quoted 12 lines · Srinivas Kandagatla

From: Srinivas Kandagatla <[email protected]>

On some platforms to minimise pop and click during switching between CTIA and OMTP headset an additional HiFi mux is used. Most common case is that this switch is switched on by default, but on some platforms this needs a regulator enable.

move to using mux control to enable both regulator and handle gpios, deprecate the usage of gpio.

Quoted 11 lines
Quoted 10 lines
(quoted diff) +0 -0
@@ -3261,11 +3276,26 @@ static int wcd938x_populate_dt_data(struct 

wcd938x_priv *wcd938x, struct device
          return dev_err_probe(dev, wcd938x->reset_gpio, "Failed to get reset gpio\n");
-    wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro", -                        GPIOD_OUT_LOW);
-    if (IS_ERR(wcd938x->us_euro_gpio))
-        return dev_err_probe(dev, PTR_ERR(wcd938x->us_euro_gpio), -                     "us-euro swap Control GPIO not found\n"); +    wcd938x->us_euro_mux = devm_mux_control_get(dev, NULL);

Thanks Johan,

Quoted 4 lines

Running with this patch on the CRD I noticed that this now prints an error as there is no optional mux (or gpio) defined:

    wcd938x_codec audio-codec: /audio-codec: failed to get mux-control (0)

This is not from codec driver, mux control is throwing up this.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

You need to suppress that error in mux_get() to allow for optional muxes to be looked up like this.

I have a plan for this,

I proposed some changes to mux api for exclusive apis at https:// lkml.org/lkml/2025/3/26/955

This should also allow us to easily add an optional api, which I plan to do once i get some feedback on this patch.

I'd rather suggest an API to switch the state without deselecting the the mux.

Quoted 4 lines

--srini

Quoted 1 line
Signature · 2 lines
With best wishes
Dmitry
#20 lore raw

PATCH v6 6/6 arm64: dts: qcom: x1e78100-t14s: Enable audio headset support

In reply to [email protected]

From: Srinivas Kandagatla <[email protected]>

On Lenovo ThinkPad T14s, the headset is connected via a HiFi mux to support CTIA and OMTP headsets. This switch is used to minimise pop and click during headset type switching.

Enable the mux controls required to power this switch along with wiring up gpio that control the headset switching.

Without this, headset audio will be very noisy and might see headset detection errors.

---
 .../qcom/x1e78100-lenovo-thinkpad-t14s.dtsi   | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi +25 -0
index afea82616bc4..34d1d8927484 100644
@@ -41,6 +41,7 @@ wcd938x: audio-codec {
 		qcom,tx-device = <&wcd_tx>;
 
 		reset-gpios = <&tlmm 191 GPIO_ACTIVE_LOW>;
+		mux-controls = <&us_euro_mux_ctrl>;
 
 		vdd-buck-supply = <&vreg_l15b_1p8>;
 		vdd-rxtx-supply = <&vreg_l15b_1p8>;
@@ -149,6 +150,16 @@ pmic_glink_ss1_con_sbu_in: endpoint {
 		};
 	};
 
+	/* two muxes together support CTIA and OMTP switching */
+	us_euro_mux_ctrl: mux-controller {
+		compatible = "gpio-mux";
+		pinctrl-0 = <&us_euro_hs_sel>;
+		pinctrl-names = "default";
+		mux-supply = <&vreg_l16b_2p5>;
+		#mux-control-cells = <0>;
+		mux-gpios = <&tlmm 68 GPIO_ACTIVE_HIGH>;
+	};
+
 	reserved-memory {
 		linux,cma {
 			compatible = "shared-dma-pool";
@@ -604,6 +615,13 @@ vreg_l15b_1p8: ldo15 {
 			regulator-always-on;
 		};
 
+		vreg_l16b_2p5: ldo16 {
+			regulator-name = "vreg_l16b_2p5";
+			regulator-min-microvolt = <2504000>;
+			regulator-max-microvolt = <2504000>;
+			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
+		};
+
 		vreg_l17b_2p5: ldo17 {
 			regulator-name = "vreg_l17b_2p5";
 			regulator-min-microvolt = <2504000>;
@@ -1461,6 +1479,13 @@ rtmr1_default: rtmr1-reset-n-active-state {
 		bias-disable;
 	};
 
+	us_euro_hs_sel: us-euro-hs-sel-state {
+		pins = "gpio68";
+		function = "gpio";
+		bias-pull-down;
+		drive-strength = <2>;
+	};
+
 	usb1_pwr_1p15_reg_en: usb1-pwr-1p15-reg-en-state {
 		pins = "gpio188";
 		function = "gpio";
Signature · 1 line
2.39.5
Reviewed-by Tested-by on v6 6/6
#21 lore raw

Re: [PATCH v6 6/6] arm64: dts: qcom: x1e78100-t14s: Enable audio headset support

Quoted 9 lines · Srinivas Kandagatla

From: Srinivas Kandagatla <[email protected]>

On Lenovo ThinkPad T14s, the headset is connected via a HiFi mux to support CTIA and OMTP headsets. This switch is used to minimise pop and click during headset type switching.

Enable the mux controls required to power this switch along with wiring up gpio that control the headset switching.

Quoted 6 lines

Without this, headset audio will be very noisy and might see headset detection errors.

Looks good and both playback and recording works fine:

Johan

#22 lore raw

Re: [PATCH v6 6/6] arm64: dts: qcom: x1e78100-t14s: Enable audio headset support

Hi Bjorn,

Quoted 13 lines · Johan Hovold
Quoted 12 lines · Srinivas Kandagatla

From: Srinivas Kandagatla <[email protected]>

On Lenovo ThinkPad T14s, the headset is connected via a HiFi mux to support CTIA and OMTP headsets. This switch is used to minimise pop and click during headset type switching.

Enable the mux controls required to power this switch along with wiring up gpio that control the headset switching.

Without this, headset audio will be very noisy and might see headset detection errors.

Quoted 8 lines
Quoted 3 lines

Looks good and both playback and recording works fine:

Assuming the mux change will make it into 6.16 now, can you pick this one up as well?

Johan

#23 lore raw

Re: [PATCH v6 6/6] arm64: dts: qcom: x1e78100-t14s: Enable audio headset support

Quoted 10 lines · Johan Hovold
Quoted 10 lines
Quoted 9 lines

Enable the mux controls required to power this switch along with wiring up gpio that control the headset switching.

Without this, headset audio will be very noisy and might see headset detection errors.

Quoted 8 lines
Quoted 4 lines

Looks good and both playback and recording works fine:

Assuming the mux change will make it into 6.16 now, can you pick this one up as well?

FYI,
I will take the mux binding, so next will be fine.

Best regards,
Krzysztof

maintainer Applied
#24 lore raw

Re: (subset) [PATCH v6 6/6] arm64: dts: qcom: x1e78100-t14s: Enable audio headset support

In reply to [email protected]
Quoted 8 lines · On Thu, 27 Mar 2025 10:06:33 +0000, [email protected] wrote:

On Lenovo ThinkPad T14s, the headset is connected via a HiFi mux to support CTIA and OMTP headsets. This switch is used to minimise pop and click during headset type switching.

Enable the mux controls required to power this switch along with wiring up gpio that control the headset switching.

[...]

Applied, thanks!

[6/6] arm64: dts: qcom: x1e78100-t14s: Enable audio headset support

      commit: 5603525e40e3257ea507ff34f8acd5790fb8bc49

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>
maintainer
#25 lore raw

Re: (subset) [PATCH v6 0/6] ASoC: wcd938x: enable t14s audio headset

In reply to [email protected]
Quoted 9 lines · On Thu, 27 Mar 2025 10:06:27 +0000, [email protected] wrote:

On Lenovo ThinkPad T14s, the headset is connected via a HiFi Switch to support CTIA and OMTP headsets. This switch is used to minimise pop and click during headset type switching.

This patchset adds required bindings and changes to codec and dts to tnable the regulator required to power this switch along with wiring up gpio that control the headset switching.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[3/6] ASoC: codecs: wcd-mbhc: cleanup swap_gnd_mic api

      commit: 6417066fb41f70c5aec242a36cbb6def8c99303f
[4/6] ASoC: dt-bindings: wcd93xx: add bindings for audio mux controlling hp
      commit: fe19245d3efd5bf714623e83f2056bc46d9339b1
[5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux
      commit: eec611d26f84800852a9badbeafa76db3cdc9118

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark