[libcamera-devel] [PATCH 1/3] libcamera: camera_sensor: Add a function to reset the HBLANK interval

David Plowman david.plowman at raspberrypi.com
Tue Nov 22 13:03:41 CET 2022


The existing code to reset the HBLANK interval to the minimum value
(in the init method) is moved into a separate function that pipeline
handlers will be able to call.

We no longer reset the HBLANK in init because we may not own the
camera and the operation may fail, so pipeline handlers will have to
call the new method for themselves. These calls will be added in
subsequent commits.

Signed-off-by: David Plowman <david.plowman at raspberrypi.com>
---
 include/libcamera/internal/camera_sensor.h |  2 ++
 src/libcamera/camera_sensor.cpp            | 10 +++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h
index b9f4d786..c97b5698 100644
--- a/include/libcamera/internal/camera_sensor.h
+++ b/include/libcamera/internal/camera_sensor.h
@@ -68,6 +68,8 @@ public:
 
 	CameraLens *focusLens() { return focusLens_.get(); }
 
+	int resetHblank();
+
 protected:
 	std::string logPrefix() const override;
 
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index 572a313a..589e9736 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -176,6 +176,11 @@ int CameraSensor::init()
 	if (ret)
 		return ret;
 
+	return applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);
+}
+
+int CameraSensor::resetHblank()
+{
 	/*
 	 * 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
@@ -192,17 +197,16 @@ int CameraSensor::init()
 	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>();
+	int ret = 0;
 
 	if (hblankMin != hblankMax) {
 		ControlList ctrl(subdev_->controls());
 
 		ctrl.set(V4L2_CID_HBLANK, hblankMin);
 		ret = subdev_->setControls(&ctrl);
-		if (ret)
-			return ret;
 	}
 
-	return applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);
+	return ret;
 }
 
 int CameraSensor::validateSensorDriver()
-- 
2.30.2



More information about the libcamera-devel mailing list