From 7b663b23b2d8932fb51aa2a433cb597594a0e91e Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Tue, 22 Oct 2019 11:39:10 +0530 Subject: [PATCH] ASoC: wcd-mbhc: Fix headset insert not detected after moisture config Headset insertion is not detected after moisture is configured and then removed. This is because during moisture_detect GND_DET_EN is configured irrespective of whether it is enabled or not. Add a check before enabling gnd_det_en. Also as moisture_en is disabled and duty cycle is enabled change check during removal to disable threshold and polling. Change-Id: Iee9d79b38b228e78d1509d59e92d37f1328f079e Signed-off-by: Vatsal Bucha --- asoc/codecs/wcd-mbhc-v2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/asoc/codecs/wcd-mbhc-v2.c b/asoc/codecs/wcd-mbhc-v2.c index 01544aab9c..e332acd6f9 100644 --- a/asoc/codecs/wcd-mbhc-v2.c +++ b/asoc/codecs/wcd-mbhc-v2.c @@ -883,7 +883,8 @@ static bool wcd_mbhc_moisture_detect(struct wcd_mbhc *mbhc, bool detection_type) detection_type); ret = true; WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_L_DET_EN, 1); - WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_GND_DET_EN, 1); + if (mbhc->mbhc_cfg->gnd_det_en) + WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_GND_DET_EN, 1); } else { mbhc->mbhc_cb->mbhc_moisture_polling_ctrl(mbhc, false); mbhc->mbhc_cb->mbhc_moisture_detect_en(mbhc, false); @@ -1023,7 +1024,7 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc) mbhc->component, false); } - if (mbhc->mbhc_cfg->moisture_en && + if (mbhc->mbhc_cfg->moisture_en || mbhc->mbhc_cfg->moisture_duty_cycle_en) { if (mbhc->mbhc_cb->mbhc_moisture_polling_ctrl) mbhc->mbhc_cb->mbhc_moisture_polling_ctrl(mbhc,