From patchwork Wed Dec 17 10:01:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25594 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 9CCE8C32F1 for ; Wed, 17 Dec 2025 10:02:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D14C061F3A; Wed, 17 Dec 2025 11:02:24 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="q6FqmFZi"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 22F8861F28 for ; Wed, 17 Dec 2025 11:02:09 +0100 (CET) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-47798ded6fcso36050895e9.1 for ; Wed, 17 Dec 2025 02:02:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765965728; x=1766570528; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZK3P0VzssNwl0WhBtRyk+w7dSYasdHalDGrt/ye5fgo=; b=q6FqmFZiUtuSp//3vCFW+90PAiTwIXGamOK7tWKlNf6SMLzaH4EGo8ZKV4wUPrvBN5 DAWH+MzmgSGqW4qHa6dH9g8H+trUQq+d1Soyo/n+13iqqsbCTNv/8qMzLyDyM8z+gevY qf+JVMoL64QXZdNM4SUM/pQZc/BDXYS9l2/xBzR+Y8gLH862YVDweFO8L2KeWsfHrhQ+ ZuAzGaYFFr8n28ZpwqP/u/Sjht9SzojzbO05vGPhJRhLoU3VZm0yMRbM8UMpL/MyZFe7 TLD5cxMkit3c78ysMfjNlCaQ0+rkw45lUKeBLPiPPr9V5DP2PaccqF4FwMwNw7eCv3wz Ma/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765965728; x=1766570528; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZK3P0VzssNwl0WhBtRyk+w7dSYasdHalDGrt/ye5fgo=; b=rdD6STNi2yuNXWucLveMpnc+xxvHf2ZwETH+x8rKLRO7s5jwIQAHN7HOftxVK318fI qwxrS2eaVqMomsCP9pR0e8Wrb35ZipKBCIz3cVjnnsCoBbIBgTs3qqcvG+ZlV2u/adDo hAYo0eKblTcQZh7z9pZONfO7IexYkt5v05XT59enWu/WQ4i7szRkrKTIwo9EBj+sPHAH g4VPWawJR7Ux8tISmhbeuqVPXjlToPr7dWPbb/3zHz91ViqtkIEMhXqdw9ByzHQa3816 kL0CdQHP42SFBc9CX+i9qLw6k7oSh30KGetIq6fd5MZaHTXDPkcYB1ocWagjvJ/jEvcj 4y+g== X-Gm-Message-State: AOJu0YzO3XvAuzys4lgxeVeJS1myf17T1qXGBVQI34hUj4H64j0kkCOr xUc2BZzBorkotuGZpYNJAsbk5R2ysw5BLI5XC5sbMAy0lq+HJgGbGxUkomIIqJtSiJShPwB1Tjh yGAPE X-Gm-Gg: AY/fxX6iU1rawaGRgZYjrN1aaG4Xa46uxHzVnbeN6DTkFvoIzpTYIfYuH9W6Vmqlivw 2OZi99FGlwPBhuxD7XOpFZchX/tOoPj8Z4EZ5/SyT/ryGVSy49+k3VTjvjiqCZ6kCQ4QuES0h+v uxthO4ZxDr3St9qy75MucT4SDjBNcIwWgsgqReULoRsO1dhexcC/znHxHsnXFvlKhlkCWIzcLXt OBrAXmCc9veDdtYmDMtZ6XOpOGWltnJzu3ja6kNhwmW6kXeNrsCX49ammwcObnbZkUsAwzr7MfU 7rEDj8o6bC8IhNr5bEgb25dI+YTo9NhGNuP+C9YoAdkge77Tb0g/rMeS/nbxOaGewOR3tGsuMG5 QK0M77rjg+jAmtdkPWxn2MQAOTLVRila/nGHF8CRYz1JgPaoP8fKJVEgFrqTujtLwjZ5MLoLZYh uQ8GtfxjLF2XWISAL/QzQNIszvACrPYnfT1SgKOKHtcKPI73PPdq+zLcTgKG6Kt8mNtyg= X-Google-Smtp-Source: AGHT+IGYDq5HAP3rkh+XO8HGsPp8VVlBUSrq2YQSUXbsvOMcv1MqKlZY0CaNGNeJmUD9PHM4KSclBA== X-Received: by 2002:a05:600d:b:b0:47a:94fc:d057 with SMTP id 5b1f17b1804b1-47a94fcd555mr125619335e9.2.1765965728179; Wed, 17 Dec 2025 02:02:08 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47bdc1583fbsm32292585e9.0.2025.12.17.02.02.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Dec 2025 02:02:07 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Milan Zamazal Subject: [PATCH v9 21/26] ipa: libipa: module: Add createSelfEnumeratingAlgorithm Date: Wed, 17 Dec 2025 10:01:33 +0000 Message-ID: <20251217100138.82525-22-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217100138.82525-1-bryan.odonoghue@linaro.org> References: <20251217100138.82525-1-bryan.odonoghue@linaro.org> 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" Create an algorithm without having YAML data input. Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- src/ipa/libipa/module.cpp | 34 +++++++++++++++++++++++++++++ src/ipa/libipa/module.h | 46 +++++++++++++++++++++++++++++---------- 2 files changed, 68 insertions(+), 12 deletions(-) diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp index a95dca696..8e86ca823 100644 --- a/src/ipa/libipa/module.cpp +++ b/src/ipa/libipa/module.cpp @@ -83,6 +83,40 @@ namespace ipa { * \return The list of instantiated algorithms */ +/** + * \fn int Module::createSelfEnumeratingAlgorithm(Context &context, const std::string &name) + * \brief Create and initialise a self-enumerating algorithm by name + * + * This function creates an algorithm instance from the registered algorithm + * factories using only the algorithm name, without requiring YAML configuration + * data. + * + * This is useful for algorithms that don't require external configuration + * parameters and can self-configure or use default values. + * + * \param[in] context The IPA context to pass to the algorithm's init function + * \param[in] name The name of the algorithm to instantiate + * + * \return 0 on success, negative errno value on failure: + * -EINVAL if the algorithm is not found in the factory registry + * Other negative values if algorithm initialisation fails + */ + +/** + * \fn int Module::createAlgorithmCommon(Context &context, const YamlObject &algoData, const std::string &name) + * \brief Common helper fucntion to allow createSelfEnumeratingAlgorithm and createAlgorithm share code + * + * Worker method which allows sharing of common code in the Yaml and self-initialising algorithm case + * + * \param[in] context The IPA context to pass to the algorithm's init function + * \param[in] algoData Yaml object + * \param[in] name The name of the algorithm to instantiate + * + * \return 0 on success, negative errno value on failure: + * -EINVAL if the algorithm is not found in the factory registry + * Other negative values if algorithm initialisation fails + */ + /** * \fn Module::createAlgorithms() * \brief Create algorithms from YAML configuration data diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h index c27af7718..d309606f2 100644 --- a/src/ipa/libipa/module.h +++ b/src/ipa/libipa/module.h @@ -70,22 +70,25 @@ public: factories().push_back(factory); } -private: - int createAlgorithm(Context &context, const YamlObject &data) + int createSelfEnumeratingAlgorithm(Context &context, const std::string &name) { - const auto &[name, algoData] = *data.asDict().begin(); + YamlObject dummy; - /* - * 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) + << "Algorithm '" << name << "' not found"; + return -EINVAL; } + context.selfInitialising = true; + + return createAlgorithmCommon(context, dummy, name); + } + +private: + int createAlgorithmCommon(Context &context, const YamlObject &algoData, const std::string &name) + { std::unique_ptr> algo = createAlgorithm(name); if (!algo) { LOG(IPAModuleAlgo, Error) @@ -104,9 +107,28 @@ private: << "Instantiated algorithm '" << name << "'"; algorithms_.push_back(std::move(algo)); + return 0; } + 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; + } + + return createAlgorithmCommon(context, algoData, name); + } + static std::unique_ptr> createAlgorithm(const std::string &name) { for (const AlgorithmFactoryBase *factory : factories()) {