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

Commit 86874d39 authored by Walter Yang's avatar Walter Yang Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: wcd: correct the swap plug type detection



For swap plug type detection, only if it's detected as swap type
for four consecutive times, it will be set as swap. If there is
some problem during the detection, the longest mis-operation
period we can wait for is also four-consecutive-time detection.
So even if there is some unexpected behavior like HPH PA being
turned on, the fourth detection won't become the singular decisive
one.

CRs-Fixed: 806833
Change-Id: Icdb9d8e222b8cd9cb239deddfc637d6b874ad819
Signed-off-by: default avatarWalter Yang <yandongy@codeaurora.org>
parent 59b408c5
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -980,6 +980,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
	u16 result1, result2;
	bool wrk_complete = false;
	int pt_gnd_mic_swap_cnt = 0;
	int no_gnd_mic_swap_cnt = 0;
	bool is_pa_on;
	bool micbias2;
	bool micbias1;
@@ -1029,6 +1030,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
			/* Check for cross connection*/
			if (wcd_check_cross_conn(mbhc)) {
				pt_gnd_mic_swap_cnt++;
				no_gnd_mic_swap_cnt = 0;
				if (pt_gnd_mic_swap_cnt <
						GND_MIC_SWAP_THRESHOLD) {
					continue;
@@ -1046,13 +1048,14 @@ static void wcd_correct_swch_plug(struct work_struct *work)
					plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
				}
			} else {
				pt_gnd_mic_swap_cnt++;
				no_gnd_mic_swap_cnt++;
				pt_gnd_mic_swap_cnt = 0;
				plug_type = MBHC_PLUG_TYPE_HEADSET;
				if (pt_gnd_mic_swap_cnt <
				if (no_gnd_mic_swap_cnt <
						GND_MIC_SWAP_THRESHOLD) {
					continue;
				} else {
					pt_gnd_mic_swap_cnt = 0;
					no_gnd_mic_swap_cnt = 0;
				}
			}
		}