[libcamera-devel] [PATCH v3 2/2] libcamera:camera_sensor, ipa: raspberrypi: Test readOnly() for HBLANK control
Kieran Bingham
kieran.bingham at ideasonboard.com
Thu Nov 2 18:24:39 CET 2023
From: Naushir Patuck <naush at raspberrypi.com>
Use ControlInfo::readOnly() to test if the camera sensor accepts V4L2_CID_HBLANK
control changes. This replaces the current workaround where we test if the
V4L2_CID_HBLANK min and max values are the same to determine if a control is
read-only.
Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
src/ipa/rpi/common/ipa_base.cpp | 12 +-----------
src/libcamera/camera_sensor.cpp | 14 ++------------
2 files changed, 3 insertions(+), 23 deletions(-)
diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp
index a1fec3aa3dd1..a623ad1bae66 100644
--- a/src/ipa/rpi/common/ipa_base.cpp
+++ b/src/ipa/rpi/common/ipa_base.cpp
@@ -1346,17 +1346,7 @@ void IpaBase::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)
ctrls.set(V4L2_CID_EXPOSURE, exposureLines);
ctrls.set(V4L2_CID_ANALOGUE_GAIN, gainCode);
- /*
- * At present, there is no way of knowing if a control is read-only.
- * As a workaround, assume that if the minimum and maximum values of
- * the V4L2_CID_HBLANK control are the same, it implies the control
- * is read-only. This seems to be the case for all the cameras our IPA
- * works with.
- *
- * \todo The control API ought to have a flag to specify if a control
- * is read-only which could be used below.
- */
- if (mode_.minLineLength != mode_.maxLineLength)
+ if (!sensorCtrls_.at(V4L2_CID_HBLANK).readOnly())
ctrls.set(V4L2_CID_HBLANK, static_cast<int32_t>(hblank));
/*
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index ee1066c680ff..12512341feb6 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -188,20 +188,10 @@ int CameraSensor::init()
* Set HBLANK to the minimum to start with a well-defined line length,
* allowing IPA modules that do not modify HBLANK to use the sensor
* minimum line length in their calculations.
- *
- * At present, there is no way of knowing if a control is read-only.
- * As a workaround, assume that if the minimum and maximum values of
- * the V4L2_CID_HBLANK control are the same, it implies the control
- * is read-only.
- *
- * \todo The control API ought to have a flag to specify if a control
- * is read-only which could be used below.
*/
const ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);
- const int32_t hblankMin = hblank.min().get<int32_t>();
- const int32_t hblankMax = hblank.max().get<int32_t>();
-
- if (hblankMin != hblankMax) {
+ if (!hblank.readOnly()) {
+ const int32_t hblankMin = hblank.min().get<int32_t>();
ControlList ctrl(subdev_->controls());
ctrl.set(V4L2_CID_HBLANK, hblankMin);
--
2.34.1
More information about the libcamera-devel
mailing list