[1/2] pipeline: rpi: Pass sensor HDR state to the IPA
diff mbox series

Message ID 20261120114233.86270-2-danius@kurokesu.com
State New
Headers show
Series
  • Raspberry Pi: Sensor HDR and decompand curve from camera helper
Related show

Commit Message

Danius Kalvaitis Nov. 20, 2026, 11:42 a.m. UTC
Some sensors switch HDR through V4L2_CID_WIDE_DYNAMIC_RANGE without
changing mode size or bit depth. The IPA currently cannot tell such HDR
and linear modes apart, although they need different processing, such
as decompanding.

Read the control at configure time and store its state in CameraMode
for camera helpers and control algorithms.

Signed-off-by: Danius Kalvaitis <danius@kurokesu.com>
---
 include/libcamera/ipa/raspberrypi.mojom             |  1 +
 src/ipa/rpi/common/ipa_base.cpp                     |  1 +
 src/ipa/rpi/controller/camera_mode.h                |  2 ++
 src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 10 ++++++++++
 4 files changed, 14 insertions(+)

Patch
diff mbox series

diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom
index 1b7e03582..8213bb882 100644
--- a/include/libcamera/ipa/raspberrypi.mojom
+++ b/include/libcamera/ipa/raspberrypi.mojom
@@ -37,6 +37,7 @@  struct BufferIds {
 
 struct ConfigParams {
 	uint32 transform;
+	bool sensorHdr;
 	libcamera.ControlInfoMap sensorControls;
 	libcamera.ControlInfoMap ispControls;
 	libcamera.ControlInfoMap lensControls;
diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp
index c28483444..319d6bf44 100644
--- a/src/ipa/rpi/common/ipa_base.cpp
+++ b/src/ipa/rpi/common/ipa_base.cpp
@@ -215,6 +215,7 @@  int32_t IpaBase::configure(const IPACameraSensorInfo &sensorInfo, const ConfigPa
 	setMode(sensorInfo);
 
 	mode_.transform = static_cast<libcamera::Transform>(params.transform);
+	mode_.sensorHdr = params.sensorHdr;
 
 	/* Pass the camera mode to the CamHelper to setup algorithms. */
 	helper_->setCameraMode(mode_);
diff --git a/src/ipa/rpi/controller/camera_mode.h b/src/ipa/rpi/controller/camera_mode.h
index 61162b327..5eb05705e 100644
--- a/src/ipa/rpi/controller/camera_mode.h
+++ b/src/ipa/rpi/controller/camera_mode.h
@@ -56,4 +56,6 @@  struct CameraMode {
 	/* Mode specific analogue gain limits */
 	double minAnalogueGain;
 	double maxAnalogueGain;
+	/* sensor HDR state */
+	bool sensorHdr;
 };
diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
index d6ce2dbf5..b9347235a 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
@@ -1236,6 +1236,16 @@  int CameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::Config
 	Transform transform = config->orientation / Orientation::Rotate0;
 	params.transform = static_cast<unsigned int>(transform);
 
+	/*
+	 * Sensor HDR may not change mode size or bit depth, so tell the IPA
+	 * if it is enabled.
+	 */
+	if (sensor_->controls().count(V4L2_CID_WIDE_DYNAMIC_RANGE)) {
+		ControlList ctrls = sensor_->getControls({ { V4L2_CID_WIDE_DYNAMIC_RANGE } });
+		if (!ctrls.empty())
+			params.sensorHdr = ctrls.get(V4L2_CID_WIDE_DYNAMIC_RANGE).get<int32_t>();
+	}
+
 	/* Ready the IPA - it must know about the sensor resolution. */
 	ret = ipa_->configure(sensorInfo_, params, result);
 	if (ret < 0) {