Show a patch.

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

{
    "id": 24865,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/24865/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/24865/",
    "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": "<20251028170847.2673396-13-rui.wang@ideasonboard.com>",
    "date": "2025-10-28T17:08:42",
    "name": "[v1,13/16] ipa: rkisp1: algorithms: dpf: apply DPF overrides",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "08bcdc2833499046154e385c20d58514d59ef22d",
    "submitter": {
        "id": 241,
        "url": "https://patchwork.libcamera.org/api/1.1/people/241/?format=api",
        "name": "Rui Wang",
        "email": "rui.wang@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/24865/mbox/",
    "series": [
        {
            "id": 5539,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5539/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5539",
            "date": "2025-10-28T17:08:30",
            "name": "[v1,01/16] ipa: rkisp1: algorithms: add Denoise base class shell",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5539/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/24865/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/24865/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 04F51BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Oct 2025 17:09:28 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 82FA16086D;\n\tTue, 28 Oct 2025 18:09:27 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DCF1B60831\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Oct 2025 18:09:20 +0100 (CET)",
            "from rui-Precision-7560.local (unknown [209.216.122.90])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 074981AED;\n\tTue, 28 Oct 2025 18:07: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=\"STAh135q\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761671252;\n\tbh=UayJ33sCZKLJm8XhFu0HRt1O7AxezNxr4NJvV45GOW8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=STAh135q+Ws+ZNNbP/DigkBHg7jZugz13qIROKJR51FvpBKUFR4BwoL/XwJSglAs0\n\tX3L3YYKl7xmCJH1EWdb4PHxOXGXx+6ypT+KlcZp+oHUxTT4oeni1SBVTf6+lL7zJcL\n\tUQ/tKxb1nDc/2GY9RIGbpyAL1YcPyfYaJ03fLauc=",
        "From": "Rui Wang <rui.wang@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Rui Wang <rui.wang@ideasonboard.com>",
        "Subject": "[PATCH v1 13/16] ipa: rkisp1: algorithms: dpf: apply DPF overrides",
        "Date": "Tue, 28 Oct 2025 13:08:42 -0400",
        "Message-ID": "<20251028170847.2673396-13-rui.wang@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20251028170847.2673396-1-rui.wang@ideasonboard.com>",
        "References": "<20251028170847.2673396-1-rui.wang@ideasonboard.com>",
        "MIME-Version": "1.0",
        "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>"
    },
    "content": "Implement applyOverridesTo() to merge manual overrides into hardware state\nand add logConfigIfChanged() to make configuration updates visible in logs\nfor debugging.\n\napplyOverridesTo() applies all collected manual overrides to the DPF\nconfiguration in manual mode:\n- Channel strengths (R/G/B)\n- Spatial coefficients (green and RB)\n- RB filter size\n- NLL coefficients and scale mode\n\nlogConfigIfChanged() provides detailed logging of configuration changes,\nincluding all coefficients, strength values, ISO band selection, and\ncontrol mode. Uses static state tracking to log only when changes occur.\n\nAdded <sstream> include for ostringstream usage in logging.\n\nSigned-off-by: Rui Wang <rui.wang@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/dpf.cpp | 104 ++++++++++++++++++++++++++++++\n src/ipa/rkisp1/algorithms/dpf.h   |   4 ++\n 2 files changed, 108 insertions(+)",
    "diff": "diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp\nindex f6bbe3e4..75e083eb 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.cpp\n+++ b/src/ipa/rkisp1/algorithms/dpf.cpp\n@@ -9,6 +9,7 @@\n \n #include <algorithm>\n #include <array>\n+#include <sstream>\n #include <string>\n #include <vector>\n \n@@ -403,6 +404,109 @@ bool Dpf::processModeChange(const ControlList &controls, uint32_t currentFrame)\n \treturn true;\n }\n \n+void Dpf::applyOverridesTo(rkisp1_cif_isp_dpf_config &cfg,\n+\t\t\t   rkisp1_cif_isp_dpf_strength_config &str,\n+\t\t\t   bool &anyOverride)\n+{\n+\tif (!isManualMode())\n+\t\treturn; /* only apply overrides in manual mode */\n+\n+\tif (overrides_.strength) {\n+\t\tstr.r = overrides_.strength->r;\n+\t\tstr.g = overrides_.strength->g;\n+\t\tstr.b = overrides_.strength->b;\n+\t\tanyOverride = true;\n+\t}\n+\tif (overrides_.spatialGreen) {\n+\t\tfor (unsigned i = 0; i < RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS; ++i) {\n+\t\t\tcfg.g_flt.spatial_coeff[i] = overrides_.spatialGreen->coeffs[i];\n+\t\t}\n+\t\tanyOverride = true;\n+\t}\n+\tif (overrides_.spatialRb) {\n+\t\tfor (unsigned i = 0; i < RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS; ++i) {\n+\t\t\tcfg.rb_flt.spatial_coeff[i] = overrides_.spatialRb->coeffs[i];\n+\t\t}\n+\t\tanyOverride = true;\n+\t}\n+\tif (overrides_.rbSize) {\n+\t\tcfg.rb_flt.fltsize = *overrides_.rbSize ? RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9\n+\t\t\t\t\t\t\t: RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9;\n+\t\tanyOverride = true;\n+\t}\n+\tif (overrides_.nll) {\n+\t\tfor (unsigned i = 0; i < RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS; ++i) {\n+\t\t\tcfg.nll.coeff[i] = overrides_.nll->coeffs[i];\n+\t\t}\n+\t\tcfg.nll.scale_mode = overrides_.nll->scaleMode ? RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC\n+\t\t\t\t\t\t\t       : RKISP1_CIF_ISP_NLL_SCALE_LINEAR;\n+\t\tanyOverride = true;\n+\t}\n+\tif (anyOverride) {\n+\t\tconfig_ = cfg;\n+\t\tstrengthConfig_ = str;\n+\t\tLOG(RkISP1Dpf, Info)\n+\t\t\t<< \"DPF manual overrides applied: strength=\"\n+\t\t\t<< (int)strengthConfig_.r << \",\" << (int)strengthConfig_.g << \",\" << (int)strengthConfig_.b\n+\t\t\t<< (overrides_.spatialGreen ? \" gKernel\" : \"\")\n+\t\t\t<< (overrides_.spatialRb ? \" rbKernel\" : \"\")\n+\t\t\t<< (overrides_.rbSize ? \" rbSize\" : \"\")\n+\t\t\t<< (overrides_.nll ? \" nll\" : \"\");\n+\t}\n+}\n+\n+void Dpf::logConfigIfChanged(unsigned iso, int isoIndex, bool anyOverride, const IPAFrameContext &frameContext)\n+{\n+\tstatic rkisp1_cif_isp_dpf_config lastCfg{};\n+\tstatic rkisp1_cif_isp_dpf_strength_config lastStr{};\n+\tstatic bool haveLast = false;\n+\tbool cfgChanged = !haveLast || memcmp(&lastCfg, &config_, sizeof(config_)) != 0;\n+\tbool strChanged = !haveLast || memcmp(&lastStr, &strengthConfig_, sizeof(strengthConfig_)) != 0;\n+\tif (!(cfgChanged || strChanged))\n+\t\treturn;\n+\tstd::ostringstream gs, rbs, nll;\n+\tgs << '[';\n+\trbs << '[';\n+\tnll << '[';\n+\tfor (unsigned i = 0; i < RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS; ++i) {\n+\t\tif (i) {\n+\t\t\tgs << ',';\n+\t\t\trbs << ',';\n+\t\t}\n+\t\tgs << (int)config_.g_flt.spatial_coeff[i];\n+\t\trbs << (int)config_.rb_flt.spatial_coeff[i];\n+\t}\n+\tfor (unsigned i = 0; i < RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS; ++i) {\n+\t\tif (i)\n+\t\t\tnll << ',';\n+\t\tnll << config_.nll.coeff[i];\n+\t}\n+\tgs << ']';\n+\trbs << ']';\n+\tnll << ']';\n+\tconst char *modeStr =\n+\t\tconfig_.gain.mode == RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS ? \"AWB+LSC\" : config_.gain.mode == RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS ? \"AWB\"\n+\t\t\t\t\t\t\t\t\t\t       : config_.gain.mode == RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS\t    ? \"LSC\"\n+\t\t\t\t\t\t\t\t\t\t       : config_.gain.mode == RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS\t    ? \"NF\"\n+\t\t\t\t\t\t\t\t\t\t       : config_.gain.mode == RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS    ? \"NF+LSC\"\n+\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t    : \"disabled\";\n+\tLOG(RkISP1Dpf, Info) << \"DPF config update: rb_fltsize=\"\n+\t\t\t     << (config_.rb_flt.fltsize == RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9 ? \"13x9\" : \"9x9\")\n+\t\t\t     << \", nll_scale=\"\n+\t\t\t     << (config_.nll.scale_mode == RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC ? \"log\" : \"linear\")\n+\t\t\t     << \", gain_mode=\" << modeStr\n+\t\t\t     << \", strength=\" << (int)strengthConfig_.r << \",\" << (int)strengthConfig_.g << \",\" << (int)strengthConfig_.b\n+\t\t\t     << \", g=\" << gs.str() << \", rb=\" << rbs.str() << \", nll=\" << nll.str()\n+\t\t\t     << \", iso=\" << iso\n+\t\t\t     << (useIsoLevels_ && isoIndex >= 0 ? (\", iso_band=\" + std::to_string(isoIndex) + (lastIsoIndex_ == isoIndex ? \"\" : \"(new)\")) : \"\")\n+\t\t\t     << \", control mode=\" << (isManualMode() ? \"manual\" : \"auto\")\n+\t\t\t     << \", denoise=\" << (frameContext.dpf.denoise ? \"enabled\" : \"disabled\")\n+\t\t\t     << (anyOverride ? \" (overrides applied)\" : \"\");\n+\tlastCfg = config_;\n+\tlastStr = strengthConfig_;\n+\thaveLast = true;\n+}\n+\n /**\n  * \\copydoc libcamera::ipa::Algorithm::queueRequest\n  */\ndiff --git a/src/ipa/rkisp1/algorithms/dpf.h b/src/ipa/rkisp1/algorithms/dpf.h\nindex b6676203..8c34abcf 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.h\n+++ b/src/ipa/rkisp1/algorithms/dpf.h\n@@ -101,6 +101,10 @@ private:\n \tvoid snapshotCurrentToOverrides() override;\n \n \tvoid restoreAutoConfig(IPAContext &context, IPAFrameContext &frameContext) override;\n+\n+\tvoid applyOverridesTo(rkisp1_cif_isp_dpf_config &cfg, rkisp1_cif_isp_dpf_strength_config &str, bool &anyOverride);\n+\n+\tvoid logConfigIfChanged(unsigned iso, int isoIndex, bool anyOverride, const IPAFrameContext &frameContext);\n };\n \n } /* namespace ipa::rkisp1::algorithms */\n",
    "prefixes": [
        "v1",
        "13/16"
    ]
}