aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8993.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2009-07-29 16:21:49 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-08-13 17:19:31 -0400
commita2342ae325bb1f65d90a9f38baab4c9762018a5e (patch)
treed1e7e4a45421ff9b16ef2e1059568305b79fa420 /sound/soc/codecs/wm8993.c
parente9ade7f933d629698cbe5f09f1e5511269180fea (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.c716
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
31static u16 wm8993_reg_defaults[WM8993_REGISTER_COUNT] = { 32static 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
560static 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
579static const DECLARE_TLV_DB_SCALE(inpga_tlv, -1650, 150, 0);
580static const DECLARE_TLV_DB_SCALE(inmix_sw_tlv, 0, 3000, 0);
581static const DECLARE_TLV_DB_SCALE(inmix_tlv, -1500, 300, 1);
582static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -3600, 300, 0); 561static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -3600, 300, 0);
583static const DECLARE_TLV_DB_SCALE(drc_comp_threash, -4500, 75, 0); 562static const DECLARE_TLV_DB_SCALE(drc_comp_threash, -4500, 75, 0);
584static const DECLARE_TLV_DB_SCALE(drc_comp_amp, -2250, 75, 0); 563static 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);
593static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); 572static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
594static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1); 573static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1);
595static const DECLARE_TLV_DB_SCALE(dac_boost_tlv, 0, 600, 0); 574static const DECLARE_TLV_DB_SCALE(dac_boost_tlv, 0, 600, 0);
596static const DECLARE_TLV_DB_SCALE(earpiece_tlv, -600, 600, 0);
597static const DECLARE_TLV_DB_SCALE(outmix_tlv, -2100, 300, 0);
598static const DECLARE_TLV_DB_SCALE(spkmix_tlv, -300, 300, 0);
599static const DECLARE_TLV_DB_SCALE(spkmixout_tlv, -1800, 600, 1);
600static const DECLARE_TLV_DB_SCALE(outpga_tlv, -5700, 100, 0);
601static 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};
606static const DECLARE_TLV_DB_SCALE(line_tlv, -600, 600, 0);
607
608static const char *speaker_ref_text[] = {
609 "SPKVDD/2",
610 "VMID",
611};
612
613static const struct soc_enum speaker_ref =
614 SOC_ENUM_SINGLE(WM8993_SPEAKER_MIXER, 8, 2, speaker_ref_text);
615
616static const char *speaker_mode_text[] = {
617 "Class D",
618 "Class AB",
619};
620
621static const struct soc_enum speaker_mode =
622 SOC_ENUM_SINGLE(WM8993_SPKMIXR_ATTENUATION, 8, 2, speaker_mode_text);
623 575
624static const char *dac_deemph_text[] = { 576static const char *dac_deemph_text[] = {
625 "None", 577 "None",
@@ -731,73 +683,7 @@ static const char *drc_smooth_text[] = {
731static const struct soc_enum drc_smooth = 683static 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 */
738static 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
759static const struct snd_kcontrol_new wm8993_snd_controls[] = { 686static const struct snd_kcontrol_new wm8993_snd_controls[] = {
760SOC_SINGLE_TLV("IN1L Volume", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 0, 31, 0,
761 inpga_tlv),
762SOC_SINGLE("IN1L Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 1),
763SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 0),
764
765SOC_SINGLE_TLV("IN1R Volume", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 0, 31, 0,
766 inpga_tlv),
767SOC_SINGLE("IN1R Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 1),
768SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 0),
769
770
771SOC_SINGLE_TLV("IN2L Volume", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 0, 31, 0,
772 inpga_tlv),
773SOC_SINGLE("IN2L Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 1),
774SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 0),
775
776SOC_SINGLE_TLV("IN2R Volume", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 0, 31, 0,
777 inpga_tlv),
778SOC_SINGLE("IN2R Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 1),
779SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 0),
780
781SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8993_INPUT_MIXER3, 7, 1, 0,
782 inmix_sw_tlv),
783SOC_SINGLE_TLV("MIXINL IN1L Volume", WM8993_INPUT_MIXER3, 4, 1, 0,
784 inmix_sw_tlv),
785SOC_SINGLE_TLV("MIXINL Output Record Volume", WM8993_INPUT_MIXER3, 0, 7, 0,
786 inmix_tlv),
787SOC_SINGLE_TLV("MIXINL IN1LP Volume", WM8993_INPUT_MIXER5, 6, 7, 0, inmix_tlv),
788SOC_SINGLE_TLV("MIXINL Direct Voice Volume", WM8993_INPUT_MIXER5, 0, 6, 0,
789 inmix_tlv),
790
791SOC_SINGLE_TLV("MIXINR IN2R Volume", WM8993_INPUT_MIXER4, 7, 1, 0,
792 inmix_sw_tlv),
793SOC_SINGLE_TLV("MIXINR IN1R Volume", WM8993_INPUT_MIXER4, 4, 1, 0,
794 inmix_sw_tlv),
795SOC_SINGLE_TLV("MIXINR Output Record Volume", WM8993_INPUT_MIXER4, 0, 7, 0,
796 inmix_tlv),
797SOC_SINGLE_TLV("MIXINR IN1RP Volume", WM8993_INPUT_MIXER6, 6, 7, 0, inmix_tlv),
798SOC_SINGLE_TLV("MIXINR Direct Voice Volume", WM8993_INPUT_MIXER6, 0, 6, 0,
799 inmix_tlv),
800
801SOC_DOUBLE_TLV("Digital Sidetone Volume", WM8993_DIGITAL_SIDE_TONE, 687SOC_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),
841SOC_ENUM("DAC Deemphasis", dac_deemph), 727SOC_ENUM("DAC Deemphasis", dac_deemph),
842 728
843SOC_SINGLE_TLV("Left Output Mixer IN2RN Volume", WM8993_OUTPUT_MIXER5, 6, 7, 1,
844 outmix_tlv),
845SOC_SINGLE_TLV("Left Output Mixer IN2LN Volume", WM8993_OUTPUT_MIXER3, 6, 7, 1,
846 outmix_tlv),
847SOC_SINGLE_TLV("Left Output Mixer IN2LP Volume", WM8993_OUTPUT_MIXER3, 9, 7, 1,
848 outmix_tlv),
849SOC_SINGLE_TLV("Left Output Mixer IN1L Volume", WM8993_OUTPUT_MIXER3, 0, 7, 1,
850 outmix_tlv),
851SOC_SINGLE_TLV("Left Output Mixer IN1R Volume", WM8993_OUTPUT_MIXER3, 3, 7, 1,
852 outmix_tlv),
853SOC_SINGLE_TLV("Left Output Mixer Right Input Volume",
854 WM8993_OUTPUT_MIXER5, 3, 7, 1, outmix_tlv),
855SOC_SINGLE_TLV("Left Output Mixer Left Input Volume",
856 WM8993_OUTPUT_MIXER5, 0, 7, 1, outmix_tlv),
857SOC_SINGLE_TLV("Left Output Mixer DAC Volume", WM8993_OUTPUT_MIXER5, 9, 7, 1,
858 outmix_tlv),
859
860SOC_SINGLE_TLV("Right Output Mixer IN2LN Volume",
861 WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv),
862SOC_SINGLE_TLV("Right Output Mixer IN2RN Volume",
863 WM8993_OUTPUT_MIXER4, 6, 7, 1, outmix_tlv),
864SOC_SINGLE_TLV("Right Output Mixer IN1L Volume",
865 WM8993_OUTPUT_MIXER4, 3, 7, 1, outmix_tlv),
866SOC_SINGLE_TLV("Right Output Mixer IN1R Volume",
867 WM8993_OUTPUT_MIXER4, 0, 7, 1, outmix_tlv),
868SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume",
869 WM8993_OUTPUT_MIXER4, 9, 7, 1, outmix_tlv),
870SOC_SINGLE_TLV("Right Output Mixer Left Input Volume",
871 WM8993_OUTPUT_MIXER6, 3, 7, 1, outmix_tlv),
872SOC_SINGLE_TLV("Right Output Mixer Right Input Volume",
873 WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv),
874SOC_SINGLE_TLV("Right Output Mixer DAC Volume",
875 WM8993_OUTPUT_MIXER6, 9, 7, 1, outmix_tlv),
876
877SOC_DOUBLE_R_TLV("Output Volume", WM8993_LEFT_OPGA_VOLUME,
878 WM8993_RIGHT_OPGA_VOLUME, 0, 63, 0, outpga_tlv),
879SOC_DOUBLE_R("Output Switch", WM8993_LEFT_OPGA_VOLUME,
880 WM8993_RIGHT_OPGA_VOLUME, 6, 1, 0),
881SOC_DOUBLE_R("Output ZC Switch", WM8993_LEFT_OPGA_VOLUME,
882 WM8993_RIGHT_OPGA_VOLUME, 7, 1, 0),
883
884SOC_SINGLE("Earpiece Switch", WM8993_HPOUT2_VOLUME, 5, 1, 1),
885SOC_SINGLE_TLV("Earpiece Volume", WM8993_HPOUT2_VOLUME, 4, 1, 1, earpiece_tlv),
886
887SOC_SINGLE_TLV("SPKL Input Volume", WM8993_SPKMIXL_ATTENUATION,
888 5, 1, 1, spkmix_tlv),
889SOC_SINGLE_TLV("SPKL IN1LP Volume", WM8993_SPKMIXL_ATTENUATION,
890 4, 1, 1, spkmix_tlv),
891SOC_SINGLE_TLV("SPKL Output Volume", WM8993_SPKMIXL_ATTENUATION,
892 3, 1, 1, spkmix_tlv),
893SOC_SINGLE_TLV("SPKL DAC Volume", WM8993_SPKMIXL_ATTENUATION, 729SOC_SINGLE_TLV("SPKL DAC Volume", WM8993_SPKMIXL_ATTENUATION,
894 2, 1, 1, spkmix_tlv), 730 2, 1, 1, wm_hubs_spkmix_tlv),
895
896SOC_SINGLE_TLV("SPKR Input Volume", WM8993_SPKMIXR_ATTENUATION,
897 5, 1, 1, spkmix_tlv),
898SOC_SINGLE_TLV("SPKR IN1RP Volume", WM8993_SPKMIXR_ATTENUATION,
899 4, 1, 1, spkmix_tlv),
900SOC_SINGLE_TLV("SPKR Output Volume", WM8993_SPKMIXR_ATTENUATION,
901 3, 1, 1, spkmix_tlv),
902SOC_SINGLE_TLV("SPKR DAC Volume", WM8993_SPKMIXR_ATTENUATION,
903 2, 1, 1, spkmix_tlv),
904
905SOC_DOUBLE_R_TLV("Speaker Mixer Volume",
906 WM8993_SPKMIXL_ATTENUATION, WM8993_SPKMIXR_ATTENUATION,
907 0, 3, 1, spkmixout_tlv),
908SOC_DOUBLE_R_TLV("Speaker Volume",
909 WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT,
910 0, 63, 0, outpga_tlv),
911SOC_DOUBLE_R("Speaker Switch",
912 WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT,
913 6, 1, 0),
914SOC_DOUBLE_R("Speaker ZC Switch",
915 WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT,
916 7, 1, 0),
917SOC_DOUBLE_TLV("Speaker Boost Volume", WM8993_SPKOUT_BOOST, 0, 3, 7, 0,
918 spkboost_tlv),
919SOC_ENUM("Speaker Reference", speaker_ref),
920SOC_ENUM("Speaker Mode", speaker_mode),
921 731
922{ 732SOC_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},
935SOC_DOUBLE_R("Headphone Switch", WM8993_LEFT_OUTPUT_VOLUME,
936 WM8993_RIGHT_OUTPUT_VOLUME, 6, 1, 0),
937SOC_DOUBLE_R("Headphone ZC Switch", WM8993_LEFT_OUTPUT_VOLUME,
938 WM8993_RIGHT_OUTPUT_VOLUME, 7, 1, 0),
939
940SOC_SINGLE("LINEOUT1N Switch", WM8993_LINE_OUTPUTS_VOLUME, 6, 1, 1),
941SOC_SINGLE("LINEOUT1P Switch", WM8993_LINE_OUTPUTS_VOLUME, 5, 1, 1),
942SOC_SINGLE_TLV("LINEOUT1 Volume", WM8993_LINE_OUTPUTS_VOLUME, 4, 1, 1,
943 line_tlv),
944
945SOC_SINGLE("LINEOUT2N Switch", WM8993_LINE_OUTPUTS_VOLUME, 2, 1, 1),
946SOC_SINGLE("LINEOUT2P Switch", WM8993_LINE_OUTPUTS_VOLUME, 1, 1, 1),
947SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1,
948 line_tlv),
949}; 734};
950 735
951static const struct snd_kcontrol_new wm8993_eq_controls[] = { 736static const struct snd_kcontrol_new wm8993_eq_controls[] = {
@@ -956,31 +741,6 @@ SOC_SINGLE_TLV("EQ4 Volume", WM8993_EQ5, 0, 24, 0, eq_tlv),
956SOC_SINGLE_TLV("EQ5 Volume", WM8993_EQ6, 0, 24, 0, eq_tlv), 741SOC_SINGLE_TLV("EQ5 Volume", WM8993_EQ6, 0, 24, 0, eq_tlv),
957}; 742};
958 743
959static 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
984static int clk_sys_event(struct snd_soc_dapm_widget *w, 744static 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 */
1009static int wm8993_class_w_put(struct snd_kcontrol *kcontrol, 769static 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
1058static 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
1125static const struct snd_kcontrol_new in1l_pga[] = {
1126SOC_DAPM_SINGLE("IN1LP Switch", WM8993_INPUT_MIXER2, 5, 1, 0),
1127SOC_DAPM_SINGLE("IN1LN Switch", WM8993_INPUT_MIXER2, 4, 1, 0),
1128};
1129
1130static const struct snd_kcontrol_new in1r_pga[] = {
1131SOC_DAPM_SINGLE("IN1RP Switch", WM8993_INPUT_MIXER2, 1, 1, 0),
1132SOC_DAPM_SINGLE("IN1RN Switch", WM8993_INPUT_MIXER2, 0, 1, 0),
1133};
1134
1135static const struct snd_kcontrol_new in2l_pga[] = {
1136SOC_DAPM_SINGLE("IN2LP Switch", WM8993_INPUT_MIXER2, 7, 1, 0),
1137SOC_DAPM_SINGLE("IN2LN Switch", WM8993_INPUT_MIXER2, 6, 1, 0),
1138};
1139
1140static const struct snd_kcontrol_new in2r_pga[] = {
1141SOC_DAPM_SINGLE("IN2RP Switch", WM8993_INPUT_MIXER2, 3, 1, 0),
1142SOC_DAPM_SINGLE("IN2RN Switch", WM8993_INPUT_MIXER2, 2, 1, 0),
1143};
1144
1145static const struct snd_kcontrol_new mixinl[] = {
1146SOC_DAPM_SINGLE("IN2L Switch", WM8993_INPUT_MIXER3, 8, 1, 0),
1147SOC_DAPM_SINGLE("IN1L Switch", WM8993_INPUT_MIXER3, 5, 1, 0),
1148};
1149
1150static const struct snd_kcontrol_new mixinr[] = {
1151SOC_DAPM_SINGLE("IN2R Switch", WM8993_INPUT_MIXER4, 8, 1, 0),
1152SOC_DAPM_SINGLE("IN1R Switch", WM8993_INPUT_MIXER4, 5, 1, 0),
1153};
1154
1155static const struct snd_kcontrol_new left_output_mixer[] = {
1156SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER1, 7, 1, 0),
1157SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER1, 6, 1, 0),
1158SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER1, 5, 1, 0),
1159SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER1, 4, 1, 0),
1160SOC_DAPM_SINGLE("IN2LP Switch", WM8993_OUTPUT_MIXER1, 1, 1, 0),
1161SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER1, 3, 1, 0),
1162SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER1, 2, 1, 0),
1163SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER1, 0, 1, 0),
1164};
1165
1166static const struct snd_kcontrol_new right_output_mixer[] = {
1167SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER2, 7, 1, 0),
1168SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER2, 6, 1, 0),
1169SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER2, 5, 1, 0),
1170SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER2, 4, 1, 0),
1171SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER2, 3, 1, 0),
1172SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER2, 2, 1, 0),
1173SOC_DAPM_SINGLE("IN2RP Switch", WM8993_OUTPUT_MIXER2, 1, 1, 0),
1174SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER2, 0, 1, 0),
1175};
1176
1177static const struct snd_kcontrol_new earpiece_mixer[] = {
1178SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_HPOUT2_MIXER, 5, 1, 0),
1179SOC_DAPM_SINGLE("Left Output Switch", WM8993_HPOUT2_MIXER, 4, 1, 0),
1180SOC_DAPM_SINGLE("Right Output Switch", WM8993_HPOUT2_MIXER, 3, 1, 0),
1181};
1182
1183static const struct snd_kcontrol_new left_speaker_mixer[] = {
1184SOC_DAPM_SINGLE("Input Switch", WM8993_SPEAKER_MIXER, 7, 1, 0),
1185SOC_DAPM_SINGLE("IN1LP Switch", WM8993_SPEAKER_MIXER, 5, 1, 0),
1186SOC_DAPM_SINGLE("Output Switch", WM8993_SPEAKER_MIXER, 3, 1, 0),
1187SOC_DAPM_SINGLE("DAC Switch", WM8993_SPEAKER_MIXER, 6, 1, 0),
1188};
1189
1190static const struct snd_kcontrol_new right_speaker_mixer[] = {
1191SOC_DAPM_SINGLE("Input Switch", WM8993_SPEAKER_MIXER, 6, 1, 0),
1192SOC_DAPM_SINGLE("IN1RP Switch", WM8993_SPEAKER_MIXER, 4, 1, 0),
1193SOC_DAPM_SINGLE("Output Switch", WM8993_SPEAKER_MIXER, 2, 1, 0),
1194SOC_DAPM_SINGLE("DAC Switch", WM8993_SPEAKER_MIXER, 0, 1, 0),
1195};
1196
1197static const struct snd_kcontrol_new left_speaker_boost[] = {
1198SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 5, 1, 0),
1199SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 4, 1, 0),
1200SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 3, 1, 0),
1201};
1202
1203static const struct snd_kcontrol_new right_speaker_boost[] = {
1204SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 2, 1, 0),
1205SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 1, 1, 0),
1206SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 0, 1, 0),
1207};
1208
1209static const char *hp_mux_text[] = { 818static const char *hp_mux_text[] = {
1210 "Mixer", 819 "Mixer",
1211 "DAC", 820 "DAC",
@@ -1223,71 +832,26 @@ static const struct soc_enum hpr_enum =
1223static const struct snd_kcontrol_new hpr_mux = 832static 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
1226static const struct snd_kcontrol_new line1_mix[] = { 835static const struct snd_kcontrol_new left_speaker_mixer[] = {
1227SOC_DAPM_SINGLE("IN1R Switch", WM8993_LINE_MIXER1, 2, 1, 0), 836SOC_DAPM_SINGLE("Input Switch", WM8993_SPEAKER_MIXER, 7, 1, 0),
1228SOC_DAPM_SINGLE("IN1L Switch", WM8993_LINE_MIXER1, 1, 1, 0), 837SOC_DAPM_SINGLE("IN1LP Switch", WM8993_SPEAKER_MIXER, 5, 1, 0),
1229SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER1, 0, 1, 0), 838SOC_DAPM_SINGLE("Output Switch", WM8993_SPEAKER_MIXER, 3, 1, 0),
1230}; 839SOC_DAPM_SINGLE("DAC Switch", WM8993_SPEAKER_MIXER, 6, 1, 0),
1231
1232static const struct snd_kcontrol_new line1n_mix[] = {
1233SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 6, 1, 0),
1234SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER1, 5, 1, 0),
1235};
1236
1237static const struct snd_kcontrol_new line1p_mix[] = {
1238SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 0, 1, 0),
1239};
1240
1241static const struct snd_kcontrol_new line2_mix[] = {
1242SOC_DAPM_SINGLE("IN2R Switch", WM8993_LINE_MIXER2, 2, 1, 0),
1243SOC_DAPM_SINGLE("IN2L Switch", WM8993_LINE_MIXER2, 1, 1, 0),
1244SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER2, 0, 1, 0),
1245};
1246
1247static const struct snd_kcontrol_new line2n_mix[] = {
1248SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER2, 6, 1, 0),
1249SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 5, 1, 0),
1250}; 840};
1251 841
1252static const struct snd_kcontrol_new line2p_mix[] = { 842static const struct snd_kcontrol_new right_speaker_mixer[] = {
1253SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 0, 1, 0), 843SOC_DAPM_SINGLE("Input Switch", WM8993_SPEAKER_MIXER, 6, 1, 0),
844SOC_DAPM_SINGLE("IN1RP Switch", WM8993_SPEAKER_MIXER, 4, 1, 0),
845SOC_DAPM_SINGLE("Output Switch", WM8993_SPEAKER_MIXER, 2, 1, 0),
846SOC_DAPM_SINGLE("DAC Switch", WM8993_SPEAKER_MIXER, 0, 1, 0),
1254}; 847};
1255 848
1256static const struct snd_soc_dapm_widget wm8993_dapm_widgets[] = { 849static const struct snd_soc_dapm_widget wm8993_dapm_widgets[] = {
1257SND_SOC_DAPM_INPUT("IN1LN"),
1258SND_SOC_DAPM_INPUT("IN1LP"),
1259SND_SOC_DAPM_INPUT("IN2LN"),
1260SND_SOC_DAPM_INPUT("IN2LP/VXRN"),
1261SND_SOC_DAPM_INPUT("IN1RN"),
1262SND_SOC_DAPM_INPUT("IN1RP"),
1263SND_SOC_DAPM_INPUT("IN2RN"),
1264SND_SOC_DAPM_INPUT("IN2RP/VXRP"),
1265
1266SND_SOC_DAPM_SUPPLY("CLK_SYS", WM8993_BUS_CONTROL_1, 1, 0, clk_sys_event, 850SND_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),
1268SND_SOC_DAPM_SUPPLY("TOCLK", WM8993_CLOCKING_1, 14, 0, NULL, 0), 852SND_SOC_DAPM_SUPPLY("TOCLK", WM8993_CLOCKING_1, 14, 0, NULL, 0),
1269SND_SOC_DAPM_SUPPLY("CLK_DSP", WM8993_CLOCKING_3, 0, 0, NULL, 0), 853SND_SOC_DAPM_SUPPLY("CLK_DSP", WM8993_CLOCKING_3, 0, 0, NULL, 0),
1270 854
1271SND_SOC_DAPM_MICBIAS("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0),
1272SND_SOC_DAPM_MICBIAS("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0),
1273
1274SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2, 6, 0,
1275 in1l_pga, ARRAY_SIZE(in1l_pga)),
1276SND_SOC_DAPM_MIXER("IN1R PGA", WM8993_POWER_MANAGEMENT_2, 4, 0,
1277 in1r_pga, ARRAY_SIZE(in1r_pga)),
1278
1279SND_SOC_DAPM_MIXER("IN2L PGA", WM8993_POWER_MANAGEMENT_2, 7, 0,
1280 in2l_pga, ARRAY_SIZE(in2l_pga)),
1281SND_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 */
1285SND_SOC_DAPM_PGA("Direct Voice", SND_SOC_NOPM, 0, 0, NULL, 0),
1286
1287SND_SOC_DAPM_MIXER("MIXINL", WM8993_POWER_MANAGEMENT_2, 9, 0,
1288 mixinl, ARRAY_SIZE(mixinl)),
1289SND_SOC_DAPM_MIXER("MIXINR", WM8993_POWER_MANAGEMENT_2, 8, 0,
1290 mixinr, ARRAY_SIZE(mixinr)),
1291 855
1292SND_SOC_DAPM_ADC("ADCL", "Capture", WM8993_POWER_MANAGEMENT_2, 1, 0), 856SND_SOC_DAPM_ADC("ADCL", "Capture", WM8993_POWER_MANAGEMENT_2, 1, 0),
1293SND_SOC_DAPM_ADC("ADCR", "Capture", WM8993_POWER_MANAGEMENT_2, 0, 0), 857SND_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),
1295SND_SOC_DAPM_DAC("DACL", "Playback", WM8993_POWER_MANAGEMENT_3, 1, 0), 859SND_SOC_DAPM_DAC("DACL", "Playback", WM8993_POWER_MANAGEMENT_3, 1, 0),
1296SND_SOC_DAPM_DAC("DACR", "Playback", WM8993_POWER_MANAGEMENT_3, 0, 0), 860SND_SOC_DAPM_DAC("DACR", "Playback", WM8993_POWER_MANAGEMENT_3, 0, 0),
1297 861
1298SND_SOC_DAPM_MIXER("Left Output Mixer", WM8993_POWER_MANAGEMENT_3, 5, 0, 862SND_SOC_DAPM_MUX("Left Headphone Mux", SND_SOC_NOPM, 0, 0, &hpl_mux),
1299 left_output_mixer, ARRAY_SIZE(left_output_mixer)), 863SND_SOC_DAPM_MUX("Right Headphone Mux", SND_SOC_NOPM, 0, 0, &hpr_mux),
1300SND_SOC_DAPM_MIXER("Right Output Mixer", WM8993_POWER_MANAGEMENT_3, 4, 0,
1301 right_output_mixer, ARRAY_SIZE(right_output_mixer)),
1302
1303SND_SOC_DAPM_PGA("Left Output PGA", WM8993_POWER_MANAGEMENT_3, 7, 0, NULL, 0),
1304SND_SOC_DAPM_PGA("Right Output PGA", WM8993_POWER_MANAGEMENT_3, 6, 0, NULL, 0),
1305
1306SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM, 0, 0,
1307 earpiece_mixer, ARRAY_SIZE(earpiece_mixer)),
1308SND_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
1312SND_SOC_DAPM_MIXER("SPKL", WM8993_POWER_MANAGEMENT_3, 8, 0, 865SND_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)),
1314SND_SOC_DAPM_MIXER("SPKR", WM8993_POWER_MANAGEMENT_3, 9, 0, 867SND_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
1317SND_SOC_DAPM_MIXER("SPKL Boost", SND_SOC_NOPM, 0, 0,
1318 left_speaker_boost, ARRAY_SIZE(left_speaker_boost)),
1319SND_SOC_DAPM_MIXER("SPKR Boost", SND_SOC_NOPM, 0, 0,
1320 right_speaker_boost, ARRAY_SIZE(right_speaker_boost)),
1321
1322SND_SOC_DAPM_PGA("SPKL Driver", WM8993_POWER_MANAGEMENT_1, 12, 0,
1323 NULL, 0),
1324SND_SOC_DAPM_PGA("SPKR Driver", WM8993_POWER_MANAGEMENT_1, 13, 0,
1325 NULL, 0),
1326
1327SND_SOC_DAPM_MUX("Left Headphone Mux", SND_SOC_NOPM, 0, 0, &hpl_mux),
1328SND_SOC_DAPM_MUX("Right Headphone Mux", SND_SOC_NOPM, 0, 0, &hpr_mux),
1329SND_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
1333SND_SOC_DAPM_MIXER("LINEOUT1 Mixer", SND_SOC_NOPM, 0, 0,
1334 line1_mix, ARRAY_SIZE(line1_mix)),
1335SND_SOC_DAPM_MIXER("LINEOUT2 Mixer", SND_SOC_NOPM, 0, 0,
1336 line2_mix, ARRAY_SIZE(line2_mix)),
1337
1338SND_SOC_DAPM_MIXER("LINEOUT1N Mixer", SND_SOC_NOPM, 0, 0,
1339 line1n_mix, ARRAY_SIZE(line1n_mix)),
1340SND_SOC_DAPM_MIXER("LINEOUT1P Mixer", SND_SOC_NOPM, 0, 0,
1341 line1p_mix, ARRAY_SIZE(line1p_mix)),
1342SND_SOC_DAPM_MIXER("LINEOUT2N Mixer", SND_SOC_NOPM, 0, 0,
1343 line2n_mix, ARRAY_SIZE(line2n_mix)),
1344SND_SOC_DAPM_MIXER("LINEOUT2P Mixer", SND_SOC_NOPM, 0, 0,
1345 line2p_mix, ARRAY_SIZE(line2p_mix)),
1346
1347SND_SOC_DAPM_PGA("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3, 13, 0,
1348 NULL, 0),
1349SND_SOC_DAPM_PGA("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3, 12, 0,
1350 NULL, 0),
1351SND_SOC_DAPM_PGA("LINEOUT2N Driver", WM8993_POWER_MANAGEMENT_3, 11, 0,
1352 NULL, 0),
1353SND_SOC_DAPM_PGA("LINEOUT2P Driver", WM8993_POWER_MANAGEMENT_3, 10, 0,
1354 NULL, 0),
1355
1356SND_SOC_DAPM_OUTPUT("SPKOUTLP"),
1357SND_SOC_DAPM_OUTPUT("SPKOUTLN"),
1358SND_SOC_DAPM_OUTPUT("SPKOUTRP"),
1359SND_SOC_DAPM_OUTPUT("SPKOUTRN"),
1360SND_SOC_DAPM_OUTPUT("HPOUT1L"),
1361SND_SOC_DAPM_OUTPUT("HPOUT1R"),
1362SND_SOC_DAPM_OUTPUT("HPOUT2P"),
1363SND_SOC_DAPM_OUTPUT("HPOUT2N"),
1364SND_SOC_DAPM_OUTPUT("LINEOUT1P"),
1365SND_SOC_DAPM_OUTPUT("LINEOUT1N"),
1366SND_SOC_DAPM_OUTPUT("LINEOUT2P"),
1367SND_SOC_DAPM_OUTPUT("LINEOUT2N"),
1368}; 870};
1369 871
1370static const struct snd_soc_dapm_route routes[] = { 872static 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
1496static 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
1505static 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
1515static 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
1524static 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
1534static int wm8993_set_bias_level(struct snd_soc_codec *codec, 901static 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,