From patchwork Mon Jul 20 10:47:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 8889 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 AD21DC2E68 for ; Mon, 20 Jul 2020 10:44:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 807386081A; Mon, 20 Jul 2020 12:44:30 +0200 (CEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E9876039F for ; Mon, 20 Jul 2020 12:44:27 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 5CC1E60010; Mon, 20 Jul 2020 10:44:26 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Jul 2020 12:47:34 +0200 Message-Id: <20200720104736.19986-18-jacopo@jmondi.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720104736.19986-1-jacopo@jmondi.org> References: <20200720104736.19986-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 17/19] libcamera: ipu3: Validate the pipe configuration 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" Collect the desired ImgU pipe configuration while assigning streams in the pipeline handler validate() function and ask the ImgUDevice class to calculate the pipe configuration parameters. If the requested pipe configuration results in a non-valid configuration, return an error from the validate() function. Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 0379fb7b92a7..5237c3b306df 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -77,6 +77,7 @@ private: const IPU3CameraData *data_; StreamConfiguration cio2Configuration_; + ImgUDevice::PipeConfig pipeConfig_; }; class PipelineHandlerIPU3 : public PipelineHandler @@ -189,6 +190,9 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() LOG(IPU3, Debug) << "CIO2 configuration: " << cio2Configuration_.toString(); + ImgUDevice::Pipe pipe{}; + pipe.input = cio2Configuration_.size; + /* * Adjust the configurations if needed and assign streams while * iterating them. @@ -262,10 +266,15 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() cfg->setStream(const_cast(&data_->outStream_)); mainOutputAvailable = false; + pipe.output = cfg->size; + if (yuvCount == 1) + pipe.viewfinder = pipe.output; + LOG(IPU3, Debug) << "Assigned " << cfg->toString() << " to the main output"; } else { cfg->setStream(const_cast(&data_->vfStream_)); + pipe.viewfinder = cfg->size; LOG(IPU3, Debug) << "Assigned " << cfg->toString() << " to the viewfinder output"; @@ -281,6 +290,16 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() } } + /* Only compute the ImgU configuration if a YUV stream has been requested. */ + if (yuvCount) { + pipeConfig_ = data_->imgu_->calculatePipeConfig(&pipe); + if (pipeConfig_.isNull()) { + LOG(IPU3, Error) << "Failed to calculate pipe configuration: " + << "unsupported resolutions."; + return Invalid; + } + } + return status; }