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

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

asoc: codecs: modify gnd mic swap threshold for usb-c analog



To reduce time of usb-c analog headset detection, reduce
gnd mic swap threshold if usb-c is enabled. Use
existing threshold value otherwise.

CRs-Fixed: 2137077
Change-Id: Ic1d1f3a00c9034caaac45f2c80f018546a69ce59
Signed-off-by: default avatarKarthikeyan Mani <kmani@codeaurora.org>
parent 9326b2df
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -622,7 +622,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
	do {
		cross_conn = wcd_check_cross_conn(mbhc);
		try++;
	} while (try < GND_MIC_SWAP_THRESHOLD);
	} while (try < mbhc->swap_thr);

	if (cross_conn > 0) {
		plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
@@ -714,10 +714,10 @@ static void wcd_correct_swch_plug(struct work_struct *work)
				pt_gnd_mic_swap_cnt++;
				no_gnd_mic_swap_cnt = 0;
				if (pt_gnd_mic_swap_cnt <
						GND_MIC_SWAP_THRESHOLD) {
						mbhc->swap_thr) {
					continue;
				} else if (pt_gnd_mic_swap_cnt >
					   GND_MIC_SWAP_THRESHOLD) {
					   mbhc->swap_thr) {
					/*
					 * This is due to GND/MIC switch didn't
					 * work,  Report unsupported plug.
@@ -735,14 +735,14 @@ static void wcd_correct_swch_plug(struct work_struct *work)
				plug_type = wcd_mbhc_get_plug_from_adc(
						mbhc, output_mv);
				if ((no_gnd_mic_swap_cnt <
				    GND_MIC_SWAP_THRESHOLD) &&
				    mbhc->swap_thr) &&
				    (spl_hs_count != WCD_MBHC_SPL_HS_CNT)) {
					continue;
				} else {
					no_gnd_mic_swap_cnt = 0;
				}
			}
			if ((pt_gnd_mic_swap_cnt == GND_MIC_SWAP_THRESHOLD) &&
			if ((pt_gnd_mic_swap_cnt == mbhc->swap_thr) &&
				(plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP)) {
				/*
				 * if switch is toggled, check again,
+4 −4
Original line number Diff line number Diff line
@@ -498,7 +498,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
	do {
		cross_conn = wcd_check_cross_conn(mbhc);
		try++;
	} while (try < GND_MIC_SWAP_THRESHOLD);
	} while (try < mbhc->swap_thr);

	/*
	 * Check for cross connection 4 times.
@@ -599,10 +599,10 @@ static void wcd_correct_swch_plug(struct work_struct *work)
				pt_gnd_mic_swap_cnt++;
				no_gnd_mic_swap_cnt = 0;
				if (pt_gnd_mic_swap_cnt <
						GND_MIC_SWAP_THRESHOLD) {
						mbhc->swap_thr) {
					continue;
				} else if (pt_gnd_mic_swap_cnt >
						GND_MIC_SWAP_THRESHOLD) {
						mbhc->swap_thr) {
					/*
					 * This is due to GND/MIC switch didn't
					 * work,  Report unsupported plug.
@@ -626,7 +626,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
					no_gnd_mic_swap_cnt = 0;
				}
			}
			if ((pt_gnd_mic_swap_cnt == GND_MIC_SWAP_THRESHOLD) &&
			if ((pt_gnd_mic_swap_cnt == mbhc->swap_thr) &&
				(plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP)) {
				/*
				 * if switch is toggled, check again,
+2 −0
Original line number Diff line number Diff line
@@ -1707,6 +1707,7 @@ int wcd_mbhc_start(struct wcd_mbhc *mbhc, struct wcd_mbhc_config *mbhc_cfg)
	if (mbhc_cfg->enable_usbc_analog) {
		dev_dbg(mbhc->codec->dev, "%s: usbc analog enabled\n",
				__func__);
		mbhc->swap_thr = GND_MIC_USBC_SWAP_THRESHOLD;
		rc = wcd_mbhc_init_gpio(mbhc, mbhc_cfg,
				"qcom,usbc-analog-en1-gpio",
				&config->usbc_en1_gpio,
@@ -1901,6 +1902,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
	mbhc->extn_cable_hph_rem = false;
	mbhc->hph_type = WCD_MBHC_HPH_NONE;
	mbhc->wcd_mbhc_regs = wcd_mbhc_regs;
	mbhc->swap_thr = GND_MIC_SWAP_THRESHOLD;

	if (mbhc->intr_ids == NULL) {
		pr_err("%s: Interrupt mapping not provided\n", __func__);
+2 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ do { \
#define SPECIAL_HS_DETECT_TIME_MS (2 * 1000)
#define MBHC_BUTTON_PRESS_THRESHOLD_MIN 250
#define GND_MIC_SWAP_THRESHOLD 4
#define GND_MIC_USBC_SWAP_THRESHOLD 2
#define WCD_FAKE_REMOVAL_MIN_PERIOD_MS 100
#define HS_VREF_MIN_VAL 1400
#define FW_READ_ATTEMPTS 15
@@ -524,6 +525,7 @@ struct wcd_mbhc {
	bool gnd_swh; /*track GND switch NC / NO */
	u32 hs_thr;
	u32 hph_thr;
	u32 swap_thr;
	u32 moist_vref;
	u32 moist_iref;
	u32 moist_rref;