{"id":19196,"url":"https://patchwork.libcamera.org/api/1.1/patches/19196/?format=json","web_url":"https://patchwork.libcamera.org/patch/19196/","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-4-naush@raspberrypi.com>","date":"2023-11-10T11:00:00","name":"[libcamera-devel,v1,3/5] libcamera: control: Add vendor control id range reservation","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"2eb8ea4b8b7068fadd2702f2743104994faf7d8a","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/19196/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/19196/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19196/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 DE321C32B6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Nov 2023 11:00:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2D014629C5;\n\tFri, 10 Nov 2023 12:00:03 +0100 (CET)","from mail-lj1-x235.google.com (mail-lj1-x235.google.com\n\t[IPv6:2a00:1450:4864:20::235])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9A37C629C4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Nov 2023 12:00:00 +0100 (CET)","by mail-lj1-x235.google.com with SMTP id\n\t38308e7fff4ca-2c54c8934abso26177591fa.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Nov 2023 03:00:00 -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.58\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 10 Nov 2023 02:59:58 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1699614003;\n\tbh=7XSFXx2DUl5h2GAm5SWiy58sKU3/VWKQHhEIIZzYr04=;\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=Axx0yglJ2xwBXE8dk4QNbQgOub9/cek4lApBCiqPTj+LE37MABDFyL3rx2iFgd+Td\n\tLbfUwewEfc3NjY1pl2ByDdYonVDF5IzDEdf4pX1hVlPziz7vso7NTQIZ/N31EVxHvV\n\t29Vmpx+gYnHTIGLb2x72jtsohFGCBQCxn/Ss+jU5JI8omq7njvCgnZVUqLeMhjD0+z\n\twjjQusroayI2KnyifidgIxCoA3HiGXFXtrhGRBFx1UyLZV+JxYxwu0m6CyooHPwFdF\n\tLyqX5dlcvZlfOcbLC5od2ASrTeT6zUXtVhehzhKOqVZ55KjwhN9ZLz7Gwt/cDyf36p\n\tu+kVbA9p9al9g==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1699613999; x=1700218799;\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=KGVaaYbVeRRnBsWLiUTohKuu49hyzSLpVxoqEmiQ8Hs=;\n\tb=TNtpJ1YzKecoaUbFqqDG4mgF4Fwkb9x1GiJDc7Bqo83elN2xqMFTH9q/sI8qIPbLU5\n\t8/jL111xuEtpEOMLNC3ZbaeIuGyNOgy4syRw0w43kKwI8Bd/St7Djw3AHYMUPPwNksxx\n\tG1PVcSKCkMpGqjo+em6O9KG0BIvUcbJvKF2LJyrAAx/gaMNW4I2a/W7oqKB1QwATdsFr\n\tAJGVZgU06gP1b/5ccoW8h9Ip2aY7rczrhKp5q5PB7iT+rOU7yi/kcTyNXo2kZgbnhiDI\n\t208LNfM1L0Ggv3cVOTTtaJHjNbBRV8XU0xpD6Nm8rbAPX6/Wv0A+eae4gzyHfvyi7gFV\n\tk86g=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"TNtpJ1Yz\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1699613999; x=1700218799;\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=KGVaaYbVeRRnBsWLiUTohKuu49hyzSLpVxoqEmiQ8Hs=;\n\tb=JTrJvqbbjPl7ARJ6w4SC0+Hc2B+/JiDv0ujl09foI2nVM8ESsJUI5Q4S1emSHyzVBe\n\tneSwnxjwI4LqTW3OlM3dOz0G8esWEExQl0zgCvQveA7uM44Y6d84YQF6R+AnL1DSGm50\n\tCnq+bbjdHDvvK4L+7efrEjhe4Qb4ps7qvs1c6jYAy69IREFm0f1gnwwtlgMB5WpqlVU7\n\tPsjZTaLQlf7AeBuUdWkiyssYe8dlSgq/OqCmofFIi+6ui8AWSP/Hw7O8f25f1MLGu6n2\n\t6tSpLjc2THXl4690DGoFSLxfRsH+mytDOBtpD4ANVyajLgzq1fmqWUOI1AeMYdjRO4Ap\n\tmvJw==","X-Gm-Message-State":"AOJu0YxBxzgT7fhX90bFLXkxbxa/DLg+yOvtjFg4j/hlTJGxfZDaYGSz\n\tR61CfToAcblUchzQ01Hp8ktIg5yX7InFKzc4v/4RyA==","X-Google-Smtp-Source":"AGHT+IGZb5FYW8VKLDntbYhyj0onM76iscKB7nYmnIkVYx/zbp6UZqdnU+bIvhRdmdHZXXpdX9MZTA==","X-Received":"by 2002:a2e:9410:0:b0:2c7:8fee:c295 with SMTP id\n\ti16-20020a2e9410000000b002c78feec295mr1994775ljh.42.1699613999342; \n\tFri, 10 Nov 2023 02:59:59 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 10 Nov 2023 11:00:00 +0000","Message-Id":"<20231110110002.21381-4-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 3/5] libcamera: control: Add vendor\n\tcontrol id range reservation","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 a new control_ranges.yaml file that is used to reserve control id\nranges/offsets for libcamera and vendor specific controls. This file is\nused by the gen-controls.py script to generate control id values for\neach control.\n\nDraft controls now have a seprate range from core libcamera controls,\nbreaking the existing numbering behaviour.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n include/libcamera/meson.build     |  3 ++-\n src/libcamera/control_ranges.yaml | 17 +++++++++++++++++\n utils/gen-controls.py             | 15 ++++++++++++---\n 3 files changed, 31 insertions(+), 4 deletions(-)\n create mode 100644 src/libcamera/control_ranges.yaml","diff":"diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex f8af51174f08..98339b93777c 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -82,11 +82,12 @@ foreach header, mode : control_source_files\n     endforeach\n \n     template_file = files(header + '.h.in')\n+    ranges_file = files('../../src/libcamera/control_ranges.yaml')\n     control_headers += custom_target(header + '_h',\n                                      input : input_files,\n                                      output : header + '.h',\n                                      command : [gen_controls, '-o', '@OUTPUT@', '-i', '@INPUT@',\n-                                                '--mode', mode, '-t', template_file],\n+                                                '--mode', mode, '-t', template_file, '-r', ranges_file],\n                                      install : true,\n                                      install_dir : libcamera_headers_install_dir)\n endforeach\ndiff --git a/src/libcamera/control_ranges.yaml b/src/libcamera/control_ranges.yaml\nnew file mode 100644\nindex 000000000000..e908a8a3a110\n--- /dev/null\n+++ b/src/libcamera/control_ranges.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+# Specifies the control id ranges/offsets for core libcamera and vendor specific\n+# controls.\n+ranges:\n+  # Core libcamera controls\n+  libcamera: 0\n+  # Draft designated libcamera controls\n+  draft: 1000\n+  # Raspberry Pi vendor controls\n+  rpi: 2000\n+\n+...\ndiff --git a/utils/gen-controls.py b/utils/gen-controls.py\nindex 3c490a562676..a10b9fdc19ee 100755\n--- a/utils/gen-controls.py\n+++ b/utils/gen-controls.py\n@@ -259,7 +259,7 @@ ${vendor_controls_map}\n     }\n \n \n-def generate_h(controls, mode):\n+def generate_h(controls, mode, ranges):\n     enum_template_start = string.Template('''enum ${name}Enum {''')\n     enum_value_template = string.Template('''\\t${name} = ${value},''')\n     enum_values_template = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values;''')\n@@ -277,8 +277,10 @@ def generate_h(controls, mode):\n             vendor = 'draft' if ctrl.is_draft else 'libcamera'\n \n         if vendor not in ctrls:\n+            if vendor not in ranges.keys():\n+                raise RuntimeError('Vendor range is not defined')\n+            id_value[vendor] = ranges[vendor] + 1\n             ids[vendor] = []\n-            id_value[vendor] = 1\n             ctrls[vendor] = []\n \n         # Core and draft controls use the same ID value\n@@ -370,8 +372,15 @@ def main(argv):\n                         help='Template file name.')\n     parser.add_argument('--mode', type=str, required=True, choices=['controls', 'properties'],\n                         help='Mode of operation')\n+    parser.add_argument('-r', dest='ranges', type=str,\n+                        help='Control id range reservation file.')\n     args = parser.parse_args(argv[1:])\n \n+    ranges = []\n+    if args.ranges:\n+        data = open(args.ranges, 'rb').read()\n+        ranges = yaml.safe_load(data)['ranges']\n+\n     controls = []\n     for input in args.inputs:\n         data = open(input, 'rb').read()\n@@ -382,7 +391,7 @@ def main(argv):\n     if args.template.endswith('.cpp.in'):\n         data = generate_cpp(controls)\n     elif args.template.endswith('.h.in'):\n-        data = generate_h(controls, args.mode)\n+        data = generate_h(controls, args.mode, ranges)\n     else:\n         raise RuntimeError('Unknown template type')\n \n","prefixes":["libcamera-devel","v1","3/5"]}