alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Adam Rosenberg <adam@alcorn.com>
To: alsa-devel@alsa-project.org
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Liam Girdwood <lrg@slimlogic.co.uk>
Subject: How does struct snd_pcm_hardware relate to the actual hardware
Date: Wed, 30 Jun 2010 17:32:41 -0400	[thread overview]
Message-ID: <AANLkTimiH0xvYIM-gmxx95W3N4PmFKqa1skknvsxluY8@mail.gmail.com> (raw)

I am using DMA to transfer data to SPORT1 on my Blackfin BF537.  I am
using a CS42448 CODEC that has 8 DACs.  I am using TDM mode and have
set the following:

DMA Buffer Size For Each SPORT Data Line (Rx or Tx) = 131072 bytes
DMA Periods = 8

static struct snd_pcm_hardware snd_pcm_hw =
{
	.info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
SNDRV_PCM_INFO_RESUME),
	.formats = SNDRV_PCM_FMTBIT_S32_LE,
	.rates = SNDRV_PCM_RATE_48000,
	.rate_min = 48000,
	.rate_max = 48000,
	.buffer_bytes_max = 32768,
	.channels_min = 2,
	.channels_max = 2,
	.period_bytes_min = 8,
	.period_bytes_max = 4096,
	.periods_min = 8,
	.periods_max = 8,
};

Everytime I receive a DMA interrupt from the SPORT driver I call
snd_pcm_period_elapsed for all of the substreams that are currently
active.  In the PCM Copy callback I calculate the position within the
DMA buffer to write to based on the TDM slot for the channel and the
position passed into the function.

The audio is not being placed into the DMA buffer properly.  The audio
plays faster than it should and has a constant stutter.  I have read
the "writing an ALSA driver" guide multiple times but it does not
explain the relationship between struct snd_pcm_hardware,
snd_pcm_period_elapsed, and the copy callback clearly enough for me to
understand what I am doing wrong.

Please explain how these interact in more detail to help me fix this
problem.  I can also send the full source code to the CS42448 driver I
am working on if more details are needed.

Thank you,
Adam

             reply	other threads:[~2010-06-30 21:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-30 21:32 Adam Rosenberg [this message]
2010-07-01 18:40 ` How does struct snd_pcm_hardware relate to the actual hardware Mark Brown
2010-07-12 20:35   ` Adam Rosenberg

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=AANLkTimiH0xvYIM-gmxx95W3N4PmFKqa1skknvsxluY8@mail.gmail.com \
    --to=adam@alcorn.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=lrg@slimlogic.co.uk \
    /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;
as well as URLs for NNTP newsgroup(s).