Show a patch.

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

{
    "id": 25176,
    "url": "https://patchwork.libcamera.org/api/patches/25176/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/25176/",
    "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": "<20251125000848.4103786-10-rui.wang@ideasonboard.com>",
    "date": "2025-11-25T00:08:46",
    "name": "[v1,09/11] ipa: rkisp1: algorithms: dpf: refactor DPF prepare flow",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "7f67851836465daa7c4627b9777e0c26fe85ab2c",
    "submitter": {
        "id": 241,
        "url": "https://patchwork.libcamera.org/api/people/241/?format=api",
        "name": "Rui Wang",
        "email": "rui.wang@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/25176/mbox/",
    "series": [
        {
            "id": 5612,
            "url": "https://patchwork.libcamera.org/api/series/5612/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5612",
            "date": "2025-11-25T00:08:37",
            "name": "ipa: rkisp1: DPF refactor and tuning improvements",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5612/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/25176/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/25176/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 65AECC32EF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Nov 2025 00:09:22 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EC21F60AB4;\n\tTue, 25 Nov 2025 01:09:21 +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 55BD960AAF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Nov 2025 01:09:18 +0100 (CET)",
            "from rui-Precision-7560.local (unknown\n\t[IPv6:2607:fea8:935b:7220:cb34:a7b8:53d:5466])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6B9DD17EB;\n\tTue, 25 Nov 2025 01:07:09 +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=\"WNndxMjw\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764029229;\n\tbh=p9snf8mTJT/16VHTZjuDYk8EWD3+ktBVRGJUPKtlsHE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=WNndxMjwHRe+fMWKlTHY6kcXp9UUw/GjtqPqfCce8VDEj4fh2dPtKVIBGmCVu8s5X\n\tmkmguEscVGVF+ingIKZK391TBds7OV/6tAN6cOdb2QBVYeDxJZAT/jX0rkIqDZU9eG\n\t4jNNhcKMd9z6vBefp6bHv1oYYjgcT+2olqhoznW8=",
        "From": "Rui Wang <rui.wang@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Rui Wang <rui.wang@ideasonboard.com>",
        "Subject": "[PATCH v1 09/11] ipa: rkisp1: algorithms: dpf: refactor DPF prepare\n\tflow",
        "Date": "Mon, 24 Nov 2025 19:08:46 -0500",
        "Message-ID": "<20251125000848.4103786-10-rui.wang@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20251125000848.4103786-1-rui.wang@ideasonboard.com>",
        "References": "<20251125000848.4103786-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": "Split prepare() into explicit auto and manual mode branches. The auto\npath selects exposure index bands\nwhile the manual path applies user overrides before programming hardware.\n\nKey changes:\n- prepare() now branches to prepareAutoMode or prepareManualMode\n- Added debug logging to queueRequest()\n\nSigned-off-by: Rui Wang <rui.wang@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/denoise.h |  12 +++\n src/ipa/rkisp1/algorithms/dpf.cpp   | 127 +++++++++++++++++++++-------\n src/ipa/rkisp1/algorithms/dpf.h     |   5 ++\n 3 files changed, 113 insertions(+), 31 deletions(-)",
    "diff": "diff --git a/src/ipa/rkisp1/algorithms/denoise.h b/src/ipa/rkisp1/algorithms/denoise.h\nindex 4c917c1a..f07c14fe 100644\n--- a/src/ipa/rkisp1/algorithms/denoise.h\n+++ b/src/ipa/rkisp1/algorithms/denoise.h\n@@ -58,6 +58,18 @@ protected:\n \t}\n \tvirtual int32_t getRunningMode() const { return currentRunMode_; }\n \tvirtual void setRunningMode(int32_t mode) { currentRunMode_ = mode; }\n+\tvirtual void prepareDisabledMode([[maybe_unused]] IPAContext &context,\n+\t\t\t\t\t [[maybe_unused]] const uint32_t frame,\n+\t\t\t\t\t [[maybe_unused]] IPAFrameContext &frameContext,\n+\t\t\t\t\t [[maybe_unused]] RkISP1Params *params)\n+\t{\n+\t}\n+\tvirtual void prepareEnabledMode([[maybe_unused]] IPAContext &context,\n+\t\t\t\t\t[[maybe_unused]] const uint32_t frame,\n+\t\t\t\t\t[[maybe_unused]] IPAFrameContext &frameContext,\n+\t\t\t\t\t[[maybe_unused]] RkISP1Params *params)\n+\t{\n+\t}\n private:\n \t/**< Developer mode state for advanced controls */\n \tbool devMode_ = false;\ndiff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp\nindex c88f5c69..e3293241 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.cpp\n+++ b/src/ipa/rkisp1/algorithms/dpf.cpp\n@@ -748,41 +748,106 @@ void Dpf::prepare(IPAContext &context, const uint32_t frame,\n {\n \tif (!frameContext.dpf.update && frame > 0)\n \t\treturn;\n+\t/* Check if denoise toggle off */\n+\tif (!frameContext.dpf.denoise) {\n+\t\tauto cfg = params->block<BlockType::Dpf>();\n+\t\tcfg.setEnabled(false);\n+\t\tauto str = params->block<BlockType::DpfStrength>();\n+\t\tstr.setEnabled(false);\n+\t\tsetRunningMode(controls::rkisp1::DenoiseModeDisabled);\n+\t\treturn;\n+\t}\n \n-\tauto config = params->block<BlockType::Dpf>();\n-\tconfig.setEnabled(frameContext.dpf.denoise);\n-\n-\tauto strengthConfig = params->block<BlockType::DpfStrength>();\n-\tstrengthConfig.setEnabled(frameContext.dpf.denoise);\n-\n-\tif (frameContext.dpf.denoise) {\n-\t\t*config = config_;\n-\t\t*strengthConfig = strengthConfig_;\n-\n-\t\tconst auto &awb = context.configuration.awb;\n-\t\tconst auto &lsc = context.configuration.lsc;\n-\n-\t\tauto &mode = config->gain.mode;\n-\n-\t\t/*\n-\t\t * The DPF needs to take into account the total amount of\n-\t\t * digital gain, which comes from the AWB and LSC modules. The\n-\t\t * DPF hardware can be programmed with a digital gain value\n-\t\t * manually, but can also use the gains supplied by the AWB and\n-\t\t * LSC modules automatically when they are enabled. Use that\n-\t\t * mode of operation as it simplifies control of the DPF.\n-\t\t */\n-\t\tif (awb.enabled && lsc.enabled)\n-\t\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS;\n-\t\telse if (awb.enabled)\n-\t\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS;\n-\t\telse if (lsc.enabled)\n-\t\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS;\n-\t\telse\n-\t\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED;\n+\tswitch (getRunningMode()) {\n+\tcase controls::rkisp1::DenoiseModeDisabled:\n+\t\tprepareDisabledMode(context, frame, frameContext, params);\n+\t\tbreak;\n+\tcase controls::rkisp1::DenoiseModeAuto:\n+\tcase controls::rkisp1::DenoiseModeManual:\n+\tcase controls::rkisp1::DenoiseModeReduction:\n+\t\tprepareEnabledMode(context, frame, frameContext, params);\n+\t\tbreak;\n+\tdefault:\n+\t\tLOG(RkISP1Dpf, Warning) << \"DPF in unknown mode\";\n+\t\tbreak;\n \t}\n }\n \n+void Dpf::prepareEnabledMode(IPAContext &context, const uint32_t frame,\n+\t\t\t     IPAFrameContext &frameContext, RkISP1Params *params)\n+{\n+\tuint32_t exposureGainIndex = computeExposureIndex(context, frameContext);\n+\n+\tif (!frameContext.dpf.update && frame > 0)\n+\t\treturn;\n+\n+\t/* Select different DPF config determined by exposure index level for Auto mode */\n+\tif (getRunningMode() == controls::rkisp1::DenoiseModeAuto && useExposureIndexLevels_) {\n+\t\tint32_t idx =\n+\t\t\tDenoiseBaseAlgorithm::selectExposureIndexBand(\n+\t\t\t\texposureGainIndex, exposureIndexLevels_);\n+\t\tif (idx >= 0 && idx != lastExposureGainIndex_) {\n+\t\t\tconfig_ = exposureIndexLevels_[idx].dpf;\n+\t\t\tstrengthConfig_ = exposureIndexLevels_[idx].strength;\n+\t\t\tframeContext.dpf.update = true;\n+\t\t\tlastExposureGainIndex_ = idx;\n+\t\t}\n+\t}\n+\n+\tauto cfgBlock = params->block<BlockType::Dpf>();\n+\tcfgBlock.setEnabled(true);\n+\t*cfgBlock = config_;\n+\n+\t/*\n+\t * The DPF needs to take into account the total amount of\n+\t * digital gain, which comes from the AWB and LSC modules. The\n+\t * DPF hardware can be programmed with a digital gain value\n+\t * manually, but can also use the gains supplied by the AWB and\n+\t * LSC modules automatically when they are enabled. Use that\n+\t * mode of operation as it simplifies control of the DPF.\n+\t */\n+\tconst auto &awb = context.configuration.awb;\n+\tconst auto &lsc = context.configuration.lsc;\n+\tauto &mode = cfgBlock->gain.mode;\n+\n+\tif (awb.enabled && lsc.enabled)\n+\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS;\n+\telse if (awb.enabled)\n+\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS;\n+\telse if (lsc.enabled)\n+\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS;\n+\telse\n+\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED;\n+\n+\tconfig_.gain.mode = mode;\n+\n+\tauto strBlock = params->block<BlockType::DpfStrength>();\n+\tstrBlock.setEnabled(true);\n+\n+\t*strBlock = strengthConfig_;\n+\tbool anyOverride = false;\n+\tif (getRunningMode() == controls::rkisp1::DenoiseModeManual)\n+\t\tapplyOverridesTo(*cfgBlock, *strBlock, anyOverride);\n+\n+\tint32_t exposureGainIdx = lastExposureGainIndex_;\n+\tif (getRunningMode() == controls::rkisp1::DenoiseModeReduction)\n+\t\texposureGainIdx = -1;\n+\n+\tlogConfigIfChanged(exposureGainIndex, exposureGainIdx, anyOverride, frameContext);\n+}\n+\n+void Dpf::prepareDisabledMode([[maybe_unused]] IPAContext &context,\n+\t\t\t      [[maybe_unused]] const uint32_t frame,\n+\t\t\t      [[maybe_unused]] IPAFrameContext &frameContext,\n+\t\t\t      RkISP1Params *params)\n+{\n+\tframeContext.dpf.denoise = false;\n+\tauto cfg = params->block<BlockType::Dpf>();\n+\tcfg.setEnabled(false);\n+\tauto str = params->block<BlockType::DpfStrength>();\n+\tstr.setEnabled(false);\n+}\n+\n REGISTER_IPA_ALGORITHM(Dpf, \"Dpf\")\n \n } /* namespace ipa::rkisp1::algorithms */\ndiff --git a/src/ipa/rkisp1/algorithms/dpf.h b/src/ipa/rkisp1/algorithms/dpf.h\nindex abcdf8ee..86085cf9 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.h\n+++ b/src/ipa/rkisp1/algorithms/dpf.h\n@@ -97,6 +97,11 @@ private:\n \t\t\t\tint32_t exposureBandIndex,\n \t\t\t\tbool anyOverride,\n \t\t\t\tconst IPAFrameContext &frameContext);\n+\tvoid prepareDisabledMode(IPAContext &context, const uint32_t frame,\n+\t\t\t\t IPAFrameContext &frameContext,\n+\t\t\t\t RkISP1Params *params) override;\n+\tvoid prepareEnabledMode(IPAContext &context, const uint32_t frame,\n+\t\t\t\tIPAFrameContext &frameContext, RkISP1Params *params) override;\n };\n \n } /* namespace ipa::rkisp1::algorithms */\n",
    "prefixes": [
        "v1",
        "09/11"
    ]
}