diff options
author | Timur Tabi <timur@freescale.com> | 2011-09-13 21:59:35 +0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-09-16 13:06:31 +0400 |
commit | d1dc698a54259cb454284456483b45f67c865cf8 (patch) | |
tree | d85f49ae885e1995d84fb4708ec39859832443e0 | |
parent | cc2115cbfc63da72890160da01608b3189dd1b74 (diff) | |
download | linux-d1dc698a54259cb454284456483b45f67c865cf8.tar.xz |
ASoC: support sample sizes properly in the WM8776 codec driver
Use snd_pcm_format_width() to determine the sample size, instead of
checking specify sample formats and assuming that those are the only
valid format.
This change adds support for big-endian architectures (which use the _BE
formats) and the packed 24-bit format (SNDRV_PCM_FORMAT_S24_3xE).
[Fixed single letter variable name legibility problem -- broonie]
Signed-off-by: Timur Tabi <timur@freescale.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/codecs/wm8776.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c index 0cfbfc1dc093..5b17627aab0f 100644 --- a/sound/soc/codecs/wm8776.c +++ b/sound/soc/codecs/wm8776.c @@ -216,8 +216,6 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream, int ratio_shift, master; int i; - iface = 0; - switch (dai->driver->id) { case WM8776_DAI_DAC: iface_reg = WM8776_DACIFCTRL; @@ -233,20 +231,23 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - /* Set word length */ - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S16_LE: + switch (snd_pcm_format_width(params_format(params))) { + case 16: + iface = 0; + case 20: + iface = 0x10; break; - case SNDRV_PCM_FORMAT_S20_3LE: - iface |= 0x10; + case 24: + iface = 0x20; break; - case SNDRV_PCM_FORMAT_S24_LE: - iface |= 0x20; - break; - case SNDRV_PCM_FORMAT_S32_LE: - iface |= 0x30; + case 32: + iface = 0x30; break; + default: + dev_err(codec->dev, "Unsupported sample size: %i\n", + snd_pcm_format_width(params_format(params))); + return -EINVAL; } /* Only need to set MCLK/LRCLK ratio if we're master */ |