From patchwork Tue Nov 21 14:53:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19219 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 6AD54C3220 for ; Tue, 21 Nov 2023 14:54:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 25773629C6; Tue, 21 Nov 2023 15:54:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1700578443; bh=Lz7bqg4woco1wsI1dg+O/x/h8wf+lZqPik1AGilmbFQ=; 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=AfZa15WCYZ0AMzK+NjSMRO3szDUtTQcSnEe/PcZYcHERAPgE/MSzEFyTwhn190/O3 D4JzxZopLGei6Fka20Q9YdhLA7Ps/6jLY0Vv2c4vDrxxQt2EbTbx8xr/leDz1PMhjc ff7KTYk7bRbYqyo0jmO/ql38xgnvF/bQ4rd1PdMcliq8fKlQvYV+bW5V3Plsubo7Se bOIxC1FIfUayYGnH0DizfwK3PzKAncue75IrKvSABCXNBsuXrYOD9psRtxadbUM05Y 0EEkD8BSw7ertY0NQaxchT/tY9O2nin8z78S9rpoULHzvSVkzSsRpQXCQUQGqW7tgg Z/UG4xXCHUotw== Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A67B2629C7 for ; Tue, 21 Nov 2023 15:54:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="E0UdMOQi"; dkim-atps=neutral Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2c503dbe50dso72736941fa.1 for ; Tue, 21 Nov 2023 06:54:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1700578439; x=1701183239; 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=+se7h2b/3Pvt4IUgxQJOXLlI94EI05IQfuZIl3Zu+sI=; b=E0UdMOQi6s06A4NElxKIIccnp1JqQxRvCD27V8SUpt2NEotgTPZug7amJvTDkrX6wC R3CRQT5ZqptutneHpr4yMC0MtYt2LP+CdWErw824EHUS2tRGwaTGuRxGstAHjEgoE7nw RBlhvTsh/2rfDzu86PSEXgLjFWi0YTf40J6LkpM+ZE1AsmwSsx/0DnWJOa6wj4oYQaWH sDhAtKTx95ffgQCqWPl4bm45ENWBfxef46kdyW4sfb62uX4qeaxFOxcMxG8E5OlNHRPv pBg24KwGSkI+hOTRCVxqCr4Zcor4UDtv2E3QqZN/UAaet1d18ZmxA5oJlPTQ/YJFIxWx iWwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700578439; x=1701183239; 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=+se7h2b/3Pvt4IUgxQJOXLlI94EI05IQfuZIl3Zu+sI=; b=J/cYaBXhDjqMcwt0UQM1yHUN5Ox5DgEpYYREvyPCRFQWA00HjAbFUUO6NHnWVun1HM v/kf8MTpcXVs+tGM/3iOV1b5ynWpmuh61hOfHmeFeO2E+nSVJMnVOXnSwrr1LdGnz3QN lCHe4NF6P6R1XTnUlD5sTCmTPEtCgnbSZCcJ7jKYRU+grhUNg8kGcuU7Cgth97P0SvHu jXasgJPkEJ4hLPAtziOkyVXUqM/i1UWlNMtq2p/LJRYmULNyV/MG+J+SVDb8yZW7rj8D JFbtyPefdP2Om4jycfT/+6RcutoQkwoO338m3Ho2qbze7fI05/bjfuyKEytZUJ8zk6v1 998Q== X-Gm-Message-State: AOJu0Yz/4vslZaUeRHiHbDqwcJBaLJXjyIs+7KSwDgS3PfyYff2BIwi5 fMk5dJrfA0OX25bhKJozk2kihm4OOJkPJ+6emKWWOg== X-Google-Smtp-Source: AGHT+IGGfldFshS3FwXUyM8TM/WvZvbX/Kpkh4iF+gHzJ35D7TGr+uKSAF60MPAHI4B+NhC9HyO0PA== X-Received: by 2002:a2e:9ec4:0:b0:2c8:7192:817 with SMTP id h4-20020a2e9ec4000000b002c871920817mr6337638ljk.15.1700578439510; Tue, 21 Nov 2023 06:53:59 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 06:53:58 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Nov 2023 14:53:48 +0000 Message-Id: <20231121145350.5956-5-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 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 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 --- include/libcamera/meson.build | 4 +++- src/libcamera/control_ranges.yaml | 18 ++++++++++++++++++ src/libcamera/meson.build | 4 +++- utils/gen-controls.py | 15 ++++++++++++--- 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 src/libcamera/control_ranges.yaml diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 54123c5b858d..6cac385fdee4 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -83,11 +83,13 @@ 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@', - '--mode', mode, '-t', template_file, '@INPUT@'], + '--mode', mode, '-t', template_file, + '-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..150ae7fa5efd --- /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 libcamera and vendor specific +# controls. +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 7eb26ccbb7f5..303eee84a77e 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -142,11 +142,13 @@ foreach source, mode : control_source_files endforeach template_file = files(source + '.cpp.in') + ranges_file = files('control_ranges.yaml') control_sources += custom_target(source + '_cpp', input : input_files, output : source + '.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 d7862142b8c1..9eede8940f24 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -257,7 +257,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;''') @@ -272,8 +272,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 @@ -365,8 +367,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, required=True, + 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.input: data = open(input, 'rb').read() @@ -377,7 +386,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')