{"id":17170,"url":"https://patchwork.libcamera.org/api/1.1/patches/17170/?format=json","web_url":"https://patchwork.libcamera.org/patch/17170/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220818094410.1671-16-jacopo@jmondi.org>","date":"2022-08-18T09:44:08","name":"[libcamera-devel,v3,15/17] ipa: ipu3: Validate controls before assigning them","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"353ef40f9c58154d350e8fdf91fd5959af0700f0","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17170/mbox/","series":[{"id":3426,"url":"https://patchwork.libcamera.org/api/1.1/series/3426/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3426","date":"2022-08-18T09:43:53","name":"libcamera: Align IPU3 and RKISP1 interfaces","version":3,"mbox":"https://patchwork.libcamera.org/series/3426/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17170/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17170/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 3215DC3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Aug 2022 09:44:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BBAB161FE8;\n\tThu, 18 Aug 2022 11:44:41 +0200 (CEST)","from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AD40F61FD0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Aug 2022 11:44:38 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id D68A9FF808;\n\tThu, 18 Aug 2022 09:44:37 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660815881;\n\tbh=ng5PGkYcamEdUQaCz1aBwO/gs99wjLkcB6WJ29xluM0=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=aNGnNR/WmRK0hB5ayPNpw55BcF1DxTp9n4ib65ryeON6uNkVEy+SmTvoJr1RvhW8f\n\ttTfh/HQie4jLobvmtLP0FxSJcDEkcdgEt6CwBVVbctwlu6xMIjB+rxOLqF8yD0bzJ9\n\tgkUy8DVn3f1rLoIQUzIh/EykdeAkOVXihen2V/K4S4zVtISj15HL/Gnvru+mwfySjl\n\tGbfgoskko6wCdp5elylxyFXkLHI/8+HtbWpxrW5y620ZA2mbORd+m5MAsnX7wQagr5\n\tywyiEhmCiSvwLk6i2LpkK8saoixZMcZG/+eG/S9eSQ86zMucVNBm5/HZA4c6w7il1o\n\tCfNmuMFcU/QGA==","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 15/17] ipa: ipu3: Validate controls\n\tbefore assigning them","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo@jmondi.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The IPU3 IPA configure() implementation assigns to the class member\nsensorCtrls_ the list of controls before having validated it.\n\nRework the flow of operations to first validate the controls and then\ncopy them in the class member variables.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/ipa/ipu3/ipu3.cpp | 25 +++++++------------------\n 1 file changed, 7 insertions(+), 18 deletions(-)","diff":"diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 072d6cc28f33..dd9d21e4df52 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -161,7 +161,7 @@ protected:\n \tstd::string logPrefix() const override;\n \n private:\n-\tbool validateSensorControls();\n+\tbool validateSensorControls(const ControlInfoMap &sensorCtrls);\n \tvoid updateControls(const IPACameraSensorInfo &sensorInfo,\n \t\t\t    const ControlInfoMap &sensorControls,\n \t\t\t    ControlInfoMap *ipaControls);\n@@ -343,7 +343,7 @@ void IPAIPU3::calculateBdsGrid(const Size &bdsOutputSize)\n /**\n  * \\brief Validate that the sensor controls mandatory for the IPA exists\n  */\n-bool IPAIPU3::validateSensorControls()\n+bool IPAIPU3::validateSensorControls(const ControlInfoMap &sensorCtrls)\n {\n \tstatic const uint32_t ctrls[] = {\n \t\tV4L2_CID_ANALOGUE_GAIN,\n@@ -352,7 +352,7 @@ bool IPAIPU3::validateSensorControls()\n \t};\n \n \tfor (auto c : ctrls) {\n-\t\tif (sensorCtrls_.find(c) == sensorCtrls_.end()) {\n+\t\tif (sensorCtrls.find(c) == sensorCtrls.end()) {\n \t\t\tLOG(IPAIPU3, Error) << \"Unable to find sensor control \"\n \t\t\t\t\t    << utils::hex(c);\n \t\t\treturn false;\n@@ -482,28 +482,17 @@ void IPAIPU3::updateSessionConfiguration(const IPAConfigInfo &configInfo)\n int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n \t\t       ControlInfoMap *ipaControls)\n {\n-\tif (configInfo.sensorControls.empty()) {\n-\t\tLOG(IPAIPU3, Error) << \"No sensor controls provided\";\n-\t\treturn -ENODATA;\n+\tif (!validateSensorControls(configInfo.sensorControls)) {\n+\t\tLOG(IPAIPU3, Error) << \"Sensor control validation failed.\";\n+\t\treturn -EINVAL;\n \t}\n \n+\tsensorCtrls_ = configInfo.sensorControls;\n \tsensorInfo_ = configInfo.sensorInfo;\n-\n \tlensCtrls_ = configInfo.lensControls;\n \n-\t/*\n-\t * Compute the sensor V4L2 controls to be used by the algorithms and\n-\t * to be set on the sensor.\n-\t */\n-\tsensorCtrls_ = configInfo.sensorControls;\n-\n \tcalculateBdsGrid(configInfo.bdsOutputSize);\n \n-\tif (!validateSensorControls()) {\n-\t\tLOG(IPAIPU3, Error) << \"Sensor control validation failed.\";\n-\t\treturn -EINVAL;\n-\t}\n-\n \t/* Update the camera controls using the new sensor settings. */\n \tupdateControls(sensorInfo_, sensorCtrls_, ipaControls);\n \n","prefixes":["libcamera-devel","v3","15/17"]}