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

Commit 73f3c6c2 authored by Sudheer Papothi's avatar Sudheer Papothi
Browse files

ASoC: wcd9xxx: Add HPH auto pull down support



Add support for headphone auto pull down on WCD9330
to avoid noise while plugging headphone in car stereo.

Change-Id: I0da1300095b44269caefa0f469ab490e6b210361
Signed-off-by: default avatarSudheer Papothi <spapothi@codeaurora.org>
parent e92aa60f
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -7534,6 +7534,25 @@ static void tomtom_mbhc_micb_pulldown_ctrl(struct wcd9xxx_mbhc *mbhc,
	}
}

static void tomtom_codec_hph_auto_pull_down(struct snd_soc_codec *codec,
					    bool enable)
{
	struct wcd9xxx *tomtom_core = dev_get_drvdata(codec->dev->parent);

	if (TOMTOM_IS_1_0(tomtom_core->version))
		return;

	dev_dbg(codec->dev, "%s: %s auto pull down\n", __func__,
			enable ? "enable" : "disable");
	if (enable) {
		snd_soc_update_bits(codec, TOMTOM_A_RX_HPH_L_TEST, 0x08, 0x08);
		snd_soc_update_bits(codec, TOMTOM_A_RX_HPH_R_TEST, 0x08, 0x08);
	} else {
		snd_soc_update_bits(codec, TOMTOM_A_RX_HPH_L_TEST, 0x08, 0x00);
		snd_soc_update_bits(codec, TOMTOM_A_RX_HPH_R_TEST, 0x08, 0x00);
	}
}

static const struct wcd9xxx_mbhc_cb mbhc_cb = {
	.get_cdc_type = tomtom_get_cdc_type,
	.setup_zdet = tomtom_setup_zdet,
@@ -7542,6 +7561,7 @@ static const struct wcd9xxx_mbhc_cb mbhc_cb = {
	.insert_rem_status = tomtom_mbhc_ins_rem_status,
	.micbias_pulldown_ctrl = tomtom_mbhc_micb_pulldown_ctrl,
	.codec_rco_ctrl = tomtom_codec_internal_rco_ctrl,
	.hph_auto_pulldown_ctrl = tomtom_codec_hph_auto_pull_down,
};

static const struct wcd9xxx_mbhc_intr cdc_intr_ids = {
+13 −0
Original line number Diff line number Diff line
@@ -874,6 +874,9 @@ static void wcd9xxx_report_plug(struct wcd9xxx_mbhc *mbhc, int insertion,
		hphlocp_off_report(mbhc, SND_JACK_OC_HPHL);
		mbhc->current_plug = PLUG_TYPE_NONE;
		mbhc->polling_active = false;
		if (mbhc->mbhc_cb && mbhc->mbhc_cb->hph_auto_pulldown_ctrl)
			mbhc->mbhc_cb->hph_auto_pulldown_ctrl(mbhc->codec,
								false);
	} else {
		/*
		 * Report removal of current jack type.
@@ -901,6 +904,11 @@ static void wcd9xxx_report_plug(struct wcd9xxx_mbhc *mbhc, int insertion,
						SND_JACK_LINEOUT |
						SND_JACK_ANC_HEADPHONE |
						SND_JACK_UNSUPPORTED);
			if (mbhc->mbhc_cb &&
				 mbhc->mbhc_cb->hph_auto_pulldown_ctrl)
				mbhc->mbhc_cb->hph_auto_pulldown_ctrl(
								mbhc->codec,
								false);
		}

		/* Report insertion */
@@ -3198,6 +3206,11 @@ static void wcd9xxx_correct_swch_plug(struct work_struct *work)
		WCD9XXX_BCL_UNLOCK(mbhc->resmgr);
	}

	if (plug_type == PLUG_TYPE_HEADPHONE) {
		if (mbhc->mbhc_cb && mbhc->mbhc_cb->hph_auto_pulldown_ctrl)
			mbhc->mbhc_cb->hph_auto_pulldown_ctrl(codec, true);
	}

	if (!correction && current_source_enable) {
		WCD9XXX_BCL_LOCK(mbhc->resmgr);
		wcd9xxx_turn_onoff_current_source(mbhc, &mbhc->mbhc_bias_regs,
+1 −0
Original line number Diff line number Diff line
@@ -294,6 +294,7 @@ struct wcd9xxx_mbhc_cb {
	bool (*insert_rem_status) (struct snd_soc_codec *);
	void (*micbias_pulldown_ctrl) (struct wcd9xxx_mbhc *, bool);
	int (*codec_rco_ctrl) (struct snd_soc_codec *, bool);
	void (*hph_auto_pulldown_ctrl) (struct snd_soc_codec *, bool);
};

struct wcd9xxx_mbhc {