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

Commit 6d1a19d4 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: wcd9xxx: Continue polling for Unsupported plug types"

parents a42b8dc9 528f2767
Loading
Loading
Loading
Loading
+60 −34
Original line number Diff line number Diff line
@@ -3098,6 +3098,37 @@ static bool wcd9xxx_mbhc_enable_mb_decision(int high_hph_cnt)
	return (high_hph_cnt > 2) && !(high_hph_cnt & (high_hph_cnt - 1));
}

static inline void wcd9xxx_handle_gnd_mic_swap(struct wcd9xxx_mbhc *mbhc,
					int pt_gnd_mic_swap_cnt,
					enum wcd9xxx_mbhc_plug_type plug_type)
{
	if (mbhc->mbhc_cfg->swap_gnd_mic &&
	    (pt_gnd_mic_swap_cnt == GND_MIC_SWAP_THRESHOLD)) {
		/*
		 * if switch is toggled, check again,
		 * otherwise report unsupported plug
		 */
		mbhc->mbhc_cfg->swap_gnd_mic(mbhc->codec);
	} else if (pt_gnd_mic_swap_cnt >= GND_MIC_SWAP_THRESHOLD) {
		/* Report UNSUPPORTED plug
		 * and continue polling
		 */
		WCD9XXX_BCL_LOCK(mbhc->resmgr);
		if (!mbhc->mbhc_cfg->detect_extn_cable) {
			if (mbhc->current_plug == PLUG_TYPE_HEADPHONE)
				wcd9xxx_report_plug(mbhc, 0,
						    SND_JACK_HEADPHONE);
			else if (mbhc->current_plug == PLUG_TYPE_HEADSET)
				wcd9xxx_report_plug(mbhc, 0,
						    SND_JACK_HEADSET);
		}
		if (mbhc->current_plug != plug_type)
			wcd9xxx_report_plug(mbhc, 1,
					SND_JACK_UNSUPPORTED);
		WCD9XXX_BCL_UNLOCK(mbhc->resmgr);
	}
}

static void wcd9xxx_correct_swch_plug(struct work_struct *work)
{
	struct wcd9xxx_mbhc *mbhc;
@@ -3212,24 +3243,15 @@ static void wcd9xxx_correct_swch_plug(struct work_struct *work)
		} else {
			if (plug_type == PLUG_TYPE_GND_MIC_SWAP) {
				pt_gnd_mic_swap_cnt++;
				if (pt_gnd_mic_swap_cnt <
				if (pt_gnd_mic_swap_cnt >=
						GND_MIC_SWAP_THRESHOLD)
					wcd9xxx_handle_gnd_mic_swap(mbhc,
							pt_gnd_mic_swap_cnt,
							plug_type);
				pr_debug("%s: unsupported HS detected, continue polling\n",
					 __func__);
				continue;
				else if (pt_gnd_mic_swap_cnt >
					 GND_MIC_SWAP_THRESHOLD) {
					/*
					 * This is due to GND/MIC switch didn't
					 * work,  Report unsupported plug
					 */
				} else if (mbhc->mbhc_cfg->swap_gnd_mic) {
					/*
					 * if switch is toggled, check again,
					 * otherwise report unsupported plug
					 */
					if (mbhc->mbhc_cfg->swap_gnd_mic(codec))
						continue;
				}
			} else
			} else {
				pt_gnd_mic_swap_cnt = 0;

				WCD9XXX_BCL_LOCK(mbhc->resmgr);
@@ -3239,15 +3261,19 @@ static void wcd9xxx_correct_swch_plug(struct work_struct *work)
							&mbhc->mbhc_bias_regs,
							false, false);
				else
				wcd9xxx_turn_onoff_override(mbhc, false);
					wcd9xxx_turn_onoff_override(mbhc,
								    false);
				/*
			 * The valid plug also includes PLUG_TYPE_GND_MIC_SWAP
				 * The valid plug also includes
				 * PLUG_TYPE_GND_MIC_SWAP
				 */
				wcd9xxx_find_plug_and_report(mbhc, plug_type);
				WCD9XXX_BCL_UNLOCK(mbhc->resmgr);
			pr_debug("Attempt %d found correct plug %d\n", retry,
				pr_debug("Attempt %d found correct plug %d\n",
						retry,
						plug_type);
				correction = true;
			}
			break;
		}
	}