aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-05-10 03:24:50 -0400
committerTakashi Iwai <tiwai@suse.de>2011-05-10 03:24:50 -0400
commit1209842af4db98ffd7364ec9cf7d1a59293aa74c (patch)
tree33202a5468dc66456b67764eb6a272bd7e8c5af5 /sound/soc/codecs
parentf0a2b0cb71e652ae9f0feeea91e5320e4faf25dc (diff)
parentf3eee00da39cba3c8a4db7048458969c620ac6d8 (diff)
Merge branch 'for-2.6.40' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6 into topic/asoc
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r--sound/soc/codecs/88pm860x-codec.c2
-rw-r--r--sound/soc/codecs/ssm2602.c302
-rw-r--r--sound/soc/codecs/ssm2602.h6
-rw-r--r--sound/soc/codecs/uda134x.c2
-rw-r--r--sound/soc/codecs/wm8915.c46
5 files changed, 203 insertions, 155 deletions
diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c
index 06b6981b8d6d..19241576b6b5 100644
--- a/sound/soc/codecs/88pm860x-codec.c
+++ b/sound/soc/codecs/88pm860x-codec.c
@@ -120,7 +120,7 @@
120 */ 120 */
121#define PM860X_DAPM_OUTPUT(wname, wevent) \ 121#define PM860X_DAPM_OUTPUT(wname, wevent) \
122{ .id = snd_soc_dapm_pga, .name = wname, .reg = SND_SOC_NOPM, \ 122{ .id = snd_soc_dapm_pga, .name = wname, .reg = SND_SOC_NOPM, \
123 .shift = 0, .invert = 0, .kcontrols = NULL, \ 123 .shift = 0, .invert = 0, .kcontrol_news = NULL, \
124 .num_kcontrols = 0, .event = wevent, \ 124 .num_kcontrols = 0, .event = wevent, \
125 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD, } 125 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD, }
126 126
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c
index 7e2194975360..70099c9d63c7 100644
--- a/sound/soc/codecs/ssm2602.c
+++ b/sound/soc/codecs/ssm2602.c
@@ -40,17 +40,25 @@
40#include <sound/pcm_params.h> 40#include <sound/pcm_params.h>
41#include <sound/soc.h> 41#include <sound/soc.h>
42#include <sound/initval.h> 42#include <sound/initval.h>
43#include <sound/tlv.h>
43 44
44#include "ssm2602.h" 45#include "ssm2602.h"
45 46
46#define SSM2602_VERSION "0.1" 47#define SSM2602_VERSION "0.1"
47 48
49enum ssm2602_type {
50 SSM2602,
51 SSM2604,
52};
53
48/* codec private data */ 54/* codec private data */
49struct ssm2602_priv { 55struct ssm2602_priv {
50 unsigned int sysclk; 56 unsigned int sysclk;
51 enum snd_soc_control_type control_type; 57 enum snd_soc_control_type control_type;
52 struct snd_pcm_substream *master_substream; 58 struct snd_pcm_substream *master_substream;
53 struct snd_pcm_substream *slave_substream; 59 struct snd_pcm_substream *slave_substream;
60
61 enum ssm2602_type type;
54}; 62};
55 63
56/* 64/*
@@ -60,8 +68,8 @@ struct ssm2602_priv {
60 * There is no point in caching the reset register 68 * There is no point in caching the reset register
61 */ 69 */
62static const u16 ssm2602_reg[SSM2602_CACHEREGNUM] = { 70static const u16 ssm2602_reg[SSM2602_CACHEREGNUM] = {
63 0x0017, 0x0017, 0x0079, 0x0079, 71 0x0097, 0x0097, 0x0079, 0x0079,
64 0x0000, 0x0000, 0x0000, 0x000a, 72 0x000a, 0x0008, 0x009f, 0x000a,
65 0x0000, 0x0000 73 0x0000, 0x0000
66}; 74};
67 75
@@ -80,172 +88,186 @@ static const struct soc_enum ssm2602_enum[] = {
80 SOC_ENUM_SINGLE(SSM2602_APDIGI, 1, 4, ssm2602_deemph), 88 SOC_ENUM_SINGLE(SSM2602_APDIGI, 1, 4, ssm2602_deemph),
81}; 89};
82 90
83static const struct snd_kcontrol_new ssm2602_snd_controls[] = { 91static const unsigned int ssm260x_outmix_tlv[] = {
92 TLV_DB_RANGE_HEAD(2),
93 0, 47, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
94 48, 127, TLV_DB_SCALE_ITEM(-7400, 100, 0),
95};
84 96
85SOC_DOUBLE_R("Master Playback Volume", SSM2602_LOUT1V, SSM2602_ROUT1V, 97static const DECLARE_TLV_DB_SCALE(ssm260x_inpga_tlv, -3450, 150, 0);
86 0, 127, 0), 98static const DECLARE_TLV_DB_SCALE(ssm260x_sidetone_tlv, -1500, 300, 0);
87SOC_DOUBLE_R("Master Playback ZC Switch", SSM2602_LOUT1V, SSM2602_ROUT1V,
88 7, 1, 0),
89 99
90SOC_DOUBLE_R("Capture Volume", SSM2602_LINVOL, SSM2602_RINVOL, 0, 31, 0), 100static const struct snd_kcontrol_new ssm260x_snd_controls[] = {
101SOC_DOUBLE_R_TLV("Capture Volume", SSM2602_LINVOL, SSM2602_RINVOL, 0, 45, 0,
102 ssm260x_inpga_tlv),
91SOC_DOUBLE_R("Capture Switch", SSM2602_LINVOL, SSM2602_RINVOL, 7, 1, 1), 103SOC_DOUBLE_R("Capture Switch", SSM2602_LINVOL, SSM2602_RINVOL, 7, 1, 1),
92 104
93SOC_SINGLE("Mic Boost (+20dB)", SSM2602_APANA, 0, 1, 0),
94SOC_SINGLE("Mic Boost2 (+20dB)", SSM2602_APANA, 7, 1, 0),
95SOC_SINGLE("Mic Switch", SSM2602_APANA, 1, 1, 1),
96
97SOC_SINGLE("Sidetone Playback Volume", SSM2602_APANA, 6, 3, 1),
98
99SOC_SINGLE("ADC High Pass Filter Switch", SSM2602_APDIGI, 0, 1, 1), 105SOC_SINGLE("ADC High Pass Filter Switch", SSM2602_APDIGI, 0, 1, 1),
100SOC_SINGLE("Store DC Offset Switch", SSM2602_APDIGI, 4, 1, 0), 106SOC_SINGLE("Store DC Offset Switch", SSM2602_APDIGI, 4, 1, 0),
101 107
102SOC_ENUM("Capture Source", ssm2602_enum[0]),
103
104SOC_ENUM("Playback De-emphasis", ssm2602_enum[1]), 108SOC_ENUM("Playback De-emphasis", ssm2602_enum[1]),
105}; 109};
106 110
111static const struct snd_kcontrol_new ssm2602_snd_controls[] = {
112SOC_DOUBLE_R_TLV("Master Playback Volume", SSM2602_LOUT1V, SSM2602_ROUT1V,
113 0, 127, 0, ssm260x_outmix_tlv),
114SOC_DOUBLE_R("Master Playback ZC Switch", SSM2602_LOUT1V, SSM2602_ROUT1V,
115 7, 1, 0),
116SOC_SINGLE_TLV("Sidetone Playback Volume", SSM2602_APANA, 6, 3, 1,
117 ssm260x_sidetone_tlv),
118
119SOC_SINGLE("Mic Boost (+20dB)", SSM2602_APANA, 0, 1, 0),
120SOC_SINGLE("Mic Boost2 (+20dB)", SSM2602_APANA, 8, 1, 0),
121SOC_SINGLE("Mic Switch", SSM2602_APANA, 1, 1, 1),
122};
123
107/* Output Mixer */ 124/* Output Mixer */
108static const struct snd_kcontrol_new ssm2602_output_mixer_controls[] = { 125static const struct snd_kcontrol_new ssm260x_output_mixer_controls[] = {
109SOC_DAPM_SINGLE("Line Bypass Switch", SSM2602_APANA, 3, 1, 0), 126SOC_DAPM_SINGLE("Line Bypass Switch", SSM2602_APANA, 3, 1, 0),
110SOC_DAPM_SINGLE("Mic Sidetone Switch", SSM2602_APANA, 5, 1, 0),
111SOC_DAPM_SINGLE("HiFi Playback Switch", SSM2602_APANA, 4, 1, 0), 127SOC_DAPM_SINGLE("HiFi Playback Switch", SSM2602_APANA, 4, 1, 0),
128SOC_DAPM_SINGLE("Mic Sidetone Switch", SSM2602_APANA, 5, 1, 0),
112}; 129};
113 130
114/* Input mux */ 131/* Input mux */
115static const struct snd_kcontrol_new ssm2602_input_mux_controls = 132static const struct snd_kcontrol_new ssm2602_input_mux_controls =
116SOC_DAPM_ENUM("Input Select", ssm2602_enum[0]); 133SOC_DAPM_ENUM("Input Select", ssm2602_enum[0]);
117 134
118static const struct snd_soc_dapm_widget ssm2602_dapm_widgets[] = { 135static const struct snd_soc_dapm_widget ssm260x_dapm_widgets[] = {
119SND_SOC_DAPM_MIXER("Output Mixer", SSM2602_PWR, 4, 1,
120 &ssm2602_output_mixer_controls[0],
121 ARRAY_SIZE(ssm2602_output_mixer_controls)),
122SND_SOC_DAPM_DAC("DAC", "HiFi Playback", SSM2602_PWR, 3, 1), 136SND_SOC_DAPM_DAC("DAC", "HiFi Playback", SSM2602_PWR, 3, 1),
137SND_SOC_DAPM_ADC("ADC", "HiFi Capture", SSM2602_PWR, 2, 1),
138SND_SOC_DAPM_PGA("Line Input", SSM2602_PWR, 0, 1, NULL, 0),
139
140SND_SOC_DAPM_SUPPLY("Digital Core Power", SSM2602_ACTIVE, 0, 0, 0, 0),
141
123SND_SOC_DAPM_OUTPUT("LOUT"), 142SND_SOC_DAPM_OUTPUT("LOUT"),
124SND_SOC_DAPM_OUTPUT("LHPOUT"),
125SND_SOC_DAPM_OUTPUT("ROUT"), 143SND_SOC_DAPM_OUTPUT("ROUT"),
126SND_SOC_DAPM_OUTPUT("RHPOUT"), 144SND_SOC_DAPM_INPUT("RLINEIN"),
127SND_SOC_DAPM_ADC("ADC", "HiFi Capture", SSM2602_PWR, 2, 1), 145SND_SOC_DAPM_INPUT("LLINEIN"),
146};
147
148static const struct snd_soc_dapm_widget ssm2602_dapm_widgets[] = {
149SND_SOC_DAPM_MIXER("Output Mixer", SSM2602_PWR, 4, 1,
150 ssm260x_output_mixer_controls,
151 ARRAY_SIZE(ssm260x_output_mixer_controls)),
152
128SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0, &ssm2602_input_mux_controls), 153SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0, &ssm2602_input_mux_controls),
129SND_SOC_DAPM_PGA("Line Input", SSM2602_PWR, 0, 1, NULL, 0),
130SND_SOC_DAPM_MICBIAS("Mic Bias", SSM2602_PWR, 1, 1), 154SND_SOC_DAPM_MICBIAS("Mic Bias", SSM2602_PWR, 1, 1),
155
156SND_SOC_DAPM_OUTPUT("LHPOUT"),
157SND_SOC_DAPM_OUTPUT("RHPOUT"),
131SND_SOC_DAPM_INPUT("MICIN"), 158SND_SOC_DAPM_INPUT("MICIN"),
132SND_SOC_DAPM_INPUT("RLINEIN"),
133SND_SOC_DAPM_INPUT("LLINEIN"),
134}; 159};
135 160
136static const struct snd_soc_dapm_route audio_conn[] = { 161static const struct snd_soc_dapm_widget ssm2604_dapm_widgets[] = {
137 /* output mixer */ 162SND_SOC_DAPM_MIXER("Output Mixer", SND_SOC_NOPM, 0, 0,
163 ssm260x_output_mixer_controls,
164 ARRAY_SIZE(ssm260x_output_mixer_controls) - 1), /* Last element is the mic */
165};
166
167static const struct snd_soc_dapm_route ssm260x_routes[] = {
168 {"DAC", NULL, "Digital Core Power"},
169 {"ADC", NULL, "Digital Core Power"},
170
138 {"Output Mixer", "Line Bypass Switch", "Line Input"}, 171 {"Output Mixer", "Line Bypass Switch", "Line Input"},
139 {"Output Mixer", "HiFi Playback Switch", "DAC"}, 172 {"Output Mixer", "HiFi Playback Switch", "DAC"},
173
174 {"ROUT", NULL, "Output Mixer"},
175 {"LOUT", NULL, "Output Mixer"},
176
177 {"Line Input", NULL, "LLINEIN"},
178 {"Line Input", NULL, "RLINEIN"},
179};
180
181static const struct snd_soc_dapm_route ssm2602_routes[] = {
140 {"Output Mixer", "Mic Sidetone Switch", "Mic Bias"}, 182 {"Output Mixer", "Mic Sidetone Switch", "Mic Bias"},
141 183
142 /* outputs */
143 {"RHPOUT", NULL, "Output Mixer"}, 184 {"RHPOUT", NULL, "Output Mixer"},
144 {"ROUT", NULL, "Output Mixer"},
145 {"LHPOUT", NULL, "Output Mixer"}, 185 {"LHPOUT", NULL, "Output Mixer"},
146 {"LOUT", NULL, "Output Mixer"},
147 186
148 /* input mux */
149 {"Input Mux", "Line", "Line Input"}, 187 {"Input Mux", "Line", "Line Input"},
150 {"Input Mux", "Mic", "Mic Bias"}, 188 {"Input Mux", "Mic", "Mic Bias"},
151 {"ADC", NULL, "Input Mux"}, 189 {"ADC", NULL, "Input Mux"},
152 190
153 /* inputs */
154 {"Line Input", NULL, "LLINEIN"},
155 {"Line Input", NULL, "RLINEIN"},
156 {"Mic Bias", NULL, "MICIN"}, 191 {"Mic Bias", NULL, "MICIN"},
157}; 192};
158 193
159static int ssm2602_add_widgets(struct snd_soc_codec *codec) 194static const struct snd_soc_dapm_route ssm2604_routes[] = {
160{ 195 {"ADC", NULL, "Line Input"},
161 struct snd_soc_dapm_context *dapm = &codec->dapm; 196};
162
163 snd_soc_dapm_new_controls(dapm, ssm2602_dapm_widgets,
164 ARRAY_SIZE(ssm2602_dapm_widgets));
165 snd_soc_dapm_add_routes(dapm, audio_conn, ARRAY_SIZE(audio_conn));
166
167 return 0;
168}
169 197
170struct _coeff_div { 198struct ssm2602_coeff {
171 u32 mclk; 199 u32 mclk;
172 u32 rate; 200 u32 rate;
173 u16 fs; 201 u8 srate;
174 u8 sr:4;
175 u8 bosr:1;
176 u8 usb:1;
177}; 202};
178 203
179/* codec mclk clock divider coefficients */ 204#define SSM2602_COEFF_SRATE(sr, bosr, usb) (((sr) << 2) | ((bosr) << 1) | (usb))
180static const struct _coeff_div coeff_div[] = { 205
206/* codec mclk clock coefficients */
207static const struct ssm2602_coeff ssm2602_coeff_table[] = {
181 /* 48k */ 208 /* 48k */
182 {12288000, 48000, 256, 0x0, 0x0, 0x0}, 209 {12288000, 48000, SSM2602_COEFF_SRATE(0x0, 0x0, 0x0)},
183 {18432000, 48000, 384, 0x0, 0x1, 0x0}, 210 {18432000, 48000, SSM2602_COEFF_SRATE(0x0, 0x1, 0x0)},
184 {12000000, 48000, 250, 0x0, 0x0, 0x1}, 211 {12000000, 48000, SSM2602_COEFF_SRATE(0x0, 0x0, 0x1)},
185 212
186 /* 32k */ 213 /* 32k */
187 {12288000, 32000, 384, 0x6, 0x0, 0x0}, 214 {12288000, 32000, SSM2602_COEFF_SRATE(0x6, 0x0, 0x0)},
188 {18432000, 32000, 576, 0x6, 0x1, 0x0}, 215 {18432000, 32000, SSM2602_COEFF_SRATE(0x6, 0x1, 0x0)},
189 {12000000, 32000, 375, 0x6, 0x0, 0x1}, 216 {12000000, 32000, SSM2602_COEFF_SRATE(0x6, 0x0, 0x1)},
190 217
191 /* 8k */ 218 /* 8k */
192 {12288000, 8000, 1536, 0x3, 0x0, 0x0}, 219 {12288000, 8000, SSM2602_COEFF_SRATE(0x3, 0x0, 0x0)},
193 {18432000, 8000, 2304, 0x3, 0x1, 0x0}, 220 {18432000, 8000, SSM2602_COEFF_SRATE(0x3, 0x1, 0x0)},
194 {11289600, 8000, 1408, 0xb, 0x0, 0x0}, 221 {11289600, 8000, SSM2602_COEFF_SRATE(0xb, 0x0, 0x0)},
195 {16934400, 8000, 2112, 0xb, 0x1, 0x0}, 222 {16934400, 8000, SSM2602_COEFF_SRATE(0xb, 0x1, 0x0)},
196 {12000000, 8000, 1500, 0x3, 0x0, 0x1}, 223 {12000000, 8000, SSM2602_COEFF_SRATE(0x3, 0x0, 0x1)},
197 224
198 /* 96k */ 225 /* 96k */
199 {12288000, 96000, 128, 0x7, 0x0, 0x0}, 226 {12288000, 96000, SSM2602_COEFF_SRATE(0x7, 0x0, 0x0)},
200 {18432000, 96000, 192, 0x7, 0x1, 0x0}, 227 {18432000, 96000, SSM2602_COEFF_SRATE(0x7, 0x1, 0x0)},
201 {12000000, 96000, 125, 0x7, 0x0, 0x1}, 228 {12000000, 96000, SSM2602_COEFF_SRATE(0x7, 0x0, 0x1)},
202 229
203 /* 44.1k */ 230 /* 44.1k */
204 {11289600, 44100, 256, 0x8, 0x0, 0x0}, 231 {11289600, 44100, SSM2602_COEFF_SRATE(0x8, 0x0, 0x0)},
205 {16934400, 44100, 384, 0x8, 0x1, 0x0}, 232 {16934400, 44100, SSM2602_COEFF_SRATE(0x8, 0x1, 0x0)},
206 {12000000, 44100, 272, 0x8, 0x1, 0x1}, 233 {12000000, 44100, SSM2602_COEFF_SRATE(0x8, 0x1, 0x1)},
207 234
208 /* 88.2k */ 235 /* 88.2k */
209 {11289600, 88200, 128, 0xf, 0x0, 0x0}, 236 {11289600, 88200, SSM2602_COEFF_SRATE(0xf, 0x0, 0x0)},
210 {16934400, 88200, 192, 0xf, 0x1, 0x0}, 237 {16934400, 88200, SSM2602_COEFF_SRATE(0xf, 0x1, 0x0)},
211 {12000000, 88200, 136, 0xf, 0x1, 0x1}, 238 {12000000, 88200, SSM2602_COEFF_SRATE(0xf, 0x1, 0x1)},
212}; 239};
213 240
214static inline int get_coeff(int mclk, int rate) 241static inline int ssm2602_get_coeff(int mclk, int rate)
215{ 242{
216 int i; 243 int i;
217 244
218 for (i = 0; i < ARRAY_SIZE(coeff_div); i++) { 245 for (i = 0; i < ARRAY_SIZE(ssm2602_coeff_table); i++) {
219 if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk) 246 if (ssm2602_coeff_table[i].rate == rate &&
220 return i; 247 ssm2602_coeff_table[i].mclk == mclk)
248 return ssm2602_coeff_table[i].srate;
221 } 249 }
222 return i; 250 return -EINVAL;
223} 251}
224 252
225static int ssm2602_hw_params(struct snd_pcm_substream *substream, 253static int ssm2602_hw_params(struct snd_pcm_substream *substream,
226 struct snd_pcm_hw_params *params, 254 struct snd_pcm_hw_params *params,
227 struct snd_soc_dai *dai) 255 struct snd_soc_dai *dai)
228{ 256{
229 u16 srate;
230 struct snd_soc_pcm_runtime *rtd = substream->private_data; 257 struct snd_soc_pcm_runtime *rtd = substream->private_data;
231 struct snd_soc_codec *codec = rtd->codec; 258 struct snd_soc_codec *codec = rtd->codec;
232 struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); 259 struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec);
233 u16 iface = snd_soc_read(codec, SSM2602_IFACE) & 0xfff3; 260 u16 iface = snd_soc_read(codec, SSM2602_IFACE) & 0xfff3;
234 int i = get_coeff(ssm2602->sysclk, params_rate(params)); 261 int srate = ssm2602_get_coeff(ssm2602->sysclk, params_rate(params));
235 262
236 if (substream == ssm2602->slave_substream) { 263 if (substream == ssm2602->slave_substream) {
237 dev_dbg(codec->dev, "Ignoring hw_params for slave substream\n"); 264 dev_dbg(codec->dev, "Ignoring hw_params for slave substream\n");
238 return 0; 265 return 0;
239 } 266 }
240 267
241 /*no match is found*/ 268 if (srate < 0)
242 if (i == ARRAY_SIZE(coeff_div)) 269 return srate;
243 return -EINVAL;
244 270
245 srate = (coeff_div[i].sr << 2) |
246 (coeff_div[i].bosr << 1) | coeff_div[i].usb;
247
248 snd_soc_write(codec, SSM2602_ACTIVE, 0);
249 snd_soc_write(codec, SSM2602_SRATE, srate); 271 snd_soc_write(codec, SSM2602_SRATE, srate);
250 272
251 /* bit size */ 273 /* bit size */
@@ -263,7 +285,6 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream,
263 break; 285 break;
264 } 286 }
265 snd_soc_write(codec, SSM2602_IFACE, iface); 287 snd_soc_write(codec, SSM2602_IFACE, iface);
266 snd_soc_write(codec, SSM2602_ACTIVE, ACTIVE_ACTIVATE_CODEC);
267 return 0; 288 return 0;
268} 289}
269 290
@@ -305,17 +326,6 @@ static int ssm2602_startup(struct snd_pcm_substream *substream,
305 return 0; 326 return 0;
306} 327}
307 328
308static int ssm2602_pcm_prepare(struct snd_pcm_substream *substream,
309 struct snd_soc_dai *dai)
310{
311 struct snd_soc_pcm_runtime *rtd = substream->private_data;
312 struct snd_soc_codec *codec = rtd->codec;
313 /* set active */
314 snd_soc_write(codec, SSM2602_ACTIVE, ACTIVE_ACTIVATE_CODEC);
315
316 return 0;
317}
318
319static void ssm2602_shutdown(struct snd_pcm_substream *substream, 329static void ssm2602_shutdown(struct snd_pcm_substream *substream,
320 struct snd_soc_dai *dai) 330 struct snd_soc_dai *dai)
321{ 331{
@@ -323,16 +333,13 @@ static void ssm2602_shutdown(struct snd_pcm_substream *substream,
323 struct snd_soc_codec *codec = rtd->codec; 333 struct snd_soc_codec *codec = rtd->codec;
324 struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); 334 struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec);
325 335
326 /* deactivate */
327 if (!codec->active)
328 snd_soc_write(codec, SSM2602_ACTIVE, 0);
329
330 if (ssm2602->master_substream == substream) 336 if (ssm2602->master_substream == substream)
331 ssm2602->master_substream = ssm2602->slave_substream; 337 ssm2602->master_substream = ssm2602->slave_substream;
332 338
333 ssm2602->slave_substream = NULL; 339 ssm2602->slave_substream = NULL;
334} 340}
335 341
342
336static int ssm2602_mute(struct snd_soc_dai *dai, int mute) 343static int ssm2602_mute(struct snd_soc_dai *dai, int mute)
337{ 344{
338 struct snd_soc_codec *codec = dai->codec; 345 struct snd_soc_codec *codec = dai->codec;
@@ -439,7 +446,6 @@ static int ssm2602_set_bias_level(struct snd_soc_codec *codec,
439 break; 446 break;
440 case SND_SOC_BIAS_OFF: 447 case SND_SOC_BIAS_OFF:
441 /* everything off, dac mute, inactive */ 448 /* everything off, dac mute, inactive */
442 snd_soc_write(codec, SSM2602_ACTIVE, 0);
443 snd_soc_write(codec, SSM2602_PWR, 0xffff); 449 snd_soc_write(codec, SSM2602_PWR, 0xffff);
444 break; 450 break;
445 451
@@ -457,7 +463,6 @@ static int ssm2602_set_bias_level(struct snd_soc_codec *codec,
457 463
458static struct snd_soc_dai_ops ssm2602_dai_ops = { 464static struct snd_soc_dai_ops ssm2602_dai_ops = {
459 .startup = ssm2602_startup, 465 .startup = ssm2602_startup,
460 .prepare = ssm2602_pcm_prepare,
461 .hw_params = ssm2602_hw_params, 466 .hw_params = ssm2602_hw_params,
462 .shutdown = ssm2602_shutdown, 467 .shutdown = ssm2602_shutdown,
463 .digital_mute = ssm2602_mute, 468 .digital_mute = ssm2602_mute,
@@ -499,8 +504,46 @@ static int ssm2602_resume(struct snd_soc_codec *codec)
499 504
500static int ssm2602_probe(struct snd_soc_codec *codec) 505static int ssm2602_probe(struct snd_soc_codec *codec)
501{ 506{
507 struct snd_soc_dapm_context *dapm = &codec->dapm;
508 int ret, reg;
509
510 reg = snd_soc_read(codec, SSM2602_LOUT1V);
511 snd_soc_write(codec, SSM2602_LOUT1V, reg | LOUT1V_LRHP_BOTH);
512 reg = snd_soc_read(codec, SSM2602_ROUT1V);
513 snd_soc_write(codec, SSM2602_ROUT1V, reg | ROUT1V_RLHP_BOTH);
514
515 ret = snd_soc_add_controls(codec, ssm2602_snd_controls,
516 ARRAY_SIZE(ssm2602_snd_controls));
517 if (ret)
518 return ret;
519
520 ret = snd_soc_dapm_new_controls(dapm, ssm2602_dapm_widgets,
521 ARRAY_SIZE(ssm2602_dapm_widgets));
522 if (ret)
523 return ret;
524
525 return snd_soc_dapm_add_routes(dapm, ssm2602_routes,
526 ARRAY_SIZE(ssm2602_routes));
527}
528
529static int ssm2604_probe(struct snd_soc_codec *codec)
530{
531 struct snd_soc_dapm_context *dapm = &codec->dapm;
532 int ret;
533
534 ret = snd_soc_dapm_new_controls(dapm, ssm2604_dapm_widgets,
535 ARRAY_SIZE(ssm2604_dapm_widgets));
536 if (ret)
537 return ret;
538
539 return snd_soc_dapm_add_routes(dapm, ssm2604_routes,
540 ARRAY_SIZE(ssm2604_routes));
541}
542
543static int ssm260x_probe(struct snd_soc_codec *codec)
544{
502 struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); 545 struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec);
503 int ret = 0, reg; 546 int ret, reg;
504 547
505 pr_info("ssm2602 Audio Codec %s", SSM2602_VERSION); 548 pr_info("ssm2602 Audio Codec %s", SSM2602_VERSION);
506 549
@@ -516,27 +559,25 @@ static int ssm2602_probe(struct snd_soc_codec *codec)
516 return ret; 559 return ret;
517 } 560 }
518 561
519 /*power on device*/
520 snd_soc_write(codec, SSM2602_ACTIVE, 0);
521 /* set the update bits */ 562 /* set the update bits */
522 reg = snd_soc_read(codec, SSM2602_LINVOL); 563 reg = snd_soc_read(codec, SSM2602_LINVOL);
523 snd_soc_write(codec, SSM2602_LINVOL, reg | LINVOL_LRIN_BOTH); 564 snd_soc_write(codec, SSM2602_LINVOL, reg | LINVOL_LRIN_BOTH);
524 reg = snd_soc_read(codec, SSM2602_RINVOL); 565 reg = snd_soc_read(codec, SSM2602_RINVOL);
525 snd_soc_write(codec, SSM2602_RINVOL, reg | RINVOL_RLIN_BOTH); 566 snd_soc_write(codec, SSM2602_RINVOL, reg | RINVOL_RLIN_BOTH);
526 reg = snd_soc_read(codec, SSM2602_LOUT1V);
527 snd_soc_write(codec, SSM2602_LOUT1V, reg | LOUT1V_LRHP_BOTH);
528 reg = snd_soc_read(codec, SSM2602_ROUT1V);
529 snd_soc_write(codec, SSM2602_ROUT1V, reg | ROUT1V_RLHP_BOTH);
530 /*select Line in as default input*/ 567 /*select Line in as default input*/
531 snd_soc_write(codec, SSM2602_APANA, APANA_SELECT_DAC | 568 snd_soc_write(codec, SSM2602_APANA, APANA_SELECT_DAC |
532 APANA_ENABLE_MIC_BOOST); 569 APANA_ENABLE_MIC_BOOST);
533 snd_soc_write(codec, SSM2602_PWR, 0);
534 570
535 snd_soc_add_controls(codec, ssm2602_snd_controls, 571 switch (ssm2602->type) {
536 ARRAY_SIZE(ssm2602_snd_controls)); 572 case SSM2602:
537 ssm2602_add_widgets(codec); 573 ret = ssm2602_probe(codec);
574 break;
575 case SSM2604:
576 ret = ssm2604_probe(codec);
577 break;
578 }
538 579
539 return 0; 580 return ret;
540} 581}
541 582
542/* remove everything here */ 583/* remove everything here */
@@ -547,14 +588,21 @@ static int ssm2602_remove(struct snd_soc_codec *codec)
547} 588}
548 589
549static struct snd_soc_codec_driver soc_codec_dev_ssm2602 = { 590static struct snd_soc_codec_driver soc_codec_dev_ssm2602 = {
550 .probe = ssm2602_probe, 591 .probe = ssm260x_probe,
551 .remove = ssm2602_remove, 592 .remove = ssm2602_remove,
552 .suspend = ssm2602_suspend, 593 .suspend = ssm2602_suspend,
553 .resume = ssm2602_resume, 594 .resume = ssm2602_resume,
554 .set_bias_level = ssm2602_set_bias_level, 595 .set_bias_level = ssm2602_set_bias_level,
555 .reg_cache_size = sizeof(ssm2602_reg), 596 .reg_cache_size = ARRAY_SIZE(ssm2602_reg),
556 .reg_word_size = sizeof(u16), 597 .reg_word_size = sizeof(u16),
557 .reg_cache_default = ssm2602_reg, 598 .reg_cache_default = ssm2602_reg,
599
600 .controls = ssm260x_snd_controls,
601 .num_controls = ARRAY_SIZE(ssm260x_snd_controls),
602 .dapm_widgets = ssm260x_dapm_widgets,
603 .num_dapm_widgets = ARRAY_SIZE(ssm260x_dapm_widgets),
604 .dapm_routes = ssm260x_routes,
605 .num_dapm_routes = ARRAY_SIZE(ssm260x_routes),
558}; 606};
559 607
560#if defined(CONFIG_SPI_MASTER) 608#if defined(CONFIG_SPI_MASTER)
@@ -569,6 +617,7 @@ static int __devinit ssm2602_spi_probe(struct spi_device *spi)
569 617
570 spi_set_drvdata(spi, ssm2602); 618 spi_set_drvdata(spi, ssm2602);
571 ssm2602->control_type = SND_SOC_SPI; 619 ssm2602->control_type = SND_SOC_SPI;
620 ssm2602->type = SSM2602;
572 621
573 ret = snd_soc_register_codec(&spi->dev, 622 ret = snd_soc_register_codec(&spi->dev,
574 &soc_codec_dev_ssm2602, &ssm2602_dai, 1); 623 &soc_codec_dev_ssm2602, &ssm2602_dai, 1);
@@ -601,7 +650,7 @@ static struct spi_driver ssm2602_spi_driver = {
601 * low = 0x1a 650 * low = 0x1a
602 * high = 0x1b 651 * high = 0x1b
603 */ 652 */
604static int ssm2602_i2c_probe(struct i2c_client *i2c, 653static int __devinit ssm2602_i2c_probe(struct i2c_client *i2c,
605 const struct i2c_device_id *id) 654 const struct i2c_device_id *id)
606{ 655{
607 struct ssm2602_priv *ssm2602; 656 struct ssm2602_priv *ssm2602;
@@ -613,6 +662,7 @@ static int ssm2602_i2c_probe(struct i2c_client *i2c,
613 662
614 i2c_set_clientdata(i2c, ssm2602); 663 i2c_set_clientdata(i2c, ssm2602);
615 ssm2602->control_type = SND_SOC_I2C; 664 ssm2602->control_type = SND_SOC_I2C;
665 ssm2602->type = id->driver_data;
616 666
617 ret = snd_soc_register_codec(&i2c->dev, 667 ret = snd_soc_register_codec(&i2c->dev,
618 &soc_codec_dev_ssm2602, &ssm2602_dai, 1); 668 &soc_codec_dev_ssm2602, &ssm2602_dai, 1);
@@ -621,7 +671,7 @@ static int ssm2602_i2c_probe(struct i2c_client *i2c,
621 return ret; 671 return ret;
622} 672}
623 673
624static int ssm2602_i2c_remove(struct i2c_client *client) 674static int __devexit ssm2602_i2c_remove(struct i2c_client *client)
625{ 675{
626 snd_soc_unregister_codec(&client->dev); 676 snd_soc_unregister_codec(&client->dev);
627 kfree(i2c_get_clientdata(client)); 677 kfree(i2c_get_clientdata(client));
@@ -629,7 +679,9 @@ static int ssm2602_i2c_remove(struct i2c_client *client)
629} 679}
630 680
631static const struct i2c_device_id ssm2602_i2c_id[] = { 681static const struct i2c_device_id ssm2602_i2c_id[] = {
632 { "ssm2602", 0 }, 682 { "ssm2602", SSM2602 },
683 { "ssm2603", SSM2602 },
684 { "ssm2604", SSM2604 },
633 { } 685 { }
634}; 686};
635MODULE_DEVICE_TABLE(i2c, ssm2602_i2c_id); 687MODULE_DEVICE_TABLE(i2c, ssm2602_i2c_id);
@@ -641,7 +693,7 @@ static struct i2c_driver ssm2602_i2c_driver = {
641 .owner = THIS_MODULE, 693 .owner = THIS_MODULE,
642 }, 694 },
643 .probe = ssm2602_i2c_probe, 695 .probe = ssm2602_i2c_probe,
644 .remove = ssm2602_i2c_remove, 696 .remove = __devexit_p(ssm2602_i2c_remove),
645 .id_table = ssm2602_i2c_id, 697 .id_table = ssm2602_i2c_id,
646}; 698};
647#endif 699#endif
@@ -679,6 +731,6 @@ static void __exit ssm2602_exit(void)
679} 731}
680module_exit(ssm2602_exit); 732module_exit(ssm2602_exit);
681 733
682MODULE_DESCRIPTION("ASoC ssm2602 driver"); 734MODULE_DESCRIPTION("ASoC SSM2602/SSM2603/SSM2604 driver");
683MODULE_AUTHOR("Cliff Cai"); 735MODULE_AUTHOR("Cliff Cai");
684MODULE_LICENSE("GPL"); 736MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/ssm2602.h b/sound/soc/codecs/ssm2602.h
index 42a47d0f8e25..b98c69168036 100644
--- a/sound/soc/codecs/ssm2602.h
+++ b/sound/soc/codecs/ssm2602.h
@@ -117,11 +117,5 @@
117#define SSM2602_CACHEREGNUM 10 117#define SSM2602_CACHEREGNUM 10
118 118
119#define SSM2602_SYSCLK 0 119#define SSM2602_SYSCLK 0
120#define SSM2602_DAI 0
121
122struct ssm2602_setup_data {
123 int i2c_bus;
124 unsigned short i2c_address;
125};
126 120
127#endif 121#endif
diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c
index 48ffd406a71d..a7b8f301bad3 100644
--- a/sound/soc/codecs/uda134x.c
+++ b/sound/soc/codecs/uda134x.c
@@ -601,9 +601,7 @@ static struct snd_soc_codec_driver soc_codec_dev_uda134x = {
601 .reg_cache_step = 1, 601 .reg_cache_step = 1,
602 .read = uda134x_read_reg_cache, 602 .read = uda134x_read_reg_cache,
603 .write = uda134x_write, 603 .write = uda134x_write,
604#ifdef POWER_OFF_ON_STANDBY
605 .set_bias_level = uda134x_set_bias_level, 604 .set_bias_level = uda134x_set_bias_level,
606#endif
607}; 605};
608 606
609static int __devinit uda134x_codec_probe(struct platform_device *pdev) 607static int __devinit uda134x_codec_probe(struct platform_device *pdev)
diff --git a/sound/soc/codecs/wm8915.c b/sound/soc/codecs/wm8915.c
index 4a3c5cc77e55..ccc9bd832794 100644
--- a/sound/soc/codecs/wm8915.c
+++ b/sound/soc/codecs/wm8915.c
@@ -991,17 +991,16 @@ SND_SOC_DAPM_MICBIAS("MICB1", WM8915_POWER_MANAGEMENT_1, 8, 0),
991SND_SOC_DAPM_PGA("IN1L PGA", WM8915_POWER_MANAGEMENT_2, 5, 0, NULL, 0), 991SND_SOC_DAPM_PGA("IN1L PGA", WM8915_POWER_MANAGEMENT_2, 5, 0, NULL, 0),
992SND_SOC_DAPM_PGA("IN1R PGA", WM8915_POWER_MANAGEMENT_2, 4, 0, NULL, 0), 992SND_SOC_DAPM_PGA("IN1R PGA", WM8915_POWER_MANAGEMENT_2, 4, 0, NULL, 0),
993 993
994SND_SOC_DAPM_PGA("ADC", SND_SOC_NOPM, 0, 0, NULL, 0), 994SND_SOC_DAPM_MUX("IN1L Mux", SND_SOC_NOPM, 0, 0, &in1_mux),
995 995SND_SOC_DAPM_MUX("IN1R Mux", SND_SOC_NOPM, 0, 0, &in1_mux),
996SND_SOC_DAPM_MUX("IN1 Mux", SND_SOC_NOPM, 0, 0, &in1_mux), 996SND_SOC_DAPM_MUX("IN2L Mux", SND_SOC_NOPM, 0, 0, &in2_mux),
997SND_SOC_DAPM_MUX("IN2 Mux", SND_SOC_NOPM, 0, 0, &in2_mux), 997SND_SOC_DAPM_MUX("IN2R Mux", SND_SOC_NOPM, 0, 0, &in2_mux),
998 998
999SND_SOC_DAPM_PGA("IN1L", WM8915_POWER_MANAGEMENT_7, 2, 0, NULL, 0), 999SND_SOC_DAPM_PGA("IN1L", WM8915_POWER_MANAGEMENT_7, 2, 0, NULL, 0),
1000SND_SOC_DAPM_PGA("IN1R", WM8915_POWER_MANAGEMENT_7, 3, 0, NULL, 0), 1000SND_SOC_DAPM_PGA("IN1R", WM8915_POWER_MANAGEMENT_7, 3, 0, NULL, 0),
1001SND_SOC_DAPM_PGA("IN2L", WM8915_POWER_MANAGEMENT_7, 6, 0, NULL, 0), 1001SND_SOC_DAPM_PGA("IN2L", WM8915_POWER_MANAGEMENT_7, 6, 0, NULL, 0),
1002SND_SOC_DAPM_PGA("IN2R", WM8915_POWER_MANAGEMENT_7, 7, 0, NULL, 0), 1002SND_SOC_DAPM_PGA("IN2R", WM8915_POWER_MANAGEMENT_7, 7, 0, NULL, 0),
1003 1003
1004/* FIXME - these need to be concentrator widgets */
1005SND_SOC_DAPM_SUPPLY("DMIC2", WM8915_POWER_MANAGEMENT_7, 9, 0, NULL, 0), 1004SND_SOC_DAPM_SUPPLY("DMIC2", WM8915_POWER_MANAGEMENT_7, 9, 0, NULL, 0),
1006SND_SOC_DAPM_SUPPLY("DMIC1", WM8915_POWER_MANAGEMENT_7, 8, 0, NULL, 0), 1005SND_SOC_DAPM_SUPPLY("DMIC1", WM8915_POWER_MANAGEMENT_7, 8, 0, NULL, 0),
1007 1006
@@ -1172,28 +1171,33 @@ static const struct snd_soc_dapm_route wm8915_dapm_routes[] = {
1172 { "DMIC1L", NULL, "DMIC1" }, 1171 { "DMIC1L", NULL, "DMIC1" },
1173 { "DMIC1R", NULL, "DMIC1" }, 1172 { "DMIC1R", NULL, "DMIC1" },
1174 1173
1175 { "ADC", NULL, "ADCL" }, 1174 { "IN1L Mux", "ADC", "ADCL" },
1176 { "ADC", NULL, "ADCR" }, 1175 { "IN1L Mux", "DMIC1", "DMIC1L" },
1176 { "IN1L Mux", "DMIC2", "DMIC2L" },
1177
1178 { "IN1R Mux", "ADC", "ADCR" },
1179 { "IN1R Mux", "DMIC1", "DMIC1R" },
1180 { "IN1R Mux", "DMIC2", "DMIC2R" },
1177 1181
1178 { "IN1 Mux", "ADC", "ADC" }, 1182 { "IN2L Mux", "ADC", "ADCL" },
1179 { "IN1 Mux", "DMIC1", "DMIC1" }, 1183 { "IN2L Mux", "DMIC1", "DMIC1L" },
1180 { "IN1 Mux", "DMIC2", "DMIC2" }, 1184 { "IN2L Mux", "DMIC2", "DMIC2L" },
1181 1185
1182 { "IN2 Mux", "ADC", "ADC" }, 1186 { "IN2R Mux", "ADC", "ADCR" },
1183 { "IN2 Mux", "DMIC1", "DMIC1" }, 1187 { "IN2R Mux", "DMIC1", "DMIC1R" },
1184 { "IN2 Mux", "DMIC2", "DMIC2" }, 1188 { "IN2R Mux", "DMIC2", "DMIC2R" },
1185 1189
1186 { "Left Sidetone", "IN1", "IN1 Mux" }, 1190 { "Left Sidetone", "IN1", "IN1L Mux" },
1187 { "Left Sidetone", "IN2", "IN2 Mux" }, 1191 { "Left Sidetone", "IN2", "IN2L Mux" },
1188 1192
1189 { "Right Sidetone", "IN1", "IN1 Mux" }, 1193 { "Right Sidetone", "IN1", "IN1R Mux" },
1190 { "Right Sidetone", "IN2", "IN2 Mux" }, 1194 { "Right Sidetone", "IN2", "IN2R Mux" },
1191 1195
1192 { "DSP1TXL", "IN1 Switch", "IN1 Mux" }, 1196 { "DSP1TXL", "IN1 Switch", "IN1L Mux" },
1193 { "DSP1TXR", "IN1 Switch", "IN1 Mux" }, 1197 { "DSP1TXR", "IN1 Switch", "IN1R Mux" },
1194 1198
1195 { "DSP2TXL", "IN1 Switch", "IN2 Mux" }, 1199 { "DSP2TXL", "IN1 Switch", "IN2L Mux" },
1196 { "DSP2TXR", "IN1 Switch", "IN2 Mux" }, 1200 { "DSP2TXR", "IN1 Switch", "IN2R Mux" },
1197 1201
1198 { "AIF1TX0", NULL, "DSP1TXL" }, 1202 { "AIF1TX0", NULL, "DSP1TXL" },
1199 { "AIF1TX1", NULL, "DSP1TXR" }, 1203 { "AIF1TX1", NULL, "DSP1TXR" },