From patchwork Thu Feb 4 23:26:05 2021 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: 11165 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1B237BD162 for ; Thu, 4 Feb 2021 23:27:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E3B4B614A7; Fri, 5 Feb 2021 00:27:09 +0100 (CET) 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 2FD2A6149E for ; Fri, 5 Feb 2021 00:27:09 +0100 (CET) X-Halon-ID: 7edfa7ab-6740-11eb-b73f-0050569116f7 Authorized-sender: niklas.soderlund@fsdn.se Received: from bismarck.berto.se (p4fca2458.dip0.t-ipconnect.de [79.202.36.88]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 7edfa7ab-6740-11eb-b73f-0050569116f7; Fri, 05 Feb 2021 00:27:08 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 5 Feb 2021 00:26:05 +0100 Message-Id: <20210204232613.494121-4-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210204232613.494121-1-niklas.soderlund@ragnatech.se> References: <20210204232613.494121-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 03/11] libcamera: ipu3: imgu: Add parameters video device X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add the parameters video device to the data structure of the ImgUDevice. Even if the video device is configured, prepared to import buffers and started no buffers are ever queued to it so it does not yet effect the capture. Nor is does this change hinder the current capture mode to function. This is done in preparation to attach an IPA to the IPU3 pipeline. Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- * Changes since v1 - Update commit message s/attache/attach/. - Utilise unique pointer returned from fromEntityName() that have been merged since v1. - Expand explanatory note in ImgUDevice::configureVideoDevice(). - Sort std::unique_ptr to match pad numbering. --- src/libcamera/pipeline/ipu3/imgu.cpp | 41 ++++++++++++++++++++++++++-- src/libcamera/pipeline/ipu3/imgu.h | 3 +- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index 08f0fce9d740963f..c861022060c82dde 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -363,6 +363,11 @@ int ImgUDevice::init(MediaDevice *media, unsigned int index) if (ret) return ret; + param_ = V4L2VideoDevice::fromEntityName(media, name_ + " parameters"); + ret = param_->open(); + if (ret) + return ret; + stat_ = V4L2VideoDevice::fromEntityName(media, name_ + " 3a stat"); ret = stat_->open(); if (ret) @@ -475,6 +480,13 @@ int ImgUDevice::configure(const PipeConfig &pipeConfig, V4L2DeviceFormat *inputF LOG(IPU3, Debug) << "ImgU GDC format = " << gdcFormat.toString(); + StreamConfiguration paramCfg = {}; + paramCfg.size = inputFormat->size; + V4L2DeviceFormat paramFormat; + ret = configureVideoDevice(param_.get(), PAD_PARAM, paramCfg, ¶mFormat); + if (ret) + return ret; + StreamConfiguration statCfg = {}; statCfg.size = inputFormat->size; V4L2DeviceFormat statFormat; @@ -505,8 +517,11 @@ int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad, if (ret) return ret; - /* No need to apply format to the stat node. */ - if (dev == stat_.get()) + /* + * No need to apply format to the param or stat video devices as the + * driver ignores the operation. + */ + if (dev == param_.get() || dev == stat_.get()) return 0; *outputFormat = {}; @@ -537,6 +552,12 @@ int ImgUDevice::allocateBuffers(unsigned int bufferCount) return ret; } + ret = param_->importBuffers(bufferCount); + if (ret < 0) { + LOG(IPU3, Error) << "Failed to allocate ImgU param buffers"; + goto error; + } + /* * The kernel fails to start if buffers are not either imported or * allocated for the statistics video device. As statistics buffers are @@ -586,6 +607,10 @@ void ImgUDevice::freeBuffers() if (ret) LOG(IPU3, Error) << "Failed to release ImgU output buffers"; + ret = param_->releaseBuffers(); + if (ret) + LOG(IPU3, Error) << "Failed to release ImgU param buffers"; + ret = stat_->releaseBuffers(); if (ret) LOG(IPU3, Error) << "Failed to release ImgU stat buffers"; @@ -616,6 +641,12 @@ int ImgUDevice::start() return ret; } + ret = param_->streamOn(); + if (ret) { + LOG(IPU3, Error) << "Failed to start ImgU param"; + return ret; + } + ret = stat_->streamOn(); if (ret) { LOG(IPU3, Error) << "Failed to start ImgU stat"; @@ -637,6 +668,7 @@ int ImgUDevice::stop() ret = output_->streamOff(); ret |= viewfinder_->streamOff(); + ret |= param_->streamOff(); ret |= stat_->streamOff(); ret |= input_->streamOff(); @@ -678,6 +710,7 @@ int ImgUDevice::linkSetup(const std::string &source, unsigned int sourcePad, int ImgUDevice::enableLinks(bool enable) { std::string viewfinderName = name_ + " viewfinder"; + std::string paramName = name_ + " parameters"; std::string outputName = name_ + " output"; std::string statName = name_ + " 3a stat"; std::string inputName = name_ + " input"; @@ -695,6 +728,10 @@ int ImgUDevice::enableLinks(bool enable) if (ret) return ret; + ret = linkSetup(paramName, 0, name_, PAD_PARAM, enable); + if (ret) + return ret; + return linkSetup(name_, PAD_STAT, statName, 0, enable); } diff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h index 37f5ae77c99ff8fe..4a1896e2bbb41842 100644 --- a/src/libcamera/pipeline/ipu3/imgu.h +++ b/src/libcamera/pipeline/ipu3/imgu.h @@ -71,13 +71,14 @@ public: std::unique_ptr imgu_; std::unique_ptr input_; + std::unique_ptr param_; std::unique_ptr output_; std::unique_ptr viewfinder_; std::unique_ptr stat_; - /* \todo Add param video device for 3A tuning */ private: static constexpr unsigned int PAD_INPUT = 0; + static constexpr unsigned int PAD_PARAM = 1; static constexpr unsigned int PAD_OUTPUT = 2; static constexpr unsigned int PAD_VF = 3; static constexpr unsigned int PAD_STAT = 4;