[{"id":39844,"web_url":"https://patchwork.libcamera.org/comment/39844/","msgid":"<1478eab6-a17f-48b5-91bb-8352799f79f3@ideasonboard.com>","date":"2026-07-24T15:24:20","subject":"Re: [PATCH v6 31/31] ipa: mali-c55: Port to use LscAlgorithm","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 07. 20. 16:59 keltezéssel, Jacopo Mondi írta:\n> Port the Mali-C55 LSC algorithm to use libIPA LscAlgorithm.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\n> ---\n>   src/ipa/mali-c55/algorithms/lsc.cpp | 156 ++++++++++++++++++++++--------------\n>   src/ipa/mali-c55/algorithms/lsc.h   |  32 ++++++--\n>   src/ipa/mali-c55/ipa_context.h      |   3 +\n>   3 files changed, 122 insertions(+), 69 deletions(-)\n> \n> diff --git a/src/ipa/mali-c55/algorithms/lsc.cpp b/src/ipa/mali-c55/algorithms/lsc.cpp\n> index 097239dcef3e..daa28c3e28e0 100644\n> --- a/src/ipa/mali-c55/algorithms/lsc.cpp\n> +++ b/src/ipa/mali-c55/algorithms/lsc.cpp\n> [...]\n> @@ -48,44 +84,29 @@ int Lsc::init([[maybe_unused]] IPAContext &context, const ValueNode &tuningData)\n>   \t\t\treturn -EINVAL;\n>   \t\t}\n>   \n> -\t\tstd::vector<uint8_t> rTable =\n> -\t\t\tset[\"r\"].get<std::vector<uint8_t>>().value_or(utils::defopt);\n> -\t\tstd::vector<uint8_t> gTable =\n> -\t\t\tset[\"g\"].get<std::vector<uint8_t>>().value_or(utils::defopt);\n> -\t\tstd::vector<uint8_t> bTable =\n> -\t\t\tset[\"b\"].get<std::vector<uint8_t>>().value_or(utils::defopt);\n> -\n> -\t\t/*\n> -\t\t * Some validation to do; only 16x16 and 32x32 tables of\n> -\t\t * coefficients are acceptable, and all tables across all of the\n> -\t\t * sets must be the same size. The first time we encounter a\n> -\t\t * table we check that it is an acceptable size and if so make\n> -\t\t * sure all other tables are of equal size.\n> -\t\t */\n> -\t\tif (!tableSize) {\n> -\t\t\tif (rTable.size() != 256 && rTable.size() != 1024) {\n> -\t\t\t\tLOG(MaliC55Lsc, Error)\n> -\t\t\t\t\t<< \"Invalid table size for colour temperature \" << ct;\n> -\t\t\t\treturn -EINVAL;\n> -\t\t\t}\n> -\t\t\ttableSize = rTable.size();\n> -\t\t}\n> +\t\tstd::vector<uint8_t> rTable = component.at(\"r\");\n> +\t\tstd::vector<uint8_t> gTable = component.at(\"g\");\n> +\t\tstd::vector<uint8_t> bTable = component.at(\"b\");\n\nThese should be references, to avoid the copy.\n\n\n>   \n> -\t\tif (rTable.size() != tableSize ||\n> -\t\t    gTable.size() != tableSize ||\n> -\t\t    bTable.size() != tableSize) {\n> +\t\t/* Only 32x32 tables of coefficients are accepted. */\n> +\t\tif (rTable.size() != kGridSize || gTable.size() != kGridSize ||\n> +\t\t    bTable.size() != kGridSize) {\n\nShouldn't these be enforced by `LscAlgorithm`? Maybe just an `ASSERT()`?\n\n\n>   \t\t\tLOG(MaliC55Lsc, Error)\n> -\t\t\t\t<< \"Invalid or mismatched table size for colour temperature \" << ct;\n> +\t\t\t\t<< \"Invalid table size for colour temperature \" << ct;\n>   \t\t\treturn -EINVAL;\n>   \t\t}\n>   \n> -\t\tif (colourTemperatures_.size() >= 3) {\n> +\t\tif (colourTemperatures_.size() >= kMaxColourTemperatures) {\n>   \t\t\tLOG(MaliC55Lsc, Error)\n>   \t\t\t\t<< \"A maximum of 3 colour temperatures are supported\";\n>   \t\t\treturn -EINVAL;\n>   \t\t}\n>   \n> -\t\tfor (unsigned int i = 0; i < tableSize; i++) {\n> +\t\t/*\n> +\t\t * Create the mesh table entries by assembling up to 3 gains per\n> +\t\t * colour temperature in a u32 word.\n> +\t\t */\n> +\t\tfor (unsigned int i = 0; i < kGridSize; i++) {\n>   \t\t\tmesh_[kRedOffset + i] |=\n>   \t\t\t\t(rTable[i] << (colourTemperatures_.size() * 8));\n>   \t\t\tmesh_[kGreenOffset + i] |=\n> @@ -97,35 +118,36 @@ int Lsc::init([[maybe_unused]] IPAContext &context, const ValueNode &tuningData)\n>   \t\tcolourTemperatures_.push_back(ct);\n>   \t}\n>   \n> -\t/*\n> -\t * The mesh has either 16x16 or 32x32 nodes, we tell the driver which it\n> -\t * is based on the number of values in the tuning data's table.\n> -\t */\n> -\tif (tableSize == 256)\n> -\t\tmeshSize_ = 15;\n> -\telse\n> -\t\tmeshSize_ = 31;\n\nSo now only the 32x32 is accepted? I think this could be mentioned in the commit message.\n\n\n> -\n>   \treturn 0;\n>   }\n> [...]","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 AB573BDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jul 2026 15:24:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 93C0E67F28;\n\tFri, 24 Jul 2026 17:24:25 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E0EDB67E89\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jul 2026 17:24:23 +0200 (CEST)","from [192.168.33.42] (185.182.215.156.nat.pool.zt.hu\n\t[185.182.215.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EB171524;\n\tFri, 24 Jul 2026 17:23:21 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"MGBJRqFi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1784906602;\n\tbh=ONVwIzMKrrI1pkXxkavWm6TqM30jfneFECL3u48crw8=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=MGBJRqFiWTpLBB7HayiPa31Me4IRrmjdk7l9KgZRAEma2lVDVufDfxP3OVivK4yDa\n\tYGKbxFRD2G5tRvwiywDa5CS68cfiXPWKt3DHRRXbUh21JHouRitCKZv/t1xT3qQFVx\n\teiTP0P8TEWFCH9WNeh3p+PHqCSXACBF74YVUZWdc=","Message-ID":"<1478eab6-a17f-48b5-91bb-8352799f79f3@ideasonboard.com>","Date":"Fri, 24 Jul 2026 17:24:20 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v6 31/31] ipa: mali-c55: Port to use LscAlgorithm","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org,\n\tStefan Klug <stefan.klug@ideasonboard.com>,\n\tMilan Zamazal <mzamazal@redhat.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>","References":"<20260720-libipa-algorithms-v6-0-ececb73f97cb@ideasonboard.com>\n\t<20260720-libipa-algorithms-v6-31-ececb73f97cb@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260720-libipa-algorithms-v6-31-ececb73f97cb@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]