]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ASoC: rt5682: improve the sensitivity of push button
authorShuming Fan <shumingf@realtek.com>
Wed, 30 Oct 2019 08:55:33 +0000 (16:55 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 30 Oct 2019 14:13:21 +0000 (14:13 +0000)
The sensitivity could improve by decreasing the HW debounce time
and reduce the delay time of workequeue.
This patch added a device property for HW debounce time control.
We could change this value to tune the sensitivity of push button.

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

index bf2ee75aabb196b51ba0f8185d0c48e1071ac9b9..bc2c31734df11856e57b8668d26871e8df93d94e 100644 (file)
@@ -31,6 +31,7 @@ struct rt5682_platform_data {
        enum rt5682_dmic1_data_pin dmic1_data_pin;
        enum rt5682_dmic1_clk_pin dmic1_clk_pin;
        enum rt5682_jd_src jd_src;
+       unsigned int btndet_delay;
 };
 
 #endif
index c50b75ce82e0b727cd91fb0d17caf93088890da1..35dcec135c8a609d02eea8de3f458bcd726bec77 100644 (file)
@@ -44,6 +44,7 @@ static const struct rt5682_platform_data i2s_default_platform_data = {
        .dmic1_data_pin = RT5682_DMIC1_DATA_GPIO2,
        .dmic1_clk_pin = RT5682_DMIC1_CLK_GPIO3,
        .jd_src = RT5682_JD1,
+       .btndet_delay = 16,
 };
 
 struct rt5682_priv {
@@ -1026,6 +1027,18 @@ static int rt5682_set_jack_detect(struct snd_soc_component *component,
                regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,
                        RT5682_JD1_EN_MASK | RT5682_JD1_POL_MASK,
                        RT5682_JD1_EN | RT5682_JD1_POL_NOR);
+               regmap_update_bits(rt5682->regmap, RT5682_4BTN_IL_CMD_4,
+                       0x7f7f, (rt5682->pdata.btndet_delay << 8 |
+                       rt5682->pdata.btndet_delay));
+               regmap_update_bits(rt5682->regmap, RT5682_4BTN_IL_CMD_5,
+                       0x7f7f, (rt5682->pdata.btndet_delay << 8 |
+                       rt5682->pdata.btndet_delay));
+               regmap_update_bits(rt5682->regmap, RT5682_4BTN_IL_CMD_6,
+                       0x7f7f, (rt5682->pdata.btndet_delay << 8 |
+                       rt5682->pdata.btndet_delay));
+               regmap_update_bits(rt5682->regmap, RT5682_4BTN_IL_CMD_7,
+                       0x7f7f, (rt5682->pdata.btndet_delay << 8 |
+                       rt5682->pdata.btndet_delay));
                mod_delayed_work(system_power_efficient_wq,
                           &rt5682->jack_detect_work, msecs_to_jiffies(250));
                break;
@@ -2467,6 +2480,8 @@ static int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev)
                &rt5682->pdata.dmic1_clk_pin);
        device_property_read_u32(dev, "realtek,jd-src",
                &rt5682->pdata.jd_src);
+       device_property_read_u32(dev, "realtek,btndet-delay",
+               &rt5682->pdata.btndet_delay);
 
        rt5682->pdata.ldo1_en = of_get_named_gpio(dev->of_node,
                "realtek,ldo1-en-gpios", 0);