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

Commit 648c5075 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: move DCE_Z recalibration after mic measurements"

parents e0e2bb07 b17402be
Loading
Loading
Loading
Loading
+35 −9
Original line number Diff line number Diff line
@@ -208,6 +208,10 @@ static void wcd9xxx_get_z(struct wcd9xxx_mbhc *mbhc, s16 *dce_z, s16 *sta_z,

static void wcd9xxx_mbhc_calc_thres(struct wcd9xxx_mbhc *mbhc);

static u16 wcd9xxx_codec_v_sta_dce(struct wcd9xxx_mbhc *mbhc,
				   enum meas_type dce, s16 vin_mv,
				   bool cs_enable);

static bool wcd9xxx_mbhc_polling(struct wcd9xxx_mbhc *mbhc)
{
	return snd_soc_read(mbhc->codec, WCD9XXX_A_CDC_MBHC_EN_CTL) & 0x1;
@@ -1204,10 +1208,6 @@ static short wcd9xxx_mbhc_setup_hs_polling(struct wcd9xxx_mbhc *mbhc,
	struct snd_soc_codec *codec = mbhc->codec;
	short bias_value;
	u8 cfilt_mode;
	s16 reg;
	int change;
	struct wcd9xxx_mbhc_btn_detect_cfg *btn_det;
	s16 sta_z = 0, dce_z = 0;

	WCD9XXX_BCL_ASSERT_LOCKED(mbhc->resmgr);

@@ -1217,7 +1217,6 @@ static short wcd9xxx_mbhc_setup_hs_polling(struct wcd9xxx_mbhc *mbhc,
		return -ENODEV;
	}

	btn_det = WCD9XXX_MBHC_CAL_BTN_DET_PTR(mbhc->mbhc_cfg->calibration);
	/* Enable external voltage source to micbias if present */
	if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mb_source)
		mbhc->mbhc_cb->enable_mb_source(codec, true, true);
@@ -1277,6 +1276,21 @@ static short wcd9xxx_mbhc_setup_hs_polling(struct wcd9xxx_mbhc *mbhc,
	snd_soc_write(codec, mbhc_micb_regs->cfilt_ctl, cfilt_mode);
	snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x13, 0x00);

	return bias_value;
}

static void wcd9xxx_recalibrate(struct wcd9xxx_mbhc *mbhc,
				struct mbhc_micbias_regs *mbhc_micb_regs,
				bool is_cs_enable)
{
	struct snd_soc_codec *codec = mbhc->codec;
	s16 reg;
	int change;
	struct wcd9xxx_mbhc_btn_detect_cfg *btn_det;
	s16 sta_z = 0, dce_z = 0;

	btn_det = WCD9XXX_MBHC_CAL_BTN_DET_PTR(mbhc->mbhc_cfg->calibration);

	if (mbhc->mbhc_cfg->do_recalibration) {
		/* recalibrate dce_z and sta_z */
		reg = snd_soc_read(codec, WCD9XXX_A_CDC_MBHC_B1_CTL);
@@ -1311,17 +1325,24 @@ static short wcd9xxx_mbhc_setup_hs_polling(struct wcd9xxx_mbhc *mbhc,
			snd_soc_write(mbhc->codec, WCD9XXX_A_CDC_MBHC_B1_CTL,
				      reg);
			if (dce_z) {
				pr_debug("%s: dce_nsc_cs_z 0x%x -> 0x%x\n",
					 __func__, mbhc->mbhc_data.dce_nsc_cs_z,
					 dce_z & 0xffff);
				mbhc->mbhc_data.dce_nsc_cs_z = dce_z;
				/* update v_cs_ins_h with new dce_nsc_cs_z */
				mbhc->mbhc_data.v_cs_ins_h =
						wcd9xxx_codec_v_sta_dce(
							mbhc, DCE,
							WCD9XXX_V_CS_HS_MAX,
							is_cs_enable);
				pr_debug("%s: dce_nsc_cs_z 0x%x -> 0x%x, v_cs_ins_h 0x%x\n",
					  __func__,
					  mbhc->mbhc_data.dce_nsc_cs_z,
					  dce_z & 0xffff,
					  mbhc->mbhc_data.v_cs_ins_h);
			} else {
				pr_debug("%s: failed get new dce_nsc_cs_z\n",
					 __func__);
			}
		}
	}
	return bias_value;
}

static void wcd9xxx_shutdown_hs_removal_detect(struct wcd9xxx_mbhc *mbhc)
@@ -1898,6 +1919,9 @@ wcd9xxx_codec_cs_get_plug_type(struct wcd9xxx_mbhc *mbhc, bool highhph)
			wcd9xxx_codec_hphr_gnd_switch(codec, false);
	}

	/* recalibrate DCE/STA GND voltages */
	wcd9xxx_recalibrate(mbhc, &mbhc->mbhc_bias_regs, true);

	type = wcd9xxx_cs_find_plug_type(mbhc, rt, ARRAY_SIZE(rt), highhph,
					 mbhc->event_state);

@@ -1978,6 +2002,8 @@ wcd9xxx_codec_get_plug_type(struct wcd9xxx_mbhc *mbhc, bool highhph)
		if (rt[i].swap_gnd)
			wcd9xxx_codec_hphr_gnd_switch(codec, false);
	}
	/* recalibrate DCE/STA GND voltages */
	wcd9xxx_recalibrate(mbhc, &mbhc->mbhc_bias_regs, false);

	if (vddioon)
		__wcd9xxx_switch_micbias(mbhc, 1, false, false);