]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: rt5640: Allow snd_soc_component_set_jack() to override the codec IRQ
authorHans de Goede <hdegoede@redhat.com>
Thu, 6 Jan 2022 11:01:25 +0000 (12:01 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 6 Jan 2022 13:55:49 +0000 (13:55 +0000)
On some boards where the firmware/fwnode information is in essence
read-only (x86 + ACPI boards) the i2c_client for the codec may contain
the wrong IRQ or no IRQ at all.

Since we only request the IRQ once snd_soc_component_set_jack() gets
called, allow machine drivers to override the IRQ with the proper one
through the data parameter to snd_soc_component_set_jack().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220106110128.66049-4-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt5640.c
sound/soc/codecs/rt5640.h

index a1e4e3ac99f118f08bff0240eb3c5c088f5aa489..fabc6e44b4a68a3c1224978bf4b75f86aa9f944a 100644 (file)
@@ -2452,7 +2452,8 @@ static void rt5640_disable_jack_detect(struct snd_soc_component *component)
 }
 
 static void rt5640_enable_jack_detect(struct snd_soc_component *component,
-                                     struct snd_soc_jack *jack)
+                                     struct snd_soc_jack *jack,
+                                     struct rt5640_set_jack_data *jack_data)
 {
        struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
        int ret;
@@ -2496,6 +2497,9 @@ static void rt5640_enable_jack_detect(struct snd_soc_component *component,
                rt5640_enable_micbias1_ovcd_irq(component);
        }
 
+       if (jack_data && jack_data->codec_irq_override)
+               rt5640->irq = jack_data->codec_irq_override;
+
        ret = request_irq(rt5640->irq, rt5640_irq,
                          IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
                          "rt5640", rt5640);
@@ -2558,7 +2562,7 @@ static int rt5640_set_jack(struct snd_soc_component *component,
                if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER)
                        rt5640_enable_hda_jack_detect(component, jack);
                else
-                       rt5640_enable_jack_detect(component, jack);
+                       rt5640_enable_jack_detect(component, jack, data);
        } else {
                rt5640_disable_jack_detect(component);
        }
index 7ab930def8dd5d009536c702f30e72226b793e59..2f4da5a8ecb212da8a493cd101cd1cfdb5104b74 100644 (file)
@@ -2153,6 +2153,10 @@ struct rt5640_priv {
        unsigned int ovcd_sf;
 };
 
+struct rt5640_set_jack_data {
+       int codec_irq_override;
+};
+
 int rt5640_dmic_enable(struct snd_soc_component *component,
                       bool dmic1_data_pin, bool dmic2_data_pin);
 int rt5640_sel_asrc_clk_src(struct snd_soc_component *component,