ASoC: rt5645: implement set_jack callback
authorShuming Fan <shumingf@realtek.com>
Wed, 5 Jul 2023 04:23:48 +0000 (12:23 +0800)
committerMark Brown <broonie@kernel.org>
Sun, 9 Jul 2023 21:50:56 +0000 (22:50 +0100)
Add a wrapper function to support set_jack component driver callback.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20230705042349.24905-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt5645.c

index a506d940a2eadcd011506eb72cdd075be2492006..b0953e9bcaf948b4e73b296dc516b1abefa6ec90 100644 (file)
@@ -3258,6 +3258,22 @@ int rt5645_set_jack_detect(struct snd_soc_component *component,
 }
 EXPORT_SYMBOL_GPL(rt5645_set_jack_detect);
 
+static int rt5645_component_set_jack(struct snd_soc_component *component,
+       struct snd_soc_jack *hs_jack, void *data)
+{
+       struct snd_soc_jack *mic_jack = NULL;
+       struct snd_soc_jack *btn_jack = NULL;
+       int *type = (int *)data;
+
+       if (*type & SND_JACK_MICROPHONE)
+               mic_jack = hs_jack;
+       if (*type & (SND_JACK_BTN_0 | SND_JACK_BTN_1 |
+               SND_JACK_BTN_2 | SND_JACK_BTN_3))
+               btn_jack = hs_jack;
+
+       return rt5645_set_jack_detect(component, hs_jack, mic_jack, btn_jack);
+}
+
 static void rt5645_jack_detect_work(struct work_struct *work)
 {
        struct rt5645_priv *rt5645 =
@@ -3532,6 +3548,7 @@ static const struct snd_soc_component_driver soc_component_dev_rt5645 = {
        .num_dapm_widgets       = ARRAY_SIZE(rt5645_dapm_widgets),
        .dapm_routes            = rt5645_dapm_routes,
        .num_dapm_routes        = ARRAY_SIZE(rt5645_dapm_routes),
+       .set_jack               = rt5645_component_set_jack,
        .use_pmdown_time        = 1,
        .endianness             = 1,
 };