ASoC: mediatek: mt8173-rt5650: Map missing jack kcontrols
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>
Wed, 2 Aug 2023 17:57:25 +0000 (20:57 +0300)
committerMark Brown <broonie@kernel.org>
Mon, 7 Aug 2023 13:32:54 +0000 (14:32 +0100)
This driver does not properly map jack pins to kcontrols that PulseAudio
and PipeWire need to handle jack detection events. The RT5645 codec used
here can detect Headphone and Headset Mic connections. Expose both to
userspace as kcontrols.

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

index 3ece4b5..18cf84b 100644 (file)
@@ -54,6 +54,17 @@ static const struct snd_kcontrol_new mt8173_rt5650_controls[] = {
        SOC_DAPM_PIN_SWITCH("Headset Mic"),
 };
 
+static struct snd_soc_jack_pin mt8173_rt5650_jack_pins[] = {
+       {
+               .pin    = "Headphone",
+               .mask   = SND_JACK_HEADPHONE,
+       },
+       {
+               .pin    = "Headset Mic",
+               .mask   = SND_JACK_MICROPHONE,
+       },
+};
+
 static int mt8173_rt5650_hw_params(struct snd_pcm_substream *substream,
                                   struct snd_pcm_hw_params *params)
 {
@@ -128,11 +139,13 @@ static int mt8173_rt5650_init(struct snd_soc_pcm_runtime *runtime)
        }
 
        /* enable jack detection */
-       ret = snd_soc_card_jack_new(card, "Headset Jack",
-                                   SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
-                                   SND_JACK_BTN_0 | SND_JACK_BTN_1 |
-                                   SND_JACK_BTN_2 | SND_JACK_BTN_3,
-                                   &mt8173_rt5650_jack);
+       ret = snd_soc_card_jack_new_pins(card, "Headset Jack",
+                                        SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
+                                        SND_JACK_BTN_0 | SND_JACK_BTN_1 |
+                                        SND_JACK_BTN_2 | SND_JACK_BTN_3,
+                                        &mt8173_rt5650_jack,
+                                        mt8173_rt5650_jack_pins,
+                                        ARRAY_SIZE(mt8173_rt5650_jack_pins));
        if (ret) {
                dev_err(card->dev, "Can't new Headset Jack %d\n", ret);
                return ret;