[libcamera-devel] [PATCH 2/3] pipeline: simple: Add FrameDurations to stream configuration
Marian Cichy
m.cichy at pengutronix.de
Mon Mar 22 11:42:41 CET 2021
Add a instance of CameraSensorInfo to the simple pipeline and populate
it with the sensorInfo from the sensor. With the informations from the
sensor, compute the frame duration by using lineLength, minFrameLength
and pixelRate and save it in the controlList of the stream.
Signed-off-by: Marian Cichy <m.cichy at pengutronix.de>
---
src/libcamera/pipeline/simple/simple.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index 24d940fc..2df83302 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -22,6 +22,8 @@
#include <linux/media-bus-format.h>
#include <libcamera/camera.h>
+#include <libcamera/controls.h>
+#include <libcamera/control_ids.h>
#include <libcamera/request.h>
#include <libcamera/stream.h>
@@ -176,6 +178,7 @@ public:
std::vector<Stream> streams_;
std::unique_ptr<CameraSensor> sensor_;
+ CameraSensorInfo sensorInfo_;
std::list<Entity> entities_;
V4L2VideoDevice *video_;
@@ -339,6 +342,8 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe,
ret = sensor_->init();
if (ret)
sensor_.reset();
+
+ sensor_->sensorInfo(&sensorInfo_);
}
int SimpleCameraData::init()
@@ -679,6 +684,10 @@ CameraConfiguration *SimplePipelineHandler::generateConfiguration(Camera *camera
StreamConfiguration cfg{ StreamFormats{ formats } };
cfg.pixelFormat = formats.begin()->first;
cfg.size = formats.begin()->second[0].max;
+ double frameDuration = (data->sensorInfo_.minFrameLength * data->sensorInfo_.lineLength) /
+ (data->sensorInfo_.pixelRate / 1'000'000);
+ cfg.controls.set(controls::FrameDurations, { static_cast<int64_t>(frameDuration),
+ static_cast<int64_t>(frameDuration) });
config->addConfiguration(cfg);
}
--
2.29.2
More information about the libcamera-devel
mailing list