aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Riegel <damien.riegel@savoirfairelinux.com>2017-10-03 09:27:35 -0400
committerMark Brown <broonie@kernel.org>2017-10-04 06:20:53 -0400
commit79f01fe6262b0fbba4c558dfe3dd61b3c511a61a (patch)
tree67acd09a8ea7be410813cabb2409719efc240c25
parent46d69e141d479585c105a4d5b2337cd2ce6967e5 (diff)
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>
-rw-r--r--sound/soc/codecs/msm8916-wcd-analog.c94
1 files 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
443 wcd->micbias1_cap_mode); 443 wcd->micbias1_cap_mode);
444} 444}
445 445
446static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
447{
448 struct snd_soc_codec *codec = wcd->codec;
449 u32 plug_type = 0;
450 u32 int_en_mask;
451
452 snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
453 CDC_A_MBHC_DET_CTL_L_DET_EN |
454 CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
455 CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
456 CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
457
458 if (wcd->hphl_jack_type_normally_open)
459 plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
460
461 if (wcd->gnd_jack_type_normally_open)
462 plug_type |= CDC_A_GND_PLUG_TYPE_NO;
463
464 snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
465 CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
466 CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
467 plug_type |
468 CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
469
470
471 snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
472 CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
473 CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
474
475 /* enable MBHC clock */
476 snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
477 DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
478 DIG_CLK_CTL_D_MBHC_CLK_EN);
479
480 int_en_mask = MBHC_SWITCH_INT;
481 if (wcd->mbhc_btn_enabled)
482 int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET;
483
484 snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
485 snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
486 wcd->mbhc_btn0_released = false;
487 wcd->detect_accessory_type = true;
488}
489
490static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, 446static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
491 bool micbias2_enabled) 447 bool micbias2_enabled)
492{ 448{
@@ -534,6 +490,56 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv,
534 return 0; 490 return 0;
535} 491}
536 492
493static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
494{
495 struct snd_soc_codec *codec = wcd->codec;
496 bool micbias_enabled = false;
497 u32 plug_type = 0;
498 u32 int_en_mask;
499
500 snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1,
501 CDC_A_MBHC_DET_CTL_L_DET_EN |
502 CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION |
503 CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO |
504 CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN);
505
506 if (wcd->hphl_jack_type_normally_open)
507 plug_type |= CDC_A_HPHL_PLUG_TYPE_NO;
508
509 if (wcd->gnd_jack_type_normally_open)
510 plug_type |= CDC_A_GND_PLUG_TYPE_NO;
511
512 snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2,
513 CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 |
514 CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD |
515 plug_type |
516 CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN);
517
518
519 snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER,
520 CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS |
521 CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS);
522
523 /* enable MBHC clock */
524 snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
525 DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
526 DIG_CLK_CTL_D_MBHC_CLK_EN);
527
528 if (snd_soc_read(codec, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE)
529 micbias_enabled = true;
530
531 pm8916_mbhc_configure_bias(wcd, micbias_enabled);
532
533 int_en_mask = MBHC_SWITCH_INT;
534 if (wcd->mbhc_btn_enabled)
535 int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET;
536
537 snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
538 snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
539 wcd->mbhc_btn0_released = false;
540 wcd->detect_accessory_type = true;
541}
542
537static int pm8916_wcd_analog_enable_micbias_int2(struct 543static int pm8916_wcd_analog_enable_micbias_int2(struct
538 snd_soc_dapm_widget 544 snd_soc_dapm_widget
539 *w, struct snd_kcontrol 545 *w, struct snd_kcontrol