From e1728c5c3c59bfaa595daa26aa5ae98637555c9e Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Thu, 17 Jan 2019 17:24:55 +0530 Subject: [PATCH] ASoC: wcd-mbhc: Disable moisture_en when duty cycle is enabled Moisture Detection should be disabled at init if duty cycle is enabled. Change-Id: If398928a680174d981b9baefe02d9efd4e21766e Signed-off-by: Vatsal Bucha --- asoc/codecs/wcd-mbhc-v2.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/asoc/codecs/wcd-mbhc-v2.c b/asoc/codecs/wcd-mbhc-v2.c index 6839203bd9..1159b1128a 100644 --- a/asoc/codecs/wcd-mbhc-v2.c +++ b/asoc/codecs/wcd-mbhc-v2.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. */ #include #include @@ -850,7 +850,7 @@ static bool wcd_mbhc_moisture_detect(struct wcd_mbhc *mbhc, bool detection_type) { bool ret = false; - if (!mbhc->mbhc_cfg->moisture_en || + if (!mbhc->mbhc_cfg->moisture_en && !mbhc->mbhc_cfg->moisture_duty_cycle_en) return ret; @@ -1342,9 +1342,15 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) else WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_CTRL, 3); + /* Configure for moisture detection when duty cycle is not enabled. + * Otherwise disable moisture detection. + */ if (mbhc->mbhc_cfg->moisture_en && mbhc->mbhc_cb->mbhc_moisture_config && !mbhc->mbhc_cfg->moisture_duty_cycle_en) mbhc->mbhc_cb->mbhc_moisture_config(mbhc); + else if (mbhc->mbhc_cfg->moisture_duty_cycle_en && + mbhc->mbhc_cb->mbhc_moisture_detect_en) + mbhc->mbhc_cb->mbhc_moisture_detect_en(mbhc, false); /* * For USB analog we need to override the switch configuration.