[{"id":37412,"web_url":"https://patchwork.libcamera.org/comment/37412/","msgid":"<2bqiywgil2cv6uu7j7hkkgihvug6zrtlh2blediddohf56gmni@7kpe2al43wf3>","date":"2025-12-16T17:01:07","subject":"Re: [PATCH v5 3/6] ipa: rkisp1: algorithms: dpf: Refactor prepare()\n\tinto helpers","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Rui\n\nOn Sun, Dec 14, 2025 at 01:16:43PM -0500, Rui Wang wrote:\n> Split the prepare() function into prepareDisabledMode() and\n> prepareEnabledMode() to improve readability and maintainability.\n>\n> This separates the logic for disabling and enabling the DPF, making\n> the main prepare() function cleaner and easier to follow.\n>\n> Signed-off-by: Rui Wang <rui.wang@ideasonboard.com>\n\nPlease remember to collect tags\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nif you intentially leave them out, because you think the patch has\nchanged and you want reviewers to have a full review again, please\nmention it, otherwise carry the tags over to the next version!\n\nThanks\n  j\n> ---\n>\n> changelog :\n>  - Add blank line into code\n>  - removing  frameContext.dpf.denoise = false in prepareDisabledMode\n>\n>  src/ipa/rkisp1/algorithms/dpf.cpp | 80 ++++++++++++++++++++-----------\n>  src/ipa/rkisp1/algorithms/dpf.h   |  7 +++\n>  2 files changed, 58 insertions(+), 29 deletions(-)\n>\n> diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp\n> index 392edda1..677239ca 100644\n> --- a/src/ipa/rkisp1/algorithms/dpf.cpp\n> +++ b/src/ipa/rkisp1/algorithms/dpf.cpp\n> @@ -325,38 +325,60 @@ 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> +\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, [[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>\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> +\t*strengthConfig = strengthConfig_;\n>  }\n>\n>  REGISTER_IPA_ALGORITHM(Dpf, \"Dpf\")\n> diff --git a/src/ipa/rkisp1/algorithms/dpf.h b/src/ipa/rkisp1/algorithms/dpf.h\n> index 2a2c7052..fcf121cb 100644\n> --- a/src/ipa/rkisp1/algorithms/dpf.h\n> +++ b/src/ipa/rkisp1/algorithms/dpf.h\n> @@ -44,6 +44,13 @@ private:\n>\n>  \tbool loadReductionConfig(int32_t mode);\n>\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,\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> --\n> 2.43.0\n>","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 26A85C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Dec 2025 17:01:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4CA1361A2C;\n\tTue, 16 Dec 2025 18:01:12 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EDDDF6191D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Dec 2025 18:01:10 +0100 (CET)","from ideasonboard.com (93-46-82-201.ip106.fastwebnet.it\n\t[93.46.82.201])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D5A306DE;\n\tTue, 16 Dec 2025 18:01:04 +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=\"qcFcGJJ9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1765904464;\n\tbh=31/4XOFLk7gDfaB/d1G/H+6GLd/tAFFVFsnTjbhjO7E=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=qcFcGJJ9sDV6yNsNV1ZPVHVW7vLS+E6G9nnOfeGp5A6FGOHZC+BWW9U1usQiveQvE\n\tz8hOUYbikDgrVmrWtEhueYpOan07GzesSFVmvLZy92KnGmA27befkJyJmTMRLheAOE\n\tvpn2XjmlHBbtKm3sC6DilGDsDun8yxcHdpjQrcjg=","Date":"Tue, 16 Dec 2025 18:01:07 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Rui Wang <rui.wang@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v5 3/6] ipa: rkisp1: algorithms: dpf: Refactor prepare()\n\tinto helpers","Message-ID":"<2bqiywgil2cv6uu7j7hkkgihvug6zrtlh2blediddohf56gmni@7kpe2al43wf3>","References":"<20251214181646.573675-1-rui.wang@ideasonboard.com>\n\t<20251214181646.573675-4-rui.wang@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20251214181646.573675-4-rui.wang@ideasonboard.com>","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>"}},{"id":37436,"web_url":"https://patchwork.libcamera.org/comment/37436/","msgid":"<176607498493.724385.2058569870135084551@rui-Precision-7560.local>","date":"2025-12-18T16:23:04","subject":"Re: [PATCH v5 3/6] ipa: rkisp1: algorithms: dpf: Refactor prepare()\n\tinto helpers","submitter":{"id":241,"url":"https://patchwork.libcamera.org/api/people/241/","name":"Rui Wang","email":"rui.wang@ideasonboard.com"},"content":"Thanks Jacopo,\n\nQuoting Jacopo Mondi (2025-12-16 12:01:07)\n> Hi Rui\n> \n> On Sun, Dec 14, 2025 at 01:16:43PM -0500, Rui Wang wrote:\n> > Split the prepare() function into prepareDisabledMode() and\n> > prepareEnabledMode() to improve readability and maintainability.\n> >\n> > This separates the logic for disabling and enabling the DPF, making\n> > the main prepare() function cleaner and easier to follow.\n> >\n> > Signed-off-by: Rui Wang <rui.wang@ideasonboard.com>\n> \n> Please remember to collect tags\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> \n> if you intentially leave them out, because you think the patch has\n> changed and you want reviewers to have a full review again, please\n> mention it, otherwise carry the tags over to the next version!\n> \n> Thanks\n>   j\n\nYes , I will add those reviewed tag into change log in next series.\n\n> > ---\n> >\n> > changelog :\n> >  - Add blank line into code\n> >  - removing  frameContext.dpf.denoise = false in prepareDisabledMode\n> >\n> >  src/ipa/rkisp1/algorithms/dpf.cpp | 80 ++++++++++++++++++++-----------\n> >  src/ipa/rkisp1/algorithms/dpf.h   |  7 +++\n> >  2 files changed, 58 insertions(+), 29 deletions(-)\n> >\n> > diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp\n> > index 392edda1..677239ca 100644\n> > --- a/src/ipa/rkisp1/algorithms/dpf.cpp\n> > +++ b/src/ipa/rkisp1/algorithms/dpf.cpp\n> > @@ -325,38 +325,60 @@ void Dpf::prepare(IPAContext &context, const uint32_t frame,\n> >       if (!frameContext.dpf.update && frame > 0)\n> >               return;\n> >\n> > +     if (!frameContext.dpf.denoise) {\n> > +             prepareDisabledMode(context, frame, frameContext, params);\n> > +             return;\n> > +     }\n> > +\n> > +     prepareEnabledMode(context, frame, frameContext, params);\n> > +}\n> > +\n> > +void Dpf::prepareDisabledMode([[maybe_unused]] IPAContext &context,\n> > +                           [[maybe_unused]] const uint32_t frame,\n> > +                           [[maybe_unused]] IPAFrameContext &frameContext,\n> > +                           RkISP1Params *params)\n> > +{\n> > +     auto dpfConfig = params->block<BlockType::Dpf>();\n> > +     dpfConfig.setEnabled(false);\n> > +     auto dpfStrength = params->block<BlockType::DpfStrength>();\n> > +     dpfStrength.setEnabled(false);\n> > +}\n> > +\n> > +void Dpf::prepareEnabledMode(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> > +                          [[maybe_unused]] IPAFrameContext &frameContext,\n> > +                          RkISP1Params *params)\n> > +{\n> >       auto config = params->block<BlockType::Dpf>();\n> > -     config.setEnabled(frameContext.dpf.denoise);\n> > +     config.setEnabled(true);\n> > +     *config = config_;\n> > +\n> > +     const auto &awb = context.configuration.awb;\n> > +     const auto &lsc = context.configuration.lsc;\n> > +\n> > +     auto &mode = config->gain.mode;\n> > +\n> > +     /*\n> > +      * The DPF needs to take into account the total amount of\n> > +      * digital gain, which comes from the AWB and LSC modules. The\n> > +      * DPF hardware can be programmed with a digital gain value\n> > +      * manually, but can also use the gains supplied by the AWB and\n> > +      * LSC modules automatically when they are enabled. Use that\n> > +      * mode of operation as it simplifies control of the DPF.\n> > +      */\n> > +     if (awb.enabled && lsc.enabled)\n> > +             mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS;\n> > +     else if (awb.enabled)\n> > +             mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS;\n> > +     else if (lsc.enabled)\n> > +             mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS;\n> > +     else\n> > +             mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED;\n> > +\n> > +     config_.gain.mode = mode;\n> >\n> >       auto strengthConfig = params->block<BlockType::DpfStrength>();\n> > -     strengthConfig.setEnabled(frameContext.dpf.denoise);\n> > -\n> > -     if (frameContext.dpf.denoise) {\n> > -             *config = config_;\n> > -             *strengthConfig = strengthConfig_;\n> > -\n> > -             const auto &awb = context.configuration.awb;\n> > -             const auto &lsc = context.configuration.lsc;\n> > -\n> > -             auto &mode = config->gain.mode;\n> > -\n> > -             /*\n> > -              * The DPF needs to take into account the total amount of\n> > -              * digital gain, which comes from the AWB and LSC modules. The\n> > -              * DPF hardware can be programmed with a digital gain value\n> > -              * manually, but can also use the gains supplied by the AWB and\n> > -              * LSC modules automatically when they are enabled. Use that\n> > -              * mode of operation as it simplifies control of the DPF.\n> > -              */\n> > -             if (awb.enabled && lsc.enabled)\n> > -                     mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS;\n> > -             else if (awb.enabled)\n> > -                     mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS;\n> > -             else if (lsc.enabled)\n> > -                     mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS;\n> > -             else\n> > -                     mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED;\n> > -     }\n> > +     strengthConfig.setEnabled(true);\n> > +     *strengthConfig = strengthConfig_;\n> >  }\n> >\n> >  REGISTER_IPA_ALGORITHM(Dpf, \"Dpf\")\n> > diff --git a/src/ipa/rkisp1/algorithms/dpf.h b/src/ipa/rkisp1/algorithms/dpf.h\n> > index 2a2c7052..fcf121cb 100644\n> > --- a/src/ipa/rkisp1/algorithms/dpf.h\n> > +++ b/src/ipa/rkisp1/algorithms/dpf.h\n> > @@ -44,6 +44,13 @@ private:\n> >\n> >       bool loadReductionConfig(int32_t mode);\n> >\n> > +     void prepareDisabledMode(IPAContext &context, const uint32_t frame,\n> > +                              IPAFrameContext &frameContext,\n> > +                              RkISP1Params *params);\n> > +     void prepareEnabledMode(IPAContext &context, const uint32_t frame,\n> > +                             IPAFrameContext &frameContext,\n> > +                             RkISP1Params *params);\n> > +\n> >       struct rkisp1_cif_isp_dpf_config config_;\n> >       struct rkisp1_cif_isp_dpf_strength_config strengthConfig_;\n> >       std::vector<ModeConfig> noiseReductionModes_;\n> > --\n> > 2.43.0\n> >","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 ABB7EC3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Dec 2025 16:23:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C6B2861F2F;\n\tThu, 18 Dec 2025 17:23:19 +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 8DD4061A61\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Dec 2025 17:23:18 +0100 (CET)","from pyrite.rasen.tech (unknown [209.216.103.65])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D1DF51189;\n\tThu, 18 Dec 2025 17:23:10 +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=\"jqwDffVd\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1766074991;\n\tbh=/RZmIY/ZYj+6ALDdxSFMosZThTnGRtX9j5tAco4WhU4=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=jqwDffVdJH0MOr+7KP5vb91xWWu8IrENVLrhkqyplEg3NO9ojCdYXcOHqroXJtL7h\n\tiLVTJHOzwrbcLt1fieKI4j5hHjGZnAf94tGKpg+IOidy0A1AET6+z+nBnhIFaC+n6n\n\tv2hzVfnuonKFCOLGmkU6l+ZfL9WzcnRpetKxo0BQ=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<2bqiywgil2cv6uu7j7hkkgihvug6zrtlh2blediddohf56gmni@7kpe2al43wf3>","References":"<20251214181646.573675-1-rui.wang@ideasonboard.com>\n\t<20251214181646.573675-4-rui.wang@ideasonboard.com>\n\t<2bqiywgil2cv6uu7j7hkkgihvug6zrtlh2blediddohf56gmni@7kpe2al43wf3>","Subject":"Re: [PATCH v5 3/6] ipa: rkisp1: algorithms: dpf: Refactor prepare()\n\tinto helpers","From":"Rui Wang <rui.wang@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Date":"Thu, 18 Dec 2025 11:23:04 -0500","Message-ID":"<176607498493.724385.2058569870135084551@rui-Precision-7560.local>","User-Agent":"alot/0.12","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>"}}]