All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Steve Spano <steve@fl-eng.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: ### Question on HW Pointer
Date: Wed, 06 Oct 2010 08:46:51 +0200	[thread overview]
Message-ID: <4CAC1B5B.6000705@ladisch.de> (raw)
In-Reply-To: <001201cb64ee$5beec5c0$13cc5140$@fl-eng.com>

Steve Spano wrote:
> I think the flow should be as follows (lets consider the dac part)
> 
> Step #1 ) interrupt occurs
> Step #2) dma/transfer begins as kicked off in interrupt routine

So I assume the driver is responsible for telling the hardware to begin
transferring the next period.  Doesn't it do this automatically?

> Step #3) we advance the buffer pointer for the alsa buffer

An interrupt (that is, for ALSA, the call to snd_pcm_period_elapsed)
signals the end of the previous period.

> Step #4) we exit the interrupt
> 
> . then the hardware should start advancing its pointer as it is reading the
> new samples
> 
> .. then sometime later, the alsa layer calls the "hw_pointer" function

The pointer callback can be called at any time.  It will definitely be
called from snd_pcm_period_elapsed, so the buffer pointer must already
have been increased before that call.

> And then we return the current value of the hardware pointer from the board?

Drop the word "then"; the pointer callback _always_ must return the
current value. :)

> So alsa knows how many samples the board has processed from the interrupt?

Yes; ALSA (or the application) wants to know how many samples the board
has processed.  If your DMA controller does not have a register for this,
the pointer must be calculated and updated in the interrupt handler (as
you do).

> Can someone explain how this pointer/etc is supposed to flow and what alsa
> may be using it for? Maybe some latency calculation in a an upper layer?

This, and to know which part of the buffer can be written to (the
hardware pointer indicates which part of the buffer has been processed
by the hardware; the samples after the pointer will be read now or
later).


Regards,
Clemens

  reply	other threads:[~2010-10-06  6:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-06  0:35 ### Question on HW Pointer Steve Spano
2010-10-06  6:46 ` Clemens Ladisch [this message]
2010-10-06  7:15 ` Eliot Blennerhassett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CAC1B5B.6000705@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=steve@fl-eng.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.