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

Commit 803998b4 authored by Yeleswarapu Nagaradhesh's avatar Yeleswarapu Nagaradhesh
Browse files

ASoC: wcd: don't set autozeroing for conga



Conga analog codec has fix to support special headset detection
and button press. So no need to set autozeroing for conga.
Check for function pointer before accessing it.

Change-Id: I52a79a50d8f0a45d7320e63ed753050178ad2951
Signed-off-by: default avatarYeleswarapu Nagaradhesh <nagaradh@codeaurora.org>
parent 0b5fe757
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -185,6 +185,8 @@ static int msm8x16_wcd_enable_ext_mb_source(struct snd_soc_codec *codec,
static void msm8x16_trim_btn_reg(struct snd_soc_codec *codec);
static void msm8x16_wcd_set_micb_v(struct snd_soc_codec *codec);
static void msm8x16_wcd_set_boost_v(struct snd_soc_codec *codec);
static void msm8x16_wcd_set_auto_zeroing(struct snd_soc_codec *codec,
		bool enable);

struct msm8x16_wcd_spmi msm8x16_wcd_modules[MAX_MSM8X16_WCD_DEVICE];

@@ -218,6 +220,7 @@ static const struct wcd_mbhc_cb mbhc_cb = {
	.trim_btn_reg = msm8x16_trim_btn_reg,
	.compute_impedance = msm8x16_wcd_compute_impedance,
	.set_micbias_value = msm8x16_wcd_set_micb_v,
	.set_auto_zeroing = msm8x16_wcd_set_auto_zeroing,
};

int msm8x16_unregister_notifier(struct snd_soc_codec *codec,
@@ -2011,6 +2014,32 @@ static int msm8x16_wcd_codec_enable_dmic(struct snd_soc_dapm_widget *w,
	return 0;
}


static void msm8x16_wcd_set_auto_zeroing(struct snd_soc_codec *codec,
					bool enable)
{
	struct msm8x16_wcd_priv *msm8x16_wcd = snd_soc_codec_get_drvdata(codec);

	if (get_codec_version(msm8x16_wcd) < CONGA) {
		if (enable)
			/*
			 * Set autozeroing for special headset detection and
			 * buttons to work.
			 */
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_ANALOG_MICB_2_EN,
				0x18, 0x10);
		else
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_ANALOG_MICB_2_EN,
				0x18, 0x00);

	} else {
		pr_debug("%s: Auto Zeroing is not required from CONGA\n",
				__func__);
	}
}

static void msm8x16_trim_btn_reg(struct snd_soc_codec *codec)
{
	struct msm8x16_wcd_priv *msm8x16_wcd = snd_soc_codec_get_drvdata(codec);
+14 −12
Original line number Diff line number Diff line
@@ -253,9 +253,8 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val,
			 * 50 msec for the MICBIAS to reach 2.7 volts.
			 */
			msleep(50);
			snd_soc_update_bits(codec,
					MSM8X16_WCD_A_ANALOG_MICB_2_EN,
					0x18, 0x10);
			if (mbhc->mbhc_cb && mbhc->mbhc_cb->set_auto_zeroing)
				mbhc->mbhc_cb->set_auto_zeroing(codec, true);
			snd_soc_update_bits(codec,
					MSM8X16_WCD_A_ANALOG_MICB_1_CTL,
					0x60, 0x00);
@@ -270,9 +269,9 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val,
		break;
	/* MICBIAS usage change */
	case WCD_EVENT_PRE_MICBIAS_2_OFF:
		snd_soc_update_bits(codec,
				MSM8X16_WCD_A_ANALOG_MICB_2_EN,
				0x18, 0x00);
		if (mbhc->mbhc_cb && mbhc->mbhc_cb->set_auto_zeroing)
			mbhc->mbhc_cb->set_auto_zeroing(codec, false);
		if (mbhc->mbhc_cb && mbhc->mbhc_cb->set_micbias_value)
			mbhc->mbhc_cb->set_micbias_value(codec);
		/* Enable current source again for polling */
		wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_CS);
@@ -615,6 +614,7 @@ exit:
	snd_soc_write(codec, MSM8X16_WCD_A_ANALOG_MBHC_BTN2_ZDETH_CTL, reg1);
	snd_soc_write(codec, MSM8X16_WCD_A_ANALOG_MBHC_DBNC_TIMER, reg0);
	snd_soc_write(codec, MSM8X16_WCD_A_ANALOG_MBHC_DET_CTL_2, reg2);
	if (mbhc->mbhc_cb && mbhc->mbhc_cb->compute_impedance)
		mbhc->mbhc_cb->compute_impedance(impedance_l, impedance_r,
					 zl, zr, high);

@@ -855,8 +855,8 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
			      0xC0);
		/* Wait for 50msec for MICBIAS to settle down */
		msleep(50);
		snd_soc_update_bits(codec, MSM8X16_WCD_A_ANALOG_MICB_2_EN,
					0x18, 0x10);
		if (mbhc->mbhc_cb && mbhc->mbhc_cb->set_auto_zeroing)
			mbhc->mbhc_cb->set_auto_zeroing(codec, true);
		/* Wait for 50msec for FSM to update result values */
		msleep(50);
		result2 = snd_soc_read(codec,
@@ -876,8 +876,10 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
		ret = true;
	}
	snd_soc_update_bits(codec, MSM8X16_WCD_A_ANALOG_MICB_1_CTL, 0x60, 0x00);
	if (mbhc->mbhc_cb && mbhc->mbhc_cb->set_micbias_value)
		mbhc->mbhc_cb->set_micbias_value(codec);
	snd_soc_update_bits(codec, MSM8X16_WCD_A_ANALOG_MICB_2_EN, 0x18, 0x00);
	if (mbhc->mbhc_cb && mbhc->mbhc_cb->set_auto_zeroing)
		mbhc->mbhc_cb->set_auto_zeroing(codec, false);

	pr_debug("%s: leave\n", __func__);
	return ret;
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ struct wcd_mbhc_cb {
	void (*trim_btn_reg) (struct snd_soc_codec *);
	void (*compute_impedance) (s16 , s16 , uint32_t *, uint32_t *, bool);
	void (*set_micbias_value) (struct snd_soc_codec *);
	void (*set_auto_zeroing) (struct snd_soc_codec *, bool);
};

struct wcd_mbhc {