From patchwork Fri Nov 21 17:31:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaac Scott X-Patchwork-Id: 25151 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 6F609C0F1B for ; Fri, 21 Nov 2025 17:31:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A165960A8B; Fri, 21 Nov 2025 18:31:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XVtrd20V"; 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 0DC7560805 for ; Fri, 21 Nov 2025 18:31:29 +0100 (CET) Received: from isaac-ThinkPad-T16-Gen-2.infra.iob (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A90FE66B; Fri, 21 Nov 2025 18:29:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1763746162; bh=jPiwPePkkfeI4m0VI6KdzPi0VFhpqCEv9vso6Mf4kps=; h=From:To:Cc:Subject:Date:From; b=XVtrd20VTC6U26X98p+d2HHiF/xcI39PelsEJBB+z70d8YOlWTahg6/cVEBrq85k3 AYOuzAfbC5j8lb6T9ZjuzMKwSL5Qapfbu7QrLQJ9klq2TG4cMXSw5TQu0fTJk8qoW+ qwXI/d1ofZdlauIVru7rTXpTKW6peBG9kQ1/fXf4= From: Isaac Scott To: libcamera-devel@lists.libcamera.org Cc: Isaac Scott Subject: [PATCH v4] libipa: module: Allow algorithms to be disabled via the tuning file Date: Fri, 21 Nov 2025 17:31:24 +0000 Message-ID: <20251121173124.178430-1-isaac.scott@ideasonboard.com> X-Mailer: git-send-email 2.43.0 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" It is beneficial to have the option during development to disable and enable algorithms via the tuning file without having to delete their entries. Add support for an optional "enabled" parameter to accomplish this. Usage example: version: 1 algorithms: - Agc: enabled: true - Awb: enabled: false This will enable AGC, and disable AWB. If the enabled flag is not present, the algorithm will be enabled. Signed-off-by: Isaac Scott Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v1 of this patch can be found here: https://patchwork.libcamera.org/patch/23299/ Changelog: v3 -> v4: - Made DEBUG logging into INFO - Checked whether enabled exists before attempting to create the algorithm. v2 -> v3: - Moved parsing back to createAlgorithm(). - Added documentation to module.cpp. - Ensured the 'enabled' flag is part of the algoData for an algorithm to help avoid ambiguity. v1 -> v2: - Moved parsing to createAlgorithms() instead of createAlgorithm() - Changed "disabled" flag to "enabled: [boolean]" --- src/ipa/libipa/module.cpp | 8 ++++++++ src/ipa/libipa/module.h | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp index 64ca91419..f142c5257 100644 --- a/src/ipa/libipa/module.cpp +++ b/src/ipa/libipa/module.cpp @@ -94,6 +94,14 @@ namespace ipa { * algorithms. The configuration data is expected to be correct, any error * causes the function to fail and return immediately. * + * Algorithms can optionally be disabled via the tuning file of the camera module + * as shown here, with AGC being used as an example: + * + * - Agc: + * enabled: false + * + * If this is the case, the algorithm will not be instantiated. + * * \return 0 on success, or a negative error code on failure */ diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h index 0fb51916f..826b34dab 100644 --- a/src/ipa/libipa/module.h +++ b/src/ipa/libipa/module.h @@ -74,6 +74,18 @@ private: int createAlgorithm(Context &context, const YamlObject &data) { const auto &[name, algoData] = *data.asDict().begin(); + + /* + * Optionally, algorithms can be disabled via the tuning file by including + * enabled: false as a parameter within the algorithm tuning data. + * This is not an error, so we return 0. + */ + if (!algoData["enabled"].get(true)) { + LOG(IPAModuleAlgo, Info) + << "Algorithm '" << name << "' disabled via tuning file"; + return 0; + } + std::unique_ptr> algo = createAlgorithm(name); if (!algo) { LOG(IPAModuleAlgo, Error)