[{"id":36126,"web_url":"https://patchwork.libcamera.org/comment/36126/","msgid":"<20251006013116.GE13055@pendragon.ideasonboard.com>","date":"2025-10-06T01:31:16","subject":"Re: [PATCH v4 1/5] include: linux: Add v4l2-isp.h","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Oct 01, 2025 at 05:42:30PM +0200, Jacopo Mondi wrote:\n> Import the v4l2-isp.h header from the Linux kernel sources.\n> \n> The file has not been merged in mainline Linux yet but is available\n> at:\n> https://lore.kernel.org/all/20250915-extensible-parameters-validation-v5-0-e6db94468af3@ideasonboard.com/\n> \n> Create the include/linux/media/ directory so that header files\n> exported from the kernel which include this file do not need\n> to be adjusted when imported in libcamera.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Tested-By: Antoine Bouyer <antoine.bouyer@nxp.com>\n\nThe header will change, but I expect the ABI to be preserved, so we can\neasily update it later.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nIt would be nice to have a patch for utils/update-kernel-headers.sh in\nthis series, that we'll merge later once the v4l2-isp.h header is merged\nupstream.\n\n> ---\n>  include/linux/media/v4l2-isp.h | 100 +++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 100 insertions(+)\n> \n> diff --git a/include/linux/media/v4l2-isp.h b/include/linux/media/v4l2-isp.h\n> new file mode 100644\n> index 0000000000000000000000000000000000000000..fed89b5678585a3565d33cf873d0313dc089524f\n> --- /dev/null\n> +++ b/include/linux/media/v4l2-isp.h\n> @@ -0,0 +1,100 @@\n> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n> +/*\n> + * Video4Linux2 generic ISP parameters and statistics support\n> + *\n> + * Copyright (C) 2025 Ideas On Board Oy\n> + * Author: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> + */\n> +\n> +#ifndef _V4L2_ISP_H_\n> +#define _V4L2_ISP_H_\n> +\n> +#include <linux/stddef.h>\n> +#include <linux/types.h>\n> +\n> +#define V4L2_PARAMS_FL_BLOCK_DISABLE\t(1U << 0)\n> +#define V4L2_PARAMS_FL_BLOCK_ENABLE\t(1U << 1)\n> +\n> +/*\n> + * Reserve the first 8 bits for V4L2_PARAMS_FL_* flag.\n> + *\n> + * Driver-specific flags should be defined as:\n> + * #define PLATFORM_SPECIFIC_FLAG0     ((1U << V4L2_PARAMS_FL_DRIVER_FLAGS(0))\n> + * #define PLATFORM_SPECIFIC_FLAG1     ((1U << V4L2_PARAMS_FL_DRIVER_FLAGS(1))\n> + */\n> +#define V4L2_PARAMS_FL_DRIVER_FLAGS(n)       ((n) + 8)\n> +\n> +/**\n> + * struct v4l2_params_block_header - V4L2 extensible parameters block header\n> + *\n> + * This structure represents the common part of all the ISP configuration\n> + * blocks. Each parameters block shall embed an instance of this structure type\n> + * as its first member, followed by the block-specific configuration data. The\n> + * driver inspects this common header to discern the block type and its size and\n> + * properly handle the block content.\n> + *\n> + * The @type field is an ISP driver-specific value that identifies the block\n> + * type. The @size field specifies the size of the parameters block.\n> + *\n> + * The @flags field is a bitmask of per-block flags V4L2_PARAMS_FL_* and\n> + * driver-specific flags specified by the driver header.\n> + *\n> + * @type: The parameters block type (driver-specific)\n> + * @flags: A bitmask of block flags (driver-specific)\n> + * @size: Size (in bytes) of the parameters block, including this header\n> + */\n> +struct v4l2_params_block_header {\n> +\t__u16 type;\n> +\t__u16 flags;\n> +\t__u32 size;\n> +} __attribute__((aligned(8)));\n> +\n> +/**\n> + * v4l2_params_buffer_size - Calculate size of v4l2_params_buffer for a platform\n> + *\n> + * Users of the v4l2 extensible parameters will have differing sized data arrays\n> + * depending on their specific parameter buffers. Drivers and userspace will\n> + * need to be able to calculate the appropriate size of the struct to\n> + * accommodate all ISP configuration blocks provided by the platform.\n> + * This macro provides a convenient tool for the calculation.\n> + *\n> + * @max_params_size: The total size of the ISP configuration blocks\n> + */\n> +#define v4l2_params_buffer_size(max_params_size) \\\n> +\t(offsetof(struct v4l2_params_buffer, data) + (max_params_size))\n> +\n> +/**\n> + * struct v4l2_params_buffer - V4L2 extensible parameters configuration\n> + *\n> + * This struct contains the configuration parameters of the ISP algorithms,\n> + * serialized by userspace into a data buffer. Each configuration parameter\n> + * block is represented by a block-specific structure which contains a\n> + * :c:type:`v4l2_params_block_header` entry as first member. Userspace populates\n> + * the @data buffer with configuration parameters for the blocks that it intends\n> + * to configure. As a consequence, the data buffer effective size changes\n> + * according to the number of ISP blocks that userspace intends to configure and\n> + * is set by userspace in the @data_size field.\n> + *\n> + * The parameters buffer is versioned by the @version field to allow modifying\n> + * and extending its definition. Userspace shall populate the @version field to\n> + * inform the driver about the version it intends to use. The driver will parse\n> + * and handle the @data buffer according to the data layout specific to the\n> + * indicated version and return an error if the desired version is not\n> + * supported.\n> + *\n> + * For each ISP block that userspace wants to configure, a block-specific\n> + * structure is appended to the @data buffer, one after the other without gaps\n> + * in between nor overlaps. Userspace shall populate the @data_size field with\n> + * the effective size, in bytes, of the @data buffer.\n> + *\n> + * @version: The parameters buffer version (driver-specific)\n> + * @data_size: The configuration data effective size, excluding this header\n> + * @data: The configuration data\n> + */\n> +struct v4l2_params_buffer {\n> +\t__u32 version;\n> +\t__u32 data_size;\n> +\t__u8 data[] __counted_by(data_size);\n> +};\n> +\n> +#endif /* _V4L2_ISP_H_ */","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 A1248BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Oct 2025 01:31:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 687E96B5F3;\n\tMon,  6 Oct 2025 03:31:24 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6FD1E613AB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Oct 2025 03:31:22 +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 UTF8SMTPSA id 0219CC67;\n\tMon,  6 Oct 2025 03:29:49 +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=\"eilhr5KQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1759714190;\n\tbh=xVBgRgZONwD/5lLvzltEpOvq2ehBgbMSt48/599NezQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=eilhr5KQG+pRYakliY4m9e+U3lX/ofNukEaJ/Mx0K3dPGO/Ylma68i4Rc4k8zqOMe\n\tIm+SbA1lCrvJmYZd2AozsLtvIk8y47OCyjyuNCdGbyrbb+LD6KzE2XhrMXzIxWQDOa\n\ttHypbb27CDqpD2SeUqy0TR0FG7QIVP7jNz6w1LI8=","Date":"Mon, 6 Oct 2025 04:31:16 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tAntoine Bouyer <antoine.bouyer@nxp.com>","Subject":"Re: [PATCH v4 1/5] include: linux: Add v4l2-isp.h","Message-ID":"<20251006013116.GE13055@pendragon.ideasonboard.com>","References":"<20251001-v4l2-params-v4-0-8f2b4779205e@ideasonboard.com>\n\t<20251001-v4l2-params-v4-1-8f2b4779205e@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20251001-v4l2-params-v4-1-8f2b4779205e@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":36130,"web_url":"https://patchwork.libcamera.org/comment/36130/","msgid":"<cc6feca6-6170-4cfe-84e4-954cbb7a2533@ideasonboard.com>","date":"2025-10-06T08:21:26","subject":"Re: [PATCH v4 1/5] include: linux: Add v4l2-isp.h","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"content":"Hi Jacopo\n\nOn 01/10/2025 16:42, Jacopo Mondi wrote:\n> Import the v4l2-isp.h header from the Linux kernel sources.\n> \n> The file has not been merged in mainline Linux yet but is available\n> at:\n> https://lore.kernel.org/all/20250915-extensible-parameters-validation-v5-0-e6db94468af3@ideasonboard.com/\n> \n> Create the include/linux/media/ directory so that header files\n> exported from the kernel which include this file do not need\n> to be adjusted when imported in libcamera.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Tested-By: Antoine Bouyer <antoine.bouyer@nxp.com>\n\nReviewed-by: Daniel Scally <dan.scally@ideasonboard.com>> ---\n>   include/linux/media/v4l2-isp.h | 100 +++++++++++++++++++++++++++++++++++++++++\n>   1 file changed, 100 insertions(+)\n> \n> diff --git a/include/linux/media/v4l2-isp.h b/include/linux/media/v4l2-isp.h\n> new file mode 100644\n> index 0000000000000000000000000000000000000000..fed89b5678585a3565d33cf873d0313dc089524f\n> --- /dev/null\n> +++ b/include/linux/media/v4l2-isp.h\n> @@ -0,0 +1,100 @@\n> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n> +/*\n> + * Video4Linux2 generic ISP parameters and statistics support\n> + *\n> + * Copyright (C) 2025 Ideas On Board Oy\n> + * Author: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> + */\n> +\n> +#ifndef _V4L2_ISP_H_\n> +#define _V4L2_ISP_H_\n> +\n> +#include <linux/stddef.h>\n> +#include <linux/types.h>\n> +\n> +#define V4L2_PARAMS_FL_BLOCK_DISABLE\t(1U << 0)\n> +#define V4L2_PARAMS_FL_BLOCK_ENABLE\t(1U << 1)\n> +\n> +/*\n> + * Reserve the first 8 bits for V4L2_PARAMS_FL_* flag.\n> + *\n> + * Driver-specific flags should be defined as:\n> + * #define PLATFORM_SPECIFIC_FLAG0     ((1U << V4L2_PARAMS_FL_DRIVER_FLAGS(0))\n> + * #define PLATFORM_SPECIFIC_FLAG1     ((1U << V4L2_PARAMS_FL_DRIVER_FLAGS(1))\n> + */\n> +#define V4L2_PARAMS_FL_DRIVER_FLAGS(n)       ((n) + 8)\n> +\n> +/**\n> + * struct v4l2_params_block_header - V4L2 extensible parameters block header\n> + *\n> + * This structure represents the common part of all the ISP configuration\n> + * blocks. Each parameters block shall embed an instance of this structure type\n> + * as its first member, followed by the block-specific configuration data. The\n> + * driver inspects this common header to discern the block type and its size and\n> + * properly handle the block content.\n> + *\n> + * The @type field is an ISP driver-specific value that identifies the block\n> + * type. The @size field specifies the size of the parameters block.\n> + *\n> + * The @flags field is a bitmask of per-block flags V4L2_PARAMS_FL_* and\n> + * driver-specific flags specified by the driver header.\n> + *\n> + * @type: The parameters block type (driver-specific)\n> + * @flags: A bitmask of block flags (driver-specific)\n> + * @size: Size (in bytes) of the parameters block, including this header\n> + */\n> +struct v4l2_params_block_header {\n> +\t__u16 type;\n> +\t__u16 flags;\n> +\t__u32 size;\n> +} __attribute__((aligned(8)));\n> +\n> +/**\n> + * v4l2_params_buffer_size - Calculate size of v4l2_params_buffer for a platform\n> + *\n> + * Users of the v4l2 extensible parameters will have differing sized data arrays\n> + * depending on their specific parameter buffers. Drivers and userspace will\n> + * need to be able to calculate the appropriate size of the struct to\n> + * accommodate all ISP configuration blocks provided by the platform.\n> + * This macro provides a convenient tool for the calculation.\n> + *\n> + * @max_params_size: The total size of the ISP configuration blocks\n> + */\n> +#define v4l2_params_buffer_size(max_params_size) \\\n> +\t(offsetof(struct v4l2_params_buffer, data) + (max_params_size))\n> +\n> +/**\n> + * struct v4l2_params_buffer - V4L2 extensible parameters configuration\n> + *\n> + * This struct contains the configuration parameters of the ISP algorithms,\n> + * serialized by userspace into a data buffer. Each configuration parameter\n> + * block is represented by a block-specific structure which contains a\n> + * :c:type:`v4l2_params_block_header` entry as first member. Userspace populates\n> + * the @data buffer with configuration parameters for the blocks that it intends\n> + * to configure. As a consequence, the data buffer effective size changes\n> + * according to the number of ISP blocks that userspace intends to configure and\n> + * is set by userspace in the @data_size field.\n> + *\n> + * The parameters buffer is versioned by the @version field to allow modifying\n> + * and extending its definition. Userspace shall populate the @version field to\n> + * inform the driver about the version it intends to use. The driver will parse\n> + * and handle the @data buffer according to the data layout specific to the\n> + * indicated version and return an error if the desired version is not\n> + * supported.\n> + *\n> + * For each ISP block that userspace wants to configure, a block-specific\n> + * structure is appended to the @data buffer, one after the other without gaps\n> + * in between nor overlaps. Userspace shall populate the @data_size field with\n> + * the effective size, in bytes, of the @data buffer.\n> + *\n> + * @version: The parameters buffer version (driver-specific)\n> + * @data_size: The configuration data effective size, excluding this header\n> + * @data: The configuration data\n> + */\n> +struct v4l2_params_buffer {\n> +\t__u32 version;\n> +\t__u32 data_size;\n> +\t__u8 data[] __counted_by(data_size);\n> +};\n> +\n> +#endif /* _V4L2_ISP_H_ */\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 A7921BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Oct 2025 08:21:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BAED66B5AA;\n\tMon,  6 Oct 2025 10:21:31 +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 5A6E362C35\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Oct 2025 10:21:29 +0200 (CEST)","from [192.168.0.43]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DD86B2273\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Oct 2025 10:19:56 +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=\"GLDaZuGf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1759738796;\n\tbh=efEw1QjYWmaQlvZy1iSBqO3KUcOKUBzDDccTSJogumk=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=GLDaZuGfh1Kn/5YFGC/xnRKvfEL+5QRaHsNq30OajXVuYO4AUCnlfo5ujIeKBnk/e\n\t42MEJUWtMphSkd5cYlpBjWk4Tjh5u4Ow/vi4C/oZQCT/GnnNIJDbVd+19MWnlflHfu\n\tT432i/t14/hA2zJUZl7Gj1IOnYyjjg1sNxt3AYBg=","Message-ID":"<cc6feca6-6170-4cfe-84e4-954cbb7a2533@ideasonboard.com>","Date":"Mon, 6 Oct 2025 09:21:26 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v4 1/5] include: linux: Add v4l2-isp.h","To":"libcamera-devel@lists.libcamera.org","References":"<20251001-v4l2-params-v4-0-8f2b4779205e@ideasonboard.com>\n\t<20251001-v4l2-params-v4-1-8f2b4779205e@ideasonboard.com>","Content-Language":"en-US","From":"Dan Scally <dan.scally@ideasonboard.com>","In-Reply-To":"<20251001-v4l2-params-v4-1-8f2b4779205e@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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>"}}]