The button detection functionality depends on a calibration voltage value which is currently not updated anywhere in the driver code, and hence it doesn't actually do anything. Remove this unused code. Signed-off-by: Nícolas F. R. A. Prado <nfraprado@xxxxxxxxxxxxx> --- sound/soc/codecs/mt6359-accdet.c | 92 ++-------------------------------------- sound/soc/codecs/mt6359-accdet.h | 17 -------- 2 files changed, 3 insertions(+), 106 deletions(-) diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c index a21c6544174517e3eebc8cf25d1ea3029ba014f6..6b0178976d91e37c32540991693ebfd8e29c11f5 100644 --- a/sound/soc/codecs/mt6359-accdet.c +++ b/sound/soc/codecs/mt6359-accdet.c @@ -37,9 +37,6 @@ #define ACCDET_PMIC_RSV_EINT BIT(7) -#define ACCDET_THREE_KEY BIT(8) -#define ACCDET_FOUR_KEY BIT(9) -#define ACCDET_TRI_KEY_CDD BIT(10) #define ACCDET_RSV_KEY BIT(11) #define ACCDET_ANALOG_FASTDISCHARGE BIT(12) @@ -255,7 +252,6 @@ static void mt6359_accdet_recover_jd_setting(struct mt6359_accdet *priv) priv->data->pwm_deb->debounce3); priv->jack_type = 0; - priv->btn_type = 0; priv->accdet_status = 0x3; mt6359_accdet_jack_report(priv); } @@ -318,45 +314,10 @@ static void mt6359_accdet_jack_report(struct mt6359_accdet *priv) if (!priv->jack) return; - report = priv->jack_type | priv->btn_type; + report = priv->jack_type; snd_soc_jack_report(priv->jack, report, MT6359_ACCDET_JACK_MASK); } -static unsigned int check_button(struct mt6359_accdet *priv, unsigned int v) -{ - if (priv->caps & ACCDET_FOUR_KEY) { - if (v < priv->data->four_key.down && - v >= priv->data->four_key.up) - priv->btn_type = SND_JACK_BTN_1; - if (v < priv->data->four_key.up && - v >= priv->data->four_key.voice) - priv->btn_type = SND_JACK_BTN_2; - if (v < priv->data->four_key.voice && - v >= priv->data->four_key.mid) - priv->btn_type = SND_JACK_BTN_3; - if (v < priv->data->four_key.mid) - priv->btn_type = SND_JACK_BTN_0; - } else { - if (v < priv->data->three_key.down && - v >= priv->data->three_key.up) - priv->btn_type = SND_JACK_BTN_1; - if (v < priv->data->three_key.up && - v >= priv->data->three_key.mid) - priv->btn_type = SND_JACK_BTN_2; - if (v < priv->data->three_key.mid) - priv->btn_type = SND_JACK_BTN_0; - } - return 0; -} - -static void is_key_pressed(struct mt6359_accdet *priv, bool pressed) -{ - priv->btn_type = priv->jack_type & ~MT6359_ACCDET_BTN_MASK; - - if (pressed) - check_button(priv, priv->cali_voltage); -} - static inline void check_jack_btn_type(struct mt6359_accdet *priv) { unsigned int val = 0; @@ -368,15 +329,11 @@ static inline void check_jack_btn_type(struct mt6359_accdet *priv) switch (priv->accdet_status) { case 0: - if (priv->jack_type == SND_JACK_HEADSET) - is_key_pressed(priv, true); - else + if (priv->jack_type != SND_JACK_HEADSET) priv->jack_type = SND_JACK_HEADPHONE; break; case 1: - if (priv->jack_type == SND_JACK_HEADSET) { - is_key_pressed(priv, false); - } else { + if (priv->jack_type != SND_JACK_HEADSET) { priv->jack_type = SND_JACK_HEADSET; accdet_set_debounce(priv, eint_state011, 0x1); } @@ -603,48 +560,6 @@ static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv) if (ret) priv->data->eint_comp_vth = 0x0; - ret = of_property_read_u32(node, "mediatek,key-mode", &tmp); - if (ret) - tmp = 0; - if (tmp == 0) { - int three_key[4]; - - priv->caps |= ACCDET_THREE_KEY; - ret = of_property_read_u32_array(node, - "mediatek,three-key-thr", - three_key, - ARRAY_SIZE(three_key)); - if (!ret) - memcpy(&priv->data->three_key, three_key + 1, - sizeof(struct three_key_threshold)); - } else if (tmp == 1) { - int four_key[5]; - - priv->caps |= ACCDET_FOUR_KEY; - ret = of_property_read_u32_array(node, - "mediatek,four-key-thr", - four_key, - ARRAY_SIZE(four_key)); - if (!ret) { - memcpy(&priv->data->four_key, four_key + 1, - sizeof(struct four_key_threshold)); - } else { - dev_warn(priv->dev, - "accdet no 4-key-thrsh dts, use efuse\n"); - } - } else if (tmp == 2) { - int three_key[4]; - - priv->caps |= ACCDET_TRI_KEY_CDD; - ret = of_property_read_u32_array(node, - "mediatek,tri-key-cdd-thr", - three_key, - ARRAY_SIZE(three_key)); - if (!ret) - memcpy(&priv->data->three_key, three_key + 1, - sizeof(struct three_key_threshold)); - } - of_node_put(node); dev_warn(priv->dev, "accdet caps=%x\n", priv->caps); @@ -1015,7 +930,6 @@ static int mt6359_accdet_probe(struct platform_device *pdev) priv->jd_sts = M_PLUG_OUT; priv->jack_type = 0; - priv->btn_type = 0; priv->accdet_status = 0x3; mt6359_accdet_init(priv); diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h index a54a328bdf3797ce642da446c0cc6792f72ec939..09e1072b61a4c929bf6b764b4fab3c4b26f7cf4a 100644 --- a/sound/soc/codecs/mt6359-accdet.h +++ b/sound/soc/codecs/mt6359-accdet.h @@ -50,19 +50,6 @@ enum { eint_inverter_state000, }; -struct three_key_threshold { - unsigned int mid; - unsigned int up; - unsigned int down; -}; - -struct four_key_threshold { - unsigned int mid; - unsigned int voice; - unsigned int up; - unsigned int down; -}; - struct pwm_deb_settings { unsigned int pwm_width; unsigned int pwm_thresh; @@ -88,8 +75,6 @@ struct dts_data { unsigned int plugout_deb; bool hp_eint_high; struct pwm_deb_settings *pwm_deb; - struct three_key_threshold three_key; - struct four_key_threshold four_key; unsigned int moisture_detect_enable; unsigned int eint_detect_mode; unsigned int eint_use_ext_res; @@ -112,10 +97,8 @@ struct mt6359_accdet { struct mutex res_lock; /* lock protection */ bool jack_plugged; unsigned int jack_type; - unsigned int btn_type; unsigned int accdet_status; unsigned int pre_accdet_status; - unsigned int cali_voltage; unsigned int jd_sts; struct work_struct accdet_work; struct workqueue_struct *accdet_workqueue; -- 2.48.1