aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8776.c
diff options
context:
space:
mode:
authorTimur Tabi <timur@freescale.com>2011-09-13 13:59:35 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-09-16 05:06:31 -0400
commitd1dc698a54259cb454284456483b45f67c865cf8 (patch)
treed85f49ae885e1995d84fb4708ec39859832443e0 /sound/soc/codecs/wm8776.c
parentcc2115cbfc63da72890160da01608b3189dd1b74 (diff)
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>
Diffstat (limited to 'sound/soc/codecs/wm8776.c')
-rw-r--r--sound/soc/codecs/wm8776.c25
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,
216 int ratio_shift, master; 216 int ratio_shift, master;
217 int i; 217 int i;
218 218
219 iface = 0;
220
221 switch (dai->driver->id) { 219 switch (dai->driver->id) {
222 case WM8776_DAI_DAC: 220 case WM8776_DAI_DAC:
223 iface_reg = WM8776_DACIFCTRL; 221 iface_reg = WM8776_DACIFCTRL;
@@ -233,20 +231,23 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream,
233 return -EINVAL; 231 return -EINVAL;
234 } 232 }
235 233
236
237 /* Set word length */ 234 /* Set word length */
238 switch (params_format(params)) { 235 switch (snd_pcm_format_width(params_format(params))) {
239 case SNDRV_PCM_FORMAT_S16_LE: 236 case 16:
237 iface = 0;
238 case 20:
239 iface = 0x10;
240 break; 240 break;
241 case SNDRV_PCM_FORMAT_S20_3LE: 241 case 24:
242 iface |= 0x10; 242 iface = 0x20;
243 break; 243 break;
244 case SNDRV_PCM_FORMAT_S24_LE: 244 case 32:
245 iface |= 0x20; 245 iface = 0x30;
246 break;
247 case SNDRV_PCM_FORMAT_S32_LE:
248 iface |= 0x30;
249 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;
250 } 251 }
251 252
252 /* Only need to set MCLK/LRCLK ratio if we're master */ 253 /* Only need to set MCLK/LRCLK ratio if we're master */