From: James Courtier-Dutton <James@superbug.co.uk>
To: Nicolas Boullis <nboullis@debian.org>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: writing an alsa driver for an MPEG decoder chip
Date: Mon, 29 Aug 2005 01:04:18 +0100 [thread overview]
Message-ID: <43125102.5020101@superbug.co.uk> (raw)
In-Reply-To: <20050828233639.GB16031@home>
Nicolas Boullis wrote:
> After sending my previous message, I figured out that with a smaller
> period_bytes_max, I can play some sound with xine. It looks like you got
> a point. Thanks! :-)
>
> Anyway, explanations and suggestions for improvement are still very
> welcome... ;-)
Well, get it working first, then improve it. For example, all the
"magic" stuff is unneeded now.
>
> On Sun, Aug 28, 2005 at 11:51:49PM +0100, James Courtier-Dutton wrote:
>
>>Your FIFO looks to me to be a scatter gather array with each entry
>>pointing to a buffer in memory.
>
>
> You're perfectly right. Is there a better way to handle scatter-gather
> arrays within the ALSA framework?
The Linux kernel has it's own scatter gather framework, but I can't
remember off hand how best to use it.
>
>
>
>>You say that it is circular, which sort of contradicts the FIFO name for
>>it, so which is it, A FIFO or a circular buffer?
>
>
> It is a FIFO implemented in a circular buffer: there is this circular
> buffer and two pointers that point to the head and tail of the FIFO
> within this buffer (look for MA_PCIRdPtr and MA_PCIWrPtr in my code).
>
Is the number of entries in the scatter-gather list a fixed size? If so,
how big is it? If the number of entries in the scatter-gather list can
be varied each time you open the device, then set the "periods_min/max
to the range of values it can take. Most sound cards generally do
between 2 and 8 periods.
>
>
>>ALSA has the following terms, periods and frames.
>>A frame equivalent to having one sample for every channel. E.g. stereo
>>16bit PCM would have a frame size of 4 bytes, but a 5.1 16bit PCM would
>>have a frame size of 12 bytes.
>
>
> And the em8300 chip only handles 2-channel 16-bit big-endian streams,
> which means 4 bytes per sample.
>
>
>
>>A period is the time between interrupts for the sound card, and this
>>normally is closely linked to a fixed number of frames per period.
>>
>>Now, I will explain what periods are.
>>One period in alsa is the amount of sound samples
>
>
> between 2 interrupts?
Yes.
>
>
>
>>A buffer is simply the total of period_size * periods.
>>
>>How is the 3 byte FIFO struction layed out? 2 bytes offset, 1 byte size?
>
>
> Almost: these are 2-byte words rather than bytes. Hence, there is:
> - 1 2-byte word for the upper 16 bits of physical address to data
> block
> - 1 2-byte word for the lower 16 bits of physical address to data
> block
> - 1 2-byte word for the size (in bytes) of the data block
>
You would generally pre allocate all the DMA memory use for sound in the
snd_em8300_create() function.
One would then fill the scatter-gather list with pointers to the DMA
memory in the snd_em8300_pcm_prepare() function.
One would also try to do the fewest number of read/write to IO memory in
the em8300_alsa_audio_interrupt() function. I.e. remove the
read_ucregister(MA_PCISize) calls etc, and cache their values in the
em8300_alsa_t structure.
You might want to write to the MA_PCISize register if you want the
application to be able to select a different number of periods. It would
be set in the prepare() function.
>
> Thanks for your help,
>
> Nicolas Boullis
>
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
next prev parent reply other threads:[~2005-08-29 0:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-28 14:46 writing an alsa driver for an MPEG decoder chip Nicolas Boullis
2005-08-28 21:59 ` James Courtier-Dutton
2005-08-28 22:35 ` Nicolas Boullis
2005-08-28 22:51 ` James Courtier-Dutton
2005-08-28 23:36 ` Nicolas Boullis
2005-08-29 0:04 ` James Courtier-Dutton [this message]
2005-08-29 17:45 ` Nicolas Boullis
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=43125102.5020101@superbug.co.uk \
--to=james@superbug.co.uk \
--cc=alsa-devel@lists.sourceforge.net \
--cc=nboullis@debian.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.