From patchwork Mon Jan 21 17:27:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 306 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 081C860CA0 for ; Mon, 21 Jan 2019 18:27:06 +0100 (CET) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 966821BF213; Mon, 21 Jan 2019 17:27:05 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Jan 2019 18:27:04 +0100 Message-Id: <20190121172705.19985-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121172705.19985-1-jacopo@jmondi.org> References: <20190121172705.19985-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/6] libcamera: ipu3: Create CIO2 V4L2 devices 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 17:27:06 -0000 Create V4L2 devices for the CIO2 capture video nodes. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 36 +++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index daf681c..0689ce8 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -15,6 +15,8 @@ #include "log.h" #include "media_device.h" #include "pipeline_handler.h" +#include "utils.h" +#include "v4l2_device.h" namespace libcamera { @@ -30,6 +32,9 @@ private: MediaDevice *cio2_; MediaDevice *imgu_; + std::vector> videoDevices_; + + void createVideoDevices(); void registerCameras(CameraManager *manager); }; @@ -91,6 +96,12 @@ bool PipelineHandlerIPU3::match(CameraManager *manager, DeviceEnumerator *enumer cio2_->acquire(); imgu_->acquire(); + /* Create video device nodes for CIO2 outputs */ + if (cio2_->open()) + goto error_release_mdev; + + createVideoDevices(); + /* * Disable all links that are enabled by default on CIO2, as camera * creation enables all valid links it finds. @@ -98,9 +109,6 @@ bool PipelineHandlerIPU3::match(CameraManager *manager, DeviceEnumerator *enumer * Close the CIO2 media device after, as links are enabled and should * not need to be changed after. */ - if (cio2_->open()) - goto error_release_mdev; - if (cio2_->disableLinks()) goto error_close_cio2; @@ -120,6 +128,28 @@ error_release_mdev: return false; } +/* + * Create video devices for the CIO2 unit capture nodes and cache them + * for later reuse. + */ +void PipelineHandlerIPU3::createVideoDevices() +{ + for (unsigned int id = 0; id < 3; ++id) { + std::string cio2Name = "ipu3-cio2 " + std::to_string(id); + MediaEntity *cio2 = cio2_->getEntityByName(cio2Name); + if (!cio2) + continue; + + std::unique_ptr dev = + utils::make_unique(*cio2); + if (dev->open()) + continue; + dev->close(); + + videoDevices_.push_back(std::move(dev)); + } +} + /* * Cameras are created associating an image sensor (represented by a * media entity with function MEDIA_ENT_F_CAM_SENSOR) to one of the four