Skip to contentSkip to conversation

How can I make sure the period size is a multiple of 16?

DISCUSSION Timur Tabi 5 participants 7 messages Sep 4, 2007 – Sep 6, 2007

lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

To work around a hardware issue, my ASoC driver requires the period size to be a multiple of 16. What is the best way to ensure that?

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
#1 lore raw
Quoted 2 lines · On Wednesday 05 September 2007 10:50:31 Timur Tabi wrote:

To work around a hardware issue, my ASoC driver requires the period size to be a multiple of 16. What is the best way to ensure that?

Well, I was going to refer you to
http://www-old.alsa-project.org/~iwai/writing-an-alsa-driver/index.html
but I just get a blank page today.

Set snd_pcm_hardware.period_bytes_min to 16 or is that 16 * samplesize?

You need to add some constraints to your driver, in the open callback. E.g.
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 16);

List of hwparams that can be constrained is in asound.h
List of constraint helpers in pcm.h, or grep for snd_pcm_hw_constraint to see usage examples.

--
Eliot

#2 lore raw
Quoted 1 line · Eliot Blennerhassett

Set snd_pcm_hardware.period_bytes_min to 16 or is that 16 * samplesize?

This value is measured in bytes.

Quoted 1 line

snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 16);

This parameter is measured in frames.

HTH
Clemens

#3 lore raw
Quoted 8 lines · Clemens Ladisch
Quoted 1 line · Eliot Blennerhassett

Set snd_pcm_hardware.period_bytes_min to 16 or is that 16 * samplesize?

This value is measured in bytes.

Quoted 1 line

snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 16);

This parameter is measured in frames.

Isn't SNDRV_PCM_HW_PARAM_PERIOD_SIZE measured in frames, and SNDRV_PCM_HW_PARAM_PERIOD_BYTES in bytes?

#4 lore raw

At Wed, 5 Sep 2007 02:55:32 -0700 (PDT),

Quoted 5 lines · Trent Piepho
Quoted 3 lines · Clemens Ladisch
Quoted 1 line · Eliot Blennerhassett

Set snd_pcm_hardware.period_bytes_min to 16 or is that 16 * samplesize?

Quoted 8 lines
Quoted 5 lines

This value is measured in bytes.

Quoted 1 line

snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 16);

This parameter is measured in frames.

Isn't SNDRV_PCM_HW_PARAM_PERIOD_SIZE measured in frames, and SNDRV_PCM_HW_PARAM_PERIOD_BYTES in bytes?

Yes, *_BYTES is for bytes.

I don't know what happens with www-old.alsa-project.org. Anyway, I'd love to move back the pages to www.alsa-project.org, if possible. If that's difficult due to a technical reason, I'm willing to move the stuff to other web site.

Jaroslav, what is the status?

thanks,

Takashi

author
#5 lore raw
In reply to Eliot Blennerhassett
Quoted 3 lines · Eliot Blennerhassett

You need to add some constraints to your driver, in the open callback. E.g.
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 16);

Thanks. snd_pcm_hw_constraint_step() is not documented anywhere, and the comments in the source code don't provide any clues, either. Even the "ALSA Driver API" document just lists the function, but doesn't actually tell you what it does.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
#6 lore raw
Quoted 10 lines · Timur Tabi
Quoted 3 lines · Eliot Blennerhassett

You need to add some constraints to your driver, in the open callback. E.g.
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 16);

Thanks. snd_pcm_hw_constraint_step() is not documented anywhere, and the comments in the source code don't provide any clues, either. Even the "ALSA Driver API" document just lists the function, but doesn't actually tell you what it does.

I still haven't figured out what the "condition bits" do. It's always 0 every time one of the constraint functions are called. I looked in the ALSA core code, and it seems that if you specify some condition bits they must match some flag bits in the hw params for the constraint to apply. But the flags bits just get copied from user space, so there is no clue in the kernel code what they are or what they do.