From patchwork Fri Jan 25 14:39:49 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: 374 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 8D1BC60B21 for ; Fri, 25 Jan 2019 15:40:17 +0100 (CET) X-Halon-ID: 1e72a053-20af-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 1e72a053-20af-11e9-9adf-005056917a89; Fri, 25 Jan 2019 15:40:11 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Jan 2019 15:39:49 +0100 Message-Id: <20190125143951.27992-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125143951.27992-1-niklas.soderlund@ragnatech.se> References: <20190125143951.27992-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] libcamera: pipelines: rename MediaDevice member for UVC and VIMC 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: Fri, 25 Jan 2019 14:40:17 -0000 The name dev_ do a poor job of representing that it holds a media device, rename it to media_. There is no functional change in this change just s/dev_/media_/. Suggested-by: Laurent Pinchart Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/uvcvideo.cpp | 18 +++++++++--------- src/libcamera/pipeline/vimc.cpp | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index f84fa41515f1a439..5de8a0cb9c3406a8 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -22,34 +22,34 @@ public: bool match(DeviceEnumerator *enumerator); private: - std::shared_ptr dev_; + std::shared_ptr media_; }; PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager) - : PipelineHandler(manager), dev_(nullptr) + : PipelineHandler(manager), media_(nullptr) { } PipelineHandlerUVC::~PipelineHandlerUVC() { - if (dev_) - dev_->release(); + if (media_) + media_->release(); } bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) { DeviceMatch dm("uvcvideo"); - dev_ = std::move(enumerator->search(dm)); + media_ = std::move(enumerator->search(dm)); - if (!dev_) + if (!media_) return false; - dev_->acquire(); + media_->acquire(); - std::shared_ptr camera = Camera::create(this, dev_->model()); + std::shared_ptr camera = Camera::create(this, media_->model()); registerCamera(std::move(camera)); - hotplugMediaDevice(dev_.get()); + hotplugMediaDevice(media_.get()); return true; } diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index b714a07688e91a02..f58a97d51619515d 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -22,18 +22,18 @@ public: bool match(DeviceEnumerator *enumerator); private: - std::shared_ptr dev_; + std::shared_ptr media_; }; PipeHandlerVimc::PipeHandlerVimc(CameraManager *manager) - : PipelineHandler(manager), dev_(nullptr) + : PipelineHandler(manager), media_(nullptr) { } PipeHandlerVimc::~PipeHandlerVimc() { - if (dev_) - dev_->release(); + if (media_) + media_->release(); } bool PipeHandlerVimc::match(DeviceEnumerator *enumerator) @@ -50,11 +50,11 @@ bool PipeHandlerVimc::match(DeviceEnumerator *enumerator) dm.add("RGB/YUV Input"); dm.add("Scaler"); - dev_ = std::move(enumerator->search(dm)); - if (!dev_) + media_ = std::move(enumerator->search(dm)); + if (!media_) return false; - dev_->acquire(); + media_->acquire(); std::shared_ptr camera = Camera::create(this, "Dummy VIMC Camera"); registerCamera(std::move(camera)); From patchwork Fri Jan 25 14:39:50 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: 377 X-Patchwork-Delegate: niklas.soderlund@ragnatech.se Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B466860C83 for ; Fri, 25 Jan 2019 15:40:18 +0100 (CET) X-Halon-ID: 1ed1e189-20af-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 1ed1e189-20af-11e9-9adf-005056917a89; Fri, 25 Jan 2019 15:40:12 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Jan 2019 15:39:50 +0100 Message-Id: <20190125143951.27992-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125143951.27992-1-niklas.soderlund@ragnatech.se> References: <20190125143951.27992-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/3] libcamera: pipelines: add log category for each pipeline 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: Fri, 25 Jan 2019 14:40:19 -0000 The VIMC and UVC pipeline handlers lacked a dedicated log category. Signed-off-by: Niklas Söderlund --- src/libcamera/pipeline/uvcvideo.cpp | 3 +++ src/libcamera/pipeline/vimc.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 5de8a0cb9c3406a8..1a445edfa8df777c 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -8,11 +8,14 @@ #include #include "device_enumerator.h" +#include "log.h" #include "media_device.h" #include "pipeline_handler.h" namespace libcamera { +LOG_DEFINE_CATEGORY(UVC) + class PipelineHandlerUVC : public PipelineHandler { public: diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index f58a97d51619515d..32b35626306bbce9 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -8,11 +8,14 @@ #include #include "device_enumerator.h" +#include "log.h" #include "media_device.h" #include "pipeline_handler.h" namespace libcamera { +LOG_DEFINE_CATEGORY(VIMC) + class PipeHandlerVimc : public PipelineHandler { public: From patchwork Fri Jan 25 14:39:51 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: 376 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A6C7B60B21 for ; Fri, 25 Jan 2019 15:40:18 +0100 (CET) X-Halon-ID: 1f0cad2f-20af-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 1f0cad2f-20af-11e9-9adf-005056917a89; Fri, 25 Jan 2019 15:40:12 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Jan 2019 15:39:51 +0100 Message-Id: <20190125143951.27992-4-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125143951.27992-1-niklas.soderlund@ragnatech.se> References: <20190125143951.27992-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] libcamera: pipeline: uvcvideo: create a V4L2Device for the default video entity 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: Fri, 25 Jan 2019 14:40:19 -0000 Add a V4L2Device for the default video entity in the media graph. The UVC pipeline needs to search for the entity marked with the MEDIA_ENT_FL_DEFAULT flag as the entity names in the media graph varies depending on which device is used. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/uvcvideo.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 1a445edfa8df777c..e3a475704c080e90 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -11,6 +11,7 @@ #include "log.h" #include "media_device.h" #include "pipeline_handler.h" +#include "v4l2_device.h" namespace libcamera { @@ -26,15 +27,20 @@ public: private: std::shared_ptr media_; + + V4L2Device *video_; }; PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager) - : PipelineHandler(manager), media_(nullptr) + : PipelineHandler(manager), media_(nullptr), video_(nullptr) { } PipelineHandlerUVC::~PipelineHandlerUVC() { + if (video_) + delete video_; + if (media_) media_->release(); } @@ -50,6 +56,18 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) media_->acquire(); + for (MediaEntity *entity : media_->entities()) { + if (entity->flags() & MEDIA_ENT_FL_DEFAULT) { + video_ = new V4L2Device(*entity); + break; + } + } + + if (!video_ || video_->open()) { + media_->release(); + return false; + } + std::shared_ptr camera = Camera::create(this, media_->model()); registerCamera(std::move(camera)); hotplugMediaDevice(media_.get());