mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup
@ 2017-10-03 13:27 Damien Riegel
  2017-10-03 20:42 ` Srinivas Kandagatla
  2017-10-04 11:28 ` Applied "ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup" to the asoc tree Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Damien Riegel @ 2017-10-03 13:27 UTC (permalink / raw)
  To: alsa-devel, linux-kernel
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Srinivas Kandagatla, kernel, Damien Riegel

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. Move pm8916_wcd_setup_mbhc after
pm8916_mbhc_configure_bias to avoid a forward declaration.

Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
---
Changes in v2:
 - squash the two patches in one patch only

 sound/soc/codecs/msm8916-wcd-analog.c | 94 +++++++++++++++++++----------------
 1 file changed, 50 insertions(+), 44 deletions(-)

diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
index f562f2d86907..71494e9dbdcb 100644
--- a/sound/soc/codecs/msm8916-wcd-analog.c
+++ b/sound/soc/codecs/msm8916-wcd-analog.c
@@ -443,50 +443,6 @@ static int pm8916_wcd_analog_enable_micbias_int1(struct
 						     wcd->micbias1_cap_mode);
 }
 
-static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
-{
-	struct snd_soc_codec *codec = wcd->codec;
-	u32 plug_type = 0;
-	u32 int_en_mask;
-
-	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
-		      CDC_A_MBHC_DET_CTL_L_DET_EN |
-		      CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
-		      CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
-		      CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
-
-	if (wcd->hphl_jack_type_normally_open)
-		plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
-
-	if (wcd->gnd_jack_type_normally_open)
-		plug_type |= CDC_A_GND_PLUG_TYPE_NO;
-
-	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
-		      CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
-		      CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
-		      plug_type |
-		      CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
-
-
-	snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
-		      CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
-		      CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
-
-	/* enable MBHC clock */
-	snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
-			    DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
-			    DIG_CLK_CTL_D_MBHC_CLK_EN);
-
-	int_en_mask = MBHC_SWITCH_INT;
-	if (wcd->mbhc_btn_enabled)
-		int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET;
-
-	snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
-	snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
-	wcd->mbhc_btn0_released = false;
-	wcd->detect_accessory_type = true;
-}
-
 static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
 				      bool micbias2_enabled)
 {
@@ -534,6 +490,56 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
 	return 0;
 }
 
