[libcamera-devel,v4,6/6] libcamera: pipeline: virtual: Set camera properties & controls
diff mbox series

Message ID 20230315102300.2265491-7-chenghaoyang@google.com
State Superseded
Headers show
Series
  • Virtual pipeline handler
Related show

Commit Message

Harvey Yang March 15, 2023, 10:23 a.m. UTC
Initialize the CameraData properties with Location, Model, and
PixelArrayActiveAreas, and the control attribute: FrameDurationLimits.

Updating `/etc/camera/libcamera/camera_hal.yaml` on a chromebook DUT is
required to find the virtual camera with id `Virtual0`.

Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
---
 src/libcamera/pipeline/virtual/virtual.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp
index b91e7000..f858ed1e 100644
--- a/src/libcamera/pipeline/virtual/virtual.cpp
+++ b/src/libcamera/pipeline/virtual/virtual.cpp
@@ -12,6 +12,7 @@ 
 #include <libcamera/controls.h>
 #include <libcamera/formats.h>
 #include <libcamera/heap_allocator.h>
+#include <libcamera/property_ids.h>
 
 #include "libcamera/internal/camera.h"
 #include "libcamera/internal/pipeline_handler.h"
@@ -20,6 +21,10 @@  namespace libcamera {
 
 LOG_DEFINE_CATEGORY(VIRTUAL)
 
+static const ControlInfoMap::Map VirtualControls = {
+	{ &controls::draft::PipelineDepth, ControlInfo(2, 3) },
+};
+
 uint64_t CurrentTimestamp()
 {
 	struct timespec ts;
@@ -270,6 +275,16 @@  bool PipelineHandlerVirtual::match(DeviceEnumerator *enumerator)
 	data->supportedResolutions_[0] = { .size = Size(1920, 1080), .frame_rates = { 30 }, .formats = { "YCbCr_420_888" } };
 	data->supportedResolutions_[1] = { .size = Size(1280, 720), .frame_rates = { 30, 60 }, .formats = { "YCbCr_420_888" } };
 
+	data->properties_.set(properties::Location, properties::CameraLocationFront);
+	data->properties_.set(properties::Model, "Virtual Video Device");
+	data->properties_.set(properties::PixelArrayActiveAreas, { Rectangle(Size(1920, 1080)) });
+
+	// TODO: Set FrameDurationLimits based on config.
+	ControlInfoMap::Map controls = VirtualControls;
+	int64_t min_frame_duration = 30, max_frame_duration = 60;
+	controls[&controls::FrameDurationLimits] = ControlInfo(min_frame_duration, max_frame_duration);
+	data->controlInfo_ = ControlInfoMap(std::move(controls), controls::controls);
+
 	/* Create and register the camera. */
 	std::set<Stream *> streams{ &data->stream_ };
 	const std::string id = "Virtual0";