{"id":25381,"url":"https://patchwork.libcamera.org/api/patches/25381/?format=json","web_url":"https://patchwork.libcamera.org/patch/25381/","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":"<20251208004808.1274417-4-rui.wang@ideasonboard.com>","date":"2025-12-08T00:48:04","name":"[v4,3/7] ipa: rkisp1: algorithms: dpf: Refactor prepare() into helpers","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1b643847963336ae5e4546e16b280574b8e9a59e","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/25381/mbox/","series":[{"id":5641,"url":"https://patchwork.libcamera.org/api/series/5641/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5641","date":"2025-12-08T00:48:01","name":"rebase_dpf_refactory_patch_v4","version":4,"mbox":"https://patchwork.libcamera.org/series/5641/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/25381/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/25381/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 27F4DC3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  8 Dec 2025 00:48:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D2B0A613F2;\n\tMon,  8 Dec 2025 01:48:45 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 989BD611BA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Dec 2025 01:48:43 +0100 (CET)","from localhost.localdomain (unknown [209.216.103.65])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 049A01E2B;\n\tMon,  8 Dec 2025 01:46:24 +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=\"XOl2Iwys\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1765154785;\n\tbh=C1cCdb/jlSi9MVxLX2CrJ1kTpj4ehzCLxKGO8bpF0Fo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=XOl2Iwyswl95hMPeMua8HO7Vjw8B4u2DStizWcnD425N87KwmjSMz1VfwMf5gjM6X\n\tLNV7IogVt4jQtgRRwLKrjBXBtBKzrOoLzkS2WSXoE8L4k5dZdfBlt9GfUESItkJc+c\n\tEEab9oxzlY4eoPJUXJ8V/lKCb5F3Y6Umy0DoYyrE=","From":"Rui Wang <rui.wang@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Rui Wang <rui.wang@ideasonboard.com>","Subject":"[PATCH v4 3/7] ipa: rkisp1: algorithms: dpf: Refactor prepare() into\n\thelpers","Date":"Sun,  7 Dec 2025 19:48:04 -0500","Message-ID":"<20251208004808.1274417-4-rui.wang@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20251208004808.1274417-1-rui.wang@ideasonboard.com>","References":"<20251208004808.1274417-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 the prepare() function into prepareDisabledMode() and\nprepareEnabledMode() to improve readability and maintainability.\n\nThis separates the logic for disabling and enabling the DPF, making\nthe main prepare() function cleaner and easier to follow.\n\nSigned-off-by: Rui Wang <rui.wang@ideasonboard.com>\n---\nchangelog:\n - Move V3 prepareEnabledMode/prepareDisabledMode into this patch\n\n src/ipa/rkisp1/algorithms/dpf.cpp | 82 ++++++++++++++++++++-----------\n src/ipa/rkisp1/algorithms/dpf.h   |  9 ++++\n 2 files changed, 62 insertions(+), 29 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp\nindex 18f2a158..edb4c2bf 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.cpp\n+++ b/src/ipa/rkisp1/algorithms/dpf.cpp\n@@ -320,38 +320,62 @@ void Dpf::prepare(IPAContext &context, const uint32_t frame,\n \tif (!frameContext.dpf.update && frame > 0)\n \t\treturn;\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+void Dpf::prepareEnabledMode(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 \tauto config = params->block<BlockType::Dpf>();\n-\tconfig.setEnabled(frameContext.dpf.denoise);\n+\tconfig.setEnabled(true);\n+\t*config = config_;\n+\n+\tconst auto &awb = context.configuration.awb;\n+\tconst auto &lsc = context.configuration.lsc;\n \n+\tauto &mode = config->gain.mode;\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+\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 \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-\t}\n+\tstrengthConfig.setEnabled(true);\n+\n+\t*strengthConfig = 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 30cbaa57..99cdbdd3 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.h\n+++ b/src/ipa/rkisp1/algorithms/dpf.h\n@@ -44,6 +44,15 @@ private:\n \n \tbool loadReductionConfig(int32_t mode);\n \n+\tvoid prepareDisabledMode(IPAContext &context,\n+\t\t\t\t const uint32_t frame,\n+\t\t\t\t IPAFrameContext &frameContext,\n+\t\t\t\t RkISP1Params *params);\n+\tvoid prepareEnabledMode(IPAContext &context,\n+\t\t\t\tconst uint32_t frame,\n+\t\t\t\tIPAFrameContext &frameContext,\n+\t\t\t\tRkISP1Params *params);\n+\n \tstruct rkisp1_cif_isp_dpf_config config_;\n \tstruct rkisp1_cif_isp_dpf_strength_config strengthConfig_;\n \tstd::vector<ModeConfig> noiseReductionModes_;\n","prefixes":["v4","3/7"]}