Show a patch.

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

{
    "id": 26026,
    "url": "https://patchwork.libcamera.org/api/patches/26026/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26026/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20260128-sklug-lsc-resampling-v2-dev-v6-15-af7d95f03d22@ideasonboard.com>",
    "date": "2026-01-28T16:00:32",
    "name": "[v6,15/15] ipa: rkisp1: Implement LensShadingCorrectionEnable control",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "e3ad4359c09ae35cc47ee1cd80e37a5e233e2806",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/26026/mbox/",
    "series": [
        {
            "id": 5751,
            "url": "https://patchwork.libcamera.org/api/series/5751/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5751",
            "date": "2026-01-28T16:00:17",
            "name": "Add resampling support for polynomial LSC data",
            "version": 6,
            "mbox": "https://patchwork.libcamera.org/series/5751/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26026/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26026/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 912D2C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 28 Jan 2026 16:01:10 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 49B4562000;\n\tWed, 28 Jan 2026 17:01:10 +0100 (CET)",
            "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 E44C961FDB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Jan 2026 17:01:08 +0100 (CET)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:1a60:e70f:ec38:13a9])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id B0B921FBC; \n\tWed, 28 Jan 2026 17:00:31 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"qrqOGK44\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769616031;\n\tbh=7Wx67UStwgEoLnP7Xbl/rkT50e8YqwzzTWg/UOnk1YA=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=qrqOGK44AakP0NTFF5wmh/ES3xpjh7jw4jx1MkPyGpV+a/GruIIM7kHAf3cwjBi8O\n\t++BJq6qUdmAc7zRAVgiJAwXR3S36e8FpelKf1vZqCS4aXL73rTm2TD3IV5yIUwVIP1\n\tkADkMUESw/TsAm9GRCNSugQ9ty0Zgiarz3DpYoFs=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "Date": "Wed, 28 Jan 2026 17:00:32 +0100",
        "Subject": "[PATCH v6 15/15] ipa: rkisp1: Implement\n\tLensShadingCorrectionEnable control",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "8bit",
        "Message-Id": "<20260128-sklug-lsc-resampling-v2-dev-v6-15-af7d95f03d22@ideasonboard.com>",
        "References": "<20260128-sklug-lsc-resampling-v2-dev-v6-0-af7d95f03d22@ideasonboard.com>",
        "In-Reply-To": "<20260128-sklug-lsc-resampling-v2-dev-v6-0-af7d95f03d22@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>, =?utf-8?q?Barnab=C3=A1s_P?=\n\t=?utf-8?b?xZFjemU=?= <barnabas.pocze@ideasonboard.com>, Kieran Bingham\n\t<kieran.bingham@ideasonboard.com>, Laurent Pinchart\n\t<laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "b4 0.14.2",
        "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": "Implement the LensShadingCorrectionEnable control for rkisp1.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nTested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\n\nChanges in v6:\n- Wrapped a long line\n- Collected tag\n\nChanges in v5:\n- Split patch 14 into two again, to have a separate patch for\n  control_ids_core.yaml\n\nChanges in v4:\n- Squahed patch 14 (addition od the LSC control) and 15 (implementation)\n  into one.\n- Collected tag\n\nChanges in v3:\n- Include LensShadingCorrectionEnable in metadata\n- Add the queueRequest function in the header in logical order instead\n  of alphabetical order\n\nChanges in v2:\n- Add the control only if LSC is properly configured in the tuning file\n- Introduce enable flag in frame context for per frame control\n---\n src/ipa/rkisp1/algorithms/dpf.cpp |  2 +-\n src/ipa/rkisp1/algorithms/lsc.cpp | 68 +++++++++++++++++++++++++++++++++------\n src/ipa/rkisp1/algorithms/lsc.h   |  7 ++++\n src/ipa/rkisp1/ipa_context.h      | 13 +++++---\n 4 files changed, 75 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp\nindex 39f3e461f313dfbf35cb5d6a0daca0540bdf7b6b..83c1e4b7b355041295cbe0498a8dd70877ea6636 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.cpp\n+++ b/src/ipa/rkisp1/algorithms/dpf.cpp\n@@ -233,7 +233,7 @@ void Dpf::prepare(IPAContext &context, const uint32_t frame,\n \t\t*strengthConfig = strengthConfig_;\n \n \t\tconst auto &awb = context.configuration.awb;\n-\t\tconst auto &lsc = context.configuration.lsc;\n+\t\tconst auto &lsc = context.activeState.lsc;\n \n \t\tauto &mode = config->gain.mode;\n \ndiff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\nindex c7a40a64bc94b6a5b846e266261e0c102f4010f5..c6982e6b4b10a321744e0101cdc0e07e23fb0185 100644\n--- a/src/ipa/rkisp1/algorithms/lsc.cpp\n+++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n@@ -416,6 +416,9 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,\n \tif (ret)\n \t\treturn ret;\n \n+\tcontext.ctrlMap[&controls::LensShadingCorrectionEnable] =\n+\t\tControlInfo(false, true, true);\n+\n \tshadingDescriptors_ = std::move(lscData);\n \n \treturn 0;\n@@ -460,7 +463,7 @@ int LensShadingCorrection::configure(IPAContext &context,\n \n \tsets_.setData(std::move(shadingData));\n \n-\tcontext.configuration.lsc.enabled = true;\n+\tcontext.activeState.lsc.enabled = true;\n \treturn 0;\n }\n \n@@ -481,6 +484,29 @@ void LensShadingCorrection::copyTable(rkisp1_cif_isp_lsc_config &config,\n \tstd::copy(set.b.begin(), set.b.end(), &config.b_data_tbl[0][0]);\n }\n \n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::queueRequest\n+ */\n+void LensShadingCorrection::queueRequest(IPAContext &context,\n+\t\t\t\t\t [[maybe_unused]] const uint32_t frame,\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+}\n+\n /**\n  * \\copydoc libcamera::ipa::Algorithm::prepare\n  */\n@@ -492,18 +518,28 @@ void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,\n \tuint32_t ct = frameContext.awb.temperatureK;\n \tunsigned int quantizedCt = quantize(ct, kColourTemperatureQuantization);\n \n-\t/*\n-\t * Add a threshold so that oscillations around a quantization step don't\n-\t * lead to constant changes.\n-\t */\n-\tif (utils::abs_diff(ct, lastAppliedCt_) < kColourTemperatureQuantization / 2)\n-\t\treturn;\n+\t/* Check if we can skip the update. */\n+\tif (!frameContext.lsc.update) {\n+\t\tif (!frameContext.lsc.enabled)\n+\t\t\treturn;\n \n-\tif (quantizedCt == lastAppliedQuantizedCt_)\n-\t\treturn;\n+\t\t/*\n+\t\t * Add a threshold so that oscillations around a quantization\n+\t\t * step don't lead to constant changes.\n+\t\t */\n+\t\tif (utils::abs_diff(ct, lastAppliedCt_) < kColourTemperatureQuantization / 2)\n+\t\t\treturn;\n+\n+\t\tif (quantizedCt == lastAppliedQuantizedCt_)\n+\t\t\treturn;\n+\t}\n \n \tauto config = params->block<BlockType::Lsc>();\n-\tconfig.setEnabled(true);\n+\tconfig.setEnabled(frameContext.lsc.enabled);\n+\n+\tif (!frameContext.lsc.enabled)\n+\t\treturn;\n+\n \tsetParameters(*config);\n \n \tconst Components &set = sets_.getInterpolated(quantizedCt);\n@@ -517,6 +553,18 @@ void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,\n \t\t<< quantizedCt;\n }\n \n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::process\n+ */\n+void LensShadingCorrection::process([[maybe_unused]] IPAContext &context,\n+\t\t\t\t    [[maybe_unused]] const uint32_t frame,\n+\t\t\t\t    IPAFrameContext &frameContext,\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+}\n+\n REGISTER_IPA_ALGORITHM(LensShadingCorrection, \"LensShadingCorrection\")\n \n } /* namespace ipa::rkisp1::algorithms */\ndiff --git a/src/ipa/rkisp1/algorithms/lsc.h b/src/ipa/rkisp1/algorithms/lsc.h\nindex 3097740a6cb2ce9063a4ba087856987a489b0ab6..fb9dcc1a52af4a88a52808346b5da99e3f2b1c87 100644\n--- a/src/ipa/rkisp1/algorithms/lsc.h\n+++ b/src/ipa/rkisp1/algorithms/lsc.h\n@@ -26,9 +26,16 @@ public:\n \n \tint init(IPAContext &context, const YamlObject &tuningData) override;\n \tint configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;\n+\tvoid queueRequest(IPAContext &context, const uint32_t frame,\n+\t\t\t  IPAFrameContext &frameContext,\n+\t\t\t  const ControlList &controls) override;\n \tvoid prepare(IPAContext &context, const uint32_t frame,\n \t\t     IPAFrameContext &frameContext,\n \t\t     RkISP1Params *params) override;\n+\tvoid process(IPAContext &context, const uint32_t frame,\n+\t\t     IPAFrameContext &frameContext,\n+\t\t     const rkisp1_stat_buffer *stats,\n+\t\t     ControlList &metadata) override;\n \n \tstruct Components {\n \t\tstd::vector<uint16_t> r;\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex b257cee55379ad932b42e613f94eccbe69a939e3..fa748811be743b43ce6ee289408c054c6f9a7046 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -55,10 +55,6 @@ struct IPASessionConfiguration {\n \t\tbool supported;\n \t} compress;\n \n-\tstruct {\n-\t\tbool enabled;\n-\t} lsc;\n-\n \tstruct {\n \t\tutils::Duration minExposureTime;\n \t\tutils::Duration maxExposureTime;\n@@ -143,6 +139,10 @@ struct IPAActiveState {\n \t\tdouble gain;\n \t\tdouble strength;\n \t} wdr;\n+\n+\tstruct {\n+\t\tbool enabled;\n+\t} lsc;\n };\n \n struct IPAFrameContext : public FrameContext {\n@@ -218,6 +218,11 @@ struct IPAFrameContext : public FrameContext {\n \t\tdouble strength;\n \t\tdouble gain;\n \t} wdr;\n+\n+\tstruct {\n+\t\tbool enabled;\n+\t\tbool update;\n+\t} lsc;\n };\n \n struct IPAContext {\n",
    "prefixes": [
        "v6",
        "15/15"
    ]
}