{"id":19195,"url":"https://patchwork.libcamera.org/api/1.1/patches/19195/?format=json","web_url":"https://patchwork.libcamera.org/patch/19195/","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":"<20231110110002.21381-3-naush@raspberrypi.com>","date":"2023-11-10T10:59:59","name":"[libcamera-devel,v1,2/5] controls: build: Allow separate vendor control YAML files","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"70c6f36137fd3a2ba0393d2eef8ed78afdd7cf9a","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19195/mbox/","series":[{"id":4068,"url":"https://patchwork.libcamera.org/api/1.1/series/4068/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4068","date":"2023-11-10T10:59:57","name":"Vendor controls and properties","version":1,"mbox":"https://patchwork.libcamera.org/series/4068/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19195/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19195/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 AAD85BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Nov 2023 11:00:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8A27A629AF;\n\tFri, 10 Nov 2023 12:00:02 +0100 (CET)","from mail-wm1-x331.google.com (mail-wm1-x331.google.com\n\t[IPv6:2a00:1450:4864:20::331])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 26FFB629C0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Nov 2023 11:59:59 +0100 (CET)","by mail-wm1-x331.google.com with SMTP id\n\t5b1f17b1804b1-408425c7c10so14343805e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Nov 2023 02:59:59 -0800 (PST)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tr15-20020a05600c35cf00b0040531f5c51asm4883156wmq.5.2023.11.10.02.59.57\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 10 Nov 2023 02:59:57 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1699614002;\n\tbh=FNFGzC5HF+ifNcYw5R4MlHlpFomJsHZkSQWiEXKPNHs=;\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=dbALBVYY7o6X5wP8U78nBvgXJ5C6vfKbgP3yS2TfPm3pMWnmBGXWeebqJNYZD4EQc\n\tn+XDrfccizGcOft4QqO/1LwLOc/JrC1NcQH8ZdQGKQmZV4ZTo4bgQL7SaJbz92wrUC\n\t0CTu6jYH3ynIPYKs37W9xXtG74c6z3IB+vc36o/ZuVg1YZXIZCMEnlcKbBMFF7nkbF\n\tlHJc6vZEp1cBF1MH2LCPHQ9cJQKpPrWHrpX+eBHEBym79CVuyfWT6lWyanXthLHjhj\n\tTbhgqmt+YXEspNmLFMjdUgYXiuNT2H8wnF1g2YdE7UNV8mUfrB8caGVoslXx4ZyTww\n\t8WKCNFw9KvpMg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1699613998; x=1700218798;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=7zG4YADsqfXxky8HV1UlKl3gSBl6yLhKvKdAQ0eg5Pw=;\n\tb=k3ZCJqV8fxEBn2f2uoU5LKnnra2Vcy8Mbg0Kq9LjrnybHdeDiQPwvc1vB+vpR0r5le\n\tuVHhpAERPrReFKwWuOEI51vseRjo22s1MhY7iyurjarswRU8lnbKmg+KT2ZR0Nn5bX4m\n\txY4mIKN9Rq0d1N/IXhy4UnZ/zpKHDyHrsiXC4nLyUZ1luue+/4aeE64yt4KlT2B5OT7d\n\t/TPgFe36t23M5SUaFMoyuEAGfCtHWHK1+rBUx9/rxm3wGubxOSLS/Tdz3heUzbBtDMLN\n\tsckM78wWhJm+Gi7cr0LXgOMMrDApgLYXWmJeK5zHfDi2VPBkbuqTaAlt1WGGAUdI6ilp\n\t/fbQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"k3ZCJqV8\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1699613998; x=1700218798;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=7zG4YADsqfXxky8HV1UlKl3gSBl6yLhKvKdAQ0eg5Pw=;\n\tb=Z3V57MDC8F/t2p2MFTHzafp5Cl+tv7a/l6cfc/FJ16a7fg9g/c+5E+SBgk27xWv2Qm\n\t8SsXl9y7PVYm+T8znJUkuUZ/sC1baNOs7EJTXM3vt9OpSpLfHnDq9qjGbZTwYFhIIG+s\n\tMEL2fT3gKdL8MErKCvOtvMbxxWT3hYiYdsTOyI12bPyl0rOvTa6Fuv3z7VEdVMktwogV\n\t5lCHrxqLMo1cZKzGn8XfAiKJxrHYElvRtDyrIQinPYjk+Ysrjnx4F69ZJIQuokOPRnnL\n\t1vFJ9cXLaXPOWrCsEHBkAMp9R/+4x7kBos8ztXr/bWtPXIhzKWdHB59Ei9Vv4VxN7an/\n\twmBg==","X-Gm-Message-State":"AOJu0YwLtNLgjRmcT7xOko4qIoXVFY656k0Za8qv3Tgb2xgdnk0wknZt\n\tlTGFuiV6ZFyYase5qhTczcDcuWjkccyKWJe8s1sdTg==","X-Google-Smtp-Source":"AGHT+IF6x4PiKwj7/Lc97QqZzcw4eZ2WuYIzwRUFBNtysJsIMDgMNOIJfK0zIAOc8q5ZuSL/zRiG3A==","X-Received":"by 2002:a05:600c:4ed0:b0:40a:43d3:2348 with SMTP id\n\tg16-20020a05600c4ed000b0040a43d32348mr1630236wmq.35.1699613998115; \n\tFri, 10 Nov 2023 02:59:58 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 10 Nov 2023 10:59:59 +0000","Message-Id":"<20231110110002.21381-3-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20231110110002.21381-1-naush@raspberrypi.com>","References":"<20231110110002.21381-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 2/5] controls: build: Allow separate\n\tvendor control YAML files","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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add support for using separate YAML files for vendor specific controls.\nThis simplifies management of vendor control definitions and avoids\npossible merge conflicts when changing the control_ids.yaml file for\ncore and draft controls. The mapping of vendor/pipeline handler to\ncontrol file is done through the vendor_controls_mapping variable in\ninclude/libcamera/meson.build.\n\nThe command line argument handling for the gen-py-controls.py and\ngen-controls.py have now changed to allow multiple input files to be\nprovided. This means that all positional arguments have been replaced\nby non-positional equivalents.\n\nAdd a new control_ids_rpi.yaml file to hold the Raspberry Pi specific\nvendor controls. This contains a single control PispConfigDumpFile that\nwill be used in the Pi 5 pipeline handler as a trigger to dump the\nBackend configuration as a JSON file.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n include/libcamera/meson.build       | 48 ++++++++++++++++++++++++++---\n meson.build                         |  2 ++\n src/libcamera/control_ids_rpi.yaml  | 17 ++++++++++\n src/libcamera/meson.build           | 19 ++++++++++--\n src/py/libcamera/gen-py-controls.py | 12 +++++---\n src/py/libcamera/meson.build        | 26 ++++++++++------\n utils/gen-controls.py               | 15 +++++----\n 7 files changed, 111 insertions(+), 28 deletions(-)\n create mode 100644 src/libcamera/control_ids_rpi.yaml","diff":"diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex f736cca07228..f8af51174f08 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -32,21 +32,61 @@ install_headers(libcamera_public_headers,\n \n libcamera_headers_install_dir = get_option('includedir') / libcamera_include_dir\n \n-# control_ids.h and property_ids.h\n+# control_ids.h and property_ids.h and associated modes\n control_source_files = {\n     'control_ids': 'controls',\n     'property_ids': 'properties',\n }\n \n+vendor_mappings = {\n+    # Mapping of vendor (pipeline handler) specific controls files\n+    'controls':\n+    {\n+        'rpi/pisp': 'control_ids_rpi.yaml',\n+        'rpi/vc4': 'control_ids_rpi.yaml'\n+    },\n+    # Mapping of vendor (pipeline handler) specific properties files\n+    'properties':\n+    {\n+\n+    }\n+}\n+\n control_headers = []\n+vendor_ctrl_files = []\n+vendor_prop_files = []\n \n foreach header, mode : control_source_files\n-    input_files = files('../../src/libcamera/' + header +'.yaml', header + '.h.in')\n+    # Start by populating the vendor specific mappings into vendor_ctrl_files\n+    # vendor_prop_files. These will be cached for later use.\n+    vendor_files = []\n+    foreach pipeline, file : vendor_mappings[mode]\n+        if pipeline not in pipelines\n+            continue\n+        endif\n+        if file not in vendor_files\n+            vendor_files += file\n+        endif\n+    endforeach\n+\n+    if mode == 'controls'\n+        vendor_ctrl_files = vendor_files\n+    else\n+        vendor_prop_files = vendor_files\n+    endif\n+\n+    input_files = files('../../src/libcamera/' + header +'.yaml')\n+\n+    foreach file : vendor_files\n+        input_files += files('../../src/libcamera/' + file)\n+    endforeach\n+\n+    template_file = files(header + '.h.in')\n     control_headers += custom_target(header + '_h',\n                                      input : input_files,\n                                      output : header + '.h',\n-                                     command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@',\n-                                                '--mode', mode],\n+                                     command : [gen_controls, '-o', '@OUTPUT@', '-i', '@INPUT@',\n+                                                '--mode', mode, '-t', template_file],\n                                      install : true,\n                                      install_dir : libcamera_headers_install_dir)\n endforeach\ndiff --git a/meson.build b/meson.build\nindex e9a1c7e360ce..1423abf16c77 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -267,6 +267,8 @@ py_mod.find_installation('python3', modules : py_modules)\n summary({\n             'Enabled pipelines': pipelines,\n             'Enabled IPA modules': enabled_ipa_names,\n+            'Vendor controls': vendor_ctrl_files,\n+            'Vendor properties': vendor_prop_files,\n             'Hotplug support': libudev.found(),\n             'Tracing support': tracing_enabled,\n             'Android support': android_enabled,\ndiff --git a/src/libcamera/control_ids_rpi.yaml b/src/libcamera/control_ids_rpi.yaml\nnew file mode 100644\nindex 000000000000..239904a008a8\n--- /dev/null\n+++ b/src/libcamera/control_ids_rpi.yaml\n@@ -0,0 +1,17 @@\n+# SPDX-License-Identifier: LGPL-2.1-or-later\n+#\n+# Copyright (C) 2023, Raspberry Pi Ltd\n+#\n+%YAML 1.1\n+---\n+controls:\n+\n+  - PispConfigDumpFile:\n+      type: string\n+      vendor: rpi\n+      description: |\n+        Triggers the Raspberry Pi PiSP pipeline handler to generate a JSON\n+        formatted dump of the Backend configuration to the filename given by the\n+        value of the control.\n+\n+...\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex e49bf850b355..8891052a3316 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -128,12 +128,25 @@ endif\n control_sources = []\n \n foreach source, mode : control_source_files\n-    input_files = files(source +'.yaml', source + '.cpp.in')\n+    input_files = files(source +'.yaml')\n+\n+    # Add the vendor specific files to the input.\n+    if mode == 'controls'\n+        vendor_files = vendor_ctrl_files\n+    else\n+        vendor_files = vendor_prop_files\n+    endif\n+\n+    foreach file : vendor_files\n+        input_files += files(file)\n+    endforeach\n+\n+    template_file = files(source + '.cpp.in')\n     control_sources += custom_target(source + '_cpp',\n                                      input : input_files,\n                                      output : source + '.cpp',\n-                                     command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@',\n-                                                '--mode', mode])\n+                                     command : [gen_controls, '-o', '@OUTPUT@', '-i', '@INPUT@',\n+                                                '--mode', mode, '-t', template_file])\n endforeach\n \n libcamera_sources += control_sources\ndiff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/gen-py-controls.py\nindex e89de674966a..a32ef09c2f48 100755\n--- a/src/py/libcamera/gen-py-controls.py\n+++ b/src/py/libcamera/gen-py-controls.py\n@@ -91,9 +91,9 @@ def main(argv):\n     parser = argparse.ArgumentParser()\n     parser.add_argument('-o', dest='output', metavar='file', type=str,\n                         help='Output file name. Defaults to standard output if not specified.')\n-    parser.add_argument('input', type=str,\n-                        help='Input file name.')\n-    parser.add_argument('template', type=str,\n+    parser.add_argument('-i', dest='inputs', type=str, nargs='+', required=True,\n+                        help='Input file name(s).')\n+    parser.add_argument('-t', dest='template', type=str, required=True,\n                         help='Template file name.')\n     parser.add_argument('--mode', type=str, required=True,\n                         help='Mode is either \"controls\" or \"properties\"')\n@@ -103,8 +103,10 @@ def main(argv):\n         print(f'Invalid mode option \"{args.mode}\"', file=sys.stderr)\n         return -1\n \n-    data = open(args.input, 'rb').read()\n-    controls = yaml.safe_load(data)['controls']\n+    controls = []\n+    for input in args.inputs:\n+        data = open(input, 'rb').read()\n+        controls += yaml.safe_load(data)['controls']\n \n     data = generate_py(controls, args.mode)\n \ndiff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build\nindex f58c7198ee9e..e4bc208b4ac1 100644\n--- a/src/py/libcamera/meson.build\n+++ b/src/py/libcamera/meson.build\n@@ -28,29 +28,35 @@ pycamera_sources = files([\n \n # Generate controls\n \n-gen_py_controls_input_files = files([\n-    '../../libcamera/control_ids.yaml',\n-    'py_controls_generated.cpp.in',\n-])\n+gen_py_controls_input_files = files('../../libcamera/control_ids.yaml')\n+\n+foreach file : vendor_ctrl_files\n+    gen_py_controls_input_files += files('../../libcamera/' + file)\n+endforeach\n \n gen_py_controls = files('gen-py-controls.py')\n+gen_py_controls_template = files('py_controls_generated.cpp.in')\n \n pycamera_sources += custom_target('py_gen_controls',\n                                   input : gen_py_controls_input_files,\n                                   output : ['py_controls_generated.cpp'],\n-                                  command : [gen_py_controls, '--mode', 'controls', '-o', '@OUTPUT@', '@INPUT@'])\n+                                  command : [gen_py_controls, '--mode', 'controls', '-o', '@OUTPUT@', '-i', '@INPUT@',\n+                                             '-t', gen_py_controls_template])\n \n # Generate properties\n \n-gen_py_property_enums_input_files = files([\n-    '../../libcamera/property_ids.yaml',\n-    'py_properties_generated.cpp.in',\n-])\n+gen_py_property_enums_input_files = files('../../libcamera/property_ids.yaml')\n+gen_py_property_template = files('py_properties_generated.cpp.in')\n+\n+foreach file : vendor_prop_files\n+    gen_py_property_enums_input_files += files('../../libcamera/' + file)\n+endforeach\n \n pycamera_sources += custom_target('py_gen_properties',\n                                   input : gen_py_property_enums_input_files,\n                                   output : ['py_properties_generated.cpp'],\n-                                  command : [gen_py_controls, '--mode', 'properties', '-o', '@OUTPUT@', '@INPUT@'])\n+                                  command : [gen_py_controls, '--mode', 'properties', '-o', '@OUTPUT@', '-i', '@INPUT@',\n+                                             '-t', gen_py_property_template])\n \n # Generate formats\n \ndiff --git a/utils/gen-controls.py b/utils/gen-controls.py\nindex dd55753e792c..3c490a562676 100755\n--- a/utils/gen-controls.py\n+++ b/utils/gen-controls.py\n@@ -362,18 +362,21 @@ def main(argv):\n \n     # Parse command line arguments\n     parser = argparse.ArgumentParser()\n-    parser.add_argument('-o', dest='output', metavar='file', type=str,\n+    parser.add_argument('-o', dest='output', metavar='file', type=str, required=True,\n                         help='Output file name. Defaults to standard output if not specified.')\n-    parser.add_argument('input', type=str,\n-                        help='Input file name.')\n-    parser.add_argument('template', type=str,\n+    parser.add_argument('-i', dest='inputs', type=str, nargs='+', required=True,\n+                        help='Input file name(s).')\n+    parser.add_argument('-t', dest='template', type=str, required=True,\n                         help='Template file name.')\n     parser.add_argument('--mode', type=str, required=True, choices=['controls', 'properties'],\n                         help='Mode of operation')\n     args = parser.parse_args(argv[1:])\n \n-    data = open(args.input, 'rb').read()\n-    controls = yaml.safe_load(data)['controls']\n+    controls = []\n+    for input in args.inputs:\n+        data = open(input, 'rb').read()\n+        controls = controls + yaml.safe_load(data)['controls']\n+\n     controls = [Control(*ctrl.popitem()) for ctrl in controls]\n \n     if args.template.endswith('.cpp.in'):\n","prefixes":["libcamera-devel","v1","2/5"]}