alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] ASoC: Apply msbits constraint for sample size bigger than the msbits
@ 2012-01-18 15:05 Peter Ujfalusi
  2012-01-18 15:29 ` Mark Brown
  2012-01-18 15:35 ` Clemens Ladisch
  0 siblings, 2 replies; 11+ messages in thread
From: Peter Ujfalusi @ 2012-01-18 15:05 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood; +Cc: alsa-devel

In order to avoid confusing the applications with msbits bigger
than the selected sample size apply the msbits constraint only
to sample seze bigger than the requested msbits.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---

Hi Mark,

Converted to use while loop.
We run the loop as long as the sample size is bigger than the requested
msbits.
Most of the drivers require 24/32 configuration, so not point of looping
for smaller sample sizes.

Regards,
Peter

 sound/soc/soc-pcm.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 8bb1793..ef41a39 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -68,13 +68,14 @@ static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream,
  * like the DAC/ADC resolution to use but there isn't right now.
  */
 static int sample_sizes[] = {
-	8, 16, 24, 32,
+	32, 24, 16, 8,
 };
 
 static void soc_pcm_apply_msb(struct snd_pcm_substream *substream,
 			      struct snd_soc_dai *dai)
 {
-	int ret, i, bits;
+	int ret, bits;
+	int i = 0;
 
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
 		bits = dai->driver->playback.sig_bits;
@@ -84,14 +85,14 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream,
 	if (!bits)
 		return;
 
-	for (i = 0; i < ARRAY_SIZE(sample_sizes); i++) {
-		ret = snd_pcm_hw_constraint_msbits(substream->runtime,
-						   0, sample_sizes[i],
-						   bits);
+	/* Apply constraint only for sample size bigger than requested msbits */
+	while (sample_sizes[i] > bits && i < ARRAY_SIZE(sample_sizes)) {
+		ret = snd_pcm_hw_constraint_msbits(substream->runtime, 0,
+						   sample_sizes[i], bits);
 		if (ret != 0)
-			dev_warn(dai->dev,
-				 "Failed to set MSB %d/%d: %d\n",
+			dev_warn(dai->dev, "Failed to set MSB %d/%d: %d\n",
 				 bits, sample_sizes[i], ret);
+		i++;
 	}
 }
 
-- 
1.7.8.3

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

end of thread, other threads:[~2012-01-19 15:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-18 15:05 [PATCH v5] ASoC: Apply msbits constraint for sample size bigger than the msbits Peter Ujfalusi
2012-01-18 15:29 ` Mark Brown
2012-01-18 16:43   ` Peter Ujfalusi
2012-01-18 17:46     ` Mark Brown
2012-01-19  8:27       ` Peter Ujfalusi
2012-01-19 10:48         ` Mark Brown
2012-01-19 12:40           ` Peter Ujfalusi
2012-01-19 15:39             ` Mark Brown
2012-01-18 15:35 ` Clemens Ladisch
2012-01-18 15:43   ` Peter Ujfalusi
2012-01-18 15:49     ` Peter Ujfalusi

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