]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commit
V4L/DVB (6083): cx88-alsa: Rework buffer handling
authorTrent Piepho <xyzzy@speakeasy.org>
Fri, 24 Aug 2007 04:06:34 +0000 (01:06 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 10 Oct 2007 01:06:34 +0000 (22:06 -0300)
commit05b2723387cb4086535e935ee07cca19086308fc
tree369957184bb4e5203a46ba45e8b30de91863da2a
parent16cf1d0c5d7b8970aca2ca426166833642ce0544
V4L/DVB (6083): cx88-alsa: Rework buffer handling

Rework the way the DMA buffer is handled and IRQs are generated.

ALSA uses a ring-buffer of multiple periods.  Each period is supposed to
corrispond to one IRQ.

The existing driver was generating one interrupt per ring-buffer, as opposed
to per period.  This meant that as soon as the IRQ was generated, the hardware
was already starting to re-write the beginning of the buffer.  Since the DMA
happens on a per-line basis, there was only a narrow window to copy the data
out before the buffer was overwritten.

The cx88 core RISC program generator is modified so that it can set the IRQ
and counter flags to count every X lines of DMA transfer.  This way we can
generate an interrupt every period instead of every full ring-buffer.  Right
now only period of one line are supported, but it should be possible to
support longer periods.  Note that a WRITE instruction generates an IRQ when
it starts, not when the transfer is finished.  Thus to generate an IRQ when
line X is done, one must set the IRQ flag on the instruction that starts line
X+1, not the one that ends line X.

Change the line size so that there are four lines in the SRAM FIFO.  If there
are not four lines, the analog output from the cx88's internal DACs is full of
clicks and pops.

Try to handle FIFO sync errors.  Sometimes the chip generates many of these
errors before audio data starts.  Up to 50 sync errors will be ignored and the
counter reset.

Have the IRQ handler save the RISC counter to the chip struct, and then have
the pointer callback use this to calculate the pointer position.  We could
read the counter from the pointer callback, but sometimes the sync errors on
start up cause the counter to go crazy.  ALSA sees this and thinks there has
been an overrun.  The IRQ hander can avoid saving the counter position on
sync errors.

The chip "opened" flag wasn't necessary.  ALSA won't try to open the same
substream multiple times.  Probably this code was cut&pasted from the bt87x
driver, which has multiple sub-streams for one chip.

Do error checking for the videobuf mapping functions.

snd_card_cx88_runtime_free() is useless and can be deleted.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/cx88/cx88-alsa.c
drivers/media/video/cx88/cx88-core.c
drivers/media/video/cx88/cx88-mpeg.c
drivers/media/video/cx88/cx88.h