[libcamera-devel] [PATCH v4 00/22] Support v4l2-compliance

Paul Elder paul.elder at ideasonboard.com
Wed Jun 24 16:52:34 CEST 2020


This patchset makes the V4L2 compatibility layer comply with
v4l2-compliance, and v4l2-compliance -s. I have gotten zero failues and
2 warnings with a uvcvideo libcamera camera. The two warnings are that
VIDIOC_S_FMT doesn't work from a second fd (after a different fd has
already called it), and that VIDIOC_CREATEBUFS is not supported, which I
think are fair to not support.

The v4l2-compliance used for this test only adds libcamera to businfo
prefixes with respect to master.

Note that there are a couple failues when using a vimc libcamera camera,
as these cameras doesn't support setting frame sizes that are not
multiples of 3.

Also, while trying to comply with v4l2-compliance I lost support for
firefox. It's v4 and I still haven't gotten around to it. qv4l2 still
works, though.

* Changes in v4
- cosmetic changes and minor code polishing

* Changes in v3:

- replace exclusive locking of the camera proxy with a concept of
  ownership
- implement v4l2 priority to actually lock the camera similar to v4l2 in
  the kernel, alongside implicit ownership of the camera
- made the compat layer thread-safe by serializing accesses to the
  camera proxy
- split conglomerate v4l2-compliance fix patches into separate small
  patches

* Changes in v2:

The biggest change in v2 was adding V4L2CameraFile to contain all the
information related to the open file instance, instead of containing
maps for them within V4L2CameraProxy. dup is handled solely in
V4L2CompatManager, by adding another fd -> V4L2CameraFile map. The
V4L2CameraFile recount is handled automatically by V4L2CompatManager
with shared pointers, while V4L2CameraProxy recount is handled manually,
since it is not constructed and deconstructed but rather is open()ed and
close()d.

The other changes are minor in comparison. One is consolidating the null
arg checks in the ioctl handlerrs. Another is splitting all the
v4l2-compliance streaming test fixes to their own patches.

Paul Elder (17):
  v4l2: v4l2_camera_file: Add V4L2CameraFile to model the opened camera
    file
  v4l2: v4l2_compat: Support multiple open
  v4l2: v4l2_camera_proxy: Check for null arg values in main ioctl
    handler
  v4l2: v4l2_camera_proxy: Fix v4l2-compliance support for extended
    formats
  v4l2: v4l2_camera_proxy: Implement VIDIOC_G/S_PRIORITY
  v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUMINPUT, VIDIOC_G/S_INPUT
  v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUM_FRAMESIZES
  v4l2: v4l2_camera: Add isRunning()
  v4l2: v4l2_camera_proxy: Disallow dqbuf when not streaming
  v4l2: v4l2_camera_proxy: noop if streamon when stream is already on
  v4l2: v4l2_camera_proxy: Reset buffer flags on reqbufs 0
  v4l2: v4l2_camera: Don't use libcamera::Semaphore for available
    buffers
  v4l2: v4l2_camera: Clear pending requests on freeBuffers and streamOff
  v4l2: v4l2_camera_proxy: Check arg->index bounds for querybuf, qbuf,
    dqbuf
  v4l2: v4l2_camera_proxy: Don't allow streamon if no buffers have been
    requested
  v4l2: v4l2_camera_proxy: Don't allow buffers to be freed if still
    mmaped
  v4l2: v4l2_camera_proxy: Fix buffer flags related to queueing

 src/v4l2/meson.build             |   1 +
 src/v4l2/v4l2_camera.cpp         |  44 +++-
 src/v4l2/v4l2_camera.h           |  10 +-
 src/v4l2/v4l2_camera_file.cpp    |  45 ++++
 src/v4l2/v4l2_camera_file.h      |  35 +++
 src/v4l2/v4l2_camera_proxy.cpp   | 402 +++++++++++++++++++++++++------
 src/v4l2/v4l2_camera_proxy.h     |  57 +++--
 src/v4l2/v4l2_compat_manager.cpp |  71 +++---
 src/v4l2/v4l2_compat_manager.h   |   4 +-
 9 files changed, 539 insertions(+), 130 deletions(-)
 create mode 100644 src/v4l2/v4l2_camera_file.cpp
 create mode 100644 src/v4l2/v4l2_camera_file.h

-- 
2.27.0







