[alsa-devel] Driver code with mpc5200 pointer problem.
Timur Tabi
timur at freescale.com
Mon Apr 27 19:36:52 CEST 2009
On Sun, Apr 26, 2009 at 10:25 AM, Jon Smirl <jonsmirl at gmail.com> wrote:
> static snd_pcm_uframes_t
> psc_dma_pcm_pointer(struct snd_pcm_substream *substream)
> {
> struct snd_pcm_runtime *runtime = substream->runtime;
> struct snd_soc_pcm_runtime *rtd = substream->private_data;
> struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
> struct psc_dma_stream *s;
> dma_addr_t count;
> snd_pcm_uframes_t frames;
> int delta;
>
> if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
> s = &psc_dma->capture;
> else
> s = &psc_dma->playback;
>
> count = s->period_current_pt - s->period_start;
>
> delta = jiffies - s->jiffies;
> delta = delta * runtime->rate / HZ;
> frames = bytes_to_frames(substream->runtime, count);
Have you considered using the timebase register instead of jiffies?
It's more accurate, and you can use tb_ticks_per_usec.
--
Timur Tabi
Linux kernel developer at Freescale
More information about the Alsa-devel
mailing list