aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-05 07:31:32 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-05 09:10:41 -0400
commitbfd37bb5f681961e255fd2f346c20fdae2ef3f27 (patch)
treeb0fdaf21daa146ad50da046a51d21b9811c79b1e /sound/soc
parentc8fdc1b56611faa7b38eab6b99da5e20113661ff (diff)
ASoC: wm8994: Apply volume updates with clocks enabled
Volume updates may not be acted upon if there is no clock applied when the volume update is written. Ensure this doesn't happen by writing out registers with volume updates after we enable each of the clocks. There are more registers updated than before as previously we were relying on wm_hubs to set those for controls it manages. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: stable@vger.kernel.org
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/wm8994.c93
1 files changed, 58 insertions, 35 deletions
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 6d3a8654654a..aa8c98b628da 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -46,6 +46,39 @@
46#define WM8994_NUM_DRC 3 46#define WM8994_NUM_DRC 3
47#define WM8994_NUM_EQ 3 47#define WM8994_NUM_EQ 3
48 48
49static struct {
50 unsigned int reg;
51 unsigned int mask;
52} wm8994_vu_bits[] = {
53 { WM8994_LEFT_LINE_INPUT_1_2_VOLUME, WM8994_IN1_VU },
54 { WM8994_RIGHT_LINE_INPUT_1_2_VOLUME, WM8994_IN1_VU },
55 { WM8994_LEFT_LINE_INPUT_3_4_VOLUME, WM8994_IN2_VU },
56 { WM8994_RIGHT_LINE_INPUT_3_4_VOLUME, WM8994_IN2_VU },
57 { WM8994_SPEAKER_VOLUME_LEFT, WM8994_SPKOUT_VU },
58 { WM8994_SPEAKER_VOLUME_RIGHT, WM8994_SPKOUT_VU },
59 { WM8994_LEFT_OUTPUT_VOLUME, WM8994_HPOUT1_VU },
60 { WM8994_RIGHT_OUTPUT_VOLUME, WM8994_HPOUT1_VU },
61 { WM8994_LEFT_OPGA_VOLUME, WM8994_MIXOUT_VU },
62 { WM8994_RIGHT_OPGA_VOLUME, WM8994_MIXOUT_VU },
63
64 { WM8994_AIF1_DAC1_LEFT_VOLUME, WM8994_AIF1DAC1_VU },
65 { WM8994_AIF1_DAC1_RIGHT_VOLUME, WM8994_AIF1DAC1_VU },
66 { WM8994_AIF1_DAC2_LEFT_VOLUME, WM8994_AIF1DAC2_VU },
67 { WM8994_AIF1_DAC2_RIGHT_VOLUME, WM8994_AIF1DAC2_VU },
68 { WM8994_AIF2_DAC_LEFT_VOLUME, WM8994_AIF2DAC_VU },
69 { WM8994_AIF2_DAC_RIGHT_VOLUME, WM8994_AIF2DAC_VU },
70 { WM8994_AIF1_ADC1_LEFT_VOLUME, WM8994_AIF1ADC1_VU },
71 { WM8994_AIF1_ADC1_RIGHT_VOLUME, WM8994_AIF1ADC1_VU },
72 { WM8994_AIF1_ADC2_LEFT_VOLUME, WM8994_AIF1ADC2_VU },
73 { WM8994_AIF1_ADC2_RIGHT_VOLUME, WM8994_AIF1ADC2_VU },
74 { WM8994_AIF2_ADC_LEFT_VOLUME, WM8994_AIF2ADC_VU },
75 { WM8994_AIF2_ADC_RIGHT_VOLUME, WM8994_AIF1ADC2_VU },
76 { WM8994_DAC1_LEFT_VOLUME, WM8994_DAC1_VU },
77 { WM8994_DAC1_RIGHT_VOLUME, WM8994_DAC1_VU },
78 { WM8994_DAC2_LEFT_VOLUME, WM8994_DAC2_VU },
79 { WM8994_DAC2_RIGHT_VOLUME, WM8994_DAC2_VU },
80};
81
49static int wm8994_drc_base[] = { 82static int wm8994_drc_base[] = {
50 WM8994_AIF1_DRC1_1, 83 WM8994_AIF1_DRC1_1,
51 WM8994_AIF1_DRC2_1, 84 WM8994_AIF1_DRC2_1,
@@ -989,6 +1022,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
989 struct snd_soc_codec *codec = w->codec; 1022 struct snd_soc_codec *codec = w->codec;
990 struct wm8994 *control = codec->control_data; 1023 struct wm8994 *control = codec->control_data;
991 int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA; 1024 int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA;
1025 int i;
992 int dac; 1026 int dac;
993 int adc; 1027 int adc;
994 int val; 1028 int val;
@@ -1047,6 +1081,13 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
1047 WM8994_AIF1DAC2L_ENA); 1081 WM8994_AIF1DAC2L_ENA);
1048 break; 1082 break;
1049 1083
1084 case SND_SOC_DAPM_POST_PMU:
1085 for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++)
1086 snd_soc_write(codec, wm8994_vu_bits[i].reg,
1087 snd_soc_read(codec,
1088 wm8994_vu_bits[i].reg));
1089 break;
1090
1050 case SND_SOC_DAPM_PRE_PMD: 1091 case SND_SOC_DAPM_PRE_PMD:
1051 case SND_SOC_DAPM_POST_PMD: 1092 case SND_SOC_DAPM_POST_PMD:
1052 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, 1093 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
@@ -1072,6 +1113,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
1072 struct snd_kcontrol *kcontrol, int event) 1113 struct snd_kcontrol *kcontrol, int event)
1073{ 1114{
1074 struct snd_soc_codec *codec = w->codec; 1115 struct snd_soc_codec *codec = w->codec;
1116 int i;
1075 int dac; 1117 int dac;
1076 int adc; 1118 int adc;
1077 int val; 1119 int val;
@@ -1122,6 +1164,13 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
1122 WM8994_AIF2DACR_ENA); 1164 WM8994_AIF2DACR_ENA);
1123 break; 1165 break;
1124 1166
1167 case SND_SOC_DAPM_POST_PMU:
1168 for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++)
1169 snd_soc_write(codec, wm8994_vu_bits[i].reg,
1170 snd_soc_read(codec,
1171 wm8994_vu_bits[i].reg));
1172 break;
1173
1125 case SND_SOC_DAPM_PRE_PMD: 1174 case SND_SOC_DAPM_PRE_PMD:
1126 case SND_SOC_DAPM_POST_PMD: 1175 case SND_SOC_DAPM_POST_PMD:
1127 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, 1176 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5,
@@ -1531,9 +1580,11 @@ SND_SOC_DAPM_POST("Late Disable PGA", late_disable_ev)
1531 1580
1532static const struct snd_soc_dapm_widget wm8994_lateclk_widgets[] = { 1581static const struct snd_soc_dapm_widget wm8994_lateclk_widgets[] = {
1533SND_SOC_DAPM_SUPPLY("AIF1CLK", WM8994_AIF1_CLOCKING_1, 0, 0, aif1clk_ev, 1582SND_SOC_DAPM_SUPPLY("AIF1CLK", WM8994_AIF1_CLOCKING_1, 0, 0, aif1clk_ev,
1534 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD), 1583 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
1584 SND_SOC_DAPM_PRE_PMD),
1535SND_SOC_DAPM_SUPPLY("AIF2CLK", WM8994_AIF2_CLOCKING_1, 0, 0, aif2clk_ev, 1585SND_SOC_DAPM_SUPPLY("AIF2CLK", WM8994_AIF2_CLOCKING_1, 0, 0, aif2clk_ev,
1536 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD), 1586 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
1587 SND_SOC_DAPM_PRE_PMD),
1537SND_SOC_DAPM_PGA("Direct Voice", SND_SOC_NOPM, 0, 0, NULL, 0), 1588SND_SOC_DAPM_PGA("Direct Voice", SND_SOC_NOPM, 0, 0, NULL, 0),
1538SND_SOC_DAPM_MIXER("SPKL", WM8994_POWER_MANAGEMENT_3, 8, 0, 1589SND_SOC_DAPM_MIXER("SPKL", WM8994_POWER_MANAGEMENT_3, 8, 0,
1539 left_speaker_mixer, ARRAY_SIZE(left_speaker_mixer)), 1590 left_speaker_mixer, ARRAY_SIZE(left_speaker_mixer)),
@@ -3883,39 +3934,11 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3883 3934
3884 pm_runtime_put(codec->dev); 3935 pm_runtime_put(codec->dev);
3885 3936
3886 /* Latch volume updates (right only; we always do left then right). */ 3937 /* Latch volume update bits */
3887 snd_soc_update_bits(codec, WM8994_AIF1_DAC1_LEFT_VOLUME, 3938 for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++)
3888 WM8994_AIF1DAC1_VU, WM8994_AIF1DAC1_VU); 3939 snd_soc_update_bits(codec, wm8994_vu_bits[i].reg,
3889 snd_soc_update_bits(codec, WM8994_AIF1_DAC1_RIGHT_VOLUME, 3940 wm8994_vu_bits[i].mask,
3890 WM8994_AIF1DAC1_VU, WM8994_AIF1DAC1_VU); 3941 wm8994_vu_bits[i].mask);
3891 snd_soc_update_bits(codec, WM8994_AIF1_DAC2_LEFT_VOLUME,
3892 WM8994_AIF1DAC2_VU, WM8994_AIF1DAC2_VU);
3893 snd_soc_update_bits(codec, WM8994_AIF1_DAC2_RIGHT_VOLUME,
3894 WM8994_AIF1DAC2_VU, WM8994_AIF1DAC2_VU);
3895 snd_soc_update_bits(codec, WM8994_AIF2_DAC_LEFT_VOLUME,
3896 WM8994_AIF2DAC_VU, WM8994_AIF2DAC_VU);
3897 snd_soc_update_bits(codec, WM8994_AIF2_DAC_RIGHT_VOLUME,
3898 WM8994_AIF2DAC_VU, WM8994_AIF2DAC_VU);
3899 snd_soc_update_bits(codec, WM8994_AIF1_ADC1_LEFT_VOLUME,
3900 WM8994_AIF1ADC1_VU, WM8994_AIF1ADC1_VU);
3901 snd_soc_update_bits(codec, WM8994_AIF1_ADC1_RIGHT_VOLUME,
3902 WM8994_AIF1ADC1_VU, WM8994_AIF1ADC1_VU);
3903 snd_soc_update_bits(codec, WM8994_AIF1_ADC2_LEFT_VOLUME,
3904 WM8994_AIF1ADC2_VU, WM8994_AIF1ADC2_VU);
3905 snd_soc_update_bits(codec, WM8994_AIF1_ADC2_RIGHT_VOLUME,
3906 WM8994_AIF1ADC2_VU, WM8994_AIF1ADC2_VU);
3907 snd_soc_update_bits(codec, WM8994_AIF2_ADC_LEFT_VOLUME,
3908 WM8994_AIF2ADC_VU, WM8994_AIF1ADC2_VU);
3909 snd_soc_update_bits(codec, WM8994_AIF2_ADC_RIGHT_VOLUME,
3910 WM8994_AIF2ADC_VU, WM8994_AIF1ADC2_VU);
3911 snd_soc_update_bits(codec, WM8994_DAC1_LEFT_VOLUME,
3912 WM8994_DAC1_VU, WM8994_DAC1_VU);
3913 snd_soc_update_bits(codec, WM8994_DAC1_RIGHT_VOLUME,
3914 WM8994_DAC1_VU, WM8994_DAC1_VU);
3915 snd_soc_update_bits(codec, WM8994_DAC2_LEFT_VOLUME,
3916 WM8994_DAC2_VU, WM8994_DAC2_VU);
3917 snd_soc_update_bits(codec, WM8994_DAC2_RIGHT_VOLUME,
3918 WM8994_DAC2_VU, WM8994_DAC2_VU);
3919 3942
3920 /* Set the low bit of the 3D stereo depth so TLV matches */ 3943 /* Set the low bit of the 3D stereo depth so TLV matches */
3921 snd_soc_update_bits(codec, WM8994_AIF1_DAC1_FILTERS_2, 3944 snd_soc_update_bits(codec, WM8994_AIF1_DAC1_FILTERS_2,