{"id":3231,"url":"https://patchwork.libcamera.org/api/patches/3231/?format=json","web_url":"https://patchwork.libcamera.org/patch/3231/","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":"<20200321003640.2156-4-laurent.pinchart@ideasonboard.com>","date":"2020-03-21T00:36:36","name":"[libcamera-devel,v2,3/7] libcamera: v4l2_device: Support writing array U8 controls","commit_ref":"0aa8e0977591ed0868262ca910ab12c46a46d39c","pull_url":null,"state":"accepted","archived":false,"hash":"82380c342788ddfe0ff4ec2ceac64844b89ec851","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/3231/mbox/","series":[{"id":754,"url":"https://patchwork.libcamera.org/api/series/754/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=754","date":"2020-03-21T00:36:33","name":"Add support for V4L2 array controls","version":2,"mbox":"https://patchwork.libcamera.org/series/754/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3231/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3231/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C4DBC629AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 21 Mar 2020 01:36:51 +0100 (CET)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 54E981265;\n\tSat, 21 Mar 2020 01:36:51 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584751011;\n\tbh=jZBPg1dufv7uT5Rc6od88PpVb6kEWFLbu0m+gYgRZOM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=cKkDbQlwyta9509axDiB3zq4NirmZgb7NEY/ytcgCqGvN1XBkLJfQiUgPuxFiQP7D\n\tQtCaX3G3sNoi8wuHmRwofqn04QwQ24m3vJ5z1C9Dd9VKvqy2biouetIehXX8MVyclC\n\tHr4PBT6x5rywGMWs5jvzFZ992WzzD7vf8jpk/OHo=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 21 Mar 2020 02:36:36 +0200","Message-Id":"<20200321003640.2156-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.24.1","In-Reply-To":"<20200321003640.2156-1-laurent.pinchart@ideasonboard.com>","References":"<20200321003640.2156-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 3/7] libcamera: v4l2_device: Support\n\twriting array U8 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>","X-List-Received-Date":"Sat, 21 Mar 2020 00:36:52 -0000"},"content":"From: Jacopo Mondi <jacopo@jmondi.org>\n\nAdd support to write array controls of type V4L2_CTRL_TYPE_U8.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v1:\n\n- Avoid copy of data in updateControls()\n- Use writable ControlValue storage directly for arrays in setControls()\n- Return an error when setting a control with a non-array value\n---\n src/libcamera/v4l2_device.cpp | 33 +++++++++++++++++++++++++++------\n 1 file changed, 27 insertions(+), 6 deletions(-)","diff":"diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 7eded67cb47e..2139e98bc9b8 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -250,7 +250,7 @@ int V4L2Device::setControls(ControlList *ctrls)\n \tmemset(v4l2Ctrls, 0, sizeof(v4l2Ctrls));\n \n \tunsigned int i = 0;\n-\tfor (const auto &ctrl : *ctrls) {\n+\tfor (auto &ctrl : *ctrls) {\n \t\tunsigned int id = ctrl.first;\n \t\tconst auto iter = controls_.find(id);\n \t\tif (iter == controls_.end()) {\n@@ -262,16 +262,29 @@ int V4L2Device::setControls(ControlList *ctrls)\n \t\tv4l2Ctrls[i].id = id;\n \n \t\t/* Set the v4l2_ext_control value for the write operation. */\n-\t\tconst ControlValue &value = ctrl.second;\n+\t\tControlValue &value = ctrl.second;\n \t\tswitch (iter->first->type()) {\n \t\tcase ControlTypeInteger64:\n \t\t\tv4l2Ctrls[i].value64 = value.get<int64_t>();\n \t\t\tbreak;\n+\n+\t\tcase ControlTypeByte: {\n+\t\t\tif (!value.isArray()) {\n+\t\t\t\tLOG(V4L2, Error)\n+\t\t\t\t\t<< \"Control \" << utils::hex(id)\n+\t\t\t\t\t<< \" requires an array value\";\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\n+\t\t\tSpan<uint8_t> data = value.data();\n+\t\t\tv4l2Ctrls[i].p_u8 = data.data();\n+\t\t\tv4l2Ctrls[i].size = data.size();\n+\n+\t\t\tbreak;\n+\t\t}\n+\n \t\tdefault:\n-\t\t\t/*\n-\t\t\t * \\todo To be changed when support for string and\n-\t\t\t * compound controls will be added.\n-\t\t\t */\n+\t\t\t/* \\todo To be changed to support strings. */\n \t\t\tv4l2Ctrls[i].value = value.get<int32_t>();\n \t\t\tbreak;\n \t\t}\n@@ -414,6 +427,14 @@ void V4L2Device::updateControls(ControlList *ctrls,\n \t\tcase ControlTypeInteger64:\n \t\t\tvalue.set<int64_t>(v4l2Ctrl->value64);\n \t\t\tbreak;\n+\n+\t\tcase ControlTypeByte:\n+\t\t\t/*\n+\t\t\t * No action required, the VIDIOC_[GS]_EXT_CTRLS ioctl\n+\t\t\t * accessed the ControlValue storage directly.\n+\t\t\t */\n+\t\t\tbreak;\n+\n \t\tdefault:\n \t\t\t/*\n \t\t\t * \\todo To be changed when support for string and\n","prefixes":["libcamera-devel","v2","3/7"]}