From patchwork Tue Nov 25 00:08:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Wang X-Patchwork-Id: 25171 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id F1C73C3257 for ; Tue, 25 Nov 2025 00:09:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A27F260A9D; Tue, 25 Nov 2025 01:09:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="W+FJpiLR"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B80E7608CF for ; Tue, 25 Nov 2025 01:09:11 +0100 (CET) Received: from rui-Precision-7560.local (unknown [IPv6:2607:fea8:935b:7220:cb34:a7b8:53d:5466]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 959A61785; Tue, 25 Nov 2025 01:07:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1764029223; bh=cmhCEGrYfDDYOVEx/zoAkyOMTLK65P3DpKgjRdVMscc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W+FJpiLR5dYnB8tLYVxK9+De5DR0l7Qyhqzw0jxBsRqhhV2IDDn7aFSHVoGebbILw YdooedLP+p/+nKb3WQZQV9tFC/JgvwqRAZIcJpEBEBCYqSpIqd9/70iNvmCa7E5vIW nS6g4IMFGobL+phTI/d1QP3aqSFXdEL/xgXj1n64= From: Rui Wang To: libcamera-devel@lists.libcamera.org Cc: Rui Wang Subject: [PATCH v1 04/11] ipa: rkisp1: algorithms: Add reduction mode support to DPF Date: Mon, 24 Nov 2025 19:08:41 -0500 Message-ID: <20251125000848.4103786-5-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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" - Introduce DenoiseMode enum in DenoiseBaseAlgorithm with values: Auto, Manual, Reduction, Disabled - Add virtual getRunningMode() and setRunningMode() methods to the base class - Implement handleReductionModeControl() in Dpf class to process draft::NoiseReductionMode controls - Map control values to ReductionMode enum (Off, Minimal, HighQuality, Fast, ZSL) - Add currentReductionMode_ member to track the active reduction mode - Set running mode to controls::rkisp1::DenoiseModeReduction when reduction mode is engaged Signed-off-by: Rui Wang --- src/ipa/rkisp1/algorithms/denoise.h | 10 ++++ src/ipa/rkisp1/algorithms/dpf.cpp | 85 +++++++++++++++++++---------- src/ipa/rkisp1/algorithms/dpf.h | 6 ++ 3 files changed, 71 insertions(+), 30 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/denoise.h b/src/ipa/rkisp1/algorithms/denoise.h index abd08cba..660f648b 100644 --- a/src/ipa/rkisp1/algorithms/denoise.h +++ b/src/ipa/rkisp1/algorithms/denoise.h @@ -31,10 +31,20 @@ protected: { return true; } + virtual void handleReductionModeControl([[maybe_unused]] const ControlList &controls, + [[maybe_unused]] IPAFrameContext &frameContext, + [[maybe_unused]] IPAContext &context, + [[maybe_unused]] uint32_t frame) + { + } + virtual int32_t getRunningMode() const { return currentRunMode_; } + virtual void setRunningMode(int32_t mode) { currentRunMode_ = mode; } private: /**< Developer mode state for advanced controls */ bool devMode_ = false; + /**< Current denoise running mode */ + int32_t currentRunMode_ = controls::rkisp1::DenoiseModeDisabled; }; inline unsigned DenoiseBaseAlgorithm::computeExposureIndex(const IPAContext &context, diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp index dc0a361c..c006fb5c 100644 --- a/src/ipa/rkisp1/algorithms/dpf.cpp +++ b/src/ipa/rkisp1/algorithms/dpf.cpp @@ -309,6 +309,55 @@ bool Dpf::parseSingleConfig(const YamlObject &tuningData, return true; } +void Dpf::handleReductionModeControl(const ControlList &controls, + IPAFrameContext &frameContext, + IPAContext &context, + [[maybe_unused]] uint32_t frame) +{ + auto &dpf = context.activeState.dpf; + const auto &denoise = controls.get(controls::draft::NoiseReductionMode); + if (!denoise) { + frameContext.dpf.denoise = dpf.denoise; + return; + } + LOG(RkISP1Dpf, Debug) << "Set denoise mode to " << *denoise; + + const auto requestedMode = static_cast(*denoise); + if (requestedMode == currentReductionMode_) { + frameContext.dpf.denoise = dpf.denoise; + return; + } + + currentReductionMode_ = requestedMode; + if (requestedMode == controls::draft::NoiseReductionModeOff) { + dpf.denoise = false; + frameContext.dpf.denoise = false; + return; + } + + dpf.denoise = true; + frameContext.dpf.denoise = true; + frameContext.dpf.update = true; +} +void Dpf::loadReductionModeConfig(IPAFrameContext &frameContext) +{ + /* Find mode config */ + auto it = std::find_if(modes_.begin(), modes_.end(), + [this](const ModeConfig &mode) { + return mode.modeValue == currentReductionMode_; + }); + if (it == modes_.end()) { + LOG(RkISP1Dpf, Warning) + << "No DPF config for reduction mode " + << static_cast(currentReductionMode_); + return; + } + + /* Apply mode config */ + config_ = it->dpf; + strengthConfig_ = it->strength; + frameContext.dpf.update = true; +} /** * \copydoc libcamera::ipa::Algorithm::queueRequest */ @@ -317,38 +366,14 @@ void Dpf::queueRequest(IPAContext &context, IPAFrameContext &frameContext, const ControlList &controls) { - auto &dpf = context.activeState.dpf; - bool update = false; + frameContext.dpf.update = false; + auto currentRunnungMode = getRunningMode(); + handleReductionModeControl(controls, frameContext, context, frame); - const auto &denoise = controls.get(controls::draft::NoiseReductionMode); - if (denoise) { - LOG(RkISP1Dpf, Debug) << "Set denoise to " << *denoise; - - switch (*denoise) { - case controls::draft::NoiseReductionModeOff: - if (dpf.denoise) { - dpf.denoise = false; - update = true; - } - break; - case controls::draft::NoiseReductionModeMinimal: - case controls::draft::NoiseReductionModeHighQuality: - case controls::draft::NoiseReductionModeFast: - if (!dpf.denoise) { - dpf.denoise = true; - update = true; - } - break; - default: - LOG(RkISP1Dpf, Error) - << "Unsupported denoise value " - << *denoise; - break; - } + if (currentRunnungMode == controls::rkisp1::DenoiseModeReduction && currentReductionMode_ != controls::draft::NoiseReductionModeOff) { + loadReductionModeConfig(frameContext); + return; } - - frameContext.dpf.denoise = dpf.denoise; - frameContext.dpf.update = update; } /** diff --git a/src/ipa/rkisp1/algorithms/dpf.h b/src/ipa/rkisp1/algorithms/dpf.h index 8691932d..928e79d9 100644 --- a/src/ipa/rkisp1/algorithms/dpf.h +++ b/src/ipa/rkisp1/algorithms/dpf.h @@ -49,7 +49,13 @@ private: std::vector exposureIndexLevels_; std::vector modes_; bool useExposureIndexLevels_ = false; + int32_t currentReductionMode_ = controls::draft::NoiseReductionModeOff; + void handleReductionModeControl(const ControlList &controls, + IPAFrameContext &frameContext, + IPAContext &context, + uint32_t frame) override; + void loadReductionModeConfig(IPAFrameContext &frameContext); bool parseConfig(const YamlObject &tuningData) override; bool parseSingleConfig(const YamlObject &tuningData, rkisp1_cif_isp_dpf_config &config,