alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: support sample sizes properly in the WM8776 codec driver
@ 2011-09-13 17:59 Timur Tabi
  2011-09-13 17:59 ` [PATCH 2/3] ASoC: support all possible sample rates in the WM8776 driver Timur Tabi
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Timur Tabi @ 2011-09-13 17:59 UTC (permalink / raw)
  To: broonie, lrg, alsa-devel

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).

Signed-off-by: Timur Tabi <timur@freescale.com>
---
 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 8e7953b..ad6f0fa 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -215,8 +215,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;
@@ -232,20 +230,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:
+	i = snd_pcm_format_width(params_format(params));
+	switch (i) {
+	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", i);
+		return -EINVAL;
 	}
 
 	/* Only need to set MCLK/LRCLK ratio if we're master */
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2011-09-17 13:04 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-13 17:59 [PATCH 1/3] ASoC: support sample sizes properly in the WM8776 codec driver Timur Tabi
2011-09-13 17:59 ` [PATCH 2/3] ASoC: support all possible sample rates in the WM8776 driver Timur Tabi
2011-09-14 12:36   ` Liam Girdwood
2011-09-15 10:24   ` Mark Brown
2011-09-15 15:08     ` Timur Tabi
2011-09-15 22:38       ` Mark Brown
2011-09-15 23:06         ` Tabi Timur-B04825
2011-09-15 23:49           ` Mark Brown
2011-09-16 13:48             ` Timur Tabi
2011-09-17 13:04               ` Mark Brown
2011-09-13 17:59 ` [PATCH 3/3] ASoC: improve asynchronous mode support in the fsl_ssi driver Timur Tabi
2011-09-14 12:37   ` Liam Girdwood
2011-09-15 23:06   ` Mark Brown
2011-09-15 23:49   ` Mark Brown
2011-09-14 12:35 ` [PATCH 1/3] ASoC: support sample sizes properly in the WM8776 codec driver Liam Girdwood
2011-09-14 21:51   ` Timur Tabi
2011-09-15 10:26     ` Mark Brown
2011-09-15 11:28       ` Tabi Timur-B04825
2011-09-15 13:21 ` Mark Brown
2011-09-15 15:16   ` Timur Tabi
2011-09-15 23:38     ` Mark Brown
2011-09-16  9:07 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).