ASoC: rt5682: add delay time of workqueue to control next IRQ event
authorShuming Fan <shumingf@realtek.com>
Tue, 9 Mar 2021 08:58:27 +0000 (16:58 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 10 Mar 2021 13:14:34 +0000 (13:14 +0000)
This patch keeps the delay time (50 ms) for jack detection and zero delay time for the button press.
This patch improves the reaction of the button press.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20210309085827.32032-1-shumingf@realtek.com
Tested-by Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt5682-i2c.c
sound/soc/codecs/rt5682-sdw.c
sound/soc/codecs/rt5682.c
sound/soc/codecs/rt5682.h

index 93c1603..8ea9f1d 100644 (file)
@@ -78,7 +78,7 @@ static irqreturn_t rt5682_irq(int irq, void *data)
        struct rt5682_priv *rt5682 = data;
 
        mod_delayed_work(system_power_efficient_wq,
-               &rt5682->jack_detect_work, msecs_to_jiffies(250));
+               &rt5682->jack_detect_work, msecs_to_jiffies(rt5682->irq_work_delay_time));
 
        return IRQ_HANDLED;
 }
index 5e097f7..fed80c8 100644 (file)
@@ -677,7 +677,7 @@ static int rt5682_interrupt_callback(struct sdw_slave *slave,
 
        if (status->control_port & 0x4) {
                mod_delayed_work(system_power_efficient_wq,
-                       &rt5682->jack_detect_work, msecs_to_jiffies(250));
+                       &rt5682->jack_detect_work, msecs_to_jiffies(rt5682->irq_work_delay_time));
        }
 
        return 0;
index 559dc6d..0e2a10e 100644 (file)
@@ -1094,6 +1094,7 @@ void rt5682_jack_detect_handler(struct work_struct *work)
                        /* jack was out, report jack type */
                        rt5682->jack_type =
                                rt5682_headset_detect(rt5682->component, 1);
+                       rt5682->irq_work_delay_time = 0;
                } else if ((rt5682->jack_type & SND_JACK_HEADSET) ==
                        SND_JACK_HEADSET) {
                        /* jack is already in, report button event */
@@ -1139,6 +1140,7 @@ void rt5682_jack_detect_handler(struct work_struct *work)
        } else {
                /* jack out */
                rt5682->jack_type = rt5682_headset_detect(rt5682->component, 0);
+               rt5682->irq_work_delay_time = 50;
        }
 
        snd_soc_jack_report(rt5682->hs_jack, rt5682->jack_type,
index 1f9c51a..74ff667 100644 (file)
@@ -1439,6 +1439,7 @@ struct rt5682_priv {
        int pll_out[RT5682_PLLS];
 
        int jack_type;
+       int irq_work_delay_time;
 };
 
 extern const char *rt5682_supply_names[RT5682_NUM_SUPPLIES];