From 70b0518ba711f37a0cd519661b87f0b2dc5995dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Fri, 28 Dec 2018 23:04:31 +0100 Subject: libcamera: pipeline: uvcvideo: add pipeline handler for uvcvideo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/meson.build | 1 + src/libcamera/pipeline/uvcvideo.cpp | 59 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/libcamera/pipeline/uvcvideo.cpp 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 +#include + +#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::create(dev_->model()); + manager->addCamera(std::move(camera)); + + return true; +} + +REGISTER_PIPELINE_HANDLER(PipelineHandlerUVC); + +} /* namespace libcamera */ -- cgit v1.2.1