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

Commit 745ff7e1 authored by Kuirong Wang's avatar Kuirong Wang
Browse files

ASoC: msm8x10-wcd: Update the codec configuration sequence after SSR



After Sub-System Restart (SSR), codec is not restored back to correct
state prior to SSR which causes the headset detection failure.
Update the codec configuration sequence after SSR to be the correct
state including MBHC configuration.

Change-Id: I3839435d6113a56e9525907c43d4e03fa7d8be52
CRs-fixed: 599247
Signed-off-by: default avatarKuirong Wang <kuirongw@codeaurora.org>
parent 97d5ac84
Loading
Loading
Loading
Loading
+36 −14
Original line number Diff line number Diff line
@@ -3157,9 +3157,25 @@ static int msm8x10_wcd_device_down(struct snd_soc_codec *codec)
	return 0;
}

static const struct wcd9xxx_mbhc_intr cdc_intr_ids = {
	.poll_plug_rem = MSM8X10_WCD_IRQ_MBHC_REMOVAL,
	.shortavg_complete = MSM8X10_WCD_IRQ_MBHC_SHORT_TERM,
	.potential_button_press = MSM8X10_WCD_IRQ_MBHC_PRESS,
	.button_release = MSM8X10_WCD_IRQ_MBHC_RELEASE,
	.dce_est_complete = MSM8X10_WCD_IRQ_MBHC_POTENTIAL,
	.insertion = MSM8X10_WCD_IRQ_MBHC_INSERTION,
	.hph_left_ocp = MSM8X10_WCD_IRQ_HPH_PA_OCPL_FAULT,
	.hph_right_ocp = MSM8X10_WCD_IRQ_HPH_PA_OCPR_FAULT,
	.hs_jack_switch = MSM8X10_WCD_IRQ_MBHC_HS_DET,
};

static int msm8x10_wcd_device_up(struct snd_soc_codec *codec)
{
	dev_dbg(codec->dev, "%s: device up!\n", __func__);
	int ret = 0;
	struct msm8x10_wcd_priv *msm8x10_wcd_priv =
					snd_soc_codec_get_drvdata(codec);

	dev_err(codec->dev, "%s: device up!\n", __func__);

	snd_soc_card_change_online_state(codec->card, 1);
	/* delay is required to make sure sound card state updated */
@@ -3168,9 +3184,27 @@ static int msm8x10_wcd_device_up(struct snd_soc_codec *codec)
	mutex_lock(&codec->mutex);

	msm8x10_wcd_bringup(codec);
	msm8x10_wcd_codec_init_reg(codec);

	msm8x10_wcd_update_reg_defaults(codec);

	msm8x10_wcd_codec_init_reg(codec);

	wcd9xxx_resmgr_post_ssr(&msm8x10_wcd_priv->resmgr);

	wcd9xxx_mbhc_deinit(&msm8x10_wcd_priv->mbhc);

	ret = wcd9xxx_mbhc_init(&msm8x10_wcd_priv->mbhc,
				&msm8x10_wcd_priv->resmgr,
				codec, msm8x10_wcd_enable_mbhc_micbias,
				&mbhc_cb, &cdc_intr_ids,
				HELICON_MCLK_CLK_9P6MHZ, true);
	if (ret)
		dev_err(codec->dev, "%s: Failed to initialize mbhc\n",
			__func__);
	else
		wcd9xxx_mbhc_start(&msm8x10_wcd_priv->mbhc,
				msm8x10_wcd_priv->mbhc.mbhc_cfg);

	mutex_unlock(&codec->mutex);

	return 0;
@@ -3215,18 +3249,6 @@ static struct notifier_block adsp_state_notifier_block = {
	.priority = -INT_MAX,
};

static const struct wcd9xxx_mbhc_intr cdc_intr_ids = {
	.poll_plug_rem = MSM8X10_WCD_IRQ_MBHC_REMOVAL,
	.shortavg_complete = MSM8X10_WCD_IRQ_MBHC_SHORT_TERM,
	.potential_button_press = MSM8X10_WCD_IRQ_MBHC_PRESS,
	.button_release = MSM8X10_WCD_IRQ_MBHC_RELEASE,
	.dce_est_complete = MSM8X10_WCD_IRQ_MBHC_POTENTIAL,
	.insertion = MSM8X10_WCD_IRQ_MBHC_INSERTION,
	.hph_left_ocp = MSM8X10_WCD_IRQ_HPH_PA_OCPL_FAULT,
	.hph_right_ocp = MSM8X10_WCD_IRQ_HPH_PA_OCPR_FAULT,
	.hs_jack_switch = MSM8X10_WCD_IRQ_MBHC_HS_DET,
};

static int msm8x10_wcd_handle_pdata(struct snd_soc_codec *codec,
	struct msm8x10_wcd_pdata *pdata)
{