Show a patch.

GET /api/1.1/patches/27224/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 27224,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/27224/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/27224/",
    "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-24-968757b038bb@ideasonboard.com>",
    "date": "2026-07-06T08:01:44",
    "name": "[v3,24/35] ipa: rkisp1: lsc: Port to use LscAlgorithm",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "4b6010620d0752759898e9489479c75c72afb11d",
    "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/27224/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/27224/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/27224/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 3623DC330F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Jul 2026 08:02:32 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DDDCB66041;\n\tMon,  6 Jul 2026 10:02:31 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2075366037\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Jul 2026 10:02:13 +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 C21969CE;\n\tMon,  6 Jul 2026 10:01:24 +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=\"ifmf07F0\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783324885;\n\tbh=0T8HStG4rLCgmIX8CypsMxEEFURhdfPveKZUxkGRcQ0=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=ifmf07F0wxyyq+qURQghxSgy/qSnyEnZE1pzSFx0xA3mD/J+GtFq9Ds1YDak63Sqp\n\tooDPnT/gHKSQle5BexGkWk63lXAdsdF9KvXR1eGyYw8swmROrYjfRmZcQrOshU6Iie\n\tztqa0+wdk3+uFAhNXOsPrQHa1InP0vjpMj6oVM8k=",
        "From": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Date": "Mon, 06 Jul 2026 10:01:44 +0200",
        "Subject": "[PATCH v3 24/35] ipa: rkisp1: lsc: Port to use LscAlgorithm",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "7bit",
        "Message-Id": "<20260706-libipa-algorithms-v3-24-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=5866;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=0T8HStG4rLCgmIX8CypsMxEEFURhdfPveKZUxkGRcQ0=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBqS2DyrcZ00Gyr1Rb3TaUYiJYKVoVCxLqZXoQl7\n\tWZmBptG9i2JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaktg8gAKCRByNAaPFqFW\n\tPH22EACRw/ocIfXU5C1XuKJlUEFOs9wjUK4GietW1pqjK6S9neQdEFMGVIuIzbiImY1tBvsY1j5\n\tqKBxylu3+7W5xPGST5+U7FiFB82nwm1/o/Q5Go+y4PqMkFSGoYQoqtYPIbPrnDgZmIQEalBL7+0\n\tatkJCpx9bEbB3jIFrIlwVkXNkqH1r4f7n3g7zuA3xZOq2j5vKYvt9cKTOTi/wJ+BI2pbrvq2YEn\n\tnpAPmwFUN8GuPx0j9RVAEeKH4xAZacJvztP46qJOUc8iHyarTUm9H0nsRpErRE06jm4J+2rgcnc\n\tR0qyAGCECRVO+JO51kNEmQH358vNhvU01T8wCBrLDxw+7qZFYRD9LPVHItRETXKLfRaCEPrsP/r\n\tbR8326SlUuZeGGcu8YbwhqYjbDLDwXO/+IzhSTznyi41AUs7++c33UBcSE2ktWsXBpA2VKi6C/u\n\ts9Jil3yvBvRVm57mkVZLLvzMwUK3NSCybYxAdmgWwrojYPyHN0SC7GKBNixCz6BsZqyq1Txm4Ag\n\tD+UfC5lMTQ3qpLmXtk5vyZMTgKxZ+DLpR/9OlyTpEBd4tQZi4G144puL5SYIShwnD4Zfr34qmqZ\n\t2I8gJwWkcBkZ+ORmd6sb54TnABS8T1H7ZM6Inl3DjKEztsuhnvrEJYH5Ar2A9KCTL+Btksc0Ier\n\tu8TrTzGi06e52lg==",
        "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": "Port the RkISP1 LSC algorithm to use the LscAlgorithm class by\ncomposition.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/lsc.cpp | 72 +++++----------------------------------\n src/ipa/rkisp1/algorithms/lsc.h   | 13 +++----\n src/ipa/rkisp1/ipa_context.h      | 10 ++----\n 3 files changed, 18 insertions(+), 77 deletions(-)",
    "diff": "diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\nindex f393f101b740..828ab2f32fcc 100644\n--- a/src/ipa/rkisp1/algorithms/lsc.cpp\n+++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n@@ -14,12 +14,6 @@\n #include <libcamera/base/log.h>\n #include <libcamera/base/utils.h>\n \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  * \\file lsc.h\n  */\n@@ -73,42 +67,8 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,\n \txPos_ = sizesListToPositions(xSize_);\n \tyPos_ = sizesListToPositions(ySize_);\n \n-\t/* Get all defined sets to apply. */\n-\tconst ValueNode &sets = tuningData[\"sets\"];\n-\tif (!sets.isList()) {\n-\t\tLOG(RkISP1Lsc, Error)\n-\t\t\t<< \"'sets' parameter not found in tuning file\";\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tint ret;\n-\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<LscTable>();\n-\t\tret = algo_->parseLscData(sets);\n-\t} else if (type == \"polynomial\") {\n-\t\tLOG(RkISP1Lsc, Debug) << \"Loading polynomial LSC data.\";\n-\t\t/*\n-\t\t * \\todo: Most likely the reference frame should be native_size.\n-\t\t * Let's wait how the internal discussions progress.\n-\t\t */\n-\t\talgo_ = std::make_unique<LscPolynomial>(context.sensorInfo.activeAreaSize);\n-\t\tret = algo_->parseLscData(sets);\n-\t} else {\n-\t\tLOG(RkISP1Lsc, Error) << \"Unsupported LSC data type '\"\n-\t\t\t\t      << type << \"'\";\n-\t\tret = -EINVAL;\n-\t}\n-\n-\tif (ret)\n-\t\treturn ret;\n-\n-\tcontext.ctrlMap[&controls::LensShadingCorrectionEnable] =\n-\t\tControlInfo(false, true, true);\n-\n-\treturn 0;\n+\treturn lscAlgo_.init(tuningData, context.sensorInfo.activeAreaSize,\n+\t\t\t     context.ctrlMap);\n }\n \n std::vector<double> LensShadingCorrection::parseSizes(const ValueNode &tuningData,\n@@ -199,13 +159,8 @@ int LensShadingCorrection::configure(IPAContext &context,\n \t\tyGrad_[i] = std::round(32768 / ySizes_[i]);\n \t}\n \n-\tLOG(RkISP1Lsc, Debug) << \"Sample LSC data for \" << configInfo.analogCrop;\n-\tlsc::ComponentsMap shadingData = algo_->sampleForCrop(configInfo.analogCrop,\n-\t\t\t\t\t\t\t      xPos_, yPos_);\n-\tsets_.setData(std::move(shadingData));\n-\n-\tcontext.activeState.lsc.enabled = true;\n-\treturn 0;\n+\treturn lscAlgo_.configure(context.activeState.lsc, configInfo.analogCrop,\n+\t\t\t\t  xPos_, yPos_);\n }\n \n void LensShadingCorrection::setParameters(rkisp1_cif_isp_lsc_config &config)\n@@ -233,19 +188,8 @@ void LensShadingCorrection::queueRequest(IPAContext &context,\n \t\t\t\t\t IPAFrameContext &frameContext,\n \t\t\t\t\t const ControlList &controls)\n {\n-\tauto &lsc = context.activeState.lsc;\n-\n-\tconst auto &lscEnable = controls.get(controls::LensShadingCorrectionEnable);\n-\tif (lscEnable && *lscEnable != lsc.enabled) {\n-\t\tlsc.enabled = *lscEnable;\n-\n-\t\tLOG(RkISP1Lsc, Debug)\n-\t\t\t<< (lsc.enabled ? \"Enabling\" : \"Disabling\") << \" Lsc\";\n-\n-\t\tframeContext.lsc.update = true;\n-\t}\n-\n-\tframeContext.lsc.enabled = lsc.enabled;\n+\tlscAlgo_.queueRequest(context.activeState.lsc, frameContext.lsc,\n+\t\t\t      controls);\n }\n \n /**\n@@ -283,7 +227,7 @@ void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,\n \n \tsetParameters(*config);\n \n-\tconst lsc::Components &set = sets_.getInterpolated(quantizedCt);\n+\tconst lsc::Components &set = lscAlgo_.interpolateComponents(quantizedCt);\n \tcopyTable(*config, set);\n \n \tlastAppliedCt_ = ct;\n@@ -303,7 +247,7 @@ void LensShadingCorrection::process([[maybe_unused]] IPAContext &context,\n \t\t\t\t    [[maybe_unused]] const rkisp1_stat_buffer *stats,\n \t\t\t\t    ControlList &metadata)\n {\n-\tmetadata.set(controls::LensShadingCorrectionEnable, frameContext.lsc.enabled);\n+\tlscAlgo_.process(frameContext.lsc, metadata);\n }\n \n REGISTER_IPA_ALGORITHM(LensShadingCorrection, \"LensShadingCorrection\")\ndiff --git a/src/ipa/rkisp1/algorithms/lsc.h b/src/ipa/rkisp1/algorithms/lsc.h\nindex 06aa7a5f133c..e7d3091a36c5 100644\n--- a/src/ipa/rkisp1/algorithms/lsc.h\n+++ b/src/ipa/rkisp1/algorithms/lsc.h\n@@ -7,10 +7,13 @@\n \n #pragma once\n \n-#include <memory>\n+#include <vector>\n \n-#include \"libipa/interpolator.h\"\n-#include \"libipa/lsc_base.h\"\n+#include <linux/rkisp1-config.h>\n+\n+#include \"libcamera/internal/value_node.h\"\n+\n+#include \"libipa/lsc.h\"\n \n #include \"algorithm.h\"\n \n@@ -55,9 +58,7 @@ private:\n \tunsigned int lastAppliedCt_;\n \tunsigned int lastAppliedQuantizedCt_;\n \n-\tipa::Interpolator<lsc::Components> sets_;\n-\n-\tstd::unique_ptr<LscImplementation> algo_;\n+\tLscAlgorithm lscAlgo_;\n };\n \n } /* namespace ipa::rkisp1::algorithms */\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex 6698ccfd77cf..7b4346c54ed2 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -30,6 +30,7 @@\n #include \"libipa/ccm.h\"\n #include \"libipa/fc_queue.h\"\n #include \"libipa/fixedpoint.h\"\n+#include \"libipa/lsc.h\"\n \n namespace libcamera {\n \n@@ -141,9 +142,7 @@ struct IPAActiveState {\n \t\tdouble strength;\n \t} wdr;\n \n-\tstruct {\n-\t\tbool enabled;\n-\t} lsc;\n+\tipa::lsc::ActiveState lsc;\n };\n \n struct IPAFrameContext : public FrameContext {\n@@ -217,10 +216,7 @@ struct IPAFrameContext : public FrameContext {\n \t\tdouble gain;\n \t} wdr;\n \n-\tstruct {\n-\t\tbool enabled;\n-\t\tbool update;\n-\t} lsc;\n+\tipa::lsc::FrameContext lsc;\n };\n \n struct IPAContext {\n",
    "prefixes": [
        "v3",
        "24/35"
    ]
}