{"id":26105,"url":"https://patchwork.libcamera.org/api/patches/26105/?format=json","web_url":"https://patchwork.libcamera.org/patch/26105/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260208174450.416314-3-rui.wang@ideasonboard.com>","date":"2026-02-08T17:44:48","name":"[v1,2/4] ipa: rkisp1: dpf: Implement manual noise reduction mode","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"8cb205df354c57ee624f70581d0a54fb9cabe068","submitter":{"id":241,"url":"https://patchwork.libcamera.org/api/people/241/?format=json","name":"Rui Wang","email":"rui.wang@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26105/mbox/","series":[{"id":5777,"url":"https://patchwork.libcamera.org/api/series/5777/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5777","date":"2026-02-08T17:44:46","name":"dpf_manual_patch_v1","version":1,"mbox":"https://patchwork.libcamera.org/series/5777/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26105/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26105/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 08D57BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  8 Feb 2026 17:45:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8B551620B8;\n\tSun,  8 Feb 2026 18:45:48 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8B85D620A3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  8 Feb 2026 18:45:44 +0100 (CET)","from rui-Precision-7560.tail5b760b.ts.net (unknown\n\t[209.216.103.65])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B4CB6E72;\n\tSun,  8 Feb 2026 18:44:58 +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=\"SpaxgjD0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1770572699;\n\tbh=9Lz7WXkX5zZBIll/anol1T/awTSdG+P6YmmQZ1GcNVo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=SpaxgjD0enaK/sAnisRqvsIlgdwwUR9fCxQxd7e/3b42CjK8Pbksb9Z+DPpleQc7c\n\tX2+jZnbQnMAeaqRt3fjCrPl27iYrLbz5fFiiOKApAq/oJKJBTO/OFGBSR8yw3lF6QY\n\tNXi7igsDtQtIlhcUY+C7Go5eX9jdnjmhtcKxWmlA=","From":"Rui Wang <rui.wang@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Rui Wang <rui.wang@ideasonboard.com>","Subject":"[PATCH v1 2/4] ipa: rkisp1: dpf: Implement manual noise reduction\n\tmode","Date":"Sun,  8 Feb 2026 12:44:48 -0500","Message-ID":"<20260208174450.416314-3-rui.wang@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260208174450.416314-1-rui.wang@ideasonboard.com>","References":"<20260208174450.416314-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":"Support manual control of the Denoise Pre-Filter (DPF) parameters.\n\n- When the manual noise reduction mode is selected, apply the control\nvalues to the DPF configuration and enable the hardware block if\nrequested.\n- DPF register values can be applied manually from controls.\nRegister the DPF vendor controls with appropriate limits and defaults.\n\nSigned-off-by: Rui Wang <rui.wang@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/dpf.cpp | 116 +++++++++++++++++++++++++++++-\n src/ipa/rkisp1/algorithms/dpf.h   |   1 +\n 2 files changed, 116 insertions(+), 1 deletion(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp\nindex df6bef87..c232f2ad 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.cpp\n+++ b/src/ipa/rkisp1/algorithms/dpf.cpp\n@@ -135,6 +135,49 @@ void Dpf::registerControls(IPAContext &context)\n \t */\n \tcontext.ctrlMap[&controls::draft::NoiseReductionMode] =\n \t\tControlInfo(modes, activeMode_->modeValue);\n+\tif (noiseReductionModes_.empty())\n+\t\treturn;\n+\t/* if active mode is setted, set active mode config to control map\n+\t   else set first mode config to control map\n+\t*/\n+\tconst ModeConfig *config = nullptr;\n+\tif (activeMode_->modeValue != controls::draft::NoiseReductionModeOff)\n+\t\tconfig = &(*activeMode_);\n+\telse\n+\t\tconfig = &noiseReductionModes_[0];\n+\t/* Set the default enable value to the active mode */\n+\tcontext.ctrlMap[&controls::rkisp1::DpfEnable] = ControlInfo(0, 1, config->modeValue == controls::draft::NoiseReductionModeOff ? 0 : 1);\n+\n+\tstd::array<int32_t, 3> strengthDefault = {\n+\t\tstatic_cast<int32_t>(config->strength.r),\n+\t\tstatic_cast<int32_t>(config->strength.g),\n+\t\tstatic_cast<int32_t>(config->strength.b)\n+\t};\n+\tcontext.ctrlMap[&controls::rkisp1::DpfChannelStrengths] =\n+\t\tControlInfo(1, 255, Span<const int32_t, 3>(strengthDefault));\n+\n+\tstd::array<int32_t, RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS> greenCoeffs;\n+\tstd::copy(std::begin(config->dpf.g_flt.spatial_coeff), std::end(config->dpf.g_flt.spatial_coeff), greenCoeffs.begin());\n+\tcontext.ctrlMap[&controls::rkisp1::DpfGreenSpatialCoefficients] =\n+\t\tControlInfo(0, 16, Span<const int32_t, RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS>(greenCoeffs));\n+\n+\tcontext.ctrlMap[&controls::rkisp1::DpfRedBlueFilterSize] =\n+\t\tControlInfo(controls::rkisp1::DpfRedBlueFilterSizeValues,\n+\t\t\t    ControlValue(static_cast<int32_t>(config->dpf.rb_flt.fltsize)));\n+\n+\tstd::array<int32_t, RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS> redBlueCoeffs;\n+\tstd::copy(std::begin(config->dpf.rb_flt.spatial_coeff), std::end(config->dpf.rb_flt.spatial_coeff), redBlueCoeffs.begin());\n+\tcontext.ctrlMap[&controls::rkisp1::DpfRedBlueSpatialCoefficients] =\n+\t\tControlInfo(0, 16, Span<const int32_t, RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS>(redBlueCoeffs));\n+\n+\tstd::array<int32_t, RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS> nllCoeffs;\n+\tstd::copy(std::begin(config->dpf.nll.coeff), std::end(config->dpf.nll.coeff), nllCoeffs.begin());\n+\tcontext.ctrlMap[&controls::rkisp1::DpfNoiseLevelLookupCoefficients] =\n+\t\tControlInfo(1, 1023, Span<const int32_t, RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS>(nllCoeffs));\n+\n+\tcontext.ctrlMap[&controls::rkisp1::DpfNoiseLevelLookupScaleMode] =\n+\t\tControlInfo(controls::rkisp1::DpfNoiseLevelLookupScaleModeValues,\n+\t\t\t    ControlValue(static_cast<int32_t>(config->dpf.nll.scale_mode)));\n }\n \n int Dpf::parseSingleConfig(const YamlObject &tuningData,\n@@ -339,7 +382,8 @@ void Dpf::queueRequest(IPAContext &context,\n \tbool update = false;\n \n \tconst auto &denoise = controls.get(controls::draft::NoiseReductionMode);\n-\tif (denoise) {\n+\t/* only update denoise mode when it has changed */\n+\tif (denoise && activeMode_->modeValue != *denoise) {\n \t\tswitch (*denoise) {\n \t\tcase controls::draft::NoiseReductionModeOff:\n \t\t\tif (dpf.denoise) {\n@@ -351,6 +395,7 @@ void Dpf::queueRequest(IPAContext &context,\n \t\tcase controls::draft::NoiseReductionModeHighQuality:\n \t\tcase controls::draft::NoiseReductionModeFast:\n \t\tcase controls::draft::NoiseReductionModeZSL:\n+\t\tcase controls::draft::NoiseReductionModeManual:\n \t\t\tif (loadConfig(*denoise)) {\n \t\t\t\tupdate = true;\n \t\t\t\tdpf.denoise = true;\n@@ -365,6 +410,24 @@ void Dpf::queueRequest(IPAContext &context,\n \t\tif (update)\n \t\t\tLOG(RkISP1Dpf, Debug) << \"Set denoise to \" << *denoise;\n \t}\n+\t/* handle manual mode, collect all dpf config from controls */\n+\tif (activeMode_->modeValue == controls::draft::NoiseReductionModeManual) {\n+\t\t/*\n+\t\t * In manual mode, if DpfEnable is present and true, we enable DPF.\n+\t\t * If DpfEnable is present and false, we disable DPF.\n+\t\t * If DpfEnable is not present, we keep the previous state (or default).\n+\t\t */\n+\t\tconst auto &enable = controls.get(controls::rkisp1::DpfEnable);\n+\t\tif (*enable) {\n+\t\t\tdpf.denoise = true;\n+\t\t\tupdate = true;\n+\t\t}\n+\t\tbool ret = parseControls(controls);\n+\t\tif (!ret) {\n+\t\t\tLOG(RkISP1Dpf, Error) << \"Failed to collect manual overrides\";\n+\t\t\treturn;\n+\t\t}\n+\t}\n \n \tframeContext.dpf.denoise = dpf.denoise;\n \tframeContext.dpf.update = update;\n@@ -437,6 +500,57 @@ void Dpf::prepareEnabledMode(IPAContext &context, IPAFrameContext &frameContext,\n \t\tlogConfig(frameContext, *config, *strengthConfig);\n }\n \n+bool Dpf::parseControls(const ControlList &controls)\n+{\n+\t/*\n+\t * activeMode_ is a const_iterator, so we need to find the mutable element\n+\t * in noiseReductionModes_, and parse the controls values into manualMode\n+\t * config\n+\t */\n+\tconst auto it = std::find_if(noiseReductionModes_.begin(), noiseReductionModes_.end(),\n+\t\t\t\t     [](const ModeConfig &mode) {\n+\t\t\t\t\t     return mode.modeValue == controls::draft::NoiseReductionModeManual;\n+\t\t\t\t     });\n+\n+\tif (it == noiseReductionModes_.end()) {\n+\t\tLOG(RkISP1Dpf, Error) << \"Manual mode not found in configuration\";\n+\t\treturn false;\n+\t}\n+\n+\tModeConfig &config = *it;\n+\n+\tif (const auto &c = controls.get(controls::rkisp1::DpfGreenSpatialCoefficients); c)\n+\t\tif (c->size() == RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS)\n+\t\t\tstd::copy(c->begin(), c->end(), std::begin(config.dpf.g_flt.spatial_coeff));\n+\n+\tconfig.dpf.rb_flt.r_enable = true;\n+\tconfig.dpf.rb_flt.b_enable = true;\n+\n+\tif (const auto &c = controls.get(controls::rkisp1::DpfRedBlueSpatialCoefficients); c) {\n+\t\tif (c->size() == RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS || c->size() == RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS - 1)\n+\t\t\tstd::copy(c->begin(), c->end(), std::begin(config.dpf.rb_flt.spatial_coeff));\n+\t}\n+\n+\tif (const auto &c = controls.get(controls::rkisp1::DpfRedBlueFilterSize); c)\n+\t\tconfig.dpf.rb_flt.fltsize = *c;\n+\n+\tif (const auto &c = controls.get(controls::rkisp1::DpfNoiseLevelLookupCoefficients); c)\n+\t\tif (c->size() == RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS)\n+\t\t\tstd::copy(c->begin(), c->end(), std::begin(config.dpf.nll.coeff));\n+\n+\tif (const auto &c = controls.get(controls::rkisp1::DpfNoiseLevelLookupScaleMode); c)\n+\t\tconfig.dpf.nll.scale_mode = *c;\n+\n+\tif (const auto &c = controls.get(controls::rkisp1::DpfChannelStrengths); c)\n+\t\tif (c->size() == 3) {\n+\t\t\tconfig.strength.r = (*c)[0];\n+\t\t\tconfig.strength.g = (*c)[1];\n+\t\t\tconfig.strength.b = (*c)[2];\n+\t\t}\n+\n+\treturn true;\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 66d3f302..e3dea97b 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.h\n+++ b/src/ipa/rkisp1/algorithms/dpf.h\n@@ -41,6 +41,7 @@ private:\n \tint 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 parseControls(const ControlList &controls);\n \n \tbool loadConfig(int32_t mode);\n \tvoid logConfig(const IPAFrameContext &frameContext,\n","prefixes":["v1","2/4"]}