All of lore.kernel.org
 help / color / mirror / Atom feed
* Question about soc-utils
@ 2017-12-05  8:01 Kuninori Morimoto
  2017-12-05 12:39 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2017-12-05  8:01 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark, ALSA SoC ML

In my understanding, "frame size" means "channel x physical width".
linux/sound/core/pcm_native.c :: snd_pcm_hw_params() is doing so

static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
			     struct snd_pcm_hw_params *params)
{
	...
=>	bits = snd_pcm_format_physical_width(runtime->format);
	runtime->sample_bits = bits;
=>	bits *= runtime->channels;
	runtime->frame_bits = bits;
	...
}

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 ?

int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params)
{
	int sample_size;

=>	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);
}


About "TDM slot", in my understanding it is TDM channel number.
TDM6 = 6ch = 6 slot, TDM8 = 8ch = 8 slot.
Am I wrong ??
I'm asking because soc-utils :: snd_soc_calc_bclk() / snd_soc_calc_frame_size()
have both "channles" and "slot" parameter.
What is this "tdm_slots" means ?

	int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots)
	int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots)

Best regards
---
Kuninori Morimoto

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

* Re: Question about soc-utils
  2017-12-05  8:01 Question about soc-utils Kuninori Morimoto
@ 2017-12-05 12:39 ` Mark Brown
  2017-12-06  0:06   ` Kuninori Morimoto
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2017-12-05 12:39 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA


[-- Attachment #1.1: Type: text/plain, Size: 402 bytes --]

On Tue, Dec 05, 2017 at 08:01:07AM +0000, Kuninori Morimoto wrote:

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

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: Question about soc-utils
  2017-12-05 12:39 ` Mark Brown
@ 2017-12-06  0:06   ` Kuninori Morimoto
  2017-12-06  5:26     ` Kuninori Morimoto
  0 siblings, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2017-12-06  0:06 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark

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

OK
will post fixup patch

Best regards
---
Kuninori Morimoto

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

* Re: Question about soc-utils
  2017-12-06  0:06   ` Kuninori Morimoto
@ 2017-12-06  5:26     ` Kuninori Morimoto
  2017-12-06 12:47       ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2017-12-06  5:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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@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@opensource.wolfsonmicro.com>
    Acked-by: Liam Girdwood <lrg@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

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

* Re: Question about soc-utils
  2017-12-06  5:26     ` Kuninori Morimoto
@ 2017-12-06 12:47       ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2017-12-06 12:47 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA


[-- Attachment #1.1: Type: text/plain, Size: 636 bytes --]

On Wed, Dec 06, 2017 at 05:26:54AM +0000, Kuninori Morimoto wrote:

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

> -	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;

Ah, sorry - I misread what you were saying.  The above is the intention.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

end of thread, other threads:[~2017-12-06 12:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-05  8:01 Question about soc-utils Kuninori Morimoto
2017-12-05 12:39 ` Mark Brown
2017-12-06  0:06   ` Kuninori Morimoto
2017-12-06  5:26     ` Kuninori Morimoto
2017-12-06 12:47       ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.