[{"id":25342,"web_url":"https://patchwork.libcamera.org/comment/25342/","msgid":"<03cd6c26-6aee-0311-c315-46885368678f@ideasonboard.com>","date":"2022-10-07T14:36:55","subject":"Re: [libcamera-devel] [PATCH v2 2/4] utils: gen-controls: Improve\n\tYAML notation for variable-size array controls","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Laurent,\n\nThank you for the patch.\n\nOn 10/7/22 4:37 AM, Laurent Pinchart via libcamera-devel wrote:\n> Array controls specify the array size through the YAML 'size' element,\n> which stores a list of values, one per dimension. Variable-size arrays\n> currently use an empty 'size' list, which prevents describing the number\n> of dimensions of the array.\n>\n> Improve this by using the same notation for fixed-size and variable-size\n> array controls. Dimensions that are not fixed are described as a string\n> instead of an integer, such as [n], [n,3] or [w,h]. The strings have\n> currently no special meaning, this may change in the future.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>   src/libcamera/control_ids.yaml  |  2 +-\n>   src/libcamera/property_ids.yaml |  4 ++--\n>   utils/gen-controls.py           | 31 +++++++++++++++++++++++++------\n>   3 files changed, 28 insertions(+), 9 deletions(-)\n>\n> diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml\n> index c93f362463dd..a456e6c0358f 100644\n> --- a/src/libcamera/control_ids.yaml\n> +++ b/src/libcamera/control_ids.yaml\n> @@ -525,7 +525,7 @@ controls:\n>           the window where the focal distance for the objects shown in that part\n>           of the image are closest to the camera.\n>   \n> -      size: []\n> +      size: [n]\n>   \n>     - AfTrigger:\n>         type: int32_t\n> diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml\n> index 960e254495b7..cb55e0ed2283 100644\n> --- a/src/libcamera/property_ids.yaml\n> +++ b/src/libcamera/property_ids.yaml\n> @@ -497,7 +497,7 @@ controls:\n>   \n>     - PixelArrayOpticalBlackRectangles:\n>         type: Rectangle\n> -      size: []\n> +      size: [n]\n>         description: |\n>           The pixel array region(s) which contain optical black pixels\n>           considered valid for calibration purposes.\n> @@ -592,7 +592,7 @@ controls:\n>   \n>     - PixelArrayActiveAreas:\n>         type: Rectangle\n> -      size: []\n> +      size: [n]\n>         description: |\n>           The PixelArrayActiveAreas property defines the (possibly multiple and\n>           overlapping) portions of the camera sensor readable pixel matrix\n> diff --git a/utils/gen-controls.py b/utils/gen-controls.py\n> index d6b4e30001b2..45b7081e6b1d 100755\n> --- a/utils/gen-controls.py\n> +++ b/utils/gen-controls.py\n> @@ -39,11 +39,33 @@ class Control(object):\n>           self.__name = name\n>           self.__data = data\n>           self.__enum_values = None\n> +        self.__size = None\n>   \n>           enum_values = data.get('enum')\n>           if enum_values is not None:\n>               self.__enum_values = [ControlEnum(enum) for enum in enum_values]\n>   \n> +        size = self.__data.get('size')\n> +        if size is not None:\n> +            if len(size) == 0:\n> +                raise RuntimeError(f'Control `{self.__name}` size must have at least one dimension')\n\nNot sure if there's a case where size is not None, but has len(size) == \n0; Anyways, it's not harmful to have a guard here\n> +\n> +            # Compute the total number of elemens in the array. If any of the\n\ns/elemens/elements/\n> +            # array dimension is a string, the array is variable-sized.\n> +            num_elems = 1\n> +            for dim in size:\n> +                if type(dim) is str:\n> +                    num_elems = 0\n> +                    break\n> +\n> +                dim = int(dim)\n> +                if dim <= 0:\n> +                    raise RuntimeError(f'Control `{self.__name}` size must have positive values only')\n> +\n> +                num_elems *= dim\n> +\n> +            self.__size = num_elems\n> +\n\nLooks good!\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\n>       @property\n>       def description(self):\n>           \"\"\"The control description\"\"\"\n> @@ -86,15 +108,12 @@ class Control(object):\n>           if typ == 'string':\n>               return 'std::string'\n>   \n> -        if size is None:\n> +        if self.__size is None:\n>               return typ\n>   \n> -        if len(size) > 0:\n> -            # fixed-sized Span\n> -            span_size = reduce(operator.mul, size)\n> -            return f\"Span<const {typ}, {span_size}>\"\n> +        if self.__size:\n> +            return f\"Span<const {typ}, {self.__size}>\"\n>           else:\n> -            # variable-sized Span\n>               return f\"Span<const {typ}>\"\n>   \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 77013BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  7 Oct 2022 14:37:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D5D3262D22;\n\tFri,  7 Oct 2022 16:37:02 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DE51460A88\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  7 Oct 2022 16:37:01 +0200 (CEST)","from [192.168.1.103] (unknown [103.251.226.3])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8CF16BBE;\n\tFri,  7 Oct 2022 16:37:00 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665153422;\n\tbh=kMKnk7vYMbVnCvtdttHup74K4m7noLQkWqqcApn1+Rk=;\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:\n\tFrom;\n\tb=HN0Uh33l/HpsJ1pPMjMstHnp5eGeeLsEg4nWictWPa5FEgq376m3b8xoBPNv5UET7\n\tbHwQNcyj1y8VTh7KWpyfLFviNs//In/LaM9o6sGgv4VAoXCB/BoYuPOOgNiW6TMQEE\n\tlnYOIV1xCVPfy+ZekMHi5gU08dCYL5FJcc5QCIxmreJYdeOcDh5KljQjMIUeh+8LTO\n\tnvfqylyaEzOOScp1hWc/x6CYZ5C6A9Z8woiUOXUyDkncrpDeVTQhqaO6qNbEy8WAo1\n\t+NWAcFk0GiM13zJHUST3/UKxt6Dycl1mGE449TbQ0BzcXVdZIatHJ6eutcyQSbgl5H\n\t5pdwXAoZP4rsw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1665153421;\n\tbh=kMKnk7vYMbVnCvtdttHup74K4m7noLQkWqqcApn1+Rk=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=osFztyTNIWLGb9aRTkj2HnfKwyo3gBeUbLcGj6Rzj8WvnYKyLJFbzxEX4X/zumXhu\n\tcW1oRukLNaRjbd7oB4xmr0PBak4e3m+PcjlyNjq48SloYL/e5dkA7NcZt/me2RN6Xq\n\tdVZVT8x26BPUHJ/B0TAfkWu6LJ01CYELXV5s9WMM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"osFztyTN\"; dkim-atps=neutral","Message-ID":"<03cd6c26-6aee-0311-c315-46885368678f@ideasonboard.com>","Date":"Fri, 7 Oct 2022 20:06:55 +0530","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101\n\tThunderbird/102.2.1","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20221006230747.11688-1-laurent.pinchart@ideasonboard.com>\n\t<20221006230747.11688-3-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20221006230747.11688-3-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 2/4] utils: gen-controls: Improve\n\tYAML notation for variable-size array 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":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":25343,"web_url":"https://patchwork.libcamera.org/comment/25343/","msgid":"<Y0A7V7H+MZKcHifo@pendragon.ideasonboard.com>","date":"2022-10-07T14:44:39","subject":"Re: [libcamera-devel] [PATCH v2 2/4] utils: gen-controls: Improve\n\tYAML notation for variable-size array controls","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nOn Fri, Oct 07, 2022 at 08:06:55PM +0530, Umang Jain wrote:\n> On 10/7/22 4:37 AM, Laurent Pinchart via libcamera-devel wrote:\n> > Array controls specify the array size through the YAML 'size' element,\n> > which stores a list of values, one per dimension. Variable-size arrays\n> > currently use an empty 'size' list, which prevents describing the number\n> > of dimensions of the array.\n> >\n> > Improve this by using the same notation for fixed-size and variable-size\n> > array controls. Dimensions that are not fixed are described as a string\n> > instead of an integer, such as [n], [n,3] or [w,h]. The strings have\n> > currently no special meaning, this may change in the future.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >   src/libcamera/control_ids.yaml  |  2 +-\n> >   src/libcamera/property_ids.yaml |  4 ++--\n> >   utils/gen-controls.py           | 31 +++++++++++++++++++++++++------\n> >   3 files changed, 28 insertions(+), 9 deletions(-)\n> >\n> > diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml\n> > index c93f362463dd..a456e6c0358f 100644\n> > --- a/src/libcamera/control_ids.yaml\n> > +++ b/src/libcamera/control_ids.yaml\n> > @@ -525,7 +525,7 @@ controls:\n> >           the window where the focal distance for the objects shown in that part\n> >           of the image are closest to the camera.\n> >   \n> > -      size: []\n> > +      size: [n]\n> >   \n> >     - AfTrigger:\n> >         type: int32_t\n> > diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml\n> > index 960e254495b7..cb55e0ed2283 100644\n> > --- a/src/libcamera/property_ids.yaml\n> > +++ b/src/libcamera/property_ids.yaml\n> > @@ -497,7 +497,7 @@ controls:\n> >   \n> >     - PixelArrayOpticalBlackRectangles:\n> >         type: Rectangle\n> > -      size: []\n> > +      size: [n]\n> >         description: |\n> >           The pixel array region(s) which contain optical black pixels\n> >           considered valid for calibration purposes.\n> > @@ -592,7 +592,7 @@ controls:\n> >   \n> >     - PixelArrayActiveAreas:\n> >         type: Rectangle\n> > -      size: []\n> > +      size: [n]\n> >         description: |\n> >           The PixelArrayActiveAreas property defines the (possibly multiple and\n> >           overlapping) portions of the camera sensor readable pixel matrix\n> > diff --git a/utils/gen-controls.py b/utils/gen-controls.py\n> > index d6b4e30001b2..45b7081e6b1d 100755\n> > --- a/utils/gen-controls.py\n> > +++ b/utils/gen-controls.py\n> > @@ -39,11 +39,33 @@ class Control(object):\n> >           self.__name = name\n> >           self.__data = data\n> >           self.__enum_values = None\n> > +        self.__size = None\n> >   \n> >           enum_values = data.get('enum')\n> >           if enum_values is not None:\n> >               self.__enum_values = [ControlEnum(enum) for enum in enum_values]\n> >   \n> > +        size = self.__data.get('size')\n> > +        if size is not None:\n> > +            if len(size) == 0:\n> > +                raise RuntimeError(f'Control `{self.__name}` size must have at least one dimension')\n> \n> Not sure if there's a case where size is not None, but has len(size) == \n> 0; Anyways, it's not harmful to have a guard here\n\nIt happens with '[]'.\n\n> > +\n> > +            # Compute the total number of elemens in the array. If any of the\n> \n> s/elemens/elements/\n> \n> > +            # array dimension is a string, the array is variable-sized.\n> > +            num_elems = 1\n> > +            for dim in size:\n> > +                if type(dim) is str:\n> > +                    num_elems = 0\n> > +                    break\n> > +\n> > +                dim = int(dim)\n> > +                if dim <= 0:\n> > +                    raise RuntimeError(f'Control `{self.__name}` size must have positive values only')\n> > +\n> > +                num_elems *= dim\n> > +\n> > +            self.__size = num_elems\n> > +\n> \n> Looks good!\n> \n> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n> \n> >       @property\n> >       def description(self):\n> >           \"\"\"The control description\"\"\"\n> > @@ -86,15 +108,12 @@ class Control(object):\n> >           if typ == 'string':\n> >               return 'std::string'\n> >   \n> > -        if size is None:\n> > +        if self.__size is None:\n> >               return typ\n> >   \n> > -        if len(size) > 0:\n> > -            # fixed-sized Span\n> > -            span_size = reduce(operator.mul, size)\n> > -            return f\"Span<const {typ}, {span_size}>\"\n> > +        if self.__size:\n> > +            return f\"Span<const {typ}, {self.__size}>\"\n> >           else:\n> > -            # variable-sized Span\n> >               return f\"Span<const {typ}>\"\n> >   \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 7EF25C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  7 Oct 2022 14:44:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D1C5462D22;\n\tFri,  7 Oct 2022 16:44:46 +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 2B12660A88\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  7 Oct 2022 16:44:45 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6EEFFBBE;\n\tFri,  7 Oct 2022 16:44:44 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665153886;\n\tbh=XWPiORms+axFx9vNwhsjTE/7dVdZkgGSI1mxS6Bx1q0=;\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=yHayiRihThklf74G46epslfziUd5rOb+lS74PSh+z5JAE0CGWcKlTUYU6EdCLpknw\n\ty7X8+7iYtgY9HEI+98DqeEe+7yMccHiQrgsfRwC0BMwhqAQFDk6+yvekuAVNJUyT82\n\tQNtwRG6QUCQzJoHLp/a/qthHAmrVKjEE6b7V/9ko/KBYfPmbcthhZroRUf/DoeCjuL\n\tBAz8CQz8RRLpqkEZEhjQXVlaMoUUxQmhUmP2r1KwbmwZvpJMrngNoAPbsxL7FID78K\n\tIORqrnFuicMPGoRTl2FrBh2ZrGv/ZP05n8JCexkWG1Bfs/sU+jXEjT/b3URCHE1KQF\n\tHII4cPSzcFyDg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1665153884;\n\tbh=XWPiORms+axFx9vNwhsjTE/7dVdZkgGSI1mxS6Bx1q0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=o28hoEn0W9zbsizviIgLhhZug+uJL+ag95mIpdp0tujgrIBSbz5pES8Qb64MCu2Ui\n\typzVbsPo4yP1B7n9JNs0cTtMufwQHmLow3GUtRmKR/E8bskQ+S66HYW0RU0ae/9IcK\n\t3oGIchww+5H0cXTjyxlF60OsIAetPuGiYDALE5BA="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"o28hoEn0\"; dkim-atps=neutral","Date":"Fri, 7 Oct 2022 17:44:39 +0300","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<Y0A7V7H+MZKcHifo@pendragon.ideasonboard.com>","References":"<20221006230747.11688-1-laurent.pinchart@ideasonboard.com>\n\t<20221006230747.11688-3-laurent.pinchart@ideasonboard.com>\n\t<03cd6c26-6aee-0311-c315-46885368678f@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<03cd6c26-6aee-0311-c315-46885368678f@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 2/4] utils: gen-controls: Improve\n\tYAML notation for variable-size array 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":25344,"web_url":"https://patchwork.libcamera.org/comment/25344/","msgid":"<36cca478-df95-7ac7-4f1a-3ed1bfb116b7@ideasonboard.com>","date":"2022-10-07T14:46:13","subject":"Re: [libcamera-devel] [PATCH v2 2/4] utils: gen-controls: Improve\n\tYAML notation for variable-size array controls","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi,\n\nOn 10/7/22 8:14 PM, Laurent Pinchart wrote:\n> Hi Umang,\n>\n> On Fri, Oct 07, 2022 at 08:06:55PM +0530, Umang Jain wrote:\n>> On 10/7/22 4:37 AM, Laurent Pinchart via libcamera-devel wrote:\n>>> Array controls specify the array size through the YAML 'size' element,\n>>> which stores a list of values, one per dimension. Variable-size arrays\n>>> currently use an empty 'size' list, which prevents describing the number\n>>> of dimensions of the array.\n>>>\n>>> Improve this by using the same notation for fixed-size and variable-size\n>>> array controls. Dimensions that are not fixed are described as a string\n>>> instead of an integer, such as [n], [n,3] or [w,h]. The strings have\n>>> currently no special meaning, this may change in the future.\n>>>\n>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>>> ---\n>>>    src/libcamera/control_ids.yaml  |  2 +-\n>>>    src/libcamera/property_ids.yaml |  4 ++--\n>>>    utils/gen-controls.py           | 31 +++++++++++++++++++++++++------\n>>>    3 files changed, 28 insertions(+), 9 deletions(-)\n>>>\n>>> diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml\n>>> index c93f362463dd..a456e6c0358f 100644\n>>> --- a/src/libcamera/control_ids.yaml\n>>> +++ b/src/libcamera/control_ids.yaml\n>>> @@ -525,7 +525,7 @@ controls:\n>>>            the window where the focal distance for the objects shown in that part\n>>>            of the image are closest to the camera.\n>>>    \n>>> -      size: []\n>>> +      size: [n]\n>>>    \n>>>      - AfTrigger:\n>>>          type: int32_t\n>>> diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml\n>>> index 960e254495b7..cb55e0ed2283 100644\n>>> --- a/src/libcamera/property_ids.yaml\n>>> +++ b/src/libcamera/property_ids.yaml\n>>> @@ -497,7 +497,7 @@ controls:\n>>>    \n>>>      - PixelArrayOpticalBlackRectangles:\n>>>          type: Rectangle\n>>> -      size: []\n>>> +      size: [n]\n>>>          description: |\n>>>            The pixel array region(s) which contain optical black pixels\n>>>            considered valid for calibration purposes.\n>>> @@ -592,7 +592,7 @@ controls:\n>>>    \n>>>      - PixelArrayActiveAreas:\n>>>          type: Rectangle\n>>> -      size: []\n>>> +      size: [n]\n>>>          description: |\n>>>            The PixelArrayActiveAreas property defines the (possibly multiple and\n>>>            overlapping) portions of the camera sensor readable pixel matrix\n>>> diff --git a/utils/gen-controls.py b/utils/gen-controls.py\n>>> index d6b4e30001b2..45b7081e6b1d 100755\n>>> --- a/utils/gen-controls.py\n>>> +++ b/utils/gen-controls.py\n>>> @@ -39,11 +39,33 @@ class Control(object):\n>>>            self.__name = name\n>>>            self.__data = data\n>>>            self.__enum_values = None\n>>> +        self.__size = None\n>>>    \n>>>            enum_values = data.get('enum')\n>>>            if enum_values is not None:\n>>>                self.__enum_values = [ControlEnum(enum) for enum in enum_values]\n>>>    \n>>> +        size = self.__data.get('size')\n>>> +        if size is not None:\n>>> +            if len(size) == 0:\n>>> +                raise RuntimeError(f'Control `{self.__name}` size must have at least one dimension')\n>> Not sure if there's a case where size is not None, but has len(size) ==\n>> 0; Anyways, it's not harmful to have a guard here\n> It happens with '[]'.\n\nAh that makes sense now... my python chops a bit rusty..\n>\n>>> +\n>>> +            # Compute the total number of elemens in the array. If any of the\n>> s/elemens/elements/\n>>\n>>> +            # array dimension is a string, the array is variable-sized.\n>>> +            num_elems = 1\n>>> +            for dim in size:\n>>> +                if type(dim) is str:\n>>> +                    num_elems = 0\n>>> +                    break\n>>> +\n>>> +                dim = int(dim)\n>>> +                if dim <= 0:\n>>> +                    raise RuntimeError(f'Control `{self.__name}` size must have positive values only')\n>>> +\n>>> +                num_elems *= dim\n>>> +\n>>> +            self.__size = num_elems\n>>> +\n>> Looks good!\n>>\n>> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n>>\n>>>        @property\n>>>        def description(self):\n>>>            \"\"\"The control description\"\"\"\n>>> @@ -86,15 +108,12 @@ class Control(object):\n>>>            if typ == 'string':\n>>>                return 'std::string'\n>>>    \n>>> -        if size is None:\n>>> +        if self.__size is None:\n>>>                return typ\n>>>    \n>>> -        if len(size) > 0:\n>>> -            # fixed-sized Span\n>>> -            span_size = reduce(operator.mul, size)\n>>> -            return f\"Span<const {typ}, {span_size}>\"\n>>> +        if self.__size:\n>>> +            return f\"Span<const {typ}, {self.__size}>\"\n>>>            else:\n>>> -            # variable-sized Span\n>>>                return f\"Span<const {typ}>\"\n>>>    \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 B709BC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  7 Oct 2022 14:46:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 708BA62D25;\n\tFri,  7 Oct 2022 16:46:19 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 781F960A88\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  7 Oct 2022 16:46:18 +0200 (CEST)","from [192.168.1.103] (unknown [103.251.226.3])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 95148BBE;\n\tFri,  7 Oct 2022 16:46:17 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665153979;\n\tbh=bUa87wVp8xpA4Pb9Rel6wi54XYIhM0RNJomfI8IA1k4=;\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=4FuqaMfMEJw8l7jRRstq/kGlyZb176gsvRsNxpJ3g1mWe35GgsNKb5mrUWdoTIDUA\n\tnteevCB76SK69/ZklA3kYqJIp+/miI41o/SfVUf5mmJBKdCH/DMlxWwmITnSjGWsc3\n\tZrfyBYsPBf234qa0GryRdnxSt3TwBA/BmEuyr8fDqszgrtMggTF8mDzWX0Lmllh44u\n\tzF5W2uTq/xthwOi/YKTulbcHiR06wi6+PVCKk/a2/1qQQenCDFn9Msalqv30QjRhzL\n\t595ZBTpyGZ1UR8eYZ/d1DtCfe5s9oWF6U1WGbgjtEk1oYjsP2NuwonsegHF/T4D4Ec\n\tGWXCOD+hicSFw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1665153978;\n\tbh=bUa87wVp8xpA4Pb9Rel6wi54XYIhM0RNJomfI8IA1k4=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=wN1RQzkgJuiOSSJTOKHsG5uHyMbSmfFZFsyphhyEE1sA11YEvK6jSCKfr1u3llxLN\n\tEsNYKhP6ujgNGD/oPNu/3o0h1GLrkVI0aR3QScb00SFeDjNYPo5DtlmIYNWY1A6sbU\n\tHR18oeBr/EmSmUeTQozzsuShRIZeDy82l20hlMUk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"wN1RQzkg\"; dkim-atps=neutral","Message-ID":"<36cca478-df95-7ac7-4f1a-3ed1bfb116b7@ideasonboard.com>","Date":"Fri, 7 Oct 2022 20:16:13 +0530","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101\n\tThunderbird/102.2.1","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20221006230747.11688-1-laurent.pinchart@ideasonboard.com>\n\t<20221006230747.11688-3-laurent.pinchart@ideasonboard.com>\n\t<03cd6c26-6aee-0311-c315-46885368678f@ideasonboard.com>\n\t<Y0A7V7H+MZKcHifo@pendragon.ideasonboard.com>","In-Reply-To":"<Y0A7V7H+MZKcHifo@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 2/4] utils: gen-controls: Improve\n\tYAML notation for variable-size array 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":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@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>"}}]