From patchwork Fri Jun 3 22:07:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 16147 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 798A4C3276 for ; Fri, 3 Jun 2022 22:07:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 55F296563E; Sat, 4 Jun 2022 00:07:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1654294042; 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=vh6JvmA7Qe0hycEePJKpJTUibd2yR2EZCKJt8r23YbnZ2LmvqwhNHXkGSrm0Y22Fv 09A0z2u2ijQoBI2Rru2Y0icOUnvbE4rY6jm4Va9GsfxW6y0GZq1SV/2zKDVAzvb0Z4 UH5sVE9Vxyr8avRI4nzSNyCjJkOyza5So2lHNjWHEx2uOw1JDRhr6TvYxq+zrl0FLM 7o343ZvfyXhzrLayHaRkngFyuMPcD9atpGGbX6OLP9mfhL7/51FKJcPCRfzD6mycis WJnDOPDtB8KzmKwwjFbMWA8DkSPdqqgBskBZ8YmcG9G9Ex9YrOeJx5BQ1G4mlPv+VY 7W15I5V8hb1WA== Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4AA7D633A5 for ; Sat, 4 Jun 2022 00:07:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="YMOvHPNf"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1654294037; bh=UqwmX7+yMaOqSyR96KduBQpxFaCTOfHvdMO6MxtFX8g=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=YMOvHPNfoCu3XNvFF4WX5fJu4UEWPc+iuGD/gu0o1yCLWav7oHvIrqvA+5WxJ1pnt Qoyxb++lpI2+dscpRi9JcH1cDQOvPmJ85jOSyA/icNLbcfSNpUj6sWbPrVceWyeHDu z2AfLtOrDTJMdOiGx+MmmagLL9UuVDVvxjvaYXqg= 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 1MbAcs-1nLiqC3CIK-00bdNU; Sat, 04 Jun 2022 00:07:16 +0200 To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Jun 2022 23:07:11 +0100 Message-Id: <20220603220712.73673-5-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220603220712.73673-1-Rauch.Christian@gmx.de> References: <20220603220712.73673-1-Rauch.Christian@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:f/P8ZIEhRddX2tpuEUII+BRZ5v1vELGQL1ZG2Z0wAI37jtTKeWN 4BvV0TF62QLGtbjM+0AKTv5M2vuHazN1Bpz8dFe26d6LCkGTdNnojZ5vbl5gMsmfAE8q8Cx cl+pOJUPhDIWAAQTXfwCpllwdjZ1frhjtvGJ/36ijpkHN6vLpgbQA8Vr4CXeri2nxYkdFcQ VGdKdQlKfkJ9MXUcxW5uw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:m2ITV46j7vY=:9dRd2mtX7YEPPj++zfa7uH h8TO/6vJpV/LREovq/uxxqk2PSsw6MzBqJ0i4ZGHU1POFKe2K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V0QgNmo96o11nEASxY8foqtw== Subject: [libcamera-devel] [PATCH v6 4/5] 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,