[{"id":37270,"web_url":"https://patchwork.libcamera.org/comment/37270/","msgid":"<85ldja2rwz.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-12-10T17:00:28","subject":"Re: [PATCH v7 21/26] ipa: libipa: module: Add\n\tcreateSelfEnumeratingAlgorithm","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:\n\n> Create an algorithm without having YAML data input.\n>\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>  src/ipa/libipa/module.h | 45 +++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 45 insertions(+)\n>\n> diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h\n> index c27af7718..c5767c6f3 100644\n> --- a/src/ipa/libipa/module.h\n> +++ b/src/ipa/libipa/module.h\n> @@ -70,6 +70,51 @@ public:\n>  \t\tfactories().push_back(factory);\n>  \t}\n>  \n> +\t/**\n> +\t * \\fn int Module::createSelfEnumeratingAlgorithm(Context &context, const std::string &name)\n> +\t * \\brief Create and initialise a self-enumerating algorithm by name\n> +\t *\n> +\t * This function creates an algorithm instance from the registered algorithm\n> +\t * factories using only the algorithm name, without requiring YAML configuration\n> +\t * data.\n> +\t *\n> +\t * This is useful for algorithms that don't require external configuration\n> +\t * parameters and can self-configure or use default values.\n> +\t *\n> +\t * \\param[in] context The IPA context to pass to the algorithm's init function\n> +\t * \\param[in] name The name of the algorithm to instantiate\n> +\t *\n> +\t * \\return 0 on success, negative errno value on failure:\n> +\t *         -EINVAL if the algorithm is not found in the factory registry\n> +\t *         Other negative values if algorithm initialisation fails\n> +\t */\n\nThe docstring should go to the .cpp file.\n\n> +\tint createSelfEnumeratingAlgorithm(Context &context, const std::string &name)\n> +\t{\n> +\t\tYamlObject dummy;\n> +\n> +\t\tstd::unique_ptr<Algorithm<Module>> algo = createAlgorithm(name);\n> +\t\tif (!algo) {\n> +\t\t\tLOG(IPAModuleAlgo, Error)\n> +\t\t\t\t<< \"Algorithm '\" << name << \"' not found\";\n> +\t\t\treturn -EINVAL;\n> +\t\t}\n> +\n> +\t\tcontext.selfInitialising = true;\n> +\n> +\t\tint ret = algo->init(context, dummy);\n> +\t\tif (ret) {\n> +\t\t\tLOG(IPAModuleAlgo, Error)\n> +\t\t\t\t<< \"Algorithm '\" << name << \"' failed to initialize\";\n> +\t\t\treturn ret;\n> +\t\t}\n> +\n> +\t\tLOG(IPAModuleAlgo, Debug)\n> +\t\t\t<< \"Instantiated algorithm '\" << name << \"'\";\n> +\n> +\t\talgorithms_.push_back(std::move(algo));\n> +\t\treturn 0;\n> +\t}\n\nHmm, this code duplication doesn't feel good.  For example, it already\nomits the change that allows disabling algorithms in the tuning file; or\nis it on purpose?  I should look into my simple algorithms refactoring\nand think more whether there is a chance to find a better mechanism.\n\n>  private:\n>  \tint createAlgorithm(Context &context, const YamlObject &data)\n>  \t{","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CA117BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Dec 2025 17:00:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1E7F6614B2;\n\tWed, 10 Dec 2025 18:00:37 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DEE0F61499\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Dec 2025 18:00:34 +0100 (CET)","from mail-ed1-f69.google.com (mail-ed1-f69.google.com\n\t[209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-211-Y5RgACdlN2C_fEG42L39pQ-1; Wed, 10 Dec 2025 12:00:32 -0500","by mail-ed1-f69.google.com with SMTP id\n\t4fb4d7f45d1cf-640b06fa998so55913a12.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Dec 2025 09:00:32 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb ([213.175.46.86])\n\tby smtp.gmail.com with ESMTPSA id\n\ta640c23a62f3a-b7cfa56c152sm5430266b.56.2025.12.10.09.00.28\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 10 Dec 2025 09:00:29 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"Akf5yY0g\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1765386033;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=VxuzwB84GfOfGRkdqphmK1re3x3hO4ZUfUC8ug64e0g=;\n\tb=Akf5yY0gWUOhH9giWC0usw5xaL0Xv8WlV9w0dzO1po8yqprPbzXq3VD766rBRR57y09FHI\n\tqKd/8aYwDVGtdekmFHh9jLu/SwOjj1YyKEik0kWGUK0bOWXoxm5b6O+PyCjPfZVCrVV/LY\n\tUdl9t9MUwkYk/vov1dG+wv+4AIKmros=","X-MC-Unique":"Y5RgACdlN2C_fEG42L39pQ-1","X-Mimecast-MFC-AGG-ID":"Y5RgACdlN2C_fEG42L39pQ_1765386031","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1765386031; x=1765990831;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject\n\t:date:message-id:reply-to;\n\tbh=VxuzwB84GfOfGRkdqphmK1re3x3hO4ZUfUC8ug64e0g=;\n\tb=Gzrdl3L/rj3c9p07/P92beJhj5VtgolW4BidhkRUAbfwRWuk0pjNqtiZBA5GfdXnld\n\t+WSbUg6htQe3m+psW8lAc1hvgkGduX8kaEh2VPs2UKQ2QEW82DABmO/qJkyqPoVO5Ki9\n\tvxbWqqgmyjcesmmCYHvzz46MXbkIGbjaqHBIPLSQITZ0Z5uM3SYX4Xno830lRLi2xAsn\n\t51dCzsjgg7JSJ/eV6nt/VWAg33cfAkUwoXiJ6o+ZQdfKu0TooYqJ901vg08nr03hAUEY\n\tJGbKvCwQ/s7eCp8KZ6ccWV5uk3WoQ2+kZt5H/9zX8/6yC7HwUc8qQIJ3vHjZFusz7nCq\n\tOkqg==","X-Gm-Message-State":"AOJu0Yx9pXy5ow9y07LDE2+MrVgbygH/Fh/iwghP7RamX2LTiyF1ztXB\n\t6QaQb1+k+42qbIFKu0JDudKB3FZtSsG2RMMI6DpeP7UqmWcz5ZhRWkkHghkJ0kDdUxc2SKeT0In\n\t0x/H+hrgL9UBhyQNeveoykfzfUsFrUjwIwKKL8tgvsvLTZ7hURy9vM5MF8vs57YyCsxDD1TizHD\n\t8=","X-Gm-Gg":"ASbGncvWW4zUIYgHBFUIsntyMY646u7PtpalctmPvG4vXJ9uiUKzXHS1Rj6QC+9pipD\n\tdp/4PXZvlyIWgJzoIzEjhmy32c5MP+9xkUhpfJtDBojm4S8JORKSd435SY9o4wDbOG/y8Ia28x5\n\tHagzSn+SdTsX8QF0hRmE5CkuaSdQWs1qOMqpI5ll9fHdtEKPvUVz1VV1D7lsn9DUpACbn2AWgjW\n\twa0zbKIInF4oH9Cx2zm+3DFUTKVJaj+UxZhipgJthpQfoE1wxe5tQYfnAgZrY4CfWe0fHq/mCgU\n\t4qmOmXEYXTYSQEDzNsAtYCkOUSz4A6NRj2lR8WGQ3yNqcoN2MyhWv3Q19jtb5+/qlOaOd75pz+C\n\tFPGRlerAfjGOLfNAxxjCqm8W8mA==","X-Received":["by 2002:a17:907:6e94:b0:b73:572d:3aff with SMTP id\n\ta640c23a62f3a-b7ce841ce0emr296575866b.35.1765386031000; \n\tWed, 10 Dec 2025 09:00:31 -0800 (PST)","by 2002:a17:907:6e94:b0:b73:572d:3aff with SMTP id\n\ta640c23a62f3a-b7ce841ce0emr296566466b.35.1765386029545; \n\tWed, 10 Dec 2025 09:00:29 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IHgJYrNfXEDHwgtb92Ui8HQYgAwKpT8BRc/Wmb5kHa+aefk/5Unj6rSBwyM7JIMvEbKXjS4Tw==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Cc":"libcamera-devel@lists.libcamera.org,  pavel@ucw.cz","Subject":"Re: [PATCH v7 21/26] ipa: libipa: module: Add\n\tcreateSelfEnumeratingAlgorithm","In-Reply-To":"<20251210005354.44726-22-bryan.odonoghue@linaro.org> (Bryan\n\tO'Donoghue's message of \"Wed, 10 Dec 2025 00:53:49 +0000\")","References":"<20251210005354.44726-1-bryan.odonoghue@linaro.org>\n\t<20251210005354.44726-22-bryan.odonoghue@linaro.org>","Date":"Wed, 10 Dec 2025 18:00:28 +0100","Message-ID":"<85ldja2rwz.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"gwlKu1qcc0ET0RkdDM13bDcbjoGvCY4GxoKQLGcaLXA_1765386031","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]