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

Commit 00a4b28b authored by Phani Kumar Uppalapati's avatar Phani Kumar Uppalapati
Browse files

ASoC: wcd9xxx: Notify mbhc when TX3 path is enabled



On Tapan, ADC2/3 both being the same, it is possible that
polling noise can be captured in the recorded audio when
IN3 path is used for the recording with headset inserted.
Notify MBHC when IN3/TX3 path is enabled so that micbias
source can be switched to VDDIO to avoid polling noise to
be captured in the recorded audio.

Change-Id: Iad7fcb4e448ff879297f37d3c5c4f260072966b2
Signed-off-by: default avatarPhani Kumar Uppalapati <phaniu@codeaurora.org>
parent b26a0ee6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1863,6 +1863,7 @@ static int tapan_codec_enable_adc(struct snd_soc_dapm_widget *w,
	struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_codec *codec = w->codec;
	struct tapan_priv *tapan = snd_soc_codec_get_drvdata(codec);
	u16 adc_reg;
	u8 init_bit_shift;

@@ -1890,6 +1891,9 @@ static int tapan_codec_enable_adc(struct snd_soc_dapm_widget *w,

	switch (event) {
	case SND_SOC_DAPM_PRE_PMU:
		if (w->reg == TAPAN_A_TX_3_EN)
			wcd9xxx_resmgr_notifier_call(&tapan->resmgr,
						WCD9XXX_EVENT_PRE_TX_3_ON);
		snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift,
				1 << init_bit_shift);
		break;
@@ -1898,6 +1902,11 @@ static int tapan_codec_enable_adc(struct snd_soc_dapm_widget *w,
		snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 0x00);

		break;
	case SND_SOC_DAPM_POST_PMD:
		if (w->reg == TAPAN_A_TX_3_EN)
			wcd9xxx_resmgr_notifier_call(&tapan->resmgr,
						WCD9XXX_EVENT_POST_TX_3_OFF);
		break;
	}
	return 0;
}
+26 −2
Original line number Diff line number Diff line
@@ -4259,7 +4259,8 @@ static int wcd9xxx_event_notify(struct notifier_block *self, unsigned long val,
		if (mbhc->hph_status & SND_JACK_OC_HPHL)
			hphlocp_off_report(mbhc, SND_JACK_OC_HPHL);
		if (!(mbhc->event_state &
		      (1 << MBHC_EVENT_PA_HPHL | 1 << MBHC_EVENT_PA_HPHR)))
		      (1 << MBHC_EVENT_PA_HPHL | 1 << MBHC_EVENT_PA_HPHR |
		       1 << MBHC_EVENT_PRE_TX_3_ON)))
			wcd9xxx_switch_micbias(mbhc, 0);
		break;
	case WCD9XXX_EVENT_POST_HPHR_PA_OFF:
@@ -4270,7 +4271,8 @@ static int wcd9xxx_event_notify(struct notifier_block *self, unsigned long val,
		if (mbhc->hph_status & SND_JACK_OC_HPHR)
			hphrocp_off_report(mbhc, SND_JACK_OC_HPHL);
		if (!(mbhc->event_state &
		      (1 << MBHC_EVENT_PA_HPHL | 1 << MBHC_EVENT_PA_HPHR)))
		      (1 << MBHC_EVENT_PA_HPHL | 1 << MBHC_EVENT_PA_HPHR |
		       1 << MBHC_EVENT_PRE_TX_3_ON)))
			wcd9xxx_switch_micbias(mbhc, 0);
		break;
	/* Clock usage change */
@@ -4352,6 +4354,28 @@ static int wcd9xxx_event_notify(struct notifier_block *self, unsigned long val,
	case WCD9XXX_EVENT_POST_BG_MBHC_ON:
		/* Not used for now */
		break;
	case WCD9XXX_EVENT_PRE_TX_3_ON:
		/*
		 * if polling is ON, mbhc micbias not enabled
		 *  switch micbias source to VDDIO
		 */
		set_bit(MBHC_EVENT_PRE_TX_3_ON, &mbhc->event_state);
		if (!(snd_soc_read(codec, mbhc->mbhc_bias_regs.ctl_reg)
		      & 0x80) &&
		    mbhc->polling_active && !mbhc->mbhc_micbias_switched)
			wcd9xxx_switch_micbias(mbhc, 1);
		break;
	case WCD9XXX_EVENT_POST_TX_3_OFF:
		/*
		 * Switch back to micbias if HPH PA or TX3 path
		 * is disabled
		 */
		clear_bit(MBHC_EVENT_PRE_TX_3_ON, &mbhc->event_state);
		if (mbhc->polling_active && mbhc->mbhc_micbias_switched &&
		    !(mbhc->event_state & (1 << MBHC_EVENT_PA_HPHL |
		      1 << MBHC_EVENT_PA_HPHR)))
			wcd9xxx_switch_micbias(mbhc, 0);
		break;
	default:
		WARN(1, "Unknown event %d\n", event);
		ret = -EINVAL;
+2 −0
Original line number Diff line number Diff line
@@ -123,6 +123,8 @@ enum wcd9xxx_mbhc_clk_freq {
enum wcd9xxx_mbhc_event_state {
	MBHC_EVENT_PA_HPHL,
	MBHC_EVENT_PA_HPHR,
	MBHC_EVENT_PRE_TX_3_ON,
	MBHC_EVENT_POST_TX_3_OFF,
};

struct wcd9xxx_mbhc_general_cfg {
+3 −0
Original line number Diff line number Diff line
@@ -92,6 +92,9 @@ static char wcd9xxx_event_string[][64] = {

	"WCD9XXX_EVENT_POST_RESUME",

	"WCD9XXX_EVENT_PRE_TX_3_ON",
	"WCD9XXX_EVENT_POST_TX_3_OFF",

	"WCD9XXX_EVENT_LAST",
};

+3 −0
Original line number Diff line number Diff line
@@ -105,6 +105,9 @@ enum wcd9xxx_notify_event {

	WCD9XXX_EVENT_POST_RESUME,

	WCD9XXX_EVENT_PRE_TX_3_ON,
	WCD9XXX_EVENT_POST_TX_3_OFF,

	WCD9XXX_EVENT_LAST,
};