[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240519-midas-wm1811-gpio-jack-v3-3-0c1736144c0e@gmail.com>
Date: Sun, 19 May 2024 10:17:49 +0200
From: Artur Weber <aweber.kernel@...il.com>
To: Sylwester Nawrocki <s.nawrocki@...sung.com>,
Krzysztof Kozlowski <krzk+dt@...nel.org>
Cc: Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
Rob Herring <robh@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
Alim Akhtar <alim.akhtar@...sung.com>, alsa-devel@...a-project.org,
linux-sound@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-samsung-soc@...r.kernel.org, ~postmarketos/upstreaming@...ts.sr.ht,
Artur Weber <aweber.kernel@...il.com>
Subject: [PATCH v3 3/8] ASoC: samsung: midas_wm1811: Add headset mic bias
supply support
Some devices use a headset mic bias supply (sometimes referred to as
"ear mic bias") to enable/disable the headset mic.
Add support for getting the supply from DT and setting it up
accordingly to the value of the Headset Mic switch.
Signed-off-by: Artur Weber <aweber.kernel@...il.com>
---
Changes in v2:
- Added this commit
---
sound/soc/samsung/midas_wm1811.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/sound/soc/samsung/midas_wm1811.c b/sound/soc/samsung/midas_wm1811.c
index f31244156ff6..ab0a4804b45e 100644
--- a/sound/soc/samsung/midas_wm1811.c
+++ b/sound/soc/samsung/midas_wm1811.c
@@ -29,6 +29,7 @@
struct midas_priv {
struct regulator *reg_mic_bias;
struct regulator *reg_submic_bias;
+ struct regulator *reg_headset_mic_bias;
struct gpio_desc *gpio_fm_sel;
struct gpio_desc *gpio_lineout_sel;
unsigned int fll1_rate;
@@ -201,6 +202,25 @@ static int midas_submic_bias(struct snd_soc_dapm_widget *w,
return 0;
}
+static int midas_headset_mic_bias(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+{
+ struct snd_soc_card *card = w->dapm->card;
+ struct midas_priv *priv = snd_soc_card_get_drvdata(card);
+
+ if (!priv->reg_headset_mic_bias)
+ return 0;
+
+ switch (event) {
+ case SND_SOC_DAPM_PRE_PMU:
+ return regulator_enable(priv->reg_headset_mic_bias);
+ case SND_SOC_DAPM_POST_PMD:
+ return regulator_disable(priv->reg_headset_mic_bias);
+ }
+
+ return 0;
+}
+
static int midas_fm_set(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
@@ -271,7 +291,7 @@ static const struct snd_soc_dapm_widget midas_dapm_widgets[] = {
SND_SOC_DAPM_LINE("FM In", midas_fm_set),
SND_SOC_DAPM_HP("Headphone", NULL),
- SND_SOC_DAPM_MIC("Headset Mic", NULL),
+ SND_SOC_DAPM_MIC("Headset Mic", midas_headset_mic_bias),
SND_SOC_DAPM_MIC("Main Mic", midas_mic_bias),
SND_SOC_DAPM_MIC("Sub Mic", midas_submic_bias),
};
@@ -455,6 +475,17 @@ static int midas_probe(struct platform_device *pdev)
return PTR_ERR(priv->reg_submic_bias);
}
+ priv->reg_headset_mic_bias = devm_regulator_get_optional(dev,
+ "headset-mic-bias");
+ if (IS_ERR(priv->reg_headset_mic_bias)) {
+ ret = PTR_ERR(priv->reg_headset_mic_bias);
+ if (ret == -ENODEV)
+ priv->reg_headset_mic_bias = NULL;
+ else
+ return dev_err_probe(dev, ret,
+ "Failed to get headset mic bias regulator\n");
+ }
+
priv->gpio_fm_sel = devm_gpiod_get_optional(dev, "fm-sel", GPIOD_OUT_HIGH);
if (IS_ERR(priv->gpio_fm_sel)) {
dev_err(dev, "Failed to get FM selection GPIO\n");
--
2.45.0
Powered by blists - more mailing lists