Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752589AbdI2Rm7 (ORCPT ); Fri, 29 Sep 2017 13:42:59 -0400 Received: from mail.savoirfairelinux.com ([208.88.110.44]:54404 "EHLO mail.savoirfairelinux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752525AbdI2Rmz (ORCPT ); Fri, 29 Sep 2017 13:42:55 -0400 From: Damien Riegel To: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , kernel@savoirfairelinux.com, Damien Riegel Subject: [PATCH v1 2/2] ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup Date: Fri, 29 Sep 2017 13:42:46 -0400 Message-Id: <20170929174246.12144-3-damien.riegel@savoirfairelinux.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170929174246.12144-1-damien.riegel@savoirfairelinux.com> References: <20170929174246.12144-1-damien.riegel@savoirfairelinux.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1532 Lines: 40 The very first time a headset is plugged in, detection is unreliable because bias hasn't been configured yet, it's done once a mechanical insertion interrupt has been triggered, so following insertions (and thus detections) are not affected. To fix the very first detection, the bias must also be configured in the function that setup the MBHC. Signed-off-by: Damien Riegel Acked-by: Srinivas Kandagatla --- sound/soc/codecs/msm8916-wcd-analog.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index 9f08d998a79b..71494e9dbdcb 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -493,6 +493,7 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd) { struct snd_soc_codec *codec = wcd->codec; + bool micbias_enabled = false; u32 plug_type = 0; u32 int_en_mask; @@ -524,6 +525,11 @@ static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd) DIG_CLK_CTL_D_MBHC_CLK_EN_MASK, DIG_CLK_CTL_D_MBHC_CLK_EN); + if (snd_soc_read(codec, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE) + micbias_enabled = true; + + pm8916_mbhc_configure_bias(wcd, micbias_enabled); + int_en_mask = MBHC_SWITCH_INT; if (wcd->mbhc_btn_enabled) int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET; -- 2.14.1