Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: Can DMA address, periods, buffer size, etc change after hw_params is called?
Date: Thu, 29 Jan 2009 11:10:34 +0100	[thread overview]
Message-ID: <20090129111034.632c5dcf@hcegtvedt> (raw)
In-Reply-To: <49817E17.8040401@ladisch.de>

On Thu, 29 Jan 2009 10:59:51 +0100
Clemens Ladisch <clemens@ladisch.de> wrote:

> Hans-Christian Egtvedt wrote:
> > Okay, so to be sure I setup and release my cyclic DMA buffer safely
> > I could use the following model:
> > 
> > in prepare callback setup the DMA buffer, once when called. The
> > hardware parameters should not change at this point.
> > 
> > If I get a hw_params callback after a prepare, then release the DMA
> > buffer, and set it up again in the prepare callback?
> > 
> > Final cleanup of the DMA buffer can/should be done in hw_free?
> 
> This would work, but doing it in the hw_params callback would be a
> little more simple:
> * In hw_params, free the old buffer (if it exists), then setup the
>   buffer;

I think I was not 100% clear, in addition to call
snd_pcm_lib_malloc_pages() in hw_params, I also need to hand over the
DMA buffer information to a prepare function in the DMA driver I use
with this sound hardware.

So I follow the scheme for free/setup of buffers for my DMA controller
setup as well.

hw_params, release DMA controller if exists, then prepare DMA
controller.

> * in hw_free, free the buffer.
> 

Which I do by calling snd_pcm_lib_free_pages().

and then in hw_free, release DMA controller if exists.

> As a rule of thumb, the callbacks open/close, hw_params/hw_free and
> start/stop trigger are mostly symmetrical, and any resources should be
> allocated and freed in the functions that belong together.  (The start
> trigger is a special case because it uses two callbacks, prepare and
> trigger with TRIGGER_START.)
> 
> The hw_params and prepare callbacks can be called multiple times.
> 

Noted, which means I should reprepare my DMA controller as well every
time I get a hw_params callback and do snd_pcm_lib_malloc_pages().

> > Is there a flow chart which shows how the different callbacks can be
> > called?
> 
> Not yet.
> 

Would probably help me a lot to see the actual flow of the callbacks.

-- 
Best regards,
Hans-Christian Egtvedt

  reply	other threads:[~2009-01-29 10:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-29  7:18 Can DMA address, periods, buffer size, etc change after hw_params is called? Hans-Christian Egtvedt
2009-01-29  8:11 ` Clemens Ladisch
2009-01-29  8:43   ` Hans-Christian Egtvedt
2009-01-29  8:58     ` Clemens Ladisch
2009-01-29  9:35       ` Hans-Christian Egtvedt
2009-01-29  9:59         ` Clemens Ladisch
2009-01-29 10:10           ` Hans-Christian Egtvedt [this message]
2009-01-29 22:30 ` Timur Tabi

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=20090129111034.632c5dcf@hcegtvedt \
    --to=hans-christian.egtvedt@atmel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox