aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8776.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/wm8776.c')
-rw-r--r--sound/soc/codecs/wm8776.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c
index 8e7953b1b790..00d8846fae8a 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -18,6 +18,7 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/of_device.h>
21#include <linux/platform_device.h> 22#include <linux/platform_device.h>
22#include <linux/spi/spi.h> 23#include <linux/spi/spi.h>
23#include <linux/slab.h> 24#include <linux/slab.h>
@@ -215,8 +216,6 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream,
215 int ratio_shift, master; 216 int ratio_shift, master;
216 int i; 217 int i;
217 218
218 iface = 0;
219
220 switch (dai->driver->id) { 219 switch (dai->driver->id) {
221 case WM8776_DAI_DAC: 220 case WM8776_DAI_DAC:
222 iface_reg = WM8776_DACIFCTRL; 221 iface_reg = WM8776_DACIFCTRL;
@@ -232,20 +231,23 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream,
232 return -EINVAL; 231 return -EINVAL;
233 } 232 }
234 233
235
236 /* Set word length */ 234 /* Set word length */
237 switch (params_format(params)) { 235 switch (snd_pcm_format_width(params_format(params))) {
238 case SNDRV_PCM_FORMAT_S16_LE: 236 case 16:
237 iface = 0;
238 case 20:
239 iface = 0x10;
239 break; 240 break;
240 case SNDRV_PCM_FORMAT_S20_3LE: 241 case 24:
241 iface |= 0x10; 242 iface = 0x20;
242 break; 243 break;
243 case SNDRV_PCM_FORMAT_S24_LE: 244 case 32:
244 iface |= 0x20; 245 iface = 0x30;
245 break;
246 case SNDRV_PCM_FORMAT_S32_LE:
247 iface |= 0x30;
248 break; 246 break;
247 default:
248 dev_err(codec->dev, "Unsupported sample size: %i\n",
249 snd_pcm_format_width(params_format(params)));
250 return -EINVAL;
249 } 251 }
250 252
251 /* Only need to set MCLK/LRCLK ratio if we're master */ 253 /* Only need to set MCLK/LRCLK ratio if we're master */
@@ -320,11 +322,6 @@ static int wm8776_set_bias_level(struct snd_soc_codec *codec,
320 return 0; 322 return 0;
321} 323}
322 324
323#define WM8776_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
324 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\
325 SNDRV_PCM_RATE_96000)
326
327
328#define WM8776_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 325#define WM8776_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
329 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 326 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
330 327
@@ -349,7 +346,9 @@ static struct snd_soc_dai_driver wm8776_dai[] = {
349 .stream_name = "Playback", 346 .stream_name = "Playback",
350 .channels_min = 2, 347 .channels_min = 2,
351 .channels_max = 2, 348 .channels_max = 2,
352 .rates = WM8776_RATES, 349 .rates = SNDRV_PCM_RATE_CONTINUOUS,
350 .rate_min = 32000,
351 .rate_max = 192000,
353 .formats = WM8776_FORMATS, 352 .formats = WM8776_FORMATS,
354 }, 353 },
355 .ops = &wm8776_dac_ops, 354 .ops = &wm8776_dac_ops,
@@ -361,7 +360,9 @@ static struct snd_soc_dai_driver wm8776_dai[] = {
361 .stream_name = "Capture", 360 .stream_name = "Capture",
362 .channels_min = 2, 361 .channels_min = 2,
363 .channels_max = 2, 362 .channels_max = 2,
364 .rates = WM8776_RATES, 363 .rates = SNDRV_PCM_RATE_CONTINUOUS,
364 .rate_min = 32000,
365 .rate_max = 96000,
365 .formats = WM8776_FORMATS, 366 .formats = WM8776_FORMATS,
366 }, 367 },
367 .ops = &wm8776_adc_ops, 368 .ops = &wm8776_adc_ops,
@@ -452,6 +453,12 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8776 = {
452 .reg_cache_default = wm8776_reg, 453 .reg_cache_default = wm8776_reg,
453}; 454};
454 455
456static const struct of_device_id wm8776_of_match[] = {
457 { .compatible = "wlf,wm8776", },
458 { }
459};
460MODULE_DEVICE_TABLE(of, wm8776_of_match);
461
455#if defined(CONFIG_SPI_MASTER) 462#if defined(CONFIG_SPI_MASTER)
456static int __devinit wm8776_spi_probe(struct spi_device *spi) 463static int __devinit wm8776_spi_probe(struct spi_device *spi)
457{ 464{
@@ -481,8 +488,9 @@ static int __devexit wm8776_spi_remove(struct spi_device *spi)
481 488
482static struct spi_driver wm8776_spi_driver = { 489static struct spi_driver wm8776_spi_driver = {
483 .driver = { 490 .driver = {
484 .name = "wm8776-codec", 491 .name = "wm8776",
485 .owner = THIS_MODULE, 492 .owner = THIS_MODULE,
493 .of_match_table = wm8776_of_match,
486 }, 494 },
487 .probe = wm8776_spi_probe, 495 .probe = wm8776_spi_probe,
488 .remove = __devexit_p(wm8776_spi_remove), 496 .remove = __devexit_p(wm8776_spi_remove),
@@ -525,8 +533,9 @@ MODULE_DEVICE_TABLE(i2c, wm8776_i2c_id);
525 533
526static struct i2c_driver wm8776_i2c_driver = { 534static struct i2c_driver wm8776_i2c_driver = {
527 .driver = { 535 .driver = {
528 .name = "wm8776-codec", 536 .name = "wm8776",
529 .owner = THIS_MODULE, 537 .owner = THIS_MODULE,
538 .of_match_table = wm8776_of_match,
530 }, 539 },
531 .probe = wm8776_i2c_probe, 540 .probe = wm8776_i2c_probe,
532 .remove = __devexit_p(wm8776_i2c_remove), 541 .remove = __devexit_p(wm8776_i2c_remove),