OSDN Git Service

ASoC: nau8825: add set_jack coponment support
authorDavid Lin <CTLIN0@nuvoton.com>
Mon, 25 Oct 2021 11:38:57 +0000 (19:38 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 26 Oct 2021 11:35:15 +0000 (12:35 +0100)
Use set_jack ops to set jack for new machine drivers. Meanwhile,
the old machine drivers can still call previous export function
"nau8825_enable_jack_detect".

Signed-off-by: David Lin <CTLIN0@nuvoton.com>
Signed-off-by: Mac Chiang <mac.chiang@intel.com>
Link: https://lore.kernel.org/r/20211025113857.3860951-2-CTLIN0@nuvoton.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/nau8825.c

index 67de0e4..e7a6bd9 100644 (file)
@@ -1434,6 +1434,12 @@ int nau8825_enable_jack_detect(struct snd_soc_component *component,
 
        nau8825->jack = jack;
 
+       if (!nau8825->jack) {
+               regmap_update_bits(regmap, NAU8825_REG_HSD_CTRL,
+                                  NAU8825_HSD_AUTO_MODE | NAU8825_SPKR_DWN1R |
+                                  NAU8825_SPKR_DWN1L, 0);
+               return 0;
+       }
        /* Ground HP Outputs[1:0], needed for headset auto detection
         * Enable Automatic Mic/Gnd switching reading on insert interrupt[6]
         */
@@ -2416,6 +2422,12 @@ static int __maybe_unused nau8825_resume(struct snd_soc_component *component)
        return 0;
 }
 
+static int nau8825_set_jack(struct snd_soc_component *component,
+                           struct snd_soc_jack *jack, void *data)
+{
+       return nau8825_enable_jack_detect(component, jack);
+}
+
 static const struct snd_soc_component_driver nau8825_component_driver = {
        .probe                  = nau8825_component_probe,
        .remove                 = nau8825_component_remove,
@@ -2430,6 +2442,7 @@ static const struct snd_soc_component_driver nau8825_component_driver = {
        .num_dapm_widgets       = ARRAY_SIZE(nau8825_dapm_widgets),
        .dapm_routes            = nau8825_dapm_routes,
        .num_dapm_routes        = ARRAY_SIZE(nau8825_dapm_routes),
+       .set_jack               = nau8825_set_jack,
        .suspend_bias_off       = 1,
        .idle_bias_on           = 1,
        .use_pmdown_time        = 1,