[{"id":25346,"web_url":"https://patchwork.libcamera.org/comment/25346/","msgid":"<0c44b891-9603-2bbc-c908-2d332ee18d3c@ideasonboard.com>","date":"2022-10-07T14:48:38","subject":"Re: [libcamera-devel] [PATCH v2 3/4] libcamera: controls: Construct\n\tSpan with size for 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\nOn 10/7/22 4:37 AM, Laurent Pinchart via libcamera-devel wrote:\n> The ControlList::set() function overload used for array controls\n> constructs a Span from an initializer list. It doesn't specify the Span\n> size explicitly, which results in a dynamic extent Span being\n> constructed. That causes a compilation failure for fixed-size array\n> controls, as they are defined as Control<T> with T being a fixed-extent\n> Span, and conversion from a dynamic-extent to fixed-extent Span when\n> calling ControlValue::set() can't be implicit.\n>\n> Fix this by constructing the Span using the size of the control, which\n> resolves to a fixed-extent and dynamic-extent Span for fixed-size and\n> dynamic-size array controls respectively. The ControlList::set()\n> function that takes an initializer list can then be used for fixed-size\n> array controls.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\n> ---\n>   include/libcamera/controls.h | 6 +++---\n>   src/libcamera/controls.cpp   | 2 +-\n>   2 files changed, 4 insertions(+), 4 deletions(-)\n>\n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index 38d0a3e8360a..cf94205577a5 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -393,14 +393,14 @@ public:\n>   \t\tval->set<T>(value);\n>   \t}\n>   \n> -\ttemplate<typename T, typename V>\n> -\tvoid set(const Control<T> &ctrl, const std::initializer_list<V> &value)\n> +\ttemplate<typename T, typename V, size_t Size>\n> +\tvoid set(const Control<Span<T, Size>> &ctrl, const std::initializer_list<V> &value)\n>   \t{\n>   \t\tControlValue *val = find(ctrl.id());\n>   \t\tif (!val)\n>   \t\t\treturn;\n>   \n> -\t\tval->set<T>(Span<const typename std::remove_cv_t<V>>{ value.begin(), value.size() });\n> +\t\tval->set(Span<const typename std::remove_cv_t<V>, Size>{ value.begin(), value.size() });\n>   \t}\n>   \n>   \tconst ControlValue &get(unsigned int id) const;\n> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\n> index bc3db4f69388..6dbf9b348709 100644\n> --- a/src/libcamera/controls.cpp\n> +++ b/src/libcamera/controls.cpp\n> @@ -970,7 +970,7 @@ bool ControlList::contains(unsigned int id) const\n>    */\n>   \n>   /**\n> - * \\fn ControlList::set(const Control<T> &ctrl, const std::initializer_list<V> &value)\n> + * \\fn ControlList::set(const Control<Span<T, Size>> &ctrl, const std::initializer_list<V> &value)\n>    * \\copydoc ControlList::set(const Control<T> &ctrl, const V &value)\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 E8269BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  7 Oct 2022 14:48:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9AB8762D26;\n\tFri,  7 Oct 2022 16:48:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7815F60A88\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  7 Oct 2022 16:48:44 +0200 (CEST)","from [192.168.1.103] (unknown [103.251.226.3])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3BC5BBBE;\n\tFri,  7 Oct 2022 16:48:42 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665154125;\n\tbh=QEpc91x9D5Fc+YDDjUHnclryXmc17B48ZR1p4YyWx20=;\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=bdSQwktPASkHiFb+W+mhtkcI62sVfijvnou0qN8C6v19lApWELaoqB5vaEDfnJwmR\n\t9YX6ZXebM/nufE81VXWxPXYijdBmX4guNXmYJ5rkaOLYJr7aDaSoHsonT5+gGqFHPS\n\thUaL+NAedWlLtKngsvhgNn5tP0YC2sfWLXRTtSCE3OSx4ggtNqDs2V970K2unBrl9v\n\t+bzvOKVXPs2f0nrf7gExeRoZelqazd99Y8bSpGM/bhS+R9MlH9muGofkzgcbM5qe6u\n\tEGQMEQePFGlWEiUJswNGKwi0uGDME24Ip2tsY0QE90RVeVn9AONGvfqugxhrsSY++Q\n\tL/qMcMeJKP0ig==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1665154124;\n\tbh=QEpc91x9D5Fc+YDDjUHnclryXmc17B48ZR1p4YyWx20=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=CKGxXs0Fb0e/GN0DccboKiPfIbOSZ5XRwiYspNitrFvu483RBdkcuJtKPqwQlA/I1\n\tbHkLwsddJhUmLg8KNgxQ1H3gQzM94aXJmAfKtDn3KTSIdYK7fKLfPnq5sYzlvhvulr\n\tDg8tat9/S/PAfCxseAmFplDXA3lxlCk0muJu2l2U="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"CKGxXs0F\"; dkim-atps=neutral","Message-ID":"<0c44b891-9603-2bbc-c908-2d332ee18d3c@ideasonboard.com>","Date":"Fri, 7 Oct 2022 20:18:38 +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-4-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20221006230747.11688-4-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 3/4] libcamera: controls: Construct\n\tSpan with size for 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>"}}]