From patchwork Mon Jan 21 15:30:04 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: 297 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ACEE060C78 for ; Mon, 21 Jan 2019 16:30:45 +0100 (CET) X-Halon-ID: 82bee41e-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 82bee41e-1d91-11e9-9adf-005056917a89; Mon, 21 Jan 2019 16:30:41 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Jan 2019 16:30:04 +0100 Message-Id: <20190121153005.19110-2-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 1/2] libcamera: media_device: expose media graph model name 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 Pipeline handlers such as the upcoming ucvideo handler needs the model name to properly name the Camera object it creates. Store the model name when querying the media device info and handle it in a similar fashion as the driver name which is already retrieved. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/include/media_device.h | 2 ++ src/libcamera/media_device.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h index a8dec0d3347bd5fc..d96b8ec718427011 100644 --- a/src/libcamera/include/media_device.h +++ b/src/libcamera/include/media_device.h @@ -36,6 +36,7 @@ public: const std::string driver() const { return driver_; } const std::string devnode() const { return devnode_; } + const std::string model() const { return model_; } const std::vector &entities() const { return entities_; } MediaEntity *getEntityByName(const std::string &name) const; @@ -50,6 +51,7 @@ public: private: std::string driver_; std::string devnode_; + std::string model_; int fd_; bool valid_; bool acquired_; diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index a346296bc38e8f3d..b315e4f383b3bbb1 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -162,6 +162,7 @@ int MediaDevice::open() } driver_ = info.driver; + model_ = info.model; return 0; } @@ -285,6 +286,12 @@ int MediaDevice::populate() * \return The MediaDevice devnode path */ +/** + * \fn MediaDevice::model() + * \brief Retrieve the media device model name + * \return The MediaDevice model name + */ + /** * \fn MediaDevice::entities() * \brief Retrieve the list of entities in the media graph 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 */