[libcamera-devel,v3,0/6] Rework camera configuration to introduce negotiation of parameters
mbox series

Message ID 20190521192740.28112-1-laurent.pinchart@ideasonboard.com
Headers show
Series
  • Rework camera configuration to introduce negotiation of parameters
Related show

Message

Laurent Pinchart May 21, 2019, 7:27 p.m. UTC
Hello,

Camera are currently configured in two steps, first by retrieving a
configuration for a set of stream usages with streamConfiguration(), and
then by configuring the camera with configureStreams(). The camera
configuration can be changed by the application between those two steps,
but there is no way for applications to find out what changes are
compatible with the camera, as the configureStreams() method either
accepts the configuration as-is, or rejects it completely without any
additional feedback. This leaves applications with no other option than
shooting in the dark.

This patch series reworks the camera configuration API to fix this
problems, and introduces a new concept: configuration negotiation
through validation.

The first 5 patches refactor the camera configuration API by renaming
the confusing streamConfiguration() and configureStreams() methods to
generateConfiguration() and configure() (1/6), replacing stream usages
with plain stream roles (2/6, with a regression in the features exposed
by libcamera, but this gets fixed in the same series), and further
refactoring the APIs (3/6 and 4/6) and the pipeline handlers (5/6).

Patch 6/6 introduces configuration negotiation. The core idea is to
introduce a new validate() method for the CameraConfiguration class that
validates and possibly updates the configuration to the closest
supported configuration. Applications can then create a configuration
(possibly from scratch, or using Camera::generateConfiguration() with a
set of stream roles), modify it, and then call validate() to request a
configuration update from libcamera. If the configuration is updated,
the application can then inspect it, decide to use the updated version,
or try again, until a configuration acceptable for both libcamera and
the application is found.

The validate() operation is implemented with the help of the pipeline
handlers that need to provide a subclass of CameraConfiguration. This
puts more burden on the pipeline handlers, but is offset by the fact
that the pipeline handler configure() method doesn't need to perform
validation anymore as the configuration is validated prior to
configure().

Compared to v1, the most notable changes are

- Dropped patch 01/12 that has already been merged
- Added a CameraConfiguration::at() method and use it on config pointers
- Dropped patches 08/12 to 12/12, a new version will be posted by Niklas

Changes compared to v2 are detailed in each individual patch.

Laurent Pinchart (6):
  libcamera: camera: Rename configureStreams() and streamConfiguration()
  libcamera: Use stream roles directly instead of StreamUsage
  libcamera: Refactor the camera configuration storage and API
  libcamera: camera: Return a pointer from generateConfiguration()
  libcamera: pipeline: Move camera data classes to the top level scope
  libcamera: camera: Add a validation API to the CameraConfiguration
    class

 include/libcamera/camera.h               |  55 ++--
 include/libcamera/stream.h               |  56 ++--
 src/cam/main.cpp                         |  74 +++--
 src/libcamera/camera.cpp                 | 351 ++++++++++++-----------
 src/libcamera/include/pipeline_handler.h |  10 +-
 src/libcamera/pipeline/ipu3/ipu3.cpp     | 349 +++++++++++++++-------
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 207 +++++++++----
 src/libcamera/pipeline/uvcvideo.cpp      | 127 +++++---
 src/libcamera/pipeline/vimc.cpp          | 142 ++++++---
 src/libcamera/pipeline_handler.cpp       |  50 ++--
 src/libcamera/stream.cpp                 | 116 +++-----
 src/qcam/main_window.cpp                 |  10 +-
 src/qcam/main_window.h                   |   4 +-
 test/camera/capture.cpp                  |  29 +-
 test/camera/configuration_default.cpp    |  14 +-
 test/camera/configuration_set.cpp        |  35 ++-
 test/camera/statemachine.cpp             |  32 ++-
 17 files changed, 1007 insertions(+), 654 deletions(-)