[alsa-devel] [PATCH] ASoC: MPC5200: Changed how appl_ptr is initialized
John Bonesio
bones at secretlab.ca
Wed Jul 29 07:26:51 CEST 2009
Hello,
I've been working in the ALSA SOC area for the MPC5200. I've noticed that
in the routine psc_dma_trigger() in sound/soc/fsl/mpc5200_dma.c there are
times when the computed value for s->appl_ptr ends up wrapping negative. This
occurs when
s->runtime->control->appl_ptr
is less than
runtime->period_size * runtime->periods
It seemed like this would occur at then of the data stream or when the data
stream is small (smaller than runtime->period_size * runtime->periods).
As far as I can tell, s->appl_ptr is supposed to be the previous value of
s->runtime->control->appl_ptr, so the driver can send out the right number
of bytes (from previous appl_ptr to current appl_ptr) to avoid pops and clicks
at the end of the audio.
So it appears the assumption in this code is wrong, that the previous
s->runtime->control->appl_ptr is always
rumtime->period_size * runtime->periods bytes prior to the current
s->runtime->control->appl_ptr.
I took out this code and instead added code to intialize s->appl_ptr to 0
in psc_dma_open().
Does this fix seem right?
- John
The computation for appl_ptr in the trigger() routine made a bad assumption
when the stream is at the end of the file and there is not
(periods * period_size) bytes remaining in the data.
This causes playback issues when the total stream size is less than this
amount, as the s->appl_ptr wrapps negative and the data is never played.
Signed-off-by: John Bonesio <bones at secretlab.ca>
---
sound/soc/fsl/mpc5200_dma.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c
index b2eba27..cfe0ea4 100644
--- a/sound/soc/fsl/mpc5200_dma.c
+++ b/sound/soc/fsl/mpc5200_dma.c
@@ -181,8 +181,6 @@ static int psc_dma_trigger(struct snd_pcm_substream *substream, int cmd)
* end of stream and not over running it.
*/
s->runtime = runtime;
- s->appl_ptr = s->runtime->control->appl_ptr -
- (runtime->period_size * runtime->periods);
/* Fill up the bestcomm bd queue and enable DMA.
* This will begin filling the PSC's fifo.
@@ -287,6 +285,7 @@ static int psc_dma_open(struct snd_pcm_substream *substream)
}
s->stream = substream;
+ s->appl_ptr = 0;
return 0;
}
More information about the Alsa-devel
mailing list