aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/twl4030.c
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@nokia.com>2009-01-27 04:29:41 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-01-27 05:42:40 -0500
commitaad749e51a66d473f5cef4a050e3e36795261be3 (patch)
tree1ec7550d036fa6e8d94e8229048f9c0d278ced3d /sound/soc/codecs/twl4030.c
parentdb04e2c58a65364218b89f1372b4b3b78d206423 (diff)
ASoC: TWL4030: Enable Headset Left anti-pop/bias ramp only if the Headset Left is in use
The Headset Left anti-pop and bias ramp does not need to be enabled, if the headset is not in use. Move the code to DAPM event handler for HeadsetL. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/twl4030.c')
-rw-r--r--sound/soc/codecs/twl4030.c71
1 files changed, 45 insertions, 26 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index af7b433d4f53..900486ef633d 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -414,6 +414,47 @@ static int handsfree_event(struct snd_soc_dapm_widget *w,
414 return 0; 414 return 0;
415} 415}
416 416
417static int headsetl_event(struct snd_soc_dapm_widget *w,
418 struct snd_kcontrol *kcontrol, int event)
419{
420 unsigned char hs_gain, hs_pop;
421
422 /* Save the current volume */
423 hs_gain = twl4030_read_reg_cache(w->codec, TWL4030_REG_HS_GAIN_SET);
424
425 switch (event) {
426 case SND_SOC_DAPM_POST_PMU:
427 /* Do the anti-pop/bias ramp enable according to the TRM */
428 hs_pop = TWL4030_RAMP_DELAY_645MS;
429 twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop);
430 hs_pop |= TWL4030_VMID_EN;
431 twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop);
432 /* Is this needed? Can we just use whatever gain here? */
433 twl4030_write(w->codec, TWL4030_REG_HS_GAIN_SET,
434 (hs_gain & (~0x0f)) | 0x0a);
435 hs_pop |= TWL4030_RAMP_EN;
436 twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop);
437
438 /* Restore the original volume */
439 twl4030_write(w->codec, TWL4030_REG_HS_GAIN_SET, hs_gain);
440 break;
441 case SND_SOC_DAPM_POST_PMD:
442 /* Do the anti-pop/bias ramp disable according to the TRM */
443 hs_pop = twl4030_read_reg_cache(w->codec,
444 TWL4030_REG_HS_POPN_SET);
445 hs_pop &= ~TWL4030_RAMP_EN;
446 twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop);
447 /* Bypass the reg_cache to mute the headset */
448 twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
449 hs_gain & (~0x0f),
450 TWL4030_REG_HS_GAIN_SET);
451 hs_pop &= ~TWL4030_VMID_EN;
452 twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop);
453 break;
454 }
455 return 0;
456}
457
417/* 458/*
418 * Some of the gain controls in TWL (mostly those which are associated with 459 * Some of the gain controls in TWL (mostly those which are associated with
419 * the outputs) are implemented in an interesting way: 460 * the outputs) are implemented in an interesting way:
@@ -720,8 +761,9 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
720 SND_SOC_DAPM_VALUE_MUX("PredriveR Mux", SND_SOC_NOPM, 0, 0, 761 SND_SOC_DAPM_VALUE_MUX("PredriveR Mux", SND_SOC_NOPM, 0, 0,
721 &twl4030_dapm_predriver_control), 762 &twl4030_dapm_predriver_control),
722 /* HeadsetL/R */ 763 /* HeadsetL/R */
723 SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0, 764 SND_SOC_DAPM_MUX_E("HeadsetL Mux", SND_SOC_NOPM, 0, 0,
724 &twl4030_dapm_hsol_control), 765 &twl4030_dapm_hsol_control, headsetl_event,
766 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
725 SND_SOC_DAPM_MUX("HeadsetR Mux", SND_SOC_NOPM, 0, 0, 767 SND_SOC_DAPM_MUX("HeadsetR Mux", SND_SOC_NOPM, 0, 0,
726 &twl4030_dapm_hsor_control), 768 &twl4030_dapm_hsor_control),
727 /* CarkitL/R */ 769 /* CarkitL/R */
@@ -882,7 +924,7 @@ static int twl4030_add_widgets(struct snd_soc_codec *codec)
882 924
883static void twl4030_power_up(struct snd_soc_codec *codec) 925static void twl4030_power_up(struct snd_soc_codec *codec)
884{ 926{
885 u8 anamicl, regmisc1, byte, popn; 927 u8 anamicl, regmisc1, byte;
886 int i = 0; 928 int i = 0;
887 929
888 /* set CODECPDZ to turn on codec */ 930 /* set CODECPDZ to turn on codec */
@@ -915,33 +957,10 @@ static void twl4030_power_up(struct snd_soc_codec *codec)
915 /* toggle CODECPDZ as per TRM */ 957 /* toggle CODECPDZ as per TRM */
916 twl4030_codec_enable(codec, 0); 958 twl4030_codec_enable(codec, 0);
917 twl4030_codec_enable(codec, 1); 959 twl4030_codec_enable(codec, 1);
918
919 /* program anti-pop with bias ramp delay */
920 popn = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET);
921 popn &= TWL4030_RAMP_DELAY;
922 popn |= TWL4030_RAMP_DELAY_645MS;
923 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn);
924 popn |= TWL4030_VMID_EN;
925 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn);
926
927 /* enable anti-pop ramp */
928 popn |= TWL4030_RAMP_EN;
929 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn);
930} 960}
931 961
932static void twl4030_power_down(struct snd_soc_codec *codec) 962static void twl4030_power_down(struct snd_soc_codec *codec)
933{ 963{
934 u8 popn;
935
936 /* disable anti-pop ramp */
937 popn = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET);
938 popn &= ~TWL4030_RAMP_EN;
939 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn);
940
941 /* disable bias out */
942 popn &= ~TWL4030_VMID_EN;
943 twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn);
944
945 /* power down */ 964 /* power down */
946 twl4030_codec_enable(codec, 0); 965 twl4030_codec_enable(codec, 0);
947} 966}