From patchwork Wed Mar 20 16:30:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 769 Return-Path: Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4485561391 for ; Wed, 20 Mar 2019 17:30:42 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id D0DF5200012; Wed, 20 Mar 2019 16:30:41 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Mar 2019 17:30:47 +0100 Message-Id: <20190320163055.22056-24-jacopo@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320163055.22056-1-jacopo@jmondi.org> References: <20190320163055.22056-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 23/31] libcamera: ipu3: Enable media links conditionally 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: Wed, 20 Mar 2019 16:30:43 -0000 Add a method to the IPU3 pipeline handler class to enable media links on the ImgU device conditionally to the requested stream configuration. FIXME: media links for viewfinder and stat node should be enabled unconditionally. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 128 +++++++++++++++------------ 1 file changed, 71 insertions(+), 57 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index ac2b14156d4f..ff1e5329c83d 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -55,7 +55,6 @@ public: int linkSetup(const std::string &source, unsigned int sourcePad, const std::string &sink, unsigned int sinkPad, bool enable); - int enableLinks(bool enable); unsigned int index_; std::string imguName_; @@ -201,6 +200,8 @@ private: int initImgU(ImgUDevice *imgu); + int enableImgULinks(IPU3CameraData *data, bool enable); + int setInputFormat(ImgUDevice *imguDevice, const StreamConfiguration &config, Rectangle *rect); @@ -364,11 +365,8 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera, CIO2Config.height = cfg.height; } - /* - * \todo: Enable links selectively based on the requested streams. - * As of now, enable all links unconditionally. - */ - ret = data->imgu->enableLinks(true); + /* Enable links selectively based on the requested streams. */ + ret = enableImgULinks(data, true); if (ret) return ret; @@ -873,57 +871,6 @@ int ImgUDevice::linkSetup(const std::string &source, unsigned int sourcePad, return link->setEnabled(enable); } -/** - * \brief Enable or disable all media links in the ImgU instance to prepare - * for capture operations - * - * \todo This method will probably be removed or changed once links will be - * enabled or disabled selectively. - * - * \return 0 on success or a negative error code otherwise - */ -int ImgUDevice::enableLinks(bool enable) -{ - std::string inputName = imguName_ + " input"; - std::string outputName = imguName_ + " output"; - std::string viewfinderName = imguName_ + " viewfinder"; - std::string statName = imguName_ + " 3a stat"; - int ret; - - /* \todo Establish rules to handle media devices open/close. */ - ret = mediaDevice_->open(); - if (ret) - return ret; - - ret = linkSetup(inputName, 0, imguName_, PAD_INPUT, enable); - if (ret) { - mediaDevice_->close(); - return ret; - } - - ret = linkSetup(imguName_, PAD_OUTPUT, outputName, 0, enable); - if (ret) { - mediaDevice_->close(); - return ret; - } - - ret = linkSetup(imguName_, PAD_VF, viewfinderName, 0, enable); - if (ret) { - mediaDevice_->close(); - return ret; - } - - ret = linkSetup(imguName_, PAD_STAT, statName, 0, enable); - if (ret) { - mediaDevice_->close(); - return ret; - } - - mediaDevice_->close(); - - return 0; -} - int PipelineHandlerIPU3::mediaBusToCIO2Format(unsigned int code) { switch (code) { @@ -1152,6 +1099,73 @@ void PipelineHandlerIPU3::deleteCIO2(CIO2Device *cio2) delete cio2->sensor; } +/** + * \brief Enable links on the ImgU media graph based on the requested + * stream configuration + * + * FIXME: viewfinder and stat should be enabled conditionally on the requested + * stream configuration. As of now, the IPU3 driver requires them to be + * operated unconditionally not to stall ImgU operations. + * + * \return 0 on success or a negative error code otherwise + */ +int PipelineHandlerIPU3::enableImgULinks(IPU3CameraData *data, bool enable) +{ + ImgUDevice *imgu = data->imgu; + std::string inputName = imgu->imguName_ + " input"; + std::string outputName = imgu->imguName_ + " output"; + std::string viewfinderName = imgu->imguName_ + " viewfinder"; + std::string statName = imgu->imguName_ + " 3a stat"; + MediaDevice *media = imgu->mediaDevice_; + int ret; + + /* \todo Establish rules to handle media devices open/close. */ + ret = media->open(); + if (ret) + return ret; + + ret = imgu->linkSetup(inputName, 0, imgu->imguName_, + ImgUDevice::PAD_INPUT, enable); + if (ret) { + media->close(); + return ret; + } + + /* Output has to be operated unconditionally. */ + ret = imgu->linkSetup(imgu->imguName_, ImgUDevice::PAD_OUTPUT, + outputName, 0, enable); + if (ret) { + media->close(); + return ret; + } + + /* + * FIXME: viewfinder should be linked and operated only if required + * but currently the IPU3 driver requires it regardless of the stream + * configuration. + */ + if (isViewfinderActive(data) || true) { + ret = imgu->linkSetup(imgu->imguName_, ImgUDevice::PAD_VF, + viewfinderName, 0, enable); + if (ret) { + media->close(); + return ret; + } + } + + /* FIXME: stat should be conditionally operated as well. */ + ret = imgu->linkSetup(imgu->imguName_, ImgUDevice::PAD_STAT, + statName, 0, enable); + if (ret) { + media->close(); + return ret; + } + + media->close(); + + return 0; +} + int PipelineHandlerIPU3::setInputFormat(ImgUDevice *imguDevice, const StreamConfiguration &config, Rectangle *rect)