Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd503718 authored by Karthikeyan Mani's avatar Karthikeyan Mani Committed by Gerrit - the friendly Code Review server
Browse files

asoc: mbhc: fix for fake ins irq



Check for in2p clamp state in insertion irq
and ignore the interrupt if the clamp is already
set, which means the mechanical removal is about
to happen next.

Change-Id: I55691d427cf07d5b61862b6dbd39f3ec34d873e5
Signed-off-by: default avatarKarthikeyan Mani <kmani@codeaurora.org>
parent aa9c44a3
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -34,6 +34,7 @@
#define WCD_MBHC_ADC_HS_THRESHOLD_MV    1700
#define WCD_MBHC_ADC_HPH_THRESHOLD_MV   75
#define WCD_MBHC_ADC_MICBIAS_MV         1800
#define WCD_MBHC_FAKE_INS_RETRY         4

static int wcd_mbhc_get_micbias(struct wcd_mbhc *mbhc)
{
@@ -1021,6 +1022,8 @@ static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data)
static irqreturn_t wcd_mbhc_adc_hs_ins_irq(int irq, void *data)
{
	struct wcd_mbhc *mbhc = data;
	u8 clamp_state = 0;
	u8 clamp_retry = WCD_MBHC_FAKE_INS_RETRY;

	pr_debug("%s: enter\n", __func__);

@@ -1035,6 +1038,19 @@ static irqreturn_t wcd_mbhc_adc_hs_ins_irq(int irq, void *data)
		return IRQ_HANDLED;
	}

	do {
		WCD_MBHC_REG_READ(WCD_MBHC_IN2P_CLAMP_STATE, clamp_state);
		if (clamp_state) {
			pr_debug("%s: fake insertion irq, leave\n", __func__);
			return IRQ_HANDLED;
		}
		/*
		 * check clamp for 120ms but at 30ms chunks to leave
		 * room for other interrupts to be processed
		 */
		usleep_range(30000, 30100);
	} while (--clamp_retry);

	WCD_MBHC_RSC_LOCK(mbhc);
	/*
	 * If current plug is headphone then there is no chance to
+1 −0
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ enum wcd_mbhc_register_function {
	WCD_MBHC_BTN_DBNC,
	WCD_MBHC_HS_VREF,
	WCD_MBHC_HS_COMP_RESULT,
	WCD_MBHC_IN2P_CLAMP_STATE,
	WCD_MBHC_MIC_SCHMT_RESULT,
	WCD_MBHC_HPHL_SCHMT_RESULT,
	WCD_MBHC_HPHR_SCHMT_RESULT,
+3 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -86,6 +86,8 @@ static struct wcd_mbhc_register
			  WCD934X_MBHC_NEW_CTL_2, 0x03, 0, 0),
	WCD_MBHC_REGISTER("WCD_MBHC_HS_COMP_RESULT",
			  WCD934X_ANA_MBHC_RESULT_3, 0x08, 3, 0),
	WCD_MBHC_REGISTER("WCD_MBHC_IN2P_CLAMP_STATE",
			  WCD934X_ANA_MBHC_RESULT_3, 0x10, 4, 0),
	WCD_MBHC_REGISTER("WCD_MBHC_MIC_SCHMT_RESULT",
			  WCD934X_ANA_MBHC_RESULT_3, 0x20, 5, 0),
	WCD_MBHC_REGISTER("WCD_MBHC_HPHL_SCHMT_RESULT",