From patchwork Mon Jul 4 23:32:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16540 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 4F7C5BE173 for ; Mon, 4 Jul 2022 23:32:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EEC7863313; Tue, 5 Jul 2022 01:32:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656977558; bh=UqwmX7+yMaOqSyR96KduBQpxFaCTOfHvdMO6MxtFX8g=; 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=j/5/Ay9DMIMPDKqIYF82sj5wp7/+83u7f/qDN4KVtpSjVpfMuxg1k4VzazkvthQop vkXQF7A2bgu0xNRSvTwtSqF9rDjD2tEEFZiS3kprZ8qjop8WNP5JEBE1JVU9WJ59bL l5rk3KEue3X55my7/L6l35LCut3OaFNWLLQFQY53A7poAibjqhZiR0nZ24CFb19YMs umr1XnL7rSGW//tpK02l7s6NxHPldDRjjXboT237uhNdPH4VpEhls24ClxG710djFw nSxgULanotBuuvBxo30Ki/bcmphOMHM2GTmzmt0+8bAK4egx8yXvV7YS8P/Ae+2WlK l7T4SgOfWFJ9w== Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 58ED36042E for ; Tue, 5 Jul 2022 01:32:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="IBGXHTri"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656977554; bh=UqwmX7+yMaOqSyR96KduBQpxFaCTOfHvdMO6MxtFX8g=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=IBGXHTrizAYQflxUJXHl32cJijLfpSiuGjPic9up9ypsZZlBCFbDI/ZkLnUbjVmHH m4NN00Cu997VaFWLu+O36BXsi1eFwnUAdFaH2sX/4HRYGt99zl5cVKJtAv5dcAnNVq oMmsUcpeprE8PFgqfRCVPzq7s49Xgoim3QAZ2wpA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([92.18.80.244]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M5QJD-1o9L2C3i1l-001P19; Tue, 05 Jul 2022 01:32:34 +0200 To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Jul 2022 00:32:16 +0100 Message-Id: <20220704233217.54769-4-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704233217.54769-1-Rauch.Christian@gmx.de> References: <20220704233217.54769-1-Rauch.Christian@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:w5qMBf2rLPmRmaGHONqhxzM+PR2cqmKzyuaorhqo6JhWh+COwX3 2T9FOXVDtvhte+XyFk15yqSjSBNHvg8NF4+Ucb7GeNwyapGVHNfVndM5Vko89JPMVkCYdUz 4aYs+fggbgqC8+ZG4rHeEfypRQ8EL9/gJZiOMZDl4XGdvTpMQGRvLZU5jBQy8ocR7tbqAkH Tj5mZYgfIihINtGfbmBug== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:DXLRsWq7lck=:Uc3EziPeJ2Q093N92i6l/p pkA3MukjmKGL7eYwLznzSbAXGJLhyjDgak75lXVzpyr3kqNZEIEQ/075WyMBlmOUqwlZX9yq+ HgGYMwMdXPsBdpDu7aGND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amera-devel] [PATCH v9 3/4] libcamera: controls: 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 Reviewed-by: Jacopo Mondi --- utils/gen-controls.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) -- 2.34.1 diff --git a/utils/gen-controls.py b/utils/gen-controls.py index 3f99b5e2..46ba4394 100755 --- a/utils/gen-controls.py +++ b/utils/gen-controls.py @@ -7,6 +7,8 @@ # gen-controls.py - Generate control definitions from YAML import argparse +from functools import reduce +import operator import string import sys import yaml @@ -22,6 +24,24 @@ def format_description(description): return '\n'.join([(line and ' * ' or ' *') + line for line in description]) +def get_ctrl_type(ctrl): + ctrl_type = ctrl['type'] + ctrl_size_arr = ctrl.get('size') + + if ctrl_type == 'string': + return 'std::string' + elif ctrl_size_arr is not None: + if len(ctrl_size_arr) > 0: + # fixed-sized Span + ctrl_span_size = reduce(operator.mul, ctrl_size_arr) + return f"Span" + else: + # variable-sized Span + return f"Span" + else: + return ctrl_type + + def generate_cpp(controls): enum_doc_start_template = string.Template('''/** * \\enum ${name}Enum @@ -50,11 +70,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(ctrl) info = { 'name': name, @@ -135,11 +151,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(ctrl) info = { 'name': name,