From patchwork Thu Nov 24 11:38:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17885 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 38EDFBE08B for ; Thu, 24 Nov 2022 11:39:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EF0E763322; Thu, 24 Nov 2022 12:39:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669289952; bh=8z9Pg26OhL7BSdfCL90aqbUPTDgCVV/fuwPpHgrpg+E=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=v26EcnEOifjV+S4TEUwiAFpdAEjixBaFKUPuoq67+8xryvz0mKe3qjUqMrWVtoKHh ksF9DdB0cyqolyEc1pNKvMOx7XVMlP8kN/hhFwlZI6JmNzeo5ZI8pY26lg+VV+Gkk9 szMdGoxm0y/0JS+YBJO6bbr6OdCO3w7EjVi+mlplmSA+HyU6qzkQRDYCKmDyiTKIlx dcM86XxAFvQqV2tFRWr99u2Gc3KOf1Y8nbxhX6h1QLLHkQ5q7Ri2Oc7s0pfO1HJzPe RC5VUJrLjv3IMYRuM41ydLH/fFdp7BUgB9WhNS1/VFTSrDc5nIjj+Z6octx72D+qk0 UD3Ou6GBIAeAw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F36A96331C for ; Thu, 24 Nov 2022 12:39:09 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RVa8IHwl"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C6EAA496; Thu, 24 Nov 2022 12:39:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669289949; bh=8z9Pg26OhL7BSdfCL90aqbUPTDgCVV/fuwPpHgrpg+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RVa8IHwlGjOlDAFFKmcvegF1PJNOvyH7rxGZ6TmECPrXwLk/7bHDd78xeBsmaEJ6o leq7tBo5dr/w54L7Ty/e0kNzeaJw5TMYGPMYOxvfXwL6zvhCx4FsoHR7tpmFHX1lgy RtzeMthtANWh55A/Ly/NC08F/t0GPgGxVQ9ucMVc= 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 Subject: [libcamera-devel] [PATCH 6/6] utils: libtuning: Get debug parameters from cli arguments 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Get the debug parameters for enabling per-module debug from command line arguments. Signed-off-by: Paul Elder --- utils/tuning/libtuning/libtuning.py | 40 ++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/utils/tuning/libtuning/libtuning.py b/utils/tuning/libtuning/libtuning.py index 469e6940..6d616ddb 100644 --- a/utils/tuning/libtuning/libtuning.py +++ b/utils/tuning/libtuning/libtuning.py @@ -5,6 +5,7 @@ # libtuning.py - An infrastructure for camera tuning tools import argparse +from pathlib import Path import libtuning as lt import libtuning.utils as utils @@ -20,10 +21,6 @@ class Color(IntEnum): B = 3 -class Debug(Enum): - Plot = 1 - - # @brief What to do with the leftover pixels after dividing them into ALSC # sectors, when the division gradient is uniform # @var Float Force floating point division so all sectors divide equally @@ -157,6 +154,23 @@ class Tuner(object): # we want a better logging infrastructure with log levels parser.add_argument('-l', '--log', type=str, default=None, help='Output log file (optional)') + parser.add_argument('-dd', '--debug_dir', type=str, default=None, + help='''Debug output directory (optional). + If the directory does not exist, it will be + created (including parent directories). If + the directory already exists, any existing + contents will be overwritten.''') + module_list = [module.type for module in self.modules] + module_list.append('macbeth') + module_list.sort() + parser.add_argument('-do', '--debug_opt', type=str, default='', + help=f'''Debug option string (optional). + Comma-separated (without spaces) list of module names + for which debug output should be enabled. If this + option is not provided but --debug_dir is, then all + modules will have debug output enabled. This option + will not do anything if --debug_dir is not specified. + Available modules: {module_list}''') return parser.parse_args(argv[1:]) def run(self, argv): @@ -181,11 +195,29 @@ class Tuner(object): if module in self.modules: self.modules.remove(module) + # Prepare debug + module_debug_list = args.debug_opt.split(',') + if '' in module_debug_list: + module_debug_list.remove('') + + if args.debug_dir is not None: + debug_dir = Path(args.debug_dir) + if not debug_dir.is_dir(): + debug_dir.mkdir() + + # Validate modules and set debug for module in self.modules: if not module.validate_config(self.config): eprint(f'Config is invalid for module {module.type}') return -1 + if args.debug_dir is not None and \ + (len(module_debug_list) == 0 or module.type in module_debug_list): + module_debug_dir = debug_dir / module.type + if not module_debug_dir.is_dir(): + module_debug_dir.mkdir() + module.enable_debug(module_debug_dir) + has_lsc = any(isinstance(m, lt.modules.lsc.LSC) for m in self.modules) # Only one LSC module allowed has_only_lsc = has_lsc and len(self.modules) == 1