• Trent Piepho's avatar
    V4L/DVB (5887): zr36067: Fix poll() operation · e42af83f
    Trent Piepho authored
    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: default avatarTrent Piepho <xyzzy@speakeasy.org>
    Acked-by: default avatarRonald S. Bultje <rbultje@ronald.bitfreak.net>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
    e42af83f
zoran_driver.c 113 KB