aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/twl4030.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/twl4030.c')
-rw-r--r--sound/soc/codecs/twl4030.c55
1 files changed, 34 insertions, 21 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 44af3188afb9..d04693e9cf9f 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -567,12 +567,13 @@ static const struct snd_kcontrol_new twl4030_dapm_dbypassv_control =
567static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \ 567static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \
568 struct snd_kcontrol *kcontrol, int event) \ 568 struct snd_kcontrol *kcontrol, int event) \
569{ \ 569{ \
570 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); \ 570 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); \
571 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); \
571 \ 572 \
572 switch (event) { \ 573 switch (event) { \
573 case SND_SOC_DAPM_POST_PMU: \ 574 case SND_SOC_DAPM_POST_PMU: \
574 twl4030->pin_name##_enabled = 1; \ 575 twl4030->pin_name##_enabled = 1; \
575 twl4030_write(w->codec, reg, twl4030_read(w->codec, reg)); \ 576 twl4030_write(codec, reg, twl4030_read(codec, reg)); \
576 break; \ 577 break; \
577 case SND_SOC_DAPM_POST_PMD: \ 578 case SND_SOC_DAPM_POST_PMD: \
578 twl4030->pin_name##_enabled = 0; \ 579 twl4030->pin_name##_enabled = 0; \
@@ -621,12 +622,14 @@ static void handsfree_ramp(struct snd_soc_codec *codec, int reg, int ramp)
621static int handsfreelpga_event(struct snd_soc_dapm_widget *w, 622static int handsfreelpga_event(struct snd_soc_dapm_widget *w,
622 struct snd_kcontrol *kcontrol, int event) 623 struct snd_kcontrol *kcontrol, int event)
623{ 624{
625 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
626
624 switch (event) { 627 switch (event) {
625 case SND_SOC_DAPM_POST_PMU: 628 case SND_SOC_DAPM_POST_PMU:
626 handsfree_ramp(w->codec, TWL4030_REG_HFL_CTL, 1); 629 handsfree_ramp(codec, TWL4030_REG_HFL_CTL, 1);
627 break; 630 break;
628 case SND_SOC_DAPM_POST_PMD: 631 case SND_SOC_DAPM_POST_PMD:
629 handsfree_ramp(w->codec, TWL4030_REG_HFL_CTL, 0); 632 handsfree_ramp(codec, TWL4030_REG_HFL_CTL, 0);
630 break; 633 break;
631 } 634 }
632 return 0; 635 return 0;
@@ -635,12 +638,14 @@ static int handsfreelpga_event(struct snd_soc_dapm_widget *w,
635static int handsfreerpga_event(struct snd_soc_dapm_widget *w, 638static int handsfreerpga_event(struct snd_soc_dapm_widget *w,
636 struct snd_kcontrol *kcontrol, int event) 639 struct snd_kcontrol *kcontrol, int event)
637{ 640{
641 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
642
638 switch (event) { 643 switch (event) {
639 case SND_SOC_DAPM_POST_PMU: 644 case SND_SOC_DAPM_POST_PMU:
640 handsfree_ramp(w->codec, TWL4030_REG_HFR_CTL, 1); 645 handsfree_ramp(codec, TWL4030_REG_HFR_CTL, 1);
641 break; 646 break;
642 case SND_SOC_DAPM_POST_PMD: 647 case SND_SOC_DAPM_POST_PMD:
643 handsfree_ramp(w->codec, TWL4030_REG_HFR_CTL, 0); 648 handsfree_ramp(codec, TWL4030_REG_HFR_CTL, 0);
644 break; 649 break;
645 } 650 }
646 return 0; 651 return 0;
@@ -649,19 +654,23 @@ static int handsfreerpga_event(struct snd_soc_dapm_widget *w,
649static int vibramux_event(struct snd_soc_dapm_widget *w, 654static int vibramux_event(struct snd_soc_dapm_widget *w,
650 struct snd_kcontrol *kcontrol, int event) 655 struct snd_kcontrol *kcontrol, int event)
651{ 656{
652 twl4030_write(w->codec, TWL4030_REG_VIBRA_SET, 0xff); 657 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
658
659 twl4030_write(codec, TWL4030_REG_VIBRA_SET, 0xff);
653 return 0; 660 return 0;
654} 661}
655 662
656static int apll_event(struct snd_soc_dapm_widget *w, 663static int apll_event(struct snd_soc_dapm_widget *w,
657 struct snd_kcontrol *kcontrol, int event) 664 struct snd_kcontrol *kcontrol, int event)
658{ 665{
666 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
667
659 switch (event) { 668 switch (event) {
660 case SND_SOC_DAPM_PRE_PMU: 669 case SND_SOC_DAPM_PRE_PMU:
661 twl4030_apll_enable(w->codec, 1); 670 twl4030_apll_enable(codec, 1);
662 break; 671 break;
663 case SND_SOC_DAPM_POST_PMD: 672 case SND_SOC_DAPM_POST_PMD:
664 twl4030_apll_enable(w->codec, 0); 673 twl4030_apll_enable(codec, 0);
665 break; 674 break;
666 } 675 }
667 return 0; 676 return 0;
@@ -670,23 +679,24 @@ static int apll_event(struct snd_soc_dapm_widget *w,
670static int aif_event(struct snd_soc_dapm_widget *w, 679static int aif_event(struct snd_soc_dapm_widget *w,
671 struct snd_kcontrol *kcontrol, int event) 680 struct snd_kcontrol *kcontrol, int event)
672{ 681{
682 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
673 u8 audio_if; 683 u8 audio_if;
674 684
675 audio_if = twl4030_read(w->codec, TWL4030_REG_AUDIO_IF); 685 audio_if = twl4030_read(codec, TWL4030_REG_AUDIO_IF);
676 switch (event) { 686 switch (event) {
677 case SND_SOC_DAPM_PRE_PMU: 687 case SND_SOC_DAPM_PRE_PMU:
678 /* Enable AIF */ 688 /* Enable AIF */
679 /* enable the PLL before we use it to clock the DAI */ 689 /* enable the PLL before we use it to clock the DAI */
680 twl4030_apll_enable(w->codec, 1); 690 twl4030_apll_enable(codec, 1);
681 691
682 twl4030_write(w->codec, TWL4030_REG_AUDIO_IF, 692 twl4030_write(codec, TWL4030_REG_AUDIO_IF,
683 audio_if | TWL4030_AIF_EN); 693 audio_if | TWL4030_AIF_EN);
684 break; 694 break;
685 case SND_SOC_DAPM_POST_PMD: 695 case SND_SOC_DAPM_POST_PMD:
686 /* disable the DAI before we stop it's source PLL */ 696 /* disable the DAI before we stop it's source PLL */
687 twl4030_write(w->codec, TWL4030_REG_AUDIO_IF, 697 twl4030_write(codec, TWL4030_REG_AUDIO_IF,
688 audio_if & ~TWL4030_AIF_EN); 698 audio_if & ~TWL4030_AIF_EN);
689 twl4030_apll_enable(w->codec, 0); 699 twl4030_apll_enable(codec, 0);
690 break; 700 break;
691 } 701 }
692 return 0; 702 return 0;
@@ -758,20 +768,21 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp)
758static int headsetlpga_event(struct snd_soc_dapm_widget *w, 768static int headsetlpga_event(struct snd_soc_dapm_widget *w,
759 struct snd_kcontrol *kcontrol, int event) 769 struct snd_kcontrol *kcontrol, int event)
760{ 770{
761 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); 771 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
772 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
762 773
763 switch (event) { 774 switch (event) {
764 case SND_SOC_DAPM_POST_PMU: 775 case SND_SOC_DAPM_POST_PMU:
765 /* Do the ramp-up only once */ 776 /* Do the ramp-up only once */
766 if (!twl4030->hsr_enabled) 777 if (!twl4030->hsr_enabled)
767 headset_ramp(w->codec, 1); 778 headset_ramp(codec, 1);
768 779
769 twl4030->hsl_enabled = 1; 780 twl4030->hsl_enabled = 1;
770 break; 781 break;
771 case SND_SOC_DAPM_POST_PMD: 782 case SND_SOC_DAPM_POST_PMD:
772 /* Do the ramp-down only if both headsetL/R is disabled */ 783 /* Do the ramp-down only if both headsetL/R is disabled */
773 if (!twl4030->hsr_enabled) 784 if (!twl4030->hsr_enabled)
774 headset_ramp(w->codec, 0); 785 headset_ramp(codec, 0);
775 786
776 twl4030->hsl_enabled = 0; 787 twl4030->hsl_enabled = 0;
777 break; 788 break;
@@ -782,20 +793,21 @@ static int headsetlpga_event(struct snd_soc_dapm_widget *w,
782static int headsetrpga_event(struct snd_soc_dapm_widget *w, 793static int headsetrpga_event(struct snd_soc_dapm_widget *w,
783 struct snd_kcontrol *kcontrol, int event) 794 struct snd_kcontrol *kcontrol, int event)
784{ 795{
785 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); 796 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
797 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
786 798
787 switch (event) { 799 switch (event) {
788 case SND_SOC_DAPM_POST_PMU: 800 case SND_SOC_DAPM_POST_PMU:
789 /* Do the ramp-up only once */ 801 /* Do the ramp-up only once */
790 if (!twl4030->hsl_enabled) 802 if (!twl4030->hsl_enabled)
791 headset_ramp(w->codec, 1); 803 headset_ramp(codec, 1);
792 804
793 twl4030->hsr_enabled = 1; 805 twl4030->hsr_enabled = 1;
794 break; 806 break;
795 case SND_SOC_DAPM_POST_PMD: 807 case SND_SOC_DAPM_POST_PMD:
796 /* Do the ramp-down only if both headsetL/R is disabled */ 808 /* Do the ramp-down only if both headsetL/R is disabled */
797 if (!twl4030->hsl_enabled) 809 if (!twl4030->hsl_enabled)
798 headset_ramp(w->codec, 0); 810 headset_ramp(codec, 0);
799 811
800 twl4030->hsr_enabled = 0; 812 twl4030->hsr_enabled = 0;
801 break; 813 break;
@@ -806,7 +818,8 @@ static int headsetrpga_event(struct snd_soc_dapm_widget *w,
806static int digimic_event(struct snd_soc_dapm_widget *w, 818static int digimic_event(struct snd_soc_dapm_widget *w,
807 struct snd_kcontrol *kcontrol, int event) 819 struct snd_kcontrol *kcontrol, int event)
808{ 820{
809 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(w->codec); 821 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
822 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
810 struct twl4030_codec_data *pdata = twl4030->pdata; 823 struct twl4030_codec_data *pdata = twl4030->pdata;
811 824
812 if (pdata && pdata->digimic_delay) 825 if (pdata && pdata->digimic_delay)