V4L/DVB (5887): zr36067: Fix poll() operation
authorTrent Piepho <xyzzy@speakeasy.org>
Tue, 17 Jul 2007 21:29:43 +0000 (18:29 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Mon, 30 Jul 2007 19:26:24 +0000 (16:26 -0300)
commite42af83f4874ebb2c6af59a05dbe5d45114fb0ed
tree7659c0d8dfc1851594ed133bce3ed1368b7ab8ea
parentc812b67ca4ed13fa5ec60f06c4ed8f648722a186
V4L/DVB (5887): zr36067: Fix poll() operation

During uncompressed capture, the poll() function was looking the wrong frame.
It was using the frame the driver was going to capture into next (pend_tail),
when it should have been looking at the next frame to be de-queued with
DQBUF/SYNC (sync_tail).

It also wasn't looking in the right spot.  It was looking at the file handle's
copy of the buffer status, rather than the driver core copy.  The interrupt
routine marks frames as done in the driver core copy, the file handle copy
isn't updated.  So even if poll() looked at the right frame, it would never
see it transition to done and return POLLIN.

The compressed capture code has this same problem, looking in fh->jpg_buffers
when it should have used zr->jpg_buffers.

There was some logic to detect when there was no current capture in process
nor any frames queued and try to return an error, which ends up being a bad
idea.  It's possible to call select() from one thread while no capture is in
process, or no frames queued, and then start a capture or queue frames from
another thread.

The buffer state variables are protected by a spin lock, which the code wasn't
acquiring.  That is fixed too.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Acked-by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/zoran_driver.c