From patchwork Tue Apr 5 00:42:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 15616 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 379BEC0F1B for ; Tue, 5 Apr 2022 00:42:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 72EF665649; Tue, 5 Apr 2022 02:42:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1649119345; bh=xyoNLYvQ00/5n2V0UrTP044WvBSFrAPN/SMgrg6VLqk=; 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=h1K5LbCnPeJDd5JDqqQjfrfyOIzxVoiDZpXubjHQj6y5WXGI1AtwVcKnmskJs8c7W cPzszrBufoc6Rzbl2tUyUtY9LiTXWkun1cA48UZjqLnlPxS2qfTsMV8Zc4+0TBpp64 59agZ0l0mCVDRVrqRop0RzdYeIjluue1pXN9V7FVdn0+VAuo6cM3BTlbQgqgNGuTGA pPuEN8OwjajhlY526TQXas5h4vb871S5LXmDsoei4+7HN0IUpy4bkYd7Blsid4Co8G O7hMzhiysvQserJagMDMzqjL4mVxzyTrtbBJLI4MQBZ49Dp3TJZG0tnyp7Q4MhZBQj ov4WY4FOCHBfg== Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C642465641 for ; Tue, 5 Apr 2022 02:42:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="TWL/TzaA"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1649119342; bh=xyoNLYvQ00/5n2V0UrTP044WvBSFrAPN/SMgrg6VLqk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=TWL/TzaAszo1nR91c2q9I58hibkBKZrfmn56sURSmrW03d8K7CE4MyON9dhzl7b1h P/v+Z66oGI6lyOwA0TVbgVtS0SSbk5GWXzPMSRdYEsP81m0vu/RLZ9jp7Z7ng4VkqV B0l/dzmST24OTDLr+BUjkBT/z0XP9RG4pyve+kJ0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([92.10.251.63]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mbir8-1o8xg81Vs6-00dEPN; Tue, 05 Apr 2022 02:42:22 +0200 To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Apr 2022 01:42:12 +0100 Message-Id: <20220405004215.86340-3-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220405004215.86340-1-Rauch.Christian@gmx.de> References: <20220405004215.86340-1-Rauch.Christian@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:EHpgIaThWfIhYiEjXAlEqfu37Nc9NoHdyeWFtIimzoGjUvxMqQc Okj9MDB2hg7Hv3DJ54rAIp28Jwmhogg+EIRwUigzfsXeJKv82vErEYnc+ec484W6lfCvdsx 1EfVo9DopxWgQr1RwH63ydCIshO0piHcO1BTfSqDtedqI3Hig5vUxuSKnlPJAY4E9jBr6PE MDyBf/zmiFq0V5SfMKn+Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:NAc2snPw1uE=:Ioj5Y3ih/LGLOQ+ZZFEmsN zCxBhtMRgEVnu2twdE6H25owfpaVlT26hqTTBdYFquFNXRIT3aWCuEgxMr+WAyq3hexF36IFV 4b6JpIWf33HJKua3Id+0fVsLFs9MlPKNIjglVoHRaxoL5LPW5iZQB685bBgTvkhWtrTNB3VXx pO/+i01RcAgKaFdg1pioT2pSsCSzdYomZPgIfEmaEBKP9a8TAQNUI36yCVW/2PnU88eayYRMu NqHQ3czUpP6BKFxfPaInERqfZPf+oNeuA7l20dwxFt+vO8nEMlqoD+n4toPpP1WdOUuwbtpsF qydNmPJT4qIHTlzvoOR8GF7sHp5jHNA03uWyahS8jv3uYIfbf3uU4RZcySe499gE9E7HScU0Z OyZeaSncnEW//muZer5LA+dEmwIhFLDX0/mfVQf++en2qOy4WFa9SQQVxPOwjeo6sm+vxbpDv bi0TYGIeBrwuuyNN71Hx6oryP23qwev6ft7uCJDt+HbSfQZidWgtN8+jkibRvAWr7gDtuB57h obC6e00s24sjITrtp1TsKNe6xRRwYk1OYEaZq684UOoQSYH/lh2jTuT5K1r3FCHx+w9YsBPm6 ek33NXMiqAzf1KVDz5CFT2o5iJQgEcJ6VPm5w9HaCnLjxVDwYUEoU8I0nERCAMNoB5/h2sqFp RP6Hy3NnxwKN1EQHHLcLcPPI1srfhCGEsej1FA455c1+mZsaRmUzS4tX4nr3ijbyBE2yXZTJp tbzjUcCjFdOlZulAantJQ69ZV+qYz4Tvch6CVsdtX15aoGGN6jznUXnY7UbTHzrnzS9UMb1vu aM41uWHUUho+pY3AECw1kA9n/2y8dJi6Pya1xQ3eooMC7vXg9VkeP3A8omNbIBXEWlTvvdtfZ r2NnCW7DO7Ijj9oCznXfCfSd5GgeCkAIOVDpJF+HRN3ZKO2Q4j5CYcD/ZKUkmG/FKU+5DpB3p FXeYX2if+aW3dm9Kxw+JohrnXlWwfbb08yIc9e1Vnon4W9nGcFyC9+kR/IFiWJvBfj74XjaT/ gskeuPcIPKLBadNpq4MLhd0Jx/O2jlbU31ZYVJxqVvK6u7FH1hDyTpXmJ5kvW/E8jjU8Usgzy Luxg9MjBumwv4w= Subject: [libcamera-devel] [PATCH v2 2/5] generate fixed- and variable-sized Span Controls 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: Christian Rauch via libcamera-devel From: Christian Rauch Reply-To: Christian Rauch Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This defines Controls with a 'size' as either variable-sized Span or as fixed-sized Span. Signed-off-by: Christian Rauch --- utils/gen-controls.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) -- 2.25.1 diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 3f99b5e2..4cadf160 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -7,6 +7,7 @@ # gen-controls.py - Generate control definitions from YAML import argparse +from math import prod import string import sys import yaml @@ -22,6 +23,26 @@ def format_description(description): return '\n'.join([(line and ' * ' or ' *') + line for line in description]) +def get_ctrl_type_format(ctrl): + ctrl_type = ctrl['type'] + ctrl_size_arr = ctrl.get('size') + ctrl_is_span = ctrl_size_arr is not None + if ctrl_is_span: + ctrl_span_size = prod(ctrl_size_arr) if len(ctrl_size_arr) > 0 else None + + if ctrl_type == 'string': + return 'std::string' + elif ctrl_is_span: + if ctrl_span_size: + # fixed-sized Span + return 'Span'.format(ctrl_type, ctrl_span_size) + else: + # variable-sized Span + return 'Span'.format(ctrl_type) + else: + return ctrl_type + + def generate_cpp(controls): enum_doc_start_template = string.Template('''/** * \\enum ${name}Enum @@ -50,11 +71,7 @@ ${description} name, ctrl = ctrl.popitem() id_name = snake_case(name).upper() - ctrl_type = ctrl['type'] - if ctrl_type == 'string': - ctrl_type = 'std::string' - elif ctrl.get('size'): - ctrl_type = 'Span' % ctrl_type + ctrl_type = get_ctrl_type_format(ctrl) info = { 'name': name, @@ -135,11 +152,7 @@ def generate_h(controls): ids.append('\t' + id_name + ' = ' + str(id_value) + ',') - ctrl_type = ctrl['type'] - if ctrl_type == 'string': - ctrl_type = 'std::string' - elif ctrl.get('size'): - ctrl_type = 'Span' % ctrl_type + ctrl_type = get_ctrl_type_format(ctrl) info = { 'name': name,