[{"id":22747,"web_url":"https://patchwork.libcamera.org/comment/22747/","msgid":"<Yl8fiuYRo0XdzQxq@pendragon.ideasonboard.com>","date":"2022-04-19T20:46:02","subject":"Re: [libcamera-devel] [PATCH v3 2/4] generate fixed- and\n\tvariable-sized Span Controls","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Christian,\n\nThank you for the patch.\n\nOn Fri, Apr 08, 2022 at 02:42:29AM +0100, Christian Rauch via libcamera-devel wrote:\n> This defines Controls with a 'size' as either variable-sized Span<T> or as\n> fixed-sized Span<T,N>.\n\nAs with patch 1/4, 2/4 causes new compilation failures. You will need to\nsquash 3/4 with this. It won't be enough though, there will be two more\ncompilation errors that will need to be fixed.\n\n> Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de>\n> ---\n>  utils/gen-controls.py | 32 ++++++++++++++++++++++----------\n>  1 file changed, 22 insertions(+), 10 deletions(-)\n> \n> diff --git a/utils/gen-controls.py b/utils/gen-controls.py\n> index 3f99b5e2..c9e79a22 100755\n> --- a/utils/gen-controls.py\n> +++ b/utils/gen-controls.py\n> @@ -7,6 +7,7 @@\n>  # gen-controls.py - Generate control definitions from YAML\n> \n>  import argparse\n> +import math\n>  import string\n>  import sys\n>  import yaml\n> @@ -22,6 +23,25 @@ def format_description(description):\n>      return '\\n'.join([(line and ' * ' or ' *') + line for line in description])\n> \n> \n> +def get_ctrl_type(ctrl):\n> +    ctrl_type = ctrl['type']\n> +    ctrl_size_arr = ctrl.get('size')\n> +    ctrl_is_span = ctrl_size_arr is not None\n> +\n> +    if ctrl_type == 'string':\n> +        return 'std::string'\n> +    elif ctrl_is_span:\n> +        ctrl_span_size = math.prod(ctrl_size_arr) if len(ctrl_size_arr) > 0 else None\n> +        if ctrl_span_size:\n> +            # fixed-sized Span\n> +            return f\"Span<const {ctrl_type}, {ctrl_span_size}>\"\n> +        else:\n> +            # variable-sized Span\n> +            return f\"Span<const {ctrl_type}>\"\n> +    else:\n> +        return ctrl_type\n> +\n> +\n>  def generate_cpp(controls):\n>      enum_doc_start_template = string.Template('''/**\n>   * \\\\enum ${name}Enum\n> @@ -50,11 +70,7 @@ ${description}\n>          name, ctrl = ctrl.popitem()\n>          id_name = snake_case(name).upper()\n> \n> -        ctrl_type = ctrl['type']\n> -        if ctrl_type == 'string':\n> -            ctrl_type = 'std::string'\n> -        elif ctrl.get('size'):\n> -            ctrl_type = 'Span<const %s>' % ctrl_type\n> +        ctrl_type = get_ctrl_type(ctrl)\n> \n>          info = {\n>              'name': name,\n> @@ -135,11 +151,7 @@ def generate_h(controls):\n> \n>          ids.append('\\t' + id_name + ' = ' + str(id_value) + ',')\n> \n> -        ctrl_type = ctrl['type']\n> -        if ctrl_type == 'string':\n> -            ctrl_type = 'std::string'\n> -        elif ctrl.get('size'):\n> -            ctrl_type = 'Span<const %s>' % ctrl_type\n> +        ctrl_type = get_ctrl_type(ctrl)\n> \n>          info = {\n>              'name': name,","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B0A4DC3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Apr 2022 20:46:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 672FE65640;\n\tTue, 19 Apr 2022 22:46:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B62FB604B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Apr 2022 22:46:01 +0200 (CEST)","from pendragon.ideasonboard.com (85-76-5-145-nat.elisa-mobile.fi\n\t[85.76.5.145])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A48A025B;\n\tTue, 19 Apr 2022 22:46:00 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1650401163;\n\tbh=DsF2OTqvxpbaUZm8P8bhn1Jrts6jEG7+96LWT1b19aM=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=2Yk5qRK7Ez44O+ym08LlDczqdtkaYHQvRyIO0dxhfCbfKLzbFqSpx7le/r+nJcC/C\n\tkiy6RW6d/VYPbdm0t/e5qRkGn2XAOfq4M30SmYALiB6nRIq9IT6JwgT3OTR3IeNmIM\n\tQrcNo+2Fz9D6hHh83R59/RWxxBFqwSzB/8kM1dUrw9Cw/nwVFafuMCQ2fdTZg1S5b/\n\t2O4xz3LoEO5v6Lga4u8AeuHRQCMC1kPRJXdovXIupAJYlSiGnAxgibKe2lL0GntfeT\n\tP5Uv9+LoO4zUhgznIqfOp+eoe6a8/3LVdXzm+Gz0m1/aYCdHalppFMTjlnLyIp7zkQ\n\tK53FPpK+NeEuw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1650401161;\n\tbh=DsF2OTqvxpbaUZm8P8bhn1Jrts6jEG7+96LWT1b19aM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=fNjOhEtThlMf3p+t8DkehrdjB1EuMJqDlJI/YySqgP4YX8CUXzlwQmgmgeyG2L8qx\n\t6b+P8sX57yqcb73O09FSMyTqExfQFF6+gHFgElFC8m8WSLtHJSW5eCpIsOAAPV31nv\n\tKIO+IjGHd11hbE6PIpnvG8E29zlJC37ef8mdTQGo="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"fNjOhEtT\"; dkim-atps=neutral","Date":"Tue, 19 Apr 2022 23:46:02 +0300","To":"Christian Rauch <Rauch.Christian@gmx.de>","Message-ID":"<Yl8fiuYRo0XdzQxq@pendragon.ideasonboard.com>","References":"<20220408014231.231083-1-Rauch.Christian@gmx.de>\n\t<20220408014231.231083-3-Rauch.Christian@gmx.de>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220408014231.231083-3-Rauch.Christian@gmx.de>","Subject":"Re: [libcamera-devel] [PATCH v3 2/4] generate fixed- and\n\tvariable-sized Span Controls","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22751,"web_url":"https://patchwork.libcamera.org/comment/22751/","msgid":"<7bb50516-dd70-008e-1478-fc31c397006b@gmx.de>","date":"2022-04-19T22:30:05","subject":"Re: [libcamera-devel] [PATCH v3 2/4] generate fixed- and\n\tvariable-sized Span Controls","submitter":{"id":111,"url":"https://patchwork.libcamera.org/api/people/111/","name":"Christian Rauch","email":"Rauch.Christian@gmx.de"},"content":"Hi Laurent,\n\nThanks for the review.\n\nApart from the std::optional patch, none of the other patches that deal\nwith Spans will compile individually. You have to merge the entire patch\nset (including the std::optional patch) to compile the fixed-sized Span\nfeature.\n\nI separated my commits logically by which part of the code base they\nchange and by which feature they add. The first patch changes the yaml\ntype definitions, the second patch updates the python script to generate\nnew code and the third patch updates the C++ code. Semantically, this\nmakes more sense to me than merging one huge commit that touches\nmultiple areas. I also think this separation makes the review easier.\n\nDoes libcamera require that every individual patch/commit is compilable?\n\nBest,\nChristian\n\n\nAm 19.04.22 um 21:46 schrieb Laurent Pinchart:\n> Hi Christian,\n>\n> Thank you for the patch.\n>\n> On Fri, Apr 08, 2022 at 02:42:29AM +0100, Christian Rauch via libcamera-devel wrote:\n>> This defines Controls with a 'size' as either variable-sized Span<T> or as\n>> fixed-sized Span<T,N>.\n>\n> As with patch 1/4, 2/4 causes new compilation failures. You will need to\n> squash 3/4 with this. It won't be enough though, there will be two more\n> compilation errors that will need to be fixed.\n>\n>> Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de>\n>> ---\n>>  utils/gen-controls.py | 32 ++++++++++++++++++++++----------\n>>  1 file changed, 22 insertions(+), 10 deletions(-)\n>>\n>> diff --git a/utils/gen-controls.py b/utils/gen-controls.py\n>> index 3f99b5e2..c9e79a22 100755\n>> --- a/utils/gen-controls.py\n>> +++ b/utils/gen-controls.py\n>> @@ -7,6 +7,7 @@\n>>  # gen-controls.py - Generate control definitions from YAML\n>>\n>>  import argparse\n>> +import math\n>>  import string\n>>  import sys\n>>  import yaml\n>> @@ -22,6 +23,25 @@ def format_description(description):\n>>      return '\\n'.join([(line and ' * ' or ' *') + line for line in description])\n>>\n>>\n>> +def get_ctrl_type(ctrl):\n>> +    ctrl_type = ctrl['type']\n>> +    ctrl_size_arr = ctrl.get('size')\n>> +    ctrl_is_span = ctrl_size_arr is not None\n>> +\n>> +    if ctrl_type == 'string':\n>> +        return 'std::string'\n>> +    elif ctrl_is_span:\n>> +        ctrl_span_size = math.prod(ctrl_size_arr) if len(ctrl_size_arr) > 0 else None\n>> +        if ctrl_span_size:\n>> +            # fixed-sized Span\n>> +            return f\"Span<const {ctrl_type}, {ctrl_span_size}>\"\n>> +        else:\n>> +            # variable-sized Span\n>> +            return f\"Span<const {ctrl_type}>\"\n>> +    else:\n>> +        return ctrl_type\n>> +\n>> +\n>>  def generate_cpp(controls):\n>>      enum_doc_start_template = string.Template('''/**\n>>   * \\\\enum ${name}Enum\n>> @@ -50,11 +70,7 @@ ${description}\n>>          name, ctrl = ctrl.popitem()\n>>          id_name = snake_case(name).upper()\n>>\n>> -        ctrl_type = ctrl['type']\n>> -        if ctrl_type == 'string':\n>> -            ctrl_type = 'std::string'\n>> -        elif ctrl.get('size'):\n>> -            ctrl_type = 'Span<const %s>' % ctrl_type\n>> +        ctrl_type = get_ctrl_type(ctrl)\n>>\n>>          info = {\n>>              'name': name,\n>> @@ -135,11 +151,7 @@ def generate_h(controls):\n>>\n>>          ids.append('\\t' + id_name + ' = ' + str(id_value) + ',')\n>>\n>> -        ctrl_type = ctrl['type']\n>> -        if ctrl_type == 'string':\n>> -            ctrl_type = 'std::string'\n>> -        elif ctrl.get('size'):\n>> -            ctrl_type = 'Span<const %s>' % ctrl_type\n>> +        ctrl_type = get_ctrl_type(ctrl)\n>>\n>>          info = {\n>>              'name': name,\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 81134C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Apr 2022 22:30:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AA69B65643;\n\tWed, 20 Apr 2022 00:30:08 +0200 (CEST)","from mout.gmx.net (mout.gmx.net [212.227.15.19])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9357E6563D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Apr 2022 00:30:06 +0200 (CEST)","from [192.168.1.209] ([92.10.251.63]) by mail.gmx.net (mrgmx005\n\t[212.227.17.190]) with ESMTPSA (Nemesis) id 1N9Mta-1o1zLO0FVs-015Mvb\n\tfor\n\t<libcamera-devel@lists.libcamera.org>; Wed, 20 Apr 2022 00:30:06 +0200"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1650407408;\n\tbh=4ryvsRD4pSzdN4/usMH+/oxa5J3af3qBujb5sh9YWpE=;\n\th=Date:Cc:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=zAW9sWxmOPpK3w0PjYtoy5vqApBL4muvXEl9tRp2gyc1L2SSEiTqgVhoGP6jIEMLI\n\t3Add/OV+6cX/iLJ9ZSCG9hAhn7WrSX5dfyTdcmXcJ57HzMnfYOxYosRNk0GjZzNzXd\n\t6MS4N2NkqRILfO2V6/43WuYHH39LehaKrjM9qp7aeYe5t+s4AYbda+2kLeUQRirnLF\n\tzVV9Zteb8DAXBtvVAmkgOaD6BIllBXBFH48xvVk1g0AYs6qPbyHrg2fswgINzdJDsW\n\txEglgo05SYH9rN8nyREDcGZmazIdASPzDBTUdEOIj0jpPWeKNQLWL1Jn/OVsKLiGyW\n\truNkLkZ7PPwew==","v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;\n\ts=badeba3b8450; t=1650407406;\n\tbh=4ryvsRD4pSzdN4/usMH+/oxa5J3af3qBujb5sh9YWpE=;\n\th=X-UI-Sender-Class:Date:Subject:Cc:References:From:In-Reply-To;\n\tb=P318uS/8zwfoBEeVPMunMeqiPNSWzTSCwA9GK5CqBjG5FHlxADgiw2NHnHAsqEHwu\n\tnBL/u0W0UOtEJ/HzxYqD2HpqnyD9w26hCpJYWwo4qXE+cGRRN1FPcXvxK3BAbfwYot\n\tMgODnvft7jDSJmgpxyYBZbOVqkgAnlz7HRAYSz54="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=gmx.net header.i=@gmx.net\n\theader.b=\"P318uS/8\"; dkim-atps=neutral","X-UI-Sender-Class":"01bb95c1-4bf8-414a-932a-4f6e2808ef9c","Message-ID":"<7bb50516-dd70-008e-1478-fc31c397006b@gmx.de>","Date":"Tue, 19 Apr 2022 23:30:05 +0100","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.7.0","Content-Language":"en-CA","Cc":"libcamera-devel@lists.libcamera.org","References":"<20220408014231.231083-1-Rauch.Christian@gmx.de>\n\t<20220408014231.231083-3-Rauch.Christian@gmx.de>\n\t<Yl8fiuYRo0XdzQxq@pendragon.ideasonboard.com>","In-Reply-To":"<Yl8fiuYRo0XdzQxq@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"quoted-printable","X-Provags-ID":"V03:K1:Z9l4BXhz4X7NhTNsqUbWsfMGtttbSyh6Dgbf8b6yTE4JyaELoc4\n\t9q3+/yh8MgF1QFy8DoXN6zWyQdY+r2Jjr1wLSqV7wPIRuENt55h7PeJadh6Utsk8aMgXEHr\n\t/all8evDESw/UiY3vSAG+LtGR/oC4oYRr/gVrQwqNlRX24ttofeOEMD9abYNFowcTwpmHFR\n\tyKLNHq8F2PAZPwU/Nz9Wg==","X-Spam-Flag":"NO","X-UI-Out-Filterresults":"notjunk:1; V03:K0:XOcGhZsdI+8=:lKGqaf8mDX0K+t8Rgmu6vB\n\tyLCZ0Ss7mzYDfkSfqlnjUTx33S8mOA+QVodlSSGCXCEPT5v4FeSSZ0BnLCH3gIi59UNpWe34j\n\tFbKiJCTAd9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YRAF80uBnZzTMI=","Subject":"Re: [libcamera-devel] [PATCH v3 2/4] generate fixed- and\n\tvariable-sized Span Controls","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Christian Rauch via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Christian Rauch <Rauch.Christian@gmx.de>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]