From patchwork Sat Dec 29 03:28:54 2018 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: 106 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E56260B53 for ; Sat, 29 Dec 2018 04:29:59 +0100 (CET) X-Halon-ID: fdb59afb-0b19-11e9-911a-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id fdb59afb-0b19-11e9-911a-0050569116f7; Sat, 29 Dec 2018 04:29:47 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 29 Dec 2018 04:28:54 +0100 Message-Id: <20181229032855.26249-12-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181229032855.26249-1-niklas.soderlund@ragnatech.se> References: <20181229032855.26249-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 11/12] libcamera: pipeline: vimc: add pipeline handler for 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: Sat, 29 Dec 2018 03:29:59 -0000 Provide a pipeline handler for the virtual vimc driver. Signed-off-by: Niklas Söderlund Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/meson.build | 2 + src/libcamera/pipeline/meson.build | 3 + src/libcamera/pipeline/vimc.cpp | 91 ++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 src/libcamera/pipeline/meson.build create mode 100644 src/libcamera/pipeline/vimc.cpp diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index a8cb3fdc22784334..ac5bba052d7f687b 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -21,6 +21,8 @@ includes = [ libcamera_internal_includes, ] +subdir('pipeline') + libudev = dependency('libudev') libcamera = shared_library('camera', diff --git a/src/libcamera/pipeline/meson.build b/src/libcamera/pipeline/meson.build new file mode 100644 index 0000000000000000..615ecd20f1a21141 --- /dev/null +++ b/src/libcamera/pipeline/meson.build @@ -0,0 +1,3 @@ +libcamera_sources += files([ + 'vimc.cpp', +]) diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp new file mode 100644 index 0000000000000000..e0f70a78f7e88412 --- /dev/null +++ b/src/libcamera/pipeline/vimc.cpp @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2018, Google Inc. + * + * vimc.cpp - Pipeline handler for the vimc device + */ + +#include + +#include "device_enumerator.h" +#include "pipeline_handler.h" + +namespace libcamera { + +class PipeHandlerVimc : public PipelineHandler +{ +public: + PipeHandlerVimc(); + ~PipeHandlerVimc(); + + bool match(DeviceEnumerator *enumerator); + + unsigned int count(); + Camera *camera(unsigned int id); +private: + DeviceInfo *info_; + Camera *camera_; +}; + +PipeHandlerVimc::PipeHandlerVimc() + : info_(nullptr), camera_(nullptr) +{ +} + +PipeHandlerVimc::~PipeHandlerVimc() +{ + if (camera_) + camera_->put(); + + if (info_) + info_->release(); +} + +unsigned int PipeHandlerVimc::count() +{ + return 1; +} + +Camera *PipeHandlerVimc::camera(unsigned int id) +{ + if (id != 0) + return nullptr; + + return camera_; +} + +bool PipeHandlerVimc::match(DeviceEnumerator *enumerator) +{ + DeviceMatch dm("vimc"); + + dm.add("Raw Capture 0"); + dm.add("Raw Capture 1"); + dm.add("RGB/YUV Capture"); + dm.add("Sensor A"); + dm.add("Sensor B"); + dm.add("Debayer A"); + dm.add("Debayer B"); + dm.add("RGB/YUV Input"); + dm.add("Scaler"); + + info_ = enumerator->search(dm); + + if (!info_) + return false; + + info_->acquire(); + + /* NOTE: A more complete Camera implementation could + * be passed the DeviceInfo(s) it controls here or + * a reference to the PipelineHandler. Which method + * that is chosen will depend on how the Camera + * object is modeled. + */ + camera_ = new Camera("Dummy VIMC Camera"); + + return true; +} + +REGISTER_PIPELINE_HANDLER(PipeHandlerVimc); + +} /* namespace libcamera */