{"id":17869,"url":"https://patchwork.libcamera.org/api/patches/17869/?format=json","web_url":"https://patchwork.libcamera.org/patch/17869/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20221124113550.2182342-4-paul.elder@ideasonboard.com>","date":"2022-11-24T11:35:41","name":"[libcamera-devel,v4,03/12] utils: tuning: libtuning: Implement extensible components of libtuning","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"7c6a793e0fd3667f17fa8398b7aba09a21a8e5d8","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17869/mbox/","series":[{"id":3636,"url":"https://patchwork.libcamera.org/api/series/3636/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3636","date":"2022-11-24T11:35:38","name":"utils: tuning: Add a new tuning infrastructure","version":4,"mbox":"https://patchwork.libcamera.org/series/3636/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17869/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17869/checks/","tags":{},"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 CC7D9BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Nov 2022 11:36:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8549C6331E;\n\tThu, 24 Nov 2022 12:36:09 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5D08963313\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 12:36:07 +0100 (CET)","from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D9E83978;\n\tThu, 24 Nov 2022 12:36:05 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669289769;\n\tbh=uMF4yPAsf6dMznZ6bfLD1kk7MDTUzoZIP5Re5PNa1xw=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=R67CEY7RgbPPXMjczkhXJEmdshYsdGllzq7FIaQbZBx74x2zyk6xyAHwSsNJiSWLC\n\tgCjzQoveusZZ8sjxT2YTf/E3wnxNQsWlIWNKi4zk+atia8XlWkxUNjl1nzezq0XcNS\n\tuWwX2wM2tRry2JeqBJ28RWxWl4MUsTPM5Q7MWSaT91QOeIEOwKGrpDKaUe+ne/0uXn\n\tsCzpm3FSgynyCROHfLVgzsQBTX4qx9tEVYfbwIzjOcF2X7e2XVh+U4fOGLG/Nyrk+B\n\tjNuLd+QkNnjbkZSMRjpF6I9gwxpEooUp6KV8N27nwO3RTcMekdsu6xO94AmPXVfS+e\n\tx+bxdu9O6sEdg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669289767;\n\tbh=uMF4yPAsf6dMznZ6bfLD1kk7MDTUzoZIP5Re5PNa1xw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=K99SPmfRdx1HLom9SJbpCL5KjRSR013BQWHIGZaWFqyDWeoy3RXdz/392KSyEvhOT\n\tRakDa3s0itR9XQ1j4y5ifbYyWvVu+U8d2a/BeHPmzRjDWDcg/mNaxjlZ6mYPAXaCgu\n\tiAn8JLsdEUPEQS0NgZj1CMxCG63U4fe6JmqDnb7k="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"K99SPmfR\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 24 Nov 2022 20:35:41 +0900","Message-Id":"<20221124113550.2182342-4-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20221124113550.2182342-1-paul.elder@ideasonboard.com>","References":"<20221124113550.2182342-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 03/12] utils: tuning: libtuning:\n\tImplement extensible components of libtuning","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Paul Elder <paul.elder@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Implement the extensible components of libtuning. This includes:\n- Parsers, for supporting different types of input config file formats\n- Generators, for supporting different types of output tuning file\n  formats\n- Modules, for supporting different tuning modules for different\n  algorithms and platforms\n\nNo parsers, generators, or modules are actually implemented. Only the\nbase classes are implemented.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\nChanges in v4:\n- Add license to generator __init__.py (it was around, just in a later\n  patch)\n- remove cli args from module.process parameters\n\nChanges in v3:\n- Newly split from the first patch \"utils: tuning: libtuning: Implement\n  the core of libtuning\"\n  - See changelog from that patch\n---\n utils/tuning/libtuning/generators/__init__.py |  3 ++\n .../tuning/libtuning/generators/generator.py  | 15 +++++++++\n utils/tuning/libtuning/modules/__init__.py    |  0\n utils/tuning/libtuning/modules/module.py      | 32 +++++++++++++++++++\n utils/tuning/libtuning/parsers/__init__.py    |  0\n utils/tuning/libtuning/parsers/parser.py      | 21 ++++++++++++\n 6 files changed, 71 insertions(+)\n create mode 100644 utils/tuning/libtuning/generators/__init__.py\n create mode 100644 utils/tuning/libtuning/generators/generator.py\n create mode 100644 utils/tuning/libtuning/modules/__init__.py\n create mode 100644 utils/tuning/libtuning/modules/module.py\n create mode 100644 utils/tuning/libtuning/parsers/__init__.py\n create mode 100644 utils/tuning/libtuning/parsers/parser.py","diff":"diff --git a/utils/tuning/libtuning/generators/__init__.py b/utils/tuning/libtuning/generators/__init__.py\nnew file mode 100644\nindex 00000000..9ccabb0e\n--- /dev/null\n+++ b/utils/tuning/libtuning/generators/__init__.py\n@@ -0,0 +1,3 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>\ndiff --git a/utils/tuning/libtuning/generators/generator.py b/utils/tuning/libtuning/generators/generator.py\nnew file mode 100644\nindex 00000000..7c8c9b99\n--- /dev/null\n+++ b/utils/tuning/libtuning/generators/generator.py\n@@ -0,0 +1,15 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>\n+#\n+# generator.py - Base class for a generator to convert dict to tuning file\n+\n+from pathlib import Path\n+\n+\n+class Generator(object):\n+    def __init__(self):\n+        pass\n+\n+    def write(self, output_path: Path, output_dict: dict, output_order: list):\n+        raise NotImplementedError\ndiff --git a/utils/tuning/libtuning/modules/__init__.py b/utils/tuning/libtuning/modules/__init__.py\nnew file mode 100644\nindex 00000000..e69de29b\ndiff --git a/utils/tuning/libtuning/modules/module.py b/utils/tuning/libtuning/modules/module.py\nnew file mode 100644\nindex 00000000..12e2fc7c\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/module.py\n@@ -0,0 +1,32 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>\n+#\n+# module.py - Base class for algorithm-specific tuning modules\n+\n+\n+# @var type Type of the module. Defined in the base module.\n+# @var out_name The key that will be used for the algorithm in the algorithms\n+#               dictionary in the tuning output file\n+# @var hr_name Human-readable module name, mostly for debugging\n+class Module(object):\n+    type = 'base'\n+    hr_name = 'Base Module'\n+    out_name = 'GenericAlgorithm'\n+\n+    def __init__(self):\n+        pass\n+\n+    def validate_config(self, config: dict) -> bool:\n+        raise NotImplementedError\n+\n+    # @brief Do the module's processing\n+    # @param config Full configuration from the input configuration file\n+    # @param images List of images to process\n+    # @param outputs The outputs of all modules that were executed before this\n+    #                module. Note that this is an input parameter, and the\n+    #                output of this module should be returned directly\n+    # @return Result of the module's processing. It may be empty. None\n+    #         indicates failure and that the result should not be used.\n+    def process(self, config: dict, images: list, outputs: dict) -> dict:\n+        raise NotImplementedError\ndiff --git a/utils/tuning/libtuning/parsers/__init__.py b/utils/tuning/libtuning/parsers/__init__.py\nnew file mode 100644\nindex 00000000..e69de29b\ndiff --git a/utils/tuning/libtuning/parsers/parser.py b/utils/tuning/libtuning/parsers/parser.py\nnew file mode 100644\nindex 00000000..a17d8d71\n--- /dev/null\n+++ b/utils/tuning/libtuning/parsers/parser.py\n@@ -0,0 +1,21 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>\n+#\n+# parser.py - Base class for a parser for a specific format of config file\n+\n+class Parser(object):\n+    def __init__(self):\n+        pass\n+\n+    # @brief Parse a config file into a config dict\n+    # @details The config dict shall have one key 'general' with a dict value\n+    #          for general configuration options, and all other entries shall\n+    #          have the module as the key with its configuration options (as a\n+    #          dict) as the value. The config dict shall prune entries that are\n+    #          for modules that are not in @a modules.\n+    # @param config (str) Path to config file\n+    # @param modules (list) List of modules\n+    # @return (dict, list) Configuration and list of modules to disable\n+    def parse(self, config_file: str, modules: list) -> (dict, list):\n+        raise NotImplementedError\n","prefixes":["libcamera-devel","v4","03/12"]}