ASoC: samsung: littlemill: Map missing jack kcontrols
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>
Wed, 2 Aug 2023 17:57:35 +0000 (20:57 +0300)
committerMark Brown <broonie@kernel.org>
Mon, 7 Aug 2023 13:33:06 +0000 (14:33 +0100)
This driver does not properly map jack pins to kcontrols that PulseAudio
and PipeWire need to handle jack detection events. The WM8958 codec used
here can detect Headphone and Headset Mic connections. Expose each to
userspace as a kcontrol and add the necessary widgets.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Link: https://lore.kernel.org/r/20230802175737.263412-26-alpernebiyasak@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/samsung/littlemill.c

index 5d8118e..fafadce 100644 (file)
@@ -225,12 +225,15 @@ static int bbclk_ev(struct snd_soc_dapm_widget *w,
 }
 
 static const struct snd_kcontrol_new controls[] = {
+       SOC_DAPM_PIN_SWITCH("Headphone"),
+       SOC_DAPM_PIN_SWITCH("Headset Mic"),
        SOC_DAPM_PIN_SWITCH("WM1250 Input"),
        SOC_DAPM_PIN_SWITCH("WM1250 Output"),
 };
 
 static const struct snd_soc_dapm_widget widgets[] = {
        SND_SOC_DAPM_HP("Headphone", NULL),
+       SND_SOC_DAPM_HP("Headset Mic", NULL),
 
        SND_SOC_DAPM_MIC("AMIC", NULL),
        SND_SOC_DAPM_MIC("DMIC", NULL),
@@ -255,6 +258,16 @@ static const struct snd_soc_dapm_route audio_paths[] = {
 };
 
 static struct snd_soc_jack littlemill_headset;
+static struct snd_soc_jack_pin littlemill_headset_pins[] = {
+       {
+               .pin = "Headphone",
+               .mask = SND_JACK_HEADPHONE,
+       },
+       {
+               .pin = "Headset Mic",
+               .mask = SND_JACK_MICROPHONE,
+       },
+};
 
 static int littlemill_late_probe(struct snd_soc_card *card)
 {
@@ -281,12 +294,14 @@ static int littlemill_late_probe(struct snd_soc_card *card)
        if (ret < 0)
                return ret;
 
-       ret = snd_soc_card_jack_new(card, "Headset",
-                                   SND_JACK_HEADSET | SND_JACK_MECHANICAL |
-                                   SND_JACK_BTN_0 | SND_JACK_BTN_1 |
-                                   SND_JACK_BTN_2 | SND_JACK_BTN_3 |
-                                   SND_JACK_BTN_4 | SND_JACK_BTN_5,
-                                   &littlemill_headset);
+       ret = snd_soc_card_jack_new_pins(card, "Headset",
+                                        SND_JACK_HEADSET | SND_JACK_MECHANICAL |
+                                        SND_JACK_BTN_0 | SND_JACK_BTN_1 |
+                                        SND_JACK_BTN_2 | SND_JACK_BTN_3 |
+                                        SND_JACK_BTN_4 | SND_JACK_BTN_5,
+                                        &littlemill_headset,
+                                        littlemill_headset_pins,
+                                        ARRAY_SIZE(littlemill_headset_pins));
        if (ret)
                return ret;