Paul Elder (22):
  v4l2: v4l2_camera_file: Add V4L2CameraFile to model the opened camera
    file
  v4l2: V4L2CameraProxy: Take V4L2CameraFile as argument for intercepted
    calls
  v4l2: v4l2_compat: Support multiple open
  v4l2: v4l2_camera_proxy: Free old buffers on reqbufs > 0
  v4l2: v4l2_camera_proxy: Clear reserved field in reqbufs
  v4l2: v4l2_camera_proxy: Set timestamp monotonic buffer flag on
    reqbufs
  v4l2: v4l2_camera_proxy: Check for null arg values in main ioctl
    handler
  v4l2: v4l2_camera_proxy: Fix v4l2-compliance support for extended
    formats
  v4l2: v4l2_camera_proxy: Implement VIDIOC_G/S_PRIORITY
  v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUMINPUT, VIDIOC_G/S_INPUT
  v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUM_FRAMESIZES
  v4l2: v4l2_camera: Add isRunning()
  v4l2: v4l2_camera_proxy: Disallow dqbuf when not streaming
  v4l2: v4l2_camera_proxy: noop if streamon when stream is already on
  v4l2: v4l2_camera_proxy: Reset buffer flags on reqbufs 0
  v4l2: v4l2_camera: Don't use libcamera::Semaphore for available
    buffers
  v4l2: v4l2_camera: Clear pending requests on freeBuffers and streamOff
  v4l2: v4l2_camera_proxy: Check arg->index bounds for querybuf, qbuf,
    dqbuf
  v4l2: v4l2_camera_proxy: Don't allow streamon if no buffers have been
    requested
  v4l2: v4l2_camera_proxy: Don't allow buffers to be freed if still
    mmaped
  v4l2: v4l2_camera_proxy: Fix buffer flags related to queueing
  v4l2: v4l2_camera_proxy: Serialize accesses to the proxy

 src/v4l2/meson.build             |   1 +
 src/v4l2/v4l2_camera.cpp         |  46 +++-
 src/v4l2/v4l2_camera.h           |  10 +-
 src/v4l2/v4l2_camera_file.cpp    |  26 ++
 src/v4l2/v4l2_camera_file.h      |  37 +++
 src/v4l2/v4l2_camera_proxy.cpp   | 436 ++++++++++++++++++++++++++-----
 src/v4l2/v4l2_camera_proxy.h     |  62 +++--
 src/v4l2/v4l2_compat_manager.cpp |  69 +++--
 src/v4l2/v4l2_compat_manager.h   |   4 +-
 9 files changed, 557 insertions(+), 134 deletions(-)
 create mode 100644 src/v4l2/v4l2_camera_file.cpp
 create mode 100644 src/v4l2/v4l2_camera_file.h

-- 
2.27.0





Paul Elder (22):
  v4l2: v4l2_camera_file: Add V4L2CameraFile to model the opened camera
    file
  v4l2: V4L2CameraProxy: Take V4L2CameraFile as argument for intercepted
    calls
  v4l2: v4l2_compat: Support multiple open
  v4l2: v4l2_camera_proxy: Free old buffers on reqbufs > 0
  v4l2: v4l2_camera_proxy: Clear reserved field in reqbufs
  v4l2: v4l2_camera_proxy: Set timestamp monotonic buffer flag on
    reqbufs
  v4l2: v4l2_camera_proxy: Check for null arg values in main ioctl
    handler
  v4l2: v4l2_camera_proxy: Fix v4l2-compliance support for extended
    formats
  v4l2: v4l2_camera_proxy: Implement VIDIOC_G/S_PRIORITY
  v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUMINPUT, VIDIOC_G/S_INPUT
  v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUM_FRAMESIZES
  v4l2: v4l2_camera: Add isRunning()
  v4l2: v4l2_camera_proxy: Disallow dqbuf when not streaming
  v4l2: v4l2_camera_proxy: noop if streamon when stream is already on
  v4l2: v4l2_camera_proxy: Clear internal buffer vector on reqbufs 0
  v4l2: v4l2_camera: Don't use libcamera::Semaphore for available
    buffers
  v4l2: v4l2_camera: Clear pending requests on freeBuffers and streamOff
  v4l2: v4l2_camera_proxy: Check arg->index bounds for querybuf, qbuf,
    dqbuf
  v4l2: v4l2_camera_proxy: Don't allow streamon if no buffers have been
    requested
  v4l2: v4l2_camera_proxy: Don't allow buffers to be freed if still
    mmaped
  v4l2: v4l2_camera_proxy: Fix buffer flags related to queueing
  v4l2: v4l2_camera_proxy: Serialize accesses to the proxy

 src/v4l2/meson.build             |   1 +
 src/v4l2/v4l2_camera.cpp         |  51 +++-
 src/v4l2/v4l2_camera.h           |  10 +-
 src/v4l2/v4l2_camera_file.cpp    |  26 ++
 src/v4l2/v4l2_camera_file.h      |  37 +++
 src/v4l2/v4l2_camera_proxy.cpp   | 445 +++++++++++++++++++++++++------
 src/v4l2/v4l2_camera_proxy.h     |  64 +++--
 src/v4l2/v4l2_compat_manager.cpp |  66 ++---
 src/v4l2/v4l2_compat_manager.h   |   4 +-
 9 files changed, 563 insertions(+), 141 deletions(-)
 create mode 100644 src/v4l2/v4l2_camera_file.cpp
 create mode 100644 src/v4l2/v4l2_camera_file.h

-- 
2.27.0



More information about the libcamera-devel mailing list