summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2018-12-28 23:04:31 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-01-22 14:54:20 +0100
commit70b0518ba711f37a0cd519661b87f0b2dc5995dc (patch)
treee4ddd03fa52cbf230d9250abe7b89c0bc53f1d44
parent5db44e6da72f1734f4d423b33af511a4d68bfcf1 (diff)
libcamera: pipeline: uvcvideo: add pipeline handler for uvcvideo
Provide a pipeline handler for uvcvideo devices. The entity names for UVC devices are different for different cameras so matching on entity names is not possible in the generic case. This leaves options to create specialized UVC pipeline handlers if needed to fit a specific model's needs. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/libcamera/pipeline/meson.build1
-rw-r--r--src/libcamera/pipeline/uvcvideo.cpp59
2 files changed, 60 insertions, 0 deletions
diff --git a/src/libcamera/pipeline/meson.build b/src/libcamera/pipeline/meson.build
index 811c075b..40bb2640 100644
--- a/src/libcamera/pipeline/meson.build
+++ b/src/libcamera/pipeline/meson.build
@@ -1,4 +1,5 @@
libcamera_sources += files([
+ 'uvcvideo.cpp',
'vimc.cpp',
])
diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
new file mode 100644
index 00000000..3ba69da8
--- /dev/null
+++ b/src/libcamera/pipeline/uvcvideo.cpp
@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * uvcvideo.cpp - Pipeline handler for uvcvideo devices
+ */
+
+#include <libcamera/camera.h>
+#include <libcamera/camera_manager.h>
+
+#include "device_enumerator.h"
+#include "media_device.h"
+#include "pipeline_handler.h"
+
+namespace libcamera {
+
+class PipelineHandlerUVC : public PipelineHandler
+{
+public:
+ PipelineHandlerUVC();
+ ~PipelineHandlerUVC();
+
+ bool match(CameraManager *manager, DeviceEnumerator *enumerator);
+
+private:
+ MediaDevice *dev_;
+};
+
+PipelineHandlerUVC::PipelineHandlerUVC()
+ : dev_(nullptr)
+{
+}
+
+PipelineHandlerUVC::~PipelineHandlerUVC()
+{
+ if (dev_)
+ dev_->release();
+}
+
+bool PipelineHandlerUVC::match(CameraManager *manager, DeviceEnumerator *enumerator)
+{
+ DeviceMatch dm("uvcvideo");
+
+ dev_ = enumerator->search(dm);
+
+ if (!dev_)
+ return false;
+
+ dev_->acquire();
+
+ std::shared_ptr<Camera> camera = Camera::create(dev_->model());
+ manager->addCamera(std::move(camera));
+
+ return true;
+}
+
+REGISTER_PIPELINE_HANDLER(PipelineHandlerUVC);
+
+} /* namespace libcamera */