Skip to content

Commit d1dc698

Browse files
Timur Tabibroonie
authored andcommitted
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 <[email protected]> Acked-by: Liam Girdwood <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent cc2115c commit d1dc698

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

sound/soc/codecs/wm8776.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream,
216216
int ratio_shift, master;
217217
int i;
218218

219-
iface = 0;
220-
221219
switch (dai->driver->id) {
222220
case WM8776_DAI_DAC:
223221
iface_reg = WM8776_DACIFCTRL;
@@ -233,20 +231,23 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream,
233231
return -EINVAL;
234232
}
235233

236-
237234
/* Set word length */
238-
switch (params_format(params)) {
239-
case SNDRV_PCM_FORMAT_S16_LE:
235+
switch (snd_pcm_format_width(params_format(params))) {
236+
case 16:
237+
iface = 0;
238+
case 20:
239+
iface = 0x10;
240240
break;
241-
case SNDRV_PCM_FORMAT_S20_3LE:
242-
iface |= 0x10;
241+
case 24:
242+
iface = 0x20;
243243
break;
244-
case SNDRV_PCM_FORMAT_S24_LE:
245-
iface |= 0x20;
246-
break;
247-
case SNDRV_PCM_FORMAT_S32_LE:
248-
iface |= 0x30;
244+
case 32:
245+
iface = 0x30;
249246
break;
247+
default:
248+
dev_err(codec->dev, "Unsupported sample size: %i\n",
249+
snd_pcm_format_width(params_format(params)));
250+
return -EINVAL;
250251
}
251252

252253
/* Only need to set MCLK/LRCLK ratio if we're master */

0 commit comments

Comments
 (0)