[libcamera-devel] [PATCH v3 10/23] libcamera: camera_sensor: Initialize delayed controls
Jacopo Mondi
jacopo at jmondi.org
Thu Jun 30 15:38:49 CEST 2022
Add to the CameraSensor class an instance of the DelayedControls
class and initialize it using the sensor delays registered in camera
sensor static properties.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
include/libcamera/internal/camera_sensor.h | 3 ++
src/libcamera/camera_sensor/camera_sensor.cpp | 41 +++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h
index 1eab5e9d53f0..bd5aa0dbc27d 100644
--- a/include/libcamera/internal/camera_sensor.h
+++ b/include/libcamera/internal/camera_sensor.h
@@ -21,6 +21,7 @@
#include <libcamera/ipa/core_ipa_interface.h>
#include "libcamera/internal/camera_sensor_helper.h"
+#include "libcamera/internal/delayed_controls.h"
#include "libcamera/internal/formats.h"
#include "libcamera/internal/v4l2_subdevice.h"
@@ -82,6 +83,7 @@ private:
void initStaticProperties();
void initTestPatternModes();
int initProperties();
+ int initDelayedControls();
int updateControls();
int applyTestPatternMode(controls::draft::TestPatternModeEnum mode);
int discoverAncillaryDevices();
@@ -110,6 +112,7 @@ private:
std::unique_ptr<CameraLens> focusLens_;
std::unique_ptr<CameraSensorHelper> helper_;
+ std::unique_ptr<DelayedControls> delayedCtrls_;
};
} /* namespace libcamera */
diff --git a/src/libcamera/camera_sensor/camera_sensor.cpp b/src/libcamera/camera_sensor/camera_sensor.cpp
index 976d34aaf876..211c7461f5c6 100644
--- a/src/libcamera/camera_sensor/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor/camera_sensor.cpp
@@ -189,6 +189,10 @@ int CameraSensor::init()
if (ret)
return ret;
+ ret = initDelayedControls();
+ if (ret)
+ return ret;
+
return applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);
}
@@ -460,6 +464,43 @@ int CameraSensor::initProperties()
return 0;
}
+int CameraSensor::initDelayedControls()
+{
+ /* If no static priorities are available, all controls have delay 0. */
+ static const CameraSensorProperties::SensorDelays noDelays{};
+ const CameraSensorProperties::SensorDelays *delays = staticProps_
+ ? &staticProps_->sensorDelays
+ : &noDelays;
+
+ const std::map<uint32_t, const ControlId *> controlsMap{
+ { V4L2_CID_ANALOGUE_GAIN, &controls::internal::AnalogueGain },
+ { V4L2_CID_EXPOSURE, &controls::internal::ExposureTime },
+ { V4L2_CID_VBLANK, &controls::internal::FrameDuration },
+ };
+
+ std::unordered_map<uint32_t, DelayedControls::ControlParams> params;
+ for (const auto &[v4l2Ctrl, ctrl] : controlsMap) {
+ uint32_t delay = 0;
+
+ /*
+ * If the control is not registered in the delays map, assume 0
+ * as delay.
+ */
+ auto it = delays->find(ctrl);
+ if (it != delays->end())
+ delay = it->second;
+
+ /* VBLANK needs the priority flag set. */
+ bool priority = v4l2Ctrl == V4L2_CID_VBLANK ? true : false;
+
+ params[v4l2Ctrl] = { delay, priority };
+ }
+
+ delayedCtrls_ = std::make_unique<DelayedControls>(device(), params);
+
+ return 0;
+}
+
int CameraSensor::updateControls()
{
if (!bayerFormat_)
--
2.36.1
More information about the libcamera-devel
mailing list