diff options
-rw-r--r-- | sound/soc/codecs/Kconfig | 4 | ||||
-rw-r--r-- | sound/soc/codecs/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/codecs/wm8993.c | 716 | ||||
-rw-r--r-- | sound/soc/codecs/wm_hubs.c | 758 | ||||
-rw-r--r-- | sound/soc/codecs/wm_hubs.h | 24 |
5 files changed, 810 insertions, 694 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index dd9b2956ebc7..910b9162cbbb 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -64,6 +64,10 @@ config SND_SOC_ALL_CODECS | |||
64 | 64 | ||
65 | If unsure select "N". | 65 | If unsure select "N". |
66 | 66 | ||
67 | config SND_SOC_WM_HUBS | ||
68 | tristate | ||
69 | default y if SND_SOC_WM8993=y | ||
70 | default m if SND_SOC_WM8993=m | ||
67 | 71 | ||
68 | config SND_SOC_AC97_CODEC | 72 | config SND_SOC_AC97_CODEC |
69 | tristate | 73 | tristate |
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 9cbcf8f5b880..c7fd2297a06f 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
@@ -41,6 +41,7 @@ snd-soc-wm9081-objs := wm9081.o | |||
41 | snd-soc-wm9705-objs := wm9705.o | 41 | snd-soc-wm9705-objs := wm9705.o |
42 | snd-soc-wm9712-objs := wm9712.o | 42 | snd-soc-wm9712-objs := wm9712.o |
43 | snd-soc-wm9713-objs := wm9713.o | 43 | snd-soc-wm9713-objs := wm9713.o |
44 | snd-soc-wm-hubs-objs := wm_hubs.o | ||
44 | 45 | ||
45 | # Amp | 46 | # Amp |
46 | snd-soc-max9877-objs := max9877.o | 47 | snd-soc-max9877-objs := max9877.o |
@@ -88,6 +89,7 @@ obj-$(CONFIG_SND_SOC_WM9081) += snd-soc-wm9081.o | |||
88 | obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o | 89 | obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o |
89 | obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o | 90 | obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o |
90 | obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o | 91 | obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o |
92 | obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o | ||
91 | 93 | ||
92 | # Amp | 94 | # Amp |
93 | obj-$(CONFIG_SND_SOC_MAX9877) += snd-soc-max9877.o | 95 | obj-$(CONFIG_SND_SOC_MAX9877) += snd-soc-max9877.o |
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, |
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c new file mode 100644 index 000000000000..e8fc474ba5cf --- /dev/null +++ b/sound/soc/codecs/wm_hubs.c | |||
@@ -0,0 +1,758 @@ | |||
1 | /* | ||
2 | * wm_hubs.c -- WM8993/4 common code | ||
3 | * | ||
4 | * Copyright 2009 Wolfson Microelectronics plc | ||
5 | * | ||
6 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | ||
7 | * | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/moduleparam.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/pm.h> | ||
19 | #include <linux/i2c.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/regulator/consumer.h> | ||
22 | #include <sound/core.h> | ||
23 | #include <sound/pcm.h> | ||
24 | #include <sound/pcm_params.h> | ||
25 | #include <sound/soc.h> | ||
26 | #include <sound/soc-dapm.h> | ||
27 | #include <sound/initval.h> | ||
28 | #include <sound/tlv.h> | ||
29 | |||
30 | #include "wm8993.h" | ||
31 | #include "wm_hubs.h" | ||
32 | |||
33 | const DECLARE_TLV_DB_SCALE(wm_hubs_spkmix_tlv, -300, 300, 0); | ||
34 | EXPORT_SYMBOL_GPL(wm_hubs_spkmix_tlv); | ||
35 | |||
36 | static const DECLARE_TLV_DB_SCALE(inpga_tlv, -1650, 150, 0); | ||
37 | static const DECLARE_TLV_DB_SCALE(inmix_sw_tlv, 0, 3000, 0); | ||
38 | static const DECLARE_TLV_DB_SCALE(inmix_tlv, -1500, 300, 1); | ||
39 | static const DECLARE_TLV_DB_SCALE(earpiece_tlv, -600, 600, 0); | ||
40 | static const DECLARE_TLV_DB_SCALE(outmix_tlv, -2100, 300, 0); | ||
41 | static const DECLARE_TLV_DB_SCALE(spkmixout_tlv, -1800, 600, 1); | ||
42 | static const DECLARE_TLV_DB_SCALE(outpga_tlv, -5700, 100, 0); | ||
43 | static const unsigned int spkboost_tlv[] = { | ||
44 | TLV_DB_RANGE_HEAD(7), | ||
45 | 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0), | ||
46 | 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0), | ||
47 | }; | ||
48 | static const DECLARE_TLV_DB_SCALE(line_tlv, -600, 600, 0); | ||
49 | |||
50 | static const char *speaker_ref_text[] = { | ||
51 | "SPKVDD/2", | ||
52 | "VMID", | ||
53 | }; | ||
54 | |||
55 | static const struct soc_enum speaker_ref = | ||
56 | SOC_ENUM_SINGLE(WM8993_SPEAKER_MIXER, 8, 2, speaker_ref_text); | ||
57 | |||
58 | static const char *speaker_mode_text[] = { | ||
59 | "Class D", | ||
60 | "Class AB", | ||
61 | }; | ||
62 | |||
63 | static const struct soc_enum speaker_mode = | ||
64 | SOC_ENUM_SINGLE(WM8993_SPKMIXR_ATTENUATION, 8, 2, speaker_mode_text); | ||
65 | |||
66 | static void wait_for_dc_servo(struct snd_soc_codec *codec) | ||
67 | { | ||
68 | unsigned int reg; | ||
69 | int count = 0; | ||
70 | |||
71 | dev_dbg(codec->dev, "Waiting for DC servo...\n"); | ||
72 | do { | ||
73 | count++; | ||
74 | msleep(1); | ||
75 | reg = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_0); | ||
76 | dev_dbg(codec->dev, "DC servo status: %x\n", reg); | ||
77 | } while ((reg & WM8993_DCS_CAL_COMPLETE_MASK) | ||
78 | != WM8993_DCS_CAL_COMPLETE_MASK && count < 1000); | ||
79 | |||
80 | if ((reg & WM8993_DCS_CAL_COMPLETE_MASK) | ||
81 | != WM8993_DCS_CAL_COMPLETE_MASK) | ||
82 | dev_err(codec->dev, "Timed out waiting for DC Servo\n"); | ||
83 | } | ||
84 | |||
85 | /* | ||
86 | * Update the DC servo calibration on gain changes | ||
87 | */ | ||
88 | static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, | ||
89 | struct snd_ctl_elem_value *ucontrol) | ||
90 | { | ||
91 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
92 | int ret; | ||
93 | |||
94 | ret = snd_soc_put_volsw_2r(kcontrol, ucontrol); | ||
95 | |||
96 | /* Only need to do this if the outputs are active */ | ||
97 | if (snd_soc_read(codec, WM8993_POWER_MANAGEMENT_1) | ||
98 | & (WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA)) | ||
99 | snd_soc_update_bits(codec, | ||
100 | WM8993_DC_SERVO_0, | ||
101 | WM8993_DCS_TRIG_SINGLE_0 | | ||
102 | WM8993_DCS_TRIG_SINGLE_1, | ||
103 | WM8993_DCS_TRIG_SINGLE_0 | | ||
104 | WM8993_DCS_TRIG_SINGLE_1); | ||
105 | |||
106 | return ret; | ||
107 | } | ||
108 | |||
109 | static const struct snd_kcontrol_new analogue_snd_controls[] = { | ||
110 | SOC_SINGLE_TLV("IN1L Volume", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, | ||
111 | inpga_tlv), | ||
112 | SOC_SINGLE("IN1L Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 1), | ||
113 | SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 0), | ||
114 | |||
115 | SOC_SINGLE_TLV("IN1R Volume", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 0, 31, 0, | ||
116 | inpga_tlv), | ||
117 | SOC_SINGLE("IN1R Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 1), | ||
118 | SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 0), | ||
119 | |||
120 | |||
121 | SOC_SINGLE_TLV("IN2L Volume", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, | ||
122 | inpga_tlv), | ||
123 | SOC_SINGLE("IN2L Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 1), | ||
124 | SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 0), | ||
125 | |||
126 | SOC_SINGLE_TLV("IN2R Volume", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 0, 31, 0, | ||
127 | inpga_tlv), | ||
128 | SOC_SINGLE("IN2R Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 1), | ||
129 | SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 0), | ||
130 | |||
131 | SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8993_INPUT_MIXER3, 7, 1, 0, | ||
132 | inmix_sw_tlv), | ||
133 | SOC_SINGLE_TLV("MIXINL IN1L Volume", WM8993_INPUT_MIXER3, 4, 1, 0, | ||
134 | inmix_sw_tlv), | ||
135 | SOC_SINGLE_TLV("MIXINL Output Record Volume", WM8993_INPUT_MIXER3, 0, 7, 0, | ||
136 | inmix_tlv), | ||
137 | SOC_SINGLE_TLV("MIXINL IN1LP Volume", WM8993_INPUT_MIXER5, 6, 7, 0, inmix_tlv), | ||
138 | SOC_SINGLE_TLV("MIXINL Direct Voice Volume", WM8993_INPUT_MIXER5, 0, 6, 0, | ||
139 | inmix_tlv), | ||
140 | |||
141 | SOC_SINGLE_TLV("MIXINR IN2R Volume", WM8993_INPUT_MIXER4, 7, 1, 0, | ||
142 | inmix_sw_tlv), | ||
143 | SOC_SINGLE_TLV("MIXINR IN1R Volume", WM8993_INPUT_MIXER4, 4, 1, 0, | ||
144 | inmix_sw_tlv), | ||
145 | SOC_SINGLE_TLV("MIXINR Output Record Volume", WM8993_INPUT_MIXER4, 0, 7, 0, | ||
146 | inmix_tlv), | ||
147 | SOC_SINGLE_TLV("MIXINR IN1RP Volume", WM8993_INPUT_MIXER6, 6, 7, 0, inmix_tlv), | ||
148 | SOC_SINGLE_TLV("MIXINR Direct Voice Volume", WM8993_INPUT_MIXER6, 0, 6, 0, | ||
149 | inmix_tlv), | ||
150 | |||
151 | SOC_SINGLE_TLV("Left Output Mixer IN2RN Volume", WM8993_OUTPUT_MIXER5, 6, 7, 1, | ||
152 | outmix_tlv), | ||
153 | SOC_SINGLE_TLV("Left Output Mixer IN2LN Volume", WM8993_OUTPUT_MIXER3, 6, 7, 1, | ||
154 | outmix_tlv), | ||
155 | SOC_SINGLE_TLV("Left Output Mixer IN2LP Volume", WM8993_OUTPUT_MIXER3, 9, 7, 1, | ||
156 | outmix_tlv), | ||
157 | SOC_SINGLE_TLV("Left Output Mixer IN1L Volume", WM8993_OUTPUT_MIXER3, 0, 7, 1, | ||
158 | outmix_tlv), | ||
159 | SOC_SINGLE_TLV("Left Output Mixer IN1R Volume", WM8993_OUTPUT_MIXER3, 3, 7, 1, | ||
160 | outmix_tlv), | ||
161 | SOC_SINGLE_TLV("Left Output Mixer Right Input Volume", | ||
162 | WM8993_OUTPUT_MIXER5, 3, 7, 1, outmix_tlv), | ||
163 | SOC_SINGLE_TLV("Left Output Mixer Left Input Volume", | ||
164 | WM8993_OUTPUT_MIXER5, 0, 7, 1, outmix_tlv), | ||
165 | SOC_SINGLE_TLV("Left Output Mixer DAC Volume", WM8993_OUTPUT_MIXER5, 9, 7, 1, | ||
166 | outmix_tlv), | ||
167 | |||
168 | SOC_SINGLE_TLV("Right Output Mixer IN2LN Volume", | ||
169 | WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv), | ||
170 | SOC_SINGLE_TLV("Right Output Mixer IN2RN Volume", | ||
171 | WM8993_OUTPUT_MIXER4, 6, 7, 1, outmix_tlv), | ||
172 | SOC_SINGLE_TLV("Right Output Mixer IN1L Volume", | ||
173 | WM8993_OUTPUT_MIXER4, 3, 7, 1, outmix_tlv), | ||
174 | SOC_SINGLE_TLV("Right Output Mixer IN1R Volume", | ||
175 | WM8993_OUTPUT_MIXER4, 0, 7, 1, outmix_tlv), | ||
176 | SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume", | ||
177 | WM8993_OUTPUT_MIXER4, 9, 7, 1, outmix_tlv), | ||
178 | SOC_SINGLE_TLV("Right Output Mixer Left Input Volume", | ||
179 | WM8993_OUTPUT_MIXER6, 3, 7, 1, outmix_tlv), | ||
180 | SOC_SINGLE_TLV("Right Output Mixer Right Input Volume", | ||
181 | WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv), | ||
182 | SOC_SINGLE_TLV("Right Output Mixer DAC Volume", | ||
183 | WM8993_OUTPUT_MIXER6, 9, 7, 1, outmix_tlv), | ||
184 | |||
185 | SOC_DOUBLE_R_TLV("Output Volume", WM8993_LEFT_OPGA_VOLUME, | ||
186 | WM8993_RIGHT_OPGA_VOLUME, 0, 63, 0, outpga_tlv), | ||
187 | SOC_DOUBLE_R("Output Switch", WM8993_LEFT_OPGA_VOLUME, | ||
188 | WM8993_RIGHT_OPGA_VOLUME, 6, 1, 0), | ||
189 | SOC_DOUBLE_R("Output ZC Switch", WM8993_LEFT_OPGA_VOLUME, | ||
190 | WM8993_RIGHT_OPGA_VOLUME, 7, 1, 0), | ||
191 | |||
192 | SOC_SINGLE("Earpiece Switch", WM8993_HPOUT2_VOLUME, 5, 1, 1), | ||
193 | SOC_SINGLE_TLV("Earpiece Volume", WM8993_HPOUT2_VOLUME, 4, 1, 1, earpiece_tlv), | ||
194 | |||
195 | SOC_SINGLE_TLV("SPKL Input Volume", WM8993_SPKMIXL_ATTENUATION, | ||
196 | 5, 1, 1, wm_hubs_spkmix_tlv), | ||
197 | SOC_SINGLE_TLV("SPKL IN1LP Volume", WM8993_SPKMIXL_ATTENUATION, | ||
198 | 4, 1, 1, wm_hubs_spkmix_tlv), | ||
199 | SOC_SINGLE_TLV("SPKL Output Volume", WM8993_SPKMIXL_ATTENUATION, | ||
200 | 3, 1, 1, wm_hubs_spkmix_tlv), | ||
201 | |||
202 | SOC_SINGLE_TLV("SPKR Input Volume", WM8993_SPKMIXR_ATTENUATION, | ||
203 | 5, 1, 1, wm_hubs_spkmix_tlv), | ||
204 | SOC_SINGLE_TLV("SPKR IN1RP Volume", WM8993_SPKMIXR_ATTENUATION, | ||
205 | 4, 1, 1, wm_hubs_spkmix_tlv), | ||
206 | SOC_SINGLE_TLV("SPKR Output Volume", WM8993_SPKMIXR_ATTENUATION, | ||
207 | 3, 1, 1, wm_hubs_spkmix_tlv), | ||
208 | |||
209 | SOC_DOUBLE_R_TLV("Speaker Mixer Volume", | ||
210 | WM8993_SPKMIXL_ATTENUATION, WM8993_SPKMIXR_ATTENUATION, | ||
211 | 0, 3, 1, spkmixout_tlv), | ||
212 | SOC_DOUBLE_R_TLV("Speaker Volume", | ||
213 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, | ||
214 | 0, 63, 0, outpga_tlv), | ||
215 | SOC_DOUBLE_R("Speaker Switch", | ||
216 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, | ||
217 | 6, 1, 0), | ||
218 | SOC_DOUBLE_R("Speaker ZC Switch", | ||
219 | WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT, | ||
220 | 7, 1, 0), | ||
221 | SOC_DOUBLE_TLV("Speaker Boost Volume", WM8993_SPKOUT_BOOST, 0, 3, 7, 0, | ||
222 | spkboost_tlv), | ||
223 | SOC_ENUM("Speaker Reference", speaker_ref), | ||
224 | SOC_ENUM("Speaker Mode", speaker_mode), | ||
225 | |||
226 | { | ||
227 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Headphone Volume", | ||
228 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | | ||
229 | SNDRV_CTL_ELEM_ACCESS_READWRITE, | ||
230 | .tlv.p = outpga_tlv, | ||
231 | .info = snd_soc_info_volsw_2r, | ||
232 | .get = snd_soc_get_volsw_2r, .put = wm8993_put_dc_servo, | ||
233 | .private_value = (unsigned long)&(struct soc_mixer_control) { | ||
234 | .reg = WM8993_LEFT_OUTPUT_VOLUME, | ||
235 | .rreg = WM8993_RIGHT_OUTPUT_VOLUME, | ||
236 | .shift = 0, .max = 63 | ||
237 | }, | ||
238 | }, | ||
239 | SOC_DOUBLE_R("Headphone Switch", WM8993_LEFT_OUTPUT_VOLUME, | ||
240 | WM8993_RIGHT_OUTPUT_VOLUME, 6, 1, 0), | ||
241 | SOC_DOUBLE_R("Headphone ZC Switch", WM8993_LEFT_OUTPUT_VOLUME, | ||
242 | WM8993_RIGHT_OUTPUT_VOLUME, 7, 1, 0), | ||
243 | |||
244 | SOC_SINGLE("LINEOUT1N Switch", WM8993_LINE_OUTPUTS_VOLUME, 6, 1, 1), | ||
245 | SOC_SINGLE("LINEOUT1P Switch", WM8993_LINE_OUTPUTS_VOLUME, 5, 1, 1), | ||
246 | SOC_SINGLE_TLV("LINEOUT1 Volume", WM8993_LINE_OUTPUTS_VOLUME, 4, 1, 1, | ||
247 | line_tlv), | ||
248 | |||
249 | SOC_SINGLE("LINEOUT2N Switch", WM8993_LINE_OUTPUTS_VOLUME, 2, 1, 1), | ||
250 | SOC_SINGLE("LINEOUT2P Switch", WM8993_LINE_OUTPUTS_VOLUME, 1, 1, 1), | ||
251 | SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1, | ||
252 | line_tlv), | ||
253 | }; | ||
254 | |||
255 | static int hp_event(struct snd_soc_dapm_widget *w, | ||
256 | struct snd_kcontrol *kcontrol, int event) | ||
257 | { | ||
258 | struct snd_soc_codec *codec = w->codec; | ||
259 | unsigned int reg = snd_soc_read(codec, WM8993_ANALOGUE_HP_0); | ||
260 | |||
261 | switch (event) { | ||
262 | case SND_SOC_DAPM_POST_PMU: | ||
263 | snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, | ||
264 | WM8993_CP_ENA, WM8993_CP_ENA); | ||
265 | |||
266 | msleep(5); | ||
267 | |||
268 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, | ||
269 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, | ||
270 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA); | ||
271 | |||
272 | reg |= WM8993_HPOUT1L_DLY | WM8993_HPOUT1R_DLY; | ||
273 | snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg); | ||
274 | |||
275 | /* Start the DC servo */ | ||
276 | snd_soc_update_bits(codec, WM8993_DC_SERVO_0, | ||
277 | WM8993_DCS_ENA_CHAN_0 | | ||
278 | WM8993_DCS_ENA_CHAN_1 | | ||
279 | WM8993_DCS_TRIG_STARTUP_1 | | ||
280 | WM8993_DCS_TRIG_STARTUP_0, | ||
281 | WM8993_DCS_ENA_CHAN_0 | | ||
282 | WM8993_DCS_ENA_CHAN_1 | | ||
283 | WM8993_DCS_TRIG_STARTUP_1 | | ||
284 | WM8993_DCS_TRIG_STARTUP_0); | ||
285 | wait_for_dc_servo(codec); | ||
286 | snd_soc_update_bits(codec, WM8993_DC_SERVO_1, | ||
287 | WM8993_DCS_TIMER_PERIOD_01_MASK, 0xa); | ||
288 | |||
289 | reg |= WM8993_HPOUT1R_OUTP | WM8993_HPOUT1R_RMV_SHORT | | ||
290 | WM8993_HPOUT1L_OUTP | WM8993_HPOUT1L_RMV_SHORT; | ||
291 | snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg); | ||
292 | break; | ||
293 | |||
294 | case SND_SOC_DAPM_PRE_PMD: | ||
295 | reg &= ~(WM8993_HPOUT1L_RMV_SHORT | | ||
296 | WM8993_HPOUT1L_DLY | | ||
297 | WM8993_HPOUT1L_OUTP | | ||
298 | WM8993_HPOUT1R_RMV_SHORT | | ||
299 | WM8993_HPOUT1R_DLY | | ||
300 | WM8993_HPOUT1R_OUTP); | ||
301 | |||
302 | snd_soc_update_bits(codec, WM8993_DC_SERVO_1, | ||
303 | WM8993_DCS_TIMER_PERIOD_01_MASK, 0); | ||
304 | snd_soc_update_bits(codec, WM8993_DC_SERVO_0, | ||
305 | WM8993_DCS_ENA_CHAN_0 | | ||
306 | WM8993_DCS_ENA_CHAN_1, 0); | ||
307 | |||
308 | snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg); | ||
309 | snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, | ||
310 | WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, | ||
311 | 0); | ||
312 | |||
313 | snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, | ||
314 | WM8993_CP_ENA, 0); | ||
315 | break; | ||
316 | } | ||
317 | |||
318 | return 0; | ||
319 | } | ||
320 | |||
321 | static int earpiece_event(struct snd_soc_dapm_widget *w, | ||
322 | struct snd_kcontrol *control, int event) | ||
323 | { | ||
324 | struct snd_soc_codec *codec = w->codec; | ||
325 | u16 reg = snd_soc_read(codec, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA; | ||
326 | |||
327 | switch (event) { | ||
328 | case SND_SOC_DAPM_PRE_PMU: | ||
329 | reg |= WM8993_HPOUT2_IN_ENA; | ||
330 | snd_soc_write(codec, WM8993_ANTIPOP1, reg); | ||
331 | udelay(50); | ||
332 | break; | ||
333 | |||
334 | case SND_SOC_DAPM_POST_PMD: | ||
335 | snd_soc_write(codec, WM8993_ANTIPOP1, reg); | ||
336 | break; | ||
337 | |||
338 | default: | ||
339 | BUG(); | ||
340 | break; | ||
341 | } | ||
342 | |||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | static const struct snd_kcontrol_new in1l_pga[] = { | ||
347 | SOC_DAPM_SINGLE("IN1LP Switch", WM8993_INPUT_MIXER2, 5, 1, 0), | ||
348 | SOC_DAPM_SINGLE("IN1LN Switch", WM8993_INPUT_MIXER2, 4, 1, 0), | ||
349 | }; | ||
350 | |||
351 | static const struct snd_kcontrol_new in1r_pga[] = { | ||
352 | SOC_DAPM_SINGLE("IN1RP Switch", WM8993_INPUT_MIXER2, 1, 1, 0), | ||
353 | SOC_DAPM_SINGLE("IN1RN Switch", WM8993_INPUT_MIXER2, 0, 1, 0), | ||
354 | }; | ||
355 | |||
356 | static const struct snd_kcontrol_new in2l_pga[] = { | ||
357 | SOC_DAPM_SINGLE("IN2LP Switch", WM8993_INPUT_MIXER2, 7, 1, 0), | ||
358 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_INPUT_MIXER2, 6, 1, 0), | ||
359 | }; | ||
360 | |||
361 | static const struct snd_kcontrol_new in2r_pga[] = { | ||
362 | SOC_DAPM_SINGLE("IN2RP Switch", WM8993_INPUT_MIXER2, 3, 1, 0), | ||
363 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_INPUT_MIXER2, 2, 1, 0), | ||
364 | }; | ||
365 | |||
366 | static const struct snd_kcontrol_new mixinl[] = { | ||
367 | SOC_DAPM_SINGLE("IN2L Switch", WM8993_INPUT_MIXER3, 8, 1, 0), | ||
368 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_INPUT_MIXER3, 5, 1, 0), | ||
369 | }; | ||
370 | |||
371 | static const struct snd_kcontrol_new mixinr[] = { | ||
372 | SOC_DAPM_SINGLE("IN2R Switch", WM8993_INPUT_MIXER4, 8, 1, 0), | ||
373 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_INPUT_MIXER4, 5, 1, 0), | ||
374 | }; | ||
375 | |||
376 | static const struct snd_kcontrol_new left_output_mixer[] = { | ||
377 | SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER1, 7, 1, 0), | ||
378 | SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER1, 6, 1, 0), | ||
379 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER1, 5, 1, 0), | ||
380 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER1, 4, 1, 0), | ||
381 | SOC_DAPM_SINGLE("IN2LP Switch", WM8993_OUTPUT_MIXER1, 1, 1, 0), | ||
382 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER1, 3, 1, 0), | ||
383 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER1, 2, 1, 0), | ||
384 | SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER1, 0, 1, 0), | ||
385 | }; | ||
386 | |||
387 | static const struct snd_kcontrol_new right_output_mixer[] = { | ||
388 | SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER2, 7, 1, 0), | ||
389 | SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER2, 6, 1, 0), | ||
390 | SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER2, 5, 1, 0), | ||
391 | SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER2, 4, 1, 0), | ||
392 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER2, 3, 1, 0), | ||
393 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER2, 2, 1, 0), | ||
394 | SOC_DAPM_SINGLE("IN2RP Switch", WM8993_OUTPUT_MIXER2, 1, 1, 0), | ||
395 | SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER2, 0, 1, 0), | ||
396 | }; | ||
397 | |||
398 | static const struct snd_kcontrol_new earpiece_mixer[] = { | ||
399 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_HPOUT2_MIXER, 5, 1, 0), | ||
400 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_HPOUT2_MIXER, 4, 1, 0), | ||
401 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_HPOUT2_MIXER, 3, 1, 0), | ||
402 | }; | ||
403 | |||
404 | static const struct snd_kcontrol_new left_speaker_boost[] = { | ||
405 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 5, 1, 0), | ||
406 | SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 4, 1, 0), | ||
407 | SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 3, 1, 0), | ||
408 | }; | ||
409 | |||
410 | static const struct snd_kcontrol_new right_speaker_boost[] = { | ||
411 | SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 2, 1, 0), | ||
412 | SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 1, 1, 0), | ||
413 | SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 0, 1, 0), | ||
414 | }; | ||
415 | |||
416 | static const struct snd_kcontrol_new line1_mix[] = { | ||
417 | SOC_DAPM_SINGLE("IN1R Switch", WM8993_LINE_MIXER1, 2, 1, 0), | ||
418 | SOC_DAPM_SINGLE("IN1L Switch", WM8993_LINE_MIXER1, 1, 1, 0), | ||
419 | SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER1, 0, 1, 0), | ||
420 | }; | ||
421 | |||
422 | static const struct snd_kcontrol_new line1n_mix[] = { | ||
423 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 6, 1, 0), | ||
424 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER1, 5, 1, 0), | ||
425 | }; | ||
426 | |||
427 | static const struct snd_kcontrol_new line1p_mix[] = { | ||
428 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 0, 1, 0), | ||
429 | }; | ||
430 | |||
431 | static const struct snd_kcontrol_new line2_mix[] = { | ||
432 | SOC_DAPM_SINGLE("IN2R Switch", WM8993_LINE_MIXER2, 2, 1, 0), | ||
433 | SOC_DAPM_SINGLE("IN2L Switch", WM8993_LINE_MIXER2, 1, 1, 0), | ||
434 | SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER2, 0, 1, 0), | ||
435 | }; | ||
436 | |||
437 | static const struct snd_kcontrol_new line2n_mix[] = { | ||
438 | SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER2, 6, 1, 0), | ||
439 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 5, 1, 0), | ||
440 | }; | ||
441 | |||
442 | static const struct snd_kcontrol_new line2p_mix[] = { | ||
443 | SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 0, 1, 0), | ||
444 | }; | ||
445 | |||
446 | static const struct snd_soc_dapm_widget analogue_dapm_widgets[] = { | ||
447 | SND_SOC_DAPM_INPUT("IN1LN"), | ||
448 | SND_SOC_DAPM_INPUT("IN1LP"), | ||
449 | SND_SOC_DAPM_INPUT("IN2LN"), | ||
450 | SND_SOC_DAPM_INPUT("IN2LP/VXRN"), | ||
451 | SND_SOC_DAPM_INPUT("IN1RN"), | ||
452 | SND_SOC_DAPM_INPUT("IN1RP"), | ||
453 | SND_SOC_DAPM_INPUT("IN2RN"), | ||
454 | SND_SOC_DAPM_INPUT("IN2RP/VXRP"), | ||
455 | |||
456 | SND_SOC_DAPM_MICBIAS("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0), | ||
457 | SND_SOC_DAPM_MICBIAS("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0), | ||
458 | |||
459 | SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2, 6, 0, | ||
460 | in1l_pga, ARRAY_SIZE(in1l_pga)), | ||
461 | SND_SOC_DAPM_MIXER("IN1R PGA", WM8993_POWER_MANAGEMENT_2, 4, 0, | ||
462 | in1r_pga, ARRAY_SIZE(in1r_pga)), | ||
463 | |||
464 | SND_SOC_DAPM_MIXER("IN2L PGA", WM8993_POWER_MANAGEMENT_2, 7, 0, | ||
465 | in2l_pga, ARRAY_SIZE(in2l_pga)), | ||
466 | SND_SOC_DAPM_MIXER("IN2R PGA", WM8993_POWER_MANAGEMENT_2, 5, 0, | ||
467 | in2r_pga, ARRAY_SIZE(in2r_pga)), | ||
468 | |||
469 | /* Dummy widgets to represent differential paths */ | ||
470 | SND_SOC_DAPM_PGA("Direct Voice", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
471 | |||
472 | SND_SOC_DAPM_MIXER("MIXINL", WM8993_POWER_MANAGEMENT_2, 9, 0, | ||
473 | mixinl, ARRAY_SIZE(mixinl)), | ||
474 | SND_SOC_DAPM_MIXER("MIXINR", WM8993_POWER_MANAGEMENT_2, 8, 0, | ||
475 | mixinr, ARRAY_SIZE(mixinr)), | ||
476 | |||
477 | SND_SOC_DAPM_ADC("ADCL", "Capture", WM8993_POWER_MANAGEMENT_2, 1, 0), | ||
478 | SND_SOC_DAPM_ADC("ADCR", "Capture", WM8993_POWER_MANAGEMENT_2, 0, 0), | ||
479 | |||
480 | SND_SOC_DAPM_DAC("DACL", "Playback", WM8993_POWER_MANAGEMENT_3, 1, 0), | ||
481 | SND_SOC_DAPM_DAC("DACR", "Playback", WM8993_POWER_MANAGEMENT_3, 0, 0), | ||
482 | |||
483 | SND_SOC_DAPM_MIXER("Left Output Mixer", WM8993_POWER_MANAGEMENT_3, 5, 0, | ||
484 | left_output_mixer, ARRAY_SIZE(left_output_mixer)), | ||
485 | SND_SOC_DAPM_MIXER("Right Output Mixer", WM8993_POWER_MANAGEMENT_3, 4, 0, | ||
486 | right_output_mixer, ARRAY_SIZE(right_output_mixer)), | ||
487 | |||
488 | SND_SOC_DAPM_PGA("Left Output PGA", WM8993_POWER_MANAGEMENT_3, 7, 0, NULL, 0), | ||
489 | SND_SOC_DAPM_PGA("Right Output PGA", WM8993_POWER_MANAGEMENT_3, 6, 0, NULL, 0), | ||
490 | |||
491 | SND_SOC_DAPM_PGA_E("Headphone PGA", SND_SOC_NOPM, 0, 0, | ||
492 | NULL, 0, | ||
493 | hp_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), | ||
494 | |||
495 | SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM, 0, 0, | ||
496 | earpiece_mixer, ARRAY_SIZE(earpiece_mixer)), | ||
497 | SND_SOC_DAPM_PGA_E("Earpiece Driver", WM8993_POWER_MANAGEMENT_1, 11, 0, | ||
498 | NULL, 0, earpiece_event, | ||
499 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | ||
500 | |||
501 | SND_SOC_DAPM_MIXER("SPKL Boost", SND_SOC_NOPM, 0, 0, | ||
502 | left_speaker_boost, ARRAY_SIZE(left_speaker_boost)), | ||
503 | SND_SOC_DAPM_MIXER("SPKR Boost", SND_SOC_NOPM, 0, 0, | ||
504 | right_speaker_boost, ARRAY_SIZE(right_speaker_boost)), | ||
505 | |||
506 | SND_SOC_DAPM_PGA("SPKL Driver", WM8993_POWER_MANAGEMENT_1, 12, 0, | ||
507 | NULL, 0), | ||
508 | SND_SOC_DAPM_PGA("SPKR Driver", WM8993_POWER_MANAGEMENT_1, 13, 0, | ||
509 | NULL, 0), | ||
510 | |||
511 | SND_SOC_DAPM_MIXER("LINEOUT1 Mixer", SND_SOC_NOPM, 0, 0, | ||
512 | line1_mix, ARRAY_SIZE(line1_mix)), | ||
513 | SND_SOC_DAPM_MIXER("LINEOUT2 Mixer", SND_SOC_NOPM, 0, 0, | ||
514 | line2_mix, ARRAY_SIZE(line2_mix)), | ||
515 | |||
516 | SND_SOC_DAPM_MIXER("LINEOUT1N Mixer", SND_SOC_NOPM, 0, 0, | ||
517 | line1n_mix, ARRAY_SIZE(line1n_mix)), | ||
518 | SND_SOC_DAPM_MIXER("LINEOUT1P Mixer", SND_SOC_NOPM, 0, 0, | ||
519 | line1p_mix, ARRAY_SIZE(line1p_mix)), | ||
520 | SND_SOC_DAPM_MIXER("LINEOUT2N Mixer", SND_SOC_NOPM, 0, 0, | ||
521 | line2n_mix, ARRAY_SIZE(line2n_mix)), | ||
522 | SND_SOC_DAPM_MIXER("LINEOUT2P Mixer", SND_SOC_NOPM, 0, 0, | ||
523 | line2p_mix, ARRAY_SIZE(line2p_mix)), | ||
524 | |||
525 | SND_SOC_DAPM_PGA("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3, 13, 0, | ||
526 | NULL, 0), | ||
527 | SND_SOC_DAPM_PGA("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3, 12, 0, | ||
528 | NULL, 0), | ||
529 | SND_SOC_DAPM_PGA("LINEOUT2N Driver", WM8993_POWER_MANAGEMENT_3, 11, 0, | ||
530 | NULL, 0), | ||
531 | SND_SOC_DAPM_PGA("LINEOUT2P Driver", WM8993_POWER_MANAGEMENT_3, 10, 0, | ||
532 | NULL, 0), | ||
533 | |||
534 | SND_SOC_DAPM_OUTPUT("SPKOUTLP"), | ||
535 | SND_SOC_DAPM_OUTPUT("SPKOUTLN"), | ||
536 | SND_SOC_DAPM_OUTPUT("SPKOUTRP"), | ||
537 | SND_SOC_DAPM_OUTPUT("SPKOUTRN"), | ||
538 | SND_SOC_DAPM_OUTPUT("HPOUT1L"), | ||
539 | SND_SOC_DAPM_OUTPUT("HPOUT1R"), | ||
540 | SND_SOC_DAPM_OUTPUT("HPOUT2P"), | ||
541 | SND_SOC_DAPM_OUTPUT("HPOUT2N"), | ||
542 | SND_SOC_DAPM_OUTPUT("LINEOUT1P"), | ||
543 | SND_SOC_DAPM_OUTPUT("LINEOUT1N"), | ||
544 | SND_SOC_DAPM_OUTPUT("LINEOUT2P"), | ||
545 | SND_SOC_DAPM_OUTPUT("LINEOUT2N"), | ||
546 | }; | ||
547 | |||
548 | static const struct snd_soc_dapm_route analogue_routes[] = { | ||
549 | { "IN1L PGA", "IN1LP Switch", "IN1LP" }, | ||
550 | { "IN1L PGA", "IN1LN Switch", "IN1LN" }, | ||
551 | |||
552 | { "IN1R PGA", "IN1RP Switch", "IN1RP" }, | ||
553 | { "IN1R PGA", "IN1RN Switch", "IN1RN" }, | ||
554 | |||
555 | { "IN2L PGA", "IN2LP Switch", "IN2LP/VXRN" }, | ||
556 | { "IN2L PGA", "IN2LN Switch", "IN2LN" }, | ||
557 | |||
558 | { "IN2R PGA", "IN2RP Switch", "IN2RP/VXRP" }, | ||
559 | { "IN2R PGA", "IN2RN Switch", "IN2RN" }, | ||
560 | |||
561 | { "Direct Voice", NULL, "IN2LP/VXRN" }, | ||
562 | { "Direct Voice", NULL, "IN2RP/VXRP" }, | ||
563 | |||
564 | { "MIXINL", "IN1L Switch", "IN1L PGA" }, | ||
565 | { "MIXINL", "IN2L Switch", "IN2L PGA" }, | ||
566 | { "MIXINL", NULL, "Direct Voice" }, | ||
567 | { "MIXINL", NULL, "IN1LP" }, | ||
568 | { "MIXINL", NULL, "Left Output Mixer" }, | ||
569 | |||
570 | { "MIXINR", "IN1R Switch", "IN1R PGA" }, | ||
571 | { "MIXINR", "IN2R Switch", "IN2R PGA" }, | ||
572 | { "MIXINR", NULL, "Direct Voice" }, | ||
573 | { "MIXINR", NULL, "IN1RP" }, | ||
574 | { "MIXINR", NULL, "Right Output Mixer" }, | ||
575 | |||
576 | { "ADCL", NULL, "MIXINL" }, | ||
577 | { "ADCR", NULL, "MIXINR" }, | ||
578 | |||
579 | { "Left Output Mixer", "Left Input Switch", "MIXINL" }, | ||
580 | { "Left Output Mixer", "Right Input Switch", "MIXINR" }, | ||
581 | { "Left Output Mixer", "IN2RN Switch", "IN2RN" }, | ||
582 | { "Left Output Mixer", "IN2LN Switch", "IN2LN" }, | ||
583 | { "Left Output Mixer", "IN2LP Switch", "IN2LP/VXRN" }, | ||
584 | { "Left Output Mixer", "IN1L Switch", "IN1L PGA" }, | ||
585 | { "Left Output Mixer", "IN1R Switch", "IN1R PGA" }, | ||
586 | |||
587 | { "Right Output Mixer", "Left Input Switch", "MIXINL" }, | ||
588 | { "Right Output Mixer", "Right Input Switch", "MIXINR" }, | ||
589 | { "Right Output Mixer", "IN2LN Switch", "IN2LN" }, | ||
590 | { "Right Output Mixer", "IN2RN Switch", "IN2RN" }, | ||
591 | { "Right Output Mixer", "IN2RP Switch", "IN2RP/VXRP" }, | ||
592 | { "Right Output Mixer", "IN1L Switch", "IN1L PGA" }, | ||
593 | { "Right Output Mixer", "IN1R Switch", "IN1R PGA" }, | ||
594 | |||
595 | { "Left Output PGA", NULL, "Left Output Mixer" }, | ||
596 | { "Left Output PGA", NULL, "TOCLK" }, | ||
597 | |||
598 | { "Right Output PGA", NULL, "Right Output Mixer" }, | ||
599 | { "Right Output PGA", NULL, "TOCLK" }, | ||
600 | |||
601 | { "Earpiece Mixer", "Direct Voice Switch", "Direct Voice" }, | ||
602 | { "Earpiece Mixer", "Left Output Switch", "Left Output PGA" }, | ||
603 | { "Earpiece Mixer", "Right Output Switch", "Right Output PGA" }, | ||
604 | |||
605 | { "Earpiece Driver", NULL, "Earpiece Mixer" }, | ||
606 | { "HPOUT2N", NULL, "Earpiece Driver" }, | ||
607 | { "HPOUT2P", NULL, "Earpiece Driver" }, | ||
608 | |||
609 | { "SPKL", "Input Switch", "MIXINL" }, | ||
610 | { "SPKL", "IN1LP Switch", "IN1LP" }, | ||
611 | { "SPKL", "Output Switch", "Left Output Mixer" }, | ||
612 | { "SPKL", NULL, "TOCLK" }, | ||
613 | |||
614 | { "SPKR", "Input Switch", "MIXINR" }, | ||
615 | { "SPKR", "IN1RP Switch", "IN1RP" }, | ||
616 | { "SPKR", "Output Switch", "Right Output Mixer" }, | ||
617 | { "SPKR", NULL, "TOCLK" }, | ||
618 | |||
619 | { "SPKL Boost", "Direct Voice Switch", "Direct Voice" }, | ||
620 | { "SPKL Boost", "SPKL Switch", "SPKL" }, | ||
621 | { "SPKL Boost", "SPKR Switch", "SPKR" }, | ||
622 | |||
623 | { "SPKR Boost", "Direct Voice Switch", "Direct Voice" }, | ||
624 | { "SPKR Boost", "SPKR Switch", "SPKR" }, | ||
625 | { "SPKR Boost", "SPKL Switch", "SPKL" }, | ||
626 | |||
627 | { "SPKL Driver", NULL, "SPKL Boost" }, | ||
628 | { "SPKL Driver", NULL, "CLK_SYS" }, | ||
629 | |||
630 | { "SPKR Driver", NULL, "SPKR Boost" }, | ||
631 | { "SPKR Driver", NULL, "CLK_SYS" }, | ||
632 | |||
633 | { "SPKOUTLP", NULL, "SPKL Driver" }, | ||
634 | { "SPKOUTLN", NULL, "SPKL Driver" }, | ||
635 | { "SPKOUTRP", NULL, "SPKR Driver" }, | ||
636 | { "SPKOUTRN", NULL, "SPKR Driver" }, | ||
637 | |||
638 | { "Left Headphone Mux", "Mixer", "Left Output Mixer" }, | ||
639 | { "Right Headphone Mux", "Mixer", "Right Output Mixer" }, | ||
640 | |||
641 | { "Headphone PGA", NULL, "Left Headphone Mux" }, | ||
642 | { "Headphone PGA", NULL, "Right Headphone Mux" }, | ||
643 | { "Headphone PGA", NULL, "CLK_SYS" }, | ||
644 | |||
645 | { "HPOUT1L", NULL, "Headphone PGA" }, | ||
646 | { "HPOUT1R", NULL, "Headphone PGA" }, | ||
647 | |||
648 | { "LINEOUT1N", NULL, "LINEOUT1N Driver" }, | ||
649 | { "LINEOUT1P", NULL, "LINEOUT1P Driver" }, | ||
650 | { "LINEOUT2N", NULL, "LINEOUT2N Driver" }, | ||
651 | { "LINEOUT2P", NULL, "LINEOUT2P Driver" }, | ||
652 | }; | ||
653 | |||
654 | static const struct snd_soc_dapm_route lineout1_diff_routes[] = { | ||
655 | { "LINEOUT1 Mixer", "IN1L Switch", "IN1L PGA" }, | ||
656 | { "LINEOUT1 Mixer", "IN1R Switch", "IN1R PGA" }, | ||
657 | { "LINEOUT1 Mixer", "Output Switch", "Left Output Mixer" }, | ||
658 | |||
659 | { "LINEOUT1N Driver", NULL, "LINEOUT1 Mixer" }, | ||
660 | { "LINEOUT1P Driver", NULL, "LINEOUT1 Mixer" }, | ||
661 | }; | ||
662 | |||
663 | static const struct snd_soc_dapm_route lineout1_se_routes[] = { | ||
664 | { "LINEOUT1N Mixer", "Left Output Switch", "Left Output Mixer" }, | ||
665 | { "LINEOUT1N Mixer", "Right Output Switch", "Left Output Mixer" }, | ||
666 | |||
667 | { "LINEOUT1P Mixer", "Left Output Switch", "Left Output Mixer" }, | ||
668 | |||
669 | { "LINEOUT1N Driver", NULL, "LINEOUT1N Mixer" }, | ||
670 | { "LINEOUT1P Driver", NULL, "LINEOUT1P Mixer" }, | ||
671 | }; | ||
672 | |||
673 | static const struct snd_soc_dapm_route lineout2_diff_routes[] = { | ||
674 | { "LINEOUT2 Mixer", "IN2L Switch", "IN2L PGA" }, | ||
675 | { "LINEOUT2 Mixer", "IN2R Switch", "IN2R PGA" }, | ||
676 | { "LINEOUT2 Mixer", "Output Switch", "Right Output Mixer" }, | ||
677 | |||
678 | { "LINEOUT2N Driver", NULL, "LINEOUT2 Mixer" }, | ||
679 | { "LINEOUT2P Driver", NULL, "LINEOUT2 Mixer" }, | ||
680 | }; | ||
681 | |||
682 | static const struct snd_soc_dapm_route lineout2_se_routes[] = { | ||
683 | { "LINEOUT2N Mixer", "Left Output Switch", "Left Output Mixer" }, | ||
684 | { "LINEOUT2N Mixer", "Right Output Switch", "Left Output Mixer" }, | ||
685 | |||
686 | { "LINEOUT2P Mixer", "Right Output Switch", "Right Output Mixer" }, | ||
687 | |||
688 | { "LINEOUT2N Driver", NULL, "LINEOUT2N Mixer" }, | ||
689 | { "LINEOUT2P Driver", NULL, "LINEOUT2P Mixer" }, | ||
690 | }; | ||
691 | |||
692 | int wm_hubs_add_analogue_controls(struct snd_soc_codec *codec) | ||
693 | { | ||
694 | /* Latch volume update bits & default ZC on */ | ||
695 | snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_1_2_VOLUME, | ||
696 | WM8993_IN1_VU, WM8993_IN1_VU); | ||
697 | snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, | ||
698 | WM8993_IN1_VU, WM8993_IN1_VU); | ||
699 | snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_3_4_VOLUME, | ||
700 | WM8993_IN2_VU, WM8993_IN2_VU); | ||
701 | snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, | ||
702 | WM8993_IN2_VU, WM8993_IN2_VU); | ||
703 | |||
704 | snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_RIGHT, | ||
705 | WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); | ||
706 | |||
707 | snd_soc_update_bits(codec, WM8993_LEFT_OUTPUT_VOLUME, | ||
708 | WM8993_HPOUT1L_ZC, WM8993_HPOUT1L_ZC); | ||
709 | snd_soc_update_bits(codec, WM8993_RIGHT_OUTPUT_VOLUME, | ||
710 | WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC, | ||
711 | WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC); | ||
712 | |||
713 | snd_soc_update_bits(codec, WM8993_LEFT_OPGA_VOLUME, | ||
714 | WM8993_MIXOUTL_ZC, WM8993_MIXOUTL_ZC); | ||
715 | snd_soc_update_bits(codec, WM8993_RIGHT_OPGA_VOLUME, | ||
716 | WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU, | ||
717 | WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU); | ||
718 | |||
719 | snd_soc_add_controls(codec, analogue_snd_controls, | ||
720 | ARRAY_SIZE(analogue_snd_controls)); | ||
721 | |||
722 | snd_soc_dapm_new_controls(codec, analogue_dapm_widgets, | ||
723 | ARRAY_SIZE(analogue_dapm_widgets)); | ||
724 | return 0; | ||
725 | } | ||
726 | EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls); | ||
727 | |||
728 | int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec, | ||
729 | int lineout1_diff, int lineout2_diff) | ||
730 | { | ||
731 | snd_soc_dapm_add_routes(codec, analogue_routes, | ||
732 | ARRAY_SIZE(analogue_routes)); | ||
733 | |||
734 | if (lineout1_diff) | ||
735 | snd_soc_dapm_add_routes(codec, | ||
736 | lineout1_diff_routes, | ||
737 | ARRAY_SIZE(lineout1_diff_routes)); | ||
738 | else | ||
739 | snd_soc_dapm_add_routes(codec, | ||
740 | lineout1_se_routes, | ||
741 | ARRAY_SIZE(lineout1_se_routes)); | ||
742 | |||
743 | if (lineout2_diff) | ||
744 | snd_soc_dapm_add_routes(codec, | ||
745 | lineout2_diff_routes, | ||
746 | ARRAY_SIZE(lineout2_diff_routes)); | ||
747 | else | ||
748 | snd_soc_dapm_add_routes(codec, | ||
749 | lineout2_se_routes, | ||
750 | ARRAY_SIZE(lineout2_se_routes)); | ||
751 | |||
752 | return 0; | ||
753 | } | ||
754 | EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes); | ||
755 | |||
756 | MODULE_DESCRIPTION("Shared support for Wolfson hubs products"); | ||
757 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); | ||
758 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/wm_hubs.h b/sound/soc/codecs/wm_hubs.h new file mode 100644 index 000000000000..ec09cb6a2939 --- /dev/null +++ b/sound/soc/codecs/wm_hubs.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * wm_hubs.h -- WM899x common code | ||
3 | * | ||
4 | * Copyright 2009 Wolfson Microelectronics plc | ||
5 | * | ||
6 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | ||
7 | * | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #ifndef _WM_HUBS_H | ||
15 | #define _WM_HUBS_H | ||
16 | |||
17 | struct snd_soc_codec; | ||
18 | |||
19 | extern const unsigned int wm_hubs_spkmix_tlv[]; | ||
20 | |||
21 | extern int wm_hubs_add_analogue_controls(struct snd_soc_codec *); | ||
22 | extern int wm_hubs_add_analogue_routes(struct snd_soc_codec *, int, int); | ||
23 | |||
24 | #endif | ||