* what is period_size, buffer_size and boundary size, i confuse them
@ 2012-12-09 14:37 l9jj
2012-12-09 16:22 ` Clemens Ladisch
0 siblings, 1 reply; 5+ messages in thread
From: l9jj @ 2012-12-09 14:37 UTC (permalink / raw)
To: Alsa-devel
can anyone help me to figure out the concepts between period_size ,buffer_size and boundary size?
n * period_size = buffer_size?
m * buffer_size = boundary_size?
and how the dma buffer mapped to the alsa buffer?
thank you .
br
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: what is period_size, buffer_size and boundary size, i confuse them
2012-12-09 14:37 l9jj
@ 2012-12-09 16:22 ` Clemens Ladisch
0 siblings, 0 replies; 5+ messages in thread
From: Clemens Ladisch @ 2012-12-09 16:22 UTC (permalink / raw)
To: alsa-devel
l9jj wrote:
> can anyone help me to figure out the concepts between period_size ,buffer_size and boundary size?
> n * period_size = buffer_size?
Yes. On many devices, n is not required to be an integer.
> m * buffer_size = boundary_size?
Yes, where m is very big. In applications, the actual value of the boundary
size does not matter (except as a special value for some sw params).
> and how the dma buffer mapped to the alsa buffer?
The DMA buffer _is_ the ALSA buffer.
Regards,
Clemens
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: what is period_size, buffer_size and boundary size, i confuse them
@ 2012-12-10 8:09 l9jj
2012-12-10 8:24 ` Clemens Ladisch
0 siblings, 1 reply; 5+ messages in thread
From: l9jj @ 2012-12-10 8:09 UTC (permalink / raw)
To: Clemens Ladisch, alsa-devel
thank you very much.
but,
(1)what is the relationship between DMA buffer size and the boundary
size?does the variable buffer_size equal to DMA size?
(2)how the pos>buffer_size will happen in the interface snd_pcm_update_hw_ptr0()? the variable pos is in the range of DMA_size,it can not bigger than the buffer_size.it blocked me.
thanks a lot.
在 2012-12-10 00:23:55, Clemens Ladisch <clemens@ladisch.de>写道:
l9jj wrote:
> can anyone help me to figure out the concepts between period_size ,buffer_size and boundary size?
> n * period_size = buffer_size?
Yes. On many devices, n is not required to be an integer.
> m * buffer_size = boundary_size?
Yes, where m is very big. In applications, the actual value of the boundary
size does not matter (except as a special value for some sw params).
> and how the dma buffer mapped to the alsa buffer?
The DMA buffer _is_ the ALSA buffer.
Regards,
Clemens
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
l9jj@163.com
——网易邮箱手机客户端——
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: what is period_size, buffer_size and boundary size, i confuse them
2012-12-10 8:09 what is period_size, buffer_size and boundary size, i confuse them l9jj
@ 2012-12-10 8:24 ` Clemens Ladisch
0 siblings, 0 replies; 5+ messages in thread
From: Clemens Ladisch @ 2012-12-10 8:24 UTC (permalink / raw)
To: l9jj; +Cc: alsa-devel
l9jj@163.com wrote:
> does the variable buffer_size equal to DMA size?
Yes.
> (2)how the pos>buffer_size will happen in the interface snd_pcm_update_hw_ptr0()?
It happens when your driver has a bug. The .pointer callback always must
return value that is inside the DMA buffer.
Regards,
Clemens
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: what is period_size, buffer_size and boundary size, i confuse them
@ 2012-12-10 9:19 l9jj
0 siblings, 0 replies; 5+ messages in thread
From: l9jj @ 2012-12-10 9:19 UTC (permalink / raw)
To: Clemens Ladisch; +Cc: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 3098 bytes --]
thank you very much for your help. i got another question in the interface snd_pcm_update_hw_ptr0(). The reference code is below. (1)i know that the result of representation (hdelta * HZ) / runtime->rate means the delta jiffies which spend on moving the data from the new_hw_ptr to the old_hw_ptr in the dma buffer. (2)and the jdelta represents the interval jiffies between now and last time enter here.
(3)the question is why can we think there is more than one interrupt has lost across comparing the two variables size? (4)and if the compare idear setup that means one interrupt will take jdelta jiffies in time,so if someone is bigger it we can know that.is it true? (5)if the (4) is correct, why do not use the representation (runtime->period_size * HZ) / runtime->rate) as the interrupt interval, because it is fixed and the jdelta is not. (6)why plus the HZ/100 after jdelta and (runtime->period_size * HZ) / runtime->rate) ? for ensuring have enought time? HZ ==> 1 s HZ/1000 ===> 1 ms HZ/100 ===> 10 ms ? =================================reference code start ====================================> /* Skip the jiffies check for hardwares with BATCH flag. * Such hardware usually just increases the position at each IRQ, * thus it can't give any strange position. */if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) goto no_jiffies_check; hdelta = delta; if (hdelta < runtime->delay) goto no_jiffies_check; hdelta -= runtime->delay; jdelta = jiffies - runtime->hw_ptr_jiffies; if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { delta = jdelta /(((runtime->period_size * HZ) / runtime->rate) + HZ/100); /* move new_hw_ptr according jiffies not pos variable */new_hw_ptr = old_hw_ptr; hw_base = delta; /* use loop to avoid checks for delta overflows *//* the delta value is small or zero in most cases */while (delta > 0) { new_hw_ptr += runtime->period_size; if (new_hw_ptr >= runtime->boundary) new_hw_ptr -= runtime->boundary; delta--; } /* align hw_base to buffer_size */hw_ptr_error(substream, "hw_ptr skipping! %s" "(pos=%ld, delta=%ld, period=%ld, " "jdelta=%lu/%lu/%lu, hw_ptr=%ld/%ld)\n", in_interrupt ? "[Q] " : "", (long)pos, (long)hdelta, (long)runtime->period_size, jdelta, ((hdelta * HZ) / runtime->rate), hw_base, (unsigned long)old_hw_ptr, (unsigned long)new_hw_ptr); /* reset values to proper state */delta = 0; hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size); } <======================================end =================================================== Best Regards.
在 2012-12-10 16:24:59, Clemens Ladisch <clemens@ladisch.de>写道:
l9jj@163.com wrote:
> does the variable buffer_size equal to DMA size?
Yes.
> (2)how the pos>buffer_size will happen in the interface snd_pcm_update_hw_ptr0()?
It happens when your driver has a bug. The .pointer callback always must
return value that is inside the DMA buffer.
Regards,
Clemens
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
l9jj@163.com
——网易邮箱手机客户端——
[-- Attachment #2: emailtxt.txt --]
[-- Type: application/octet-stream, Size: 2675 bytes --]
thank you very much for your help.
i got another question in the interface snd_pcm_update_hw_ptr0().
The reference code is below.
(1)i know that the result of representation (hdelta * HZ) / runtime->rate means the delta jiffies which spend on moving the data from the new_hw_ptr to the old_hw_ptr in the dma buffer.
(2)and the jdelta represents the interval jiffies between now and last time enter here.
(3)the question is why can we think there is more than one interrupt has lost across comparing the two variables size?
(4)and if the compare idear setup that means one interrupt will take jdelta jiffies in time,so if someone is bigger it we can know that.is it true?
(5)if the (4) is correct, why do not use the representation (runtime->period_size * HZ) / runtime->rate) as the interrupt interval, because it is fixed and the jdelta is not.
(6)why plus the HZ/100 after jdelta and (runtime->period_size * HZ) / runtime->rate) ? for ensuring have enought time?
HZ ==> 1 s
HZ/1000 ===> 1 ms
HZ/100 ===> 10 ms ?
=================================reference code start ====================================>
/* Skip the jiffies check for hardwares with BATCH flag.
* Such hardware usually just increases the position at each IRQ,
* thus it can't give any strange position.
*/
if (runtime->hw.info & SNDRV_PCM_INFO_BATCH)
goto no_jiffies_check;
hdelta = delta;
if (hdelta < runtime->delay)
goto no_jiffies_check;
hdelta -= runtime->delay;
jdelta = jiffies - runtime->hw_ptr_jiffies;
if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) {
delta = jdelta /
(((runtime->period_size * HZ) / runtime->rate)
+ HZ/100);
/* move new_hw_ptr according jiffies not pos variable */
new_hw_ptr = old_hw_ptr;
hw_base = delta;
/* use loop to avoid checks for delta overflows */
/* the delta value is small or zero in most cases */
while (delta > 0) {
new_hw_ptr += runtime->period_size;
if (new_hw_ptr >= runtime->boundary)
new_hw_ptr -= runtime->boundary;
delta--;
}
/* align hw_base to buffer_size */
hw_ptr_error(substream,
"hw_ptr skipping! %s"
"(pos=%ld, delta=%ld, period=%ld, "
"jdelta=%lu/%lu/%lu, hw_ptr=%ld/%ld)\n",
in_interrupt ? "[Q] " : "",
(long)pos, (long)hdelta,
(long)runtime->period_size, jdelta,
((hdelta * HZ) / runtime->rate), hw_base,
(unsigned long)old_hw_ptr,
(unsigned long)new_hw_ptr);
/* reset values to proper state */
delta = 0;
hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size);
}
<======================================end ===================================================
Best Regards.
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-12-10 9:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-10 8:09 what is period_size, buffer_size and boundary size, i confuse them l9jj
2012-12-10 8:24 ` Clemens Ladisch
-- strict thread matches above, loose matches on Subject: below --
2012-12-10 9:19 l9jj
2012-12-09 14:37 l9jj
2012-12-09 16:22 ` Clemens Ladisch
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.