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

Commit a1a8b5dc authored by Phani Kumar Uppalapati's avatar Phani Kumar Uppalapati Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: wcd9xxx: Handle codec register config if MBHC is disabled



On codec reset, mic and micbias pulldown bits are enabled
by default. In cases when MBHC block on the codec is not
enabled, the pulldown bits should be disabled so that mic
and micbias can be enabled for voice call use cases on Headset.
Add support to check whether MBHC is enabled and update the
pulldown bits accordingly. Also, it is possible that DCE_Z
and DCE_MB calibration values can be zero if MBHC block is not
enabled, add check to avoid division by zero in this scenario.

Change-Id: Ica9d95142770d3e905ab71a1923c7e389c523d6f
Signed-off-by: default avatarPhani Kumar Uppalapati <phaniu@codeaurora.org>
parent 29561e63
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -7662,9 +7662,20 @@ int tomtom_hs_detect(struct snd_soc_codec *codec,
{
	int rc;
	struct tomtom_priv *tomtom = snd_soc_codec_get_drvdata(codec);

	if (mbhc_cfg->insert_detect) {
		rc = wcd9xxx_mbhc_start(&tomtom->mbhc, mbhc_cfg);
		if (!rc)
			tomtom->mbhc_started = true;
	} else {
		/* MBHC is disabled, so disable Auto pulldown */
		snd_soc_update_bits(codec, TOMTOM_A_MBHC_INSERT_DETECT2, 0xC0,
				    0x00);
		snd_soc_update_bits(codec, TOMTOM_A_MICB_CFILT_2_CTL, 0x01,
				    0x00);
		tomtom->mbhc.mbhc_cfg = NULL;
		rc = 0;
	}
	return rc;
}
EXPORT_SYMBOL(tomtom_hs_detect);
+11 −4
Original line number Diff line number Diff line
@@ -1146,14 +1146,16 @@ static s32 __wcd9xxx_codec_sta_dce_v(struct wcd9xxx_mbhc *mbhc, s8 dce,
				     u16 bias_value, s16 z, u32 micb_mv)
{
	s16 value, mb;
	s32 mv;
	s32 mv = 0;

	value = bias_value;
	if (dce) {
		mb = (mbhc->mbhc_data.dce_mb);
		if (mb - z)
			mv = (value - z) * (s32)micb_mv / (mb - z);
	} else {
		mb = (mbhc->mbhc_data.sta_mb);
		if (mb - z)
			mv = (value - z) * (s32)micb_mv / (mb - z);
	}

@@ -4736,12 +4738,17 @@ static int wcd9xxx_event_notify(struct notifier_block *self, unsigned long val,
{
	int ret = 0;
	struct wcd9xxx_mbhc *mbhc = ((struct wcd9xxx_resmgr *)data)->mbhc;
	struct snd_soc_codec *codec = mbhc->codec;
	struct snd_soc_codec *codec;
	enum wcd9xxx_notify_event event = (enum wcd9xxx_notify_event)val;

	pr_debug("%s: enter event %s(%d)\n", __func__,
		 wcd9xxx_get_event_string(event), event);

	if (!mbhc || !mbhc->mbhc_cfg) {
		pr_debug("mbhc not initialized\n");
		return 0;
	}
	codec = mbhc->codec;
	mutex_lock(&mbhc->mbhc_lock);
	switch (event) {
	/* MICBIAS usage change */