summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcamera/internal/camera_sensor.h2
-rw-r--r--include/libcamera/internal/camera_sensor_properties.h9
-rw-r--r--src/libcamera/sensor/camera_sensor.cpp12
-rw-r--r--src/libcamera/sensor/camera_sensor_legacy.cpp25
-rw-r--r--src/libcamera/sensor/camera_sensor_properties.cpp107
5 files changed, 155 insertions, 0 deletions
diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h
index 8aafd82e..d030e254 100644
--- a/include/libcamera/internal/camera_sensor.h
+++ b/include/libcamera/internal/camera_sensor.h
@@ -21,6 +21,7 @@
#include <libcamera/transform.h>
#include "libcamera/internal/bayer_format.h"
+#include "libcamera/internal/camera_sensor_properties.h"
#include "libcamera/internal/v4l2_subdevice.h"
namespace libcamera {
@@ -73,6 +74,7 @@ public:
virtual const std::vector<controls::draft::TestPatternModeEnum> &
testPatternModes() const = 0;
virtual int setTestPatternMode(controls::draft::TestPatternModeEnum mode) = 0;
+ virtual const CameraSensorProperties::SensorDelays &sensorDelays() = 0;
};
class CameraSensorFactoryBase
diff --git a/include/libcamera/internal/camera_sensor_properties.h b/include/libcamera/internal/camera_sensor_properties.h
index 480ac121..d7d4dab6 100644
--- a/include/libcamera/internal/camera_sensor_properties.h
+++ b/include/libcamera/internal/camera_sensor_properties.h
@@ -8,6 +8,7 @@
#pragma once
#include <map>
+#include <stdint.h>
#include <string>
#include <libcamera/control_ids.h>
@@ -16,10 +17,18 @@
namespace libcamera {
struct CameraSensorProperties {
+ struct SensorDelays {
+ uint8_t exposureDelay;
+ uint8_t gainDelay;
+ uint8_t vblankDelay;
+ uint8_t hblankDelay;
+ };
+
static const CameraSensorProperties *get(const std::string &sensor);
Size unitCellSize;
std::map<controls::draft::TestPatternModeEnum, int32_t> testPatternModes;
+ SensorDelays sensorDelays;
};
} /* namespace libcamera */
diff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp
index 54cf98b2..208a1603 100644
--- a/src/libcamera/sensor/camera_sensor.cpp
+++ b/src/libcamera/sensor/camera_sensor.cpp
@@ -337,6 +337,18 @@ CameraSensor::~CameraSensor() = default;
*/
/**
+ * \fn CameraSensor::sensorDelays()
+ * \brief Fetch the sensor delay values
+ *
+ * This function retrieves the delays that the sensor applies to controls. If
+ * the static properties database doesn't specifiy control delay values for the
+ * sensor, default delays that may be suitable are returned and a warning is
+ * logged.
+ *
+ * \return The sensor delay values
+ */
+
+/**
* \class CameraSensorFactoryBase
* \brief Base class for camera sensor factories
*
diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp
index a9b15c03..17d6fa68 100644
--- a/src/libcamera/sensor/camera_sensor_legacy.cpp
+++ b/src/libcamera/sensor/camera_sensor_legacy.cpp
@@ -95,6 +95,7 @@ public:
const std::vector<controls::draft::TestPatternModeEnum> &
testPatternModes() const override { return testPatternModes_; }
int setTestPatternMode(controls::draft::TestPatternModeEnum mode) override;
+ const CameraSensorProperties::SensorDelays &sensorDelays() override;
protected:
std::string logPrefix() const override;
@@ -482,6 +483,30 @@ void CameraSensorLegacy::initStaticProperties()
initTestPatternModes();
}
+const CameraSensorProperties::SensorDelays &CameraSensorLegacy::sensorDelays()
+{
+ static constexpr CameraSensorProperties::SensorDelays defaultSensorDelays = {
+ .exposureDelay = 2,
+ .gainDelay = 1,
+ .vblankDelay = 2,
+ .hblankDelay = 2,
+ };
+
+ if (!staticProps_ ||
+ (!staticProps_->sensorDelays.exposureDelay &&
+ !staticProps_->sensorDelays.gainDelay &&
+ !staticProps_->sensorDelays.vblankDelay &&
+ !staticProps_->sensorDelays.hblankDelay)) {
+ LOG(CameraSensor, Warning)
+ << "No sensor delays found in static properties. "
+ "Assuming unverified defaults.";
+
+ return defaultSensorDelays;
+ }
+
+ return staticProps_->sensorDelays;
+}
+
void CameraSensorLegacy::initTestPatternModes()
{
const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN);
diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp
index e2305166..3fe18c16 100644
--- a/src/libcamera/sensor/camera_sensor_properties.cpp
+++ b/src/libcamera/sensor/camera_sensor_properties.cpp
@@ -41,6 +41,35 @@ LOG_DEFINE_CATEGORY(CameraSensorProperties)
* \brief Map that associates the TestPattern control value with the indexes of
* the corresponding sensor test pattern modes as returned by
* V4L2_CID_TEST_PATTERN.
+ *
+ * \var CameraSensorProperties::sensorDelays
+ * \brief Sensor control application delays
+ *
+ * This structure may be defined as empty if the actual sensor delays are not
+ * available or have not been measured.
+ */
+
+/**
+ * \struct CameraSensorProperties::SensorDelays
+ * \brief Sensor control application delay values
+ *
+ * This structure holds delay values, expressed in number of frames, between the
+ * time a control value is applied to the sensor and the time that value is
+ * reflected in the output. For example "2 frames delay" means that parameters
+ * set during frame N will take effect for frame N+2 (and by extension a delay
+ * of 0 would mean the parameter is applied immediately to the current frame).
+ *
+ * \var CameraSensorProperties::SensorDelays::exposureDelay
+ * \brief Number of frames between application of exposure control and effect
+ *
+ * \var CameraSensorProperties::SensorDelays::gainDelay
+ * \brief Number of frames between application of analogue gain control and effect
+ *
+ * \var CameraSensorProperties::SensorDelays::vblankDelay
+ * \brief Number of frames between application of vblank control and effect
+ *
+ * \var CameraSensorProperties::SensorDelays::hblankDelay
+ * \brief Number of frames between application of hblank control and effect
*/
/**
@@ -60,6 +89,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
{ controls::draft::TestPatternModeColorBars, 2 },
{ controls::draft::TestPatternModeColorBarsFadeToGray, 3 },
},
+ .sensorDelays = {
+ .exposureDelay = 2,
+ .gainDelay = 2,
+ .vblankDelay = 2,
+ .hblankDelay = 2
+ },
} },
{ "ar0521", {
.unitCellSize = { 2200, 2200 },
@@ -69,6 +104,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
{ controls::draft::TestPatternModeColorBars, 2 },
{ controls::draft::TestPatternModeColorBarsFadeToGray, 3 },
},
+ .sensorDelays = { },
} },
{ "hi846", {
.unitCellSize = { 1120, 1120 },
@@ -87,6 +123,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
* 9: "Resolution Pattern"
*/
},
+ .sensorDelays = { },
} },
{ "imx214", {
.unitCellSize = { 1120, 1120 },
@@ -97,6 +134,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
{ controls::draft::TestPatternModeColorBarsFadeToGray, 3 },
{ controls::draft::TestPatternModePn9, 4 },
},
+ .sensorDelays = { },
} },
{ "imx219", {
.unitCellSize = { 1120, 1120 },
@@ -107,6 +145,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
{ controls::draft::TestPatternModeColorBarsFadeToGray, 3 },
{ controls::draft::TestPatternModePn9, 4 },
},
+ .sensorDelays = {
+ .exposureDelay = 2,
+ .gainDelay = 1,
+ .vblankDelay = 2,
+ .hblankDelay = 2
+ },
} },
{ "imx258", {
.unitCellSize = { 1120, 1120 },
@@ -117,38 +161,67 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
{ controls::draft::TestPatternModeColorBarsFadeToGray, 3 },
{ controls::draft::TestPatternModePn9, 4 },
},
+ .sensorDelays = { },
} },
{ "imx283", {
.unitCellSize = { 2400, 2400 },
.testPatternModes = {},
+ .sensorDelays = {
+ .exposureDelay = 2,
+ .gainDelay = 2,
+ .vblankDelay = 2,
+ .hblankDelay = 2
+ },
} },
{ "imx290", {
.unitCellSize = { 2900, 2900 },
.testPatternModes = {},
+ .sensorDelays = {
+ .exposureDelay = 2,
+ .gainDelay = 2,
+ .vblankDelay = 2,
+ .hblankDelay = 2
+ },
} },
{ "imx296", {
.unitCellSize = { 3450, 3450 },
.testPatternModes = {},
+ .sensorDelays = {
+ .exposureDelay = 2,
+ .gainDelay = 2,
+ .vblankDelay = 2,
+ .hblankDelay = 2
+ },
} },
{ "imx327", {
.unitCellSize = { 2900, 2900 },
.testPatternModes = {},
+ .sensorDelays = { },
} },
{ "imx335", {
.unitCellSize = { 2000, 2000 },
.testPatternModes = {},
+ .sensorDelays = { },
} },
{ "imx415", {
.unitCellSize = { 1450, 1450 },
.testPatternModes = {},
+ .sensorDelays = { },
} },
{ "imx462", {
.unitCellSize = { 2900, 2900 },
.testPatternModes = {},
+ .sensorDelays = { },
} },
{ "imx477", {
.unitCellSize = { 1550, 1550 },
.testPatternModes = {},
+ .sensorDelays = {
+ .exposureDelay = 2,
+ .gainDelay = 2,
+ .vblankDelay = 3,
+ .hblankDelay = 3
+ },
} },
{ "imx519", {
.unitCellSize = { 1220, 1220 },
@@ -161,6 +234,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
* these two patterns do not comply with MIPI CCS v1.1 (Section 10.1).
*/
},
+ .sensorDelays = {
+ .exposureDelay = 2,
+ .gainDelay = 2,
+ .vblankDelay = 3,
+ .hblankDelay = 3
+ },
} },
{ "imx708", {
.unitCellSize = { 1400, 1400 },
@@ -171,6 +250,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
{ controls::draft::TestPatternModeColorBarsFadeToGray, 3 },
{ controls::draft::TestPatternModePn9, 4 },
},
+ .sensorDelays = {
+ .exposureDelay = 2,
+ .gainDelay = 2,
+ .vblankDelay = 3,
+ .hblankDelay = 3
+ },
} },
{ "ov2685", {
.unitCellSize = { 1750, 1750 },
@@ -185,6 +270,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
* 5: "Color Square"
*/
},
+ .sensorDelays = { },
} },
{ "ov2740", {
.unitCellSize = { 1400, 1400 },
@@ -192,6 +278,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
{ controls::draft::TestPatternModeOff, 0 },
{ controls::draft::TestPatternModeColorBars, 1},
},
+ .sensorDelays = { },
} },
{ "ov4689", {
.unitCellSize = { 2000, 2000 },
@@ -205,6 +292,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
* colorBarType2 and colorBarType3.
*/
},
+ .sensorDelays = { },
} },
{ "ov5640", {
.unitCellSize = { 1400, 1400 },
@@ -212,10 +300,17 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
{ controls::draft::TestPatternModeOff, 0 },
{ controls::draft::TestPatternModeColorBars, 1 },
},
+ .sensorDelays = { },
} },
{ "ov5647", {
.unitCellSize = { 1400, 1400 },
.testPatternModes = {},
+ .sensorDelays = {
+ .exposureDelay = 2,
+ .gainDelay = 2,
+ .vblankDelay = 2,
+ .hblankDelay = 2
+ },
} },
{ "ov5670", {
.unitCellSize = { 1120, 1120 },
@@ -223,6 +318,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
{ controls::draft::TestPatternModeOff, 0 },
{ controls::draft::TestPatternModeColorBars, 1 },
},
+ .sensorDelays = { },
} },
{ "ov5675", {
.unitCellSize = { 1120, 1120 },
@@ -230,6 +326,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
{ controls::draft::TestPatternModeOff, 0 },
{ controls::draft::TestPatternModeColorBars, 1 },
},
+ .sensorDelays = { },
} },
{ "ov5693", {
.unitCellSize = { 1400, 1400 },
@@ -242,6 +339,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
* Rolling Bar".
*/
},
+ .sensorDelays = { },
} },
{ "ov64a40", {
.unitCellSize = { 1008, 1008 },
@@ -255,6 +353,12 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
* 4: "Vertical Color Bar Type 4"
*/
},
+ .sensorDelays = {
+ .exposureDelay = 2,
+ .gainDelay = 2,
+ .vblankDelay = 2,
+ .hblankDelay = 2
+ },
} },
{ "ov8858", {
.unitCellSize = { 1120, 1120 },
@@ -268,6 +372,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
* 4: "Vertical Color Bar Type 4"
*/
},
+ .sensorDelays = { },
} },
{ "ov8865", {
.unitCellSize = { 1400, 1400 },
@@ -282,6 +387,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
* 5: "Color squares with rolling bar"
*/
},
+ .sensorDelays = { },
} },
{ "ov13858", {
.unitCellSize = { 1120, 1120 },
@@ -289,6 +395,7 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
{ controls::draft::TestPatternModeOff, 0 },
{ controls::draft::TestPatternModeColorBars, 1 },
},
+ .sensorDelays = { },
} },
};