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

Commit a2f82ed6 authored by dojha's avatar dojha Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: wcd-mbhc: fix inconsistent detection of euro headset



Cross connection sometimes gets detected late. The issue faced is
cable is reported as headset initially, cross connection is
detected later. But before confirming cross connection, playback
starts on headset, so checking for cross connection is not
confirmed. Cable remains reported as headset. So check for cross
connection just before reporting headset.

CRs-Fixed: 1028002
Change-Id: Ida4f277f13c9a193cd7c92063b99bcf1104f107e
Signed-off-by: default avatarDivya Ojha <dojha@codeaurora.org>
parent 2b660e6a
Loading
Loading
Loading
Loading
+18 −24
Original line number Diff line number Diff line
@@ -1165,6 +1165,8 @@ static void wcd_correct_swch_plug(struct work_struct *work)
	bool micbias1 = false;
	int ret = 0;
	int rc, spl_hs_count = 0;
	int cross_conn;
	int try = 0;

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

@@ -1182,11 +1184,6 @@ static void wcd_correct_swch_plug(struct work_struct *work)
	wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);


	if (mbhc->current_plug == MBHC_PLUG_TYPE_GND_MIC_SWAP) {
		mbhc->current_plug = MBHC_PLUG_TYPE_NONE;
		goto correct_plug_type;
	}

	/* Enable HW FSM */
	WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
	/*
@@ -1214,8 +1211,23 @@ static void wcd_correct_swch_plug(struct work_struct *work)
			plug_type = MBHC_PLUG_TYPE_INVALID;
	}

	pr_debug("%s: Valid plug found, plug type is %d\n",
	do {
		cross_conn = wcd_check_cross_conn(mbhc);
		try++;
	} while (try < GND_MIC_SWAP_THRESHOLD);
	/*
	 * check for cross coneection 4 times.
	 * conisder the result of the fourth iteration.
	 */
	if (cross_conn > 0) {
		pr_debug("%s: cross con found, start polling\n",
			 __func__);
		plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
		pr_debug("%s: Plug found, plug type is %d\n",
			 __func__, plug_type);
		goto correct_plug_type;
	}

	if ((plug_type == MBHC_PLUG_TYPE_HEADSET ||
	     plug_type == MBHC_PLUG_TYPE_HEADPHONE) &&
	    (!wcd_swch_level_remove(mbhc))) {
@@ -1457,10 +1469,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
static void wcd_mbhc_detect_plug_type(struct wcd_mbhc *mbhc)
{
	struct snd_soc_codec *codec = mbhc->codec;
	enum wcd_mbhc_plug_type plug_type;
	bool micbias1 = false;
	int cross_conn;
	int try = 0;

	pr_debug("%s: enter\n", __func__);
	WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
@@ -1481,21 +1490,6 @@ static void wcd_mbhc_detect_plug_type(struct wcd_mbhc *mbhc)
	else
		wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);

	do {
		cross_conn = wcd_check_cross_conn(mbhc);
		try++;
	} while (try < GND_MIC_SWAP_THRESHOLD);

	if (cross_conn > 0) {
		pr_debug("%s: cross con found, start polling\n",
			 __func__);
		plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
		if (!mbhc->current_plug)
			mbhc->current_plug = plug_type;
		pr_debug("%s: Plug found, plug type is %d\n",
			 __func__, plug_type);
	}

	/* Re-initialize button press completion object */
	reinit_completion(&mbhc->btn_press_compl);
	wcd_schedule_hs_detect_plug(mbhc, &mbhc->correct_plug_swch);