asoc: mbhc: disable pa while measuring the adc values

While measuring the adc, if PA is on we will get incorrect values of
adc due to which the detection type is missmatched. So disable the PA
While measuring the adc values and restore back PA once measuring adc
done.

Change-Id: I5833452e23a71637353449bb48b937ee44be24ae
Signed-off-by: Prasad Kumpatla <quic_pkumpatl@quicinc.com>
This commit is contained in:
Prasad Kumpatla
2022-07-26 09:25:20 +05:30
parent 290f69973e
commit 05a1b9bd4d
3 changed files with 28 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/module.h>
#include <linux/init.h>
@@ -127,9 +128,18 @@ static int wcd_measure_adc_once(struct wcd_mbhc *mbhc, int mux_ctl)
int ret = 0;
int output_mv = 0;
u8 adc_en = 0;
bool is_pa_on = false;
pr_debug("%s: enter\n", __func__);
if (mbhc->mbhc_cb->hph_pa_on_status) {
if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->component)) {
mbhc->mbhc_cb->hph_pa_enable(mbhc->component, 0);
is_pa_on = true;
pr_debug("%s: pa is on before detection,so disable pa and read adc \n", __func__);
}
}
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_MODE, 0);
/* Read ADC Enable bit to restore after adc measurement */
WCD_MBHC_REG_READ(WCD_MBHC_ADC_EN, adc_en);
@@ -178,6 +188,11 @@ static int wcd_measure_adc_once(struct wcd_mbhc *mbhc, int mux_ctl)
ret = output_mv;
}
if (is_pa_on) {
mbhc->mbhc_cb->hph_pa_enable(mbhc->component, 1);
pr_debug("%s: restore pa \n", __func__);
}
pr_debug("%s: leave\n", __func__);
return ret;