From 8f1926c5ea394676bf5a8d7a49eab0132c589c88 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Wed, 29 Sep 2021 13:42:35 +0530 Subject: [PATCH] ASoC: mbhc-adc: Prevent lineout from being reported two times Sometimes lineout is reported twice, first during initial detection and then during loop due to output mic voltage not being measured correctly. Prevent cable from being reported as headphone during second time if it was reported as lineout in initial detection. Change-Id: If828917cb2acbb0ed5b2de9bf1431d0fbb4a9d10 Signed-off-by: Vatsal Bucha --- asoc/codecs/wcd-mbhc-adc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/asoc/codecs/wcd-mbhc-adc.c b/asoc/codecs/wcd-mbhc-adc.c index ebcedb9ae059..4ebfb2be65b5 100644 --- a/asoc/codecs/wcd-mbhc-adc.c +++ b/asoc/codecs/wcd-mbhc-adc.c @@ -453,7 +453,8 @@ static bool wcd_mbhc_adc_check_for_spl_headset(struct wcd_mbhc *mbhc, adc_hph_threshold = wcd_mbhc_adc_get_hph_thres(mbhc); if (output_mv > adc_threshold || output_mv < adc_hph_threshold) { - spl_hs = false; + if (mbhc->force_linein == true) + spl_hs = false; } else { spl_hs = true; if (spl_hs_cnt) @@ -515,9 +516,12 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) msleep(50); output_mv = wcd_measure_adc_once(mbhc, MUX_CTL_IN2P); if (output_mv <= adc_threshold) { - pr_debug("%s: Special headset detected in %d msecs\n", - __func__, delay); - is_spl_hs = true; + if (mbhc->force_linein != true) { + pr_debug( + "%s: Special headset detected in %d msecs\n", + __func__, delay); + is_spl_hs = true; + } } if (delay == SPECIAL_HS_DETECT_TIME_MS) { @@ -831,7 +835,7 @@ correct_plug_type: } } - if (output_mv > hs_threshold) { + if (output_mv > hs_threshold || mbhc->force_linein == true) { pr_debug("%s: cable is extension cable\n", __func__); plug_type = MBHC_PLUG_TYPE_HIGH_HPH; wrk_complete = true;