aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-08-22 09:28:52 -0400
committerMark Brown <broonie@linaro.org>2013-08-22 09:28:52 -0400
commit2291d2691473e9f4655e74cd1ae03c9e05fed6fd (patch)
tree60aa431b04a2266cb4008b4631547744f52e4923
parent840f0e43782ed132da0db00982a41b003ff6a179 (diff)
parent4a11bc2fdd7f526c70e013366171d66f27656203 (diff)
Merge remote-tracking branch 'asoc/topic/tlv320aic26' into asoc-next
-rw-r--r--sound/soc/codecs/tlv320aic26.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c
index b1f6982c7c9c..7b8f3d965f43 100644
--- a/sound/soc/codecs/tlv320aic26.c
+++ b/sound/soc/codecs/tlv320aic26.c
@@ -29,7 +29,7 @@ MODULE_LICENSE("GPL");
29/* AIC26 driver private data */ 29/* AIC26 driver private data */
30struct aic26 { 30struct aic26 {
31 struct spi_device *spi; 31 struct spi_device *spi;
32 struct snd_soc_codec codec; 32 struct snd_soc_codec *codec;
33 int master; 33 int master;
34 int datfm; 34 int datfm;
35 int mclk; 35 int mclk;
@@ -119,6 +119,22 @@ static int aic26_reg_write(struct snd_soc_codec *codec, unsigned int reg,
119 return 0; 119 return 0;
120} 120}
121 121
122static const struct snd_soc_dapm_widget tlv320aic26_dapm_widgets[] = {
123SND_SOC_DAPM_INPUT("MICIN"),
124SND_SOC_DAPM_INPUT("AUX"),
125
126SND_SOC_DAPM_OUTPUT("HPL"),
127SND_SOC_DAPM_OUTPUT("HPR"),
128};
129
130static const struct snd_soc_dapm_route tlv320aic26_dapm_routes[] = {
131 { "Capture", NULL, "MICIN" },
132 { "Capture", NULL, "AUX" },
133
134 { "HPL", NULL, "Playback" },
135 { "HPR", NULL, "Playback" },
136};
137
122/* --------------------------------------------------------------------- 138/* ---------------------------------------------------------------------
123 * Digital Audio Interface Operations 139 * Digital Audio Interface Operations
124 */ 140 */
@@ -174,9 +190,9 @@ static int aic26_hw_params(struct snd_pcm_substream *substream,
174 dev_dbg(&aic26->spi->dev, "Setting PLLM to %d.%04d\n", jval, dval); 190 dev_dbg(&aic26->spi->dev, "Setting PLLM to %d.%04d\n", jval, dval);
175 qval = 0; 191 qval = 0;
176 reg = 0x8000 | qval << 11 | pval << 8 | jval << 2; 192 reg = 0x8000 | qval << 11 | pval << 8 | jval << 2;
177 aic26_reg_write(codec, AIC26_REG_PLL_PROG1, reg); 193 snd_soc_write(codec, AIC26_REG_PLL_PROG1, reg);
178 reg = dval << 2; 194 reg = dval << 2;
179 aic26_reg_write(codec, AIC26_REG_PLL_PROG2, reg); 195 snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg);
180 196
181 /* Audio Control 3 (master mode, fsref rate) */ 197 /* Audio Control 3 (master mode, fsref rate) */
182 reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL3); 198 reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL3);
@@ -185,13 +201,13 @@ static int aic26_hw_params(struct snd_pcm_substream *substream,
185 reg |= 0x0800; 201 reg |= 0x0800;
186 if (fsref == 48000) 202 if (fsref == 48000)
187 reg |= 0x2000; 203 reg |= 0x2000;
188 aic26_reg_write(codec, AIC26_REG_AUDIO_CTRL3, reg); 204 snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg);
189 205
190 /* Audio Control 1 (FSref divisor) */ 206 /* Audio Control 1 (FSref divisor) */
191 reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL1); 207 reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL1);
192 reg &= ~0x0fff; 208 reg &= ~0x0fff;
193 reg |= wlen | aic26->datfm | (divisor << 3) | divisor; 209 reg |= wlen | aic26->datfm | (divisor << 3) | divisor;
194 aic26_reg_write(codec, AIC26_REG_AUDIO_CTRL1, reg); 210 snd_soc_write(codec, AIC26_REG_AUDIO_CTRL1, reg);
195 211
196 return 0; 212 return 0;
197} 213}
@@ -212,7 +228,7 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute)
212 reg |= 0x8080; 228 reg |= 0x8080;
213 else 229 else
214 reg &= ~0x8080; 230 reg &= ~0x8080;
215 aic26_reg_write(codec, AIC26_REG_DAC_GAIN, reg); 231 snd_soc_write(codec, AIC26_REG_DAC_GAIN, reg);
216 232
217 return 0; 233 return 0;
218} 234}
@@ -330,7 +346,7 @@ static ssize_t aic26_keyclick_show(struct device *dev,
330 struct aic26 *aic26 = dev_get_drvdata(dev); 346 struct aic26 *aic26 = dev_get_drvdata(dev);
331 int val, amp, freq, len; 347 int val, amp, freq, len;
332 348
333 val = aic26_reg_read_cache(&aic26->codec, AIC26_REG_AUDIO_CTRL2); 349 val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2);
334 amp = (val >> 12) & 0x7; 350 amp = (val >> 12) & 0x7;
335 freq = (125 << ((val >> 8) & 0x7)) >> 1; 351 freq = (125 << ((val >> 8) & 0x7)) >> 1;
336 len = 2 * (1 + ((val >> 4) & 0xf)); 352 len = 2 * (1 + ((val >> 4) & 0xf));
@@ -346,9 +362,9 @@ static ssize_t aic26_keyclick_set(struct device *dev,
346 struct aic26 *aic26 = dev_get_drvdata(dev); 362 struct aic26 *aic26 = dev_get_drvdata(dev);
347 int val; 363 int val;
348 364
349 val = aic26_reg_read_cache(&aic26->codec, AIC26_REG_AUDIO_CTRL2); 365 val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2);
350 val |= 0x8000; 366 val |= 0x8000;
351 aic26_reg_write(&aic26->codec, AIC26_REG_AUDIO_CTRL2, val); 367 snd_soc_write(aic26->codec, AIC26_REG_AUDIO_CTRL2, val);
352 368
353 return count; 369 return count;
354} 370}
@@ -360,25 +376,26 @@ static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set);
360 */ 376 */
361static int aic26_probe(struct snd_soc_codec *codec) 377static int aic26_probe(struct snd_soc_codec *codec)
362{ 378{
379 struct aic26 *aic26 = dev_get_drvdata(codec->dev);
363 int ret, err, i, reg; 380 int ret, err, i, reg;
364 381
365 dev_info(codec->dev, "Probing AIC26 SoC CODEC driver\n"); 382 aic26->codec = codec;
366 383
367 /* Reset the codec to power on defaults */ 384 /* Reset the codec to power on defaults */
368 aic26_reg_write(codec, AIC26_REG_RESET, 0xBB00); 385 snd_soc_write(codec, AIC26_REG_RESET, 0xBB00);
369 386
370 /* Power up CODEC */ 387 /* Power up CODEC */
371 aic26_reg_write(codec, AIC26_REG_POWER_CTRL, 0); 388 snd_soc_write(codec, AIC26_REG_POWER_CTRL, 0);
372 389
373 /* Audio Control 3 (master mode, fsref rate) */ 390 /* Audio Control 3 (master mode, fsref rate) */
374 reg = aic26_reg_read(codec, AIC26_REG_AUDIO_CTRL3); 391 reg = snd_soc_read(codec, AIC26_REG_AUDIO_CTRL3);
375 reg &= ~0xf800; 392 reg &= ~0xf800;
376 reg |= 0x0800; /* set master mode */ 393 reg |= 0x0800; /* set master mode */
377 aic26_reg_write(codec, AIC26_REG_AUDIO_CTRL3, reg); 394 snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg);
378 395
379 /* Fill register cache */ 396 /* Fill register cache */
380 for (i = 0; i < codec->driver->reg_cache_size; i++) 397 for (i = 0; i < codec->driver->reg_cache_size; i++)
381 aic26_reg_read(codec, i); 398 snd_soc_read(codec, i);
382 399
383 /* Register the sysfs files for debugging */ 400 /* Register the sysfs files for debugging */
384 /* Create SysFS files */ 401 /* Create SysFS files */
@@ -401,6 +418,10 @@ static struct snd_soc_codec_driver aic26_soc_codec_dev = {
401 .write = aic26_reg_write, 418 .write = aic26_reg_write,
402 .reg_cache_size = AIC26_NUM_REGS, 419 .reg_cache_size = AIC26_NUM_REGS,
403 .reg_word_size = sizeof(u16), 420 .reg_word_size = sizeof(u16),
421 .dapm_widgets = tlv320aic26_dapm_widgets,
422 .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets),
423 .dapm_routes = tlv320aic26_dapm_routes,
424 .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes),
404}; 425};
405 426
406/* --------------------------------------------------------------------- 427/* ---------------------------------------------------------------------