diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-07-29 16:21:49 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-08-13 17:19:31 -0400 |
commit | a2342ae325bb1f65d90a9f38baab4c9762018a5e (patch) | |
tree | d1e7e4a45421ff9b16ef2e1059568305b79fa420 /sound/soc/codecs/wm8993.c | |
parent | e9ade7f933d629698cbe5f09f1e5511269180fea (diff) |
ASoC: Factor out shared code from WM8993
The WM8993 analogue control is shared with other devices in the same
product line. Since this is a very substantial proportion of the
driver move the definitions of these controls into a new wm_hubs module
which allows them to be shared between the two.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8993.c')
-rw-r--r-- | sound/soc/codecs/wm8993.c | 716 |
1 files changed, 22 insertions, 694 deletions
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c index e246ca079897..cd1566931135 100644 --- a/sound/soc/codecs/wm8993.c +++ b/sound/soc/codecs/wm8993.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <sound/wm8993.h> | 27 | #include <sound/wm8993.h> |
28 | 28 | ||
29 | #include "wm8993.h" | 29 | #include "wm8993.h" |
30 | #include "wm_hubs.h" | ||
30 | 31 | ||
31 | static u16 wm8993_reg_defaults[WM8993_REGISTER_COUNT] = { | 32 | static u16 wm8993_reg_defaults[WM8993_REGISTER_COUNT] = { |
32 | 0x8993, /* R0 - Software Reset */ | 33 | 0x8993, /* R0 - Software Reset */ |
@@ -557,28 +558,6 @@ static int configure_clock(struct snd_soc_codec *codec) | |||
557 | return 0; | 558 | return 0; |
558 | } | 559 | } |
559 | 560 | ||
560 | static void wait_for_dc_servo(struct snd_soc_codec *codec, int mask) | ||
561 | { | ||
562 | unsigned int reg; | ||
563 | int count = 0; | ||
564 | |||
565 | dev_dbg(codec->dev, "Waiting for DC servo...\n"); | ||
566 | do { | ||
567 | count++; | ||
568 | msleep(1); | ||
569 | reg = wm8993_read(codec, WM8993_DC_SERVO_READBACK_0); | ||
570 | dev_dbg(codec->dev, "DC servo status: %x\n", reg); | ||
571 | } while ((reg & WM8993_DCS_CAL_COMPLETE_MASK) | ||
572 | != WM8993_DCS_CAL_COMPLETE_MASK && count < 1000); | ||
573 | |||
574 | if ((reg & WM8993_DCS_CAL_COMPLETE_MASK) | ||
575 | != WM8993_DCS_CAL_COMPLETE_MASK) | ||
576 | dev_err(codec->dev, "Timed out waiting for DC Servo\n"); | ||
577 | } | ||
578 | |||
579 | static const DECLARE_TLV_DB_SCALE(inpga_tlv, -1650, 150, 0); | ||
580 | static const DECLARE_TLV_DB_SCALE(inmix_sw_tlv, 0, 3000, 0); | ||
581 | static const DECLARE_TLV_DB_SCALE(inmix_tlv, -1500, 300, 1); | ||
582 | static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -3600, 300, 0); | 561 | static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -3600, 300, 0); |
583 | static const DECLARE_TLV_DB_SCALE(drc_comp_threash, -4500, 75, 0); | 562 | static const DECLARE_TLV_DB_SCALE(drc_comp_threash, -4500, 75, 0); |
584 | static const DECLARE_TLV_DB_SCALE(drc_comp_amp, -2250, 75, 0); | 563 | static const DECLARE_TLV_DB_SCALE(drc_comp_amp, -2250, 75, 0); |
@@ -593,33 +572,6 @@ static const DECLARE_TLV_DB_SCALE(drc_startup_tlv, -1800, 300, 0); | |||
593 | static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); | 572 | static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); |
594 | static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1); | 573 | static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1); |
595 | static const DECLARE_TLV_DB_SCALE(dac_boost_tlv, 0, 600, 0); | 574 | static const DECLARE_TLV_DB_SCALE(dac_boost_tlv, 0, 600, 0); |
596 | static const DECLARE_TLV_DB_SCALE(earpiece_tlv, -600, 600, 0); | ||
597 | static const DECLARE_TLV_DB_SCALE(outmix_tlv, -2100, 300, 0); | ||
598 | static const DECLARE_TLV_DB_SCALE(spkmix_tlv, -300, 300, 0); | ||
599 | static const DECLARE_TLV_DB_SCALE(spkmixout_tlv, -1800, 600, 1); | ||
600 | static const DECLARE_TLV_DB_SCALE(outpga_tlv, -5700, 100, 0); | ||
601 | static const unsigned int spkboost_tlv[] = { | ||
602 | TLV_DB_RANGE_HEAD(7), | ||
603 | 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0), | ||
604 | 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0), | ||
605 | }; | ||
606 | static const DECLARE_TLV_DB_SCALE(line_tlv, -600, 600, 0); | ||
607 | |||
608 | static const char *speaker_ref_text[] = { | ||
609 | "SPKVDD/2", | ||
610 | "VMID", | ||
611 | }; | ||
612 | |||
613 | static const struct soc_enum speaker_ref = | ||
614 | SOC_ENUM_SINGLE(WM8993_SPEAKER_MIXER, 8, 2, speaker_ref_text); | ||
615 | |||
616 | static const char *speaker_mode_text[] = { | ||
617 | "Class D", | ||
618 | "Class AB", | ||
619 | }; | ||
620 | |||
621 | static const struct soc_enum speaker_mode = | ||
622 | SOC_ENUM_SINGLE(WM8993_SPKMIXR_ATTENUATION, 8, 2, speaker_mode_text); | ||
623 | 575 | ||
624 | static const char *dac_deemph_text[] = { | 576 | static const char *dac_deemph_text[] = { |
625 | "None", | 577 | "None", |
@@ -731,73 +683,7 @@ static const char *drc_smooth_text[] = { | |||
731 | static const struct soc_enum drc_smooth = | 683 | static const struct soc_enum drc_smooth = |
732 | SOC_ENUM_SINGLE(WM8993_DRC_CONTROL_1, 4, 3, drc_smooth_text); | 684 | SOC_ENUM_SINGLE(WM8993_DRC_CONTROL_1, 4, 3, drc_smooth_text); |
733 | 685 | ||
734 | |||
735 | /* | ||
736 | * Update the DC servo calibration on gain changes | ||
737 | */ | ||
738 | static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, | ||
739 | struct snd_ctl_elem_value *ucontrol) | ||
740 | { | ||
741 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
742 | int ret; | ||
743 | |||
744 | ret = snd_soc_put_volsw_2r(kcontrol, ucontrol); | ||
745 | |||
746 | /* Only need to do this if the outputs are active */ | ||
747 | if (wm8993_read(codec, WM8993_POWER_MANAGEMENT_1) | ||
748 | & (WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA)) | ||
749 | snd_soc_update_bits(codec, | ||
750 | WM8993_DC_SERVO_0, | ||
751 | WM8993_DCS_TRIG_SINGLE_0 | | ||
752 | WM8993_DCS_TRIG_SINGLE_1, | ||
753 | WM8993_DCS_TRIG_SINGLE_0 | | ||
754 | WM8993_DCS_TRIG_SINGLE_1); | ||
755 | |||
756 | return ret; | ||
757 | } | ||
758 | |||
759 | static const struct snd_kcontrol_new wm8993_snd_controls[] = { | 686 | static const struct snd_kcontrol_new wm8993_snd_controls[] = { |
760 | SOC_SINGLE_TLV("IN1L Volume", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, | ||
761 | inpga_tlv), | ||
762 | SOC_SINGLE("IN1L Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 1), | ||
763 | SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 0), | ||
764 | |||
765 | SOC_SINGLE_TLV("IN1R Volume", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, | ||
766 | inpga_tlv), | ||
767 | SOC_SINGLE("IN1R Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 1), | ||
768 | SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 0), | ||
769 | |||
770 | |||
771 | SOC_SINGLE_TLV("IN2L Volume", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, | ||
772 | inpga_tlv), | ||
773 | SOC_SINGLE("IN2L Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 1), | ||
774 | SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 0), | ||
775 | |||
776 | SOC_SINGLE_TLV("IN2R Volume", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, | ||
777 | inpga_tlv), | ||
778 | SOC_SINGLE("IN2R Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 1), | ||
779 | SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 0), | ||
780 | |||
781 | SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8993_INPUT_MIXER3, 7, 1, 0, | ||
782 | inmix_sw_tlv), | ||
783 | SOC_SINGLE_TLV("MIXINL IN1L Volume", WM8993_INPUT_MIXER3, 4, 1, 0, | ||
784 | inmix_sw_tlv), | ||
785 | SOC_SINGLE_TLV("MIXINL Output Record Volume", WM8993_INPUT_MIXER3, 0, 7, 0, | ||
786 | inmix_tlv), | ||
787 | SOC_SINGLE_TLV("MIXINL IN1LP Volume", WM8993_INPUT_MIXER5, 6, 7, 0, inmix_tlv), | ||
788 | SOC_SINGLE_TLV("MIXINL Direct Voice Volume", WM8993_INPUT_MIXER5, 0, 6, 0, | ||
789 | inmix_tlv), | ||
790 | |||
791 | SOC_SINGLE_TLV("MIXINR IN2R Volume", WM8993_INPUT_MIXER4, 7, 1, 0, | ||
792 | inmix_sw_tlv), | ||
793 | SOC_SINGLE_TLV("MIXINR IN1R Volume", WM8993_INPUT_MIXER4, 4, 1, 0, | ||
794 | inmix_sw_tlv), | ||
795 | SOC_SINGLE_TLV("MIXINR Output Record Volume", WM8993_INPUT_MIXER4, 0, 7, 0, | ||
796 | inmix_tlv), | ||
797 | SOC_SINGLE_TLV("MIXINR IN1RP Volume", WM8993_INPUT_MIXER6, 6, 7, 0, inmix_tlv), | ||
798 | SOC_SINGLE_TLV("MIXINR Direct Voice Volume", WM8993_INPUT_MIXER6, 0, 6, 0, | ||
799 | inmix_tlv), | ||
800 | |||
801 | SOC_DOUBLE_TLV("Digital Sidetone Volume", WM8993_DIGITAL_SIDE_TONE, | 687 | SOC_DOUBLE_TLV("Digital Sidetone Volume", WM8993_DIGITAL_SIDE_TONE, |
802 | 5, 9, 12, 0, sidetone_tlv), | 688 | 5, 9, 12, 0, sidetone_tlv), |
803 | 689 | ||
@@ -840,112 +726,11 @@ SOC_SINGLE_TLV("Playback Boost Volume", WM8993_AUDIO_INTERFACE_2, 10, 3, 0, | |||
840 | dac_boost_tlv), | 726 | dac_boost_tlv), |
841 | SOC_ENUM("DAC Deemphasis", dac_deemph), | 727 | SOC_ENUM("DAC Deemphasis", dac_deemph), |
842 | 728 | ||
843 | SOC_SINGLE_TLV("Left Output Mixer IN2RN Volume", WM8993_OUTPUT_MIXER5, 6, 7, 1, | ||
844 | outmix_tlv), | ||
845 | SOC_SINGLE_TLV("Left Output Mixer IN2LN Volume", WM8993_OUTPUT_MIXER3, 6, 7, 1, | ||
846 | outmix_tlv), | ||
847 | SOC_SINGLE_TLV("Left Output Mixer IN2LP Volume", WM8993_OUTPUT_MIXER3, 9, 7, 1, | ||
848 | outmix_tlv), | ||
849 | SOC_SINGLE_TLV("Left Output Mixer IN1L Volume", WM8993_OUTPUT_MIXER3, 0, 7, 1, | ||
850 | outmix_tlv), | ||
851 | SOC_SINGLE_TLV("Left Output Mixer IN1R Volume", WM8993_OUTPUT_MIXER3, 3, 7, 1, | ||
852 | outmix_tlv), | ||
853 | SOC_SINGLE_TLV("Left Output Mixer Right Input Volume", | ||
854 | WM8993_OUTPUT_MIXER5, 3, 7, 1, outmix_tlv), | ||
855 | SOC_SINGLE_TLV("Left Output Mixer Left Input Volume", | ||
856 | WM8993_OUTPUT_MIXER5, 0, 7, 1, outmix_tlv), | ||
857 | SOC_SINGLE_TLV("Left Output Mixer DAC Volume", WM8993_OUTPUT_MIXER5, 9, 7, 1, | ||
858 | outmix_tlv), | ||
859 | |||
860 | SOC_SINGLE_TLV("Right Output Mixer IN2LN Volume", | ||
861 | WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv), | ||
862 | SOC_SINGLE_TLV("Right Output Mixer IN2RN Volume", | ||
863 | WM8993_OUTPUT_MIXER4, 6, 7, 1, outmix_tlv), | ||
864 | SOC_SINGLE_TLV("Right Output Mixer IN1L Volume", | ||
865 | WM8993_OUTPUT_MIXER4, 3, 7, 1, outmix_tlv), | ||
866 | SOC_SINGLE_TLV("Right Output Mixer IN1R Volume", | ||
867 | WM8993_OUTPUT_MIXER4, 0, 7, 1, outmix_tlv), | ||
868 | SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume", | ||
869 | WM8993_OUTPUT_MIXER4, 9, 7, 1, outmix_tlv), | ||
870 | SOC_SINGLE_TLV("Right Output Mixer Left Input Volume", | ||
871 | WM8993_OUTPUT_MIXER6, 3, 7, 1, outmix_tlv), | ||
872 | SOC_SINGLE_TLV("Right Output Mixer Right Input Volume", | ||
873 | WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv), | ||
874 | SOC_SINGLE_TLV("Right Output Mixer DAC Volume", | ||
875 | WM8993_OUTPUT_MIXER6, 9, 7, 1, outmix_tlv), | ||
876 | |||
877 | SOC_DOUBLE_R_TLV("Output Volume", WM8993_LEFT_OPGA_VOLUME, | ||
878 | WM8993_RIGHT_OPGA_VOLUME, 0, 63, 0, outpga_tlv), | ||
879 | SOC_DOUBLE_R("Output Switch", WM8993_LEFT_OPGA_VOLUME, | ||
880 | WM8993_RIGHT_OPGA_VOLUME, 6, 1, 0), | ||
881 | SOC_DOUBLE_R("Output ZC Switch", WM8993_LEFT_OPGA_VOLUME, | ||
882 | WM8993_RIGHT_OPGA_VOLUME, 7, 1, 0), | ||
883 | |||
884 | SOC_SINGLE("Earpiece Switch", WM8993_HPOUT2_VOLUME, 5, 1, 1), | ||
885 | SOC_SINGLE_TLV("Earpiece Volume", WM8993_HPOUT2_VOLUME, 4, 1, 1, earpiece_tlv), | ||
886 | |||
887 | SOC_SINGLE_TLV("SPKL Input Volume", WM8993_SPKMIXL_ATTENUATION, | ||
888 | 5, 1, 1, spkmix_tlv), | ||
889 | SOC_SINGLE_TLV("SPKL IN1LP Volume", WM8993_SPKMIXL_ATTENUATION, | ||
890 | 4, 1, 1, spkmix_tlv), | ||
891 | SOC_SINGLE_TLV("SPKL Output Volume", WM8993_SPKMIXL_ATTENUATION, | ||
892 | 3, 1, 1, spkmix_tlv), | ||
893 | SOC_SINGLE_TLV("SPKL DAC Volume", WM8993_SPKMIXL_ATTENUATION, | 729 | SOC_SINGLE_TLV("SPKL DAC Volume", WM8993_SPKMIXL_ATTENUATION, |
894 | 2, 1, 1, spkmix_tlv), | 730 | 2, 1, 1, wm_hubs_spkmix_tlv), |
895 | |||
896 | SOC_SINGLE_TLV("SPKR Input Volume", WM8993_SPKMIXR_ATTENUATION, | ||
897 | 5, 1, 1, spkmix_tlv), | ||
898 | SOC_SINGLE_TLV("SPKR IN1RP Volume", WM8993_SPKMIXR_ATTENUATION, | ||
899 | 4, 1, 1, spkmix_tlv), | ||
900 | SOC_SINGLE_TLV("SPKR Output Volume", WM8993_SPKMIXR_ATTENUATION, | ||
901 | 3, 1, 1, spkmix_tlv), | ||
902 | SOC_SINGLE_TLV("SPKR DAC Volume", WM8993_SPKMIXR_ATTENUATION, | ||
903 | 2, 1, 1, spkmix_tlv), | ||
904 | |||
905 | SOC_DOUBLE_R_TLV("Speaker Mixer Volume", | ||
906 | WM8993_SPKMIXL_ATTENUATION, WM8993_SPKMIXR_ATTENUATION, | ||
907 | 0, 3, 1, spkmixout_tlv), | ||
908 | SOC_DOUBLE_R_TLV("Speaker Volume", | ||
909 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, | ||
910 | 0, 63, 0, outpga_tlv), | ||
911 | SOC_DOUBLE_R("Speaker Switch", | ||
912 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, | ||
913 | 6, 1, 0), | ||
914 | SOC_DOUBLE_R("Speaker ZC Switch", | ||
915 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, | ||
916 | 7, 1, 0), | ||
917 | SOC_DOUBLE_TLV("Speaker Boost Volume", WM8993_SPKOUT_BOOST, 0, 3, 7, 0, | ||
918 | spkboost_tlv), | ||
919 | SOC_ENUM("Speaker Reference", speaker_ref), | ||
920 | SOC_ENUM("Speaker Mode", speaker_mode), | ||
921 | 731 | ||
922 | { | 732 | SOC_SINGLE_TLV("SPKR DAC Volume", WM8993_SPKMIXR_ATTENUATION, |
923 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Headphone Volume", | 733 | 2, 1, 1, wm_hubs_spkmix_tlv), |
924 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | | ||
925 | SNDRV_CTL_ELEM_ACCESS_READWRITE, | ||
926 | .tlv.p = outpga_tlv, | ||
927 | .info = snd_soc_info_volsw_2r, | ||
928 | .get = snd_soc_get_volsw_2r, .put = wm8993_put_dc_servo, | ||
929 | .private_value = (unsigned long)&(struct soc_mixer_control) { | ||
930 | .reg = WM8993_LEFT_OUTPUT_VOLUME, | ||
931 | .rreg = WM8993_RIGHT_OUTPUT_VOLUME, | ||
932 | .shift = 0, .max = 63 | ||
933 | }, | ||
934 | }, | ||
935 | SOC_DOUBLE_R("Headphone Switch", WM8993_LEFT_OUTPUT_VOLUME, | ||
936 | WM8993_RIGHT_OUTPUT_VOLUME, 6, 1, 0), | ||
937 | SOC_DOUBLE_R("Headphone ZC Switch", WM8993_LEFT_OUTPUT_VOLUME, | ||
938 | WM8993_RIGHT_OUTPUT_VOLUME, 7, 1, 0), | ||
939 | |||
940 | SOC_SINGLE("LINEOUT1N Switch", WM8993_LINE_OUTPUTS_VOLUME, 6, 1, 1), | ||
941 | SOC_SINGLE("LINEOUT1P Switch", WM8993_LINE_OUTPUTS_VOLUME, 5, 1, 1), | ||
942 | SOC_SINGLE_TLV("LINEOUT1 Volume", WM8993_LINE_OUTPUTS_VOLUME, 4, 1, 1, | ||
943 | line_tlv), | ||
944 | |||
945 | SOC_SINGLE("LINEOUT2N Switch", WM8993_LINE_OUTPUTS_VOLUME, 2, 1, 1), | ||
946 | SOC_SINGLE("LINEOUT2P Switch", WM8993_LINE_OUTPUTS_VOLUME, 1, 1, 1), | ||
947 | SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1, | ||
948 | line_tlv), | ||
949 | }; | 734 | }; |
950 | 735 | ||
951 | static const struct snd_kcontrol_new wm8993_eq_controls[] = { | 736 | static const struct snd_kcontrol_new wm8993_eq_controls[] = { |
@@ -956,31 +741,6 @@ SOC_SINGLE_TLV("EQ4 Volume", WM8993_EQ5, 0, 24, 0, eq_tlv), | |||
956 | SOC_SINGLE_TLV("EQ5 Volume", WM8993_EQ6, 0, 24, 0, eq_tlv), | 741 | SOC_SINGLE_TLV("EQ5 Volume", WM8993_EQ6, 0, 24, 0, eq_tlv), |
957 | }; | 742 | }; |
958 | 743 | ||
959 | static int wm8993_earpiece_event(struct snd_soc_dapm_widget *w, | ||
960 | struct snd_kcontrol *control, int event) | ||
961 | { | ||
962 | struct snd_soc_codec *codec = w->codec; | ||
963 | u16 reg = wm8993_read(codec, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA; | ||
964 | |||
965 | switch (event) { | ||
966 | case SND_SOC_DAPM_PRE_PMU: | ||
967 | reg |= WM8993_HPOUT2_IN_ENA; | ||
968 | wm8993_write(codec, WM8993_ANTIPOP1, reg); | ||
969 | udelay(50); | ||
970 | break; | ||
971 | |||
972 | case SND_SOC_DAPM_POST_PMD: | ||
973 | wm8993_write(codec, WM8993_ANTIPOP1, reg); | ||
974 | break; | ||
975 | |||
976 | default: | ||
977 | BUG(); | ||
978 | break; | ||
979 | } | ||
980 | |||
981 | return 0; | ||
982 | } | ||
983 | |||
984 | static int clk_sys_event(struct snd_soc_dapm_widget *w, | 744 | static int clk_sys_event(struct snd_soc_dapm_widget *w, |
985 | struct snd_kcontrol *kcontrol, int event) | 745 | struct snd_kcontrol *kcontrol, int event) |
986 | { | 746 | { |
@@ -1006,8 +766,8 @@ static int clk_sys_event(struct snd_soc_dapm_widget *w, | |||
1006 | * Currently the only supported paths are the direct DAC->headphone | 766 | * Currently the only supported paths are the direct DAC->headphone |
1007 | * paths (which provide minimum power consumption anyway). | 767 | * paths (which provide minimum power consumption anyway). |
1008 | */ | 768 | */ |
1009 | static int wm8993_class_w_put(struct snd_kcontrol *kcontrol, | 769 | static int class_w_put(struct snd_kcontrol *kcontrol, |
1010 | struct snd_ctl_elem_value *ucontrol) | 770 | struct snd_ctl_elem_value *ucontrol) |
1011 | { | 771 | { |
1012 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); | 772 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); |
1013 | struct snd_soc_codec *codec = widget->codec; | 773 | struct snd_soc_codec *codec = widget->codec; |
@@ -1052,160 +812,9 @@ static int wm8993_class_w_put(struct snd_kcontrol *kcontrol, | |||
1052 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 812 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
1053 | .info = snd_soc_info_enum_double, \ | 813 | .info = snd_soc_info_enum_double, \ |
1054 | .get = snd_soc_dapm_get_enum_double, \ | 814 | .get = snd_soc_dapm_get_enum_double, \ |
1055 | .put = wm8993_class_w_put, \ | 815 | .put = class_w_put, \ |
1056 | .private_value = (unsigned long)&xenum } | 816 | .private_value = (unsigned long)&xenum } |
1057 | 817 | ||
1058 | static int hp_event(struct snd_soc_dapm_widget *w, | ||
1059 | struct snd_kcontrol *kcontrol, int event) | ||
1060 | { | ||
1061 | struct snd_soc_codec *codec = w->codec; | ||
1062 | unsigned int reg = wm8993_read(codec, WM8993_ANALOGUE_HP_0); | ||
1063 | |||
1064 | switch (event) { | ||
1065 | case SND_SOC_DAPM_POST_PMU: | ||
1066 | snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, | ||
1067 | WM8993_CP_ENA, WM8993_CP_ENA); | ||
1068 | |||
1069 | msleep(5); | ||
1070 | |||
1071 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, | ||
1072 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, | ||
1073 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA); | ||
1074 | |||
1075 | reg |= WM8993_HPOUT1L_DLY | WM8993_HPOUT1R_DLY; | ||
1076 | wm8993_write(codec, WM8993_ANALOGUE_HP_0, reg); | ||
1077 | |||
1078 | /* Start the DC servo */ | ||
1079 | snd_soc_update_bits(codec, WM8993_DC_SERVO_0, | ||
1080 | WM8993_DCS_ENA_CHAN_0 | | ||
1081 | WM8993_DCS_ENA_CHAN_1 | | ||
1082 | WM8993_DCS_TRIG_STARTUP_1 | | ||
1083 | WM8993_DCS_TRIG_STARTUP_0, | ||
1084 | WM8993_DCS_ENA_CHAN_0 | | ||
1085 | WM8993_DCS_ENA_CHAN_1 | | ||
1086 | WM8993_DCS_TRIG_STARTUP_1 | | ||
1087 | WM8993_DCS_TRIG_STARTUP_0); | ||
1088 | wait_for_dc_servo(codec, WM8993_DCS_TRIG_STARTUP_0 | | ||
1089 | WM8993_DCS_TRIG_STARTUP_1); | ||
1090 | snd_soc_update_bits(codec, WM8993_DC_SERVO_1, | ||
1091 | WM8993_DCS_TIMER_PERIOD_01_MASK, 0xa); | ||
1092 | |||
1093 | reg |= WM8993_HPOUT1R_OUTP | WM8993_HPOUT1R_RMV_SHORT | | ||
1094 | WM8993_HPOUT1L_OUTP | WM8993_HPOUT1L_RMV_SHORT; | ||
1095 | wm8993_write(codec, WM8993_ANALOGUE_HP_0, reg); | ||
1096 | break; | ||
1097 | |||
1098 | case SND_SOC_DAPM_PRE_PMD: | ||
1099 | reg &= ~(WM8993_HPOUT1L_RMV_SHORT | | ||
1100 | WM8993_HPOUT1L_DLY | | ||
1101 | WM8993_HPOUT1L_OUTP | | ||
1102 | WM8993_HPOUT1R_RMV_SHORT | | ||
1103 | WM8993_HPOUT1R_DLY | | ||
1104 | WM8993_HPOUT1R_OUTP); | ||
1105 | |||
1106 | snd_soc_update_bits(codec, WM8993_DC_SERVO_1, | ||
1107 | WM8993_DCS_TIMER_PERIOD_01_MASK, 0); | ||
1108 | snd_soc_update_bits(codec, WM8993_DC_SERVO_0, | ||
1109 | WM8993_DCS_ENA_CHAN_0 | | ||
1110 | WM8993_DCS_ENA_CHAN_1, 0); | ||
1111 | |||
1112 | wm8993_write(codec, WM8993_ANALOGUE_HP_0, reg); | ||
1113 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, | ||
1114 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, | ||
1115 | 0); | ||
1116 | |||
1117 | snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, | ||
1118 | WM8993_CP_ENA, 0); | ||
1119 | break; | ||
1120 | } | ||
1121 | |||
1122 | return 0; | ||
1123 | } | ||
1124 | |||
1125 | static const struct snd_kcontrol_new in1l_pga[] = { | ||
1126 | SOC_DAPM_SINGLE("IN1LP Switch", WM8993_INPUT_MIXER2, 5, 1, 0), | ||
1127 | SOC_DAPM_SINGLE("IN1LN Switch", WM8993_INPUT_MIXER2, 4, 1, 0), | ||
1128 | }; | ||
1129 | |||
1130 | static const struct snd_kcontrol_new in1r_pga[] = { | ||
1131 | SOC_DAPM_SINGLE("IN1RP Switch", WM8993_INPUT_MIXER2, 1, 1, 0), | ||
1132 | SOC_DAPM_SINGLE("IN1RN Switch", WM8993_INPUT_MIXER2, 0, 1, 0), | ||
1133 | }; | ||
1134 | |||
1135 | static const struct snd_kcontrol_new in2l_pga[] = { | ||
1136 | SOC_DAPM_SINGLE("IN2LP Switch", WM8993_INPUT_MIXER2, 7, 1, 0), | ||
1137 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_INPUT_MIXER2, 6, 1, 0), | ||
1138 | }; | ||
1139 | |||
1140 | static const struct snd_kcontrol_new in2r_pga[] = { | ||
1141 | SOC_DAPM_SINGLE("IN2RP Switch", WM8993_INPUT_MIXER2, 3, 1, 0), | ||
1142 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_INPUT_MIXER2, 2, 1, 0), | ||
1143 | }; | ||
1144 | |||
1145 | static const struct snd_kcontrol_new mixinl[] = { | ||
1146 | SOC_DAPM_SINGLE("IN2L Switch", WM8993_INPUT_MIXER3, 8, 1, 0), | ||
1147 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_INPUT_MIXER3, 5, 1, 0), | ||
1148 | }; | ||
1149 | |||
1150 | static const struct snd_kcontrol_new mixinr[] = { | ||
1151 | SOC_DAPM_SINGLE("IN2R Switch", WM8993_INPUT_MIXER4, 8, 1, 0), | ||
1152 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_INPUT_MIXER4, 5, 1, 0), | ||
1153 | }; | ||
1154 | |||
1155 | static const struct snd_kcontrol_new left_output_mixer[] = { | ||
1156 | SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER1, 7, 1, 0), | ||
1157 | SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER1, 6, 1, 0), | ||
1158 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER1, 5, 1, 0), | ||
1159 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER1, 4, 1, 0), | ||
1160 | SOC_DAPM_SINGLE("IN2LP Switch", WM8993_OUTPUT_MIXER1, 1, 1, 0), | ||
1161 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER1, 3, 1, 0), | ||
1162 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER1, 2, 1, 0), | ||
1163 | SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER1, 0, 1, 0), | ||
1164 | }; | ||
1165 | |||
1166 | static const struct snd_kcontrol_new right_output_mixer[] = { | ||
1167 | SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER2, 7, 1, 0), | ||
1168 | SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER2, 6, 1, 0), | ||
1169 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER2, 5, 1, 0), | ||
1170 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER2, 4, 1, 0), | ||
1171 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER2, 3, 1, 0), | ||
1172 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER2, 2, 1, 0), | ||
1173 | SOC_DAPM_SINGLE("IN2RP Switch", WM8993_OUTPUT_MIXER2, 1, 1, 0), | ||
1174 | SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER2, 0, 1, 0), | ||
1175 | }; | ||
1176 | |||
1177 | static const struct snd_kcontrol_new earpiece_mixer[] = { | ||
1178 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_HPOUT2_MIXER, 5, 1, 0), | ||
1179 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_HPOUT2_MIXER, 4, 1, 0), | ||
1180 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_HPOUT2_MIXER, 3, 1, 0), | ||
1181 | }; | ||
1182 | |||
1183 | static const struct snd_kcontrol_new left_speaker_mixer[] = { | ||
1184 | SOC_DAPM_SINGLE("Input Switch", WM8993_SPEAKER_MIXER, 7, 1, 0), | ||
1185 | SOC_DAPM_SINGLE("IN1LP Switch", WM8993_SPEAKER_MIXER, 5, 1, 0), | ||
1186 | SOC_DAPM_SINGLE("Output Switch", WM8993_SPEAKER_MIXER, 3, 1, 0), | ||
1187 | SOC_DAPM_SINGLE("DAC Switch", WM8993_SPEAKER_MIXER, 6, 1, 0), | ||
1188 | }; | ||
1189 | |||
1190 | static const struct snd_kcontrol_new right_speaker_mixer[] = { | ||
1191 | SOC_DAPM_SINGLE("Input Switch", WM8993_SPEAKER_MIXER, 6, 1, 0), | ||
1192 | SOC_DAPM_SINGLE("IN1RP Switch", WM8993_SPEAKER_MIXER, 4, 1, 0), | ||
1193 | SOC_DAPM_SINGLE("Output Switch", WM8993_SPEAKER_MIXER, 2, 1, 0), | ||
1194 | SOC_DAPM_SINGLE("DAC Switch", WM8993_SPEAKER_MIXER, 0, 1, 0), | ||
1195 | }; | ||
1196 | |||
1197 | static const struct snd_kcontrol_new left_speaker_boost[] = { | ||
1198 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 5, 1, 0), | ||
1199 | SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 4, 1, 0), | ||
1200 | SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 3, 1, 0), | ||
1201 | }; | ||
1202 | |||
1203 | static const struct snd_kcontrol_new right_speaker_boost[] = { | ||
1204 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 2, 1, 0), | ||
1205 | SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 1, 1, 0), | ||
1206 | SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 0, 1, 0), | ||
1207 | }; | ||
1208 | |||
1209 | static const char *hp_mux_text[] = { | 818 | static const char *hp_mux_text[] = { |
1210 | "Mixer", | 819 | "Mixer", |
1211 | "DAC", | 820 | "DAC", |
@@ -1223,71 +832,26 @@ static const struct soc_enum hpr_enum = | |||
1223 | static const struct snd_kcontrol_new hpr_mux = | 832 | static const struct snd_kcontrol_new hpr_mux = |
1224 | SOC_DAPM_ENUM_W("Right Headphone Mux", hpr_enum); | 833 | SOC_DAPM_ENUM_W("Right Headphone Mux", hpr_enum); |
1225 | 834 | ||
1226 | static const struct snd_kcontrol_new line1_mix[] = { | 835 | static const struct snd_kcontrol_new left_speaker_mixer[] = { |
1227 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_LINE_MIXER1, 2, 1, 0), | 836 | SOC_DAPM_SINGLE("Input Switch", WM8993_SPEAKER_MIXER, 7, 1, 0), |
1228 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_LINE_MIXER1, 1, 1, 0), | 837 | SOC_DAPM_SINGLE("IN1LP Switch", WM8993_SPEAKER_MIXER, 5, 1, 0), |
1229 | SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER1, 0, 1, 0), | 838 | SOC_DAPM_SINGLE("Output Switch", WM8993_SPEAKER_MIXER, 3, 1, 0), |
1230 | }; | 839 | SOC_DAPM_SINGLE("DAC Switch", WM8993_SPEAKER_MIXER, 6, 1, 0), |
1231 | |||
1232 | static const struct snd_kcontrol_new line1n_mix[] = { | ||
1233 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 6, 1, 0), | ||
1234 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER1, 5, 1, 0), | ||
1235 | }; | ||
1236 | |||
1237 | static const struct snd_kcontrol_new line1p_mix[] = { | ||
1238 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 0, 1, 0), | ||
1239 | }; | ||
1240 | |||
1241 | static const struct snd_kcontrol_new line2_mix[] = { | ||
1242 | SOC_DAPM_SINGLE("IN2R Switch", WM8993_LINE_MIXER2, 2, 1, 0), | ||
1243 | SOC_DAPM_SINGLE("IN2L Switch", WM8993_LINE_MIXER2, 1, 1, 0), | ||
1244 | SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER2, 0, 1, 0), | ||
1245 | }; | ||
1246 | |||
1247 | static const struct snd_kcontrol_new line2n_mix[] = { | ||
1248 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER2, 6, 1, 0), | ||
1249 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 5, 1, 0), | ||
1250 | }; | 840 | }; |
1251 | 841 | ||
1252 | static const struct snd_kcontrol_new line2p_mix[] = { | 842 | static const struct snd_kcontrol_new right_speaker_mixer[] = { |
1253 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 0, 1, 0), | 843 | SOC_DAPM_SINGLE("Input Switch", WM8993_SPEAKER_MIXER, 6, 1, 0), |
844 | SOC_DAPM_SINGLE("IN1RP Switch", WM8993_SPEAKER_MIXER, 4, 1, 0), | ||
845 | SOC_DAPM_SINGLE("Output Switch", WM8993_SPEAKER_MIXER, 2, 1, 0), | ||
846 | SOC_DAPM_SINGLE("DAC Switch", WM8993_SPEAKER_MIXER, 0, 1, 0), | ||
1254 | }; | 847 | }; |
1255 | 848 | ||
1256 | static const struct snd_soc_dapm_widget wm8993_dapm_widgets[] = { | 849 | static const struct snd_soc_dapm_widget wm8993_dapm_widgets[] = { |
1257 | SND_SOC_DAPM_INPUT("IN1LN"), | ||
1258 | SND_SOC_DAPM_INPUT("IN1LP"), | ||
1259 | SND_SOC_DAPM_INPUT("IN2LN"), | ||
1260 | SND_SOC_DAPM_INPUT("IN2LP/VXRN"), | ||
1261 | SND_SOC_DAPM_INPUT("IN1RN"), | ||
1262 | SND_SOC_DAPM_INPUT("IN1RP"), | ||
1263 | SND_SOC_DAPM_INPUT("IN2RN"), | ||
1264 | SND_SOC_DAPM_INPUT("IN2RP/VXRP"), | ||
1265 | |||
1266 | SND_SOC_DAPM_SUPPLY("CLK_SYS", WM8993_BUS_CONTROL_1, 1, 0, clk_sys_event, | 850 | SND_SOC_DAPM_SUPPLY("CLK_SYS", WM8993_BUS_CONTROL_1, 1, 0, clk_sys_event, |
1267 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | 851 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
1268 | SND_SOC_DAPM_SUPPLY("TOCLK", WM8993_CLOCKING_1, 14, 0, NULL, 0), | 852 | SND_SOC_DAPM_SUPPLY("TOCLK", WM8993_CLOCKING_1, 14, 0, NULL, 0), |
1269 | SND_SOC_DAPM_SUPPLY("CLK_DSP", WM8993_CLOCKING_3, 0, 0, NULL, 0), | 853 | SND_SOC_DAPM_SUPPLY("CLK_DSP", WM8993_CLOCKING_3, 0, 0, NULL, 0), |
1270 | 854 | ||
1271 | SND_SOC_DAPM_MICBIAS("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0), | ||
1272 | SND_SOC_DAPM_MICBIAS("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0), | ||
1273 | |||
1274 | SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2, 6, 0, | ||
1275 | in1l_pga, ARRAY_SIZE(in1l_pga)), | ||
1276 | SND_SOC_DAPM_MIXER("IN1R PGA", WM8993_POWER_MANAGEMENT_2, 4, 0, | ||
1277 | in1r_pga, ARRAY_SIZE(in1r_pga)), | ||
1278 | |||
1279 | SND_SOC_DAPM_MIXER("IN2L PGA", WM8993_POWER_MANAGEMENT_2, 7, 0, | ||
1280 | in2l_pga, ARRAY_SIZE(in2l_pga)), | ||
1281 | SND_SOC_DAPM_MIXER("IN2R PGA", WM8993_POWER_MANAGEMENT_2, 5, 0, | ||
1282 | in2r_pga, ARRAY_SIZE(in2r_pga)), | ||
1283 | |||
1284 | /* Dummy widgets to represent differential paths */ | ||
1285 | SND_SOC_DAPM_PGA("Direct Voice", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
1286 | |||
1287 | SND_SOC_DAPM_MIXER("MIXINL", WM8993_POWER_MANAGEMENT_2, 9, 0, | ||
1288 | mixinl, ARRAY_SIZE(mixinl)), | ||
1289 | SND_SOC_DAPM_MIXER("MIXINR", WM8993_POWER_MANAGEMENT_2, 8, 0, | ||
1290 | mixinr, ARRAY_SIZE(mixinr)), | ||
1291 | 855 | ||
1292 | SND_SOC_DAPM_ADC("ADCL", "Capture", WM8993_POWER_MANAGEMENT_2, 1, 0), | 856 | SND_SOC_DAPM_ADC("ADCL", "Capture", WM8993_POWER_MANAGEMENT_2, 1, 0), |
1293 | SND_SOC_DAPM_ADC("ADCR", "Capture", WM8993_POWER_MANAGEMENT_2, 0, 0), | 857 | SND_SOC_DAPM_ADC("ADCR", "Capture", WM8993_POWER_MANAGEMENT_2, 0, 0), |
@@ -1295,110 +859,19 @@ SND_SOC_DAPM_ADC("ADCR", "Capture", WM8993_POWER_MANAGEMENT_2, 0, 0), | |||
1295 | SND_SOC_DAPM_DAC("DACL", "Playback", WM8993_POWER_MANAGEMENT_3, 1, 0), | 859 | SND_SOC_DAPM_DAC("DACL", "Playback", WM8993_POWER_MANAGEMENT_3, 1, 0), |
1296 | SND_SOC_DAPM_DAC("DACR", "Playback", WM8993_POWER_MANAGEMENT_3, 0, 0), | 860 | SND_SOC_DAPM_DAC("DACR", "Playback", WM8993_POWER_MANAGEMENT_3, 0, 0), |
1297 | 861 | ||
1298 | SND_SOC_DAPM_MIXER("Left Output Mixer", WM8993_POWER_MANAGEMENT_3, 5, 0, | 862 | SND_SOC_DAPM_MUX("Left Headphone Mux", SND_SOC_NOPM, 0, 0, &hpl_mux), |
1299 | left_output_mixer, ARRAY_SIZE(left_output_mixer)), | 863 | SND_SOC_DAPM_MUX("Right Headphone Mux", SND_SOC_NOPM, 0, 0, &hpr_mux), |
1300 | SND_SOC_DAPM_MIXER("Right Output Mixer", WM8993_POWER_MANAGEMENT_3, 4, 0, | ||
1301 | right_output_mixer, ARRAY_SIZE(right_output_mixer)), | ||
1302 | |||
1303 | SND_SOC_DAPM_PGA("Left Output PGA", WM8993_POWER_MANAGEMENT_3, 7, 0, NULL, 0), | ||
1304 | SND_SOC_DAPM_PGA("Right Output PGA", WM8993_POWER_MANAGEMENT_3, 6, 0, NULL, 0), | ||
1305 | |||
1306 | SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM, 0, 0, | ||
1307 | earpiece_mixer, ARRAY_SIZE(earpiece_mixer)), | ||
1308 | SND_SOC_DAPM_PGA_E("Earpiece Driver", WM8993_POWER_MANAGEMENT_1, 11, 0, | ||
1309 | NULL, 0, wm8993_earpiece_event, | ||
1310 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | ||
1311 | 864 | ||
1312 | SND_SOC_DAPM_MIXER("SPKL", WM8993_POWER_MANAGEMENT_3, 8, 0, | 865 | SND_SOC_DAPM_MIXER("SPKL", WM8993_POWER_MANAGEMENT_3, 8, 0, |
1313 | left_speaker_mixer, ARRAY_SIZE(left_speaker_mixer)), | 866 | left_speaker_mixer, ARRAY_SIZE(left_speaker_mixer)), |
1314 | SND_SOC_DAPM_MIXER("SPKR", WM8993_POWER_MANAGEMENT_3, 9, 0, | 867 | SND_SOC_DAPM_MIXER("SPKR", WM8993_POWER_MANAGEMENT_3, 9, 0, |
1315 | right_speaker_mixer, ARRAY_SIZE(right_speaker_mixer)), | 868 | right_speaker_mixer, ARRAY_SIZE(right_speaker_mixer)), |
1316 | 869 | ||
1317 | SND_SOC_DAPM_MIXER("SPKL Boost", SND_SOC_NOPM, 0, 0, | ||
1318 | left_speaker_boost, ARRAY_SIZE(left_speaker_boost)), | ||
1319 | SND_SOC_DAPM_MIXER("SPKR Boost", SND_SOC_NOPM, 0, 0, | ||
1320 | right_speaker_boost, ARRAY_SIZE(right_speaker_boost)), | ||
1321 | |||
1322 | SND_SOC_DAPM_PGA("SPKL Driver", WM8993_POWER_MANAGEMENT_1, 12, 0, | ||
1323 | NULL, 0), | ||
1324 | SND_SOC_DAPM_PGA("SPKR Driver", WM8993_POWER_MANAGEMENT_1, 13, 0, | ||
1325 | NULL, 0), | ||
1326 | |||
1327 | SND_SOC_DAPM_MUX("Left Headphone Mux", SND_SOC_NOPM, 0, 0, &hpl_mux), | ||
1328 | SND_SOC_DAPM_MUX("Right Headphone Mux", SND_SOC_NOPM, 0, 0, &hpr_mux), | ||
1329 | SND_SOC_DAPM_PGA_E("Headphone PGA", SND_SOC_NOPM, 0, 0, | ||
1330 | NULL, 0, | ||
1331 | hp_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), | ||
1332 | |||
1333 | SND_SOC_DAPM_MIXER("LINEOUT1 Mixer", SND_SOC_NOPM, 0, 0, | ||
1334 | line1_mix, ARRAY_SIZE(line1_mix)), | ||
1335 | SND_SOC_DAPM_MIXER("LINEOUT2 Mixer", SND_SOC_NOPM, 0, 0, | ||
1336 | line2_mix, ARRAY_SIZE(line2_mix)), | ||
1337 | |||
1338 | SND_SOC_DAPM_MIXER("LINEOUT1N Mixer", SND_SOC_NOPM, 0, 0, | ||
1339 | line1n_mix, ARRAY_SIZE(line1n_mix)), | ||
1340 | SND_SOC_DAPM_MIXER("LINEOUT1P Mixer", SND_SOC_NOPM, 0, 0, | ||
1341 | line1p_mix, ARRAY_SIZE(line1p_mix)), | ||
1342 | SND_SOC_DAPM_MIXER("LINEOUT2N Mixer", SND_SOC_NOPM, 0, 0, | ||
1343 | line2n_mix, ARRAY_SIZE(line2n_mix)), | ||
1344 | SND_SOC_DAPM_MIXER("LINEOUT2P Mixer", SND_SOC_NOPM, 0, 0, | ||
1345 | line2p_mix, ARRAY_SIZE(line2p_mix)), | ||
1346 | |||
1347 | SND_SOC_DAPM_PGA("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3, 13, 0, | ||
1348 | NULL, 0), | ||
1349 | SND_SOC_DAPM_PGA("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3, 12, 0, | ||
1350 | NULL, 0), | ||
1351 | SND_SOC_DAPM_PGA("LINEOUT2N Driver", WM8993_POWER_MANAGEMENT_3, 11, 0, | ||
1352 | NULL, 0), | ||
1353 | SND_SOC_DAPM_PGA("LINEOUT2P Driver", WM8993_POWER_MANAGEMENT_3, 10, 0, | ||
1354 | NULL, 0), | ||
1355 | |||
1356 | SND_SOC_DAPM_OUTPUT("SPKOUTLP"), | ||
1357 | SND_SOC_DAPM_OUTPUT("SPKOUTLN"), | ||
1358 | SND_SOC_DAPM_OUTPUT("SPKOUTRP"), | ||
1359 | SND_SOC_DAPM_OUTPUT("SPKOUTRN"), | ||
1360 | SND_SOC_DAPM_OUTPUT("HPOUT1L"), | ||
1361 | SND_SOC_DAPM_OUTPUT("HPOUT1R"), | ||
1362 | SND_SOC_DAPM_OUTPUT("HPOUT2P"), | ||
1363 | SND_SOC_DAPM_OUTPUT("HPOUT2N"), | ||
1364 | SND_SOC_DAPM_OUTPUT("LINEOUT1P"), | ||
1365 | SND_SOC_DAPM_OUTPUT("LINEOUT1N"), | ||
1366 | SND_SOC_DAPM_OUTPUT("LINEOUT2P"), | ||
1367 | SND_SOC_DAPM_OUTPUT("LINEOUT2N"), | ||
1368 | }; | 870 | }; |
1369 | 871 | ||
1370 | static const struct snd_soc_dapm_route routes[] = { | 872 | static const struct snd_soc_dapm_route routes[] = { |
1371 | { "IN1L PGA", "IN1LP Switch", "IN1LP" }, | ||
1372 | { "IN1L PGA", "IN1LN Switch", "IN1LN" }, | ||
1373 | |||
1374 | { "IN1R PGA", "IN1RP Switch", "IN1RP" }, | ||
1375 | { "IN1R PGA", "IN1RN Switch", "IN1RN" }, | ||
1376 | |||
1377 | { "IN2L PGA", "IN2LP Switch", "IN2LP/VXRN" }, | ||
1378 | { "IN2L PGA", "IN2LN Switch", "IN2LN" }, | ||
1379 | |||
1380 | { "IN2R PGA", "IN2RP Switch", "IN2RP/VXRP" }, | ||
1381 | { "IN2R PGA", "IN2RN Switch", "IN2RN" }, | ||
1382 | |||
1383 | { "Direct Voice", NULL, "IN2LP/VXRN" }, | ||
1384 | { "Direct Voice", NULL, "IN2RP/VXRP" }, | ||
1385 | |||
1386 | { "MIXINL", "IN1L Switch", "IN1L PGA" }, | ||
1387 | { "MIXINL", "IN2L Switch", "IN2L PGA" }, | ||
1388 | { "MIXINL", NULL, "Direct Voice" }, | ||
1389 | { "MIXINL", NULL, "IN1LP" }, | ||
1390 | { "MIXINL", NULL, "Left Output Mixer" }, | ||
1391 | |||
1392 | { "MIXINR", "IN1R Switch", "IN1R PGA" }, | ||
1393 | { "MIXINR", "IN2R Switch", "IN2R PGA" }, | ||
1394 | { "MIXINR", NULL, "Direct Voice" }, | ||
1395 | { "MIXINR", NULL, "IN1RP" }, | ||
1396 | { "MIXINR", NULL, "Right Output Mixer" }, | ||
1397 | |||
1398 | { "ADCL", NULL, "MIXINL" }, | ||
1399 | { "ADCL", NULL, "CLK_SYS" }, | 873 | { "ADCL", NULL, "CLK_SYS" }, |
1400 | { "ADCL", NULL, "CLK_DSP" }, | 874 | { "ADCL", NULL, "CLK_DSP" }, |
1401 | { "ADCR", NULL, "MIXINR" }, | ||
1402 | { "ADCR", NULL, "CLK_SYS" }, | 875 | { "ADCR", NULL, "CLK_SYS" }, |
1403 | { "ADCR", NULL, "CLK_DSP" }, | 876 | { "ADCR", NULL, "CLK_DSP" }, |
1404 | 877 | ||
@@ -1407,128 +880,22 @@ static const struct snd_soc_dapm_route routes[] = { | |||
1407 | { "DACR", NULL, "CLK_SYS" }, | 880 | { "DACR", NULL, "CLK_SYS" }, |
1408 | { "DACR", NULL, "CLK_DSP" }, | 881 | { "DACR", NULL, "CLK_DSP" }, |
1409 | 882 | ||
1410 | { "Left Output Mixer", "Left Input Switch", "MIXINL" }, | ||
1411 | { "Left Output Mixer", "Right Input Switch", "MIXINR" }, | ||
1412 | { "Left Output Mixer", "IN2RN Switch", "IN2RN" }, | ||
1413 | { "Left Output Mixer", "IN2LN Switch", "IN2LN" }, | ||
1414 | { "Left Output Mixer", "IN2LP Switch", "IN2LP/VXRN" }, | ||
1415 | { "Left Output Mixer", "IN1L Switch", "IN1L PGA" }, | ||
1416 | { "Left Output Mixer", "IN1R Switch", "IN1R PGA" }, | ||
1417 | { "Left Output Mixer", "DAC Switch", "DACL" }, | 883 | { "Left Output Mixer", "DAC Switch", "DACL" }, |
1418 | 884 | ||
1419 | { "Right Output Mixer", "Left Input Switch", "MIXINL" }, | ||
1420 | { "Right Output Mixer", "Right Input Switch", "MIXINR" }, | ||
1421 | { "Right Output Mixer", "IN2LN Switch", "IN2LN" }, | ||
1422 | { "Right Output Mixer", "IN2RN Switch", "IN2RN" }, | ||
1423 | { "Right Output Mixer", "IN2RP Switch", "IN2RP/VXRP" }, | ||
1424 | { "Right Output Mixer", "IN1L Switch", "IN1L PGA" }, | ||
1425 | { "Right Output Mixer", "IN1R Switch", "IN1R PGA" }, | ||
1426 | { "Right Output Mixer", "DAC Switch", "DACR" }, | 885 | { "Right Output Mixer", "DAC Switch", "DACR" }, |
1427 | 886 | ||
1428 | { "Left Output PGA", NULL, "Left Output Mixer" }, | ||
1429 | { "Left Output PGA", NULL, "CLK_SYS" }, | 887 | { "Left Output PGA", NULL, "CLK_SYS" }, |
1430 | { "Left Output PGA", NULL, "TOCLK" }, | ||
1431 | 888 | ||
1432 | { "Right Output PGA", NULL, "Right Output Mixer" }, | ||
1433 | { "Right Output PGA", NULL, "CLK_SYS" }, | 889 | { "Right Output PGA", NULL, "CLK_SYS" }, |
1434 | { "Right Output PGA", NULL, "TOCLK" }, | ||
1435 | |||
1436 | { "Earpiece Mixer", "Direct Voice Switch", "Direct Voice" }, | ||
1437 | { "Earpiece Mixer", "Left Output Switch", "Left Output PGA" }, | ||
1438 | { "Earpiece Mixer", "Right Output Switch", "Right Output PGA" }, | ||
1439 | 890 | ||
1440 | { "Earpiece Driver", NULL, "Earpiece Mixer" }, | ||
1441 | { "HPOUT2N", NULL, "Earpiece Driver" }, | ||
1442 | { "HPOUT2P", NULL, "Earpiece Driver" }, | ||
1443 | |||
1444 | { "SPKL", "Input Switch", "MIXINL" }, | ||
1445 | { "SPKL", "IN1LP Switch", "IN1LP" }, | ||
1446 | { "SPKL", "Output Switch", "Left Output Mixer" }, | ||
1447 | { "SPKL", "DAC Switch", "DACL" }, | 891 | { "SPKL", "DAC Switch", "DACL" }, |
1448 | { "SPKL", NULL, "CLK_SYS" }, | 892 | { "SPKL", NULL, "CLK_SYS" }, |
1449 | { "SPKL", NULL, "TOCLK" }, | ||
1450 | 893 | ||
1451 | { "SPKR", "Input Switch", "MIXINR" }, | ||
1452 | { "SPKR", "IN1RP Switch", "IN1RP" }, | ||
1453 | { "SPKR", "Output Switch", "Right Output Mixer" }, | ||
1454 | { "SPKR", "DAC Switch", "DACR" }, | 894 | { "SPKR", "DAC Switch", "DACR" }, |
1455 | { "SPKR", NULL, "CLK_SYS" }, | 895 | { "SPKR", NULL, "CLK_SYS" }, |
1456 | { "SPKR", NULL, "TOCLK" }, | ||
1457 | |||
1458 | { "SPKL Boost", "Direct Voice Switch", "Direct Voice" }, | ||
1459 | { "SPKL Boost", "SPKL Switch", "SPKL" }, | ||
1460 | { "SPKL Boost", "SPKR Switch", "SPKR" }, | ||
1461 | |||
1462 | { "SPKR Boost", "Direct Voice Switch", "Direct Voice" }, | ||
1463 | { "SPKR Boost", "SPKR Switch", "SPKR" }, | ||
1464 | { "SPKR Boost", "SPKL Switch", "SPKL" }, | ||
1465 | |||
1466 | { "SPKL Driver", NULL, "SPKL Boost" }, | ||
1467 | { "SPKL Driver", NULL, "CLK_SYS" }, | ||
1468 | |||
1469 | { "SPKR Driver", NULL, "SPKR Boost" }, | ||
1470 | { "SPKR Driver", NULL, "CLK_SYS" }, | ||
1471 | |||
1472 | { "SPKOUTLP", NULL, "SPKL Driver" }, | ||
1473 | { "SPKOUTLN", NULL, "SPKL Driver" }, | ||
1474 | { "SPKOUTRP", NULL, "SPKR Driver" }, | ||
1475 | { "SPKOUTRN", NULL, "SPKR Driver" }, | ||
1476 | 896 | ||
1477 | { "Left Headphone Mux", "DAC", "DACL" }, | 897 | { "Left Headphone Mux", "DAC", "DACL" }, |
1478 | { "Left Headphone Mux", "Mixer", "Left Output Mixer" }, | ||
1479 | { "Right Headphone Mux", "DAC", "DACR" }, | 898 | { "Right Headphone Mux", "DAC", "DACR" }, |
1480 | { "Right Headphone Mux", "Mixer", "Right Output Mixer" }, | ||
1481 | |||
1482 | { "Headphone PGA", NULL, "Left Headphone Mux" }, | ||
1483 | { "Headphone PGA", NULL, "Right Headphone Mux" }, | ||
1484 | { "Headphone PGA", NULL, "CLK_SYS" }, | ||
1485 | { "Headphone PGA", NULL, "TOCLK" }, | ||
1486 | |||
1487 | { "HPOUT1L", NULL, "Headphone PGA" }, | ||
1488 | { "HPOUT1R", NULL, "Headphone PGA" }, | ||
1489 | |||
1490 | { "LINEOUT1N", NULL, "LINEOUT1N Driver" }, | ||
1491 | { "LINEOUT1P", NULL, "LINEOUT1P Driver" }, | ||
1492 | { "LINEOUT2N", NULL, "LINEOUT2N Driver" }, | ||
1493 | { "LINEOUT2P", NULL, "LINEOUT2P Driver" }, | ||
1494 | }; | ||
1495 | |||
1496 | static const struct snd_soc_dapm_route lineout1_diff_routes[] = { | ||
1497 | { "LINEOUT1 Mixer", "IN1L Switch", "IN1L PGA" }, | ||
1498 | { "LINEOUT1 Mixer", "IN1R Switch", "IN1R PGA" }, | ||
1499 | { "LINEOUT1 Mixer", "Output Switch", "Left Output Mixer" }, | ||
1500 | |||
1501 | { "LINEOUT1N Driver", NULL, "LINEOUT1 Mixer" }, | ||
1502 | { "LINEOUT1P Driver", NULL, "LINEOUT1 Mixer" }, | ||
1503 | }; | ||
1504 | |||
1505 | static const struct snd_soc_dapm_route lineout1_se_routes[] = { | ||
1506 | { "LINEOUT1N Mixer", "Left Output Switch", "Left Output Mixer" }, | ||
1507 | { "LINEOUT1N Mixer", "Right Output Switch", "Left Output Mixer" }, | ||
1508 | |||
1509 | { "LINEOUT1P Mixer", "Left Output Switch", "Left Output Mixer" }, | ||
1510 | |||
1511 | { "LINEOUT1N Driver", NULL, "LINEOUT1N Mixer" }, | ||
1512 | { "LINEOUT1P Driver", NULL, "LINEOUT1P Mixer" }, | ||
1513 | }; | ||
1514 | |||
1515 | static const struct snd_soc_dapm_route lineout2_diff_routes[] = { | ||
1516 | { "LINEOUT2 Mixer", "IN2L Switch", "IN2L PGA" }, | ||
1517 | { "LINEOUT2 Mixer", "IN2R Switch", "IN2R PGA" }, | ||
1518 | { "LINEOUT2 Mixer", "Output Switch", "Right Output Mixer" }, | ||
1519 | |||
1520 | { "LINEOUT2N Driver", NULL, "LINEOUT2 Mixer" }, | ||
1521 | { "LINEOUT2P Driver", NULL, "LINEOUT2 Mixer" }, | ||
1522 | }; | ||
1523 | |||
1524 | static const struct snd_soc_dapm_route lineout2_se_routes[] = { | ||
1525 | { "LINEOUT2N Mixer", "Left Output Switch", "Left Output Mixer" }, | ||
1526 | { "LINEOUT2N Mixer", "Right Output Switch", "Left Output Mixer" }, | ||
1527 | |||
1528 | { "LINEOUT2P Mixer", "Right Output Switch", "Right Output Mixer" }, | ||
1529 | |||
1530 | { "LINEOUT2N Driver", NULL, "LINEOUT2N Mixer" }, | ||
1531 | { "LINEOUT2P Driver", NULL, "LINEOUT2P Mixer" }, | ||
1532 | }; | 899 | }; |
1533 | 900 | ||
1534 | static int wm8993_set_bias_level(struct snd_soc_codec *codec, | 901 | static int wm8993_set_bias_level(struct snd_soc_codec *codec, |
@@ -1950,26 +1317,11 @@ static int wm8993_probe(struct platform_device *pdev) | |||
1950 | 1317 | ||
1951 | snd_soc_dapm_new_controls(codec, wm8993_dapm_widgets, | 1318 | snd_soc_dapm_new_controls(codec, wm8993_dapm_widgets, |
1952 | ARRAY_SIZE(wm8993_dapm_widgets)); | 1319 | ARRAY_SIZE(wm8993_dapm_widgets)); |
1320 | wm_hubs_add_analogue_controls(codec); | ||
1953 | 1321 | ||
1954 | snd_soc_dapm_add_routes(codec, routes, ARRAY_SIZE(routes)); | 1322 | snd_soc_dapm_add_routes(codec, routes, ARRAY_SIZE(routes)); |
1955 | 1323 | wm_hubs_add_analogue_routes(codec, wm8993->pdata.lineout1_diff, | |
1956 | if (wm8993->pdata.lineout1_diff) | 1324 | wm8993->pdata.lineout2_diff); |
1957 | snd_soc_dapm_add_routes(codec, | ||
1958 | lineout1_diff_routes, | ||
1959 | ARRAY_SIZE(lineout1_diff_routes)); | ||
1960 | else | ||
1961 | snd_soc_dapm_add_routes(codec, | ||
1962 | lineout1_se_routes, | ||
1963 | ARRAY_SIZE(lineout1_se_routes)); | ||
1964 | |||
1965 | if (wm8993->pdata.lineout2_diff) | ||
1966 | snd_soc_dapm_add_routes(codec, | ||
1967 | lineout2_diff_routes, | ||
1968 | ARRAY_SIZE(lineout2_diff_routes)); | ||
1969 | else | ||
1970 | snd_soc_dapm_add_routes(codec, | ||
1971 | lineout2_se_routes, | ||
1972 | ARRAY_SIZE(lineout2_se_routes)); | ||
1973 | 1325 | ||
1974 | snd_soc_dapm_new_widgets(codec); | 1326 | snd_soc_dapm_new_widgets(codec); |
1975 | 1327 | ||
@@ -2066,30 +1418,6 @@ static int wm8993_i2c_probe(struct i2c_client *i2c, | |||
2066 | wm8993->class_w_users = 2; | 1418 | wm8993->class_w_users = 2; |
2067 | 1419 | ||
2068 | /* Latch volume update bits and default ZC on */ | 1420 | /* Latch volume update bits and default ZC on */ |
2069 | snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_1_2_VOLUME, | ||
2070 | WM8993_IN1_VU, WM8993_IN1_VU); | ||
2071 | snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, | ||
2072 | WM8993_IN1_VU, WM8993_IN1_VU); | ||
2073 | snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_3_4_VOLUME, | ||
2074 | WM8993_IN2_VU, WM8993_IN2_VU); | ||
2075 | snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, | ||
2076 | WM8993_IN2_VU, WM8993_IN2_VU); | ||
2077 | |||
2078 | snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_RIGHT, | ||
2079 | WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); | ||
2080 | |||
2081 | snd_soc_update_bits(codec, WM8993_LEFT_OUTPUT_VOLUME, | ||
2082 | WM8993_HPOUT1L_ZC, WM8993_HPOUT1L_ZC); | ||
2083 | snd_soc_update_bits(codec, WM8993_RIGHT_OUTPUT_VOLUME, | ||
2084 | WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC, | ||
2085 | WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC); | ||
2086 | |||
2087 | snd_soc_update_bits(codec, WM8993_LEFT_OPGA_VOLUME, | ||
2088 | WM8993_MIXOUTL_ZC, WM8993_MIXOUTL_ZC); | ||
2089 | snd_soc_update_bits(codec, WM8993_RIGHT_OPGA_VOLUME, | ||
2090 | WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU, | ||
2091 | WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU); | ||
2092 | |||
2093 | snd_soc_update_bits(codec, WM8993_RIGHT_DAC_DIGITAL_VOLUME, | 1421 | snd_soc_update_bits(codec, WM8993_RIGHT_DAC_DIGITAL_VOLUME, |
2094 | WM8993_DAC_VU, WM8993_DAC_VU); | 1422 | WM8993_DAC_VU, WM8993_DAC_VU); |
2095 | snd_soc_update_bits(codec, WM8993_RIGHT_ADC_DIGITAL_VOLUME, | 1423 | snd_soc_update_bits(codec, WM8993_RIGHT_ADC_DIGITAL_VOLUME, |