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

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

ASoC: wcd: correct handling of GND_MIC_SWAP type detection



In current hardware MBHC, if there is no gpio setting for swap
switch and we insert a EURO headset into a US jack, it will be
detected as HEADSET finally. Make the change to set the plug
type as GND_MIC_SWAP when the swap counter reaches
GND_MIC_SWAP_THRESHOLD.

CRs-Fixed: 793061
Change-Id: I74cc80343f466367b03d7c7fabefe1009fa08727
Signed-off-by: default avatarWalter Yang <yandongy@codeaurora.org>
parent d3986129
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -1042,16 +1042,8 @@ static void wcd_correct_swch_plug(struct work_struct *work)
						  __func__);
					plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
					goto report;
				} else if (mbhc->mbhc_cfg->swap_gnd_mic) {
					pr_debug("%s: US_EU gpio present, flip switch\n",
						 __func__);
					/*
					 * if switch is toggled, check again,
					 * otherwise report unsupported plug
					 */
				} else {
					plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
					if (mbhc->mbhc_cfg->swap_gnd_mic(codec))
						continue;
				}
			} else {
				pt_gnd_mic_swap_cnt++;
@@ -1064,6 +1056,21 @@ static void wcd_correct_swch_plug(struct work_struct *work)
				}
			}
		}

		if ((pt_gnd_mic_swap_cnt == GND_MIC_SWAP_THRESHOLD) &&
			(plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP)) {
			/*
			 * if switch is toggled, check again,
			 * otherwise report unsupported plug
			 */
			if (mbhc->mbhc_cfg->swap_gnd_mic &&
				mbhc->mbhc_cfg->swap_gnd_mic(codec)) {
				pr_debug("%s: US_EU gpio present,flip switch\n"
					, __func__);
				continue;
			}
		}

		if (result2 == 1) {
			pr_debug("%s: cable is extension cable\n", __func__);
			plug_type = MBHC_PLUG_TYPE_HIGH_HPH;