{"id":15791,"url":"https://patchwork.libcamera.org/api/1.1/patches/15791/?format=json","web_url":"https://patchwork.libcamera.org/patch/15791/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20220505104104.70841-9-tomi.valkeinen@ideasonboard.com>","date":"2022-05-05T10:40:59","name":"[libcamera-devel,v7,08/13] py: support setting array-controls","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"248ab18b8b77a04946099720a4414410fd294e55","submitter":{"id":109,"url":"https://patchwork.libcamera.org/api/1.1/people/109/?format=json","name":"Tomi Valkeinen","email":"tomi.valkeinen@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15791/mbox/","series":[{"id":3093,"url":"https://patchwork.libcamera.org/api/1.1/series/3093/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3093","date":"2022-05-05T10:40:51","name":"Python bindings","version":7,"mbox":"https://patchwork.libcamera.org/series/3093/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15791/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15791/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 F04DDC0F2A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  5 May 2022 10:41:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2FA4465658;\n\tThu,  5 May 2022 12:41:35 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EBCA165658\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  5 May 2022 12:41:29 +0200 (CEST)","from deskari.lan (91-156-85-209.elisa-laajakaista.fi\n\t[91.156.85.209])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5E5414A8;\n\tThu,  5 May 2022 12:41:29 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1651747295;\n\tbh=PVAyCaitM3siiYv1k27wm6GStBa71P4ZGo3rLLegKjY=;\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=iGDRsb5Y5O3D6kTTnHgBT9yvP1nFLUDrlvsja+nTywMY+c9gLRTbyNK1CNh+Ilr51\n\tEZkls9U2unVGHiZbT+ZCAZ4Cm3nEe/3c8KrJVX2AoPc2VU+I011VXLxK1kOKx7cGe/\n\tXgbulhlj8ICsND5sPGZvOi4cFAVNfmHbtkLIlorR0hNpBVd3J2OIyaFp/pXBEpRpMm\n\ttw6rD87dACKUopyO5KPc7Z/ISL+FbhIeGZ5sjX/UMN9ycKtBVh6jq+CluInfjTrFbn\n\tPA536hn7LVQIGvi/JHHCFRYRLHIMxoF+3+q7QXjAonKLi9CEkBlfwVPt3b2W4JQHHG\n\t4kHdSvk4s+tvg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1651747289;\n\tbh=PVAyCaitM3siiYv1k27wm6GStBa71P4ZGo3rLLegKjY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=hrJEj6PIlgG6oVEO5I3Lq1HZGCQ/ygE5SDfH9dyX4Xhkwm3X+tzqDs6+zkRS+JZAC\n\t8nv/by9B5zVgzyYaGLtNzSqM3Mvm6/cMEAJW/Xkkbv4ElV8RSeSBasamDKMv6BhD/I\n\tcfhy338eRCxwFrIuGsJeqCKIRK9cXqFFOsbaS94Y="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"hrJEj6PI\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org,\n\tDavid Plowman <david.plowman@raspberrypi.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tJacopo Mondi <jacopo@jmondi.org>","Date":"Thu,  5 May 2022 13:40:59 +0300","Message-Id":"<20220505104104.70841-9-tomi.valkeinen@ideasonboard.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20220505104104.70841-1-tomi.valkeinen@ideasonboard.com>","References":"<20220505104104.70841-1-tomi.valkeinen@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v7 08/13] py: support setting\n\tarray-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":"Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Improve PyToControlValue() to convert python lists and tuples to a\nControlValue with a Span<> value.\n\nOriginal version from David Plowman <david.plowman@raspberrypi.com>.\n\nSigned-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n---\n src/py/libcamera/pymain.cpp | 19 +++++++++++++++----\n 1 file changed, 15 insertions(+), 4 deletions(-)","diff":"diff --git a/src/py/libcamera/pymain.cpp b/src/py/libcamera/pymain.cpp\nindex 81d48a20..db9d90ab 100644\n--- a/src/py/libcamera/pymain.cpp\n+++ b/src/py/libcamera/pymain.cpp\n@@ -75,19 +75,30 @@ static py::object ControlValueToPy(const ControlValue &cv)\n \t}\n }\n \n+template<typename T>\n+static ControlValue ControlValueMaybeArray(const py::object &ob)\n+{\n+\tif (py::isinstance<py::list>(ob) || py::isinstance<py::tuple>(ob)) {\n+\t\tstd::vector<T> vec = ob.cast<std::vector<T>>();\n+\t\treturn ControlValue(Span<const T>(vec));\n+\t}\n+\n+\treturn ControlValue(ob.cast<T>());\n+}\n+\n static ControlValue PyToControlValue(const py::object &ob, ControlType type)\n {\n \tswitch (type) {\n \tcase ControlTypeBool:\n \t\treturn ControlValue(ob.cast<bool>());\n \tcase ControlTypeByte:\n-\t\treturn ControlValue(ob.cast<uint8_t>());\n+\t\treturn ControlValueMaybeArray<uint8_t>(ob);\n \tcase ControlTypeInteger32:\n-\t\treturn ControlValue(ob.cast<int32_t>());\n+\t\treturn ControlValueMaybeArray<int32_t>(ob);\n \tcase ControlTypeInteger64:\n-\t\treturn ControlValue(ob.cast<int64_t>());\n+\t\treturn ControlValueMaybeArray<int64_t>(ob);\n \tcase ControlTypeFloat:\n-\t\treturn ControlValue(ob.cast<float>());\n+\t\treturn ControlValueMaybeArray<float>(ob);\n \tcase ControlTypeString:\n \t\treturn ControlValue(ob.cast<string>());\n \tcase ControlTypeRectangle:\n","prefixes":["libcamera-devel","v7","08/13"]}