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

Commit 1e6369d2 authored by Bhalchandra Gajare's avatar Bhalchandra Gajare
Browse files

ASoC: WCD9XXX: Add configurable micbias option for headset detection



Micbias is required to perform plug type detection on 3.5mm headset
jack. Some platforms can have the microphone pulled up to micbias using
external on-board pull up resistor or using the pull up resistor
internal to the codec. Add support for headset detection logic to
support configurable option for internal or external micbias.

CRs-fixed: 539445
Change-Id: I9438812f0a924c22932dacc56181cf997625e056
Signed-off-by: default avatarBhalchandra Gajare <gajare@codeaurora.org>
parent b9eab1f9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2692,6 +2692,12 @@ static int msm8x10_wcd_enable_ext_mb_source(struct snd_soc_codec *codec,
	return ret;
}

static void msm8x10_wcd_micb_internal(struct snd_soc_codec *codec, bool on)
{
	snd_soc_update_bits(codec, MSM8X10_WCD_A_MICB_1_INT_RBIAS,
			    0x1C, on ? 0x14 : 0x00);
}

static const struct wcd9xxx_mbhc_cb mbhc_cb = {
	.enable_mux_bias_block = msm8x10_wcd_enable_mux_bias_block,
	.cfilt_fast_mode = msm8x10_wcd_put_cfilt_fast_mode,
@@ -2704,6 +2710,7 @@ static const struct wcd9xxx_mbhc_cb mbhc_cb = {
	.enable_clock_gate = msm8x10_wcd_mbhc_clk_gate,
	.enable_mbhc_txfe = msm8x10_wcd_mbhc_txfe,
	.enable_mb_source = msm8x10_wcd_enable_ext_mb_source,
	.setup_int_rbias = msm8x10_wcd_micb_internal,
};

static void delayed_hs_detect_fn(struct work_struct *work)
+12 −0
Original line number Diff line number Diff line
@@ -3948,6 +3948,18 @@ int wcd9xxx_mbhc_start(struct wcd9xxx_mbhc *mbhc,
		snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.cfilt_ctl,
		0x40, WCD9XXX_CFILT_FAST_MODE);

	/*
	 * setup internal micbias if codec uses internal micbias for
	 * headset detection
	 */
	if (mbhc->mbhc_cfg->use_int_rbias) {
		if (mbhc->mbhc_cb && mbhc->mbhc_cb->setup_int_rbias)
			mbhc->mbhc_cb->setup_int_rbias(codec, true);
		else
			pr_info("%s: internal bias is requested but codec did not provide callback\n",
				__func__);
	}

	/*
	 * If codec has specific clock gating for MBHC,
	 * remove the clock gate
+2 −0
Original line number Diff line number Diff line
@@ -227,6 +227,7 @@ struct wcd9xxx_mbhc_config {
	/* swap_gnd_mic returns true if extern GND/MIC swap switch toggled */
	bool (*swap_gnd_mic) (struct snd_soc_codec *);
	unsigned long cs_enable_flags;
	bool use_int_rbias;
};

struct wcd9xxx_cfilt_mode {
@@ -252,6 +253,7 @@ struct wcd9xxx_mbhc_cb {
	void (*compute_impedance) (s16 *, s16 *, uint32_t *, uint32_t *);
	void (*enable_mbhc_txfe) (struct snd_soc_codec *, bool);
	int (*enable_mb_source) (struct snd_soc_codec *, bool);
	void (*setup_int_rbias) (struct snd_soc_codec *, bool);
};

struct wcd9xxx_mbhc {