* [PATCH v5 0/6] ASoC: wcd938x: enable t14s audio headset
@ 2025-03-25 11:40 srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 1/6] dt-bindings: mux: add optional regulator binding to gpio mux srinivas.kandagatla
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2025-03-25 11:40 UTC (permalink / raw)
To: peda, broonie, andersson, krzk+dt
Cc: ivprusov, luca.ceresoli, zhoubinbin, paulha, lgirdwood, robh,
conor+dt, konradybcio, perex, tiwai, dmitry.baryshkov,
linux-sound, linux-arm-msm, devicetree, linux-kernel,
johan+linaro, Srinivas Kandagatla
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
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
enable 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.
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 | 52 ++++++++++++++-----
sound/soc/codecs/wcd939x.c | 2 +-
10 files changed, 84 insertions(+), 17 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 1/6] dt-bindings: mux: add optional regulator binding to gpio mux
2025-03-25 11:40 [PATCH v5 0/6] ASoC: wcd938x: enable t14s audio headset srinivas.kandagatla
@ 2025-03-25 11:40 ` srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 2/6] mux: gpio: add optional regulator support srinivas.kandagatla
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2025-03-25 11:40 UTC (permalink / raw)
To: peda, broonie, andersson, krzk+dt
Cc: ivprusov, luca.ceresoli, zhoubinbin, paulha, lgirdwood, robh,
conor+dt, konradybcio, perex, tiwai, dmitry.baryshkov,
linux-sound, linux-arm-msm, devicetree, linux-kernel,
johan+linaro, Srinivas Kandagatla, Krzysztof Kozlowski
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
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.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
---
Documentation/devicetree/bindings/mux/gpio-mux.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/mux/gpio-mux.yaml b/Documentation/devicetree/bindings/mux/gpio-mux.yaml
index b597c1f2c577..ef7e33ec85d4 100644
--- a/Documentation/devicetree/bindings/mux/gpio-mux.yaml
+++ b/Documentation/devicetree/bindings/mux/gpio-mux.yaml
@@ -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 ]
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v5 2/6] mux: gpio: add optional regulator support
2025-03-25 11:40 [PATCH v5 0/6] ASoC: wcd938x: enable t14s audio headset srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 1/6] dt-bindings: mux: add optional regulator binding to gpio mux srinivas.kandagatla
@ 2025-03-25 11:40 ` srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 3/6] ASoC: codecs: wcd-mbhc: cleanup swap_gnd_mic api srinivas.kandagatla
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2025-03-25 11:40 UTC (permalink / raw)
To: peda, broonie, andersson, krzk+dt
Cc: ivprusov, luca.ceresoli, zhoubinbin, paulha, lgirdwood, robh,
conor+dt, konradybcio, perex, tiwai, dmitry.baryshkov,
linux-sound, linux-arm-msm, devicetree, linux-kernel,
johan+linaro, Srinivas Kandagatla, Christopher Obbard
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
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.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Tested-by: Christopher Obbard <christopher.obbard@linaro.org>
---
drivers/mux/gpio.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/mux/gpio.c b/drivers/mux/gpio.c
index cc5f2c1861d4..d1607f287755 100644
--- a/drivers/mux/gpio.c
+++ b/drivers/mux/gpio.c
@@ -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;
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v5 3/6] ASoC: codecs: wcd-mbhc: cleanup swap_gnd_mic api
2025-03-25 11:40 [PATCH v5 0/6] ASoC: wcd938x: enable t14s audio headset srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 1/6] dt-bindings: mux: add optional regulator binding to gpio mux srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 2/6] mux: gpio: add optional regulator support srinivas.kandagatla
@ 2025-03-25 11:40 ` srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 4/6] ASoC: dt-bindings: wcd93xx: add bindings for audio mux controlling hp srinivas.kandagatla
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2025-03-25 11:40 UTC (permalink / raw)
To: peda, broonie, andersson, krzk+dt
Cc: ivprusov, luca.ceresoli, zhoubinbin, paulha, lgirdwood, robh,
conor+dt, konradybcio, perex, tiwai, dmitry.baryshkov,
linux-sound, linux-arm-msm, devicetree, linux-kernel,
johan+linaro, Srinivas Kandagatla
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
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.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
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(-)
diff --git a/sound/soc/codecs/wcd-mbhc-v2.c b/sound/soc/codecs/wcd-mbhc-v2.c
index d589a212b768..4b7c3d6080a1 100644
--- a/sound/soc/codecs/wcd-mbhc-v2.c
+++ b/sound/soc/codecs/wcd-mbhc-v2.c
@@ -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;
}
}
diff --git a/sound/soc/codecs/wcd-mbhc-v2.h b/sound/soc/codecs/wcd-mbhc-v2.h
index b977e8f87d7c..a5d52b9643f5 100644
--- a/sound/soc/codecs/wcd-mbhc-v2.h
+++ b/sound/soc/codecs/wcd-mbhc-v2.h
@@ -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;
diff --git a/sound/soc/codecs/wcd937x.c b/sound/soc/codecs/wcd937x.c
index c9d5e67bf66e..b2fb8520c823 100644
--- a/sound/soc/codecs/wcd937x.c
+++ b/sound/soc/codecs/wcd937x.c
@@ -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;
diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index f2a4f3262bdb..dfaa3de31164 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -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;
diff --git a/sound/soc/codecs/wcd939x.c b/sound/soc/codecs/wcd939x.c
index 4a417a92514d..546aa88a398c 100644
--- a/sound/soc/codecs/wcd939x.c
+++ b/sound/soc/codecs/wcd939x.c
@@ -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);
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v5 4/6] ASoC: dt-bindings: wcd93xx: add bindings for audio mux controlling hp
2025-03-25 11:40 [PATCH v5 0/6] ASoC: wcd938x: enable t14s audio headset srinivas.kandagatla
` (2 preceding siblings ...)
2025-03-25 11:40 ` [PATCH v5 3/6] ASoC: codecs: wcd-mbhc: cleanup swap_gnd_mic api srinivas.kandagatla
@ 2025-03-25 11:40 ` srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 6/6] arm64: dts: qcom: x1e78100-t14s: Enable audio headset support srinivas.kandagatla
5 siblings, 0 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2025-03-25 11:40 UTC (permalink / raw)
To: peda, broonie, andersson, krzk+dt
Cc: ivprusov, luca.ceresoli, zhoubinbin, paulha, lgirdwood, robh,
conor+dt, konradybcio, perex, tiwai, dmitry.baryshkov,
linux-sound, linux-arm-msm, devicetree, linux-kernel,
johan+linaro, Srinivas Kandagatla, Krzysztof Kozlowski
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
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.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
Documentation/devicetree/bindings/sound/qcom,wcd938x.yaml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/qcom,wcd938x.yaml b/Documentation/devicetree/bindings/sound/qcom,wcd938x.yaml
index 10531350c336..ab1c6285dbf8 100644
--- a/Documentation/devicetree/bindings/sound/qcom,wcd938x.yaml
+++ b/Documentation/devicetree/bindings/sound/qcom,wcd938x.yaml
@@ -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
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v5 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux
2025-03-25 11:40 [PATCH v5 0/6] ASoC: wcd938x: enable t14s audio headset srinivas.kandagatla
` (3 preceding siblings ...)
2025-03-25 11:40 ` [PATCH v5 4/6] ASoC: dt-bindings: wcd93xx: add bindings for audio mux controlling hp srinivas.kandagatla
@ 2025-03-25 11:40 ` srinivas.kandagatla
2025-03-25 13:36 ` Dmitry Baryshkov
2025-03-25 11:40 ` [PATCH v5 6/6] arm64: dts: qcom: x1e78100-t14s: Enable audio headset support srinivas.kandagatla
5 siblings, 1 reply; 11+ messages in thread
From: srinivas.kandagatla @ 2025-03-25 11:40 UTC (permalink / raw)
To: peda, broonie, andersson, krzk+dt
Cc: ivprusov, luca.ceresoli, zhoubinbin, paulha, lgirdwood, robh,
conor+dt, konradybcio, perex, tiwai, dmitry.baryshkov,
linux-sound, linux-arm-msm, devicetree, linux-kernel,
johan+linaro, Srinivas Kandagatla, Christopher Obbard
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
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.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Tested-by: Christopher Obbard <christopher.obbard@linaro.org>
---
sound/soc/codecs/Kconfig | 1 +
sound/soc/codecs/wcd938x.c | 50 +++++++++++++++++++++++++++++---------
2 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index ee35f3aa5521..a2829d76e108 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -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"
diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index dfaa3de31164..209d0b64c8be 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -19,6 +19,7 @@
#include <linux/regmap.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
+#include <linux/mux/consumer.h>
#include <linux/regulator/consumer.h>
#include "wcd-clsh-v2.h"
@@ -178,6 +179,8 @@ struct wcd938x_priv {
int variant;
int reset_gpio;
struct gpio_desc *us_euro_gpio;
+ struct mux_control *us_euro_mux;
+ unsigned int mux_state;
u32 micb1_mv;
u32 micb2_mv;
u32 micb3_mv;
@@ -3237,15 +3240,22 @@ static void wcd938x_dt_parse_micbias_info(struct device *dev, struct wcd938x_pri
static bool wcd938x_swap_gnd_mic(struct snd_soc_component *component)
{
- int value;
-
- struct wcd938x_priv *wcd938x;
-
- wcd938x = snd_soc_component_get_drvdata(component);
+ struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
+ struct device *dev = component->dev;
+ int ret;
- value = gpiod_get_value(wcd938x->us_euro_gpio);
+ if (wcd938x->us_euro_mux) {
+ mux_control_deselect(wcd938x->us_euro_mux);
+ 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);
+ return false;
+ }
+ } else {
+ gpiod_set_value(wcd938x->us_euro_gpio, !wcd938x->mux_state);
+ }
- gpiod_set_value(wcd938x->us_euro_gpio, !value);
+ wcd938x->mux_state = !wcd938x->mux_state;
return true;
}
@@ -3261,11 +3271,24 @@ 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);
+ 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),
+ "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);
+ return ret;
+ }
+ }
cfg->swap_gnd_mic = wcd938x_swap_gnd_mic;
@@ -3581,6 +3604,9 @@ static void wcd938x_remove(struct platform_device *pdev)
pm_runtime_set_suspended(dev);
pm_runtime_dont_use_autosuspend(dev);
+ if (wcd938x->us_euro_mux)
+ mux_control_deselect(wcd938x->us_euro_mux);
+
regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies);
regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies);
}
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v5 6/6] arm64: dts: qcom: x1e78100-t14s: Enable audio headset support
2025-03-25 11:40 [PATCH v5 0/6] ASoC: wcd938x: enable t14s audio headset srinivas.kandagatla
` (4 preceding siblings ...)
2025-03-25 11:40 ` [PATCH v5 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux srinivas.kandagatla
@ 2025-03-25 11:40 ` srinivas.kandagatla
5 siblings, 0 replies; 11+ messages in thread
From: srinivas.kandagatla @ 2025-03-25 11:40 UTC (permalink / raw)
To: peda, broonie, andersson, krzk+dt
Cc: ivprusov, luca.ceresoli, zhoubinbin, paulha, lgirdwood, robh,
conor+dt, konradybcio, perex, tiwai, dmitry.baryshkov,
linux-sound, linux-arm-msm, devicetree, linux-kernel,
johan+linaro, Srinivas Kandagatla, Krzysztof Kozlowski,
Christopher Obbard
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
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.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tested-by: Christopher Obbard <christopher.obbard@linaro.org>
---
.../qcom/x1e78100-lenovo-thinkpad-t14s.dtsi | 25 +++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi b/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi
index afea82616bc4..34d1d8927484 100644
--- a/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi
+++ b/arch/arm64/boot/dts/qcom/x1e78100-lenovo-thinkpad-t14s.dtsi
@@ -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";
--
2.39.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v5 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux
2025-03-25 11:40 ` [PATCH v5 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux srinivas.kandagatla
@ 2025-03-25 13:36 ` Dmitry Baryshkov
2025-03-25 18:04 ` Srinivas Kandagatla
0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Baryshkov @ 2025-03-25 13:36 UTC (permalink / raw)
To: srinivas.kandagatla
Cc: peda, broonie, andersson, krzk+dt, ivprusov, luca.ceresoli,
zhoubinbin, paulha, lgirdwood, robh, conor+dt, konradybcio, perex,
tiwai, linux-sound, linux-arm-msm, devicetree, linux-kernel,
johan+linaro, Christopher Obbard
On Tue, Mar 25, 2025 at 11:40:57AM +0000, srinivas.kandagatla@linaro.org wrote:
> From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>
> 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.
>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Tested-by: Christopher Obbard <christopher.obbard@linaro.org>
> ---
> sound/soc/codecs/Kconfig | 1 +
> sound/soc/codecs/wcd938x.c | 50 +++++++++++++++++++++++++++++---------
> 2 files changed, 39 insertions(+), 12 deletions(-)
>
> diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
> index ee35f3aa5521..a2829d76e108 100644
> --- a/sound/soc/codecs/Kconfig
> +++ b/sound/soc/codecs/Kconfig
> @@ -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"
> diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
> index dfaa3de31164..209d0b64c8be 100644
> --- a/sound/soc/codecs/wcd938x.c
> +++ b/sound/soc/codecs/wcd938x.c
> @@ -19,6 +19,7 @@
> #include <linux/regmap.h>
> #include <sound/soc.h>
> #include <sound/soc-dapm.h>
> +#include <linux/mux/consumer.h>
> #include <linux/regulator/consumer.h>
>
> #include "wcd-clsh-v2.h"
> @@ -178,6 +179,8 @@ struct wcd938x_priv {
> int variant;
> int reset_gpio;
> struct gpio_desc *us_euro_gpio;
> + struct mux_control *us_euro_mux;
> + unsigned int mux_state;
> u32 micb1_mv;
> u32 micb2_mv;
> u32 micb3_mv;
> @@ -3237,15 +3240,22 @@ static void wcd938x_dt_parse_micbias_info(struct device *dev, struct wcd938x_pri
>
> static bool wcd938x_swap_gnd_mic(struct snd_soc_component *component)
> {
> - int value;
> -
> - struct wcd938x_priv *wcd938x;
> -
> - wcd938x = snd_soc_component_get_drvdata(component);
> + struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
> + struct device *dev = component->dev;
> + int ret;
>
> - value = gpiod_get_value(wcd938x->us_euro_gpio);
> + if (wcd938x->us_euro_mux) {
> + mux_control_deselect(wcd938x->us_euro_mux);
> + 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);
> + return false;
I really don't see any improvement here. If mux_control_try_select()
fails, then on the next toggle mux_control_deselect() would still try to
deselect the mux, although the driver no longer owns it. Likewise in the
remove path the mux_control_deselect() is called unconditionally. I
understand that this driver is the only user of the MUX, so currently
there seems to be no need for any special handling. However if the
hardware design gets more complicated, we can easily face the situation
when selecting the MUX state errors out.
> + }
> + } else {
> + gpiod_set_value(wcd938x->us_euro_gpio, !wcd938x->mux_state);
> + }
>
> - gpiod_set_value(wcd938x->us_euro_gpio, !value);
> + wcd938x->mux_state = !wcd938x->mux_state;
>
> return true;
> }
[...]
> @@ -3581,6 +3604,9 @@ static void wcd938x_remove(struct platform_device *pdev)
> pm_runtime_set_suspended(dev);
> pm_runtime_dont_use_autosuspend(dev);
>
> + if (wcd938x->us_euro_mux)
> + mux_control_deselect(wcd938x->us_euro_mux);
> +
> regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies);
> regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies);
> }
> --
> 2.39.5
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v5 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux
2025-03-25 13:36 ` Dmitry Baryshkov
@ 2025-03-25 18:04 ` Srinivas Kandagatla
2025-03-25 20:13 ` Peter Rosin
0 siblings, 1 reply; 11+ messages in thread
From: Srinivas Kandagatla @ 2025-03-25 18:04 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: peda, broonie, andersson, krzk+dt, ivprusov, luca.ceresoli,
zhoubinbin, paulha, lgirdwood, robh, conor+dt, konradybcio, perex,
tiwai, linux-sound, linux-arm-msm, devicetree, linux-kernel,
johan+linaro, Christopher Obbard
On 25/03/2025 13:36, Dmitry Baryshkov wrote:
> On Tue, Mar 25, 2025 at 11:40:57AM +0000, srinivas.kandagatla@linaro.org wrote:
>> From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>>
>> 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.
>>
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> Tested-by: Christopher Obbard <christopher.obbard@linaro.org>
>> ---
>> sound/soc/codecs/Kconfig | 1 +
>> sound/soc/codecs/wcd938x.c | 50 +++++++++++++++++++++++++++++---------
>> 2 files changed, 39 insertions(+), 12 deletions(-)
>>
>> diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
>> index ee35f3aa5521..a2829d76e108 100644
>> --- a/sound/soc/codecs/Kconfig
>> +++ b/sound/soc/codecs/Kconfig
>> @@ -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"
>> diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
>> index dfaa3de31164..209d0b64c8be 100644
>> --- a/sound/soc/codecs/wcd938x.c
>> +++ b/sound/soc/codecs/wcd938x.c
>> @@ -19,6 +19,7 @@
>> #include <linux/regmap.h>
>> #include <sound/soc.h>
>> #include <sound/soc-dapm.h>
>> +#include <linux/mux/consumer.h>
>> #include <linux/regulator/consumer.h>
>>
>> #include "wcd-clsh-v2.h"
>> @@ -178,6 +179,8 @@ struct wcd938x_priv {
>> int variant;
>> int reset_gpio;
>> struct gpio_desc *us_euro_gpio;
>> + struct mux_control *us_euro_mux;
>> + unsigned int mux_state;
>> u32 micb1_mv;
>> u32 micb2_mv;
>> u32 micb3_mv;
>> @@ -3237,15 +3240,22 @@ static void wcd938x_dt_parse_micbias_info(struct device *dev, struct wcd938x_pri
>>
>> static bool wcd938x_swap_gnd_mic(struct snd_soc_component *component)
>> {
>> - int value;
>> -
>> - struct wcd938x_priv *wcd938x;
>> -
>> - wcd938x = snd_soc_component_get_drvdata(component);
>> + struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
>> + struct device *dev = component->dev;
>> + int ret;
>>
>> - value = gpiod_get_value(wcd938x->us_euro_gpio);
>> + if (wcd938x->us_euro_mux) {
>> + mux_control_deselect(wcd938x->us_euro_mux);
>> + 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);
>> + return false;
>
>
> I really don't see any improvement here. If mux_control_try_select()
> fails, then on the next toggle mux_control_deselect() would still try to
> deselect the mux, although the driver no longer owns it.
TBH, if the first select fails, there is no guarantee that next select
will pass,
Something like this to conditionally check before deselecting should
address some of your concerns:
---------------------------->cut<-----------------------------------
if (wcd938x->us_euro_mux) {
if (wcd938x->mux_setup_done)
mux_control_deselect(wcd938x->us_euro_mux);
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 false;
}
} else {
gpiod_set_value(wcd938x->us_euro_gpio, !wcd938x->mux_state);
}
wcd938x->mux_state = !wcd938x->mux_state;
wcd938x->mux_setup_done = true;
---------------------------->cut<-----------------------------------
I wish we could be taken care in mux-core or even in the deselect api
--srini
Likewise in the
> remove path the mux_control_deselect() is called unconditionally. I
> understand that this driver is the only user of the MUX, so currently
> there seems to be no need for any special handling. However if the
> hardware design gets more complicated, we can easily face the situation
> when selecting the MUX state errors out.
>
>> + }
>> + } else {
>> + gpiod_set_value(wcd938x->us_euro_gpio, !wcd938x->mux_state);
>> + }
>>
>> - gpiod_set_value(wcd938x->us_euro_gpio, !value);
>> + wcd938x->mux_state = !wcd938x->mux_state;
>>
>> return true;
>> }
>
> [...]
>
>> @@ -3581,6 +3604,9 @@ static void wcd938x_remove(struct platform_device *pdev)
>> pm_runtime_set_suspended(dev);
>> pm_runtime_dont_use_autosuspend(dev);
>>
>> + if (wcd938x->us_euro_mux)
>> + mux_control_deselect(wcd938x->us_euro_mux);
>> +
>> regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies);
>> regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies);
>> }
>> --
>> 2.39.5
>>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v5 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux
2025-03-25 18:04 ` Srinivas Kandagatla
@ 2025-03-25 20:13 ` Peter Rosin
2025-03-25 21:39 ` Srinivas Kandagatla
0 siblings, 1 reply; 11+ messages in thread
From: Peter Rosin @ 2025-03-25 20:13 UTC (permalink / raw)
To: Srinivas Kandagatla, Dmitry Baryshkov
Cc: broonie, andersson, krzk+dt, ivprusov, luca.ceresoli, zhoubinbin,
paulha, lgirdwood, robh, conor+dt, konradybcio, perex, tiwai,
linux-sound, linux-arm-msm, devicetree, linux-kernel,
johan+linaro, Christopher Obbard
Hi!
2025-03-25 at 19:04, Srinivas Kandagatla wrote:
> I wish we could be taken care in mux-core or even in the deselect api
It is not easily done. A mux is a shared resource. How can the mux core
know if it is consumer A or consumer B that deselects the mux if both
ignore failures when calling select? Mux select is backed by a semaphore
and there is no guarantee that a consumer selects/deselects from the
same thread or anything like that. The onus is on the consumer to get
this right and only deselect when select is successful.
I believe the documentation is clear on this topic: "do not call
mux_control_deselect() if mux_control_select() fails".
One thing can be done from the mux core, and that is to provide a new
API where consumers get a mux that is exclusive so that the consumer
can call select/deselect without involving a lock in the core. There
need not even be a requirement to call deselect between selects in that
case. Such an API is what many consumers want, I think, but it is of
course not really compatible with the existing API, which is totally
focused on the need to share a mux among multiple consumers.
And, of course, someone has to do it.
Cheers,
Peter
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v5 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux
2025-03-25 20:13 ` Peter Rosin
@ 2025-03-25 21:39 ` Srinivas Kandagatla
0 siblings, 0 replies; 11+ messages in thread
From: Srinivas Kandagatla @ 2025-03-25 21:39 UTC (permalink / raw)
To: Peter Rosin, Dmitry Baryshkov
Cc: broonie, andersson, krzk+dt, ivprusov, luca.ceresoli, zhoubinbin,
paulha, lgirdwood, robh, conor+dt, konradybcio, perex, tiwai,
linux-sound, linux-arm-msm, devicetree, linux-kernel,
johan+linaro, Christopher Obbard
Thanks Peter,
On 25/03/2025 20:13, Peter Rosin wrote:
> Hi!
>
> 2025-03-25 at 19:04, Srinivas Kandagatla wrote:
>> I wish we could be taken care in mux-core or even in the deselect api
>
> It is not easily done. A mux is a shared resource. How can the mux core
> know if it is consumer A or consumer B that deselects the mux if both
> ignore failures when calling select? Mux select is backed by a semaphore
> and there is no guarantee that a consumer selects/deselects from the
> same thread or anything like that. The onus is on the consumer to get
> this right and only deselect when select is successful.
Should deselect fail if there was no previous mux selected?
>
> I believe the documentation is clear on this topic: "do not call
> mux_control_deselect() if mux_control_select() fails".
True, the documentation is pretty clear about this behavior.
>
> One thing can be done from the mux core, and that is to provide a new
> API where consumers get a mux that is exclusive so that the consumer
> can call select/deselect without involving a lock in the core. There
> need not even be a requirement to call deselect between selects in that
> case. Such an API is what many consumers want, I think, but it is of
> course not really compatible with the existing API, which is totally
> focused on the need to share a mux among multiple consumers.
>
exclusive apis would simplify the consumer side of code for sure.
> And, of course, someone has to do it.
Yes, I can give it a go and see how it will turn out.
--srini
>
> Cheers,
> Peter
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-03-25 21:39 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25 11:40 [PATCH v5 0/6] ASoC: wcd938x: enable t14s audio headset srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 1/6] dt-bindings: mux: add optional regulator binding to gpio mux srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 2/6] mux: gpio: add optional regulator support srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 3/6] ASoC: codecs: wcd-mbhc: cleanup swap_gnd_mic api srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 4/6] ASoC: dt-bindings: wcd93xx: add bindings for audio mux controlling hp srinivas.kandagatla
2025-03-25 11:40 ` [PATCH v5 5/6] ASoC: codecs: wcd938x: add mux control support for hp audio mux srinivas.kandagatla
2025-03-25 13:36 ` Dmitry Baryshkov
2025-03-25 18:04 ` Srinivas Kandagatla
2025-03-25 20:13 ` Peter Rosin
2025-03-25 21:39 ` Srinivas Kandagatla
2025-03-25 11:40 ` [PATCH v5 6/6] arm64: dts: qcom: x1e78100-t14s: Enable audio headset support srinivas.kandagatla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox