From patchwork Fri Nov 10 11:00:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19196 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 DE321C32B6 for ; Fri, 10 Nov 2023 11:00:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2D014629C5; Fri, 10 Nov 2023 12:00:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1699614003; bh=7XSFXx2DUl5h2GAm5SWiy58sKU3/VWKQHhEIIZzYr04=; 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=Axx0yglJ2xwBXE8dk4QNbQgOub9/cek4lApBCiqPTj+LE37MABDFyL3rx2iFgd+Td LbfUwewEfc3NjY1pl2ByDdYonVDF5IzDEdf4pX1hVlPziz7vso7NTQIZ/N31EVxHvV 29Vmpx+gYnHTIGLb2x72jtsohFGCBQCxn/Ss+jU5JI8omq7njvCgnZVUqLeMhjD0+z wjjQusroayI2KnyifidgIxCoA3HiGXFXtrhGRBFx1UyLZV+JxYxwu0m6CyooHPwFdF LyqX5dlcvZlfOcbLC5od2ASrTeT6zUXtVhehzhKOqVZ55KjwhN9ZLz7Gwt/cDyf36p u+kVbA9p9al9g== Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9A37C629C4 for ; Fri, 10 Nov 2023 12:00:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="TNtpJ1Yz"; dkim-atps=neutral Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2c54c8934abso26177591fa.0 for ; Fri, 10 Nov 2023 03:00:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1699613999; x=1700218799; 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=KGVaaYbVeRRnBsWLiUTohKuu49hyzSLpVxoqEmiQ8Hs=; b=TNtpJ1YzKecoaUbFqqDG4mgF4Fwkb9x1GiJDc7Bqo83elN2xqMFTH9q/sI8qIPbLU5 8/jL111xuEtpEOMLNC3ZbaeIuGyNOgy4syRw0w43kKwI8Bd/St7Djw3AHYMUPPwNksxx G1PVcSKCkMpGqjo+em6O9KG0BIvUcbJvKF2LJyrAAx/gaMNW4I2a/W7oqKB1QwATdsFr AJGVZgU06gP1b/5ccoW8h9Ip2aY7rczrhKp5q5PB7iT+rOU7yi/kcTyNXo2kZgbnhiDI 208LNfM1L0Ggv3cVOTTtaJHjNbBRV8XU0xpD6Nm8rbAPX6/Wv0A+eae4gzyHfvyi7gFV k86g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699613999; x=1700218799; 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=KGVaaYbVeRRnBsWLiUTohKuu49hyzSLpVxoqEmiQ8Hs=; b=JTrJvqbbjPl7ARJ6w4SC0+Hc2B+/JiDv0ujl09foI2nVM8ESsJUI5Q4S1emSHyzVBe neSwnxjwI4LqTW3OlM3dOz0G8esWEExQl0zgCvQveA7uM44Y6d84YQF6R+AnL1DSGm50 Cnq+bbjdHDvvK4L+7efrEjhe4Qb4ps7qvs1c6jYAy69IREFm0f1gnwwtlgMB5WpqlVU7 PsjZTaLQlf7AeBuUdWkiyssYe8dlSgq/OqCmofFIi+6ui8AWSP/Hw7O8f25f1MLGu6n2 6tSpLjc2THXl4690DGoFSLxfRsH+mytDOBtpD4ANVyajLgzq1fmqWUOI1AeMYdjRO4Ap mvJw== X-Gm-Message-State: AOJu0YxBxzgT7fhX90bFLXkxbxa/DLg+yOvtjFg4j/hlTJGxfZDaYGSz R61CfToAcblUchzQ01Hp8ktIg5yX7InFKzc4v/4RyA== X-Google-Smtp-Source: AGHT+IGZb5FYW8VKLDntbYhyj0onM76iscKB7nYmnIkVYx/zbp6UZqdnU+bIvhRdmdHZXXpdX9MZTA== X-Received: by 2002:a2e:9410:0:b0:2c7:8fee:c295 with SMTP id i16-20020a2e9410000000b002c78feec295mr1994775ljh.42.1699613999342; Fri, 10 Nov 2023 02:59:59 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id r15-20020a05600c35cf00b0040531f5c51asm4883156wmq.5.2023.11.10.02.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Nov 2023 02:59:58 -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 Subject: [libcamera-devel] [PATCH v1 3/5] libcamera: control: Add vendor control id range reservation 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 a new control_ranges.yaml file that is used to reserve control id ranges/offsets for libcamera and vendor specific controls. This file is used by the gen-controls.py script to generate control id values for each control. Draft controls now have a seprate range from core libcamera controls, breaking the existing numbering behaviour. Signed-off-by: Naushir Patuck --- include/libcamera/meson.build | 3 ++- src/libcamera/control_ranges.yaml | 17 +++++++++++++++++ utils/gen-controls.py | 15 ++++++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/libcamera/control_ranges.yaml diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index f8af51174f08..98339b93777c 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -82,11 +82,12 @@ foreach header, mode : control_source_files endforeach template_file = files(header + '.h.in') + ranges_file = files('../../src/libcamera/control_ranges.yaml') control_headers += custom_target(header + '_h', input : input_files, output : header + '.h', command : [gen_controls, '-o', '@OUTPUT@', '-i', '@INPUT@', - '--mode', mode, '-t', template_file], + '--mode', mode, '-t', template_file, '-r', ranges_file], install : true, install_dir : libcamera_headers_install_dir) endforeach diff --git a/src/libcamera/control_ranges.yaml b/src/libcamera/control_ranges.yaml new file mode 100644 index 000000000000..e908a8a3a110 --- /dev/null +++ b/src/libcamera/control_ranges.yaml @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Copyright (C) 2023, Raspberry Pi Ltd +# +%YAML 1.1 +--- +# Specifies the control id ranges/offsets for core libcamera and vendor specific +# controls. +ranges: + # Core libcamera controls + libcamera: 0 + # Draft designated libcamera controls + draft: 1000 + # Raspberry Pi vendor controls + rpi: 2000 + +... diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 3c490a562676..a10b9fdc19ee 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -259,7 +259,7 @@ ${vendor_controls_map} } -def generate_h(controls, mode): +def generate_h(controls, mode, ranges): enum_template_start = string.Template('''enum ${name}Enum {''') enum_value_template = string.Template('''\t${name} = ${value},''') enum_values_template = string.Template('''extern const std::array ${name}Values;''') @@ -277,8 +277,10 @@ def generate_h(controls, mode): vendor = 'draft' if ctrl.is_draft else 'libcamera' if vendor not in ctrls: + if vendor not in ranges.keys(): + raise RuntimeError('Vendor range is not defined') + id_value[vendor] = ranges[vendor] + 1 ids[vendor] = [] - id_value[vendor] = 1 ctrls[vendor] = [] # Core and draft controls use the same ID value @@ -370,8 +372,15 @@ def main(argv): help='Template file name.') parser.add_argument('--mode', type=str, required=True, choices=['controls', 'properties'], help='Mode of operation') + parser.add_argument('-r', dest='ranges', type=str, + help='Control id range reservation file.') args = parser.parse_args(argv[1:]) + ranges = [] + if args.ranges: + data = open(args.ranges, 'rb').read() + ranges = yaml.safe_load(data)['ranges'] + controls = [] for input in args.inputs: data = open(input, 'rb').read() @@ -382,7 +391,7 @@ def main(argv): if args.template.endswith('.cpp.in'): data = generate_cpp(controls) elif args.template.endswith('.h.in'): - data = generate_h(controls, args.mode) + data = generate_h(controls, args.mode, ranges) else: raise RuntimeError('Unknown template type')