Patch Detail
Show a patch.
GET /api/1.1/patches/27217/?format=api
{ "id": 27217, "url": "https://patchwork.libcamera.org/api/1.1/patches/27217/?format=api", "web_url": "https://patchwork.libcamera.org/patch/27217/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260706-libipa-algorithms-v3-17-968757b038bb@ideasonboard.com>", "date": "2026-07-06T08:01:37", "name": "[v3,17/35] ipa: libipa: lsc_table: Move LscTable from RkISP1", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "9a3bcbc225df154b27b947280fbd775ad782573b", "submitter": { "id": 143, "url": "https://patchwork.libcamera.org/api/1.1/people/143/?format=api", "name": "Jacopo Mondi", "email": "jacopo.mondi@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/27217/mbox/", "series": [ { "id": 6038, "url": "https://patchwork.libcamera.org/api/1.1/series/6038/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6038", "date": "2026-07-06T08:01:20", "name": "ipa: libipa: Introduce libipa algorithms", "version": 3, "mbox": "https://patchwork.libcamera.org/series/6038/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/27217/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/27217/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 D4D05C330A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 6 Jul 2026 08:02:23 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 85A746603E;\n\tMon, 6 Jul 2026 10:02:23 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BE1F466012\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 6 Jul 2026 10:02:08 +0200 (CEST)", "from [192.168.125.177] (mob-109-113-60-81.net.vodafone.it\n\t[109.113.60.81])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 63C043F97;\n\tMon, 6 Jul 2026 10:01:20 +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=\"riEF/JLG\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783324880;\n\tbh=88oJ1AACTeEN2ePgzO63p+RFA3svmWEVA3UY8uvI+uE=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=riEF/JLGUHcEuT10KM500qiTYpd4mJb0ct4SAa4mRgNp8i7fV8ZVypJydeCEyRnUY\n\tSkiCTfUkVvxmcsjYENXxvy3OrmkxbDNuRHpsS6TfujICkkV/wLQoK5FsDVihS9aCnQ\n\tN4uC3ATSa1QZ4Eb+MYN1xcMCyDbvPrYp/C2WI11I=", "From": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "Date": "Mon, 06 Jul 2026 10:01:37 +0200", "Subject": "[PATCH v3 17/35] ipa: libipa: lsc_table: Move LscTable from RkISP1", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260706-libipa-algorithms-v3-17-968757b038bb@ideasonboard.com>", "References": "<20260706-libipa-algorithms-v3-0-968757b038bb@ideasonboard.com>", "In-Reply-To": "<20260706-libipa-algorithms-v3-0-968757b038bb@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org, \n\tStefan Klug <stefan.klug@ideasonboard.com>", "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "X-Mailer": "b4 0.14.3", "X-Developer-Signature": "v=1; a=openpgp-sha256; l=8250;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=88oJ1AACTeEN2ePgzO63p+RFA3svmWEVA3UY8uvI+uE=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBqS2Dxz4aDjjTOqGnVVAdtXPyErqIPmDZISmhIl\n\tOGZYsSEVaGJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaktg8QAKCRByNAaPFqFW\n\tPH4rEACPjuoN8AMDCzCUdgz6DSenhb7b3YMmPQgWhkPshwQQsK67w2qcD9ydfOkhF14txNlU6fv\n\thzysI9tCXyAIlBFpMARA/MSawmlsjPaE3Msa1QYPO5VJazD1DtD5c06/D+MmzQ7QyKR2aHEwuHg\n\tXylmXbXn4hWvOSM5kJEC9UgbNJ3Xmqd709D+6RHMDQe9ONkKHca6VO8x380rbicdZuJKwILMuGU\n\tGBmMrNtcnIEuTIT7A7/JVCoK1O2fSP/w4trZKDDuUWIeUh7U+VB41awqoUI9BM1dZ5QxgYe0uIN\n\tdFipS0fCMempmavox4dURJSbj8eiwwOEOyYKcY8OojZPz5if8ja6G7dT5YEkdLs7xxQEzB/lJxm\n\tLRGaUHx2nO/SIvZH4G41mLkfYYg96YOLZtBPTuiVhbpM0TTu+ZOFIcfiqT4j7CeKKJnuXdoD/Uc\n\tq09VkjSbEzKcsfaWfWC2Fsv2BvibuoNzMNSQgnV3+OBSr7Ug0L3kFE9RTocMg6Z44A+qVP1Kw9v\n\t3qen15REbGZFuk+otpnVPrHhLFkdjvsNQPO/FKgWbQoQfNpAS2bx19NJfLZZXYBNv5IDtV+M+Gd\n\tuaffXlHJfrbq3oenm09wv4Z0Z52k+jkY/rmIZG7sRQH0i233CRCC4v0k9G5zlnCfMe5N6RMVepN\n\tnb1N+XzpG4lpOkg==", "X-Developer-Key": "i=jacopo.mondi@ideasonboard.com; a=openpgp;\n\tfpr=72392EDC88144A65C701EA9BA5826A2587AD026B", "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>" }, "content": "Move the LscTableImpl class to libipa from RkISP1.\n\nRename the class from LscTableImpl to a simpler LscTable.\nThe class is copied verbatim, only documntation has been added.\n\nThe implementation still contains RkISP1 specific data which will be\nremoved once the class is generalized.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/ipa/libipa/lsc_table.cpp | 95 +++++++++++++++++++++++++++++++++++++++\n src/ipa/libipa/lsc_table.h | 50 +++++++++++++++++++++\n src/ipa/libipa/meson.build | 2 +\n src/ipa/rkisp1/algorithms/lsc.cpp | 81 +--------------------------------\n 4 files changed, 149 insertions(+), 79 deletions(-)", "diff": "diff --git a/src/ipa/libipa/lsc_table.cpp b/src/ipa/libipa/lsc_table.cpp\nnew file mode 100644\nindex 000000000000..41a862b92e88\n--- /dev/null\n+++ b/src/ipa/libipa/lsc_table.cpp\n@@ -0,0 +1,95 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2026, Ideas On Board\n+ *\n+ * Table-based Lsc implementation\n+ */\n+\n+#include \"lsc_table.h\"\n+\n+/* \\todo Remove RkISP1 from libipa. */\n+#include \"linux/rkisp1-config.h\"\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(LscTable)\n+\n+namespace ipa {\n+\n+/**\n+ * \\class LscTable\n+ * \\brief Table based lsc algorithm implementation\n+ *\n+ * Table based lsc algorithm implementation. The LscTable class implements lsc\n+ * support using tabular lsc data.\n+ *\n+ * \\sa LscImplementation\n+ */\n+\n+/**\n+ * \\brief Parse tabular lsc data\n+ * \\param[in] sets The tuning file content\n+ *\n+ * Parse the lsc data in tabular form from the \\a sets tuning data.\n+ *\n+ * \\return 0 on success or a negative error number otherwise\n+ */\n+int LscTable::parseLscData(const ValueNode &sets)\n+{\n+\tfor (const auto &set : sets.asList()) {\n+\t\tuint32_t ct = set[\"ct\"].get<uint32_t>(0);\n+\n+\t\tif (lscData_.count(ct)) {\n+\t\t\tLOG(LscTable, Error)\n+\t\t\t\t<< \"Multiple sets found for color temperature \"\n+\t\t\t\t<< ct;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tlsc::Components components;\n+\t\tcomponents.r = parseTable(set, \"r\");\n+\t\tcomponents.gr = parseTable(set, \"gr\");\n+\t\tcomponents.gb = parseTable(set, \"gb\");\n+\t\tcomponents.b = parseTable(set, \"b\");\n+\n+\t\tif (components.r.empty() || components.gr.empty() ||\n+\t\t components.gb.empty() || components.b.empty()) {\n+\t\t\tLOG(LscTable, Error)\n+\t\t\t\t<< \"Set for color temperature \" << ct\n+\t\t\t\t<< \" is missing tables\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tlscData_.emplace(ct, std::move(components));\n+\t}\n+\n+\tif (lscData_.empty()) {\n+\t\tLOG(LscTable, Error) << \"Failed to load any sets\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+std::vector<uint16_t> LscTable::parseTable(const ValueNode &tuningData,\n+\t\t\t\t\t const char *prop)\n+{\n+\tstatic constexpr unsigned int kLscNumSamples =\n+\t\tRKISP1_CIF_ISP_LSC_SAMPLES_MAX * RKISP1_CIF_ISP_LSC_SAMPLES_MAX;\n+\n+\tstd::vector<uint16_t> table =\n+\t\ttuningData[prop].get<std::vector<uint16_t>>().value_or(utils::defopt);\n+\tif (table.size() != kLscNumSamples) {\n+\t\tLOG(LscTable, Error)\n+\t\t\t<< \"Invalid '\" << prop << \"' values: expected \"\n+\t\t\t<< kLscNumSamples\n+\t\t\t<< \" elements, got \" << table.size();\n+\t\treturn {};\n+\t}\n+\n+\treturn table;\n+}\n+\n+} /* namespace ipa */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/libipa/lsc_table.h b/src/ipa/libipa/lsc_table.h\nnew file mode 100644\nindex 000000000000..0983b78c3f6b\n--- /dev/null\n+++ b/src/ipa/libipa/lsc_table.h\n@@ -0,0 +1,50 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2026, Ideas On Board\n+ *\n+ * Table-based Lsc implementation\n+ */\n+#pragma once\n+\n+#include <vector>\n+\n+#include <libcamera/base/log.h>\n+#include <libcamera/base/span.h>\n+\n+#include <libcamera/geometry.h>\n+\n+#include \"libcamera/internal/value_node.h\"\n+\n+#include \"lsc_base.h\"\n+\n+namespace libcamera {\n+\n+LOG_DECLARE_CATEGORY(LscTable)\n+\n+namespace ipa {\n+\n+class LscTable : public LscImplementation\n+{\n+public:\n+\tint parseLscData(const ValueNode &sets) override;\n+\n+\tlsc::ComponentsMap\n+\tsampleForCrop([[maybe_unused]] const Rectangle &cropRectangle,\n+\t\t [[maybe_unused]] Span<const double> xSizes,\n+\t\t [[maybe_unused]] Span<const double> ySizes) override\n+\t{\n+\t\tLOG(LscTable, Warning)\n+\t\t\t<< \"Tabular LSC data doesn't support resampling\";\n+\t\treturn lscData_;\n+\t}\n+\n+private:\n+\tstd::vector<uint16_t> parseTable(const ValueNode &tuningData,\n+\t\t\t\t\t const char *prop);\n+\n+\tlsc::ComponentsMap lscData_;\n+};\n+\n+} /* namespace ipa */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build\nindex 96611e90ee1e..95d398d99fd6 100644\n--- a/src/ipa/libipa/meson.build\n+++ b/src/ipa/libipa/meson.build\n@@ -16,6 +16,7 @@ libipa_headers = files([\n 'interpolator.h',\n 'lsc_base.h',\n 'lsc_polynomial.h',\n+ 'lsc_table.h',\n 'lux.h',\n 'module.h',\n 'pwl.h',\n@@ -39,6 +40,7 @@ libipa_sources = files([\n 'interpolator.cpp',\n 'lsc_base.cpp',\n 'lsc_polynomial.cpp',\n+ 'lsc_table.cpp',\n 'lux.cpp',\n 'module.cpp',\n 'pwl.cpp',\ndiff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\nindex a4ea879aaa83..974534175e06 100644\n--- a/src/ipa/rkisp1/algorithms/lsc.cpp\n+++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n@@ -17,6 +17,7 @@\n #include \"libcamera/internal/value_node.h\"\n \n #include \"libipa/lsc_polynomial.h\"\n+#include \"libipa/lsc_table.h\"\n #include \"linux/rkisp1-config.h\"\n \n /**\n@@ -33,84 +34,6 @@ namespace {\n \n constexpr int kColourTemperatureQuantization = 10;\n \n-class LscTableImpl : public LscImplementation\n-{\n-public:\n-\tint parseLscData(const ValueNode &sets) override;\n-\n-\tlsc::ComponentsMap\n-\tsampleForCrop([[maybe_unused]] const Rectangle &cropRectangle,\n-\t\t [[maybe_unused]] Span<const double> xSizes,\n-\t\t [[maybe_unused]] Span<const double> ySizes) override\n-\t{\n-\t\tLOG(RkISP1Lsc, Warning)\n-\t\t\t<< \"Tabular LSC data doesn't support resampling\";\n-\t\treturn lscData_;\n-\t}\n-\n-private:\n-\tstd::vector<uint16_t> parseTable(const ValueNode &tuningData,\n-\t\t\t\t\t const char *prop);\n-\n-\tlsc::ComponentsMap lscData_;\n-};\n-\n-int LscTableImpl::parseLscData(const ValueNode &sets)\n-{\n-\tfor (const auto &set : sets.asList()) {\n-\t\tuint32_t ct = set[\"ct\"].get<uint32_t>(0);\n-\n-\t\tif (lscData_.count(ct)) {\n-\t\t\tLOG(RkISP1Lsc, Error)\n-\t\t\t\t<< \"Multiple sets found for color temperature \"\n-\t\t\t\t<< ct;\n-\t\t\treturn -EINVAL;\n-\t\t}\n-\n-\t\tlsc::Components components;\n-\t\tcomponents.r = parseTable(set, \"r\");\n-\t\tcomponents.gr = parseTable(set, \"gr\");\n-\t\tcomponents.gb = parseTable(set, \"gb\");\n-\t\tcomponents.b = parseTable(set, \"b\");\n-\n-\t\tif (components.r.empty() || components.gr.empty() ||\n-\t\t components.gb.empty() || components.b.empty()) {\n-\t\t\tLOG(RkISP1Lsc, Error)\n-\t\t\t\t<< \"Set for color temperature \" << ct\n-\t\t\t\t<< \" is missing tables\";\n-\t\t\treturn -EINVAL;\n-\t\t}\n-\n-\t\tlscData_.emplace(ct, std::move(components));\n-\t}\n-\n-\tif (lscData_.empty()) {\n-\t\tLOG(RkISP1Lsc, Error) << \"Failed to load any sets\";\n-\t\treturn -EINVAL;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-std::vector<uint16_t> LscTableImpl::parseTable(const ValueNode &tuningData,\n-\t\t\t\t\t\t const char *prop)\n-{\n-\tstatic constexpr unsigned int kLscNumSamples =\n-\t\tRKISP1_CIF_ISP_LSC_SAMPLES_MAX * RKISP1_CIF_ISP_LSC_SAMPLES_MAX;\n-\n-\tstd::vector<uint16_t> table =\n-\t\ttuningData[prop].get<std::vector<uint16_t>>().value_or(utils::defopt);\n-\tif (table.size() != kLscNumSamples) {\n-\t\tLOG(RkISP1Lsc, Error)\n-\t\t\t<< \"Invalid '\" << prop << \"' values: expected \"\n-\t\t\t<< kLscNumSamples\n-\t\t\t<< \" elements, got \" << table.size();\n-\t\treturn {};\n-\t}\n-\n-\treturn table;\n-}\n-\n std::vector<double> parseSizes(const ValueNode &tuningData,\n \t\t\t const char *prop)\n {\n@@ -190,7 +113,7 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,\n \tstd::string type = tuningData[\"type\"].get<std::string>(\"table\");\n \tif (type == \"table\") {\n \t\tLOG(RkISP1Lsc, Debug) << \"Loading tabular LSC data.\";\n-\t\talgo_ = std::make_unique<LscTableImpl>();\n+\t\talgo_ = std::make_unique<LscTable>();\n \t\tret = algo_->parseLscData(sets);\n \t} else if (type == \"polynomial\") {\n \t\tLOG(RkISP1Lsc, Debug) << \"Loading polynomial LSC data.\";\n", "prefixes": [ "v3", "17/35" ] }