From patchwork Tue Nov 21 14:53:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19218 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 2C6EFC32B6 for ; Tue, 21 Nov 2023 14:54:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A9C861DAE; Tue, 21 Nov 2023 15:54:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1700578440; bh=u1pzwaJCyQvFTyvZsijtKDuzg3WHLwqOttR93D7fqk8=; 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=NIeg185CnTEazeZol6kKLy9gyzgLy+1WW9L/3aKlickd18tU2o8YZtDPO9YK5RE90 odsItdpYDxc+bJkYOS5Qd8G1ZU8MnXZoZ5aiS1PfpHmC/UYo0wWLsZM3yG6b2yd944 FfT19sCqGnxvx7dVfAzs8tLEJWVl2AWHplZg9y/xH4DqEeSPE/4caxkVJNAa5B2DqI mX0tWUKpboWzed1cZBBguqDCBbI30tc3kDlZezymv7bOuitmS8+xkGus1cc8R0R+/3 4wNbswhy8+8a8AQqAzxzVMK2Z98+LHrFtJ9eQVt9yZ8tYGw7g36ldpKUamoLxOBRVF eBgkaAEpAwUPw== Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A8656629C2 for ; Tue, 21 Nov 2023 15:53:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="flyltw9h"; dkim-atps=neutral Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40859c464daso25602965e9.1 for ; Tue, 21 Nov 2023 06:53:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1700578438; x=1701183238; 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=ktpi15tBs8cYjJhOKHEBmP3OaeY5TzoUYnry6TQur+I=; b=flyltw9h9rMHcLxO4G5ATtNuI5+3v6312zL0b2/PQMNESFCfF16AXY5valx6yj/ETq IGGjiEU425wqsBDTLWZYAhIaP4Jq2l8DojrlIcoMKb9mKTh2k2C1UYkcHDCIp73XXVQK NuTC9RX722dmrP7hZgpi/Tyy4qVfMTXlaavHJ9ZHFF8plmGHVEz5TIBgXFMCPsRZFWJl tLvfR1vmbI8U0jxjupv9Mc/EAFb6cEFBPvxN3G667m3Tr4tPz8xZLVLCmKZXQH9CoXqN wgCyLEdJPoHyJ9V2+DtsY/e3KSx849ZqXm9BbBzO15MKRwGfE6ybHqua3sr/ee/zeZZE LcEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700578438; x=1701183238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ktpi15tBs8cYjJhOKHEBmP3OaeY5TzoUYnry6TQur+I=; b=jsk6oYlffKswRNXEeJwNSzm7MhTn56cqZDiEt2Gnzl4yPEj8aWb/TovDPCOwCeyysf vvvzu2MHuOHsuAUDxAietTLm1/fGewXmNbQEn7OlwZQ0ftt17OyK4ckXc/GMgvcgMcY9 Pcaahc6gV0kDFCqqZ8iNLVbf8khvwUvlPPY3tfjXWcMj8V1fYGDffHIyJLFqA8NYqtMB Y8WihY6hyXEIuRqHPBX/+7EwBilvIs7yJvQoSyBsuSfnwo+xg6dretHTkzEoX+NBUpSh y8NCRvQYa0nfPH9nSmXbv167+mQm92vfGxGoHsDXDrLtaAbHHwMU6IZSlk0cIemVwJyv 8zZA== X-Gm-Message-State: AOJu0YxMpBfWQYXb/mVmHHabWVczfz0ViatZTKJB5Yhg6wFT94OjqCWq HgMrKfm06iPiCKc6EWf8YF3UbrkjaIv+AVxV3eBIkA== X-Google-Smtp-Source: AGHT+IFipRwKbifJWtND2SAAyf0h08d+WsllpwBMmyFK1CCJ5a6HXLoyEPcLW9UBNr+besTwbYxXyQ== X-Received: by 2002:a05:600c:a02:b0:408:53d4:52dd with SMTP id z2-20020a05600c0a0200b0040853d452ddmr8050359wmp.22.1700578438025; Tue, 21 Nov 2023 06:53:58 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c351200b004063ea92492sm17570968wmq.22.2023.11.21.06.53.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:53:57 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Nov 2023 14:53:47 +0000 Message-Id: <20231121145350.5956-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231121145350.5956-1-naush@raspberrypi.com> References: <20231121145350.5956-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/6] controls: build: Allow separate vendor control YAML files 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add support for using separate YAML files for vendor specific controls. This simplifies management of vendor control definitions and avoids possible merge conflicts when changing the control_ids.yaml file for core and draft controls. The mapping of vendor/pipeline handler to control file is done through the vendor_controls_mapping variable in include/libcamera/meson.build. Add a new control_ids_rpi.yaml file to hold the Raspberry Pi specific vendor controls. This contains a single control PispConfigDumpFile that will be used in the Pi 5 pipeline handler as a trigger to dump the Backend configuration as a JSON file. Signed-off-by: Naushir Patuck --- include/libcamera/meson.build | 42 ++++++++++++++++++++++++++++- meson.build | 2 ++ src/libcamera/control_ids_rpi.yaml | 16 +++++++++++ src/libcamera/meson.build | 12 +++++++++ src/py/libcamera/gen-py-controls.py | 10 +++---- src/py/libcamera/meson.build | 8 ++++++ utils/gen-controls.py | 12 +++++---- 7 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 src/libcamera/control_ids_rpi.yaml diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 5fb772e6dd14..54123c5b858d 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -38,10 +38,50 @@ control_source_files = { 'property_ids': 'properties', } +vendor_controls_mapping = { + # Mapping of vendor (pipeline handler) specific controls files + 'controls': + { + 'rpi/pisp': 'control_ids_rpi.yaml', + 'rpi/vc4': 'control_ids_rpi.yaml' + }, + # Mapping of vendor (pipeline handler) specific properties files + 'properties': + { + + } +} + control_headers = [] +vendor_ctrl_files = [] +vendor_prop_files = [] foreach header, mode : control_source_files - input_files = files('../../src/libcamera/' + header +'.yaml') + + # Start by populating the vendor specific mappings into vendor_ctrl_files + # and vendor_prop_files. These will be cached for later use. + vendor_files = [] + foreach pipeline, file : vendor_controls_mapping[mode] + if pipeline not in pipelines + continue + endif + if file not in vendor_files + vendor_files += file + endif + endforeach + + if mode == 'controls' + vendor_ctrl_files = vendor_files + else + vendor_prop_files = vendor_files + endif + + input_files = files('../../src/libcamera/' + header + '.yaml') + + foreach file : vendor_files + input_files += files('../../src/libcamera/' + file) + endforeach + template_file = files(header + '.h.in') control_headers += custom_target(header + '_h', input : input_files, diff --git a/meson.build b/meson.build index e9a1c7e360ce..1423abf16c77 100644 --- a/meson.build +++ b/meson.build @@ -267,6 +267,8 @@ py_mod.find_installation('python3', modules : py_modules) summary({ 'Enabled pipelines': pipelines, 'Enabled IPA modules': enabled_ipa_names, + 'Vendor controls': vendor_ctrl_files, + 'Vendor properties': vendor_prop_files, 'Hotplug support': libudev.found(), 'Tracing support': tracing_enabled, 'Android support': android_enabled, diff --git a/src/libcamera/control_ids_rpi.yaml b/src/libcamera/control_ids_rpi.yaml new file mode 100644 index 000000000000..a6f8b43a5f62 --- /dev/null +++ b/src/libcamera/control_ids_rpi.yaml @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Copyright (C) 2023, Raspberry Pi Ltd +# +%YAML 1.1 +--- +vendor: rpi +controls: + - PispConfigDumpFile: + type: string + description: | + Triggers the Raspberry Pi PiSP pipeline handler to generate a JSON + formatted dump of the Backend configuration to the filename given by the + value of the control. + +... diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 05ee38daf22b..7eb26ccbb7f5 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -129,6 +129,18 @@ control_sources = [] foreach source, mode : control_source_files input_files = files(source +'.yaml') + + # Add the vendor specific files to the input. + if mode == 'controls' + vendor_files = vendor_ctrl_files + else + vendor_files = vendor_prop_files + endif + + foreach file : vendor_files + input_files += files(file) + endforeach + template_file = files(source + '.cpp.in') control_sources += custom_target(source + '_cpp', input : input_files, diff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/gen-py-controls.py index ea28f0139f23..e2ddad8581fd 100755 --- a/src/py/libcamera/gen-py-controls.py +++ b/src/py/libcamera/gen-py-controls.py @@ -91,7 +91,7 @@ def main(argv): parser = argparse.ArgumentParser() parser.add_argument('-o', dest='output', metavar='file', type=str, help='Output file name. Defaults to standard output if not specified.') - parser.add_argument('input', type=str, + parser.add_argument('input', type=str, nargs='+', help='Input file name.') parser.add_argument('-t', dest='template', type=str, required=True, help='Template file name.') @@ -103,11 +103,11 @@ def main(argv): print(f'Invalid mode option "{args.mode}"', file=sys.stderr) return -1 - data = open(args.input, 'rb').read() - controls = {} - vendor = yaml.safe_load(data)['vendor'] - controls[vendor] = yaml.safe_load(data)['controls'] + for input in args.input: + data = open(input, 'rb').read() + vendor = yaml.safe_load(data)['vendor'] + controls[vendor] = yaml.safe_load(data)['controls'] data = generate_py(controls, args.mode) diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build index 1c3ea1843ac0..ea38ad6ca829 100644 --- a/src/py/libcamera/meson.build +++ b/src/py/libcamera/meson.build @@ -33,6 +33,10 @@ gen_py_controls_template = files('py_controls_generated.cpp.in') gen_py_controls = files('gen-py-controls.py') +foreach file : vendor_ctrl_files + gen_py_controls_input_files += files('../../libcamera/' + file) +endforeach + pycamera_sources += custom_target('py_gen_controls', input : gen_py_controls_input_files, output : ['py_controls_generated.cpp'], @@ -44,6 +48,10 @@ pycamera_sources += custom_target('py_gen_controls', gen_py_property_enums_input_files = files('../../libcamera/property_ids.yaml') gen_py_properties_template = files('py_properties_generated.cpp.in') +foreach file : vendor_prop_files + gen_py_property_enums_input_files += files('../../libcamera/' + file) +endforeach + pycamera_sources += custom_target('py_gen_properties', input : gen_py_property_enums_input_files, output : ['py_properties_generated.cpp'], diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 8af33d29cd07..d7862142b8c1 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -359,7 +359,7 @@ def main(argv): parser = argparse.ArgumentParser() parser.add_argument('-o', dest='output', metavar='file', type=str, help='Output file name. Defaults to standard output if not specified.') - parser.add_argument('input', type=str, + parser.add_argument('input', type=str, nargs='+', help='Input file name.') parser.add_argument('-t', dest='template', type=str, required=True, help='Template file name.') @@ -367,10 +367,12 @@ def main(argv): help='Mode of operation') args = parser.parse_args(argv[1:]) - data = open(args.input, 'rb').read() - vendor = yaml.safe_load(data)['vendor'] - controls = yaml.safe_load(data)['controls'] - controls = [Control(*ctrl.popitem(), vendor) for ctrl in controls] + controls = [] + for input in args.input: + data = open(input, 'rb').read() + vendor = yaml.safe_load(data)['vendor'] + ctrls = yaml.safe_load(data)['controls'] + controls = controls + [Control(*ctrl.popitem(), vendor) for ctrl in ctrls] if args.template.endswith('.cpp.in'): data = generate_cpp(controls)