+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;
+
+	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
+		      CDC_A_MBHC_DET_CTL_L_DET_EN |
+		      CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
+		      CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
+		      CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
+
+	if (wcd->hphl_jack_type_normally_open)
+		plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
+
+	if (wcd->gnd_jack_type_normally_open)
+		plug_type |= CDC_A_GND_PLUG_TYPE_NO;
+
+	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
+		      CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
+		      CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
+		      plug_type |
+		      CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
+
+
+	snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
+		      CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
+		      CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
+
+	/* enable MBHC clock */
+	snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
+			    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;
+
+	snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
+	snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
+	wcd->mbhc_btn0_released = false;
+	wcd->detect_accessory_type = true;
+}
+
 static int pm8916_wcd_analog_enable_micbias_int2(struct
 						  snd_soc_dapm_widget
 						  *w, struct snd_kcontrol
-- 
2.14.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup
  2017-10-03 13:27 [PATCH v2] ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup Damien Riegel
@ 2017-10-03 20:42 ` Srinivas Kandagatla
  2017-10-03 20:49   ` Srinivas Kandagatla
  2017-10-03 20:53   ` Damien Riegel
  2017-10-04 11:28 ` Applied "ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup" to the asoc tree Mark Brown
  1 sibling, 2 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2017-10-03 20:42 UTC (permalink / raw)
  To: Damien Riegel, alsa-devel, linux-kernel
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai, kernel



On 03/10/17 14:27, Damien Riegel wrote:
> 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. Move pm8916_wcd_setup_mbhc after
> pm8916_mbhc_configure_bias to avoid a forward declaration.
> 
> Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
> ---
> Changes in v2:
>   - squash the two patches in one patch only

I do not see the squashed patches here??
It looks like its just the first patch.


Thanks,
srini
> 
>   sound/soc/codecs/msm8916-wcd-analog.c | 94 +++++++++++++++++++----------------
>   1 file changed, 50 insertions(+), 44 deletions(-)
> 
> diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
> index f562f2d86907..71494e9dbdcb 100644
> --- a/sound/soc/codecs/msm8916-wcd-analog.c
> +++ b/sound/soc/codecs/msm8916-wcd-analog.c
> @@ -443,50 +443,6 @@ static int pm8916_wcd_analog_enable_micbias_int1(struct
>   						     wcd->micbias1_cap_mode);
>   }
>   
> -static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
> -{
> -	struct snd_soc_codec *codec = wcd->codec;
> -	u32 plug_type = 0;
> -	u32 int_en_mask;
> -
> -	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
> -		      CDC_A_MBHC_DET_CTL_L_DET_EN |
> -		      CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
> -		      CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
> -		      CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
> -
> -	if (wcd->hphl_jack_type_normally_open)
> -		plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
> -
> -	if (wcd->gnd_jack_type_normally_open)
> -		plug_type |= CDC_A_GND_PLUG_TYPE_NO;
> -
> -	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
> -		      CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
> -		      CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
> -		      plug_type |
> -		      CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
> -
> -
> -	snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
> -		      CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
> -		      CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
> -
> -	/* enable MBHC clock */
> -	snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
> -			    DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
> -			    DIG_CLK_CTL_D_MBHC_CLK_EN);
> -
> -	int_en_mask = MBHC_SWITCH_INT;
> -	if (wcd->mbhc_btn_enabled)
> -		int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET;
> -
> -	snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
> -	snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
> -	wcd->mbhc_btn0_released = false;
> -	wcd->detect_accessory_type = true;
> -}
> -
>   static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
>   				      bool micbias2_enabled)
>   {
> @@ -534,6 +490,56 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
>   	return 0;
>   }
>   
> +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;
> +
> +	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
> +		      CDC_A_MBHC_DET_CTL_L_DET_EN |
> +		      CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
> +		      CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
> +		      CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
> +
> +	if (wcd->hphl_jack_type_normally_open)
> +		plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
> +
> +	if (wcd->gnd_jack_type_normally_open)
> +		plug_type |= CDC_A_GND_PLUG_TYPE_NO;
> +
> +	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
> +		      CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
> +		      CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
> +		      plug_type |
> +		      CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
> +
> +
> +	snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
> +		      CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
> +		      CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
> +
> +	/* enable MBHC clock */
> +	snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
> +			    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;
> +
> +	snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
> +	snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
> +	wcd->mbhc_btn0_released = false;
> +	wcd->detect_accessory_type = true;
> +}
> +
>   static int pm8916_wcd_analog_enable_micbias_int2(struct
>   						  snd_soc_dapm_widget
>   						  *w, struct snd_kcontrol
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup
  2017-10-03 20:42 ` Srinivas Kandagatla
@ 2017-10-03 20:49   ` Srinivas Kandagatla
  2017-10-03 20:53   ` Damien Riegel
  1 sibling, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2017-10-03 20:49 UTC (permalink / raw)
  To: Damien Riegel, alsa-devel, linux-kernel
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai, kernel



On 03/10/17 21:42, Srinivas Kandagatla wrote:
> 
> 
> On 03/10/17 14:27, Damien Riegel wrote:
>> 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. Move pm8916_wcd_setup_mbhc after
>> pm8916_mbhc_configure_bias to avoid a forward declaration.
>>
>> Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
>> ---
>> Changes in v2:
>>   - squash the two patches in one patch only
> 
> I do not see the squashed patches here??
> It looks like its just the first patch.

Please Ignore this comment!!
Opps!! should have looked at it carefully!!


Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> 
> 
> Thanks,
> srini
>>
>>   sound/soc/codecs/msm8916-wcd-analog.c | 94 
>> +++++++++++++++++++----------------
>>   1 file changed, 50 insertions(+), 44 deletions(-)
>>
>> diff --git a/sound/soc/codecs/msm8916-wcd-analog.c 
>> b/sound/soc/codecs/msm8916-wcd-analog.c
>> index f562f2d86907..71494e9dbdcb 100644
>> --- a/sound/soc/codecs/msm8916-wcd-analog.c
>> +++ b/sound/soc/codecs/msm8916-wcd-analog.c
>> @@ -443,50 +443,6 @@ static int 
>> pm8916_wcd_analog_enable_micbias_int1(struct
>>                                wcd->micbias1_cap_mode);
>>   }
>> -static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
>> -{
>> -    struct snd_soc_codec *codec = wcd->codec;
>> -    u32 plug_type = 0;
>> -    u32 int_en_mask;
>> -
>> -    snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
>> -              CDC_A_MBHC_DET_CTL_L_DET_EN |
>> -              CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
>> -              CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
>> -              CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
>> -
>> -    if (wcd->hphl_jack_type_normally_open)
>> -        plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
>> -
>> -    if (wcd->gnd_jack_type_normally_open)
>> -        plug_type |= CDC_A_GND_PLUG_TYPE_NO;
>> -
>> -    snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
>> -              CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
>> -              CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
>> -              plug_type |
>> -              CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
>> -
>> -
>> -    snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
>> -              CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
>> -              CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
>> -
>> -    /* enable MBHC clock */
>> -    snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
>> -                DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
>> -                DIG_CLK_CTL_D_MBHC_CLK_EN);
>> -
>> -    int_en_mask = MBHC_SWITCH_INT;
>> -    if (wcd->mbhc_btn_enabled)
>> -        int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET;
>> -
>> -    snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
>> -    snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, 
>> int_en_mask);
>> -    wcd->mbhc_btn0_released = false;
>> -    wcd->detect_accessory_type = true;
>> -}
>> -
>>   static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv 
>> *priv,
>>                         bool micbias2_enabled)
>>   {
>> @@ -534,6 +490,56 @@ static int pm8916_mbhc_configure_bias(struct 
>> pm8916_wcd_analog_priv *priv,
>>       return 0;
>>   }
>> +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;
>> +
>> +    snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
>> +              CDC_A_MBHC_DET_CTL_L_DET_EN |
>> +              CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
>> +              CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
>> +              CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
>> +
>> +    if (wcd->hphl_jack_type_normally_open)
>> +        plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
>> +
>> +    if (wcd->gnd_jack_type_normally_open)
>> +        plug_type |= CDC_A_GND_PLUG_TYPE_NO;
>> +
>> +    snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
>> +              CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
>> +              CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
>> +              plug_type |
>> +              CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
>> +
>> +
>> +    snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
>> +              CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
>> +              CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
>> +
>> +    /* enable MBHC clock */
>> +    snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
>> +                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;
>> +
>> +    snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
>> +    snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, 
>> int_en_mask);
>> +    wcd->mbhc_btn0_released = false;
>> +    wcd->detect_accessory_type = true;
>> +}
>> +
>>   static int pm8916_wcd_analog_enable_micbias_int2(struct
>>                             snd_soc_dapm_widget
>>                             *w, struct snd_kcontrol
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup
  2017-10-03 20:42 ` Srinivas Kandagatla
  2017-10-03 20:49   ` Srinivas Kandagatla
@ 2017-10-03 20:53   ` Damien Riegel
  1 sibling, 0 replies; 5+ messages in thread
From: Damien Riegel @ 2017-10-03 20:53 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: alsa-devel, linux-kernel, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, kernel

On Tue, Oct 03, 2017 at 09:42:18PM +0100, Srinivas Kandagatla wrote:
> 
> 
> On 03/10/17 14:27, Damien Riegel wrote:
> > 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. Move pm8916_wcd_setup_mbhc after
> > pm8916_mbhc_configure_bias to avoid a forward declaration.
> > 
> > Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
> > ---
> > Changes in v2:
> >   - squash the two patches in one patch only
> 
> I do not see the squashed patches here??
> It looks like its just the first patch.

pm8916_mbhc_configure_bias is now called in pm8916_wcd_setup_mbhc. See
inlined comment.

> Thanks,
> srini
> > 
> >   sound/soc/codecs/msm8916-wcd-analog.c | 94 +++++++++++++++++++----------------
> >   1 file changed, 50 insertions(+), 44 deletions(-)
> > 
> > diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
> > index f562f2d86907..71494e9dbdcb 100644
> > --- a/sound/soc/codecs/msm8916-wcd-analog.c
> > +++ b/sound/soc/codecs/msm8916-wcd-analog.c
> > @@ -443,50 +443,6 @@ static int pm8916_wcd_analog_enable_micbias_int1(struct
> >   						     wcd->micbias1_cap_mode);
> >   }
> > -static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
> > -{
> > -	struct snd_soc_codec *codec = wcd->codec;
> > -	u32 plug_type = 0;
> > -	u32 int_en_mask;
> > -
> > -	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
> > -		      CDC_A_MBHC_DET_CTL_L_DET_EN |
> > -		      CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
> > -		      CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
> > -		      CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
> > -
> > -	if (wcd->hphl_jack_type_normally_open)
> > -		plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
> > -
> > -	if (wcd->gnd_jack_type_normally_open)
> > -		plug_type |= CDC_A_GND_PLUG_TYPE_NO;
> > -
> > -	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
> > -		      CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
> > -		      CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
> > -		      plug_type |
> > -		      CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
> > -
> > -
> > -	snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
> > -		      CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
> > -		      CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
> > -
> > -	/* enable MBHC clock */
> > -	snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
> > -			    DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
> > -			    DIG_CLK_CTL_D_MBHC_CLK_EN);
> > -
> > -	int_en_mask = MBHC_SWITCH_INT;
> > -	if (wcd->mbhc_btn_enabled)
> > -		int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET;
> > -
> > -	snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
> > -	snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
> > -	wcd->mbhc_btn0_released = false;
> > -	wcd->detect_accessory_type = true;
> > -}
> > -
> >   static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
> >   				      bool micbias2_enabled)
> >   {
> > @@ -534,6 +490,56 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
> >   	return 0;
> >   }
> > +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;
> > +
> > +	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
> > +		      CDC_A_MBHC_DET_CTL_L_DET_EN |
> > +		      CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
> > +		      CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
> > +		      CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
> > +
> > +	if (wcd->hphl_jack_type_normally_open)
> > +		plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
> > +
> > +	if (wcd->gnd_jack_type_normally_open)
> > +		plug_type |= CDC_A_GND_PLUG_TYPE_NO;
> > +
> > +	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
> > +		      CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
> > +		      CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
> > +		      plug_type |
> > +		      CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
> > +
> > +
> > +	snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
> > +		      CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
> > +		      CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
> > +
> > +	/* enable MBHC clock */
> > +	snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
> > +			    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);
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Right here. I agree that it's quite easy to miss when most of the diff
is a function being moved, with only a few lines added into it.

