{"id":17885,"url":"https://patchwork.libcamera.org/api/1.1/patches/17885/?format=json","web_url":"https://patchwork.libcamera.org/patch/17885/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20221124113849.2193579-7-paul.elder@ideasonboard.com>","date":"2022-11-24T11:38:49","name":"[libcamera-devel,6/6] utils: libtuning: Get debug parameters from cli arguments","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ec7c81b53be1c7d9628202e69ff1d78d613c108f","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17885/mbox/","series":[{"id":3637,"url":"https://patchwork.libcamera.org/api/1.1/series/3637/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3637","date":"2022-11-24T11:38:43","name":"utils: tuning: Add per-module debugging","version":1,"mbox":"https://patchwork.libcamera.org/series/3637/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17885/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17885/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 38EDFBE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Nov 2022 11:39:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EF0E763322;\n\tThu, 24 Nov 2022 12:39:11 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F36A96331C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 12:39:09 +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 C6EAA496;\n\tThu, 24 Nov 2022 12:39:08 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669289952;\n\tbh=8z9Pg26OhL7BSdfCL90aqbUPTDgCVV/fuwPpHgrpg+E=;\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=v26EcnEOifjV+S4TEUwiAFpdAEjixBaFKUPuoq67+8xryvz0mKe3qjUqMrWVtoKHh\n\tksF9DdB0cyqolyEc1pNKvMOx7XVMlP8kN/hhFwlZI6JmNzeo5ZI8pY26lg+VV+Gkk9\n\tszMdGoxm0y/0JS+YBJO6bbr6OdCO3w7EjVi+mlplmSA+HyU6qzkQRDYCKmDyiTKIlx\n\tdcM86XxAFvQqV2tFRWr99u2Gc3KOf1Y8nbxhX6h1QLLHkQ5q7Ri2Oc7s0pfO1HJzPe\n\tRC5VUJrLjv3IMYRuM41ydLH/fFdp7BUgB9WhNS1/VFTSrDc5nIjj+Z6octx72D+qk0\n\tUD3Ou6GBIAeAw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669289949;\n\tbh=8z9Pg26OhL7BSdfCL90aqbUPTDgCVV/fuwPpHgrpg+E=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=RVa8IHwlGjOlDAFFKmcvegF1PJNOvyH7rxGZ6TmECPrXwLk/7bHDd78xeBsmaEJ6o\n\tleq7tBo5dr/w54L7Ty/e0kNzeaJw5TMYGPMYOxvfXwL6zvhCx4FsoHR7tpmFHX1lgy\n\tRtzeMthtANWh55A/Ly/NC08F/t0GPgGxVQ9ucMVc="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"RVa8IHwl\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 24 Nov 2022 20:38:49 +0900","Message-Id":"<20221124113849.2193579-7-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20221124113849.2193579-1-paul.elder@ideasonboard.com>","References":"<20221124113849.2193579-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 6/6] utils: libtuning: Get debug\n\tparameters from cli arguments","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":"Get the debug parameters for enabling per-module debug from command line\narguments.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n utils/tuning/libtuning/libtuning.py | 40 ++++++++++++++++++++++++++---\n 1 file changed, 36 insertions(+), 4 deletions(-)","diff":"diff --git a/utils/tuning/libtuning/libtuning.py b/utils/tuning/libtuning/libtuning.py\nindex 469e6940..6d616ddb 100644\n--- a/utils/tuning/libtuning/libtuning.py\n+++ b/utils/tuning/libtuning/libtuning.py\n@@ -5,6 +5,7 @@\n # libtuning.py - An infrastructure for camera tuning tools\n \n import argparse\n+from pathlib import Path\n \n import libtuning as lt\n import libtuning.utils as utils\n@@ -20,10 +21,6 @@ class Color(IntEnum):\n     B = 3\n \n \n-class Debug(Enum):\n-    Plot = 1\n-\n-\n # @brief What to do with the leftover pixels after dividing them into ALSC\n #        sectors, when the division gradient is uniform\n # @var Float Force floating point division so all sectors divide equally\n@@ -157,6 +154,23 @@ class Tuner(object):\n         # we want a better logging infrastructure with log levels\n         parser.add_argument('-l', '--log', type=str, default=None,\n                             help='Output log file (optional)')\n+        parser.add_argument('-dd', '--debug_dir', type=str, default=None,\n+                            help='''Debug output directory (optional).\n+                                    If the directory does not exist, it will be\n+                                    created (including parent directories).  If\n+                                    the directory already exists, any existing\n+                                    contents will be overwritten.''')\n+        module_list = [module.type for module in self.modules]\n+        module_list.append('macbeth')\n+        module_list.sort()\n+        parser.add_argument('-do', '--debug_opt', type=str, default='',\n+                            help=f'''Debug option string (optional).\n+                                     Comma-separated (without spaces) list of module names\n+                                     for which debug output should be enabled. If this\n+                                     option is not provided but --debug_dir is, then all\n+                                     modules will have debug output enabled. This option\n+                                     will not do anything if --debug_dir is not specified.\n+                                     Available modules: {module_list}''')\n         return parser.parse_args(argv[1:])\n \n     def run(self, argv):\n@@ -181,11 +195,29 @@ class Tuner(object):\n             if module in self.modules:\n                 self.modules.remove(module)\n \n+        # Prepare debug\n+        module_debug_list = args.debug_opt.split(',')\n+        if '' in module_debug_list:\n+            module_debug_list.remove('')\n+\n+        if args.debug_dir is not None:\n+            debug_dir = Path(args.debug_dir)\n+            if not debug_dir.is_dir():\n+                debug_dir.mkdir()\n+\n+        # Validate modules and set debug\n         for module in self.modules:\n             if not module.validate_config(self.config):\n                 eprint(f'Config is invalid for module {module.type}')\n                 return -1\n \n+            if args.debug_dir is not None and \\\n+               (len(module_debug_list) == 0 or module.type in module_debug_list):\n+                module_debug_dir = debug_dir / module.type\n+                if not module_debug_dir.is_dir():\n+                    module_debug_dir.mkdir()\n+                module.enable_debug(module_debug_dir)\n+\n         has_lsc = any(isinstance(m, lt.modules.lsc.LSC) for m in self.modules)\n         # Only one LSC module allowed\n         has_only_lsc = has_lsc and len(self.modules) == 1\n","prefixes":["libcamera-devel","6/6"]}