Skip to contentSkip to conversation

buffer/period constraint

DISCUSSION [email protected] 4 participants 4 messages Jul 20, 2004 – Jul 21, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

Is the a way to force the period/buffer sizes so that they have an integral relationship?

I've seen some cases where the buffer size is 1 or 2 frames bigger than n*period_size, so I am not sure how the driver is supposed to handle that. It ends causing noise the output for now, but I'd like to avoid it.

Second, is there an easy way to find the current position of the DMA being used?

Thanks,

Francisco

-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click

#1 lore raw
Quoted 4 lines · On Tue, 20 Jul 2004 [email protected] wrote:

Hi,

Is the a way to force the period/buffer sizes so that they have an integral relationship ?

There are many examples:

grep -r snd_pcm_hw_constraint_integer .
[...]
./alsa-kernel/pci/intel8x0.c: if ((err =
snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) [...]

Quoted 2 lines

Second, is there an easy way to find the current position of the DMA being used ?

It depends on the hardware... Usually you only have to read a value from a register.

--
Giuliano.

-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click

#2 lore raw
In reply to [email protected]
Quoted 3 lines · [email protected] wrote:

[...]
I've seen some cases where the buffer size is 1 or 2 frames bigger than n*period_size,

The hardware must generate interrupts at period boundaries. In these cases, the interrupts would happen at different positions in the buffer, over time.

Quoted 1 line

so I am not sure how the driver is supposed to handle that.

The driver mustn't allow this unless the hardware can manage it.

Quoted 2 lines

Second, is there an easy way to find the current position of the DMA being used?

In the good ol' times of the ISA bus, the DMA controller knew the current position. On the PCI bus, the DMA is controlled by the card itself, so the card should have a register for the current position. If there isn't such a register, you have to count interrupts (and hope that none are lost).

HTH
Clemens

-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click

#3 lore raw
Quoted 13 lines · Clemens Ladisch
Quoted 3 lines · [email protected] wrote:

[...]
I've seen some cases where the buffer size is 1 or 2 frames bigger than n*period_size,

The hardware must generate interrupts at period boundaries. In these cases, the interrupts would happen at different positions in the buffer, over time.

Quoted 1 line

so I am not sure how the driver is supposed to handle that.

The driver mustn't allow this unless the hardware can manage it.

Quoted 9 lines
Quoted 2 lines

Second, is there an easy way to find the current position of the DMA being used?

In the good ol' times of the ISA bus, the DMA controller knew the current position. On the PCI bus, the DMA is controlled by the card itself, so the card should have a register for the current position. If there isn't such a register, you have to count interrupts (and hope that none are lost).

Look at snd_pcm_update_hw_ptr_interrupt() in alsa-kernel/core/pcm_lib.c. This gets called by snd_pcm_period_elapsed(), which gets called by your interrupt handler. If you are trying to reverse engineer the allowed period sizes, this is a good place to start - do something that you think should set the period to N and then check the hw_ptr value in that function against what you think it should be.

If you have to count interrupts, it is pretty easy to figure out whether you are missing some. It does happen, a lot. I hacked the emu10k1 driver to do this, the code is pretty ugly but it does the trick.

Lee

-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click