From patchwork Tue Oct 28 17:08:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Wang X-Patchwork-Id: 24858 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 3D8B2C32CE for ; Tue, 28 Oct 2025 17:09:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B412860831; Tue, 28 Oct 2025 18:09:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DisJxvO/"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B29C06081F for ; Tue, 28 Oct 2025 18:09:12 +0100 (CET) Received: from rui-Precision-7560.local (unknown [209.216.122.90]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C608616CD; Tue, 28 Oct 2025 18:07:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761671244; bh=Trv+AgvvlCtuEhbgOacWmb+5oWJPm9tv6x2/CUl7rp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DisJxvO/THpsIpaJVcQOOmkJRImy/ceaA84NV1k/9h/JBOfR/hju+i4MDZjdHxJi7 8x3WBmkjgSvYhe3I3zmXctgoWbyh+83f2fKnI4b55hJ2agdrOWnN1AIgE159qSBTuR 7r9dWC5vJVAeHR4qMNnr/MzbWt/bfBDatoZu6ZeM= From: Rui Wang To: libcamera-devel@lists.libcamera.org Cc: Rui Wang Subject: [PATCH v1 06/16] ipa: rkisp1: algorithms: dpf: add Dpf parseConfig Date: Tue, 28 Oct 2025 13:08:35 -0400 Message-ID: <20251028170847.2673396-6-rui.wang@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028170847.2673396-1-rui.wang@ideasonboard.com> References: <20251028170847.2673396-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" Load tuning flags and ISO levels on top of the single-config helper. The parseConfig() function wraps parseSingleConfig() to load the base configuration, then parses optional enable/devmode flags and any ISO-banded overrides. ISO levels are sorted by maxIso threshold for efficient band selection at runtime. Signed-off-by: Rui Wang --- src/ipa/rkisp1/algorithms/denoise.h | 1 + src/ipa/rkisp1/algorithms/dpf.cpp | 42 +++++++++++++++++++++++++++++ src/ipa/rkisp1/algorithms/dpf.h | 21 +++++++++++++-- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/denoise.h b/src/ipa/rkisp1/algorithms/denoise.h index f40e5aa1..5fc78588 100644 --- a/src/ipa/rkisp1/algorithms/denoise.h +++ b/src/ipa/rkisp1/algorithms/denoise.h @@ -36,6 +36,7 @@ protected: const IPAFrameContext &frameContext) const; template int selectIsoBand(unsigned iso, const LevelContainer &levels) const; + virtual bool parseConfig(const YamlObject &tuningData) = 0; private: bool manualMode_ = false; /**< Current manual/auto mode state */ diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp index 9d1e6435..d1b89691 100644 --- a/src/ipa/rkisp1/algorithms/dpf.cpp +++ b/src/ipa/rkisp1/algorithms/dpf.cpp @@ -171,6 +171,48 @@ int Dpf::init([[maybe_unused]] IPAContext &context, return 0; } +bool Dpf::parseConfig(const YamlObject &tuningData) +{ + // Parse base config + if (!parseSingleConfig(tuningData, config_, strengthConfig_)) + return false; + + baseConfig_ = config_; + baseStrengthConfig_ = strengthConfig_; + + /* Optional master enable flag (default true). If false, we parse but won't program. */ + yamlHelper::optbool(tuningData, "enable", enableDpf_, true); + + /* Optional developer mode flag (default true). If false, only basic manual controls available. */ + bool devMode = true; + yamlHelper::optbool(tuningData, "devmode", devMode, true); + setDevMode(devMode); + + // Parse ISO levels + if (tuningData.contains("IsoLevels")) { + useIsoLevels_ = true; + isoLevels_.clear(); + for (const auto &entry : tuningData["IsoLevels"].asList()) { + std::optional maxIsoOpt = entry["maxIso"].get(); + if (!maxIsoOpt) { + LOG(RkISP1Dpf, Error) << "IsoLevels entry missing maxIso"; + continue; + } + IsoLevelConfig lvl{}; + lvl.maxIso = *maxIsoOpt; + if (!parseSingleConfig(entry, lvl.dpf, lvl.strength)) + continue; + isoLevels_.push_back(lvl); + } + std::sort(isoLevels_.begin(), isoLevels_.end(), + [](const IsoLevelConfig &a, const IsoLevelConfig &b) { + return a.maxIso < b.maxIso; + }); + } + + return true; +} + bool Dpf::parseSingleConfig(const YamlObject &config, rkisp1_cif_isp_dpf_config &cfg, rkisp1_cif_isp_dpf_strength_config &strength) diff --git a/src/ipa/rkisp1/algorithms/dpf.h b/src/ipa/rkisp1/algorithms/dpf.h index cfd6ef44..faeb6c27 100644 --- a/src/ipa/rkisp1/algorithms/dpf.h +++ b/src/ipa/rkisp1/algorithms/dpf.h @@ -32,8 +32,25 @@ public: RkISP1Params *params) override; private: - struct rkisp1_cif_isp_dpf_config config_; - struct rkisp1_cif_isp_dpf_strength_config strengthConfig_; + struct rkisp1_cif_isp_dpf_config config_ { + }; + struct rkisp1_cif_isp_dpf_strength_config strengthConfig_ { + }; + struct rkisp1_cif_isp_dpf_config baseConfig_ { + }; + struct rkisp1_cif_isp_dpf_strength_config baseStrengthConfig_ { + }; + struct IsoLevelConfig { + unsigned int maxIso; /* inclusive upper bound */ + struct rkisp1_cif_isp_dpf_config dpf; + struct rkisp1_cif_isp_dpf_strength_config strength; + }; + + std::vector isoLevels_; + bool useIsoLevels_ = false; + bool enableDpf_ = true; /* YAML master enable */ + + bool parseConfig(const YamlObject &tuningData) override; bool parseSingleConfig(const YamlObject &config, rkisp1_cif_isp_dpf_config &cfg, rkisp1_cif_isp_dpf_strength_config &strength);