Thanks,
-- 
Damien

> > +
> > +	int_en_mask = MBHC_SWITCH_INT;
> > +	if (wcd->mbhc_btn_enabled)
> > +		int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET;
> > +
> > +	snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
> > +	snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
> > +	wcd->mbhc_btn0_released = false;
> > +	wcd->detect_accessory_type = true;
> > +}
> > +
> >   static int pm8916_wcd_analog_enable_micbias_int2(struct
> >   						  snd_soc_dapm_widget
> >   						  *w, struct snd_kcontrol
> > 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Applied "ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup" to the asoc tree
  2017-10-03 13:27 [PATCH v2] ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup Damien Riegel
  2017-10-03 20:42 ` Srinivas Kandagatla
@ 2017-10-04 11:28 ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2017-10-04 11:28 UTC (permalink / raw)
  To: Damien Riegel
  Cc: Srinivas Kandagatla, Mark Brown, alsa-devel, linux-kernel,
	Takashi Iwai, Liam Girdwood, Mark Brown, kernel,
	Srinivas Kandagatla, alsa-devel

The patch

   ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 79f01fe6262b0fbba4c558dfe3dd61b3c511a61a Mon Sep 17 00:00:00 2001
From: Damien Riegel <damien.riegel@savoirfairelinux.com>
Date: Tue, 3 Oct 2017 09:27:35 -0400
Subject: [PATCH] ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc
 setup

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. Move pm8916_wcd_setup_mbhc after
pm8916_mbhc_configure_bias to avoid a forward declaration.

Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/msm8916-wcd-analog.c | 94 +++++++++++++++++++----------------
 1 file changed, 50 insertions(+), 44 deletions(-)

diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
index 3593c578e3e7..8db5824429b3 100644
--- a/sound/soc/codecs/msm8916-wcd-analog.c
+++ b/sound/soc/codecs/msm8916-wcd-analog.c
@@ -443,50 +443,6 @@ static int pm8916_wcd_analog_enable_micbias_int1(struct
 						     wcd->micbias1_cap_mode);
 }
 
-static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
-{
-	struct snd_soc_codec *codec = wcd->codec;
-	u32 plug_type = 0;
-	u32 int_en_mask;
-
-	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
-		      CDC_A_MBHC_DET_CTL_L_DET_EN |
-		      CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
-		      CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
-		      CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
-
-	if (wcd->hphl_jack_type_normally_open)
-		plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
-
-	if (wcd->gnd_jack_type_normally_open)
-		plug_type |= CDC_A_GND_PLUG_TYPE_NO;
-
-	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
-		      CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
-		      CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
-		      plug_type |
-		      CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
-
-
-	snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
-		      CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
-		      CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
-
-	/* enable MBHC clock */
-	snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
-			    DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
-			    DIG_CLK_CTL_D_MBHC_CLK_EN);
-
-	int_en_mask = MBHC_SWITCH_INT;
-	if (wcd->mbhc_btn_enabled)
-		int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET;
-
-	snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
-	snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
-	wcd->mbhc_btn0_released = false;
-	wcd->detect_accessory_type = true;
-}
-
 static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
 				      bool micbias2_enabled)
 {
@@ -534,6 +490,56 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
 	return 0;
 }
 
+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;
+
+	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
+		      CDC_A_MBHC_DET_CTL_L_DET_EN |
+		      CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
+		      CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
+		      CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
+
+	if (wcd->hphl_jack_type_normally_open)
+		plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
+
+	if (wcd->gnd_jack_type_normally_open)
+		plug_type |= CDC_A_GND_PLUG_TYPE_NO;
+
+	snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
+		      CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
+		      CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
+		      plug_type |
+		      CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
+
+
+	snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
+		      CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
+		      CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
+
+	/* enable MBHC clock */
+	snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
+			    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;
+
+	snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
+	snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
+	wcd->mbhc_btn0_released = false;
+	wcd->detect_accessory_type = true;
+}
+
 static int pm8916_wcd_analog_enable_micbias_int2(struct
 						  snd_soc_dapm_widget
 						  *w, struct snd_kcontrol
-- 
2.14.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-04 11:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-03 13:27 [PATCH v2] ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup Damien Riegel
2017-10-03 20:42 ` Srinivas Kandagatla
2017-10-03 20:49   ` Srinivas Kandagatla
2017-10-03 20:53   ` Damien Riegel
2017-10-04 11:28 ` Applied "ASoC: codecs: msm8916-wcd-analog: configure micbias in mbhc setup" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®