From patchwork Thu Nov 20 23:33:45 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: 25145 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 399DEBD80A for ; Thu, 20 Nov 2025 23:34:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E680160B0F; Fri, 21 Nov 2025 00:34:33 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="O2/sxY9e"; dkim-atps=neutral Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DE61960AB1 for ; Fri, 21 Nov 2025 00:34:31 +0100 (CET) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-477a219dbcaso13868525e9.3 for ; Thu, 20 Nov 2025 15:34:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763681671; x=1764286471; 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=TkT+a2CnUga2pQvVkMr1EpE/d+TJ7UNDIhvUEz6eS0s=; b=O2/sxY9eGLmHh0HfIXCthu2t9y/p2di8r9LZZnMgRvXCJOESwQ1dMSamYaOrgeW6ro 9bjRQpBQQxP6H/AE5oYLZtkbBs/FdPHqx4kbknyudvhFyZs0GcWqa2eJgjOC1Xmqoe3T jrNEbVCBhLEWvt1I2toERHy1NZtSo4AAEg7ql9W0fE0p/HS46rf7ckwFhqGTLlzsR4Hu baZ6Qyx6l/XCi5P0vOYDkj10yxak8+SNSfRy6NiqaEptG94e+Qwq8dzzCGQ6qEK/uPIc lZCMm6kDlTqAWpdgfkNx1up+7+QOgivNBMOAsJBvGFgg2ucS84Uuu4gxTUAWEeCRRDp+ okfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763681671; x=1764286471; 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=TkT+a2CnUga2pQvVkMr1EpE/d+TJ7UNDIhvUEz6eS0s=; b=eOFphUV1Tytkz36Yx8G1Gqd0iLllHuWRsE0a/ygHOARXxTpM1BHuW6IGRV9HGnYvtC RTEJk3HFqBFTrdhuNdnFAFfhmY+1EKpyjQ4lSQqP3fe9iYAFwAiN50Tti+pJhJbOjLoG VlkizFLLJataVhqGZNrQMk2zDFRr1shDp3+4H655YQVsKcvTjudmqLiJf2BsDm3OTAo/ WTYsDLPr7Cd4KJBDxd5JN5Q22SY83Tkqz9RjZfd38b5eanS4msiQigaSWqyqlshBrQhg qFyYiYKkePEVoulP7eMbsoUhneJGPTcL3MVsYRfM5m5Zeh9LF1OvmGJ6xiwKaiElE/Fo lWvw== X-Gm-Message-State: AOJu0Yygm9C5nR97s+aw+ujTDWzxlW41eDD4dIHM4JVoEZ8BeK1ViJWz c7WEAY9aQTpR23tvAJEXKpeRLt9DknvS2qXZdObAi/viutELXhI6KJ/cXpZ+XQEVkQhonyGTo9r iaS70+s8= X-Gm-Gg: ASbGncthvHbzzN1FjGVL9RuDkBZrcJ3+Zj+Rb8NFGq3Xso0uFx0N2/xEI6OwgvBrxrQ taLo2O595Hrgj3NpTaQUwy9VZ8uubX9x3Hw9SQI01KydMvw/oVwq35SaLnEJN1+G53o3LBJvI7s hKeqbDVxxmCgR0nKY6lK1ofLiEQ3ioHpqUkfLmczyzFSkwIg7BO7YeLOIlXsf10/3d0DSG6AsNE r03u7dBEEbhwXuFjRXjkkts85yM5GN0mSqs2b7Ef7Na4DJ5XYKLYP9lrdbNYxOms+ceZltw8qrZ UiLAEd1oZQ4x+gMBD+ZsR/9MediOKtjIiGb5IdKi+G7c3yF86Ri/g/+6Z92yX1YwfYWQZVgYkDj U2nvbtUrAbpixiLz93yWMJiHI85ZUlLgDiOBvgPoLib80zCO+SIZj8f8Wg4IDTum6T9Y1wdvWiu cAbZ0InSfA8cZbILIbc75lqcdEu5gxGzSEPpNhgKhKj1iVWwjYId8weRgPnDf/QMTm2L4= X-Google-Smtp-Source: AGHT+IFMHx96olIGmPLnBgM6g1PRvACossLASN4JRzbSuK3kw+bE7TBrQUO2rzzvqvR1p4dOECR2SA== X-Received: by 2002:a05:600c:3110:b0:477:b734:8c52 with SMTP id 5b1f17b1804b1-477c0185bebmr3513425e9.14.1763681671261; Thu, 20 Nov 2025 15:34:31 -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 ffacd0b85a97d-42cb7fa3a81sm7984139f8f.26.2025.11.20.15.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 15:34:30 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v4 21/23] ipa: libipa: module: Add createSelfEnumeratingAlgorithm Date: Thu, 20 Nov 2025 23:33:45 +0000 Message-ID: <20251120233347.5046-22-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251120233347.5046-1-bryan.odonoghue@linaro.org> References: <20251120233347.5046-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" Signed-off-by: Bryan O'Donoghue --- src/ipa/libipa/module.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h index 0fb51916f..d11e189bc 100644 --- a/src/ipa/libipa/module.h +++ b/src/ipa/libipa/module.h @@ -70,6 +70,47 @@ public: factories().push_back(factory); } + /** + * \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 + */ + int createSelfEnumeratingAlgorithm(Context &context, const std::string &name) + { + std::unique_ptr> algo = createAlgorithm(name); + if (!algo) { + LOG(IPAModuleAlgo, Error) + << "Algorithm '" << name << "' not found"; + return -EINVAL; + } + + int ret = algo->init(context); + if (ret) { + LOG(IPAModuleAlgo, Error) + << "Algorithm '" << name << "' failed to initialize"; + return ret; + } + + LOG(IPAModuleAlgo, Debug) + << "Instantiated algorithm '" << name << "'"; + + algorithms_.push_back(std::move(algo)); + return 0; + } + private: int createAlgorithm(Context &context, const YamlObject &data) {