From: Clemens Ladisch <clemens@ladisch.de>
To: Carlo Caione <carlo@caione.org>
Cc: alsa-devel@alsa-project.org
Subject: Re: DMA buffer alignment
Date: Fri, 05 Dec 2014 12:34:58 +0100 [thread overview]
Message-ID: <54819862.9030509@ladisch.de> (raw)
In-Reply-To: <CAOQ7t2ZNARpAyfr_q9qjsbvbxQU2-AFgQC6aY=Tuurm3dhWPUA@mail.gmail.com>
Carlo Caione wrote:
> let's say that our application sends uning snd_pcm_writei() a buffer
> that is exactly 64 bytes and that our hwoff (appl_ofs)
The hardware and the software (appl) pointers are independent.
> is pointing to a memory location 0 in the DMA area.
> When this buffer is taken from the SoC sound driver, the .copy
> callback writes this buffer as follow: 32 bytes (left channel) to
> memory locations from *hwoff to *hwoff+31, and 32 bytes (right
> channel) for *hwoff+32 to *hwoff+63.
> Problem is when my buffer is not multiple of 64 bytes, for example if
> the buffer size is < 64. If I receive a buffer of lenght 32 byte than
> my DMA memory is filled as follows: 16 bytes from *hwoff to *hwoff+15
> and 16 bytes from *hwoff+32 to *hwoff+47, leaving 32 bytes in the
> block not initialized.
These bytes are written later. And if they are not written fast enough,
you get an underrun. This is no difference from any other sound card.
> In some way I should always guarantee that the size of the buffer
> passed to my .copy callback is multiple of 64 bytes.
The .copy callback just copies samples to memory; this is possible
with any alignment.
The DMA runs asynchronously, and uses its own pointer.
Regards,
Clemens
next prev parent reply other threads:[~2014-12-05 11:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-04 15:54 DMA buffer alignment Carlo Caione
2014-12-04 16:20 ` Clemens Ladisch
2014-12-05 1:04 ` Carlo Caione
2014-12-05 11:34 ` Clemens Ladisch [this message]
2014-12-05 2:23 ` Raymond Yau
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=54819862.9030509@ladisch.de \
--to=clemens@ladisch.de \
--cc=alsa-devel@alsa-project.org \
--cc=carlo@caione.org \
/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.