Merge "ASoC: wcd-mbhc: correct detection logic for headphone"

This commit is contained in:
Linux Build Service Account 2017-01-28 08:41:51 -08:00 committed by Gerrit - the friendly Code Review server
commit cf4c7e9a8b

View file

@ -1554,6 +1554,7 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
if (mbhc->mbhc_cb->enable_mb_source) if (mbhc->mbhc_cb->enable_mb_source)
mbhc->mbhc_cb->enable_mb_source(mbhc, true); mbhc->mbhc_cb->enable_mb_source(mbhc, true);
mbhc->btn_press_intr = false; mbhc->btn_press_intr = false;
mbhc->is_btn_press = false;
wcd_mbhc_detect_plug_type(mbhc); wcd_mbhc_detect_plug_type(mbhc);
} else if ((mbhc->current_plug != MBHC_PLUG_TYPE_NONE) } else if ((mbhc->current_plug != MBHC_PLUG_TYPE_NONE)
&& !detection_type) { && !detection_type) {
@ -1571,6 +1572,7 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
mbhc->mbhc_cb->set_cap_mode(codec, micbias1, false); mbhc->mbhc_cb->set_cap_mode(codec, micbias1, false);
mbhc->btn_press_intr = false; mbhc->btn_press_intr = false;
mbhc->is_btn_press = false;
if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADPHONE) { if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADPHONE) {
wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_REM, wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_REM,
false); false);
@ -1759,6 +1761,7 @@ determine_plug:
mic_trigerred = 0; mic_trigerred = 0;
mbhc->is_extn_cable = true; mbhc->is_extn_cable = true;
mbhc->btn_press_intr = false; mbhc->btn_press_intr = false;
mbhc->is_btn_press = false;
wcd_mbhc_detect_plug_type(mbhc); wcd_mbhc_detect_plug_type(mbhc);
WCD_MBHC_RSC_UNLOCK(mbhc); WCD_MBHC_RSC_UNLOCK(mbhc);
pr_debug("%s: leave\n", __func__); pr_debug("%s: leave\n", __func__);
@ -1935,15 +1938,13 @@ static irqreturn_t wcd_mbhc_btn_press_handler(int irq, void *data)
pr_debug("%s: enter\n", __func__); pr_debug("%s: enter\n", __func__);
complete(&mbhc->btn_press_compl); complete(&mbhc->btn_press_compl);
WCD_MBHC_RSC_LOCK(mbhc); WCD_MBHC_RSC_LOCK(mbhc);
/* send event to sw intr handler*/
mbhc->is_btn_press = true;
wcd_cancel_btn_work(mbhc); wcd_cancel_btn_work(mbhc);
if (wcd_swch_level_remove(mbhc)) { if (wcd_swch_level_remove(mbhc)) {
pr_debug("%s: Switch level is low ", __func__); pr_debug("%s: Switch level is low ", __func__);
goto done; goto done;
} }
mbhc->btn_press_intr = true;
mbhc->is_btn_press = true;
msec_val = jiffies_to_msecs(jiffies - mbhc->jiffies_atreport); msec_val = jiffies_to_msecs(jiffies - mbhc->jiffies_atreport);
pr_debug("%s: msec_val = %ld\n", __func__, msec_val); pr_debug("%s: msec_val = %ld\n", __func__, msec_val);
if (msec_val < MBHC_BUTTON_PRESS_THRESHOLD_MIN) { if (msec_val < MBHC_BUTTON_PRESS_THRESHOLD_MIN) {
@ -1957,12 +1958,15 @@ static irqreturn_t wcd_mbhc_btn_press_handler(int irq, void *data)
__func__); __func__);
goto done; goto done;
} }
mask = wcd_mbhc_get_button_mask(mbhc);
if (mask == SND_JACK_BTN_0)
mbhc->btn_press_intr = true;
if (mbhc->current_plug != MBHC_PLUG_TYPE_HEADSET) { if (mbhc->current_plug != MBHC_PLUG_TYPE_HEADSET) {
pr_debug("%s: Plug isn't headset, ignore button press\n", pr_debug("%s: Plug isn't headset, ignore button press\n",
__func__); __func__);
goto done; goto done;
} }
mask = wcd_mbhc_get_button_mask(mbhc);
mbhc->buttons_pressed |= mask; mbhc->buttons_pressed |= mask;
mbhc->mbhc_cb->lock_sleep(mbhc, true); mbhc->mbhc_cb->lock_sleep(mbhc, true);
if (schedule_delayed_work(&mbhc->mbhc_btn_dwork, if (schedule_delayed_work(&mbhc->mbhc_btn_dwork,
@ -1988,8 +1992,8 @@ static irqreturn_t wcd_mbhc_release_handler(int irq, void *data)
goto exit; goto exit;
} }
if (mbhc->btn_press_intr) { if (mbhc->is_btn_press) {
mbhc->btn_press_intr = false; mbhc->is_btn_press = false;
} else { } else {
pr_debug("%s: This release is for fake btn press\n", __func__); pr_debug("%s: This release is for fake btn press\n", __func__);
goto exit; goto exit;