[{"id":30467,"web_url":"https://patchwork.libcamera.org/comment/30467/","msgid":"<3d2fqin2ftqw4rc2ctepes2cvnqvl264c2qsotziskcaov5ln3@e2h3evengrio>","date":"2024-07-24T13:07:11","subject":"Re: [RFC PATCH 1/6] libcamera: v4l2_device: Add support for\n\tV4L2_CTRL_TYPE_U32","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Umang\n\nOn Fri, Jul 12, 2024 at 10:59:15AM GMT, Umang Jain wrote:\n> Support for the U16 and U32 compound control types is missing. U16 will\n> require a new libcamera control type, but U32 maps to the existing\n> ControlTypeInteger32 and can be added easily.\n\nCan this patch be broken out and fast-tracked maybe ?\n\n>\n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>  include/libcamera/controls.h  |  5 +++++\n>  src/libcamera/v4l2_device.cpp | 11 +++++++++++\n>  2 files changed, 16 insertions(+)\n>\n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index 7c2bb287..c6db4ebb 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -57,6 +57,11 @@ struct control_type<uint8_t> {\n>  \tstatic constexpr ControlType value = ControlTypeByte;\n>  };\n>\n> +template<>\n> +struct control_type<uint32_t> {\n> +\tstatic constexpr ControlType value = ControlTypeInteger32;\n> +};\n> +\n>  template<>\n>  struct control_type<int32_t> {\n>  \tstatic constexpr ControlType value = ControlTypeInteger32;\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 4a2048cf..db20f31c 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -212,6 +212,10 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)\n>  \t\t\t\ttype = ControlTypeByte;\n>  \t\t\t\tbreak;\n>\n> +\t\t\tcase V4L2_CTRL_TYPE_U32:\n> +\t\t\t\ttype = ControlTypeInteger32;\n> +\t\t\t\tbreak;\n> +\n>  \t\t\tdefault:\n>  \t\t\t\tLOG(V4L2, Error)\n>  \t\t\t\t\t<< \"Unsupported payload control type \"\n\nI was about to say that you should also have changed the below\n\n\t\t\tv4l2Ctrl.p_u8 = data.data();\n\nto\n\n\t\t\tv4l2Ctrl.p_u32 = data.data();\n\nBut as this is a union it probably doesn't make a difference as we\ndon't access the control value by pointer but the content will be\nstored in ControlValue::data ?\n\nHave you verified you can actually read the content of\nthe array control using p_u8 unconditionally ?\n\n\n> @@ -491,6 +495,7 @@ ControlType V4L2Device::v4l2CtrlType(uint32_t ctrlType)\n>  \t\treturn ControlTypeBool;\n>\n>  \tcase V4L2_CTRL_TYPE_INTEGER:\n> +\tcase V4L2_CTRL_TYPE_U32:\n>  \t\treturn ControlTypeInteger32;\n>\n>  \tcase V4L2_CTRL_TYPE_INTEGER64:\n> @@ -543,6 +548,11 @@ std::optional<ControlInfo> V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl\n>  \t\t\t\t   static_cast<bool>(ctrl.maximum),\n>  \t\t\t\t   static_cast<bool>(ctrl.default_value));\n>\n> +\tcase V4L2_CTRL_TYPE_U32:\n> +\t\treturn ControlInfo(static_cast<uint32_t>(ctrl.minimum),\n> +\t\t\t\t   static_cast<uint32_t>(ctrl.maximum),\n> +\t\t\t\t   static_cast<uint32_t>(ctrl.default_value));\n> +\n>  \tcase V4L2_CTRL_TYPE_INTEGER64:\n>  \t\treturn ControlInfo(static_cast<int64_t>(ctrl.minimum),\n>  \t\t\t\t   static_cast<int64_t>(ctrl.maximum),\n> @@ -624,6 +634,7 @@ void V4L2Device::listControls()\n>  \t\tcase V4L2_CTRL_TYPE_BITMASK:\n>  \t\tcase V4L2_CTRL_TYPE_INTEGER_MENU:\n>  \t\tcase V4L2_CTRL_TYPE_U8:\n> +\t\tcase V4L2_CTRL_TYPE_U32:\n>  \t\t\tbreak;\n>  \t\t/* \\todo Support other control types. */\n>  \t\tdefault:\n> --\n> 2.45.0\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 1D920C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Jul 2024 13:07:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C33DA6336F;\n\tWed, 24 Jul 2024 15:07:17 +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 C85BA619A0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jul 2024 15:07:15 +0200 (CEST)","from ideasonboard.com (unknown [91.80.74.127])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9002B4CD;\n\tWed, 24 Jul 2024 15:06:32 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"e2/BYp4p\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1721826392;\n\tbh=MxrEz2Yqdx13wsJ17kPCejGcYlUXMBoFVVd0hRfMcFQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=e2/BYp4pEiKU3Dt5h69Pr+IFoxG2v0ojdjhGeK6T6nKl8ZJXWbluCti19jeVmbVXt\n\t5sgv2nMR0fugI44NwLYwC9o7cQlmNXe25vszTVrfAti8H3/w0PbomD4Rt2z7s6VEYT\n\tr9YVwUuCv8zuNJMAgvrwUAuWlJ8SvkYOv+GexHSg=","Date":"Wed, 24 Jul 2024 15:07:11 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tXavier Roumegue <xavier.roumegue@oss.nxp.com>","Subject":"Re: [RFC PATCH 1/6] libcamera: v4l2_device: Add support for\n\tV4L2_CTRL_TYPE_U32","Message-ID":"<3d2fqin2ftqw4rc2ctepes2cvnqvl264c2qsotziskcaov5ln3@e2h3evengrio>","References":"<20240712052920.33396-1-umang.jain@ideasonboard.com>\n\t<20240712052920.33396-2-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240712052920.33396-2-umang.jain@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30553,"web_url":"https://patchwork.libcamera.org/comment/30553/","msgid":"<20240802222552.GB3319@pendragon.ideasonboard.com>","date":"2024-08-02T22:25:52","subject":"Re: [RFC PATCH 1/6] libcamera: v4l2_device: Add support for\n\tV4L2_CTRL_TYPE_U32","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nThank you for the patch.\n\nOn Fri, Jul 12, 2024 at 10:59:15AM +0530, Umang Jain wrote:\n> Support for the U16 and U32 compound control types is missing. U16 will\n> require a new libcamera control type, but U32 maps to the existing\n> ControlTypeInteger32 and can be added easily.\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>  include/libcamera/controls.h  |  5 +++++\n>  src/libcamera/v4l2_device.cpp | 11 +++++++++++\n>  2 files changed, 16 insertions(+)\n> \n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index 7c2bb287..c6db4ebb 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -57,6 +57,11 @@ struct control_type<uint8_t> {\n>  \tstatic constexpr ControlType value = ControlTypeByte;\n>  };\n>  \n> +template<>\n> +struct control_type<uint32_t> {\n> +\tstatic constexpr ControlType value = ControlTypeInteger32;\n> +};\n> +\n>  template<>\n>  struct control_type<int32_t> {\n>  \tstatic constexpr ControlType value = ControlTypeInteger32;\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 4a2048cf..db20f31c 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -212,6 +212,10 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)\n>  \t\t\t\ttype = ControlTypeByte;\n>  \t\t\t\tbreak;\n>  \n> +\t\t\tcase V4L2_CTRL_TYPE_U32:\n> +\t\t\t\ttype = ControlTypeInteger32;\n> +\t\t\t\tbreak;\n> +\n>  \t\t\tdefault:\n>  \t\t\t\tLOG(V4L2, Error)\n>  \t\t\t\t\t<< \"Unsupported payload control type \"\n> @@ -491,6 +495,7 @@ ControlType V4L2Device::v4l2CtrlType(uint32_t ctrlType)\n>  \t\treturn ControlTypeBool;\n>  \n>  \tcase V4L2_CTRL_TYPE_INTEGER:\n> +\tcase V4L2_CTRL_TYPE_U32:\n>  \t\treturn ControlTypeInteger32;\n>  \n>  \tcase V4L2_CTRL_TYPE_INTEGER64:\n> @@ -543,6 +548,11 @@ std::optional<ControlInfo> V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl\n>  \t\t\t\t   static_cast<bool>(ctrl.maximum),\n>  \t\t\t\t   static_cast<bool>(ctrl.default_value));\n>  \n> +\tcase V4L2_CTRL_TYPE_U32:\n> +\t\treturn ControlInfo(static_cast<uint32_t>(ctrl.minimum),\n> +\t\t\t\t   static_cast<uint32_t>(ctrl.maximum),\n> +\t\t\t\t   static_cast<uint32_t>(ctrl.default_value));\n\nWhat happens if you left TYPE_U32 being handled by the default case, and\ndrop the change to include/libcamera/controls.h ?\n\n> +\n>  \tcase V4L2_CTRL_TYPE_INTEGER64:\n>  \t\treturn ControlInfo(static_cast<int64_t>(ctrl.minimum),\n>  \t\t\t\t   static_cast<int64_t>(ctrl.maximum),\n> @@ -624,6 +634,7 @@ void V4L2Device::listControls()\n>  \t\tcase V4L2_CTRL_TYPE_BITMASK:\n>  \t\tcase V4L2_CTRL_TYPE_INTEGER_MENU:\n>  \t\tcase V4L2_CTRL_TYPE_U8:\n> +\t\tcase V4L2_CTRL_TYPE_U32:\n>  \t\t\tbreak;\n>  \t\t/* \\todo Support other control types. */\n>  \t\tdefault:","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 0FC4EBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Aug 2024 22:26:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 06D9263381;\n\tSat,  3 Aug 2024 00:26:17 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A2CC6195B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  3 Aug 2024 00:26:14 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 785DE3C7;\n\tSat,  3 Aug 2024 00:25:24 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"vO5vLlvC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1722637524;\n\tbh=2px8UdLg4RhE+2QLTnC/zYJwzRwa4HqBvkRkIx8dZEk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=vO5vLlvCMGyBboxDxRfKECl1DEwfvOT/H0hm/L9jvGoDsBGXQu0tABeXaQY9kEal9\n\tuUvRbcDgRFCRbE2jv6VTPiklH0pFE9/uCY4qYynhB8/uSl4jmUMYJ/Onz+rQUblsb8\n\tyFEqU28juPrJHs58X7Jbc14bC/dmEgQADOzUxaXw=","Date":"Sat, 3 Aug 2024 01:25:52 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tXavier Roumegue <xavier.roumegue@oss.nxp.com>","Subject":"Re: [RFC PATCH 1/6] libcamera: v4l2_device: Add support for\n\tV4L2_CTRL_TYPE_U32","Message-ID":"<20240802222552.GB3319@pendragon.ideasonboard.com>","References":"<20240712052920.33396-1-umang.jain@ideasonboard.com>\n\t<20240712052920.33396-2-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240712052920.33396-2-umang.jain@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]