31 Dec, 2011

5 commits

  • It seems that a cut-and-past error were added by the last patch:

    drivers/media/video/videobuf2-core.c: In function ‘vb2_qbuf’:
    drivers/media/video/videobuf2-core.c:1099:14: warning: comparison between ‘enum v4l2_buf_type’ and ‘enum v4l2_memory’ [-Wenum-compare]

    On all places V4L2_MEMORY_USERPTR is used, it is associated with
    q->memory, and not b->type. So, the fix seems obvious.

    Cc: Andrzej Pietrasiewicz
    Cc: Kyungmin Park
    Cc: Marek Szyprowski
    Cc: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • This patch is a result of review of mem_priv entry usage in videobuf2 core.
    It fixes all all potential places where it was not checked against NULL or
    zeroed after freeing as well as a few style issues.

    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • This patch removes unused 'plane' argument from call_memop macro.

    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • To get direct access to userspace memory pages vb2 allocator needs to
    gather read access on mmap semaphore in the current process.
    The same semaphore is taken before calling mmap operation, while
    both mmap and qbuf are called by the driver or v4l2 core with
    driver's lock held. To avoid a AB-BA deadlock (mmap_sem then
    driver's lock in mmap and driver's lock then mmap_sem in qbuf)
    the videobuf2 core release driver's lock, takes mmap_sem and then
    takes again driver's lock. get_userptr methods are now called with
    all needed locks already taken to avoid further lock magic inside
    memory allocator's code.

    Reported-by: Laurent Pinchart
    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • Heuristic that checks if the memory pointer has been changed lacked a check
    if the pointer was actually provided by the userspace, what allowed one to
    queue a NULL pointer which was accepted without further checking. This
    patch fixes this issue.

    Reported-by: Sylwester Nawrocki
    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     

08 Nov, 2011

3 commits


04 Nov, 2011

5 commits


19 Oct, 2011

1 commit


07 Sep, 2011

3 commits

  • This patch changes the order of operations during stream on call. Now the
    buffers are first queued to the driver and then the start_streaming method
    is called.

    This resolves the most common case when the driver needs to know buffer
    addresses to enable dma engine and start streaming. Additional parameter
    to start_streaming method have been added to simplify drivers code. The
    driver are now obliged to check if the number of queued buffers is high
    enough to enable hardware streaming. If not - it can return an error. In
    such case all the buffers that have been pre-queued are invalidated.

    This patch also updates all videobuf2 clients to work properly with the
    changed order of operations.

    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    CC: Guennadi Liakhovetski
    CC: Hans Verkuil
    CC: Tomasz Stanislawski
    CC: Sylwester Nawrocki
    CC: Kamil Debski
    CC: Jonathan Corbet
    CC: Josh Wu
    CC: Hans de Goede
    CC: Paul Mundt
    Tested-by: Josh Wu
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • MAPPED flag was set for the buffer only if all it's planes were mapped and
    relied on a simple mapping counter. This assumption is really bogus,
    especially because the buffers may be mapped multiple times. Also the
    meaning of this flag for muliplane buffers was not really useful. This
    patch fixes this issue by setting the MAPPED flag for the buffer if any of
    it's planes is in use (what means that has been mapped at least once), so
    MAPPED flag can be used as 'in_use' indicator.

    Reported-by: Hans Verkuil
    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    Tested-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • Videobuf2 accepted any userptr buffer without verifying if its size is
    large enough to store the video data from the driver. The driver reports
    the minimal size of video data once in queue_setup and expects that
    videobuf2 provides buffers that match these requirements. This patch
    adds the required check.

    Reported-by: Laurent Pinchart
    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    Acked-by: Laurent Pinchart
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     

01 Jul, 2011

3 commits

  • __vb2_queue_alloc function returns the number of successfully allocated
    buffers. There is no point in checking if the returned value is negative.
    If this function returns 0, videobuf2 should just return -ENOMEM to
    userspace, because no driver can work without memory buffers.

    Reported-by: Jonathan Corbet
    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • queued_count variable was left untouched during the queue reinitialization
    in __vb2_queue_cancel, what might lead to mismatch between the real number
    of queued buffers and queued_count variable.

    Reported-by: Uwe Kleine-König
    Signed-off-by: Marek Szyprowski
    CC: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • This reverts commit 31901a078af29c33c736dcbf815656920e904632.

    Queue should be reinitialized on each REQBUFS() call even if the memory
    access method and buffer count have not been changed. The user might have
    changed the format and if we go the short path introduced in that commit,
    the memory buffer will not be reallocated to fit with new format.

    The previous patch was just over-engineered optimization, which just
    introduced a bug to videobuf2.

    Reported-by: Uwe Kleine-König
    Signed-off-by: Marek Szyprowski
    CC: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     

