From patchwork Thu Nov 30 14:25:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19252 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 C8D91C32B5 for ; Thu, 30 Nov 2023 14:25:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7FE44629CF; Thu, 30 Nov 2023 15:25:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1701354348; bh=2cqMmfpJysqXAMnIJX1SsnoAlqgYBQFtjEQO/6n7xZ0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gmTIeNCwIQas6JPTF/RHMZThk8X2upF+sWYjVINIQ2NyS/pvcKdpkJbx+kVyTYgtv +Aqllc00FLjAH2VtwIv3xtrDAhtxquR9nOPHmAZ1W0GgzG6JoDnKMQNCl75lyEGEd+ rmjCZO2RAHPUwXkC07zYNuWggTqV9nVgk0byfNyXwUL2wAaNkJWscYRo/KGtThhxFI B78RhthrFwS6T+RY7PAvZu94o5s0Lpfh65sWvZo8bJPTs6DRBWlueyommIKb66apZR YWpfFrrZBI3R0FCxRmz2SV+/YHuc+JLFvjZuUaJJEhQU8N/w3hH/GEbYIyRvEVtylS xb53Uj6gTvaLA== Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 36C75629D5 for ; Thu, 30 Nov 2023 15:25:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Sy1476eS"; dkim-atps=neutral Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-9fa45e75ed9so142167866b.1 for ; Thu, 30 Nov 2023 06:25:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1701354344; x=1701959144; 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=8MNvkO447TQABbMc0LlAq8P6s+MCZZx+lmqdO0CLVRk=; b=Sy1476eSsVGSwS90kkb6u7G0Wjv2Wgphu77Z/brxgeoBn1953Ps3T6D1V4JyrBeUL2 V1yE9AaW82qlorvtb9mM9lTg7GMI0pXLpQsalaaOhgBZBPzrBwJcqxIofRg30gT8l4ok lue+p62vO6fdafP5hqB+k+BxC0igzOZQQe80JF0zyF+jGr8h1z9gdZPEVp8RNh8dlyiY Yi6vTZmuMoER5hCHWkJLQ3CBl0CCtuBBFqay6js43g2f+oKl+7BHyjka7fgyRj2uko2E 3coYNYd/Ks725rUMOrIPYOsdABd8xjIZkEgEfoAHsXiqzUTFpW57ow1siI0CLpPHRewW iFlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701354344; x=1701959144; 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=8MNvkO447TQABbMc0LlAq8P6s+MCZZx+lmqdO0CLVRk=; b=XkuQc3nIp51LpnverZVz8p7uFXt9Q/+ZMq+K0ZuCf5Fk15Vgmb30F2bUTyR3dt5Erq 0S7R2CyHZ5sqDEryZMmw/ptouC2dqT7d55YgZ1Pdg/zO29s7vvts35tOk159HvgeBqfh cIGTh1StdLTWmNBYeSv62ioqeolCzXnDJwRAkeXJDxa7+udh3zYXhnQB4d9Vm0a6DVrp 6nnph6Vz0N1PDMF7Nd6+XL4UBoZj1j/nPqJ8/biUFNSbIWXn1OHpqIzzYC1RD84vcEK2 LGfH9HZbEIHeZVsPGb6bTTDb+DHLNPMlvb8uPnne+1fXiOR8oGNHS3pPXaz9jHfARNSN 5GQA== X-Gm-Message-State: AOJu0Yxe0RkTiXxNyS6VJFFWuoH5KsKDW3K5A3CTpYvt3qyEx/jaOR03 b0jsk4JDqImUCaksj/59Pd4HGwbjsuLkA4Q2ODl8kQ== X-Google-Smtp-Source: AGHT+IFSPmOsHRHyZ09FPi8s5EAmI4Fgme0XA37LlW2Vd+LDDZo+9zCMDIrNkKDgO7hW5R4sxJ/Iig== X-Received: by 2002:a17:906:f806:b0:a0e:3a12:a62a with SMTP id kh6-20020a170906f80600b00a0e3a12a62amr8461100ejb.59.1701354344643; Thu, 30 Nov 2023 06:25:44 -0800 (PST) Received: from localhost.localdomain ([88.97.53.79]) by smtp.gmail.com with ESMTPSA id a5-20020a17090640c500b009e50ea0a05asm725577ejk.99.2023.11.30.06.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 06:25:44 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 30 Nov 2023 14:25:32 +0000 Message-Id: <20231130142534.2075-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130142534.2075-1-naush@raspberrypi.com> References: <20231130142534.2075-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 4/6] 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 Cc: Jacopo Mondi 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 separate range from core libcamera controls, breaking the existing numbering behaviour. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- include/libcamera/meson.build | 3 ++- src/libcamera/control_ranges.yaml | 18 ++++++++++++++++++ src/libcamera/meson.build | 4 +++- utils/gen-controls.py | 15 ++++++++++++--- 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 src/libcamera/control_ranges.yaml diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index c46a4e701ac4..a2bb5d163ece 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -74,12 +74,13 @@ foreach mode, entry : controls_map endif template_file = files(outfile + '.in') + ranges_file = files('../../src/libcamera/control_ranges.yaml') control_headers += custom_target(header + '_h', input : input_files, output : outfile, command : [gen_controls, '-o', '@OUTPUT@', '--mode', mode, '-t', template_file, - '@INPUT@'], + '-r', ranges_file, '@INPUT@'], 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..d42447d04647 --- /dev/null +++ b/src/libcamera/control_ranges.yaml @@ -0,0 +1,18 @@ +# 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/draft libcamera and vendor +# controls and properties. +ranges: + # Core libcamera controls + libcamera: 0 + # Draft designated libcamera controls + draft: 10000 + # Raspberry Pi vendor controls + rpi: 20000 + # Next range starts at 30000 + +... diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 6d9902e6ffd1..45f63e932e4f 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -141,11 +141,13 @@ foreach mode, input_files : controls_mode_files template_file = files('property_ids.cpp.in') endif + ranges_file = files('control_ranges.yaml') control_sources += custom_target(mode + '_cpp', input : input_files, output : mode + '_ids.cpp', command : [gen_controls, '-o', '@OUTPUT@', - '--mode', mode, '-t', template_file, '@INPUT@']) + '--mode', mode, '-t', template_file, + '-r', ranges_file, '@INPUT@']) endforeach libcamera_sources += control_sources diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 2a633cc0aba9..8e592148af3d 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -239,7 +239,7 @@ ${vendor_controls_str} } -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;''') @@ -254,8 +254,10 @@ def generate_h(controls, mode): vendor = 'draft' if ctrl.is_draft else ctrl.vendor if vendor not in ctrls: + if vendor not in ranges.keys(): + raise RuntimeError(f'Control id range is not defined for vendor {vendor}') + id_value[vendor] = ranges[vendor] + 1 ids[vendor] = [] - id_value[vendor] = 1 ctrls[vendor] = [] # Core and draft controls use the same ID value @@ -341,6 +343,8 @@ def main(argv): help='Mode of operation') parser.add_argument('--output', '-o', metavar='file', type=str, help='Output file name. Defaults to standard output if not specified.') + parser.add_argument('--ranges', '-r', type=str, required=True, + help='Control id range reservation file.') parser.add_argument('--template', '-t', dest='template', type=str, required=True, help='Template file name.') parser.add_argument('input', type=str, nargs='+', @@ -348,6 +352,11 @@ def main(argv): args = parser.parse_args(argv[1:]) + ranges = {} + with open(args.ranges, 'rb') as f: + data = open(args.ranges, 'rb').read() + ranges = yaml.safe_load(data)['ranges'] + controls = [] for input in args.input: with open(input, 'rb') as f: @@ -359,7 +368,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')