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

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

Commit Message

Harvey Yang Jan. 5, 2023, 4:37 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 db6fe14c..d56989b2 100644
--- a/src/libcamera/pipeline/virtual/virtual.cpp
+++ b/src/libcamera/pipeline/virtual/virtual.cpp
@@ -11,6 +11,7 @@ 
 #include <libcamera/control_ids.h>
 #include <libcamera/controls.h>
 #include <libcamera/formats.h>
+#include <libcamera/property_ids.h>
 
 #include "libcamera/internal/camera.h"
 #include "libcamera/internal/media_device_virtual.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;
@@ -272,6 +277,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";