103 lines
3.7 KiB
Diff
103 lines
3.7 KiB
Diff
From 8b12f09d1ba7f704e1ff0435d891556aae675b22 Mon Sep 17 00:00:00 2001
|
|
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
|
|
Date: Wed, 2 Aug 2023 20:57:30 +0300
|
|
Subject: [PATCH 11/17] ASoC: qcom: sc7180: Map missing jack kcontrols
|
|
|
|
This driver does not properly map jack pins to kcontrols that PulseAudio
|
|
and PipeWire need to handle jack detection events. The RT5682 and
|
|
RT5682s codecs used here can detect Headphone and Headset Mic
|
|
connections. Expose each to userspace as a kcontrol.
|
|
|
|
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
|
|
Link: https://lore.kernel.org/r/20230802175737.263412-21-alpernebiyasak@gmail.com
|
|
Signed-off-by: Mark Brown <broonie@kernel.org>
|
|
---
|
|
sound/soc/qcom/sc7180.c | 40 +++++++++++++++++++++++++++++++++-------
|
|
1 file changed, 33 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/sound/soc/qcom/sc7180.c b/sound/soc/qcom/sc7180.c
|
|
index f5f7c64b23a2..57c5f35dfcc5 100644
|
|
--- a/sound/soc/qcom/sc7180.c
|
|
+++ b/sound/soc/qcom/sc7180.c
|
|
@@ -42,6 +42,17 @@ static void sc7180_jack_free(struct snd_jack *jack)
|
|
snd_soc_component_set_jack(component, NULL, NULL);
|
|
}
|
|
|
|
+static struct snd_soc_jack_pin sc7180_jack_pins[] = {
|
|
+ {
|
|
+ .pin = "Headphone Jack",
|
|
+ .mask = SND_JACK_HEADPHONE,
|
|
+ },
|
|
+ {
|
|
+ .pin = "Headset Mic",
|
|
+ .mask = SND_JACK_MICROPHONE,
|
|
+ },
|
|
+};
|
|
+
|
|
static int sc7180_headset_init(struct snd_soc_pcm_runtime *rtd)
|
|
{
|
|
struct snd_soc_card *card = rtd->card;
|
|
@@ -51,13 +62,14 @@ static int sc7180_headset_init(struct snd_soc_pcm_runtime *rtd)
|
|
struct snd_jack *jack;
|
|
int rval;
|
|
|
|
- rval = snd_soc_card_jack_new(
|
|
- card, "Headset Jack",
|
|
- SND_JACK_HEADSET |
|
|
- SND_JACK_HEADPHONE |
|
|
- SND_JACK_BTN_0 | SND_JACK_BTN_1 |
|
|
- SND_JACK_BTN_2 | SND_JACK_BTN_3,
|
|
- &pdata->hs_jack);
|
|
+ rval = snd_soc_card_jack_new_pins(card, "Headset Jack",
|
|
+ SND_JACK_HEADSET |
|
|
+ SND_JACK_HEADPHONE |
|
|
+ SND_JACK_BTN_0 | SND_JACK_BTN_1 |
|
|
+ SND_JACK_BTN_2 | SND_JACK_BTN_3,
|
|
+ &pdata->hs_jack,
|
|
+ sc7180_jack_pins,
|
|
+ ARRAY_SIZE(sc7180_jack_pins));
|
|
|
|
if (rval < 0) {
|
|
dev_err(card->dev, "Unable to add Headset Jack\n");
|
|
@@ -297,6 +309,11 @@ static const struct snd_soc_dapm_widget sc7180_snd_widgets[] = {
|
|
SND_SOC_DAPM_MIC("Headset Mic", NULL),
|
|
};
|
|
|
|
+static const struct snd_kcontrol_new sc7180_snd_controls[] = {
|
|
+ SOC_DAPM_PIN_SWITCH("Headphone Jack"),
|
|
+ SOC_DAPM_PIN_SWITCH("Headset Mic"),
|
|
+};
|
|
+
|
|
static const struct snd_soc_dapm_widget sc7180_adau7002_snd_widgets[] = {
|
|
SND_SOC_DAPM_MIC("DMIC", NULL),
|
|
};
|
|
@@ -320,6 +337,11 @@ static const struct snd_soc_dapm_widget sc7180_snd_dual_mic_widgets[] = {
|
|
SND_SOC_DAPM_MUX("Dmic Mux", SND_SOC_NOPM, 0, 0, &sc7180_dmic_mux_control),
|
|
};
|
|
|
|
+static const struct snd_kcontrol_new sc7180_snd_dual_mic_controls[] = {
|
|
+ SOC_DAPM_PIN_SWITCH("Headphone Jack"),
|
|
+ SOC_DAPM_PIN_SWITCH("Headset Mic"),
|
|
+};
|
|
+
|
|
static const struct snd_soc_dapm_route sc7180_snd_dual_mic_audio_route[] = {
|
|
{"Dmic Mux", "Front Mic", "DMIC"},
|
|
{"Dmic Mux", "Rear Mic", "DMIC"},
|
|
@@ -348,10 +370,14 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev)
|
|
card->dev = dev;
|
|
card->dapm_widgets = sc7180_snd_widgets;
|
|
card->num_dapm_widgets = ARRAY_SIZE(sc7180_snd_widgets);
|
|
+ card->controls = sc7180_snd_controls;
|
|
+ card->num_controls = ARRAY_SIZE(sc7180_snd_controls);
|
|
|
|
if (of_property_read_bool(dev->of_node, "dmic-gpios")) {
|
|
card->dapm_widgets = sc7180_snd_dual_mic_widgets,
|
|
card->num_dapm_widgets = ARRAY_SIZE(sc7180_snd_dual_mic_widgets),
|
|
+ card->controls = sc7180_snd_dual_mic_controls,
|
|
+ card->num_controls = ARRAY_SIZE(sc7180_snd_dual_mic_controls),
|
|
card->dapm_routes = sc7180_snd_dual_mic_audio_route,
|
|
card->num_dapm_routes = ARRAY_SIZE(sc7180_snd_dual_mic_audio_route),
|
|
data->dmic_sel = devm_gpiod_get(&pdev->dev, "dmic", GPIOD_OUT_LOW);
|
|
--
|
|
2.43.0
|
|
|