[{"id":21950,"web_url":"https://patchwork.libcamera.org/comment/21950/","msgid":"<YdVtTl5h0WpbiVln@pendragon.ideasonboard.com>","date":"2022-01-05T10:05:02","subject":"Re: [libcamera-devel] [PATCH v2 2/3] libcamera: v4l2_device: Add\n\tsupport for integer array controls","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Wed, Jan 05, 2022 at 08:55:52AM +0000, David Plowman wrote:\n> V4L2Device::setControl and V4L2Device::updateControl are both updated\n> to handle ControlTypeInteger32 array controls.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n\nI'm always a bit worried when changing low-level components like this,\ndue to the risk of regressions with V4L2. If any issue is found later,\nthat will mean the unit tests coverage is too narrow, so we'll fix that\n:-)\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/v4l2_device.cpp | 33 ++++++++++++++++++++++-----------\n>  1 file changed, 22 insertions(+), 11 deletions(-)\n> \n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 62c91779..3fc8438f 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -297,6 +297,18 @@ int V4L2Device::setControls(ControlList *ctrls)\n>  \t\t/* Set the v4l2_ext_control value for the write operation. */\n>  \t\tControlValue &value = ctrl->second;\n>  \t\tswitch (iter->first->type()) {\n> +\t\tcase ControlTypeInteger32: {\n> +\t\t\tif (value.isArray()) {\n> +\t\t\t\tSpan<uint8_t> data = value.data();\n> +\t\t\t\tv4l2Ctrl.p_u32 = reinterpret_cast<uint32_t *>(data.data());\n> +\t\t\t\tv4l2Ctrl.size = data.size();\n> +\t\t\t} else {\n> +\t\t\t\tv4l2Ctrl.value = value.get<int32_t>();\n> +\t\t\t}\n> +\n> +\t\t\tbreak;\n> +\t\t}\n> +\n>  \t\tcase ControlTypeInteger64:\n>  \t\t\tv4l2Ctrl.value64 = value.get<int64_t>();\n>  \t\t\tbreak;\n> @@ -671,6 +683,14 @@ void V4L2Device::updateControls(ControlList *ctrls,\n>  \t\tconst unsigned int id = v4l2Ctrl.id;\n>  \n>  \t\tControlValue value = ctrls->get(id);\n> +\t\tif (value.isArray()) {\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 for array\n> +\t\t\t * controls.\n> +\t\t\t */\n> +\t\t\tcontinue;\n> +\t\t}\n>  \n>  \t\tconst auto iter = controls_.find(id);\n>  \t\tASSERT(iter != controls_.end());\n> @@ -680,19 +700,10 @@ void V4L2Device::updateControls(ControlList *ctrls,\n>  \t\t\tvalue.set<int64_t>(v4l2Ctrl.value64);\n>  \t\t\tbreak;\n>  \n> -\t\tcase ControlTypeInteger32:\n> -\t\t\tvalue.set<int32_t>(v4l2Ctrl.value);\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 * Note: this catches the ControlTypeInteger32 case.\n> +\t\t\t *\n>  \t\t\t * \\todo To be changed when support for string controls\n>  \t\t\t * will be added.\n>  \t\t\t */","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 91F06BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jan 2022 10:05:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ED7AE60868;\n\tWed,  5 Jan 2022 11:05:09 +0100 (CET)","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 D9D7C60115\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jan 2022 11:05:07 +0100 (CET)","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 50278993;\n\tWed,  5 Jan 2022 11:05:07 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZNGoFqzi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1641377107;\n\tbh=SS5sPxWfptUksHiTEzJ6jgA9eP6lbfxlUXqG7bXrClk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ZNGoFqziYBVgV9alZ2+AsLTsstypXwEI4FGtbM5G/NIEtNLDMmx40yq07OFmtS14f\n\tocpTDY6tuE7S7iFjOK2rFV7efHhn9e57NuY86Z43kSlCcgnot8T35rayuzk3tBaj0+\n\tVF25FAc4LiJzlZFhZFgFdh8CCQrK2eylHXl2wgEw=","Date":"Wed, 5 Jan 2022 12:05:02 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YdVtTl5h0WpbiVln@pendragon.ideasonboard.com>","References":"<20220105085553.12092-1-david.plowman@raspberrypi.com>\n\t<20220105085553.12092-3-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220105085553.12092-3-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2 2/3] libcamera: v4l2_device: Add\n\tsupport for integer 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]