[libcamera-devel] [RFC PATCH 0/2] Sensor mode hints

David Plowman david.plowman at raspberrypi.com
Thu Sep 16 15:20:13 CEST 2021


Hi everyone

Here's a first attempt at functionality that allows applications to
provide "hints" as to what kind of camera mode they want.

1. Bit Depths and Sizes

So far I'm allowing hints about bit depth and the image sizes that can
be read out of a sensor, and I've gathered these together into
something I've call a SensorMode.

I've added a SensorMode field to the CameraConfiguration so that
applications can optionally put in there what they think they want,
and also a CameraSensor::getSensorModes function that returns a list
of the supported modes (raw formats only...).

There are various ways an application could use this:

* It might not care and would ignore the new field altogether. The
  pipeline handler will stick to its current behaviour.

* It might have some notion of what it wants, perhaps a larger bit
  depth, and/or a range of sizes. It can fill some or all of those
  into the SensorMode and the pipeline handler should respect it.

* Or it could query the CameraSensor for its list of SensorModes and
  then sift through them looking for the one that it likes best.

2. Field of View and Framerates

The SensorMode should probably include FoV and framerate information
so that applications can make intelligent choices automatically.
However, this is a bit trickier for various reasons so I've left it
out. There could be a later phase of work that adds these.

Even without this, however, the implementation gets us out of our
rather critical hole where we simply can't get 10-bit modes. It also
provides a better alternative to the current nasty practice of
requesting a raw stream specifically to bodge the camera mode
selection, even when the raw stream is not actually wanted!

3. There are 2 commits here

The first adds the SensorMode class, puts it into the
CameraConfiguration, and allows the supported modes to be listed from
the CameraSensor. (All the non-Pi stuff.)

The second commit updates our mode selection code to select according
to the hinted SensorMode (figuring out defaults if it was empty). But
it essentially works just the same, if in a slightly more generic way.

The code here is fully functional and seems to work fine. Would other
pipeline handlers be able to adapt to the idea of a "hinted
SensorMode" as easily?


As always, I'm looking forward to people's thoughts!

Thanks
David

David Plowman (2):
  libcamera: Add SensorMode class
  libcamera: pipeline_handler: raspberrypi: Handle the new SensorMode
    hint

 include/libcamera/camera.h                    |   3 +
 include/libcamera/internal/camera_sensor.h    |   4 +
 include/libcamera/meson.build                 |   1 +
 include/libcamera/sensor_mode.h               |  50 +++++++++
 src/libcamera/camera_sensor.cpp               |  15 +++
 src/libcamera/meson.build                     |   1 +
 .../pipeline/raspberrypi/raspberrypi.cpp      | 105 +++++++++++++-----
 src/libcamera/sensor_mode.cpp                 |  60 ++++++++++
 8 files changed, 212 insertions(+), 27 deletions(-)
 create mode 100644 include/libcamera/sensor_mode.h
 create mode 100644 src/libcamera/sensor_mode.cpp

-- 
2.20.1



More information about the libcamera-devel mailing list