Commit d1dc698a authored by Timur Tabi's avatar Timur Tabi Committed by Mark Brown

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: default avatarTimur Tabi <timur@freescale.com>
Acked-by: default avatarLiam Girdwood <lrg@ti.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent cc2115cb
...@@ -216,8 +216,6 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream, ...@@ -216,8 +216,6 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream,
int ratio_shift, master; int ratio_shift, master;
int i; int i;
iface = 0;
switch (dai->driver->id) { switch (dai->driver->id) {
case WM8776_DAI_DAC: case WM8776_DAI_DAC:
iface_reg = WM8776_DACIFCTRL; iface_reg = WM8776_DACIFCTRL;
...@@ -233,20 +231,23 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream, ...@@ -233,20 +231,23 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
/* Set word length */ /* Set word length */
switch (params_format(params)) { switch (snd_pcm_format_width(params_format(params))) {
case SNDRV_PCM_FORMAT_S16_LE: case 16:
iface = 0;
case 20:
iface = 0x10;
break; break;
case SNDRV_PCM_FORMAT_S20_3LE: case 24:
iface |= 0x10; iface = 0x20;
break; break;
case SNDRV_PCM_FORMAT_S24_LE: case 32:
iface |= 0x20; iface = 0x30;
break;
case SNDRV_PCM_FORMAT_S32_LE:
iface |= 0x30;
break; 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 */ /* Only need to set MCLK/LRCLK ratio if we're master */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment