aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/codecs/Kconfig4
-rw-r--r--sound/soc/codecs/Makefile2
-rw-r--r--sound/soc/codecs/wm8993.c716
-rw-r--r--sound/soc/codecs/wm_hubs.c758
-rw-r--r--sound/soc/codecs/wm_hubs.h24
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
67config SND_SOC_WM_HUBS
68 tristate
69 default y if SND_SOC_WM8993=y
70 default m if SND_SOC_WM8993=m
67 71
68config SND_SOC_AC97_CODEC 72config 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
41snd-soc-wm9705-objs := wm9705.o 41snd-soc-wm9705-objs := wm9705.o
42snd-soc-wm9712-objs := wm9712.o 42snd-soc-wm9712-objs := wm9712.o
43snd-soc-wm9713-objs := wm9713.o 43snd-soc-wm9713-objs := wm9713.o
44snd-soc-wm-hubs-objs := wm_hubs.o
44 45
45# Amp 46# Amp
46snd-soc-max9877-objs := max9877.o 47snd-soc-max9877-objs := max9877.o
@@ -88,6 +89,7 @@ obj-$(CONFIG_SND_SOC_WM9081) += snd-soc-wm9081.o
88obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o 89obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o
89obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o 90obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o
90obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o 91obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o
92obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o
91 93
92# Amp 94# Amp
93obj-$(CONFIG_SND_SOC_MAX9877) += snd-soc-max9877.o 95obj-$(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
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,
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
33const DECLARE_TLV_DB_SCALE(wm_hubs_spkmix_tlv, -300, 300, 0);
34EXPORT_SYMBOL_GPL(wm_hubs_spkmix_tlv);
35
36static const DECLARE_TLV_DB_SCALE(inpga_tlv, -1650, 150, 0);
37static const DECLARE_TLV_DB_SCALE(inmix_sw_tlv, 0, 3000, 0);
38static const DECLARE_TLV_DB_SCALE(inmix_tlv, -1500, 300, 1);
39static const DECLARE_TLV_DB_SCALE(earpiece_tlv, -600, 600, 0);
40static const DECLARE_TLV_DB_SCALE(outmix_tlv, -2100, 300, 0);
41static const DECLARE_TLV_DB_SCALE(spkmixout_tlv, -1800, 600, 1);
42static const DECLARE_TLV_DB_SCALE(outpga_tlv, -5700, 100, 0);
43static 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};
48static const DECLARE_TLV_DB_SCALE(line_tlv, -600, 600, 0);
49
50static const char *speaker_ref_text[] = {
51 "SPKVDD/2",
52 "VMID",
53};
54
55static const struct soc_enum speaker_ref =
56 SOC_ENUM_SINGLE(WM8993_SPEAKER_MIXER, 8, 2, speaker_ref_text);
57
58static const char *speaker_mode_text[] = {
59 "Class D",
60 "Class AB",
61};
62
63static const struct soc_enum speaker_mode =
64 SOC_ENUM_SINGLE(WM8993_SPKMIXR_ATTENUATION, 8, 2, speaker_mode_text);
65
66static 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 */
88static 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
109static const struct snd_kcontrol_new analogue_snd_controls[] = {
110SOC_SINGLE_TLV("IN1L Volume", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 0, 31, 0,
111 inpga_tlv),
112SOC_SINGLE("IN1L Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 1),
113SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 0),
114
115SOC_SINGLE_TLV("IN1R Volume", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 0, 31, 0,
116 inpga_tlv),
117SOC_SINGLE("IN1R Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 1),
118SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 0),
119
120
121SOC_SINGLE_TLV("IN2L Volume", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 0, 31, 0,
122 inpga_tlv),
123SOC_SINGLE("IN2L Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 1),
124SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 0),
125
126SOC_SINGLE_TLV("IN2R Volume", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 0, 31, 0,
127 inpga_tlv),
128SOC_SINGLE("IN2R Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 1),
129SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 0),
130
131SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8993_INPUT_MIXER3, 7, 1, 0,
132 inmix_sw_tlv),
133SOC_SINGLE_TLV("MIXINL IN1L Volume", WM8993_INPUT_MIXER3, 4, 1, 0,
134 inmix_sw_tlv),
135SOC_SINGLE_TLV("MIXINL Output Record Volume", WM8993_INPUT_MIXER3, 0, 7, 0,
136 inmix_tlv),
137SOC_SINGLE_TLV("MIXINL IN1LP Volume", WM8993_INPUT_MIXER5, 6, 7, 0, inmix_tlv),
138SOC_SINGLE_TLV("MIXINL Direct Voice Volume", WM8993_INPUT_MIXER5, 0, 6, 0,
139 inmix_tlv),
140
141SOC_SINGLE_TLV("MIXINR IN2R Volume", WM8993_INPUT_MIXER4, 7, 1, 0,
142 inmix_sw_tlv),
143SOC_SINGLE_TLV("MIXINR IN1R Volume", WM8993_INPUT_MIXER4, 4, 1, 0,
144 inmix_sw_tlv),
145SOC_SINGLE_TLV("MIXINR Output Record Volume", WM8993_INPUT_MIXER4, 0, 7, 0,
146 inmix_tlv),
147SOC_SINGLE_TLV("MIXINR IN1RP Volume", WM8993_INPUT_MIXER6, 6, 7, 0, inmix_tlv),
148SOC_SINGLE_TLV("MIXINR Direct Voice Volume", WM8993_INPUT_MIXER6, 0, 6, 0,
149 inmix_tlv),
150
151SOC_SINGLE_TLV("Left Output Mixer IN2RN Volume", WM8993_OUTPUT_MIXER5, 6, 7, 1,
152 outmix_tlv),
153SOC_SINGLE_TLV("Left Output Mixer IN2LN Volume", WM8993_OUTPUT_MIXER3, 6, 7, 1,
154 outmix_tlv),
155SOC_SINGLE_TLV("Left Output Mixer IN2LP Volume", WM8993_OUTPUT_MIXER3, 9, 7, 1,
156 outmix_tlv),
157SOC_SINGLE_TLV("Left Output Mixer IN1L Volume", WM8993_OUTPUT_MIXER3, 0, 7, 1,
158 outmix_tlv),
159SOC_SINGLE_TLV("Left Output Mixer IN1R Volume", WM8993_OUTPUT_MIXER3, 3, 7, 1,
160 outmix_tlv),
161SOC_SINGLE_TLV("Left Output Mixer Right Input Volume",
162 WM8993_OUTPUT_MIXER5, 3, 7, 1, outmix_tlv),
163SOC_SINGLE_TLV("Left Output Mixer Left Input Volume",
164 WM8993_OUTPUT_MIXER5, 0, 7, 1, outmix_tlv),
165SOC_SINGLE_TLV("Left Output Mixer DAC Volume", WM8993_OUTPUT_MIXER5, 9, 7, 1,
166 outmix_tlv),
167
168SOC_SINGLE_TLV("Right Output Mixer IN2LN Volume",
169 WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv),
170SOC_SINGLE_TLV("Right Output Mixer IN2RN Volume",
171 WM8993_OUTPUT_MIXER4, 6, 7, 1, outmix_tlv),
172SOC_SINGLE_TLV("Right Output Mixer IN1L Volume",
173 WM8993_OUTPUT_MIXER4, 3, 7, 1, outmix_tlv),
174SOC_SINGLE_TLV("Right Output Mixer IN1R Volume",
175 WM8993_OUTPUT_MIXER4, 0, 7, 1, outmix_tlv),
176SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume",
177 WM8993_OUTPUT_MIXER4, 9, 7, 1, outmix_tlv),
178SOC_SINGLE_TLV("Right Output Mixer Left Input Volume",
179 WM8993_OUTPUT_MIXER6, 3, 7, 1, outmix_tlv),
180SOC_SINGLE_TLV("Right Output Mixer Right Input Volume",
181 WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv),
182SOC_SINGLE_TLV("Right Output Mixer DAC Volume",
183 WM8993_OUTPUT_MIXER6, 9, 7, 1, outmix_tlv),
184
185SOC_DOUBLE_R_TLV("Output Volume", WM8993_LEFT_OPGA_VOLUME,
186 WM8993_RIGHT_OPGA_VOLUME, 0, 63, 0, outpga_tlv),
187SOC_DOUBLE_R("Output Switch", WM8993_LEFT_OPGA_VOLUME,
188 WM8993_RIGHT_OPGA_VOLUME, 6, 1, 0),
189SOC_DOUBLE_R("Output ZC Switch", WM8993_LEFT_OPGA_VOLUME,
190 WM8993_RIGHT_OPGA_VOLUME, 7, 1, 0),
191
192SOC_SINGLE("Earpiece Switch", WM8993_HPOUT2_VOLUME, 5, 1, 1),
193SOC_SINGLE_TLV("Earpiece Volume", WM8993_HPOUT2_VOLUME, 4, 1, 1, earpiece_tlv),
194
195SOC_SINGLE_TLV("SPKL Input Volume", WM8993_SPKMIXL_ATTENUATION,
196 5, 1, 1, wm_hubs_spkmix_tlv),
197SOC_SINGLE_TLV("SPKL IN1LP Volume", WM8993_SPKMIXL_ATTENUATION,
198 4, 1, 1, wm_hubs_spkmix_tlv),
199SOC_SINGLE_TLV("SPKL Output Volume", WM8993_SPKMIXL_ATTENUATION,
200 3, 1, 1, wm_hubs_spkmix_tlv),
201
202SOC_SINGLE_TLV("SPKR Input Volume", WM8993_SPKMIXR_ATTENUATION,
203 5, 1, 1, wm_hubs_spkmix_tlv),
204SOC_SINGLE_TLV("SPKR IN1RP Volume", WM8993_SPKMIXR_ATTENUATION,
205 4, 1, 1, wm_hubs_spkmix_tlv),
206SOC_SINGLE_TLV("SPKR Output Volume", WM8993_SPKMIXR_ATTENUATION,
207 3, 1, 1, wm_hubs_spkmix_tlv),
208
209SOC_DOUBLE_R_TLV("Speaker Mixer Volume",
210 WM8993_SPKMIXL_ATTENUATION, WM8993_SPKMIXR_ATTENUATION,
211 0, 3, 1, spkmixout_tlv),
212SOC_DOUBLE_R_TLV("Speaker Volume",
213 WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT,
214 0, 63, 0, outpga_tlv),
215SOC_DOUBLE_R("Speaker Switch",
216 WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT,
217 6, 1, 0),
218SOC_DOUBLE_R("Speaker ZC Switch",
219 WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT,
220 7, 1, 0),
221SOC_DOUBLE_TLV("Speaker Boost Volume", WM8993_SPKOUT_BOOST, 0, 3, 7, 0,
222 spkboost_tlv),
223SOC_ENUM("Speaker Reference", speaker_ref),
224SOC_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},
239SOC_DOUBLE_R("Headphone Switch", WM8993_LEFT_OUTPUT_VOLUME,
240 WM8993_RIGHT_OUTPUT_VOLUME, 6, 1, 0),
241SOC_DOUBLE_R("Headphone ZC Switch", WM8993_LEFT_OUTPUT_VOLUME,
242 WM8993_RIGHT_OUTPUT_VOLUME, 7, 1, 0),
243
244SOC_SINGLE("LINEOUT1N Switch", WM8993_LINE_OUTPUTS_VOLUME, 6, 1, 1),
245SOC_SINGLE("LINEOUT1P Switch", WM8993_LINE_OUTPUTS_VOLUME, 5, 1, 1),
246SOC_SINGLE_TLV("LINEOUT1 Volume", WM8993_LINE_OUTPUTS_VOLUME, 4, 1, 1,
247 line_tlv),
248
249SOC_SINGLE("LINEOUT2N Switch", WM8993_LINE_OUTPUTS_VOLUME, 2, 1, 1),
250SOC_SINGLE("LINEOUT2P Switch", WM8993_LINE_OUTPUTS_VOLUME, 1, 1, 1),
251SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1,
252 line_tlv),
253};
254
255static 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
321static 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
346static const struct snd_kcontrol_new in1l_pga[] = {
347SOC_DAPM_SINGLE("IN1LP Switch", WM8993_INPUT_MIXER2, 5, 1, 0),
348SOC_DAPM_SINGLE("IN1LN Switch", WM8993_INPUT_MIXER2, 4, 1, 0),
349};
350
351static const struct snd_kcontrol_new in1r_pga[] = {
352SOC_DAPM_SINGLE("IN1RP Switch", WM8993_INPUT_MIXER2, 1, 1, 0),
353SOC_DAPM_SINGLE("IN1RN Switch", WM8993_INPUT_MIXER2, 0, 1, 0),
354};
355
356static const struct snd_kcontrol_new in2l_pga[] = {
357SOC_DAPM_SINGLE("IN2LP Switch", WM8993_INPUT_MIXER2, 7, 1, 0),
358SOC_DAPM_SINGLE("IN2LN Switch", WM8993_INPUT_MIXER2, 6, 1, 0),
359};
360
361static const struct snd_kcontrol_new in2r_pga[] = {
362SOC_DAPM_SINGLE("IN2RP Switch", WM8993_INPUT_MIXER2, 3, 1, 0),
363SOC_DAPM_SINGLE("IN2RN Switch", WM8993_INPUT_MIXER2, 2, 1, 0),
364};
365
366static const struct snd_kcontrol_new mixinl[] = {
367SOC_DAPM_SINGLE("IN2L Switch", WM8993_INPUT_MIXER3, 8, 1, 0),
368SOC_DAPM_SINGLE("IN1L Switch", WM8993_INPUT_MIXER3, 5, 1, 0),
369};
370
371static const struct snd_kcontrol_new mixinr[] = {
372SOC_DAPM_SINGLE("IN2R Switch", WM8993_INPUT_MIXER4, 8, 1, 0),
373SOC_DAPM_SINGLE("IN1R Switch", WM8993_INPUT_MIXER4, 5, 1, 0),
374};
375
376static const struct snd_kcontrol_new left_output_mixer[] = {
377SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER1, 7, 1, 0),
378SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER1, 6, 1, 0),
379SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER1, 5, 1, 0),
380SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER1, 4, 1, 0),
381SOC_DAPM_SINGLE("IN2LP Switch", WM8993_OUTPUT_MIXER1, 1, 1, 0),
382SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER1, 3, 1, 0),
383SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER1, 2, 1, 0),
384SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER1, 0, 1, 0),
385};
386
387static const struct snd_kcontrol_new right_output_mixer[] = {
388SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER2, 7, 1, 0),
389SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER2, 6, 1, 0),
390SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER2, 5, 1, 0),
391SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER2, 4, 1, 0),
392SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER2, 3, 1, 0),
393SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER2, 2, 1, 0),
394SOC_DAPM_SINGLE("IN2RP Switch", WM8993_OUTPUT_MIXER2, 1, 1, 0),
395SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER2, 0, 1, 0),
396};
397
398static const struct snd_kcontrol_new earpiece_mixer[] = {
399SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_HPOUT2_MIXER, 5, 1, 0),
400SOC_DAPM_SINGLE("Left Output Switch", WM8993_HPOUT2_MIXER, 4, 1, 0),
401SOC_DAPM_SINGLE("Right Output Switch", WM8993_HPOUT2_MIXER, 3, 1, 0),
402};
403
404static const struct snd_kcontrol_new left_speaker_boost[] = {
405SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 5, 1, 0),
406SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 4, 1, 0),
407SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 3, 1, 0),
408};
409
410static const struct snd_kcontrol_new right_speaker_boost[] = {
411SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 2, 1, 0),
412SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 1, 1, 0),
413SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 0, 1, 0),
414};
415
416static const struct snd_kcontrol_new line1_mix[] = {
417SOC_DAPM_SINGLE("IN1R Switch", WM8993_LINE_MIXER1, 2, 1, 0),
418SOC_DAPM_SINGLE("IN1L Switch", WM8993_LINE_MIXER1, 1, 1, 0),
419SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER1, 0, 1, 0),
420};
421
422static const struct snd_kcontrol_new line1n_mix[] = {
423SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 6, 1, 0),
424SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER1, 5, 1, 0),
425};
426
427static const struct snd_kcontrol_new line1p_mix[] = {
428SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 0, 1, 0),
429};
430
431static const struct snd_kcontrol_new line2_mix[] = {
432SOC_DAPM_SINGLE("IN2R Switch", WM8993_LINE_MIXER2, 2, 1, 0),
433SOC_DAPM_SINGLE("IN2L Switch", WM8993_LINE_MIXER2, 1, 1, 0),
434SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER2, 0, 1, 0),
435};
436
437static const struct snd_kcontrol_new line2n_mix[] = {
438SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER2, 6, 1, 0),
439SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 5, 1, 0),
440};
441
442static const struct snd_kcontrol_new line2p_mix[] = {
443SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 0, 1, 0),
444};
445
446static const struct snd_soc_dapm_widget analogue_dapm_widgets[] = {
447SND_SOC_DAPM_INPUT("IN1LN"),
448SND_SOC_DAPM_INPUT("IN1LP"),
449SND_SOC_DAPM_INPUT("IN2LN"),
450SND_SOC_DAPM_INPUT("IN2LP/VXRN"),
451SND_SOC_DAPM_INPUT("IN1RN"),
452SND_SOC_DAPM_INPUT("IN1RP"),
453SND_SOC_DAPM_INPUT("IN2RN"),
454SND_SOC_DAPM_INPUT("IN2RP/VXRP"),
455
456SND_SOC_DAPM_MICBIAS("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0),
457SND_SOC_DAPM_MICBIAS("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0),
458
459SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2, 6, 0,
460 in1l_pga, ARRAY_SIZE(in1l_pga)),
461SND_SOC_DAPM_MIXER("IN1R PGA", WM8993_POWER_MANAGEMENT_2, 4, 0,
462 in1r_pga, ARRAY_SIZE(in1r_pga)),
463
464SND_SOC_DAPM_MIXER("IN2L PGA", WM8993_POWER_MANAGEMENT_2, 7, 0,
465 in2l_pga, ARRAY_SIZE(in2l_pga)),
466SND_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 */
470SND_SOC_DAPM_PGA("Direct Voice", SND_SOC_NOPM, 0, 0, NULL, 0),
471
472SND_SOC_DAPM_MIXER("MIXINL", WM8993_POWER_MANAGEMENT_2, 9, 0,
473 mixinl, ARRAY_SIZE(mixinl)),
474SND_SOC_DAPM_MIXER("MIXINR", WM8993_POWER_MANAGEMENT_2, 8, 0,
475 mixinr, ARRAY_SIZE(mixinr)),
476
477SND_SOC_DAPM_ADC("ADCL", "Capture", WM8993_POWER_MANAGEMENT_2, 1, 0),
478SND_SOC_DAPM_ADC("ADCR", "Capture", WM8993_POWER_MANAGEMENT_2, 0, 0),
479
480SND_SOC_DAPM_DAC("DACL", "Playback", WM8993_POWER_MANAGEMENT_3, 1, 0),
481SND_SOC_DAPM_DAC("DACR", "Playback", WM8993_POWER_MANAGEMENT_3, 0, 0),
482
483SND_SOC_DAPM_MIXER("Left Output Mixer", WM8993_POWER_MANAGEMENT_3, 5, 0,
484 left_output_mixer, ARRAY_SIZE(left_output_mixer)),
485SND_SOC_DAPM_MIXER("Right Output Mixer", WM8993_POWER_MANAGEMENT_3, 4, 0,
486 right_output_mixer, ARRAY_SIZE(right_output_mixer)),
487
488SND_SOC_DAPM_PGA("Left Output PGA", WM8993_POWER_MANAGEMENT_3, 7, 0, NULL, 0),
489SND_SOC_DAPM_PGA("Right Output PGA", WM8993_POWER_MANAGEMENT_3, 6, 0, NULL, 0),
490
491SND_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
495SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM, 0, 0,
496 earpiece_mixer, ARRAY_SIZE(earpiece_mixer)),
497SND_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
501SND_SOC_DAPM_MIXER("SPKL Boost", SND_SOC_NOPM, 0, 0,
502 left_speaker_boost, ARRAY_SIZE(left_speaker_boost)),
503SND_SOC_DAPM_MIXER("SPKR Boost", SND_SOC_NOPM, 0, 0,
504 right_speaker_boost, ARRAY_SIZE(right_speaker_boost)),
505
506SND_SOC_DAPM_PGA("SPKL Driver", WM8993_POWER_MANAGEMENT_1, 12, 0,
507 NULL, 0),
508SND_SOC_DAPM_PGA("SPKR Driver", WM8993_POWER_MANAGEMENT_1, 13, 0,
509 NULL, 0),
510
511SND_SOC_DAPM_MIXER("LINEOUT1 Mixer", SND_SOC_NOPM, 0, 0,
512 line1_mix, ARRAY_SIZE(line1_mix)),
513SND_SOC_DAPM_MIXER("LINEOUT2 Mixer", SND_SOC_NOPM, 0, 0,
514 line2_mix, ARRAY_SIZE(line2_mix)),
515
516SND_SOC_DAPM_MIXER("LINEOUT1N Mixer", SND_SOC_NOPM, 0, 0,
517 line1n_mix, ARRAY_SIZE(line1n_mix)),
518SND_SOC_DAPM_MIXER("LINEOUT1P Mixer", SND_SOC_NOPM, 0, 0,
519 line1p_mix, ARRAY_SIZE(line1p_mix)),
520SND_SOC_DAPM_MIXER("LINEOUT2N Mixer", SND_SOC_NOPM, 0, 0,
521 line2n_mix, ARRAY_SIZE(line2n_mix)),
522SND_SOC_DAPM_MIXER("LINEOUT2P Mixer", SND_SOC_NOPM, 0, 0,
523 line2p_mix, ARRAY_SIZE(line2p_mix)),
524
525SND_SOC_DAPM_PGA("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3, 13, 0,
526 NULL, 0),
527SND_SOC_DAPM_PGA("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3, 12, 0,
528 NULL, 0),
529SND_SOC_DAPM_PGA("LINEOUT2N Driver", WM8993_POWER_MANAGEMENT_3, 11, 0,
530 NULL, 0),
531SND_SOC_DAPM_PGA("LINEOUT2P Driver", WM8993_POWER_MANAGEMENT_3, 10, 0,
532 NULL, 0),
533
534SND_SOC_DAPM_OUTPUT("SPKOUTLP"),
535SND_SOC_DAPM_OUTPUT("SPKOUTLN"),
536SND_SOC_DAPM_OUTPUT("SPKOUTRP"),
537SND_SOC_DAPM_OUTPUT("SPKOUTRN"),
538SND_SOC_DAPM_OUTPUT("HPOUT1L"),
539SND_SOC_DAPM_OUTPUT("HPOUT1R"),
540SND_SOC_DAPM_OUTPUT("HPOUT2P"),
541SND_SOC_DAPM_OUTPUT("HPOUT2N"),
542SND_SOC_DAPM_OUTPUT("LINEOUT1P"),
543SND_SOC_DAPM_OUTPUT("LINEOUT1N"),
544SND_SOC_DAPM_OUTPUT("LINEOUT2P"),
545SND_SOC_DAPM_OUTPUT("LINEOUT2N"),
546};
547
548static 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
654static 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
663static 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
673static 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
682static 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
692int 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}
726EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls);
727
728int 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}
754EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes);
755
756MODULE_DESCRIPTION("Shared support for Wolfson hubs products");
757MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
758MODULE_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
17struct snd_soc_codec;
18
19extern const unsigned int wm_hubs_spkmix_tlv[];
20
21extern int wm_hubs_add_analogue_controls(struct snd_soc_codec *);
22extern int wm_hubs_add_analogue_routes(struct snd_soc_codec *, int, int);
23
24#endif