From 9fe98418b2c518f44b17cbd153239201a3c95fe0 Mon Sep 17 00:00:00 2001 From: Yeleswarapu Nagaradhesh Date: Sun, 12 Apr 2015 15:35:31 +0530 Subject: [PATCH] ASoC: wcd: skip impedance detection after SSR While recording, if SSR is triggered POP noise is generated due to disabling of micbias during impedance detection. So, skip impedance detection after SSR to resolve the POP. CRs-Fixed: 809007 Change-Id: I0d74d01d7fae8f019fb8b38d54083f1e169e0d64 Signed-off-by: Yeleswarapu Nagaradhesh --- sound/soc/codecs/msm8x16-wcd.c | 14 ++++++++++++++ sound/soc/codecs/wcd-mbhc-v2.c | 13 +++++++++++++ sound/soc/codecs/wcd-mbhc-v2.h | 2 ++ 3 files changed, 29 insertions(+) diff --git a/sound/soc/codecs/msm8x16-wcd.c b/sound/soc/codecs/msm8x16-wcd.c index bff69898c509..71bd82c83c2b 100644 --- a/sound/soc/codecs/msm8x16-wcd.c +++ b/sound/soc/codecs/msm8x16-wcd.c @@ -207,6 +207,7 @@ static void msm8x16_wcd_set_auto_zeroing(struct snd_soc_codec *codec, bool enable); static void msm8x16_wcd_configure_cap(struct snd_soc_codec *codec, bool micbias1, bool micbias2); +static void msm8x16_skip_imped_detect(struct snd_soc_codec *codec); struct msm8x16_wcd_spmi msm8x16_wcd_modules[MAX_MSM8X16_WCD_DEVICE]; @@ -274,6 +275,7 @@ static const struct wcd_mbhc_cb mbhc_cb = { .set_auto_zeroing = msm8x16_wcd_set_auto_zeroing, .get_hwdep_fw_cal = msm8x16_wcd_get_hwdep_fw_cal, .set_cap_mode = msm8x16_wcd_configure_cap, + .skip_imped_detect = msm8x16_skip_imped_detect, }; static const uint32_t wcd_imped_val[] = {4, 8, 12, 16, @@ -2504,6 +2506,18 @@ static void msm8x16_wcd_set_auto_zeroing(struct snd_soc_codec *codec, } } +static void msm8x16_skip_imped_detect(struct snd_soc_codec *codec) +{ + struct msm8x16_wcd_priv *msm8x16_wcd; + + if (codec != NULL) { + msm8x16_wcd = snd_soc_codec_get_drvdata(codec); + msm8x16_wcd->mbhc.skip_imped_detection = true; + } else { + pr_debug("%s: Codec pointer is NULL\n", __func__); + } +} + static void msm8x16_trim_btn_reg(struct snd_soc_codec *codec) { struct msm8x16_wcd_priv *msm8x16_wcd = snd_soc_codec_get_drvdata(codec); diff --git a/sound/soc/codecs/wcd-mbhc-v2.c b/sound/soc/codecs/wcd-mbhc-v2.c index e1be6d8b064d..da8b2a5c3012 100644 --- a/sound/soc/codecs/wcd-mbhc-v2.c +++ b/sound/soc/codecs/wcd-mbhc-v2.c @@ -468,6 +468,13 @@ static void wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, bool high = false; pr_debug("%s: enter\n", __func__); + if (mbhc->skip_imped_detection) { + pr_debug("%s: Skip imped detect RL %d ohm, RR %d ohm\n", + __func__, mbhc->zl, mbhc->zr); + mbhc->skip_imped_detection = false; + goto skip_imped_detect; + } + WCD_MBHC_RSC_ASSERT_LOCKED(mbhc); reg0 = snd_soc_read(codec, MSM8X16_WCD_A_ANALOG_MBHC_DBNC_TIMER); @@ -652,6 +659,7 @@ exit: zl, zr, high); pr_debug("%s: RL %d ohm, RR %d ohm\n", __func__, *zl, *zr); +skip_imped_detect: pr_debug("%s: Impedance detection completed\n", __func__); } @@ -1988,6 +1996,10 @@ EXPORT_SYMBOL(wcd_mbhc_start); void wcd_mbhc_stop(struct wcd_mbhc *mbhc) { pr_debug("%s: enter\n", __func__); + if (mbhc->current_plug != MBHC_PLUG_TYPE_NONE) { + if (mbhc->mbhc_cb && mbhc->mbhc_cb->skip_imped_detect) + mbhc->mbhc_cb->skip_imped_detect(mbhc->codec); + } mbhc->current_plug = MBHC_PLUG_TYPE_NONE; mbhc->hph_status = 0; wcd9xxx_spmi_disable_irq(mbhc->intr_ids->hph_left_ocp); @@ -2051,6 +2063,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, mbhc->is_hs_recording = false; mbhc->is_extn_cable = false; mbhc->hph_type = WCD_MBHC_HPH_NONE; + mbhc->skip_imped_detection = false; if (mbhc->intr_ids == NULL) { pr_err("%s: Interrupt mapping not provided\n", __func__); diff --git a/sound/soc/codecs/wcd-mbhc-v2.h b/sound/soc/codecs/wcd-mbhc-v2.h index 39846b564925..bcbd0b0a186c 100644 --- a/sound/soc/codecs/wcd-mbhc-v2.h +++ b/sound/soc/codecs/wcd-mbhc-v2.h @@ -153,6 +153,7 @@ struct wcd_mbhc_cb { struct firmware_cal * (*get_hwdep_fw_cal)(struct snd_soc_codec *, enum wcd_cal_type); void (*set_cap_mode)(struct snd_soc_codec *, bool, bool); + void (*skip_imped_detect)(struct snd_soc_codec *); }; struct wcd_mbhc { @@ -179,6 +180,7 @@ struct wcd_mbhc { bool btn_press_intr; bool is_hs_recording; bool is_extn_cable; + bool skip_imped_detection; struct snd_soc_codec *codec; /* Work to perform MBHC Firmware Read */