Show a patch.

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

{
    "id": 25365,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/25365/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/25365/",
    "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": "<20251204202500.1075575-2-rui.wang@ideasonboard.com>",
    "date": "2025-12-04T20:24:59",
    "name": "[v2,1/2] ipa/rkisp1: refactory DPF parsing and initialization",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "4664cd58227dab39006a053915ce0d7d855e71cd",
    "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/25365/mbox/",
    "series": [
        {
            "id": 5638,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5638/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5638",
            "date": "2025-12-04T20:24:58",
            "name": "rebase_dpf_refactory_patch_v2",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5638/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/25365/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/25365/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 BB122BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Dec 2025 20:25:27 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6D50461145;\n\tThu,  4 Dec 2025 21:25:27 +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 8A4E461136\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Dec 2025 21:25:25 +0100 (CET)",
            "from localhost.localdomain (unknown [209.216.103.65])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7AECFEB7;\n\tThu,  4 Dec 2025 21:23: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=\"Gi+T8hKe\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764879790;\n\tbh=1ehvjQdVxodgJZnewrT50IJCpgntDXllaau3hYSJ3+Y=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Gi+T8hKeE5wydwJHqLe7bVuUYOIfw4Qr0ckx/4xKL4G8Iq3lQ20yEBXsZojl1El9K\n\t8LgFtT003CRa69uODNFYh+4cA/k1PwEwUnvBH5VmSnJVuJqbliKetYALkZh8g0K+iM\n\t7jycEQ6nzPER7iQeKSTJqrQaH6r9eFjkFlibUaJ8=",
        "From": "Rui Wang <rui.wang@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Rui Wang <rui.wang@ideasonboard.com>",
        "Subject": "[PATCH v2 1/2] ipa/rkisp1: refactory DPF parsing and initialization",
        "Date": "Thu,  4 Dec 2025 15:24:59 -0500",
        "Message-ID": "<20251204202500.1075575-2-rui.wang@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20251204202500.1075575-1-rui.wang@ideasonboard.com>",
        "References": "<20251204202500.1075575-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 DPF configuration parsing and initialization into clearer,\nself-contained helpers and modernized initialization patterns.\n\nAdd parseConfig, parseModes and loadReductionConfig to factor\nparsing logic and mode lookups.\nIntroduce ModeConfig and store mode entries in\nnoiseReductionModes_ to decouple parsing from runtime selection.\nMove sentinel member initializers into the constructor initializer\nlist (runningMode_) and declare vectors\nwithout in-class initializers for default construction.\nReplace ad-hoc string handling with value_or and const auto\nwhere appropriate for clearer and safer parsing.\nReplace domain/range/strength YAML keys mapping and error returns\n(use filter, nll, strength keys and return false from parse\nhelpers instead of -EINVAL).\nAdd loadReductionConfig to centralize loading of DPF configs for\nreduction modes and preserve logging and failure behavior.\nAdjust queueRequest, prepare, and helpers to use the new\nparsing/initialization flow while preserving existing behavior.\nThis refactor improves separation of concerns, makes parsing easier\nto maintain, and reduces duplicated logic. No functional behaviour is\nintended to be changed.\n\nSigned-off-by: Rui Wang <rui.wang@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/dpf.cpp | 290 ++++++++++++++++++++++--------\n src/ipa/rkisp1/algorithms/dpf.h   |  19 ++\n 2 files changed, 233 insertions(+), 76 deletions(-)",
    "diff": "diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp\nindex 39f3e461..cf1f9199 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.cpp\n+++ b/src/ipa/rkisp1/algorithms/dpf.cpp\n@@ -37,7 +37,8 @@ namespace ipa::rkisp1::algorithms {\n LOG_DEFINE_CATEGORY(RkISP1Dpf)\n \n Dpf::Dpf()\n-\t: config_({}), strengthConfig_({})\n+\t: config_({}), strengthConfig_({}),\n+\t  runningMode_(controls::draft::NoiseReductionModeOff)\n {\n }\n \n@@ -46,6 +47,69 @@ Dpf::Dpf()\n  */\n int Dpf::init([[maybe_unused]] IPAContext &context,\n \t      const YamlObject &tuningData)\n+{\n+\t/* Parse tuning block. */\n+\tif (!parseConfig(tuningData)) {\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+bool Dpf::parseConfig(const YamlObject &tuningData)\n+{\n+\t/* Parse base config. */\n+\tif (!parseSingleConfig(tuningData, config_, strengthConfig_)) {\n+\t\treturn false;\n+\t}\n+\tif (!parseModes(tuningData)) {\n+\t\treturn false;\n+\t}\n+\treturn true;\n+}\n+\n+bool Dpf::parseModes(const YamlObject &tuningData)\n+{\n+\t/* Parse noise reduction modes. */\n+\tif (!tuningData.contains(\"modes\")) {\n+\t\treturn true;\n+\t}\n+\n+\tnoiseReductionModes_.clear();\n+\tfor (const auto &entry : tuningData[\"modes\"].asList()) {\n+\t\tstd::optional<std::string> typeOpt =\n+\t\t\tentry[\"type\"].get<std::string>();\n+\t\tif (!typeOpt) {\n+\t\t\tLOG(RkISP1Dpf, Error) << \"Modes entry missing type\";\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tint32_t modeValue = controls::draft::NoiseReductionModeOff;\n+\t\tif (*typeOpt == \"minimal\") {\n+\t\t\tmodeValue = controls::draft::NoiseReductionModeMinimal;\n+\t\t} else if (*typeOpt == \"fast\") {\n+\t\t\tmodeValue = controls::draft::NoiseReductionModeFast;\n+\t\t} else if (*typeOpt == \"highquality\") {\n+\t\t\tmodeValue = controls::draft::NoiseReductionModeHighQuality;\n+\t\t} else if (*typeOpt == \"zsl\") {\n+\t\t\tmodeValue = controls::draft::NoiseReductionModeZSL;\n+\t\t} else {\n+\t\t\tLOG(RkISP1Dpf, Error) << \"Unknown mode type: \" << *typeOpt;\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tModeConfig mode{};\n+\t\tmode.modeValue = modeValue;\n+\t\tif (!parseSingleConfig(entry, mode.dpf, mode.strength)) {\n+\t\t\treturn false;\n+\t\t}\n+\t\tnoiseReductionModes_.push_back(mode);\n+\t}\n+\n+\treturn true;\n+}\n+bool Dpf::parseSingleConfig(const YamlObject &tuningData,\n+\t\t\t    rkisp1_cif_isp_dpf_config &config,\n+\t\t\t    rkisp1_cif_isp_dpf_strength_config &strengthConfig)\n {\n \tstd::vector<uint8_t> values;\n \n@@ -53,7 +117,11 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\n \t * The domain kernel is configured with a 9x9 kernel for the green\n \t * pixels, and a 13x9 or 9x9 kernel for red and blue pixels.\n \t */\n-\tconst YamlObject &dFObject = tuningData[\"DomainFilter\"];\n+\tconst YamlObject &dFObject = tuningData[\"filter\"];\n+\tif (!dFObject) {\n+\t\tLOG(RkISP1Dpf, Error) << \"filter section missing\";\n+\t\treturn false;\n+\t}\n \n \t/*\n \t * For the green component, we have the 9x9 kernel specified\n@@ -75,10 +143,10 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\n \tvalues = dFObject[\"g\"].getList<uint8_t>().value_or(std::vector<uint8_t>{});\n \tif (values.size() != RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS) {\n \t\tLOG(RkISP1Dpf, Error)\n-\t\t\t<< \"Invalid 'DomainFilter:g': expected \"\n+\t\t\t<< \"Invalid 'filter:g': expected \"\n \t\t\t<< RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS\n \t\t\t<< \" elements, got \" << values.size();\n-\t\treturn -EINVAL;\n+\t\treturn false;\n \t}\n \n \tstd::copy_n(values.begin(), values.size(),\n@@ -112,16 +180,16 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\n \tif (values.size() != RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS &&\n \t    values.size() != RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS - 1) {\n \t\tLOG(RkISP1Dpf, Error)\n-\t\t\t<< \"Invalid 'DomainFilter:rb': expected \"\n+\t\t\t<< \"Invalid 'filter:rb': expected \"\n \t\t\t<< RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS - 1\n \t\t\t<< \" or \" << RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS\n \t\t\t<< \" elements, got \" << values.size();\n-\t\treturn -EINVAL;\n+\t\treturn false;\n \t}\n \n \tconfig_.rb_flt.fltsize = values.size() == RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS\n-\t\t\t       ? RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9\n-\t\t\t       : RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9;\n+\t\t\t\t\t ? RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9\n+\t\t\t\t\t : RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9;\n \n \tstd::copy_n(values.begin(), values.size(),\n \t\t    std::begin(config_.rb_flt.spatial_coeff));\n@@ -134,43 +202,86 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\n \t * which stores a piecewise linear function that characterizes the\n \t * sensor noise profile as a noise level function curve (NLF).\n \t */\n-\tconst YamlObject &rFObject = tuningData[\"NoiseLevelFunction\"];\n+\tconst YamlObject &rFObject = tuningData[\"nll\"];\n+\tif (!rFObject) {\n+\t\tLOG(RkISP1Dpf, Error) << \"nll section missing\";\n+\t\treturn false;\n+\t}\n \n-\tstd::vector<uint16_t> nllValues;\n-\tnllValues = rFObject[\"coeff\"].getList<uint16_t>().value_or(std::vector<uint16_t>{});\n+\tconst auto nllValues =\n+\t\trFObject[\"coeff\"].getList<uint16_t>().value_or(std::vector<uint16_t>{});\n \tif (nllValues.size() != RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS) {\n \t\tLOG(RkISP1Dpf, Error)\n-\t\t\t<< \"Invalid 'RangeFilter:coeff': expected \"\n+\t\t\t<< \"Invalid 'nll:coeff': expected \"\n \t\t\t<< RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS\n \t\t\t<< \" elements, got \" << nllValues.size();\n-\t\treturn -EINVAL;\n+\t\treturn false;\n \t}\n \n \tstd::copy_n(nllValues.begin(), nllValues.size(),\n \t\t    std::begin(config_.nll.coeff));\n \n-\tstd::string scaleMode = rFObject[\"scale-mode\"].get<std::string>(\"\");\n+\tconst auto scaleMode = rFObject[\"scale-mode\"].get<std::string>(\"\");\n \tif (scaleMode == \"linear\") {\n \t\tconfig_.nll.scale_mode = RKISP1_CIF_ISP_NLL_SCALE_LINEAR;\n \t} else if (scaleMode == \"logarithmic\") {\n \t\tconfig_.nll.scale_mode = RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC;\n \t} else {\n \t\tLOG(RkISP1Dpf, Error)\n-\t\t\t<< \"Invalid 'RangeFilter:scale-mode': expected \"\n+\t\t\t<< \"Invalid 'nll:scale-mode': expected \"\n \t\t\t<< \"'linear' or 'logarithmic' value, got \"\n \t\t\t<< scaleMode;\n-\t\treturn -EINVAL;\n+\t\treturn false;\n \t}\n \n-\tconst YamlObject &fSObject = tuningData[\"FilterStrength\"];\n+\tconst YamlObject &gObject = tuningData[\"gain\"];\n+\tif (!gObject) {\n+\t\tLOG(RkISP1Dpf, Error) << \"gain section missing\";\n+\t\treturn false;\n+\t}\n \n-\tstrengthConfig_.r = fSObject[\"r\"].get<uint16_t>(64);\n-\tstrengthConfig_.g = fSObject[\"g\"].get<uint16_t>(64);\n-\tstrengthConfig_.b = fSObject[\"b\"].get<uint16_t>(64);\n+\tconfig.gain.mode =\n+\t\tgObject[\"gain_mode\"].get<uint32_t>().value_or(\n+\t\t\tRKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS);\n+\tconfig.gain.nf_r_gain = gObject[\"r\"].get<uint16_t>().value_or(256);\n+\tconfig.gain.nf_b_gain = gObject[\"b\"].get<uint16_t>().value_or(256);\n+\tconfig.gain.nf_gr_gain = gObject[\"gr\"].get<uint16_t>().value_or(256);\n+\tconfig.gain.nf_gb_gain = gObject[\"gb\"].get<uint16_t>().value_or(256);\n+\n+\tconst YamlObject &fSObject = tuningData[\"strength\"];\n+\tif (!fSObject) {\n+\t\tLOG(RkISP1Dpf, Error) << \"strength section missing\";\n+\t\treturn false;\n+\t}\n \n-\treturn 0;\n+\tstrengthConfig.r = fSObject[\"r\"].get<uint8_t>().value_or(64);\n+\tstrengthConfig.g = fSObject[\"g\"].get<uint8_t>().value_or(64);\n+\tstrengthConfig.b = fSObject[\"b\"].get<uint8_t>().value_or(64);\n+\treturn true;\n }\n \n+bool Dpf::loadReductionConfig(int32_t mode)\n+{\n+\tauto it = std::find_if(noiseReductionModes_.begin(), noiseReductionModes_.end(),\n+\t\t\t       [mode](const ModeConfig &m) {\n+\t\t\t\t       return m.modeValue == mode;\n+\t\t\t       });\n+\tif (it == noiseReductionModes_.end()) {\n+\t\tLOG(RkISP1Dpf, Warning)\n+\t\t\t<< \"No DPF config for reduction mode \"\n+\t\t\t<< static_cast<int>(mode);\n+\t\treturn false;\n+\t}\n+\n+\tconfig_ = it->dpf;\n+\tstrengthConfig_ = it->strength;\n+\n+\tLOG(RkISP1Dpf, Info)\n+\t\t<< \"DPF mode=Reduction (config loaded)\"\n+\t\t<< \" mode=\" << static_cast<int>(mode);\n+\n+\treturn true;\n+}\n /**\n  * \\copydoc libcamera::ipa::Algorithm::queueRequest\n  */\n@@ -183,30 +294,34 @@ void Dpf::queueRequest(IPAContext &context,\n \tbool update = false;\n \n \tconst auto &denoise = controls.get(controls::draft::NoiseReductionMode);\n-\tif (denoise) {\n-\t\tLOG(RkISP1Dpf, Debug) << \"Set denoise to \" << *denoise;\n-\n-\t\tswitch (*denoise) {\n-\t\tcase controls::draft::NoiseReductionModeOff:\n-\t\t\tif (dpf.denoise) {\n-\t\t\t\tdpf.denoise = false;\n-\t\t\t\tupdate = true;\n-\t\t\t}\n-\t\t\tbreak;\n-\t\tcase controls::draft::NoiseReductionModeMinimal:\n-\t\tcase controls::draft::NoiseReductionModeHighQuality:\n-\t\tcase controls::draft::NoiseReductionModeFast:\n-\t\t\tif (!dpf.denoise) {\n-\t\t\t\tdpf.denoise = true;\n-\t\t\t\tupdate = true;\n-\t\t\t}\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\tLOG(RkISP1Dpf, Error)\n-\t\t\t\t<< \"Unsupported denoise value \"\n-\t\t\t\t<< *denoise;\n-\t\t\tbreak;\n+\tif (!denoise) {\n+\t\treturn;\n+\t}\n+\trunningMode_ = *denoise;\n+\tswitch (runningMode_) {\n+\tcase controls::draft::NoiseReductionModeOff:\n+\t\tif (dpf.denoise) {\n+\t\t\tdpf.denoise = false;\n+\t\t\tupdate = true;\n+\t\t}\n+\t\tbreak;\n+\tcase controls::draft::NoiseReductionModeMinimal:\n+\tcase controls::draft::NoiseReductionModeHighQuality:\n+\tcase controls::draft::NoiseReductionModeFast:\n+\tcase controls::draft::NoiseReductionModeZSL:\n+\t\tif (loadReductionConfig(runningMode_)) {\n+\t\t\tupdate = true;\n+\t\t\tdpf.denoise = true;\n+\t\t} else {\n+\t\t\tdpf.denoise = false;\n+\t\t\tupdate = true;\n \t\t}\n+\t\tbreak;\n+\tdefault:\n+\t\tLOG(RkISP1Dpf, Error)\n+\t\t\t<< \"Unsupported denoise value \"\n+\t\t\t<< *denoise;\n+\t\tbreak;\n \t}\n \n \tframeContext.dpf.denoise = dpf.denoise;\n@@ -219,41 +334,64 @@ void Dpf::queueRequest(IPAContext &context,\n void Dpf::prepare(IPAContext &context, const uint32_t frame,\n \t\t  IPAFrameContext &frameContext, RkISP1Params *params)\n {\n-\tif (!frameContext.dpf.update && frame > 0)\n+\tif (!frameContext.dpf.update && frame > 0) {\n+\t\treturn;\n+\t}\n+\n+\tif (!frameContext.dpf.denoise) {\n+\t\tprepareDisabledMode(context, frame, frameContext, params);\n \t\treturn;\n+\t}\n+\n+\tprepareEnabledMode(context, frame, frameContext, params);\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 dpfConfig = params->block<BlockType::Dpf>();\n+\tdpfConfig.setEnabled(false);\n+\tauto dpfStrength = params->block<BlockType::DpfStrength>();\n+\tdpfStrength.setEnabled(false);\n+}\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+void Dpf::prepareEnabledMode(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n+\t\t\t     [[maybe_unused]] IPAFrameContext &frameContext, RkISP1Params *params)\n+{\n+\tauto dpfConfig = params->block<BlockType::Dpf>();\n+\tdpfConfig.setEnabled(true);\n+\t*dpfConfig = 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 = dpfConfig->gain.mode;\n+\n+\tif (awb.enabled && lsc.enabled) {\n+\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS;\n+\t} else if (awb.enabled) {\n+\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS;\n+\t} else if (lsc.enabled) {\n+\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS;\n+\t} else {\n+\t\tmode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED;\n \t}\n+\tconfig_.gain.mode = mode;\n+\n+\tauto dpfStrength = params->block<BlockType::DpfStrength>();\n+\tdpfStrength.setEnabled(true);\n+\n+\t*dpfStrength = strengthConfig_;\n }\n \n REGISTER_IPA_ALGORITHM(Dpf, \"Dpf\")\ndiff --git a/src/ipa/rkisp1/algorithms/dpf.h b/src/ipa/rkisp1/algorithms/dpf.h\nindex 2dd8cd36..163a5b1f 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.h\n+++ b/src/ipa/rkisp1/algorithms/dpf.h\n@@ -30,8 +30,27 @@ public:\n \t\t     RkISP1Params *params) override;\n \n private:\n+\tstruct ModeConfig {\n+\t\tint32_t modeValue;\n+\t\trkisp1_cif_isp_dpf_config dpf;\n+\t\trkisp1_cif_isp_dpf_strength_config strength;\n+\t};\n+\tbool parseConfig(const YamlObject &tuningData);\n+\tbool parseModes(const YamlObject &tuningData);\n+\tbool parseSingleConfig(const YamlObject &tuningData,\n+\t\t\t       rkisp1_cif_isp_dpf_config &config,\n+\t\t\t       rkisp1_cif_isp_dpf_strength_config &strengthConfig);\n+\tbool loadReductionConfig(int32_t mode);\n+\tvoid logConfigIfChanged(const 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);\n+\tvoid prepareEnabledMode(IPAContext &context, const uint32_t frame,\n+\t\t\t\tIPAFrameContext &frameContext, RkISP1Params *params);\n \tstruct rkisp1_cif_isp_dpf_config config_;\n \tstruct rkisp1_cif_isp_dpf_strength_config strengthConfig_;\n+\tstd::vector<ModeConfig> noiseReductionModes_;\n+\tint32_t runningMode_;\n };\n \n } /* namespace ipa::rkisp1::algorithms */\n",
    "prefixes": [
        "v2",
        "1/2"
    ]
}