• Hans Verkuil's avatar
    [media] vb2: fix read/write regression · 4e5a4d8a
    Hans Verkuil authored
    Commit 88e26870 ("vb2: Improve file I/O
    emulation to handle buffers in any order") broke read/write support if
    the size of the buffer being read/written is less than the size of the
    image.
    
    When the commit was tested originally I used qv4l2, which calls read()
    with exactly the size of the image. But if you try 'cat /dev/video0'
    then it will fail and typically hang after reading two buffers.
    
    This patch fixes the behavior by adding a new cur_index field that
    contains the index of the field currently being filled/read, or it
    is num_buffers in which case a new buffer needs to be dequeued.
    
    The old index field has been renamed to initial_index in order to be
    a bit more descriptive.
    
    This has been tested with both read and write.
    Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
    Tested-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
    Cc: Andy Walls <awalls@md.metrocast.net>
    Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
    4e5a4d8a
videobuf2-core.c 78.6 KB