20 Apr, 2011

2 commits

  • q->memory entry is initialized to late, so if allocation of memory buffers
    fails, the buffers might not be freed correctly (q->memory is tested in
    __vb2_free_mem, which can be called before setting q->memory).

    Reported-by: Kamil Debski
    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • Videobuf2 core assumes that driver doesn't set any buffer flags.
    This is correct for buffer state flags that videobuf2 manages,
    but the other flags like V4L2_BUF_FLAG_{KEY,P,B}FRAME,
    V4L2_BUF_FLAG_TIMECODE and V4L2_BUF_FLAG_INPUT should be passed from or to
    the driver.

    Reported-by: Jonghun Han
    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     

13 Apr, 2011

1 commit


22 Mar, 2011

9 commits

  • Fix vb2 not handling return value from start_streaming() callback.

    Signed-off-by: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Pawel Osciak
     
  • poll() should be returning poll-specific error values, not E* errors.

    Signed-off-by: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Pawel Osciak
     
  • Signed-off-by: Pawel Osciak
    Signed-off-by: Mauro Carvalho Chehab

    Pawel Osciak
     
  • __vb2_queue_free function doesn't really return anything useful. This patch
    removes support for the return value to simplify the code.

    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • Return immediately if the target number of buffers is the same as
    the current one and memory access type doesn't change.

    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • This patch fixes 2 minor bugs in videobuf2 core:
    1. Queue should be reallocated if one change the memory access
    method without changing the number of buffers.
    2. In case of REQBUFS(0), the request should not be passed to the
    driver.

    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • drivers/media/video/videobuf2-core.c: In function ‘__vb2_perform_fileio’:
    drivers/media/video/videobuf2-core.c:1638: warning: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘size_t’
    drivers/media/video/videobuf2-core.c:1697: warning: format ‘%ld’ expects type ‘long int’, but argument 2 has type ‘size_t’
    drivers/media/video/videobuf2-core.c:1703: warning: format ‘%ld’ expects type ‘long int’, but argument 2 has type ‘size_t’

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • Add a generic file io (read and write) emulator for videobuf2. It uses
    MMAP memory type buffers and generic vb2 calls: req_bufs, qbuf and
    dqbuf. Video date is being copied from mmap buffers to userspace with
    standard copy_to_user() function. To add support for file io the driver
    needs to provide an additional callback - read_setup or write_setup. It
    should provide the default number of buffers used by emulator and flags.

    With these flags one can detemine the style of read() or write()
    emulation. By default 'streaming' style is used. With
    VB2_FILEIO_READ_ONCE flag one can select 'one shot' mode for read()
    emulator. With VB2_FILEIO_WRITE_IMMEDIATE flag one can select immediate
    conversion of write calls to qbuf for write() emulator, so the vb2 will
    not wait until each buffer is filled completely before queueing it to
    the driver.

    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    Reviewed-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab

    Marek Szyprowski
     
  • Videobuf2 is a Video for Linux 2 API-compatible driver framework for
    multimedia devices. It acts as an intermediate layer between userspace
    applications and device drivers. It also provides low-level, modular
    memory management functions for drivers.

    Videobuf2 eases driver development, reduces drivers' code size and aids in
    proper and consistent implementation of V4L2 API in drivers.

    Videobuf2 memory management backend is fully modular. This allows custom
    memory management routines for devices and platforms with non-standard
    memory management requirements to be plugged in, without changing the
    high-level buffer management functions and API.

    The framework provides:
    - implementations of streaming I/O V4L2 ioctls and file operations
    - high-level video buffer, video queue and state management functions
    - video buffer memory allocation and management

    Signed-off-by: Pawel Osciak
    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    CC: Pawel Osciak
    Reviewed-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab

    Pawel Osciak