[RFC,0/3] libcamera: Allow to query binning factors
mbox series

Message ID 20261118-sklug-binning-factors-v1-v1-0-5e552aefbb07@ideasonboard.com
Headers show
Series
  • libcamera: Allow to query binning factors
Related show

Message

Stefan Klug Nov. 18, 2026, 4:08 p.m. UTC
Hi everyone,

For camshark to properly draw sensor rectangles (and most likely other
use cases) it is necessary to know the binning factors of the chosen
sensor configuration. Guessing these based on ScalerCropMaximum and
image size is error prone especially when additional scalers (like the
dw100 on the imx8mp) are involved.

One idea was to add the binning factors to the camera properties. That
was dropped in favour of extending the already existing
CameraConfiguration::sensorConfig infrastructure.

This RFC implements that functionality by adding a
validatedSensorConfig() accessor to CameraConfiguration.

To be honest, I don't like this implementation. It shows that
CameraConfiguration::sensorConfig is not fully implemented and adding a
similar function doesn't make that area of the API nicer.

Additionally it requires us to populate the sensor config during
validate() which adds complexity. If we'd just populate a camera
property we could delay querying the binning factors until
PipelineHandler::configure(). But camera properties should not be
modified... oh my.

This is only tested on rkisp1 and compile tested on the others.

I'd be happy to get some thoughts on this.

Best regards,
Stefan

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
Stefan Klug (3):
      libcamera: v4l2_subdevice: Add whence parameter to set/getSelection()
      libcamera: camera_sensor: Add function to query the sensor configuration
      libcamera: Implement CameraConfiguration::validatedSensorConfig()

 include/libcamera/camera.h                         |  2 +
 include/libcamera/internal/camera_sensor.h         |  4 ++
 include/libcamera/internal/v4l2_subdevice.h        | 14 ++--
 src/libcamera/camera.cpp                           | 10 +++
 src/libcamera/pipeline/imx8-isi/imx8-isi.cpp       |  7 ++
 src/libcamera/pipeline/ipu3/cio2.cpp               | 10 ++-
 src/libcamera/pipeline/ipu3/cio2.h                 |  5 +-
 src/libcamera/pipeline/ipu3/ipu3.cpp               |  4 +-
 src/libcamera/pipeline/mali-c55/mali-c55.cpp       |  9 ++-
 src/libcamera/pipeline/rkisp1/rkisp1.cpp           |  4 ++
 .../pipeline/rpi/common/pipeline_base.cpp          |  5 ++
 src/libcamera/pipeline/rpi/common/pipeline_base.h  |  3 +
 src/libcamera/pipeline/simple/simple.cpp           | 10 +++
 src/libcamera/pipeline/uvcvideo/uvcvideo.cpp       |  2 +
 src/libcamera/pipeline/vimc/vimc.cpp               |  2 +
 src/libcamera/pipeline/virtual/virtual.cpp         |  2 +
 src/libcamera/sensor/camera_sensor_legacy.cpp      | 83 ++++++++++++++++++++--
 src/libcamera/sensor/camera_sensor_raw.cpp         | 12 ++++
 src/libcamera/v4l2_subdevice.cpp                   |  8 +--
 src/py/libcamera/py_main.cpp                       |  3 +-
 test/stream/stream_colorspace.cpp                  |  8 +++
 21 files changed, 188 insertions(+), 19 deletions(-)
---
base-commit: da6a6ed33ed0ab305f10b6f8b44736150d39cef4
change-id: 20261118-sklug-binning-factors-v1-96b58ed11c51

Best regards,