From patchwork Thu Aug 18 09:44:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 17170 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 3215DC3275 for ; Thu, 18 Aug 2022 09:44:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BBAB161FE8; Thu, 18 Aug 2022 11:44:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660815881; bh=ng5PGkYcamEdUQaCz1aBwO/gs99wjLkcB6WJ29xluM0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=aNGnNR/WmRK0hB5ayPNpw55BcF1DxTp9n4ib65ryeON6uNkVEy+SmTvoJr1RvhW8f tTfh/HQie4jLobvmtLP0FxSJcDEkcdgEt6CwBVVbctwlu6xMIjB+rxOLqF8yD0bzJ9 gkUy8DVn3f1rLoIQUzIh/EykdeAkOVXihen2V/K4S4zVtISj15HL/Gnvru+mwfySjl Gbfgoskko6wCdp5elylxyFXkLHI/8+HtbWpxrW5y620ZA2mbORd+m5MAsnX7wQagr5 ywyiEhmCiSvwLk6i2LpkK8saoixZMcZG/+eG/S9eSQ86zMucVNBm5/HZA4c6w7il1o CfNmuMFcU/QGA== Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AD40F61FD0 for ; Thu, 18 Aug 2022 11:44:38 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id D68A9FF808; Thu, 18 Aug 2022 09:44:37 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Thu, 18 Aug 2022 11:44:08 +0200 Message-Id: <20220818094410.1671-16-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220818094410.1671-1-jacopo@jmondi.org> References: <20220818094410.1671-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 15/17] ipa: ipu3: Validate controls before assigning them 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The IPU3 IPA configure() implementation assigns to the class member sensorCtrls_ the list of controls before having validated it. Rework the flow of operations to first validate the controls and then copy them in the class member variables. Signed-off-by: Jacopo Mondi --- src/ipa/ipu3/ipu3.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 072d6cc28f33..dd9d21e4df52 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -161,7 +161,7 @@ protected: std::string logPrefix() const override; private: - bool validateSensorControls(); + bool validateSensorControls(const ControlInfoMap &sensorCtrls); void updateControls(const IPACameraSensorInfo &sensorInfo, const ControlInfoMap &sensorControls, ControlInfoMap *ipaControls); @@ -343,7 +343,7 @@ void IPAIPU3::calculateBdsGrid(const Size &bdsOutputSize) /** * \brief Validate that the sensor controls mandatory for the IPA exists */ -bool IPAIPU3::validateSensorControls() +bool IPAIPU3::validateSensorControls(const ControlInfoMap &sensorCtrls) { static const uint32_t ctrls[] = { V4L2_CID_ANALOGUE_GAIN, @@ -352,7 +352,7 @@ bool IPAIPU3::validateSensorControls() }; for (auto c : ctrls) { - if (sensorCtrls_.find(c) == sensorCtrls_.end()) { + if (sensorCtrls.find(c) == sensorCtrls.end()) { LOG(IPAIPU3, Error) << "Unable to find sensor control " << utils::hex(c); return false; @@ -482,28 +482,17 @@ void IPAIPU3::updateSessionConfiguration(const IPAConfigInfo &configInfo) int IPAIPU3::configure(const IPAConfigInfo &configInfo, ControlInfoMap *ipaControls) { - if (configInfo.sensorControls.empty()) { - LOG(IPAIPU3, Error) << "No sensor controls provided"; - return -ENODATA; + if (!validateSensorControls(configInfo.sensorControls)) { + LOG(IPAIPU3, Error) << "Sensor control validation failed."; + return -EINVAL; } + sensorCtrls_ = configInfo.sensorControls; sensorInfo_ = configInfo.sensorInfo; - lensCtrls_ = configInfo.lensControls; - /* - * Compute the sensor V4L2 controls to be used by the algorithms and - * to be set on the sensor. - */ - sensorCtrls_ = configInfo.sensorControls; - calculateBdsGrid(configInfo.bdsOutputSize); - if (!validateSensorControls()) { - LOG(IPAIPU3, Error) << "Sensor control validation failed."; - return -EINVAL; - } - /* Update the camera controls using the new sensor settings. */ updateControls(sensorInfo_, sensorCtrls_, ipaControls);