[libcamera-devel] [PATCH 05/15] libcamera: camera_sensor: Retrieve sensor delays
Jacopo Mondi
jacopo at jmondi.org
Mon Jun 27 18:27:22 CEST 2022
Add a function to the CameraSensor to retrieve the SensorDelay map that
associate controls to their latencies.
If such information is not provided, return a reference to an empty map.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
include/libcamera/internal/camera_sensor.h | 4 +++
src/libcamera/camera_sensor.cpp | 30 ++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h
index b9f4d7867854..0359d4609517 100644
--- a/include/libcamera/internal/camera_sensor.h
+++ b/include/libcamera/internal/camera_sensor.h
@@ -9,6 +9,7 @@
#include <memory>
#include <string>
+#include <unordered_map>
#include <vector>
#include <libcamera/base/class.h>
@@ -34,6 +35,8 @@ struct CameraSensorProperties;
class CameraSensor : protected Loggable
{
public:
+ using SensorDelays = std::unordered_map<const ControlId *, unsigned int>;
+
explicit CameraSensor(const MediaEntity *entity);
~CameraSensor();
@@ -45,6 +48,7 @@ public:
const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
std::vector<Size> sizes(unsigned int mbusCode) const;
Size resolution() const;
+ const SensorDelays &sensorDelays();
const std::vector<controls::draft::TestPatternModeEnum> &testPatternModes() const
{
return testPatternModes_;
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index d055c16a4885..5cd33e904174 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -47,6 +47,14 @@ LOG_DEFINE_CATEGORY(CameraSensor)
* devices as the needs arise.
*/
+/**
+ * \typedef CameraSensor::SensorDelays
+ * \brief Camera sensor controls delays
+ *
+ * Type to represent a map of camera sensor controls associated with their
+ * latencies, expressed in frame periods.
+ */
+
/**
* \brief Construct a CameraSensor
* \param[in] entity The media entity backing the camera sensor
@@ -561,6 +569,28 @@ Size CameraSensor::resolution() const
return std::min(sizes_.back(), activeArea_.size());
}
+/**
+ * \brief Retrieve the map of latencies associated with camera controls
+ *
+ * Retrieve the SensorDelays map that associates camera controls with
+ * their latencies.
+ *
+ * If a camera sensor does not provide such information an empty map is
+ * returned.
+ *
+ * \return A map of controls associated with their latencies or an empty map
+ * if no sensor delays are available.
+ */
+const CameraSensor::SensorDelays &CameraSensor::sensorDelays()
+{
+ static SensorDelays emptyDelays{};
+
+ if (!staticProps_)
+ return emptyDelays;
+
+ return staticProps_->sensorDelays;
+}
+
/**
* \fn CameraSensor::testPatternModes()
* \brief Retrieve all the supported test pattern modes of the camera sensor
--
2.36.1
More information about the libcamera-devel
mailing list