From d6d62b8d3c2962466542d7139efbde3b92e2234c Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Tue, 12 Dec 2017 14:22:31 +0530 Subject: [PATCH] ASoC: wcd: Avoid multiple insertion/removals for aux cable High impedance aux cable when inserted causes jack to change to lineout. This causes removal event to be called which results in pause during music playback because jack value is not updated. Do not change current plug while plug is marked as lineout. CRs-Fixed: 2151012 Change-Id: I99797b58c48be00185a352094e32e8623faee491 Signed-off-by: Vatsal Bucha --- asoc/codecs/wcd-mbhc-legacy.c | 6 +++++- asoc/codecs/wcd-mbhc-v2.c | 3 +++ asoc/codecs/wcd-mbhc-v2.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/asoc/codecs/wcd-mbhc-legacy.c b/asoc/codecs/wcd-mbhc-legacy.c index 9f6a6254986f..d03d8342a8df 100644 --- a/asoc/codecs/wcd-mbhc-legacy.c +++ b/asoc/codecs/wcd-mbhc-legacy.c @@ -688,7 +688,11 @@ correct_plug_type: if (!wrk_complete && mbhc->btn_press_intr) { pr_debug("%s: Can be slow insertion of headphone\n", __func__); wcd_cancel_btn_work(mbhc); - plug_type = MBHC_PLUG_TYPE_HEADPHONE; + /* Report as headphone only if previously + * not reported as lineout + */ + if (!mbhc->force_linein) + plug_type = MBHC_PLUG_TYPE_HEADPHONE; } /* * If plug_tye is headset, we might have already reported either in diff --git a/asoc/codecs/wcd-mbhc-v2.c b/asoc/codecs/wcd-mbhc-v2.c index 6088a1ee09a7..0b6e35562355 100644 --- a/asoc/codecs/wcd-mbhc-v2.c +++ b/asoc/codecs/wcd-mbhc-v2.c @@ -605,6 +605,7 @@ void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion, hphrocp_off_report(mbhc, SND_JACK_OC_HPHR); hphlocp_off_report(mbhc, SND_JACK_OC_HPHL); mbhc->current_plug = MBHC_PLUG_TYPE_NONE; + mbhc->force_linein = false; } else { /* * Report removal of current jack type. @@ -657,6 +658,7 @@ void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion, SND_JACK_LINEOUT | SND_JACK_ANC_HEADPHONE | SND_JACK_UNSUPPORTED); + mbhc->force_linein = false; } if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADSET && @@ -699,6 +701,7 @@ void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion, mbhc->zr < MAX_IMPED) && (jack_type == SND_JACK_HEADPHONE)) { jack_type = SND_JACK_LINEOUT; + mbhc->force_linein = true; mbhc->current_plug = MBHC_PLUG_TYPE_HIGH_HPH; if (mbhc->hph_status) { mbhc->hph_status &= ~(SND_JACK_HEADSET | diff --git a/asoc/codecs/wcd-mbhc-v2.h b/asoc/codecs/wcd-mbhc-v2.h index bdae77630f02..94f096adcfbb 100644 --- a/asoc/codecs/wcd-mbhc-v2.h +++ b/asoc/codecs/wcd-mbhc-v2.h @@ -589,6 +589,7 @@ struct wcd_mbhc { struct work_struct usbc_analog_work; struct wcd_mbhc_fn *mbhc_fn; + bool force_linein; }; void wcd_mbhc_find_plug_and_report(struct wcd_mbhc *mbhc,