{"id":17558,"url":"https://patchwork.libcamera.org/api/patches/17558/?format=json","web_url":"https://patchwork.libcamera.org/patch/17558/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20221006230747.11688-4-laurent.pinchart@ideasonboard.com>","date":"2022-10-06T23:07:46","name":"[libcamera-devel,v2,3/4] libcamera: controls: Construct Span with size for array controls","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"11e0453b569448e5bca434682d8098c5e3cb832a","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17558/mbox/","series":[{"id":3541,"url":"https://patchwork.libcamera.org/api/series/3541/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3541","date":"2022-10-06T23:07:43","name":"libcamera: Improve handling of fixed-size array controls","version":2,"mbox":"https://patchwork.libcamera.org/series/3541/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17558/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17558/checks/","tags":{},"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 72FD7BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  6 Oct 2022 23:08:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2913262D07;\n\tFri,  7 Oct 2022 01:08:01 +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 3AC2962D07\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  7 Oct 2022 01:07:59 +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 B39906D6;\n\tFri,  7 Oct 2022 01:07:58 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665097681;\n\tbh=5RD1PXUGvhzpLRYGfkbmlyL16KVADQxTMpFINfHZAxg=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=1AAIcKCXjmFB+RcraLJ94GmG61nxMlZkfuA9hhwSLVaUuAyFlbzPXy2PKSp06j0kB\n\tllPcwJGPeiy6DWdbDviuR8o7orSyO0xI8RfpoxsV1izpWCbm1LXnNqiU+yLYMfWqFF\n\tq/YnkVWkWRJiRVPOKoaQIQVhwkuqADecZYl6c/CzaucOfIms8DFVxoZbxQ5iXLfmLo\n\tgUpoj+S+KAdVP8QWaIK/cycZTijVrKAMecyN3BFw/+A1IcapzKVdXmT3z0EyrjBS5+\n\tVen85p01WoLXKRGn5racEDeIVsXc2qeWfEPxXSFeNW0JgbXTLGZJGC6GjEzulWpD15\n\tAtsZlUfrtUCSA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1665097679;\n\tbh=5RD1PXUGvhzpLRYGfkbmlyL16KVADQxTMpFINfHZAxg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=qaIHJQyIBIiq+SPCXnN/fMHwRjCvQ4to7Pwfm5CJtn4VJoOMVRE0zgfYx12ldaJoK\n\tWmQg0S5zC4KCaoIejl3ogrVpqhPd3gB8wDI7goVQJlfsgRdgz6DVXb7/3jilUvjHPP\n\tsp6iyzuxepc+PxhL2nFHHzka2wW60Dnr/lekMHqM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"qaIHJQyI\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  7 Oct 2022 02:07:46 +0300","Message-Id":"<20221006230747.11688-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20221006230747.11688-1-laurent.pinchart@ideasonboard.com>","References":"<20221006230747.11688-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The ControlList::set() function overload used for array controls\nconstructs a Span from an initializer list. It doesn't specify the Span\nsize explicitly, which results in a dynamic extent Span being\nconstructed. That causes a compilation failure for fixed-size array\ncontrols, as they are defined as Control<T> with T being a fixed-extent\nSpan, and conversion from a dynamic-extent to fixed-extent Span when\ncalling ControlValue::set() can't be implicit.\n\nFix this by constructing the Span using the size of the control, which\nresolves to a fixed-extent and dynamic-extent Span for fixed-size and\ndynamic-size array controls respectively. The ControlList::set()\nfunction that takes an initializer list can then be used for fixed-size\narray controls.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/controls.h | 6 +++---\n src/libcamera/controls.cpp   | 2 +-\n 2 files changed, 4 insertions(+), 4 deletions(-)","diff":"diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 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;\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 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 \n","prefixes":["libcamera-devel","v2","3/4"]}