[alsa-devel] Question about soc-utils

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Wed Dec 6 06:26:54 CET 2017


Hi Mark, again

> > > But, soc-utils::snd_soc_params_to_frame_size()
> > > is using snd_pcm_format_width() instead of snd_pcm_format_physical_width(),
> > > In "2ch x 24bit data with 32bit width" case, above "frame_bits" will be "64",
> > > but, below "frame size" will be "48", I think.
> > > Am I wrong ?
> > 
> > That's just an oversight, it should be using the sample size.

The original commit was below.
It seems original code was also assuming format width.
Was this also oversight ?
format_width -> physical_width changes meaning, I think...

--------------------------------------------------------
commit 3d8b2ce01b2de7c3c5cbf18b9b97d26cfaf11c14
Author: Mark Brown <broonie at opensource.wolfsonmicro.com>
Date:   Mon Jan 31 20:14:38 2011 +0000

    ASoC: Use snd_pcm_format_width() in snd_soc_params_to_frame_size()
    
    Signed-off-by: Mark Brown <broonie at opensource.wolfsonmicro.com>
    Acked-by: Liam Girdwood <lrg at slimlogic.co.uk>

diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c
index 1d07b93..3f45e6a 100644
--- a/sound/soc/soc-utils.c
+++ b/sound/soc/soc-utils.c
@@ -28,26 +28,9 @@ int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params)
 {
 	int sample_size;
 
-	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_LE:
-	case SNDRV_PCM_FORMAT_S16_BE:
-		sample_size = 16;
-		break;
-	case SNDRV_PCM_FORMAT_S20_3LE:
-	case SNDRV_PCM_FORMAT_S20_3BE:
-		sample_size = 20;
-		break;
-	case SNDRV_PCM_FORMAT_S24_LE:
-	case SNDRV_PCM_FORMAT_S24_BE:
-		sample_size = 24;
-		break;
-	case SNDRV_PCM_FORMAT_S32_LE:
-	case SNDRV_PCM_FORMAT_S32_BE:
-		sample_size = 32;
-		break;
-	default:
-		return -ENOTSUPP;
-	}
+	sample_size = snd_pcm_format_width(params_format(params));
+	if (sample_size < 0)
+		return sample_size;
 
 	return snd_soc_calc_frame_size(sample_size, params_channels(params),
 				       1);
--------------------------------------------------------



Best regards
---
Kuninori Morimoto


More information about the Alsa-devel mailing list