From patchwork Fri Dec 12 00:29:32 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: 25536 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 5E0B0BD1F1 for ; Fri, 12 Dec 2025 00:34:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 13C3B61921; Fri, 12 Dec 2025 01:34:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="xBrRAmmE"; dkim-atps=neutral Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A5C96191A for ; Fri, 12 Dec 2025 01:34:28 +0100 (CET) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-29d7b019e0eso8862715ad.2 for ; Thu, 11 Dec 2025 16:34:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765499667; x=1766104467; 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=Ycci6C9edEvwR+DeR6OxjWNs4OeJb37qDGnfoes6rM0=; b=xBrRAmmEWsKS0SOk0kiEfngpGxlOBxB5EHGFNh0L8c5ECDz5c6A+d31VXDqQH47Xdx hWkdJhnnQl337BSZ+D6RuQvzkkE0JQezKwosQj93hm42HH91VL1EVZrtoqOK+yfwhpVw pHuVKgpDL3W1j2dygYILxJZ3RKSnDHUReCNRutbm0ciQ5eD3EX+qZER2RPwXi2sV0l3p oM/QYDoeF/Y+A3Vgp1q3b+y0L8ON0/ubMW0/LLjqwt1lPyjtvM7864Tnq3mdkmB1/C3B D6v3I4FH8o33csl0CPzsp51ico2EJR7rSYi/8z4d/w2IXfdAfVULIQxUBLlX18pTP0Ud bpqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765499667; x=1766104467; 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=Ycci6C9edEvwR+DeR6OxjWNs4OeJb37qDGnfoes6rM0=; b=bgRo8/mhISEELJJdH9lX6yVvb283Of9ElFdy7jR3A9SX1cNexbEHxIkRJ1nAcieyY4 vPg3L1LiqdOAQ30aCh3Ky+/r5wpJcX113nHMWFpqbY+15iAx5H1A6JaqG16u8Fyazbct pb0nu5/PbTC5OusQR0ZtMD3ID5ZsW/QJF6lipi9bo+8q9c0Ivj4yjNmAPLu51gjFdRjd uywAAq8lj3jXfQGyVBarJ+aKh3lUBgrSkoeLK+JTIWytMrVE4RSrZ6Y/4MicfPOTKmzy I1GqHYkjacX/qkYhja9BB5t8IERQ/XZiWrhMiz/yxz9DG3M84/cm4qNKqpsg5M+4QwEG hSPg== X-Gm-Message-State: AOJu0YwhASMz3MTn1MJL5TzFW1x3CXwqW5WfEO1PF9/5fr86wGPWLd8C tytpYZRNMyed0y7l2NzZfxNF9KG5VLk+9DHuSLAsLlYy/L3fer1p7eqgqXfyookUk9bsmn14RHk rg68K X-Gm-Gg: AY/fxX7XKTii9fpnawheHFmw65cke8/GvLBL3tUA0a7328qOctsvvHNSIKHtJd6v51Z H3PxqE1q9MvVEIVTrBi7s3P1lxexAsdQANFW4G15mdM+aHDn0rNsO1fez2MK2XkH5qoVUvrUbO6 P18YelX2VeqTnDMF9YflFhR5SSfHCymfOvBLVBIwlEFgXty7mGZXPx+br2DVI3eB5Ie9s1SZ9gH hJgXRNXJmwxV+oGLcHn0ZxwsVbkLD2LMSmJqNkWsIqttgoY9IZwTFTiRJMPP/VHEfkdQLJUttzJ cCcTBwUpjikdM5USbLDiiGHvrydXdZeDih0WesY3lVayisL0ccZUSMyhaGk2YJydRgxQaeTA8Gd SjeO7/Jd8tfg3d1QPConUcB53GdbjuT6LoF6AfBZx8q19MOzZjBUgS0hbIrLWo7f5cEqj6BwUmm ZH342I3UDjULIRRbQbeTKsycq4s3m4dxGivFqJ94M9HB5bR/dUzPRJyiUVszE= X-Google-Smtp-Source: AGHT+IHV5VCJNqj3JYE+QpyY+8THgMODQGOIohct7Qg7gtevkrlR94MTuRVkrwofdF1NkhLnAEzSVQ== X-Received: by 2002:a05:6a21:e097:b0:35d:8881:e6ce with SMTP id adf61e73a8af0-369ae1a9b3fmr288711637.26.1765499666503; Thu, 11 Dec 2025 16:34:26 -0800 (PST) Received: from inspiron14p-linux (p99250-ipoefx.ipoe.ocn.ne.jp. [153.246.134.249]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c0c26eb0f6bsm3317282a12.14.2025.12.11.16.34.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 16:34:26 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v8 21/26] ipa: libipa: module: Add createSelfEnumeratingAlgorithm Date: Fri, 12 Dec 2025 00:29:32 +0000 Message-ID: <20251212002937.3118-22-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251212002937.3118-1-bryan.odonoghue@linaro.org> References: <20251212002937.3118-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. Signed-off-by: Bryan O'Donoghue --- src/ipa/libipa/module.cpp | 34 ++++++++++++++++++++++++++++ src/ipa/libipa/module.h | 47 +++++++++++++++++++++++++++++---------- 2 files changed, 69 insertions(+), 12 deletions(-) diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp index a95dca696..41235f902 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..5ab6afc18 100644 --- a/src/ipa/libipa/module.h +++ b/src/ipa/libipa/module.h @@ -70,22 +70,26 @@ 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 +108,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()) {