playback write error (DMA or IRQ trouble)
Can anyone give me a clue as to when i would get such an error?
Signature · 1 line
-Harsha
At Mon, 2 Jun 2008 12:39:31 +0530,
Quoted 2 lines · Harsha priya gupta
Can anyone give me a clue as to when i would get such an error?
... only if you give more clue what exactly you did.
In general, it implies that an interrupt isn't issued properly at PCM period boundary.
Takashi
I implemented the copy function and immediately transfered the user block data to the hardware.
Correct me if am wrong;
.pointer implementation - passes the current buffer pointer. When the .pointer function returns the size of the buffer = user buffer size logically I need to expect the hardware to send an interrupt because buffer is consumed and I should call snd_pcm_period_elapsed after that.
what would happen if i call the snd_pcm_period_elapsed from the pointer function once the buffer is consumed from hardware. Would that be right? This is what i am trying to do
Quoted 13 lines · Takashi Iwai
At Mon, 2 Jun 2008 12:39:31 +0530,
Quoted 2 lines · Harsha priya gupta
Can anyone give me a clue as to when i would get such an error?
... only if you give more clue what exactly you did.
In general, it implies that an interrupt isn't issued properly at PCM period boundary.
Takashi
Signature · 1 line
-Harsha
At Mon, 2 Jun 2008 13:26:01 +0530,
Quoted 10 lines · Harsha priya gupta
I implemented the copy function and immediately transfered the user block data to the hardware.
Correct me if am wrong;
.pointer implementation - passes the current buffer pointer. When the .pointer function returns the size of the buffer = user buffer size logically I need to expect the hardware to send an interrupt because buffer is consumed and I should callsnd_pcm_period_elapsedafter that.
Quoted 3 lines
what would happen if i call the
snd_pcm_period_elapsedfrom the pointer function once the buffer is consumed from hardware. Would that be right? This is what i am trying to do
The logic is reversed.
The pointer callback is a passive one that does nothing but returning the current h/w buffer position. This is called either from snd_pcm_period_elapsed() or at the PCM status update.
You must call snd_pcm_period_elapsed() somewhere in your driver *explicitly* at the timing that one period is finished. Usually, this is done in an IRQ handler the h/w generates at the period ("fragment", "half-buffer", or whatever) boundary.
And note that the valid value from the pointer callback is between 0 and buffer_size-1 as it handles the buffer as a ring-buffer. The value buffer_size is invalid.
Takashi
Quoted 18 lines · Takashi Iwai
At Mon, 2 Jun 2008 12:39:31 +0530,
Harsha priya gupta wrote:
>
> Can anyone give me a clue as to when i would get such an error?... only if you give more clue what exactly you did.
In general, it implies that an interrupt isn't issued properly at PCM period boundary.
Takashi
--
-Harsha
Quick question
Quoted 1 line
From my copy function after I pass the buffer to HW, what would happen if i
call snd_pcm_period_elapsed.
Quoted 56 lines · Takashi Iwai
At Mon, 2 Jun 2008 13:26:01 +0530,
Quoted 2 lines · Harsha priya gupta
I implemented the copy function and immediately transfered the user block
data
Quoted 4 lines
to the hardware.
Correct me if am wrong;
.pointer implementation - passes the current buffer pointer. When the.pointer
Quoted 1 line
function returns the size of the buffer = user buffer size logically I
need to
Quoted 5 lines
expect the hardware to send an interrupt because buffer is consumed and I should call
snd_pcm_period_elapsedafter that.what would happen if i call the
snd_pcm_period_elapsedfrom the pointer function once the buffer is consumed from hardware. Would that be right?This
Quoted 1 line
is what i am trying to do
The logic is reversed.
The pointer callback is a passive one that does nothing but returning the current h/w buffer position. This is called either fromsnd_pcm_period_elapsed()or at the PCM status update.You must call
snd_pcm_period_elapsed()somewhere in your driver *explicitly* at the timing that one period is finished. Usually, this is done in an IRQ handler the h/w generates at the period ("fragment", "half-buffer", or whatever) boundary.And note that the valid value from the pointer callback is between 0 and buffer_size-1 as it handles the buffer as a ring-buffer. The value
buffer_sizeis invalid.Takashi
Quoted 18 lines · Takashi Iwai
At Mon, 2 Jun 2008 12:39:31 +0530,
Harsha priya gupta wrote:
>
> Can anyone give me a clue as to when i would get such an error?... only if you give more clue what exactly you did.
In general, it implies that an interrupt isn't issued properly at PCM period boundary.
Takashi
--
-Harsha
Signature · 1 line
-Harsha
At Mon, 2 Jun 2008 14:33:14 +0530,
Quoted 5 lines · Harsha priya gupta
Quick question
From my copy function after I pass the buffer to HW, what would happen if i call
snd_pcm_period_elapsed.
It's invalid and a misdesign.
I guess you are misunderstanding about when to callsnd_pcm_period_elapsed(). snd_pcm_period_elapsed() is called when one period of samples on the hardware is *processed*. It doesn't mean that the samples are transferred to the hardware.
Suppose that you have period_size = 48000 (frames) for 48kHz samples. Then, the first snd_pcm_period_epased() shall be called just one second after starting the PCM stream. The second call be another one second later, and so on. It doesn't matter how quick the copy to h/w is done (via copy callback).
Takashi
Quoted 62 lines · Takashi Iwai
At Mon, 2 Jun 2008 13:26:01 +0530,
Harsha priya gupta wrote:
>
> I implemented the copy function and immediately transfered the user block data
> to the hardware.
>
> Correct me if am wrong;
> .pointer implementation - passes the current buffer pointer. When the .pointer
> function returns the size of the buffer = user buffer size logically I need to
> expect the hardware to send an interrupt because buffer is consumed and I > should callsnd_pcm_period_elapsedafter that.
>
> what would happen if i call thesnd_pcm_period_elapsedfrom the pointer > function once the buffer is consumed from hardware. Would that be right?
This
> is what i am trying to doThe logic is reversed.
The pointer callback is a passive one that does nothing but returning the current h/w buffer position. This is called either fromsnd_pcm_period_elapsed()or at the PCM status update.You must call
snd_pcm_period_elapsed()somewhere in your driver *explicitly* at the timing that one period is finished. Usually, this is done in an IRQ handler the h/w generates at the period ("fragment", "half-buffer", or whatever) boundary.And note that the valid value from the pointer callback is between 0 and buffer_size-1 as it handles the buffer as a ring-buffer. The value
buffer_sizeis invalid.Takashi
> On Mon, Jun 2, 2008 at 1:02 PM, Takashi Iwai <[email protected]> wrote:
>
> At Mon, 2 Jun 2008 12:39:31 +0530,
> Harsha priya gupta wrote:
> >
> > Can anyone give me a clue as to when i would get such an error?
>
> ... only if you give more clue what exactly you did.
>
> In general, it implies that an interrupt isn't issued properly at PCM
> period boundary.
>
> Takashi
>
> --
> -Harsha
>
>--
-Harsha
Say if my hardware is such that it shall interrupt only after it has processed entire sample and not ever period or sample. What will ensure that i get my next buffer down? Will calling the snd_pcm_period_elapsed in the interrupt function help?
Quoted 99 lines · Takashi Iwai
At Mon, 2 Jun 2008 14:33:14 +0530,
Quoted 4 lines · Harsha priya gupta
Quick question
From my copy function after I pass the buffer to HW, what would happen if
i
Quoted 1 line
call
snd_pcm_period_elapsed.It's invalid and a misdesign.
I guess you are misunderstanding about when to
callsnd_pcm_period_elapsed().snd_pcm_period_elapsed()is called when one period of samples on the hardware is *processed*. It doesn't mean that the samples are transferred to the hardware.Suppose that you have
period_size= 48000 (frames) for 48kHz samples. Then, the firstsnd_pcm_period_epased()shall be called just one second after starting the PCM stream. The second call be another one second later, and so on. It doesn't matter how quick the copy to h/w is done (via copy callback).Takashi
Quoted 7 lines · Takashi Iwai
At Mon, 2 Jun 2008 13:26:01 +0530,
Harsha priya gupta wrote:
>
> I implemented the copy function and immediately transfered the userblock
Quoted 5 lines
data
> to the hardware.
>
> Correct me if am wrong;
> .pointer implementation - passes the current buffer pointer. Whenthe
Quoted 2 lines
.pointer
> function returns the size of the buffer = user buffer sizelogically I
Quoted 2 lines
need to
> expect the hardware to send an interrupt because buffer is consumedand I
Quoted 3 lines
Quoted 3 lines
should call
snd_pcm_period_elapsedafter that.what would happen if i call the
snd_pcm_period_elapsedfrom thepointer
Quoted 1 line
Quoted 1 line
function once the buffer is consumed from hardware. Would that be
right?
Quoted 10 lines
This
> is what i am trying to doThe logic is reversed.
The pointer callback is a passive one that does nothing but returning the current h/w buffer position. This is called either fromsnd_pcm_period_elapsed()or at the PCM status update.You must call
snd_pcm_period_elapsed()somewhere in your driver *explicitly* at the timing that one period is finished. Usually,this
Quoted 1 line
is done in an IRQ handler the h/w generates at the period
("fragment",
Quoted 9 lines
"half-buffer", or whatever) boundary.
And note that the valid value from the pointer callback is between 0 and buffer_size-1 as it handles the buffer as a ring-buffer. The value
buffer_sizeis invalid.Takashi
> On Mon, Jun 2, 2008 at 1:02 PM, Takashi Iwai <[email protected]>
Quoted 5 lines · wrote:
Quoted 5 lines
At Mon, 2 Jun 2008 12:39:31 +0530,
Harsha priya gupta wrote:
>
> Can anyone give me a clue as to when i would get such anerror?
Quoted 4 lines
Quoted 4 lines
... only if you give more clue what exactly you did.
In general, it implies that an interrupt isn't issued properly
at PCM
Quoted 13 lines
Quoted 8 lines
period boundary.
Takashi
--
-Harsha--
-Harsha
Signature · 1 line
-Harsha
At Mon, 2 Jun 2008 15:06:03 +0530,
Quoted 5 lines · Harsha priya gupta
Say if my hardware is such that it shall interrupt only after it has processed entire sample and not ever period or sample. What will ensure that i get my next buffer down? Will calling the
snd_pcm_period_elapsedin the interrupt function help?
So, your hardware has only a single ring buffer and can issue an interrupt only at the end of the buffer?
If so, you might need to seek for another interrupt source, such as a system timer.
Takashi
Quoted 103 lines · Takashi Iwai
At Mon, 2 Jun 2008 14:33:14 +0530,
Harsha priya gupta wrote:
>
> Quick question
>
> From my copy function after I pass the buffer to HW, what would happen if i
> callsnd_pcm_period_elapsed.It's invalid and a misdesign.
I guess you are misunderstanding about when to
callsnd_pcm_period_elapsed().snd_pcm_period_elapsed()is called when one period of samples on the hardware is *processed*. It doesn't mean that the samples are transferred to the hardware.Suppose that you have
period_size= 48000 (frames) for 48kHz samples. Then, the firstsnd_pcm_period_epased()shall be called just one second after starting the PCM stream. The second call be another one second later, and so on. It doesn't matter how quick the copy to h/w is done (via copy callback).Takashi
>
> On Mon, Jun 2, 2008 at 1:37 PM, Takashi Iwai <[email protected]> wrote:
>
> At Mon, 2 Jun 2008 13:26:01 +0530,
> Harsha priya gupta wrote:
> >
> > I implemented the copy function and immediately transfered the user
block
> data
> > to the hardware.
> >
> > Correct me if am wrong;
> > .pointer implementation - passes the current buffer pointer. When
the
> .pointer
> > function returns the size of the buffer = user buffer size
logically I
> need to
> > expect the hardware to send an interrupt because buffer is consumed
and I
> > should callsnd_pcm_period_elapsedafter that.
> >
> > what would happen if i call thesnd_pcm_period_elapsedfrom the
pointer
> > function once the buffer is consumed from hardware. Would that be
right?
> This
> > is what i am trying to do
>
> The logic is reversed.
> The pointer callback is a passive one that does nothing but returning
> the current h/w buffer position. This is called either from
>snd_pcm_period_elapsed()or at the PCM status update.
>
> You must callsnd_pcm_period_elapsed()somewhere in your driver
> *explicitly* at the timing that one period is finished. Usually,
this
> is done in an IRQ handler the h/w generates at the period
("fragment",
> "half-buffer", or whatever) boundary.
>
> And note that the valid value from the pointer callback is between 0
> and buffer_size-1 as it handles the buffer as a ring-buffer. The
> valuebuffer_sizeis invalid.
>
> Takashi
>
> > On Mon, Jun 2, 2008 at 1:02 PM, Takashi Iwai <[email protected]> wrote:
> >
> > At Mon, 2 Jun 2008 12:39:31 +0530,
> > Harsha priya gupta wrote:
> > >
> > > Can anyone give me a clue as to when i would get such an
error?
> >
> > ... only if you give more clue what exactly you did.
> >
> > In general, it implies that an interrupt isn't issued properly
at PCM
> > period boundary.
> >
> > Takashi
> >
> > --
> > -Harsha
> >
> >
>
> --
> -Harsha
>
>--
-Harsha
Is there any way to avoid the timer part? Because i do not want the cpu to bother with anything till the hardware has done its part. after the hardware interrupts, can i manipulate someway to get the next buffer rather than interrupting every 1 sec to say that the period has been processed.
Quoted 140 lines · Takashi Iwai
At Mon, 2 Jun 2008 15:06:03 +0530,
Quoted 2 lines · Harsha priya gupta
Say if my hardware is such that it shall interrupt only after it has
processed
Quoted 1 line
entire sample and not ever period or sample. What will ensure that i get
my
Quoted 1 line
next buffer down? Will calling the
snd_pcm_period_elapsedin theinterrupt
Quoted 1 line
function help?
So, your hardware has only a single ring buffer and can issue an interrupt only at the end of the buffer?
If so, you might need to seek for another interrupt source, such as a system timer.
Takashi
Quoted 8 lines · Takashi Iwai
At Mon, 2 Jun 2008 14:33:14 +0530,
Harsha priya gupta wrote:
>
> Quick question
>
> From my copy function after I pass the buffer to HW, what wouldhappen if
Quoted 7 lines
i
> callsnd_pcm_period_elapsed.It's invalid and a misdesign.
I guess you are misunderstanding about when to
callsnd_pcm_period_elapsed().snd_pcm_period_elapsed()is calledwhen
Quoted 1 line
one period of samples on the hardware is *processed*. It doesn't
mean
Quoted 12 lines
that the samples are transferred to the hardware.
Suppose that you have
period_size= 48000 (frames) for 48kHz samples. Then, the firstsnd_pcm_period_epased()shall be called just one second after starting the PCM stream. The second call be another one second later, and so on. It doesn't matter how quick the copy to h/w is done (via copy callback).Takashi
>
> On Mon, Jun 2, 2008 at 1:37 PM, Takashi Iwai <[email protected]>Quoted 5 lines · wrote:
Quoted 5 lines
At Mon, 2 Jun 2008 13:26:01 +0530,
Harsha priya gupta wrote:
>
> I implemented the copy function and immediately transferedthe user
Quoted 6 lines
block
> data
> > to the hardware.
> >
> > Correct me if am wrong;
> > .pointer implementation - passes the current buffer pointer.When
Quoted 6 lines
the
> .pointer
> > function returns the size of the buffer = user buffer size
logically I
> need to
> > expect the hardware to send an interrupt because buffer isconsumed
Quoted 4 lines
and I
> > should callsnd_pcm_period_elapsedafter that.
> >
> > what would happen if i call thesnd_pcm_period_elapsedfromthe
Quoted 2 lines
pointer
> > function once the buffer is consumed from hardware. Wouldthat be
Quoted 6 lines
right?
> This
> > is what i am trying to do
>
> The logic is reversed.
> The pointer callback is a passive one that does nothing butreturning
Quoted 5 lines
Quoted 5 lines
the current h/w buffer position. This is called either from
snd_pcm_period_elapsed()or at the PCM status update.You must call
snd_pcm_period_elapsed()somewhere in your driver *explicitly* at the timing that one period is finished.Usually,
Quoted 6 lines
this
> is done in an IRQ handler the h/w generates at the period
("fragment",
> "half-buffer", or whatever) boundary.
>
> And note that the valid value from the pointer callback isbetween 0
Quoted 1 line
Quoted 1 line
and buffer_size-1 as it handles the buffer as a ring-buffer.
The
Quoted 5 lines
Quoted 5 lines
value
buffer_sizeis invalid.Takashi
> On Mon, Jun 2, 2008 at 1:02 PM, Takashi Iwai <[email protected]>
Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 lines
At Mon, 2 Jun 2008 12:39:31 +0530,
Harsha priya gupta wrote:
>
> Can anyone give me a clue as to when i would get suchan
Quoted 5 lines
error?
> >
> > ... only if you give more clue what exactly you did.
> >
> > In general, it implies that an interrupt isn't issuedproperly
Quoted 19 lines
at PCM > > period boundary. > > > > Takashi > > > > -- > > -Harsha > > > > > > -- > -Harsha > >--
-Harsha
Signature · 1 line
-Harsha
At Mon, 2 Jun 2008 15:16:06 +0530,
Quoted 3 lines · Harsha priya gupta
Is there any way to avoid the timer part? Because i do not want the cpu to bother with anything till the hardware has done its part.
But your hardware doesn't do what we need. A basic part is missing.
Quoted 3 lines
after the hardware
interrupts, can i manipulate someway to get the next buffer rather than interrupting every 1 sec to say that the period has been processed.
Well, how would you handle "the next buffer"?
Suppose all samples on the buffer are processed and an irq is issued. At this moment, you have no data on the buffer. It means that the device is already in a buffer-underrun error state.
The period-based transfer is the basis of ALSA PCM transfer model. In this way, you can write programs requiring a precise timing control, too.
Takashi
Quoted 145 lines · Takashi Iwai
At Mon, 2 Jun 2008 15:06:03 +0530,
Harsha priya gupta wrote:
>
> Say if my hardware is such that it shall interrupt only after it has processed
> entire sample and not ever period or sample. What will ensure that i get my
> next buffer down? Will calling thesnd_pcm_period_elapsedin the interrupt
> function help?So, your hardware has only a single ring buffer and can issue an interrupt only at the end of the buffer?
If so, you might need to seek for another interrupt source, such as a system timer.
Takashi
> On Mon, Jun 2, 2008 at 2:54 PM, Takashi Iwai <[email protected]> wrote:
>
> At Mon, 2 Jun 2008 14:33:14 +0530,
> Harsha priya gupta wrote:
> >
> > Quick question
> >
> > From my copy function after I pass the buffer to HW, what would
happen if
> i
> > callsnd_pcm_period_elapsed.
>
> It's invalid and a misdesign.
>
> I guess you are misunderstanding about when to
>callsnd_pcm_period_elapsed().snd_pcm_period_elapsed()is called
when
> one period of samples on the hardware is *processed*. It doesn't
mean
> that the samples are transferred to the hardware.
>
> Suppose that you haveperiod_size= 48000 (frames) for 48kHz samples.
> Then, the firstsnd_pcm_period_epased()shall be called just one
> second after starting the PCM stream. The second call be another one
> second later, and so on. It doesn't matter how quick the copy to h/w
> is done (via copy callback).
>
> Takashi
>
> >
> > On Mon, Jun 2, 2008 at 1:37 PM, Takashi Iwai <[email protected]> wrote:
> >
> > At Mon, 2 Jun 2008 13:26:01 +0530,
> > Harsha priya gupta wrote:
> > >
> > > I implemented the copy function and immediately transfered
the user
> block
> > data
> > > to the hardware.
> > >
> > > Correct me if am wrong;
> > > .pointer implementation - passes the current buffer pointer.
When
> the
> > .pointer
> > > function returns the size of the buffer = user buffer size
> logically I
> > need to
> > > expect the hardware to send an interrupt because buffer is
consumed
> and I
> > > should callsnd_pcm_period_elapsedafter that.
> > >
> > > what would happen if i call thesnd_pcm_period_elapsedfrom
the
> pointer
> > > function once the buffer is consumed from hardware. Would
that be
> right?
> > This
> > > is what i am trying to do
> >
> > The logic is reversed.
> > The pointer callback is a passive one that does nothing but
returning
> > the current h/w buffer position. This is called either from
> >snd_pcm_period_elapsed()or at the PCM status update.
> >
> > You must callsnd_pcm_period_elapsed()somewhere in your driver
> > *explicitly* at the timing that one period is finished.
Usually,
> this
> > is done in an IRQ handler the h/w generates at the period
> ("fragment",
> > "half-buffer", or whatever) boundary.
> >
> > And note that the valid value from the pointer callback is
between 0
> > and buffer_size-1 as it handles the buffer as a ring-buffer.
The
> > valuebuffer_sizeis invalid.
> >
> > Takashi
> >
> > > On Mon, Jun 2, 2008 at 1:02 PM, Takashi Iwai <[email protected]>
wrote:
> > >
> > > At Mon, 2 Jun 2008 12:39:31 +0530,
> > > Harsha priya gupta wrote:
> > > >
> > > > Can anyone give me a clue as to when i would get such
an
> error?
> > >
> > > ... only if you give more clue what exactly you did.
> > >
> > > In general, it implies that an interrupt isn't issued
properly
> at PCM
> > > period boundary.
> > >
> > > Takashi
> > >
> > > --
> > > -Harsha
> > >
> > >
> >
> > --
> > -Harsha
> >
> >
>
> --
> -Harsha
>
>--
-Harsha
OK. So can i assume that its compulsory to raise at least a timer interrupt every 1 second (for 48K sample/ 48 kHz). if its 96Khz, then i would have to raise the timer interrupt every 2 seconds... correct?
Quoted 198 lines · Takashi Iwai
At Mon, 2 Jun 2008 15:16:06 +0530,
Quoted 2 lines · Harsha priya gupta
Is there any way to avoid the timer part? Because i do not want the cpu
to
Quoted 1 line
bother with anything till the hardware has done its part.
But your hardware doesn't do what we need. A basic part is missing.
Quoted 3 lines
after the hardware
interrupts, can i manipulate someway to get the next buffer rather than interrupting every 1 sec to say that the period has been processed.Well, how would you handle "the next buffer"?
Suppose all samples on the buffer are processed and an irq is issued. At this moment, you have no data on the buffer. It means that the device is already in a buffer-underrun error state.
The period-based transfer is the basis of ALSA PCM transfer model. In this way, you can write programs requiring a precise timing control, too.
Takashi
Quoted 7 lines · Takashi Iwai
At Mon, 2 Jun 2008 15:06:03 +0530,
Harsha priya gupta wrote:
>
> Say if my hardware is such that it shall interrupt only after ithas
Quoted 2 lines
processed
> entire sample and not ever period or sample. What will ensure thati get
Quoted 14 lines
my
> next buffer down? Will calling thesnd_pcm_period_elapsedin the interrupt
> function help?So, your hardware has only a single ring buffer and can issue an interrupt only at the end of the buffer?
If so, you might need to seek for another interrupt source, such as a system timer.
Takashi
> On Mon, Jun 2, 2008 at 2:54 PM, Takashi Iwai <[email protected]>
Quoted 7 lines · wrote:
Quoted 7 lines
At Mon, 2 Jun 2008 14:33:14 +0530,
Harsha priya gupta wrote:
>
> Quick question
>
> From my copy function after I pass the buffer to HW, whatwould
Quoted 8 lines
happen if
> i
> > callsnd_pcm_period_elapsed.
>
> It's invalid and a misdesign.
>
> I guess you are misunderstanding about when to
>callsnd_pcm_period_elapsed().snd_pcm_period_elapsed()iscalled
Quoted 2 lines
when
> one period of samples on the hardware is *processed*. Itdoesn't
Quoted 4 lines
mean
> that the samples are transferred to the hardware.
>
> Suppose that you haveperiod_size= 48000 (frames) for 48kHzsamples.
Quoted 1 line
Quoted 1 line
Then, the first
snd_pcm_period_epased()shall be called justone
Quoted 1 line
Quoted 1 line
second after starting the PCM stream. The second call be
another one
Quoted 1 line
Quoted 1 line
second later, and so on. It doesn't matter how quick the copy
to h/w
Quoted 6 lines
Quoted 6 lines
is done (via copy callback). Takashi > > On Mon, Jun 2, 2008 at 1:37 PM, Takashi Iwai <[email protected]>Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 lines
At Mon, 2 Jun 2008 13:26:01 +0530,
Harsha priya gupta wrote:
>
> I implemented the copy function and immediatelytransfered
Quoted 7 lines
the user
> block
> > data
> > > to the hardware.
> > >
> > > Correct me if am wrong;
> > > .pointer implementation - passes the current bufferpointer.
Quoted 4 lines
When
> the
> > .pointer
> > > function returns the size of the buffer = user buffersize
Quoted 3 lines
Quoted 3 lines
logically I
> need to
> > expect the hardware to send an interrupt because bufferis
Quoted 5 lines
consumed
> and I
> > > should callsnd_pcm_period_elapsedafter that.
> > >
> > > what would happen if i call thesnd_pcm_period_elapsedfrom
Quoted 3 lines
the
> pointer
> > > function once the buffer is consumed from hardware.Would
Quoted 7 lines
that be
> right?
> > This
> > > is what i am trying to do
> >
> > The logic is reversed.
> > The pointer callback is a passive one that does nothingbut
Quoted 2 lines
returning
> > the current h/w buffer position. This is called eitherfrom
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
snd_pcm_period_elapsed()or at the PCM status update.You must call
snd_pcm_period_elapsed()somewhere in yourdriver
Quoted 8 lines
Quoted 1 line
Quoted 1 line
*explicitly* at the timing that one period is finished.
Usually,
> this
> > is done in an IRQ handler the h/w generates at the period
> ("fragment",
> > "half-buffer", or whatever) boundary.
> >
> > And note that the valid value from the pointer callbackis
Quoted 2 lines
between 0
> > and buffer_size-1 as it handles the buffer as aring-buffer.
Quoted 6 lines
The > > value buffer_size is invalid. > > > > Takashi > > > > > On Mon, Jun 2, 2008 at 1:02 PM, Takashi Iwai <Quoted 6 lines
wrote:
> > >
> > > At Mon, 2 Jun 2008 12:39:31 +0530,
> > > Harsha priya gupta wrote:
> > > >
> > > > Can anyone give me a clue as to when i would getsuch
Quoted 4 lines
an
> error?
> > >
> > > ... only if you give more clue what exactly youdid.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
In general, it implies that an interrupt isn't
issued
Quoted 25 lines
properly
> at PCM
> > > period boundary.
> > >
> > > Takashi
> > >
> > > --
> > > -Harsha
> > >
> > >
> >
> > --
> > -Harsha
> >
> >
>
> --
> -Harsha
>
>--
-Harsha
Signature · 1 line
-Harsha
At Mon, 2 Jun 2008 15:39:07 +0530,
Quoted 4 lines · Harsha priya gupta
OK. So can i assume that its compulsory to raise at least a timer interrupt every 1 second (for 48K sample/ 48 kHz). if its 96Khz, then i would have to raise the timer interrupt every 2 seconds... correct?
No, no. The one second timer is just my example where the period_size = 48000 at 48kHz is assumed. The actual timer period must be calculated from the sample rate, the buffer size and the period size given by the user and the hardware supports.
Takashi
Quoted 203 lines · Takashi Iwai
At Mon, 2 Jun 2008 15:16:06 +0530,
Harsha priya gupta wrote:
>
> Is there any way to avoid the timer part? Because i do not want the cpu to
> bother with anything till the hardware has done its part.But your hardware doesn't do what we need. A basic part is missing.
> after the hardware
> interrupts, can i manipulate someway to get the next buffer rather than > interrupting every 1 sec to say that the period has been processed.Well, how would you handle "the next buffer"?
Suppose all samples on the buffer are processed and an irq is issued. At this moment, you have no data on the buffer. It means that the device is already in a buffer-underrun error state.
The period-based transfer is the basis of ALSA PCM transfer model. In this way, you can write programs requiring a precise timing control, too.
Takashi
>
> On Mon, Jun 2, 2008 at 3:10 PM, Takashi Iwai <[email protected]> wrote:
>
> At Mon, 2 Jun 2008 15:06:03 +0530,
> Harsha priya gupta wrote:
> >
> > Say if my hardware is such that it shall interrupt only after it
has
> processed
> > entire sample and not ever period or sample. What will ensure that
i get
> my
> > next buffer down? Will calling thesnd_pcm_period_elapsedin the
> interrupt
> > function help?
>
> So, your hardware has only a single ring buffer and can issue an
> interrupt only at the end of the buffer?
>
> If so, you might need to seek for another interrupt source, such as a
> system timer.
>
> Takashi
>
> > On Mon, Jun 2, 2008 at 2:54 PM, Takashi Iwai <[email protected]> wrote:
> >
> > At Mon, 2 Jun 2008 14:33:14 +0530,
> > Harsha priya gupta wrote:
> > >
> > > Quick question
> > >
> > > From my copy function after I pass the buffer to HW, what
would
> happen if
> > i
> > > callsnd_pcm_period_elapsed.
> >
> > It's invalid and a misdesign.
> >
> > I guess you are misunderstanding about when to
> >callsnd_pcm_period_elapsed().snd_pcm_period_elapsed()is
called
> when
> > one period of samples on the hardware is *processed*. It
doesn't
> mean
> > that the samples are transferred to the hardware.
> >
> > Suppose that you haveperiod_size= 48000 (frames) for 48kHz
samples.
> > Then, the firstsnd_pcm_period_epased()shall be called just
one
> > second after starting the PCM stream. The second call be
another one
> > second later, and so on. It doesn't matter how quick the copy
to h/w
> > is done (via copy callback).
> >
> > Takashi
> >
> > >
> > > On Mon, Jun 2, 2008 at 1:37 PM, Takashi Iwai <[email protected]>
wrote:
> > >
> > > At Mon, 2 Jun 2008 13:26:01 +0530,
> > > Harsha priya gupta wrote:
> > > >
> > > > I implemented the copy function and immediately
transfered
> the user
> > block
> > > data
> > > > to the hardware.
> > > >
> > > > Correct me if am wrong;
> > > > .pointer implementation - passes the current buffer
pointer.
> When
> > the
> > > .pointer
> > > > function returns the size of the buffer = user buffer
size
> > logically I
> > > need to
> > > > expect the hardware to send an interrupt because buffer
is
> consumed
> > and I
> > > > should callsnd_pcm_period_elapsedafter that.
> > > >
> > > > what would happen if i call thesnd_pcm_period_elapsed
from
> the
> > pointer
> > > > function once the buffer is consumed from hardware.
Would
> that be
> > right?
> > > This
> > > > is what i am trying to do
> > >
> > > The logic is reversed.
> > > The pointer callback is a passive one that does nothing
but
> returning
> > > the current h/w buffer position. This is called either
from
> > >snd_pcm_period_elapsed()or at the PCM status update.
> > >
> > > You must callsnd_pcm_period_elapsed()somewhere in your
driver
> > > *explicitly* at the timing that one period is finished.
> Usually,
> > this
> > > is done in an IRQ handler the h/w generates at the period
> > ("fragment",
> > > "half-buffer", or whatever) boundary.
> > >
> > > And note that the valid value from the pointer callback
is
> between 0
> > > and buffer_size-1 as it handles the buffer as a
ring-buffer.
> The
> > > valuebuffer_sizeis invalid.
> > >
> > > Takashi
> > >
> > > > On Mon, Jun 2, 2008 at 1:02 PM, Takashi Iwai <
[email protected]>
> wrote:
> > > >
> > > > At Mon, 2 Jun 2008 12:39:31 +0530,
> > > > Harsha priya gupta wrote:
> > > > >
> > > > > Can anyone give me a clue as to when i would get
such
> an
> > error?
> > > >
> > > > ... only if you give more clue what exactly you
did.
> > > >
> > > > In general, it implies that an interrupt isn't
issued
> properly
> > at PCM
> > > > period boundary.
> > > >
> > > > Takashi
> > > >
> > > > --
> > > > -Harsha
> > > >
> > > >
> > >
> > > --
> > > -Harsha
> > >
> > >
> >
> > --
> > -Harsha
> >
> >
>
> --
> -Harsha
>
>--
-Harsha