[{"id":38800,"web_url":"https://patchwork.libcamera.org/comment/38800/","msgid":"<e4dafa16-49e6-47bc-934e-8552de77b543@ideasonboard.com>","date":"2026-05-08T08:35:26","subject":"Re: [PATCH 2/3] ipa: libipa: v4l2_params: Enforce uint16_t for\n\tid_type underlying type","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 05. 07. 23:37 keltezéssel, Laurent Pinchart írta:\n> The Linux kernel V4L2 extensible ISP parameters API uses a 16-bit\n> integer for the block type. We can therefore standardize on the same\n> type for the underlying type of the Traits::id_type enum class, as there\n> will never be more block types in libcamera than in the kernel. This\n> will help sharing code between different specializations of V4L2Params.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>   src/ipa/libipa/v4l2_params.cpp |  2 +-\n>   src/ipa/libipa/v4l2_params.h   | 11 +++++++----\n>   src/ipa/mali-c55/params.h      |  4 +++-\n>   src/ipa/rkisp1/params.cpp      |  3 ++-\n>   src/ipa/rkisp1/params.h        |  4 +++-\n>   5 files changed, 16 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/libipa/v4l2_params.cpp b/src/ipa/libipa/v4l2_params.cpp\n> index c2971f1caf28..d44a366a60b8 100644\n> --- a/src/ipa/libipa/v4l2_params.cpp\n> +++ b/src/ipa/libipa/v4l2_params.cpp\n> @@ -217,7 +217,7 @@ namespace ipa {\n>    */\n> \n>   /**\n> - * \\fn V4L2Params::block(typename Traits::id_type type, unsigned int blockType, size_t blockSize)\n> + * \\fn V4L2Params::block(uint16_t type, unsigned int blockType, size_t blockSize)\n>    * \\brief Populate an ISP configuration block a returns a reference to its\n>    * memory\n>    * \\param[in] type The ISP block identifier enumerated by the IPA module\n> diff --git a/src/ipa/libipa/v4l2_params.h b/src/ipa/libipa/v4l2_params.h\n> index f400b37d74b5..4f84360ee449 100644\n> --- a/src/ipa/libipa/v4l2_params.h\n> +++ b/src/ipa/libipa/v4l2_params.h\n> @@ -15,6 +15,7 @@\n> \n>   #include <libcamera/base/log.h>\n>   #include <libcamera/base/span.h>\n> +#include <libcamera/base/utils.h>\n> \n>   namespace libcamera {\n> \n> @@ -72,6 +73,8 @@ template<typename Traits>\n>   class V4L2Params\n>   {\n>   public:\n> +\tstatic_assert(std::is_same_v<std::underlying_type_t<typename Traits::id_type>, uint16_t>);\n> +\n>   \tV4L2Params(Span<uint8_t> data, unsigned int version)\n>   \t\t: data_(data)\n>   \t{\n> @@ -93,13 +96,13 @@ public:\n>   \t\tusing Type = typename Details::type;\n>   \t\tconstexpr auto kernelId = Details::blockType;\n> \n> -\t\tauto data = block(Id, kernelId, sizeof(Type));\n> +\t\tauto data = block(utils::to_underlying(Id), kernelId, sizeof(Type));\n>   \t\treturn V4L2ParamsBlock<Type>(data);\n>   \t}\n> \n>   protected:\n> -\tSpan<uint8_t> block(typename Traits::id_type type,\n> -\t\t\t    unsigned int blockType, size_t blockSize)\n> +\tSpan<uint8_t> block(uint16_t type, unsigned int blockType,\n> +\t\t\t    size_t blockSize)\n>   \t{\n>   \t\t/*\n>   \t\t * Look up the block in the cache first. If an algorithm\n> @@ -144,7 +147,7 @@ protected:\n>   \tSpan<uint8_t> data_;\n>   \tsize_t used_;\n> \n> -\tstd::map<typename Traits::id_type, Span<uint8_t>> blocks_;\n> +\tstd::map<uint16_t, Span<uint8_t>> blocks_;\n\nA bit unfortunate that now debuggers won't show the keys nicely, but oh well.\n\n\n>   };\n> \n>   } /* namespace ipa */\n> diff --git a/src/ipa/mali-c55/params.h b/src/ipa/mali-c55/params.h\n> index 64be68583ddb..3abcb7f94916 100644\n> --- a/src/ipa/mali-c55/params.h\n> +++ b/src/ipa/mali-c55/params.h\n> @@ -7,6 +7,8 @@\n> \n>   #pragma once\n> \n> +#include <stdint.h>\n> +\n>   #include <linux/media/arm/mali-c55-config.h>\n>   #include <linux/videodev2.h>\n> \n> @@ -16,7 +18,7 @@ namespace libcamera {\n> \n>   namespace ipa::mali_c55 {\n> \n> -enum class MaliC55Blocks {\n> +enum class MaliC55Blocks : uint16_t {\n>   \tBls,\n>   \tAexpHist,\n>   \tAexpHistWeights,\n> diff --git a/src/ipa/rkisp1/params.cpp b/src/ipa/rkisp1/params.cpp\n> index 7040207c2655..b8abbdf6ec66 100644\n> --- a/src/ipa/rkisp1/params.cpp\n> +++ b/src/ipa/rkisp1/params.cpp\n> @@ -128,7 +128,8 @@ Span<uint8_t> RkISP1Params::block(BlockType type)\n>   \t\treturn data_.subspan(info.offset, info.size);\n>   \t}\n> \n> -\treturn V4L2Params::block(type, info.type, info.size);\n> +\treturn V4L2Params::block(utils::to_underlying(type), info.type,\n> +\t\t\t\t info.size);\n\nDoes this warrant a line break? It's the same length as the reinterpret_cast\na couple lines above.\n\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\n>   }\n> \n>   } /* namespace ipa::rkisp1 */\n> diff --git a/src/ipa/rkisp1/params.h b/src/ipa/rkisp1/params.h\n> index eddb37d5c000..8e3672ca8340 100644\n> --- a/src/ipa/rkisp1/params.h\n> +++ b/src/ipa/rkisp1/params.h\n> @@ -7,6 +7,8 @@\n> \n>   #pragma once\n> \n> +#include <stdint.h>\n> +\n>   #include <linux/rkisp1-config.h>\n>   #include <linux/videodev2.h>\n> \n> @@ -16,7 +18,7 @@ namespace libcamera {\n> \n>   namespace ipa::rkisp1 {\n> \n> -enum class BlockType {\n> +enum class BlockType : uint16_t {\n>   \tBls,\n>   \tDpcc,\n>   \tSdg,\n> --\n> Regards,\n> \n> Laurent Pinchart\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 07C0EBDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  8 May 2026 08:35:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4146E62FE8;\n\tFri,  8 May 2026 10:35:32 +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 0C73162FE1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 May 2026 10:35:30 +0200 (CEST)","from [192.168.33.85] (185.221.140.217.nat.pool.zt.hu\n\t[185.221.140.217])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3D0A6ABF;\n\tFri,  8 May 2026 10:35:25 +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=\"f3O/C35I\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1778229325;\n\tbh=IxtNqrzE8kz4JIVhK3ZHvTZjJHr/KBd0lFvV1rMiS80=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=f3O/C35IjbUJ2RqFyz3T4ePZ4K2NSc8BW5aMH8DUhTybyIneYkfEz49I8nwFNrYD5\n\t7O6W9EufsfbgNoozKxoW77H8hqlglI99hpzyny3n3LFkVrRtYF+t9VE1mD+IlrHVWW\n\t/NB+0JcTE5nVTQ2etLxAdB+u4awDqKyDt3ljX1Dg=","Message-ID":"<e4dafa16-49e6-47bc-934e-8552de77b543@ideasonboard.com>","Date":"Fri, 8 May 2026 10:35:26 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 2/3] ipa: libipa: v4l2_params: Enforce uint16_t for\n\tid_type underlying type","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260507213721.2137448-1-laurent.pinchart@ideasonboard.com>\n\t<R-JjVfocoXPCwvHJZjuGafLNka7wykeRlZ1S32mpAi7C8G9s4iWuNCVQc6_Wvt745BvsGZaL7SgWZsj3K35xvQ==@protonmail.internalid>\n\t<20260507213721.2137448-3-laurent.pinchart@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260507213721.2137448-3-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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":38804,"web_url":"https://patchwork.libcamera.org/comment/38804/","msgid":"<177823097934.3304204.13376784510920045229@ping.linuxembedded.co.uk>","date":"2026-05-08T09:02:59","subject":"Re: [PATCH 2/3] ipa: libipa: v4l2_params: Enforce uint16_t for\n\tid_type underlying type","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2026-05-08 09:35:26)\n> 2026. 05. 07. 23:37 keltezéssel, Laurent Pinchart írta:\n> > The Linux kernel V4L2 extensible ISP parameters API uses a 16-bit\n> > integer for the block type. We can therefore standardize on the same\n> > type for the underlying type of the Traits::id_type enum class, as there\n> > will never be more block types in libcamera than in the kernel. This\n> > will help sharing code between different specializations of V4L2Params.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >   src/ipa/libipa/v4l2_params.cpp |  2 +-\n> >   src/ipa/libipa/v4l2_params.h   | 11 +++++++----\n> >   src/ipa/mali-c55/params.h      |  4 +++-\n> >   src/ipa/rkisp1/params.cpp      |  3 ++-\n> >   src/ipa/rkisp1/params.h        |  4 +++-\n> >   5 files changed, 16 insertions(+), 8 deletions(-)\n> > \n> > diff --git a/src/ipa/libipa/v4l2_params.cpp b/src/ipa/libipa/v4l2_params.cpp\n> > index c2971f1caf28..d44a366a60b8 100644\n> > --- a/src/ipa/libipa/v4l2_params.cpp\n> > +++ b/src/ipa/libipa/v4l2_params.cpp\n> > @@ -217,7 +217,7 @@ namespace ipa {\n> >    */\n> > \n> >   /**\n> > - * \\fn V4L2Params::block(typename Traits::id_type type, unsigned int blockType, size_t blockSize)\n> > + * \\fn V4L2Params::block(uint16_t type, unsigned int blockType, size_t blockSize)\n> >    * \\brief Populate an ISP configuration block a returns a reference to its\n> >    * memory\n> >    * \\param[in] type The ISP block identifier enumerated by the IPA module\n> > diff --git a/src/ipa/libipa/v4l2_params.h b/src/ipa/libipa/v4l2_params.h\n> > index f400b37d74b5..4f84360ee449 100644\n> > --- a/src/ipa/libipa/v4l2_params.h\n> > +++ b/src/ipa/libipa/v4l2_params.h\n> > @@ -15,6 +15,7 @@\n> > \n> >   #include <libcamera/base/log.h>\n> >   #include <libcamera/base/span.h>\n> > +#include <libcamera/base/utils.h>\n> > \n> >   namespace libcamera {\n> > \n> > @@ -72,6 +73,8 @@ template<typename Traits>\n> >   class V4L2Params\n> >   {\n> >   public:\n> > +     static_assert(std::is_same_v<std::underlying_type_t<typename Traits::id_type>, uint16_t>);\n> > +\n\nSurely with this ^\n\n> >       V4L2Params(Span<uint8_t> data, unsigned int version)\n> >               : data_(data)\n> >       {\n> > @@ -93,13 +96,13 @@ public:\n> >               using Type = typename Details::type;\n> >               constexpr auto kernelId = Details::blockType;\n> > \n> > -             auto data = block(Id, kernelId, sizeof(Type));\n> > +             auto data = block(utils::to_underlying(Id), kernelId, sizeof(Type));\n> >               return V4L2ParamsBlock<Type>(data);\n> >       }\n> > \n> >   protected:\n> > -     Span<uint8_t> block(typename Traits::id_type type,\n> > -                         unsigned int blockType, size_t blockSize)\n> > +     Span<uint8_t> block(uint16_t type, unsigned int blockType,\n> > +                         size_t blockSize)\n\nwe don't need to change this\n\n> >       {\n> >               /*\n> >                * Look up the block in the cache first. If an algorithm\n> > @@ -144,7 +147,7 @@ protected:\n> >       Span<uint8_t> data_;\n> >       size_t used_;\n> > \n> > -     std::map<typename Traits::id_type, Span<uint8_t>> blocks_;\n> > +     std::map<uint16_t, Span<uint8_t>> blocks_;\n> \n\nor this,\n\n> A bit unfortunate that now debuggers won't show the keys nicely, but oh well.\n\nAnd then this would still work ?\n\n--\nKieran\n\n\n> \n> \n> >   };\n> > \n> >   } /* namespace ipa */\n> > diff --git a/src/ipa/mali-c55/params.h b/src/ipa/mali-c55/params.h\n> > index 64be68583ddb..3abcb7f94916 100644\n> > --- a/src/ipa/mali-c55/params.h\n> > +++ b/src/ipa/mali-c55/params.h\n> > @@ -7,6 +7,8 @@\n> > \n> >   #pragma once\n> > \n> > +#include <stdint.h>\n> > +\n> >   #include <linux/media/arm/mali-c55-config.h>\n> >   #include <linux/videodev2.h>\n> > \n> > @@ -16,7 +18,7 @@ namespace libcamera {\n> > \n> >   namespace ipa::mali_c55 {\n> > \n> > -enum class MaliC55Blocks {\n> > +enum class MaliC55Blocks : uint16_t {\n> >       Bls,\n> >       AexpHist,\n> >       AexpHistWeights,\n> > diff --git a/src/ipa/rkisp1/params.cpp b/src/ipa/rkisp1/params.cpp\n> > index 7040207c2655..b8abbdf6ec66 100644\n> > --- a/src/ipa/rkisp1/params.cpp\n> > +++ b/src/ipa/rkisp1/params.cpp\n> > @@ -128,7 +128,8 @@ Span<uint8_t> RkISP1Params::block(BlockType type)\n> >               return data_.subspan(info.offset, info.size);\n> >       }\n> > \n> > -     return V4L2Params::block(type, info.type, info.size);\n> > +     return V4L2Params::block(utils::to_underlying(type), info.type,\n> > +                              info.size);\n> \n> Does this warrant a line break? It's the same length as the reinterpret_cast\n> a couple lines above.\n> \n> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> \n> \n> >   }\n> > \n> >   } /* namespace ipa::rkisp1 */\n> > diff --git a/src/ipa/rkisp1/params.h b/src/ipa/rkisp1/params.h\n> > index eddb37d5c000..8e3672ca8340 100644\n> > --- a/src/ipa/rkisp1/params.h\n> > +++ b/src/ipa/rkisp1/params.h\n> > @@ -7,6 +7,8 @@\n> > \n> >   #pragma once\n> > \n> > +#include <stdint.h>\n> > +\n> >   #include <linux/rkisp1-config.h>\n> >   #include <linux/videodev2.h>\n> > \n> > @@ -16,7 +18,7 @@ namespace libcamera {\n> > \n> >   namespace ipa::rkisp1 {\n> > \n> > -enum class BlockType {\n> > +enum class BlockType : uint16_t {\n> >       Bls,\n> >       Dpcc,\n> >       Sdg,\n> > --\n> > Regards,\n> > \n> > Laurent Pinchart\n> > \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 16051BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  8 May 2026 09:03:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B2D6863029;\n\tFri,  8 May 2026 11:03:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 356BD62E6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 May 2026 11:03:02 +0200 (CEST)","from monstersaurus.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8018EBCA;\n\tFri,  8 May 2026 11:02:57 +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=\"bdl1d2f+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1778230977;\n\tbh=JwvLBFbwhYTqNrydBRSNP32UQ3XGuQJvbXC66yQSJzM=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=bdl1d2f+vQ6RohcyPxfEs3m8NpL1k1ntceUHeFciEIoMOkqYzPtz2t5lc3u+kip33\n\tCpjoPTkCVnTtoihJUWOkWYCX61QectrZ/7gwb34xYhFBsnf9aPtIGGG16/h14+Svde\n\thK18rKi/4hES2NY9hW5yfyoGci5OrTDlrrhGlyfk=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<e4dafa16-49e6-47bc-934e-8552de77b543@ideasonboard.com>","References":"<20260507213721.2137448-1-laurent.pinchart@ideasonboard.com>\n\t<R-JjVfocoXPCwvHJZjuGafLNka7wykeRlZ1S32mpAi7C8G9s4iWuNCVQc6_Wvt745BvsGZaL7SgWZsj3K35xvQ==@protonmail.internalid>\n\t<20260507213721.2137448-3-laurent.pinchart@ideasonboard.com>\n\t<e4dafa16-49e6-47bc-934e-8552de77b543@ideasonboard.com>","Subject":"Re: [PATCH 2/3] ipa: libipa: v4l2_params: Enforce uint16_t for\n\tid_type underlying type","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 08 May 2026 10:02:59 +0100","Message-ID":"<177823097934.3304204.13376784510920045229@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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":38808,"web_url":"https://patchwork.libcamera.org/comment/38808/","msgid":"<2049b93e-8340-4ab6-9953-00cb97694671@ideasonboard.com>","date":"2026-05-08T09:25:59","subject":"Re: [PATCH 2/3] ipa: libipa: v4l2_params: Enforce uint16_t for\n\tid_type underlying type","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 05. 08. 11:02 keltezéssel, Kieran Bingham írta:\n> Quoting Barnabás Pőcze (2026-05-08 09:35:26)\n>> 2026. 05. 07. 23:37 keltezéssel, Laurent Pinchart írta:\n>>> The Linux kernel V4L2 extensible ISP parameters API uses a 16-bit\n>>> integer for the block type. We can therefore standardize on the same\n>>> type for the underlying type of the Traits::id_type enum class, as there\n>>> will never be more block types in libcamera than in the kernel. This\n>>> will help sharing code between different specializations of V4L2Params.\n>>>\n>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>>> ---\n>>>    src/ipa/libipa/v4l2_params.cpp |  2 +-\n>>>    src/ipa/libipa/v4l2_params.h   | 11 +++++++----\n>>>    src/ipa/mali-c55/params.h      |  4 +++-\n>>>    src/ipa/rkisp1/params.cpp      |  3 ++-\n>>>    src/ipa/rkisp1/params.h        |  4 +++-\n>>>    5 files changed, 16 insertions(+), 8 deletions(-)\n>>>\n>>> diff --git a/src/ipa/libipa/v4l2_params.cpp b/src/ipa/libipa/v4l2_params.cpp\n>>> index c2971f1caf28..d44a366a60b8 100644\n>>> --- a/src/ipa/libipa/v4l2_params.cpp\n>>> +++ b/src/ipa/libipa/v4l2_params.cpp\n>>> @@ -217,7 +217,7 @@ namespace ipa {\n>>>     */\n>>>\n>>>    /**\n>>> - * \\fn V4L2Params::block(typename Traits::id_type type, unsigned int blockType, size_t blockSize)\n>>> + * \\fn V4L2Params::block(uint16_t type, unsigned int blockType, size_t blockSize)\n>>>     * \\brief Populate an ISP configuration block a returns a reference to its\n>>>     * memory\n>>>     * \\param[in] type The ISP block identifier enumerated by the IPA module\n>>> diff --git a/src/ipa/libipa/v4l2_params.h b/src/ipa/libipa/v4l2_params.h\n>>> index f400b37d74b5..4f84360ee449 100644\n>>> --- a/src/ipa/libipa/v4l2_params.h\n>>> +++ b/src/ipa/libipa/v4l2_params.h\n>>> @@ -15,6 +15,7 @@\n>>>\n>>>    #include <libcamera/base/log.h>\n>>>    #include <libcamera/base/span.h>\n>>> +#include <libcamera/base/utils.h>\n>>>\n>>>    namespace libcamera {\n>>>\n>>> @@ -72,6 +73,8 @@ template<typename Traits>\n>>>    class V4L2Params\n>>>    {\n>>>    public:\n>>> +     static_assert(std::is_same_v<std::underlying_type_t<typename Traits::id_type>, uint16_t>);\n>>> +\n> \n> Surely with this ^\n> \n>>>        V4L2Params(Span<uint8_t> data, unsigned int version)\n>>>                : data_(data)\n>>>        {\n>>> @@ -93,13 +96,13 @@ public:\n>>>                using Type = typename Details::type;\n>>>                constexpr auto kernelId = Details::blockType;\n>>>\n>>> -             auto data = block(Id, kernelId, sizeof(Type));\n>>> +             auto data = block(utils::to_underlying(Id), kernelId, sizeof(Type));\n>>>                return V4L2ParamsBlock<Type>(data);\n>>>        }\n>>>\n>>>    protected:\n>>> -     Span<uint8_t> block(typename Traits::id_type type,\n>>> -                         unsigned int blockType, size_t blockSize)\n>>> +     Span<uint8_t> block(uint16_t type, unsigned int blockType,\n>>> +                         size_t blockSize)\n> \n> we don't need to change this\n> \n>>>        {\n>>>                /*\n>>>                 * Look up the block in the cache first. If an algorithm\n>>> @@ -144,7 +147,7 @@ protected:\n>>>        Span<uint8_t> data_;\n>>>        size_t used_;\n>>>\n>>> -     std::map<typename Traits::id_type, Span<uint8_t>> blocks_;\n>>> +     std::map<uint16_t, Span<uint8_t>> blocks_;\n>>\n> \n> or this,\n> \n>> A bit unfortunate that now debuggers won't show the keys nicely, but oh well.\n> \n> And then this would still work ?\n\nThe next patch requires that the map does not depend on `Traits`,\nand I don't see a way around it. It's a minor thing in any case.\n\n\n> \n> --\n> Kieran\n> \n> \n>>\n>>\n>>>    };\n>>>\n>>>    } /* namespace ipa */\n>>> diff --git a/src/ipa/mali-c55/params.h b/src/ipa/mali-c55/params.h\n>>> index 64be68583ddb..3abcb7f94916 100644\n>>> --- a/src/ipa/mali-c55/params.h\n>>> +++ b/src/ipa/mali-c55/params.h\n>>> @@ -7,6 +7,8 @@\n>>>\n>>>    #pragma once\n>>>\n>>> +#include <stdint.h>\n>>> +\n>>>    #include <linux/media/arm/mali-c55-config.h>\n>>>    #include <linux/videodev2.h>\n>>>\n>>> @@ -16,7 +18,7 @@ namespace libcamera {\n>>>\n>>>    namespace ipa::mali_c55 {\n>>>\n>>> -enum class MaliC55Blocks {\n>>> +enum class MaliC55Blocks : uint16_t {\n>>>        Bls,\n>>>        AexpHist,\n>>>        AexpHistWeights,\n>>> diff --git a/src/ipa/rkisp1/params.cpp b/src/ipa/rkisp1/params.cpp\n>>> index 7040207c2655..b8abbdf6ec66 100644\n>>> --- a/src/ipa/rkisp1/params.cpp\n>>> +++ b/src/ipa/rkisp1/params.cpp\n>>> @@ -128,7 +128,8 @@ Span<uint8_t> RkISP1Params::block(BlockType type)\n>>>                return data_.subspan(info.offset, info.size);\n>>>        }\n>>>\n>>> -     return V4L2Params::block(type, info.type, info.size);\n>>> +     return V4L2Params::block(utils::to_underlying(type), info.type,\n>>> +                              info.size);\n>>\n>> Does this warrant a line break? It's the same length as the reinterpret_cast\n>> a couple lines above.\n>>\n>> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>>\n>>\n>>>    }\n>>>\n>>>    } /* namespace ipa::rkisp1 */\n>>> diff --git a/src/ipa/rkisp1/params.h b/src/ipa/rkisp1/params.h\n>>> index eddb37d5c000..8e3672ca8340 100644\n>>> --- a/src/ipa/rkisp1/params.h\n>>> +++ b/src/ipa/rkisp1/params.h\n>>> @@ -7,6 +7,8 @@\n>>>\n>>>    #pragma once\n>>>\n>>> +#include <stdint.h>\n>>> +\n>>>    #include <linux/rkisp1-config.h>\n>>>    #include <linux/videodev2.h>\n>>>\n>>> @@ -16,7 +18,7 @@ namespace libcamera {\n>>>\n>>>    namespace ipa::rkisp1 {\n>>>\n>>> -enum class BlockType {\n>>> +enum class BlockType : uint16_t {\n>>>        Bls,\n>>>        Dpcc,\n>>>        Sdg,\n>>> --\n>>> Regards,\n>>>\n>>> Laurent Pinchart\n>>>\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 F2A2CBDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  8 May 2026 09:26:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2F4416301E;\n\tFri,  8 May 2026 11:26:04 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A875B62FE1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 May 2026 11:26:02 +0200 (CEST)","from [192.168.33.85] (185.221.140.217.nat.pool.zt.hu\n\t[185.221.140.217])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E2687BCA;\n\tFri,  8 May 2026 11:25:57 +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=\"OZwUyLlE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1778232358;\n\tbh=Yq9EDen0l8WmS/IY1IOp5lVQWd6xERIqAGkGRgHwUKA=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=OZwUyLlECyA9UcBHozsAog+kK+LED27ToFXSP4vmotXNFgWNzXxeJkIfY5SvaaFaC\n\tQWJ+imobAZIz+8BqnrEvSm6CDi9Dhdy7qmp66MuGSUNp4e7+9OxpaYNl9Ud0urzMGu\n\tKXisfUtyLimnWLBWvUVL6CGFpR8W7b3j0SPIFREc=","Message-ID":"<2049b93e-8340-4ab6-9953-00cb97694671@ideasonboard.com>","Date":"Fri, 8 May 2026 11:25:59 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 2/3] ipa: libipa: v4l2_params: Enforce uint16_t for\n\tid_type underlying type","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260507213721.2137448-1-laurent.pinchart@ideasonboard.com>\n\t<R-JjVfocoXPCwvHJZjuGafLNka7wykeRlZ1S32mpAi7C8G9s4iWuNCVQc6_Wvt745BvsGZaL7SgWZsj3K35xvQ==@protonmail.internalid>\n\t<20260507213721.2137448-3-laurent.pinchart@ideasonboard.com>\n\t<e4dafa16-49e6-47bc-934e-8552de77b543@ideasonboard.com>\n\t<177823097934.3304204.13376784510920045229@ping.linuxembedded.co.uk>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<177823097934.3304204.13376784510920045229@ping.linuxembedded.co.uk>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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":38812,"web_url":"https://patchwork.libcamera.org/comment/38812/","msgid":"<177823278073.3304204.289157383373461867@ping.linuxembedded.co.uk>","date":"2026-05-08T09:33:00","subject":"Re: [PATCH 2/3] ipa: libipa: v4l2_params: Enforce uint16_t for\n\tid_type underlying type","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2026-05-08 10:25:59)\n> 2026. 05. 08. 11:02 keltezéssel, Kieran Bingham írta:\n> > Quoting Barnabás Pőcze (2026-05-08 09:35:26)\n> >> 2026. 05. 07. 23:37 keltezéssel, Laurent Pinchart írta:\n> >>> The Linux kernel V4L2 extensible ISP parameters API uses a 16-bit\n> >>> integer for the block type. We can therefore standardize on the same\n> >>> type for the underlying type of the Traits::id_type enum class, as there\n> >>> will never be more block types in libcamera than in the kernel. This\n> >>> will help sharing code between different specializations of V4L2Params.\n> >>>\n> >>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> >>> ---\n> >>>    src/ipa/libipa/v4l2_params.cpp |  2 +-\n> >>>    src/ipa/libipa/v4l2_params.h   | 11 +++++++----\n> >>>    src/ipa/mali-c55/params.h      |  4 +++-\n> >>>    src/ipa/rkisp1/params.cpp      |  3 ++-\n> >>>    src/ipa/rkisp1/params.h        |  4 +++-\n> >>>    5 files changed, 16 insertions(+), 8 deletions(-)\n> >>>\n> >>> diff --git a/src/ipa/libipa/v4l2_params.cpp b/src/ipa/libipa/v4l2_params.cpp\n> >>> index c2971f1caf28..d44a366a60b8 100644\n> >>> --- a/src/ipa/libipa/v4l2_params.cpp\n> >>> +++ b/src/ipa/libipa/v4l2_params.cpp\n> >>> @@ -217,7 +217,7 @@ namespace ipa {\n> >>>     */\n> >>>\n> >>>    /**\n> >>> - * \\fn V4L2Params::block(typename Traits::id_type type, unsigned int blockType, size_t blockSize)\n> >>> + * \\fn V4L2Params::block(uint16_t type, unsigned int blockType, size_t blockSize)\n> >>>     * \\brief Populate an ISP configuration block a returns a reference to its\n> >>>     * memory\n> >>>     * \\param[in] type The ISP block identifier enumerated by the IPA module\n> >>> diff --git a/src/ipa/libipa/v4l2_params.h b/src/ipa/libipa/v4l2_params.h\n> >>> index f400b37d74b5..4f84360ee449 100644\n> >>> --- a/src/ipa/libipa/v4l2_params.h\n> >>> +++ b/src/ipa/libipa/v4l2_params.h\n> >>> @@ -15,6 +15,7 @@\n> >>>\n> >>>    #include <libcamera/base/log.h>\n> >>>    #include <libcamera/base/span.h>\n> >>> +#include <libcamera/base/utils.h>\n> >>>\n> >>>    namespace libcamera {\n> >>>\n> >>> @@ -72,6 +73,8 @@ template<typename Traits>\n> >>>    class V4L2Params\n> >>>    {\n> >>>    public:\n> >>> +     static_assert(std::is_same_v<std::underlying_type_t<typename Traits::id_type>, uint16_t>);\n> >>> +\n> > \n> > Surely with this ^\n> > \n> >>>        V4L2Params(Span<uint8_t> data, unsigned int version)\n> >>>                : data_(data)\n> >>>        {\n> >>> @@ -93,13 +96,13 @@ public:\n> >>>                using Type = typename Details::type;\n> >>>                constexpr auto kernelId = Details::blockType;\n> >>>\n> >>> -             auto data = block(Id, kernelId, sizeof(Type));\n> >>> +             auto data = block(utils::to_underlying(Id), kernelId, sizeof(Type));\n> >>>                return V4L2ParamsBlock<Type>(data);\n> >>>        }\n> >>>\n> >>>    protected:\n> >>> -     Span<uint8_t> block(typename Traits::id_type type,\n> >>> -                         unsigned int blockType, size_t blockSize)\n> >>> +     Span<uint8_t> block(uint16_t type, unsigned int blockType,\n> >>> +                         size_t blockSize)\n> > \n> > we don't need to change this\n> > \n> >>>        {\n> >>>                /*\n> >>>                 * Look up the block in the cache first. If an algorithm\n> >>> @@ -144,7 +147,7 @@ protected:\n> >>>        Span<uint8_t> data_;\n> >>>        size_t used_;\n> >>>\n> >>> -     std::map<typename Traits::id_type, Span<uint8_t>> blocks_;\n> >>> +     std::map<uint16_t, Span<uint8_t>> blocks_;\n> >>\n> > \n> > or this,\n> > \n> >> A bit unfortunate that now debuggers won't show the keys nicely, but oh well.\n> > \n> > And then this would still work ?\n> \n> The next patch requires that the map does not depend on `Traits`,\n> and I don't see a way around it. It's a minor thing in any case.\n\nAck, ok then:\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> \n> > \n> > --\n> > Kieran\n> > \n> > \n> >>\n> >>\n> >>>    };\n> >>>\n> >>>    } /* namespace ipa */\n> >>> diff --git a/src/ipa/mali-c55/params.h b/src/ipa/mali-c55/params.h\n> >>> index 64be68583ddb..3abcb7f94916 100644\n> >>> --- a/src/ipa/mali-c55/params.h\n> >>> +++ b/src/ipa/mali-c55/params.h\n> >>> @@ -7,6 +7,8 @@\n> >>>\n> >>>    #pragma once\n> >>>\n> >>> +#include <stdint.h>\n> >>> +\n> >>>    #include <linux/media/arm/mali-c55-config.h>\n> >>>    #include <linux/videodev2.h>\n> >>>\n> >>> @@ -16,7 +18,7 @@ namespace libcamera {\n> >>>\n> >>>    namespace ipa::mali_c55 {\n> >>>\n> >>> -enum class MaliC55Blocks {\n> >>> +enum class MaliC55Blocks : uint16_t {\n> >>>        Bls,\n> >>>        AexpHist,\n> >>>        AexpHistWeights,\n> >>> diff --git a/src/ipa/rkisp1/params.cpp b/src/ipa/rkisp1/params.cpp\n> >>> index 7040207c2655..b8abbdf6ec66 100644\n> >>> --- a/src/ipa/rkisp1/params.cpp\n> >>> +++ b/src/ipa/rkisp1/params.cpp\n> >>> @@ -128,7 +128,8 @@ Span<uint8_t> RkISP1Params::block(BlockType type)\n> >>>                return data_.subspan(info.offset, info.size);\n> >>>        }\n> >>>\n> >>> -     return V4L2Params::block(type, info.type, info.size);\n> >>> +     return V4L2Params::block(utils::to_underlying(type), info.type,\n> >>> +                              info.size);\n> >>\n> >> Does this warrant a line break? It's the same length as the reinterpret_cast\n> >> a couple lines above.\n> >>\n> >> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> >>\n> >>\n> >>>    }\n> >>>\n> >>>    } /* namespace ipa::rkisp1 */\n> >>> diff --git a/src/ipa/rkisp1/params.h b/src/ipa/rkisp1/params.h\n> >>> index eddb37d5c000..8e3672ca8340 100644\n> >>> --- a/src/ipa/rkisp1/params.h\n> >>> +++ b/src/ipa/rkisp1/params.h\n> >>> @@ -7,6 +7,8 @@\n> >>>\n> >>>    #pragma once\n> >>>\n> >>> +#include <stdint.h>\n> >>> +\n> >>>    #include <linux/rkisp1-config.h>\n> >>>    #include <linux/videodev2.h>\n> >>>\n> >>> @@ -16,7 +18,7 @@ namespace libcamera {\n> >>>\n> >>>    namespace ipa::rkisp1 {\n> >>>\n> >>> -enum class BlockType {\n> >>> +enum class BlockType : uint16_t {\n> >>>        Bls,\n> >>>        Dpcc,\n> >>>        Sdg,\n> >>> --\n> >>> Regards,\n> >>>\n> >>> Laurent Pinchart\n> >>>\n> >>\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 C9902BDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  8 May 2026 09:33:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 86B7F63021;\n\tFri,  8 May 2026 11:33:05 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 178E162FEC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 May 2026 11:33:03 +0200 (CEST)","from monstersaurus.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 662841B0C;\n\tFri,  8 May 2026 11:32:58 +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=\"TlGw34UD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1778232778;\n\tbh=MnZM/Wnp/N/FQiJB9L+22ok5RMAQmHvFWuM6Xugkjhg=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=TlGw34UDo0RmGF3ejk5jNZANQBz6n5RAlg+wq+LE4Eoi2JkKJyQ85boEf4zpRaxz9\n\tQDoWz/bI1NvvJx9TsgI6+I89Z7yJI4UTqcvY0UAoh3uzqR7H/7xUzTde4JNCTQ7Kbb\n\t8cFAzt0FRHHTzHDNSWTJiK0f9r3FUFmyQMCSgd5M=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<2049b93e-8340-4ab6-9953-00cb97694671@ideasonboard.com>","References":"<20260507213721.2137448-1-laurent.pinchart@ideasonboard.com>\n\t<R-JjVfocoXPCwvHJZjuGafLNka7wykeRlZ1S32mpAi7C8G9s4iWuNCVQc6_Wvt745BvsGZaL7SgWZsj3K35xvQ==@protonmail.internalid>\n\t<20260507213721.2137448-3-laurent.pinchart@ideasonboard.com>\n\t<e4dafa16-49e6-47bc-934e-8552de77b543@ideasonboard.com>\n\t<177823097934.3304204.13376784510920045229@ping.linuxembedded.co.uk>\n\t<2049b93e-8340-4ab6-9953-00cb97694671@ideasonboard.com>","Subject":"Re: [PATCH 2/3] ipa: libipa: v4l2_params: Enforce uint16_t for\n\tid_type underlying type","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 08 May 2026 10:33:00 +0100","Message-ID":"<177823278073.3304204.289157383373461867@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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":38814,"web_url":"https://patchwork.libcamera.org/comment/38814/","msgid":"<20260508094337.GF1652535@killaraus.ideasonboard.com>","date":"2026-05-08T09:43:37","subject":"Re: [PATCH 2/3] ipa: libipa: v4l2_params: Enforce uint16_t for\n\tid_type underlying type","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Fri, May 08, 2026 at 10:02:59AM +0100, Kieran Bingham wrote:\n> Quoting Barnabás Pőcze (2026-05-08 09:35:26)\n> > 2026. 05. 07. 23:37 keltezéssel, Laurent Pinchart írta:\n> > > The Linux kernel V4L2 extensible ISP parameters API uses a 16-bit\n> > > integer for the block type. We can therefore standardize on the same\n> > > type for the underlying type of the Traits::id_type enum class, as there\n> > > will never be more block types in libcamera than in the kernel. This\n> > > will help sharing code between different specializations of V4L2Params.\n> > > \n> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > ---\n> > >   src/ipa/libipa/v4l2_params.cpp |  2 +-\n> > >   src/ipa/libipa/v4l2_params.h   | 11 +++++++----\n> > >   src/ipa/mali-c55/params.h      |  4 +++-\n> > >   src/ipa/rkisp1/params.cpp      |  3 ++-\n> > >   src/ipa/rkisp1/params.h        |  4 +++-\n> > >   5 files changed, 16 insertions(+), 8 deletions(-)\n> > > \n> > > diff --git a/src/ipa/libipa/v4l2_params.cpp b/src/ipa/libipa/v4l2_params.cpp\n> > > index c2971f1caf28..d44a366a60b8 100644\n> > > --- a/src/ipa/libipa/v4l2_params.cpp\n> > > +++ b/src/ipa/libipa/v4l2_params.cpp\n> > > @@ -217,7 +217,7 @@ namespace ipa {\n> > >    */\n> > > \n> > >   /**\n> > > - * \\fn V4L2Params::block(typename Traits::id_type type, unsigned int blockType, size_t blockSize)\n> > > + * \\fn V4L2Params::block(uint16_t type, unsigned int blockType, size_t blockSize)\n> > >    * \\brief Populate an ISP configuration block a returns a reference to its\n> > >    * memory\n> > >    * \\param[in] type The ISP block identifier enumerated by the IPA module\n> > > diff --git a/src/ipa/libipa/v4l2_params.h b/src/ipa/libipa/v4l2_params.h\n> > > index f400b37d74b5..4f84360ee449 100644\n> > > --- a/src/ipa/libipa/v4l2_params.h\n> > > +++ b/src/ipa/libipa/v4l2_params.h\n> > > @@ -15,6 +15,7 @@\n> > > \n> > >   #include <libcamera/base/log.h>\n> > >   #include <libcamera/base/span.h>\n> > > +#include <libcamera/base/utils.h>\n> > > \n> > >   namespace libcamera {\n> > > \n> > > @@ -72,6 +73,8 @@ template<typename Traits>\n> > >   class V4L2Params\n> > >   {\n> > >   public:\n> > > +     static_assert(std::is_same_v<std::underlying_type_t<typename Traits::id_type>, uint16_t>);\n> > > +\n> \n> Surely with this ^\n> \n> > >       V4L2Params(Span<uint8_t> data, unsigned int version)\n> > >               : data_(data)\n> > >       {\n> > > @@ -93,13 +96,13 @@ public:\n> > >               using Type = typename Details::type;\n> > >               constexpr auto kernelId = Details::blockType;\n> > > \n> > > -             auto data = block(Id, kernelId, sizeof(Type));\n> > > +             auto data = block(utils::to_underlying(Id), kernelId, sizeof(Type));\n> > >               return V4L2ParamsBlock<Type>(data);\n> > >       }\n> > > \n> > >   protected:\n> > > -     Span<uint8_t> block(typename Traits::id_type type,\n> > > -                         unsigned int blockType, size_t blockSize)\n> > > +     Span<uint8_t> block(uint16_t type, unsigned int blockType,\n> > > +                         size_t blockSize)\n> \n> we don't need to change this\n> \n> > >       {\n> > >               /*\n> > >                * Look up the block in the cache first. If an algorithm\n> > > @@ -144,7 +147,7 @@ protected:\n> > >       Span<uint8_t> data_;\n> > >       size_t used_;\n> > > \n> > > -     std::map<typename Traits::id_type, Span<uint8_t>> blocks_;\n> > > +     std::map<uint16_t, Span<uint8_t>> blocks_;\n> > \n> \n> or this,\n> \n> > A bit unfortunate that now debuggers won't show the keys nicely, but oh well.\n> \n> And then this would still work ?\n\nThose two changes are needed as both blocks_ and block() are moved to\nthe base non-template class in the next patch. I could drop the changes\nhere and move them to 3/3. I don't think that's what you have in mind\nthough :-)\n\n> > >   };\n> > > \n> > >   } /* namespace ipa */\n> > > diff --git a/src/ipa/mali-c55/params.h b/src/ipa/mali-c55/params.h\n> > > index 64be68583ddb..3abcb7f94916 100644\n> > > --- a/src/ipa/mali-c55/params.h\n> > > +++ b/src/ipa/mali-c55/params.h\n> > > @@ -7,6 +7,8 @@\n> > > \n> > >   #pragma once\n> > > \n> > > +#include <stdint.h>\n> > > +\n> > >   #include <linux/media/arm/mali-c55-config.h>\n> > >   #include <linux/videodev2.h>\n> > > \n> > > @@ -16,7 +18,7 @@ namespace libcamera {\n> > > \n> > >   namespace ipa::mali_c55 {\n> > > \n> > > -enum class MaliC55Blocks {\n> > > +enum class MaliC55Blocks : uint16_t {\n> > >       Bls,\n> > >       AexpHist,\n> > >       AexpHistWeights,\n> > > diff --git a/src/ipa/rkisp1/params.cpp b/src/ipa/rkisp1/params.cpp\n> > > index 7040207c2655..b8abbdf6ec66 100644\n> > > --- a/src/ipa/rkisp1/params.cpp\n> > > +++ b/src/ipa/rkisp1/params.cpp\n> > > @@ -128,7 +128,8 @@ Span<uint8_t> RkISP1Params::block(BlockType type)\n> > >               return data_.subspan(info.offset, info.size);\n> > >       }\n> > > \n> > > -     return V4L2Params::block(type, info.type, info.size);\n> > > +     return V4L2Params::block(utils::to_underlying(type), info.type,\n> > > +                              info.size);\n> > \n> > Does this warrant a line break? It's the same length as the reinterpret_cast\n> > a couple lines above.\n\nI could avoid it here, but it would come back in the nest patch as the\nline becomes longer there.\n\n> > Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> > \n> > >   }\n> > > \n> > >   } /* namespace ipa::rkisp1 */\n> > > diff --git a/src/ipa/rkisp1/params.h b/src/ipa/rkisp1/params.h\n> > > index eddb37d5c000..8e3672ca8340 100644\n> > > --- a/src/ipa/rkisp1/params.h\n> > > +++ b/src/ipa/rkisp1/params.h\n> > > @@ -7,6 +7,8 @@\n> > > \n> > >   #pragma once\n> > > \n> > > +#include <stdint.h>\n> > > +\n> > >   #include <linux/rkisp1-config.h>\n> > >   #include <linux/videodev2.h>\n> > > \n> > > @@ -16,7 +18,7 @@ namespace libcamera {\n> > > \n> > >   namespace ipa::rkisp1 {\n> > > \n> > > -enum class BlockType {\n> > > +enum class BlockType : uint16_t {\n> > >       Bls,\n> > >       Dpcc,\n> > >       Sdg,","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 545C0BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  8 May 2026 09:43:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 80BC16301E;\n\tFri,  8 May 2026 11:43:40 +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 481A862E6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  8 May 2026 11:43:39 +0200 (CEST)","from killaraus.ideasonboard.com\n\t(2001-14ba-70f3-e800--a06.rev.dnainternet.fi\n\t[IPv6:2001:14ba:70f3:e800::a06])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4DA37BCA;\n\tFri,  8 May 2026 11:43:34 +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=\"F0ebIQ4W\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1778233414;\n\tbh=FpyY8BvY/GPDmTO5rta49kTnMC8fR/Clpj+iSguBk8I=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=F0ebIQ4W51E8CEge7xE65X03IuvM1vXPnYK2lI8nDEuEvhbsdrr6tG4qTOP+GF5o8\n\tarLN+djP50UBVCDtRDVIWwxjiaTuGEo7Y4EnVJdNVccWPTP4CVlnwC8BSeiSKnhpXd\n\tfSAiD0TKKl43BtjBhZ09zhSoix0i/F5J6WOQeCR4=","Date":"Fri, 8 May 2026 12:43:37 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 2/3] ipa: libipa: v4l2_params: Enforce uint16_t for\n\tid_type underlying type","Message-ID":"<20260508094337.GF1652535@killaraus.ideasonboard.com>","References":"<20260507213721.2137448-1-laurent.pinchart@ideasonboard.com>\n\t<R-JjVfocoXPCwvHJZjuGafLNka7wykeRlZ1S32mpAi7C8G9s4iWuNCVQc6_Wvt745BvsGZaL7SgWZsj3K35xvQ==@protonmail.internalid>\n\t<20260507213721.2137448-3-laurent.pinchart@ideasonboard.com>\n\t<e4dafa16-49e6-47bc-934e-8552de77b543@ideasonboard.com>\n\t<177823097934.3304204.13376784510920045229@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<177823097934.3304204.13376784510920045229@ping.linuxembedded.co.uk>","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>"}}]