From patchwork Mon Jan 21 15:30:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 299 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2BE4E60C80 for ; Mon, 21 Jan 2019 16:30:46 +0100 (CET) X-Halon-ID: 830155e8-1d91-11e9-9adf-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 830155e8-1d91-11e9-9adf-005056917a89; Mon, 21 Jan 2019 16:30:42 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Jan 2019 16:30:05 +0100 Message-Id: <20190121153005.19110-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121153005.19110-1-niklas.soderlund@ragnatech.se> References: <20190121153005.19110-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: uvcvideo: add pipeline handler for uvcvideo X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jan 2019 15:30:46 -0000 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 models 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 615ecd20f1a21141..4da5d8cf9c4384bb 100644 --- a/src/libcamera/pipeline/meson.build +++ b/src/libcamera/pipeline/meson.build @@ -1,3 +1,4 @@ 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 0000000000000000..2579782e90caec5a --- /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 PipeHandlerUvcvideo : public PipelineHandler +{ +public: + PipeHandlerUvcvideo(); + ~PipeHandlerUvcvideo(); + + bool match(CameraManager *manager, DeviceEnumerator *enumerator); + +private: + MediaDevice *dev_; +}; + +PipeHandlerUvcvideo::PipeHandlerUvcvideo() + : dev_(nullptr) +{ +} + +PipeHandlerUvcvideo::~PipeHandlerUvcvideo() +{ + if (dev_) + dev_->release(); +} + +bool PipeHandlerUvcvideo::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(PipeHandlerUvcvideo); + +} /* namespace libcamera */