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

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

ASoC: msm: Add hph gpio control for impedance detection



For headphone impedance detection, the switches controlling
the hifi amp enable need to be pulled high, otherwise
hph left and right impedance measurements are not accurate.
Add gpio control needed for headphone impedance detection.

Change-Id: I0df8fbdfb39bc954fe5c7d953791caeca46eefcf
Signed-off-by: default avatarPhani Kumar Uppalapati <phaniu@codeaurora.org>
parent f34a3ba0
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -1499,6 +1499,28 @@ static int msm8996_codec_event_cb(struct snd_soc_codec *codec,
	}
}

static int msm8996_config_hph_en0_gpio(struct snd_soc_codec *codec, bool high)
{
	struct snd_soc_card *card = codec->component.card;
	struct msm8996_asoc_mach_data *pdata;
	int val;

	if (!card)
		return 0;

	pdata = snd_soc_card_get_drvdata(card);
	if (!pdata || !gpio_is_valid(pdata->hph_en0_gpio))
		return 0;

	val = gpio_get_value_cansleep(pdata->hph_en0_gpio);
	if ((!!val) == high)
		return 0;

	gpio_direction_output(pdata->hph_en0_gpio, (int)high);

	return 1;
}

static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
{
	int err;
@@ -1664,9 +1686,11 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
		}
	}
	/* Start mbhc */
	if (cdc_type)
	if (cdc_type) {
		tasha_mbhc_zdet_gpio_ctrl(msm8996_config_hph_en0_gpio,
					  rtd->codec);
		mbhc_calibration = def_tasha_mbhc_cal();
	else
	} else
		mbhc_calibration = def_codec_mbhc_cal();
	if (mbhc_calibration) {
		if (cdc_type) {