From nobody Thu Dec 18 21:45:19 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51F4427F4E7; Sat, 8 Nov 2025 09:36:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594606; cv=none; b=q0EXfsh7iWWM7zJGM/9uaY2dMOoqQV1SslQqYIcDyt/w3avkv01RNfH6EVIYGhbP0lndLe6IEqX03G0ZgdQOuNE0HEwElFpyYGQRFzlroc3kvrxbpIcLhHgn5VL+cVs6mThSq85EjG0YDzU4NS50zIShthe1kZ4Ggxf4tRgak3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594606; c=relaxed/simple; bh=BLauyWgclUw8G3IPAW8WN28EBqbVDl7XpGY054U/ub8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c3N8MEEUYwUm5ZMbqfICdC9VTq9bsOce6HgpbO2dF/ieLsaAoBxcOVNmQCcklJOurZ0AzllzaUqb3kfXChx0s0TX+m0G3juFMJxz+rxtKm9MQdA4eJIr39PnQ/DWpKlxX33b+iFxkF9OJO6iKE4zXBOPjMq/YNfyneSy45hfGJo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=rO0DfbWr; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rO0DfbWr" Received: from [192.168.0.172] (mob-5-90-142-135.net.vodafone.it [5.90.142.135]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BA22EE1F; Sat, 8 Nov 2025 10:34:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1762594485; bh=BLauyWgclUw8G3IPAW8WN28EBqbVDl7XpGY054U/ub8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rO0DfbWrGyc0wDGGl4oY/+Imy66F2S/Z5Ut+UMR/uNK/VbglYNuEgHffxeVfaFkDC frJlCASTpIPnMxyolZeAebXUA9ltYKbJSZPArHIyYDen7GORItFRXbc8v+tPy/pMZE kVN3yY35bqAa28ip6x5aI0x9+mRlTeTeWi2YPr/U= From: Jacopo Mondi Date: Sat, 08 Nov 2025 10:36:22 +0100 Subject: [PATCH v9 1/8] media: uapi: Introduce V4L2 generic ISP types Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251108-extensible-parameters-validation-v9-1-6a7e22aa57d0@ideasonboard.com> References: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> In-Reply-To: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Keke Li , Mauro Carvalho Chehab , Heiko Stuebner , Dan Scally , Sakari Ailus , Antoine Bouyer Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jacopo Mondi , Laurent Pinchart , Michael Riesch , Lad Prabhakar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6466; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=BLauyWgclUw8G3IPAW8WN28EBqbVDl7XpGY054U/ub8=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpDw8lTUZllRl/YkTq/v6bnfhFzsif8H7Xopty6 jIugFC8SFOJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaQ8PJQAKCRByNAaPFqFW PH3XD/0T6mQJOBZWmFAHRJbbEdggAIMFbJ37jbwVfaDWYZvHtXrnNKhgCFD3CetsE2QMUbjJLya IsUoZnuJoGdXSfiHhTBQEQ6RiZ9QVTsmaZU/r68MzO8kQp/8V9l7L8SO4myJHrwcwhg7djLvPDd NcN2VUcFeWa8cA13ues+rBdM0p6JBeZDeJzT1x0ziOZ0Ywb1o8uYvNbSNL5PhophrHC2ciqorNs fxdMrxxXS7V9dou+ptOk5mK7q1iUtcMprjZRXPSL1F4HyDmNLFfPPTy8R25FF5CX0Udqm1JDnLK 82eIHkNguCfYwjvZeVigmqIQhX5E89g6h+XjO28OfauHhinDtq4xPtwrkMwGV6FEjGI3HqVIaIR HfKwYW1AALSG/v0JjRH2Ue7RG3t1HpU+5izeYw8RzGzlGsJZaDOfHFCgwOEb2cJakc2qAOPPIFF 6iyVej/OQTLONqDMuX/yR2bFcC9yTI7r1pbNmlg910v5zB8d4mSzVFqFyX5cR8WhMQ4EuPw9C/m wEC2UfJFaRitejILy1y7ubOBYpY2sa/o9HVjswKHqHbnI3W49p1LsNEdZTMkW092svqCCHiLIX3 lLF59XMmPFi/OyMAdKNkzuXzP/UNouDjLebJ8iIBbSyZruQ2dbjjCNHWgXMhyhLmv2zaL6WvmkH 5VJhcZjb31JD07A== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Introduce v4l2-isp.h in the Linux kernel uAPI. The header includes types for generic ISP configuration parameters and will be extended in the future with support for generic ISP statistics formats. Generic ISP parameters support is provided by introducing two new types that represent an extensible and versioned buffer of ISP configuration parameters. The v4l2_params_buffer represents the container for the ISP configuration data block. The generic type is defined with a 0-sized data member that the ISP driver implementations shall properly size according to their capabilities. The v4l2_params_block_header structure represents the header to be prepend to each ISP configuration block. Signed-off-by: Daniel Scally Reviewed-by: Daniel Scally Reviewed-by: Laurent Pinchart Reviewed-by: Michael Riesch Acked-by: Sakari Ailus Tested-by: Lad Prabhakar Signed-off-by: Jacopo Mondi --- MAINTAINERS | 6 +++ include/uapi/linux/media/v4l2-isp.h | 102 ++++++++++++++++++++++++++++++++= ++++ 2 files changed, 108 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 8aec054a6ac7280d11356737787d4b63a4bd5584..8989e7e00d86d0c13c4c0b7e5c7= eb9481b65861f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26855,6 +26855,12 @@ F: drivers/media/i2c/vd55g1.c F: drivers/media/i2c/vd56g3.c F: drivers/media/i2c/vgxy61.c =20 +V4L2 GENERIC ISP PARAMETERS AND STATISTIC FORMATS +M: Jacopo Mondi +L: linux-media@vger.kernel.org +S: Maintained +F: include/uapi/linux/media/v4l2-isp.h + VF610 NAND DRIVER M: Stefan Agner L: linux-mtd@lists.infradead.org diff --git a/include/uapi/linux/media/v4l2-isp.h b/include/uapi/linux/media= /v4l2-isp.h new file mode 100644 index 0000000000000000000000000000000000000000..779168f9058e3bcf6451f681e24= 7d34d95676cc0 --- /dev/null +++ b/include/uapi/linux/media/v4l2-isp.h @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * Video4Linux2 generic ISP parameters and statistics support + * + * Copyright (C) 2025 Ideas On Board Oy + * Author: Jacopo Mondi + */ + +#ifndef _UAPI_V4L2_ISP_H_ +#define _UAPI_V4L2_ISP_H_ + +#include +#include + +/** + * enum v4l2_isp_params_version - V4L2 ISP parameters versioning + * + * @V4L2_ISP_PARAMS_VERSION_V0: First version of the V4L2 ISP parameters f= ormat + * (for compatibility) + * @V4L2_ISP_PARAMS_VERSION_V1: First version of the V4L2 ISP parameters f= ormat + * + * V0 and V1 are identical in order to support drivers compatible with the= V4L2 + * ISP parameters format already upstreamed which use either 0 or 1 as the= ir + * versioning identifier. Both V0 and V1 refers to the first version of the + * V4L2 ISP parameters format. + * + * Future revisions of the V4L2 ISP parameters format should start from the + * value of 2. + */ +enum v4l2_isp_params_version { + V4L2_ISP_PARAMS_VERSION_V0 =3D 0, + V4L2_ISP_PARAMS_VERSION_V1 +}; + +#define V4L2_ISP_PARAMS_FL_BLOCK_DISABLE (1U << 0) +#define V4L2_ISP_PARAMS_FL_BLOCK_ENABLE (1U << 1) + +/* + * Reserve the first 8 bits for V4L2_ISP_PARAMS_FL_* flag. + * + * Driver-specific flags should be defined as: + * #define DRIVER_SPECIFIC_FLAG0 ((1U << V4L2_ISP_PARAMS_FL_DRIVER_FLA= GS(0)) + * #define DRIVER_SPECIFIC_FLAG1 ((1U << V4L2_ISP_PARAMS_FL_DRIVER_FLA= GS(1)) + */ +#define V4L2_ISP_PARAMS_FL_DRIVER_FLAGS(n) ((n) + 8) + +/** + * struct v4l2_isp_params_block_header - V4L2 extensible parameters block = header + * @type: The parameters block type (driver-specific) + * @flags: A bitmask of block flags (driver-specific) + * @size: Size (in bytes) of the parameters block, including this header + * + * This structure represents the common part of all the ISP configuration + * blocks. Each parameters block shall embed an instance of this structure= type + * as its first member, followed by the block-specific configuration data. + * + * The @type field is an ISP driver-specific value that identifies the blo= ck + * type. The @size field specifies the size of the parameters block. + * + * The @flags field is a bitmask of per-block flags V4L2_PARAMS_ISP_FL_* a= nd + * driver-specific flags specified by the driver header. + */ +struct v4l2_isp_params_block_header { + __u16 type; + __u16 flags; + __u32 size; +} __attribute__((aligned(8))); + +/** + * struct v4l2_isp_params_buffer - V4L2 extensible parameters configuration + * @version: The parameters buffer version (driver-specific) + * @data_size: The configuration data effective size, excluding this header + * @data: The configuration data + * + * This structure contains the configuration parameters of the ISP algorit= hms, + * serialized by userspace into a data buffer. Each configuration parameter + * block is represented by a block-specific structure which contains a + * :c:type:`v4l2_isp_params_block_header` entry as first member. Userspace + * populates the @data buffer with configuration parameters for the blocks= that + * it intends to configure. As a consequence, the data buffer effective si= ze + * changes according to the number of ISP blocks that userspace intends to + * configure and is set by userspace in the @data_size field. + * + * The parameters buffer is versioned by the @version field to allow modif= ying + * and extending its definition. Userspace shall populate the @version fie= ld to + * inform the driver about the version it intends to use. The driver will = parse + * and handle the @data buffer according to the data layout specific to the + * indicated version and return an error if the desired version is not + * supported. + * + * For each ISP block that userspace wants to configure, a block-specific + * structure is appended to the @data buffer, one after the other without = gaps + * in between. Userspace shall populate the @data_size field with the effe= ctive + * size, in bytes, of the @data buffer. + */ +struct v4l2_isp_params_buffer { + __u32 version; + __u32 data_size; + __u8 data[] __counted_by(data_size); +}; + +#endif /* _UAPI_V4L2_ISP_H_ */ --=20 2.51.0 From nobody Thu Dec 18 21:45:19 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58BA82EC097; Sat, 8 Nov 2025 09:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594609; cv=none; b=RbyEymTZ94KQ7N75JN78IZ8RX0FeficJz0yoE1o+QTTMoPZNob432+zN1jdqRva2dLO3o9skojzk/o3EOHC0bmTxme7Y3a/KRPyjbbiaX7JszOPXdui9pj0YNRgC3m0DCaQ0eV7EkqXqbDDDw+NosCotX/6hb0Jn2bUaEmCONaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594609; c=relaxed/simple; bh=uXqROBe03Df6nRQvNNm/MdnIXD9R/Kx+57oMSff7Frk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=n/JpSmrTDUg4wsSlmK7hs2+mQHhX4vRKVTWzKa0cxGY2rXdAr+IPXzZImR1dJkF7L3IIxVx8Dw+3+nmu02P61lqnrQekgfTSZQyAQkEHVfUIW1yCl6fFyfzzRl3CqkeCRxkpTPWof2ScBC5jSU4dxLSVQWxt2uoEqlp3jCMr5xs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=CHL/XF1A; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="CHL/XF1A" Received: from [192.168.0.172] (mob-5-90-142-135.net.vodafone.it [5.90.142.135]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E887FE96; Sat, 8 Nov 2025 10:34:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1762594486; bh=uXqROBe03Df6nRQvNNm/MdnIXD9R/Kx+57oMSff7Frk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CHL/XF1AAvEhi4AGLjRM1FCIgvSG8NKqg9RV+phR4nA5AApweU+GPP/40IWogw99F lhJHoSWDjINLHzLFgQyLBXwMCsT1Xi4uDU5Eq4LcneRqKKOPCWfHKKevE+CHUnGE2/ rnaTL4xR3j9hDyRJKoCxN+vK5ZnfGrkphyDtzr7o= From: Jacopo Mondi Date: Sat, 08 Nov 2025 10:36:23 +0100 Subject: [PATCH v9 2/8] media: uapi: Convert RkISP1 to V4L2 extensible params Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251108-extensible-parameters-validation-v9-2-6a7e22aa57d0@ideasonboard.com> References: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> In-Reply-To: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Keke Li , Mauro Carvalho Chehab , Heiko Stuebner , Dan Scally , Sakari Ailus , Antoine Bouyer Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jacopo Mondi , Laurent Pinchart , Michael Riesch , Lad Prabhakar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8205; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=uXqROBe03Df6nRQvNNm/MdnIXD9R/Kx+57oMSff7Frk=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpDw8mhziXD1y+wAlhgItxzkm1j+Lxfzzmbu+x0 KuyYgFPMc6JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaQ8PJgAKCRByNAaPFqFW PHiCD/9y/kxKfqXDBcz6EHyx88CKxVz6IfAvJb2kcIa7FfD3N1zpuG34F932HfggHtiC3Fzm3GD JECZTwAOndvToSSykEK6zhGi2KRMtYteZ6ENG996xa2g2SXRxTwe1ntcOkJ3yWn5CaBrinzwFv3 RMMwYV8xSN8SEVFAIUGfzP/ImVk4nrCzNrOdZuabxm/KsEQoPJ/HvGsifjCFpJ7LqdKBbVFLg4X JzIXhBIHA0o93/esTbPJdYc8ey3FQ5mS+Uhh1FTOraOdC5S7DcU+TdbHWOIuBlR7hnl5coWcw9i wZb8lweE36+L9VJCxtLEYvGJnoHd6hF7OrDneokhDTTzC5jjT1xOJ4tJQZZTsUPXZWxV5/lvCpr poZk92/VQndts+pFufFIpGk1yOUP91XilY9QAj3A/oLErnTDSKaXdmyJk/NpokoU8K/Qm4i9Orq Q2WlbW0zbhUyiBHDPpxuqtDEsY+b6TXboY2WCGAn7B370h1u9fzNAayCfe+kEr6fMIy2D9Jafm3 HcuoHTjKVWk95BYUcTDNqh9N2EtuAeyTeGjM1wqG+pIbZ5gU6nSc4tHTn8G6KPoMzEWW0TOD65c qBZoycu71OZ7k7WSNL/F/V/0G55uNvs1AAJBVTK2Au0Fq8eQbeg/A66lyzNo18CCMumCSQtrBpG NvOJ93rlyQ0jrbA== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B With the introduction of common types for extensible parameters format, convert the rkisp1-config.h header to use the new types. Factor out the documentation that is now part of the common header and only keep the driver-specific on in place. The conversion to use common types doesn't impact userspace as the new types are either identical to the ones already existing in the RkISP1 uAPI or are 1-to-1 type convertible. Reviewed-by: Daniel Scally Reviewed-by: Laurent Pinchart Reviewed-by: Michael Riesch Acked-by: Sakari Ailus Tested-by: Lad Prabhakar Signed-off-by: Jacopo Mondi --- include/uapi/linux/rkisp1-config.h | 107 +++++++++------------------------= ---- 1 file changed, 24 insertions(+), 83 deletions(-) diff --git a/include/uapi/linux/rkisp1-config.h b/include/uapi/linux/rkisp1= -config.h index 3b060ea6eed71b87d79abc8401eae4e9c9f5323a..b2d2a71f7baff3833b20519264b= 58db7f168af90 100644 --- a/include/uapi/linux/rkisp1-config.h +++ b/include/uapi/linux/rkisp1-config.h @@ -7,8 +7,13 @@ #ifndef _UAPI_RKISP1_CONFIG_H #define _UAPI_RKISP1_CONFIG_H =20 +#ifdef __KERNEL__ +#include +#endif /* __KERNEL__ */ #include =20 +#include + /* Defect Pixel Cluster Detection */ #define RKISP1_CIF_ISP_MODULE_DPCC (1U << 0) /* Black Level Subtraction */ @@ -1158,79 +1163,26 @@ enum rkisp1_ext_params_block_type { RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR, }; =20 -#define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE (1U << 0) -#define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE (1U << 1) +/* For backward compatibility */ +#define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE V4L2_ISP_PARAMS_FL_BLOCK_DISABLE +#define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE V4L2_ISP_PARAMS_FL_BLOCK_ENABLE =20 /* A bitmask of parameters blocks supported on the current hardware. */ #define RKISP1_CID_SUPPORTED_PARAMS_BLOCKS (V4L2_CID_USER_RKISP1_BASE + 0x= 01) =20 /** - * struct rkisp1_ext_params_block_header - RkISP1 extensible parameters bl= ock - * header + * rkisp1_ext_params_block_header - RkISP1 extensible parameters block hea= der * * This structure represents the common part of all the ISP configuration - * blocks. Each parameters block shall embed an instance of this structure= type - * as its first member, followed by the block-specific configuration data.= The - * driver inspects this common header to discern the block type and its si= ze and - * properly handle the block content by casting it to the correct block-sp= ecific - * type. + * blocks and is identical to :c:type:`v4l2_isp_params_block_header`. * - * The @type field is one of the values enumerated by + * The type field is one of the values enumerated by * :c:type:`rkisp1_ext_params_block_type` and specifies how the data shoul= d be - * interpreted by the driver. The @size field specifies the size of the - * parameters block and is used by the driver for validation purposes. - * - * The @flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*. - * - * When userspace wants to configure and enable an ISP block it shall fully - * populate the block configuration and set the - * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE bit in the @flags field. - * - * When userspace simply wants to disable an ISP block the - * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bit should be set in @flags field. T= he - * driver ignores the rest of the block configuration structure in this ca= se. - * - * If a new configuration of an ISP block has to be applied userspace shall - * fully populate the ISP block configuration and omit setting the - * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and RKISP1_EXT_PARAMS_FL_BLOCK_DISABL= E bits - * in the @flags field. - * - * Setting both the RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and - * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits in the @flags field is not allo= wed - * and not accepted by the driver. - * - * Userspace is responsible for correctly populating the parameters block = header - * fields (@type, @flags and @size) and the block-specific parameters. - * - * For example: + * interpreted by the driver. * - * .. code-block:: c - * - * void populate_bls(struct rkisp1_ext_params_block_header *block) { - * struct rkisp1_ext_params_bls_config *bls =3D - * (struct rkisp1_ext_params_bls_config *)block; - * - * bls->header.type =3D RKISP1_EXT_PARAMS_BLOCK_ID_BLS; - * bls->header.flags =3D RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; - * bls->header.size =3D sizeof(*bls); - * - * bls->config.enable_auto =3D 0; - * bls->config.fixed_val.r =3D blackLevelRed_; - * bls->config.fixed_val.gr =3D blackLevelGreenR_; - * bls->config.fixed_val.gb =3D blackLevelGreenB_; - * bls->config.fixed_val.b =3D blackLevelBlue_; - * } - * - * @type: The parameters block type, see - * :c:type:`rkisp1_ext_params_block_type` - * @flags: A bitmask of block flags - * @size: Size (in bytes) of the parameters block, including this header + * The flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*. */ -struct rkisp1_ext_params_block_header { - __u16 type; - __u16 flags; - __u32 size; -}; +#define rkisp1_ext_params_block_header v4l2_isp_params_block_header =20 /** * struct rkisp1_ext_params_bls_config - RkISP1 extensible params BLS conf= ig @@ -1588,27 +1540,14 @@ struct rkisp1_ext_params_wdr_config { * @RKISP1_EXT_PARAM_BUFFER_V1: First version of RkISP1 extensible paramet= ers */ enum rksip1_ext_param_buffer_version { - RKISP1_EXT_PARAM_BUFFER_V1 =3D 1, + RKISP1_EXT_PARAM_BUFFER_V1 =3D V4L2_ISP_PARAMS_VERSION_V1, }; =20 /** * struct rkisp1_ext_params_cfg - RkISP1 extensible parameters configurati= on * - * This struct contains the configuration parameters of the RkISP1 ISP - * algorithms, serialized by userspace into a data buffer. Each configurat= ion - * parameter block is represented by a block-specific structure which cont= ains a - * :c:type:`rkisp1_ext_params_block_header` entry as first member. Userspa= ce - * populates the @data buffer with configuration parameters for the blocks= that - * it intends to configure. As a consequence, the data buffer effective si= ze - * changes according to the number of ISP blocks that userspace intends to - * configure and is set by userspace in the @data_size field. - * - * The parameters buffer is versioned by the @version field to allow modif= ying - * and extending its definition. Userspace shall populate the @version fie= ld to - * inform the driver about the version it intends to use. The driver will = parse - * and handle the @data buffer according to the data layout specific to the - * indicated version and return an error if the desired version is not - * supported. + * This is the driver-specific implementation of + * :c:type:`v4l2_isp_params_buffer`. * * Currently the single RKISP1_EXT_PARAM_BUFFER_V1 version is supported. * When a new format version will be added, a mechanism for userspace to q= uery @@ -1624,11 +1563,6 @@ enum rksip1_ext_param_buffer_version { * the maximum value represents the blocks supported by the kernel driver, * independently of the device instance. * - * For each ISP block that userspace wants to configure, a block-specific - * structure is appended to the @data buffer, one after the other without = gaps - * in between nor overlaps. Userspace shall populate the @data_size field = with - * the effective size, in bytes, of the @data buffer. - * * The expected memory layout of the parameters buffer is:: * * +-------------------- struct rkisp1_ext_params_cfg -------------------+ @@ -1678,4 +1612,11 @@ struct rkisp1_ext_params_cfg { __u8 data[RKISP1_EXT_PARAMS_MAX_SIZE]; }; =20 +#ifdef __KERNEL__ +/* Make sure the header is type-convertible to the generic v4l2 params one= */ +static_assert((sizeof(struct rkisp1_ext_params_cfg) - + RKISP1_EXT_PARAMS_MAX_SIZE) =3D=3D + sizeof(struct v4l2_isp_params_buffer)); +#endif /* __KERNEL__ */ + #endif /* _UAPI_RKISP1_CONFIG_H */ --=20 2.51.0 From nobody Thu Dec 18 21:45:19 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 273C92ED151; Sat, 8 Nov 2025 09:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594610; cv=none; b=V1oICTrm7Oqm5g4RbfUiHHQTVomyOKm5o0pfHbqC54/7MWVbAuVSE3XV5ZdXT9a4ypbB0Kr6D2RSIo7d2quPAb/9OGXJbT/sa/+lJOz9QSE0wXbSPaUkEQEQXRFSgxV75TJvBnitP9YMKJnFl5JpivozG1kaJKNIPs6iB3OxDZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594610; c=relaxed/simple; bh=bzsrN2uQYXJndG8lZhyiTnB6LcVamCT189N9P1MIYZE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W4UK4+1dIht56+iAlAhaQ09RWzpA67zZHHwoDefOFBeH2fQLJ8aqzr6FgfayWsW+0uixIu8j3bYRIqs1U5m2dMPo8hfyJFPRqEK5wTfbbnpDJ/+g/xne/fM34QAAt5q4GaxHlOp/ff27juqaUa/xunyr9IV74Yc8D19X7XbpDTA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=Pj0cdcO3; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Pj0cdcO3" Received: from [192.168.0.172] (mob-5-90-142-135.net.vodafone.it [5.90.142.135]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 22C96EFF; Sat, 8 Nov 2025 10:34:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1762594488; bh=bzsrN2uQYXJndG8lZhyiTnB6LcVamCT189N9P1MIYZE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Pj0cdcO3W9f8ryHVfqEiiyACwUGtwQPUWSW9QLK03fhDHys9ZvmGuRSAG1wV9YODF LTj5s6L80PlMS2bg0uDZz716yHvVQU0verS3DH1P78n4wBZSS8VvGM2WxU3XlWJQX8 Bo1ocZ3R7w+t2uokRkp58FeVm+vHjSb1YX+FH31c= From: Jacopo Mondi Date: Sat, 08 Nov 2025 10:36:24 +0100 Subject: [PATCH v9 3/8] media: uapi: Convert Amlogic C3 to V4L2 extensible params Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251108-extensible-parameters-validation-v9-3-6a7e22aa57d0@ideasonboard.com> References: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> In-Reply-To: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Keke Li , Mauro Carvalho Chehab , Heiko Stuebner , Dan Scally , Sakari Ailus , Antoine Bouyer Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jacopo Mondi , Laurent Pinchart , Lad Prabhakar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6943; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=bzsrN2uQYXJndG8lZhyiTnB6LcVamCT189N9P1MIYZE=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpDw8md18tOPWDMGT7m8e6oupoxlSNh+/CMSkYv au4OTD7TDOJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaQ8PJgAKCRByNAaPFqFW PBUiEAC/vVkKMk/QpX2P1Imp9bPhkyiKx92d1Bh6a6sHK8X3hnPVIxJIvh17TEZn8rshidx98Vj tZsX5ZvTqULqwKoZJX7f3HOk6CM6YS+NCBaL6JgBmtsEjlCJzI1zGaIWUg+8B8syYxHc0vKqeSw B3ONWPATTve7qJxQkDF1/MlwiMd1xAA4605q9bcp54QX0XtqXIQAQQs30HlTta+R9GRl1MCbdTd RJnJEHt24wpxb36R3EaABaLhugsfOJnRcP17lLYtg8aOgEHC9oyr6OV2ZtH8VA8HTN6CQ94ZCCt X6huaM6KZHcUBYTs3oPtwDp0WYs3d8SXqbrzAud7bJPg7hh6H07MX0aCZxEIKgKkqUOgtYvsRDx +PkdZ9R3F5X8oZUuThqzCIwxxL1HIUnCfUxsdC1PeXqRa5dau4AUBK+OWdBKRujC1wuJTVeIPd9 QgYhNW+xw2GwR+Jc4pd0I8nP9vJII9RLbbpo4zwRBHVdMrEsL1L1caTJbCSnfg/+tczjF+LT9h+ I1kXY0dq1Kb2X38rCEWCzvmN3WkRZ/ngVsMen+aRp2bpArnaSBE7JIMXbBl36VEhyRtBGMSuGuP f4PvaNrw2UJPWL4I7ZzwU8jg3UQ+YStDMRMNudPR0KzwcKjA+FhTuDUCr7+PODFOIIgDJNrHFGk hiiKprxN3ceWLmA== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B With the introduction of common types for extensible parameters format, convert the c3-isp-config.h header to use the new types. Factor-out the documentation that is now part of the common header and only keep the driver-specific on in place. The conversion to use common types doesn't impact userspace as the new types are either identical to the ones already existing in the C3 ISP uAPI or are 1-to-1 type convertible. Reviewed-by: Daniel Scally Reviewed-by: Keke Li Reviewed-by: Laurent Pinchart Acked-by: Sakari Ailus Tested-by: Lad Prabhakar Signed-off-by: Jacopo Mondi --- include/uapi/linux/media/amlogic/c3-isp-config.h | 92 +++++++-------------= ---- 1 file changed, 24 insertions(+), 68 deletions(-) diff --git a/include/uapi/linux/media/amlogic/c3-isp-config.h b/include/uap= i/linux/media/amlogic/c3-isp-config.h index ed085ea62a574932c7ad8d59d34b2c5c74a597d8..0a3c1cc55ccbbad12f18037d65f= 32ec9ca1a4ec0 100644 --- a/include/uapi/linux/media/amlogic/c3-isp-config.h +++ b/include/uapi/linux/media/amlogic/c3-isp-config.h @@ -6,8 +6,13 @@ #ifndef _UAPI_C3_ISP_CONFIG_H_ #define _UAPI_C3_ISP_CONFIG_H_ =20 +#ifdef __KERNEL__ +#include +#endif /* __KERNEL__ */ #include =20 +#include + /* * Frames are split into zones of almost equal width and height - a zone i= s a * rectangular tile of a frame. The metering blocks within the ISP collect @@ -141,7 +146,7 @@ struct c3_isp_stats_info { * @C3_ISP_PARAMS_BUFFER_V0: First version of C3 ISP parameters block */ enum c3_isp_params_buffer_version { - C3_ISP_PARAMS_BUFFER_V0, + C3_ISP_PARAMS_BUFFER_V0 =3D V4L2_ISP_PARAMS_VERSION_V0, }; =20 /** @@ -176,62 +181,23 @@ enum c3_isp_params_block_type { C3_ISP_PARAMS_BLOCK_SENTINEL }; =20 -#define C3_ISP_PARAMS_BLOCK_FL_DISABLE (1U << 0) -#define C3_ISP_PARAMS_BLOCK_FL_ENABLE (1U << 1) +/* For backward compatibility */ +#define C3_ISP_PARAMS_BLOCK_FL_DISABLE V4L2_ISP_PARAMS_FL_BLOCK_DISABLE +#define C3_ISP_PARAMS_BLOCK_FL_ENABLE V4L2_ISP_PARAMS_FL_BLOCK_ENABLE =20 /** * struct c3_isp_params_block_header - C3 ISP parameter block header * * This structure represents the common part of all the ISP configuration - * blocks. Each parameters block shall embed an instance of this structure= type - * as its first member, followed by the block-specific configuration data.= The - * driver inspects this common header to discern the block type and its si= ze and - * properly handle the block content by casting it to the correct block-sp= ecific - * type. + * blocks and is identical to :c:type:`v4l2_isp_params_block_header`. * - * The @type field is one of the values enumerated by + * The type field is one of the values enumerated by * :c:type:`c3_isp_params_block_type` and specifies how the data should be - * interpreted by the driver. The @size field specifies the size of the - * parameters block and is used by the driver for validation purposes. The - * @flags field is a bitmask of per-block flags C3_ISP_PARAMS_FL*. - * - * When userspace wants to disable an ISP block the - * C3_ISP_PARAMS_BLOCK_FL_DISABLED bit should be set in the @flags field. = In - * this case userspace may optionally omit the remainder of the configurat= ion - * block, which will be ignored by the driver. - * - * When a new configuration of an ISP block needs to be applied userspace - * shall fully populate the ISP block and omit setting the - * C3_ISP_PARAMS_BLOCK_FL_DISABLED bit in the @flags field. - * - * Userspace is responsible for correctly populating the parameters block = header - * fields (@type, @flags and @size) and the block-specific parameters. - * - * For example: - * - * .. code-block:: c + * interpreted by the driver. * - * void populate_pst_gamma(struct c3_isp_params_block_header *block) { - * struct c3_isp_params_pst_gamma *gamma =3D - * (struct c3_isp_params_pst_gamma *)block; - * - * gamma->header.type =3D C3_ISP_PARAMS_BLOCK_PST_GAMMA; - * gamma->header.flags =3D C3_ISP_PARAMS_BLOCK_FL_ENABLE; - * gamma->header.size =3D sizeof(*gamma); - * - * for (unsigned int i =3D 0; i < 129; i++) - * gamma->pst_gamma_lut[i] =3D i; - * } - * - * @type: The parameters block type from :c:type:`c3_isp_params_block_type` - * @flags: A bitmask of block flags - * @size: Size (in bytes) of the parameters block, including this header + * The flags field is a bitmask of per-block flags C3_ISP_PARAMS_FL_*. */ -struct c3_isp_params_block_header { - __u16 type; - __u16 flags; - __u32 size; -}; +#define c3_isp_params_block_header v4l2_isp_params_block_header =20 /** * struct c3_isp_params_awb_gains - Gains for auto-white balance @@ -498,26 +464,10 @@ struct c3_isp_params_blc { /** * struct c3_isp_params_cfg - C3 ISP configuration parameters * - * This struct contains the configuration parameters of the C3 ISP - * algorithms, serialized by userspace into an opaque data buffer. Each - * configuration parameter block is represented by a block-specific struct= ure - * which contains a :c:type:`c3_isp_param_block_header` entry as first - * member. Userspace populates the @data buffer with configuration paramet= ers - * for the blocks that it intends to configure. As a consequence, the data - * buffer effective size changes according to the number of ISP blocks that - * userspace intends to configure. - * - * The parameters buffer is versioned by the @version field to allow modif= ying - * and extending its definition. Userspace should populate the @version fi= eld to - * inform the driver about the version it intends to use. The driver will = parse - * and handle the @data buffer according to the data layout specific to the - * indicated revision and return an error if the desired revision is not - * supported. - * - * For each ISP block that userspace wants to configure, a block-specific - * structure is appended to the @data buffer, one after the other without = gaps - * in between nor overlaps. Userspace shall populate the @total_size field= with - * the effective size, in bytes, of the @data buffer. + * This is the driver-specific implementation of + * :c:type:`v4l2_isp_params_buffer`. + * + * Currently only C3_ISP_PARAM_BUFFER_V0 is supported. * * The expected memory layout of the parameters buffer is:: * @@ -561,4 +511,10 @@ struct c3_isp_params_cfg { __u8 data[C3_ISP_PARAMS_MAX_SIZE]; }; =20 +#ifdef __KERNEL__ +/* Make sure the header is type-convertible to the generic v4l2 params one= */ +static_assert((sizeof(struct c3_isp_params_cfg) - C3_ISP_PARAMS_MAX_SIZE) = =3D=3D + sizeof(struct v4l2_isp_params_buffer)); +#endif /* __KERNEL__ */ + #endif --=20 2.51.0 From nobody Thu Dec 18 21:45:19 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B40B12E22BD; Sat, 8 Nov 2025 09:36:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594613; cv=none; b=Jr4Zy7EWv2SVa3IGaSuB2sDWMNYOpbWrahd1nJUuETcsPd+TA1OQXHJC29rcWUhiF/LZd0Jl+ALC2Uqe6Jld9+DpoeN1p/KXJpueUsLhIpkxayU5VwE7e6cTXQBFTwybSLusPB5R57zqyRT8cddMQ2h9T4yc1Msmg+ZTvA7ernU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594613; c=relaxed/simple; bh=EU5psEHBNq7zxVfGcbPO2p2HeGtCUZ6cPz61EOQCxBQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rg6Zd0ZQicVqPIjNXUv/4cav3vSUJHhjsJSKWgWwUOiJ01Vbq0Vpr5+6J/4WZMrgbHxnlvQna7I55oH3Obdg5pWH+JVLJHR0QvzhBitjGEIDAmrrE0zfOrDJgonMF0lIxIuGEqlW+/aWytceGJrF77LJoL7kwtVXRu4v7UrWM/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=GOvzaZwG; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GOvzaZwG" Received: from [192.168.0.172] (mob-5-90-142-135.net.vodafone.it [5.90.142.135]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4F366F06; Sat, 8 Nov 2025 10:34:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1762594489; bh=EU5psEHBNq7zxVfGcbPO2p2HeGtCUZ6cPz61EOQCxBQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GOvzaZwGa4feIx+yzb5Iut6sDCInMjxW+ZMEXZFjUBMlGBONchrR4NVWcj9d4GW4K UKvI9s2CWNkg1Qd4zEh0QYq0doMCwGwjZvRNfZFWYgY3CW9zSCjJun5iTbnGk7u8eM xA2EKkge1tbkVVejmkMAame7vCvz5gb7XGr+c9Hk= From: Jacopo Mondi Date: Sat, 08 Nov 2025 10:36:25 +0100 Subject: [PATCH v9 4/8] media: Documentation: uapi: Add V4L2 ISP documentation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251108-extensible-parameters-validation-v9-4-6a7e22aa57d0@ideasonboard.com> References: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> In-Reply-To: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Keke Li , Mauro Carvalho Chehab , Heiko Stuebner , Dan Scally , Sakari Ailus , Antoine Bouyer Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jacopo Mondi , Michael Riesch , Laurent Pinchart , Lad Prabhakar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4827; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=EU5psEHBNq7zxVfGcbPO2p2HeGtCUZ6cPz61EOQCxBQ=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpDw8mceXuXf7+LXYwHKVmC4noulRRQzL44WoWb e/9DqzXp5yJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaQ8PJgAKCRByNAaPFqFW PEakD/9muUP0gfjAuZs/SJvWSbVDGZWB837z7akXxPXl9htif13nYeEuIwyndTrstJUDTibE6Mo aQRcB15uCUJjilCYfa9mndeyEmx08aiXkKB0sGvXu4PVHhlXCoeel4E1t/PX2wnDh6lhArhhZRs sHi8n40xWcJTH9O9s8ziEieWv+0bCQkHv22O90JluwXOoo1aHenNKmw+hZk8PpVAR8/BQxS0Tp1 hi6JYTVNqqmCauTV89zKz8gQtuDUCyUF0foIrZpajDXh238Fd5bnbcw8BKw6u0p1spGr25uVjYG ZlK3PUIrBjFFvHaSq3ZkDjHswDi0c3mTCtIfCCJ3Nbn1ZVkaktbEU7sAZr6oEBTmO/FtLSQphX0 5zglNHvdxR2E3lPxkFbu391HFQA0RqhJ2SQoNBUppI7/Mk7dhI3/0yd4N+/naEHK/YdsPTESIsL v41f55Bn8RN2RmXoqTRZR2YiHJgz/M0aRrn56BV6Gq7UxuOYe51Edv/m3Sd4pbdhQ2kofjNGdVo i38IEB8pabRpZsHHRQ6q9qdfcyvlf2RKQRwFoEgnH7N3usfQFKStjp+uBYIQLyPIL8crcO40N+R XPqMgK/JgU9Yy/pqBV1MEeQuZFsxXPxAtqZgufj5n79UF4Wr2DfYDVS/3BYbOKJcjbSVznmGWhd skwMRVYHx4jiySQ== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Add userspace documentation for V4L2 ISP generic parameters and statistics formats. Reviewed-by: Daniel Scally Reviewed-by: Michael Riesch Acked-by: Sakari Ailus Reviewed-by: Laurent Pinchart Tested-by: Lad Prabhakar Signed-off-by: Jacopo Mondi --- .../userspace-api/media/v4l/meta-formats.rst | 1 + Documentation/userspace-api/media/v4l/v4l2-isp.rst | 67 ++++++++++++++++++= ++++ MAINTAINERS | 1 + 3 files changed, 69 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/meta-formats.rst b/Docum= entation/userspace-api/media/v4l/meta-formats.rst index d9868ee88a0717c1acaa4ee477eaed96a6411f73..7b758ea9eb4ac3c4b354bf8e2f3= 19985ed9e2b37 100644 --- a/Documentation/userspace-api/media/v4l/meta-formats.rst +++ b/Documentation/userspace-api/media/v4l/meta-formats.rst @@ -25,3 +25,4 @@ These formats are used for the :ref:`metadata` interface = only. metafmt-vivid metafmt-vsp1-hgo metafmt-vsp1-hgt + v4l2-isp diff --git a/Documentation/userspace-api/media/v4l/v4l2-isp.rst b/Documenta= tion/userspace-api/media/v4l/v4l2-isp.rst new file mode 100644 index 0000000000000000000000000000000000000000..facf6dba1ca7fc34c40e285215c= fcb6dfa4ee332 --- /dev/null +++ b/Documentation/userspace-api/media/v4l/v4l2-isp.rst @@ -0,0 +1,67 @@ +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later + +.. _v4l2-isp: + +************************ +Generic V4L2 ISP formats +************************ + +Generic ISP formats are metadata formats that define a mechanism to pass I= SP +parameters and statistics between userspace and drivers in V4L2 buffers. T= hey +are designed to allow extending them in a backward-compatible way. + +ISP parameters +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The generic ISP configuration parameters format is realized by a defining a +single C structure that contains a header, followed by a binary buffer whe= re +userspace programs a variable number of ISP configuration data block, one = for +each supported ISP feature. + +The :c:type:`v4l2_isp_params_buffer` structure defines the buffer header w= hich +is followed by a binary buffer of ISP configuration data. Userspace shall +correctly populate the buffer header with the generic parameters format ve= rsion +and with the size (in bytes) of the binary data buffer where it will store= the +ISP blocks configuration. + +Each *ISP configuration block* is preceded by an header implemented by the +:c:type:`v4l2_isp_params_block_header` structure, followed by the configur= ation +parameters for that specific block, defined by the ISP driver specific data +types. + +Userspace applications are responsible for correctly populating each block= 's +header fields (type, flags and size) and the block-specific parameters. + +ISP block enabling, disabling and configuration +----------------------------------------------- + +When userspace wants to configure and enable an ISP block it shall fully +populate the block configuration and set the V4L2_ISP_PARAMS_FL_BLOCK_ENAB= LE +bit in the block header's `flags` field. + +When userspace simply wants to disable an ISP block the +V4L2_ISP_PARAMS_FL_BLOCK_DISABLE bit should be set in block header's `flag= s` +field. Drivers accept a configuration parameters block with no additional +data after the header in this case. + +If the configuration of an already active ISP block has to be updated, +userspace shall fully populate the ISP block parameters and omit setting t= he +V4L2_ISP_PARAMS_FL_BLOCK_ENABLE and V4L2_ISP_PARAMS_FL_BLOCK_DISABLE bits = in the +header's `flags` field. + +Setting both the V4L2_ISP_PARAMS_FL_BLOCK_ENABLE and +V4L2_ISP_PARAMS_FL_BLOCK_DISABLE bits in the flags field is not allowed and +returns an error. + +Extension to the parameters format can be implemented by adding new blocks +definition without invalidating the existing ones. + +ISP statistics +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Support for generic statistics format is not yet implemented in Video4Linu= x2. + +V4L2 ISP uAPI data types +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. kernel-doc:: include/uapi/linux/media/v4l2-isp.h diff --git a/MAINTAINERS b/MAINTAINERS index 8989e7e00d86d0c13c4c0b7e5c7eb9481b65861f..b4dd272a0790c317580d0747c80= 43738a1a58d8e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26859,6 +26859,7 @@ V4L2 GENERIC ISP PARAMETERS AND STATISTIC FORMATS M: Jacopo Mondi L: linux-media@vger.kernel.org S: Maintained +F: Documentation/userspace-api/media/v4l/v4l2-isp.rst F: include/uapi/linux/media/v4l2-isp.h =20 VF610 NAND DRIVER --=20 2.51.0 From nobody Thu Dec 18 21:45:19 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F5052F12CD; Sat, 8 Nov 2025 09:36:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594614; cv=none; b=eADZ88+16H+LVg3WOTUpn4tSndsuGteSGOED34QoS1z3MkZTmwQM8G5Otfo83kupyKvePTS66iCUHFwfLI0GFcbfahDj388e2B0YxO/LAyG+BSd/vV9AVwhUleqqTsiXFyqP/H35rLGHnTc2EBNqeuH9uQKS1++E+yi/NaqtwdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594614; c=relaxed/simple; bh=CAJ1TQYaXVJo7jJ0uW0Q1LVCimlF+t4eYQi5HfO3kro=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ad27HL57nEPx5/q3TD1LgMWxtU2QXg+ZZjw8XXwb2pv2lBSb9sy6RH2VyY7RJYDjrkfNh4WgM2Kkflq2rVGjlwpT7C06wD1MtY44hwrfCgWBCVU8pfzn51BOx2hQQ5BjtVFgB5YqGI49cW7xVyhouE3XJP7IdIFBWG9WIXHkd98= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=g2HP7umu; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="g2HP7umu" Received: from [192.168.0.172] (mob-5-90-142-135.net.vodafone.it [5.90.142.135]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DC4CCF0F; Sat, 8 Nov 2025 10:34:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1762594490; bh=CAJ1TQYaXVJo7jJ0uW0Q1LVCimlF+t4eYQi5HfO3kro=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=g2HP7umuLGgQENEcIh+0MaDiek8G7L1iOJvyB6ysfIvZUmuCSDd7K8l06RnZsgwXq kjCc/rXQJN7XQolaqSFhf5C3/fAb9RE2fesS03b5k5lH/Vlk0JsY2Cn9fkCtnHemVZ fgxcTD7W5rAKbiiM9Mp0HIBJP8n2i9ShPEEYUBaE= From: Jacopo Mondi Date: Sat, 08 Nov 2025 10:36:26 +0100 Subject: [PATCH v9 5/8] media: v4l2-core: Introduce v4l2-isp.c Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251108-extensible-parameters-validation-v9-5-6a7e22aa57d0@ideasonboard.com> References: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> In-Reply-To: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Keke Li , Mauro Carvalho Chehab , Heiko Stuebner , Dan Scally , Sakari Ailus , Antoine Bouyer Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jacopo Mondi , Laurent Pinchart , Michael Riesch , Lad Prabhakar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=10967; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=CAJ1TQYaXVJo7jJ0uW0Q1LVCimlF+t4eYQi5HfO3kro=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpDw8mtXGhdk4rDkysA7Zg+qGwmLcVyEo7IvEl4 oMpQbHC+FuJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaQ8PJgAKCRByNAaPFqFW PDIJD/9exqsxrnJfo9gwApZEa59oFoeaQA1mNp8WBaTd1O6eChz2+Yx42Cf530OYEnyQWPPCNpp gfc5SYqG6hUt1ypM3XA505OumNdoTbOotSqPS09JzFcbuZI/eQHUeb/krrrYpErjNz8ykjHlP9Y CIqaPEy3fnMjTe2ugmBSZ//+Gd4cNklMC+gRipYGhdL7fSWhZ9eHr4+Rai4d/0myB+9Wc3jcXXa pCoh8IcBLSprJ19GXRrhg1RBKKvr/y9VkJXz1UIjUZxCa8remfPI+QTOLdZVmoFHm2iKBa3XwVw O4wYU09kw+5hZGC2FVd38aEiBrX2xDPOJUS4lQWYXcLz0C8lKXFG64RoPVQ8GhQPYGKZEbaRxmJ tizHVWQ1lbX1eJPyJ8usQ7SNgoFGXIToz/Fnwzh05kfo/ZZC4CFQuDAX3wz1QqaMJQy0mY/e1rc ZqRc9eQCx1WTnNcqOJwGzkfqNgc/VPYLDwDnw0yApjQ79nYGBvvPjoTghGewe5Jz/75yUGAB+Oa Mwo8MXUBu10cM/Z5iHv6wgbB6Y4ukVags3p/Ze429UP5PYYp/0Gq+e8p2rgsLVs/LR8/OhUXU0J kDIKRQKguy4J2miAcseMvaCEA3oT8eUl/6hKm3ufvC8J538em+YvUCApcPdx8Hz5zbneL7rrF1i 68L9ds2becwvTLQ== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Add to the V4L2 framework helper functions to support drivers when validating a buffer of V4L2 ISP parameters. Driver shall use v4l2_isp_params_validate_buffer_size() to verify the size correctness of the data received from userspace, and after having copied the data to a kernel-only memory location, complete the validation by calling v4l2_isp_params_validate_buffer(). Reviewed-by: Daniel Scally Reviewed-by: Laurent Pinchart Reviewed-by: Michael Riesch Acked-by: Sakari Ailus Tested-by: Lad Prabhakar Signed-off-by: Jacopo Mondi --- MAINTAINERS | 2 + drivers/media/v4l2-core/Kconfig | 4 ++ drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-isp.c | 128 +++++++++++++++++++++++++++++++++= ++++ include/media/v4l2-isp.h | 91 ++++++++++++++++++++++++++ 5 files changed, 226 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index b4dd272a0790c317580d0747c8043738a1a58d8e..f9a86528a153f635a5a3db5ce9c= f6854f699f47f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26860,6 +26860,8 @@ M: Jacopo Mondi L: linux-media@vger.kernel.org S: Maintained F: Documentation/userspace-api/media/v4l/v4l2-isp.rst +F: drivers/media/v4l2-core/v4l2-isp.c +F: include/media/v4l2-isp.h F: include/uapi/linux/media/v4l2-isp.h =20 VF610 NAND DRIVER diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kcon= fig index 331b8e535e5bbf33f22638b2ae8bc764ad5fc407..d50ccac9733cc39a43426ae7e79= 96dd0b5b45186 100644 --- a/drivers/media/v4l2-core/Kconfig +++ b/drivers/media/v4l2-core/Kconfig @@ -82,3 +82,7 @@ config V4L2_CCI_I2C depends on I2C select REGMAP_I2C select V4L2_CCI + +config V4L2_ISP + tristate + depends on VIDEOBUF2_CORE diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Mak= efile index 2177b9d63a8ffc1127c5a70118249a2ff63cd759..329f0eadce994cc1c8580beb435= f68fa7e2a7aeb 100644 --- a/drivers/media/v4l2-core/Makefile +++ b/drivers/media/v4l2-core/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_V4L2_CCI) +=3D v4l2-cci.o obj-$(CONFIG_V4L2_FLASH_LED_CLASS) +=3D v4l2-flash-led-class.o obj-$(CONFIG_V4L2_FWNODE) +=3D v4l2-fwnode.o obj-$(CONFIG_V4L2_H264) +=3D v4l2-h264.o +obj-$(CONFIG_V4L2_ISP) +=3D v4l2-isp.o obj-$(CONFIG_V4L2_JPEG_HELPER) +=3D v4l2-jpeg.o obj-$(CONFIG_V4L2_MEM2MEM_DEV) +=3D v4l2-mem2mem.o obj-$(CONFIG_V4L2_VP9) +=3D v4l2-vp9.o diff --git a/drivers/media/v4l2-core/v4l2-isp.c b/drivers/media/v4l2-core/v= 4l2-isp.c new file mode 100644 index 0000000000000000000000000000000000000000..35f0b701f1729c3c0ccc34b1c89= 189b179e0b684 --- /dev/null +++ b/drivers/media/v4l2-core/v4l2-isp.c @@ -0,0 +1,128 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Video4Linux2 generic ISP parameters and statistics support + * + * Copyright (C) 2025 Ideas On Board Oy + * Author: Jacopo Mondi + */ + +#include + +#include +#include + +#include + +int v4l2_isp_params_validate_buffer_size(struct device *dev, + struct vb2_buffer *vb, + size_t max_size) +{ + size_t header_size =3D offsetof(struct v4l2_isp_params_buffer, data); + size_t payload_size =3D vb2_get_plane_payload(vb, 0); + + /* Payload size can't be greater than the destination buffer size */ + if (payload_size > max_size) { + dev_dbg(dev, "Payload size is too large: %zu\n", payload_size); + return -EINVAL; + } + + /* Payload size can't be smaller than the header size */ + if (payload_size < header_size) { + dev_dbg(dev, "Payload size is too small: %zu\n", payload_size); + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL_GPL(v4l2_isp_params_validate_buffer_size); + +int v4l2_isp_params_validate_buffer(struct device *dev, struct vb2_buffer = *vb, + const struct v4l2_isp_params_buffer *buffer, + const struct v4l2_isp_params_block_info *info, + size_t num_blocks) +{ + size_t header_size =3D offsetof(struct v4l2_isp_params_buffer, data); + size_t payload_size =3D vb2_get_plane_payload(vb, 0); + size_t block_offset =3D 0; + size_t buffer_size; + + /* + * Currently only the first version of the V4L2 ISP parameters format is + * supported. We accept both V0 and V1 to support existing drivers + * compatible with V4L2 ISP that use either 0 or 1 as their "first + * version" identifiers. + */ + if (buffer->version !=3D V4L2_ISP_PARAMS_VERSION_V0 && + buffer->version !=3D V4L2_ISP_PARAMS_VERSION_V1) { + dev_dbg(dev, + "Unsupported V4L2 ISP parameters format version: %u\n", + buffer->version); + return -EINVAL; + } + + /* Validate the size reported in the header */ + buffer_size =3D header_size + buffer->data_size; + if (buffer_size !=3D payload_size) { + dev_dbg(dev, "Data size %zu and payload size %zu are different\n", + buffer_size, payload_size); + return -EINVAL; + } + + /* Walk the list of ISP configuration blocks and validate them. */ + buffer_size =3D buffer->data_size; + while (buffer_size >=3D sizeof(struct v4l2_isp_params_block_header)) { + const struct v4l2_isp_params_block_info *block_info; + const struct v4l2_isp_params_block_header *block; + + block =3D (const struct v4l2_isp_params_block_header *) + (buffer->data + block_offset); + + if (block->type >=3D num_blocks) { + dev_dbg(dev, + "Invalid block type %u at offset %zu\n", + block->type, block_offset); + return -EINVAL; + } + + if (block->size > buffer_size) { + dev_dbg(dev, "Premature end of parameters data\n"); + return -EINVAL; + } + + /* It's invalid to specify both ENABLE and DISABLE. */ + if ((block->flags & (V4L2_ISP_PARAMS_FL_BLOCK_ENABLE | + V4L2_ISP_PARAMS_FL_BLOCK_DISABLE)) =3D=3D + (V4L2_ISP_PARAMS_FL_BLOCK_ENABLE | + V4L2_ISP_PARAMS_FL_BLOCK_DISABLE)) { + dev_dbg(dev, "Invalid block flags %x at offset %zu\n", + block->flags, block_offset); + return -EINVAL; + } + + /* + * Match the block reported size against the info provided + * one, but allow the block to only contain the header in + * case it is going to be disabled. + */ + block_info =3D &info[block->type]; + if (block->size !=3D block_info->size && + (!(block->flags & V4L2_ISP_PARAMS_FL_BLOCK_DISABLE) || + block->size !=3D sizeof(*block))) { + dev_dbg(dev, + "Invalid block size %u (expected %zu) at offset %zu\n", + block->size, block_info->size, block_offset); + return -EINVAL; + } + + block_offset +=3D block->size; + buffer_size -=3D block->size; + } + + if (buffer_size) { + dev_dbg(dev, "Unexpected data after the parameters buffer end\n"); + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL_GPL(v4l2_isp_params_validate_buffer); diff --git a/include/media/v4l2-isp.h b/include/media/v4l2-isp.h new file mode 100644 index 0000000000000000000000000000000000000000..8b4695663699e7f176384739cf5= 4ed7fa2c578f8 --- /dev/null +++ b/include/media/v4l2-isp.h @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Video4Linux2 generic ISP parameters and statistics support + * + * Copyright (C) 2025 Ideas On Board Oy + * Author: Jacopo Mondi + */ + +#ifndef _V4L2_ISP_H_ +#define _V4L2_ISP_H_ + +#include + +struct device; +struct vb2_buffer; + +/** + * v4l2_isp_params_buffer_size - Calculate size of v4l2_isp_params_buffer + * @max_params_size: The total size of the ISP configuration blocks + * + * Users of the v4l2 extensible parameters will have differing sized data = arrays + * depending on their specific parameter buffers. Drivers and userspace wi= ll + * need to be able to calculate the appropriate size of the struct to + * accommodate all ISP configuration blocks provided by the platform. + * This macro provides a convenient tool for the calculation. + */ +#define v4l2_isp_params_buffer_size(max_params_size) \ + (offsetof(struct v4l2_isp_params_buffer, data) + (max_params_size)) + +/** + * v4l2_isp_params_validate_buffer_size - Validate a V4L2 ISP buffer sizes + * @dev: the driver's device pointer + * @vb: the videobuf2 buffer + * @max_size: the maximum allowed buffer size + * + * This function performs validation of the size of a V4L2 ISP parameters = buffer + * before the driver can access the actual data buffer content. + * + * After the sizes validation, drivers should copy the buffer content to a + * kernel-only memory area to prevent userspace from modifying it, + * before completing validation using v4l2_isp_params_validate_buffer(). + * + * The @vb buffer as received from the vb2 .buf_prepare() operation is che= cked + * against @max_size and it's validated to be large enough to accommodate = at + * least one ISP configuration block. + */ +int v4l2_isp_params_validate_buffer_size(struct device *dev, + struct vb2_buffer *vb, + size_t max_size); + +/** + * struct v4l2_isp_params_block_info - V4L2 ISP per-block info + * @size: the block expected size + * + * The v4l2_isp_params_block_info collects information of the ISP configur= ation + * blocks for validation purposes. It currently only contains the expected + * block size. + * + * Drivers shall prepare a list of block info, indexed by block type, one = for + * each supported ISP block and correctly populate them with the expected = block + * size. + */ +struct v4l2_isp_params_block_info { + size_t size; +}; + +/** + * v4l2_isp_params_validate_buffer - Validate a V4L2 ISP parameters buffer + * @dev: the driver's device pointer + * @vb: the videobuf2 buffer + * @buffer: the V4L2 ISP parameters buffer + * @info: the list of per-block validation info + * @num_blocks: the number of blocks + * + * This function completes the validation of a V4L2 ISP parameters buffer, + * verifying each configuration block correctness before the driver can use + * them to program the hardware. + * + * Drivers should use this function after having validated the correctness= of + * the vb2 buffer sizes by using the v4l2_isp_params_validate_buffer_size() + * helper first. Once the buffer size has been validated, drivers should + * perform a copy of the user provided buffer into a kernel-only memory bu= ffer + * to prevent userspace from modifying its content after it has been submi= tted + * to the driver, and then call this function to complete validation. + */ +int v4l2_isp_params_validate_buffer(struct device *dev, struct vb2_buffer = *vb, + const struct v4l2_isp_params_buffer *buffer, + const struct v4l2_isp_params_block_info *info, + size_t num_blocks); + +#endif /* _V4L2_ISP_H_ */ --=20 2.51.0 From nobody Thu Dec 18 21:45:19 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F20DC2F39D6; Sat, 8 Nov 2025 09:36:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594617; cv=none; b=qMpZSNhZn6pL7RqZ2ZxeQ2mbKyoI2FMUtLowk1sCJsPkTktYSIB4v+TCvuC/Aiv1Es2P+5eGfAs498xpvrL2fpdIFqScGTr4K1fSHNpGquSxbnMsSAeZHzFX1ZDVAoWqxvSI7M2l4XpRXxENw5RljK6N+JpjURR+j97RAGX7wjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594617; c=relaxed/simple; bh=hVx/tae0uGmuOaa92bBCvwER55dA7gt64o7jGbjiS44=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uGndwa6ol1Yhu7j9cfqblA/iOCIUtQuAaOhUFWoB9iq/j+S5oRQyAM2QX0tlc/ukVJxjUBymGGU973+Z3hhfkC2gsScZ10BKBkK6iHnSf2gw0n+kOgiPV80ZQ2jNemSDvyS+H2Ms+U//5GgGmoOs+RWhH2EiWdO4cCTdwL93htk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=TFdP0bri; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TFdP0bri" Received: from [192.168.0.172] (mob-5-90-142-135.net.vodafone.it [5.90.142.135]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E670DD9; Sat, 8 Nov 2025 10:34:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1762594492; bh=hVx/tae0uGmuOaa92bBCvwER55dA7gt64o7jGbjiS44=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TFdP0brihrFOJrZSSVZLyNJK7ZXlPFlwbUJ33X9kltxaVIawZrlEaw4cQT+rnshx3 4KmjPqfFh81Q3laAoCDJztfc0pJTuUvnmSyfjODNxgseHNYl7BY4Kpu0A0sRKJV3Rk 0ZnpgCuRgMwLn7lkwtw8BrYeuFI/1V4cPBkKUWcQ= From: Jacopo Mondi Date: Sat, 08 Nov 2025 10:36:27 +0100 Subject: [PATCH v9 6/8] media: rkisp1: Use v4l2-isp for validation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251108-extensible-parameters-validation-v9-6-6a7e22aa57d0@ideasonboard.com> References: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> In-Reply-To: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Keke Li , Mauro Carvalho Chehab , Heiko Stuebner , Dan Scally , Sakari Ailus , Antoine Bouyer Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jacopo Mondi , Lad Prabhakar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=11868; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=hVx/tae0uGmuOaa92bBCvwER55dA7gt64o7jGbjiS44=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpDw8mvWZ98SE805kcEg3u72CcAis2imsKJDY0C OL5kYNOYCCJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaQ8PJgAKCRByNAaPFqFW PIYXD/wMC0GP3LHxppnmFHmzzfnW939UuxJev4bB9YIGwWzDEjZ6yb2cLylX2nspoFPW7INyCsc pTWRYjBgSLB5H+fmpNb3FTI3ba9R/kLVX3ZxIa7k/TWWqzEgD/NopWwdVEbDCL+ruxQmjpGmh8P TH0vr03xb4RTioMyKgxetl678QuiVX0WEKGRaREgmnBnoZLAhl2kg4ko1q1GmujsN0Fv3upm8th hWwYvRVuB0/mhkgo5gEpF6qMuY26KKpVEA06iQOjcWI8b7rpGKOLyh+0NQVGgamkl40caIxPl7Y lMJ7SvvSLtMzdTfarLAq1Oi4VYumnSf/KKG8Dc++ZbzIUrGCZDUOmFSd1ar0qdOuOzh3NTohsKG 3bA1iwyXybL8LwjBty0x24Jy8Z/2Ac1e2ZvFPIdSOMyJGYxM6BKiA+mKG65z0lVjL4h8AX/b+PS +GuSiHPNMTgnMpvyBmidjR4rL20xTvBaZnDeeF/E6zzkO3xoWsDr3DvsdLBmlhPhixKf964PO+k Xnf2iaLyeCAn8qWGp1WD4rYU5V8p1o6ifuBMM2SeezaTR99BTz+4Wgqb7t8eBjw1OObcGTGliHR a28pbxG7Spcf+pLCYxkxRZD3qr7CRACaYxDUKlnk/Pu6CCobx2gqVvMc/M7uXs8Ly/MtpKnksqK 4FAEcJIhZVmE8uw== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Convert rkisp1-params.c to use the helpers defined in v4l2-isp.h to perform validation of a ISP parameters buffer. Reviewed-by: Daniel Scally Acked-by: Sakari Ailus Reviewed-by: Laurent Pinchart Tested-by: Lad Prabhakar Signed-off-by: Jacopo Mondi --- drivers/media/platform/rockchip/rkisp1/Kconfig | 1 + .../media/platform/rockchip/rkisp1/rkisp1-params.c | 150 ++++++-----------= ---- 2 files changed, 44 insertions(+), 107 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/Kconfig b/drivers/media= /platform/rockchip/rkisp1/Kconfig index 731c9acbf6efa33188617204d441fb0ea59adebc..f53eb1f3f3e7003d8e02c9236ae= abb5ae8844f7b 100644 --- a/drivers/media/platform/rockchip/rkisp1/Kconfig +++ b/drivers/media/platform/rockchip/rkisp1/Kconfig @@ -10,6 +10,7 @@ config VIDEO_ROCKCHIP_ISP1 select VIDEOBUF2_VMALLOC select V4L2_FWNODE select GENERIC_PHY_MIPI_DPHY + select V4L2_ISP default n help Enable this to support the Image Signal Processing (ISP) module diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c b/drive= rs/media/platform/rockchip/rkisp1/rkisp1-params.c index f1585f8fa0f478304f74317fd9dd09199c94ec82..2dde0c62c8e6b8f8447e0414950= cec0a511169fd 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c @@ -6,12 +6,14 @@ */ =20 #include +#include #include #include =20 #include #include #include +#include #include #include /* for ISP params */ =20 @@ -2097,122 +2099,132 @@ typedef void (*rkisp1_block_handler)(struct rkisp= 1_params *params, const union rkisp1_ext_params_config *config); =20 static const struct rkisp1_ext_params_handler { - size_t size; rkisp1_block_handler handler; unsigned int group; unsigned int features; } rkisp1_ext_params_handlers[] =3D { [RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS] =3D { - .size =3D sizeof(struct rkisp1_ext_params_bls_config), .handler =3D rkisp1_ext_params_bls, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, .features =3D RKISP1_FEATURE_BLS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC] =3D { - .size =3D sizeof(struct rkisp1_ext_params_dpcc_config), .handler =3D rkisp1_ext_params_dpcc, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG] =3D { - .size =3D sizeof(struct rkisp1_ext_params_sdg_config), .handler =3D rkisp1_ext_params_sdg, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN] =3D { - .size =3D sizeof(struct rkisp1_ext_params_awb_gain_config), .handler =3D rkisp1_ext_params_awbg, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT] =3D { - .size =3D sizeof(struct rkisp1_ext_params_flt_config), .handler =3D rkisp1_ext_params_flt, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM] =3D { - .size =3D sizeof(struct rkisp1_ext_params_bdm_config), .handler =3D rkisp1_ext_params_bdm, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK] =3D { - .size =3D sizeof(struct rkisp1_ext_params_ctk_config), .handler =3D rkisp1_ext_params_ctk, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC] =3D { - .size =3D sizeof(struct rkisp1_ext_params_goc_config), .handler =3D rkisp1_ext_params_goc, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF] =3D { - .size =3D sizeof(struct rkisp1_ext_params_dpf_config), .handler =3D rkisp1_ext_params_dpf, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH] =3D { - .size =3D sizeof(struct rkisp1_ext_params_dpf_strength_config), .handler =3D rkisp1_ext_params_dpfs, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC] =3D { - .size =3D sizeof(struct rkisp1_ext_params_cproc_config), .handler =3D rkisp1_ext_params_cproc, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_IE] =3D { - .size =3D sizeof(struct rkisp1_ext_params_ie_config), .handler =3D rkisp1_ext_params_ie, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC] =3D { - .size =3D sizeof(struct rkisp1_ext_params_lsc_config), .handler =3D rkisp1_ext_params_lsc, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_LSC, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS] =3D { - .size =3D sizeof(struct rkisp1_ext_params_awb_meas_config), .handler =3D rkisp1_ext_params_awbm, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS] =3D { - .size =3D sizeof(struct rkisp1_ext_params_hst_config), .handler =3D rkisp1_ext_params_hstm, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS] =3D { - .size =3D sizeof(struct rkisp1_ext_params_aec_config), .handler =3D rkisp1_ext_params_aecm, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS] =3D { - .size =3D sizeof(struct rkisp1_ext_params_afc_config), .handler =3D rkisp1_ext_params_afcm, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS] =3D { - .size =3D sizeof(struct rkisp1_ext_params_compand_bls_config), .handler =3D rkisp1_ext_params_compand_bls, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, .features =3D RKISP1_FEATURE_COMPAND, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND] =3D { - .size =3D sizeof(struct rkisp1_ext_params_compand_curve_config), .handler =3D rkisp1_ext_params_compand_expand, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, .features =3D RKISP1_FEATURE_COMPAND, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS] =3D { - .size =3D sizeof(struct rkisp1_ext_params_compand_curve_config), .handler =3D rkisp1_ext_params_compand_compress, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, .features =3D RKISP1_FEATURE_COMPAND, }, [RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR] =3D { - .size =3D sizeof(struct rkisp1_ext_params_wdr_config), .handler =3D rkisp1_ext_params_wdr, .group =3D RKISP1_EXT_PARAMS_BLOCK_GROUP_OTHERS, }, }; =20 +#define RKISP1_PARAMS_BLOCK_INFO(block, data) \ + [RKISP1_EXT_PARAMS_BLOCK_TYPE_ ## block] =3D { \ + .size =3D sizeof(struct rkisp1_ext_params_ ## data ## _config), \ + } + +static const struct v4l2_isp_params_block_info rkisp1_ext_params_blocks_in= fo[] =3D { + RKISP1_PARAMS_BLOCK_INFO(BLS, bls), + RKISP1_PARAMS_BLOCK_INFO(DPCC, dpcc), + RKISP1_PARAMS_BLOCK_INFO(SDG, sdg), + RKISP1_PARAMS_BLOCK_INFO(AWB_GAIN, awb_gain), + RKISP1_PARAMS_BLOCK_INFO(FLT, flt), + RKISP1_PARAMS_BLOCK_INFO(BDM, bdm), + RKISP1_PARAMS_BLOCK_INFO(CTK, ctk), + RKISP1_PARAMS_BLOCK_INFO(GOC, goc), + RKISP1_PARAMS_BLOCK_INFO(DPF, dpf), + RKISP1_PARAMS_BLOCK_INFO(DPF_STRENGTH, dpf_strength), + RKISP1_PARAMS_BLOCK_INFO(CPROC, cproc), + RKISP1_PARAMS_BLOCK_INFO(IE, ie), + RKISP1_PARAMS_BLOCK_INFO(LSC, lsc), + RKISP1_PARAMS_BLOCK_INFO(AWB_MEAS, awb_meas), + RKISP1_PARAMS_BLOCK_INFO(HST_MEAS, hst), + RKISP1_PARAMS_BLOCK_INFO(AEC_MEAS, aec), + RKISP1_PARAMS_BLOCK_INFO(AFC_MEAS, afc), + RKISP1_PARAMS_BLOCK_INFO(COMPAND_BLS, compand_bls), + RKISP1_PARAMS_BLOCK_INFO(COMPAND_EXPAND, compand_curve), + RKISP1_PARAMS_BLOCK_INFO(COMPAND_COMPRESS, compand_curve), + RKISP1_PARAMS_BLOCK_INFO(WDR, wdr), +}; + +static_assert(ARRAY_SIZE(rkisp1_ext_params_handlers) =3D=3D + ARRAY_SIZE(rkisp1_ext_params_blocks_info)); + static void rkisp1_ext_params_config(struct rkisp1_params *params, struct rkisp1_ext_params_cfg *cfg, u32 block_group_mask) @@ -2646,31 +2658,16 @@ static int rkisp1_params_prepare_ext_params(struct = rkisp1_params *params, { struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buffer(vb); struct rkisp1_params_buffer *params_buf =3D to_rkisp1_params_buffer(vbuf); - size_t header_size =3D offsetof(struct rkisp1_ext_params_cfg, data); struct rkisp1_ext_params_cfg *cfg =3D params_buf->cfg; size_t payload_size =3D vb2_get_plane_payload(vb, 0); struct rkisp1_ext_params_cfg *usr_cfg =3D vb2_plane_vaddr(&vbuf->vb2_buf, 0); - size_t block_offset =3D 0; - size_t cfg_size; - - /* - * Validate the buffer payload size before copying the parameters. The - * payload has to be smaller than the destination buffer size and larger - * than the header size. - */ - if (payload_size > params->metafmt->buffersize) { - dev_dbg(params->rkisp1->dev, - "Too large buffer payload size %zu\n", payload_size); - return -EINVAL; - } + int ret; =20 - if (payload_size < header_size) { - dev_dbg(params->rkisp1->dev, - "Buffer payload %zu smaller than header size %zu\n", - payload_size, header_size); - return -EINVAL; - } + ret =3D v4l2_isp_params_validate_buffer_size(params->rkisp1->dev, vb, + params->metafmt->buffersize); + if (ret) + return ret; =20 /* * Copy the parameters buffer to the internal scratch buffer to avoid @@ -2678,71 +2675,10 @@ static int rkisp1_params_prepare_ext_params(struct = rkisp1_params *params, */ memcpy(cfg, usr_cfg, payload_size); =20 - /* Only v1 is supported at the moment. */ - if (cfg->version !=3D RKISP1_EXT_PARAM_BUFFER_V1) { - dev_dbg(params->rkisp1->dev, - "Unsupported extensible format version: %u\n", - cfg->version); - return -EINVAL; - } - - /* Validate the size reported in the parameters buffer header. */ - cfg_size =3D header_size + cfg->data_size; - if (cfg_size !=3D payload_size) { - dev_dbg(params->rkisp1->dev, - "Data size %zu different than buffer payload size %zu\n", - cfg_size, payload_size); - return -EINVAL; - } - - /* Walk the list of parameter blocks and validate them. */ - cfg_size =3D cfg->data_size; - while (cfg_size >=3D sizeof(struct rkisp1_ext_params_block_header)) { - const struct rkisp1_ext_params_block_header *block; - const struct rkisp1_ext_params_handler *handler; - - block =3D (const struct rkisp1_ext_params_block_header *) - &cfg->data[block_offset]; - - if (block->type >=3D ARRAY_SIZE(rkisp1_ext_params_handlers)) { - dev_dbg(params->rkisp1->dev, - "Invalid parameters block type\n"); - return -EINVAL; - } - - if (block->size > cfg_size) { - dev_dbg(params->rkisp1->dev, - "Premature end of parameters data\n"); - return -EINVAL; - } - - if ((block->flags & (RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE | - RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE)) =3D=3D - (RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE | - RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE)) { - dev_dbg(params->rkisp1->dev, - "Invalid parameters block flags\n"); - return -EINVAL; - } - - handler =3D &rkisp1_ext_params_handlers[block->type]; - if (block->size !=3D handler->size) { - dev_dbg(params->rkisp1->dev, - "Invalid parameters block size\n"); - return -EINVAL; - } - - block_offset +=3D block->size; - cfg_size -=3D block->size; - } - - if (cfg_size) { - dev_dbg(params->rkisp1->dev, - "Unexpected data after the parameters buffer end\n"); - return -EINVAL; - } - - return 0; + return v4l2_isp_params_validate_buffer(params->rkisp1->dev, vb, + (struct v4l2_isp_params_buffer *)cfg, + rkisp1_ext_params_blocks_info, + ARRAY_SIZE(rkisp1_ext_params_blocks_info)); } =20 static int rkisp1_params_vb2_buf_prepare(struct vb2_buffer *vb) --=20 2.51.0 From nobody Thu Dec 18 21:45:19 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1E622F3C07; Sat, 8 Nov 2025 09:36:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594617; cv=none; b=i27fperk1yhnyOfr5nXY976vTiPL/8h9OPU2b7+ome7RF29POuoIX7TaR5NmtdGexEqcrt7DR4G8qnToiP4XOACR+oMxhn0PBliInAw02+Qfm9G3kCx01d6TPV3hqSqQ5rbmzLMgqHF7U7l71iWaOChwq1cbyNYZTm4AAlt0jPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594617; c=relaxed/simple; bh=NA/pEPq54tjIRQbYfe1AJ4RWRStd67bBpWv66gE41xA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K4MmXjZzOFL+bplpYsL0GYrTVrPulQ0MA/PnwtNraw7b+edX9HORwiPOyXvYXWX1S3oZ0PkR18S94pFQJhRob9a9JCFLvu+tMxRTXebUtElWtZSrKTQxfaUg8kHWOWuCtpodBLsh4+lsgZfLixDQ1NX0PPGHtT3E/G+pEhx4u3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=fXRamP5D; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fXRamP5D" Received: from [192.168.0.172] (mob-5-90-142-135.net.vodafone.it [5.90.142.135]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3E4B2E1F; Sat, 8 Nov 2025 10:34:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1762594493; bh=NA/pEPq54tjIRQbYfe1AJ4RWRStd67bBpWv66gE41xA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fXRamP5DrKDjUoJRuLTjGnluoX8ov0y9hXknwvT2r6l00Ue+cXZv/Dqt+7wGMoA4m mIlep1tx2k4spQ/xrv7ruzescIjn8Flxend3UZryJipbh6UA6Zsnyf/MAIg+RG6BFS cQmZRUDzvskJl13jH2WE6EUyopNdyOis0EGq/4/Y= From: Jacopo Mondi Date: Sat, 08 Nov 2025 10:36:28 +0100 Subject: [PATCH v9 7/8] media: amlogic-c3: Use v4l2-isp for validation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251108-extensible-parameters-validation-v9-7-6a7e22aa57d0@ideasonboard.com> References: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> In-Reply-To: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Keke Li , Mauro Carvalho Chehab , Heiko Stuebner , Dan Scally , Sakari Ailus , Antoine Bouyer Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jacopo Mondi , Laurent Pinchart , Lad Prabhakar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=9260; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=NA/pEPq54tjIRQbYfe1AJ4RWRStd67bBpWv66gE41xA=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpDw8m6Sj0DeJ6yZsXVBr2zkc1fvxpW7la+hx4k pkRIVgiE12JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaQ8PJgAKCRByNAaPFqFW PMaEEACnuxIyxW0A0SZ8JabQMBl+0QZzapO1+DsOUA9SCTmJSGP/l1UOitE4OiN9dJUnBdaigW8 bt5NYsbIDpKtmV43eW8BEtzuX4sL6d6qgOvRfjfxWpA7zMvfWVikAdfobPzhAZo9UMT/K2oBzSX abTWaGSvhuEKRwYWKIAnCMi1aS3DrvIqgEdScD5cCwwIPNcW5W556jdBDMzrlsbFr0lnAmmsKyg 1ZFXjeqyqeDy7MPzTrblxC9vk8/3s0x+rjjGVQjo02WpSgtBSmYdaVCMaJsJnOVM9HKvAHqq5w9 RiH551ldHksSk9MfQiZTc8O4w1184m+w207nAFPHhsWUdLH+9tCVJXd5HollG+ERVj4y8thLdUm g6AmrZqOX6fkuMzUdzjGGvMsnw6BO4mLkgX5/fxd+jAcNqZSyUg57pJeYId6kFis/UOYFRwpQR8 ZJ0gRyhQ69UnycFtgxh2H8LsvH2VQEdRqP7AEAh3yYxTMBAP1WOH9ly6jgtNdIgy2kX9kf05gkv TJJ6XR/g/nGK8aUYlKbK43WMb8AxWRSSdd3G/iCsD51CDNGuo3IuyA9TKxKwiWA0FIZnvWdOfw9 PULOcPtB82rJcqEnjwypzNi11jp+8GTwMzsU6yPM+bLWtFnmBNFs+V/4gbCSzwY0f818UPd+3t3 l7O6Ioo4niXJhlQ== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Convert c3-isp-params.c to use the helpers defined in v4l2-isp.h to perform validation of a ISP parameters buffer. Reviewed-by: Keke Li Reviewed-by: Daniel Scally Acked-by: Sakari Ailus Reviewed-by: Laurent Pinchart Tested-by: Lad Prabhakar Signed-off-by: Jacopo Mondi --- drivers/media/platform/amlogic/c3/isp/Kconfig | 1 + .../media/platform/amlogic/c3/isp/c3-isp-params.c | 165 ++++++-----------= ---- 2 files changed, 44 insertions(+), 122 deletions(-) diff --git a/drivers/media/platform/amlogic/c3/isp/Kconfig b/drivers/media/= platform/amlogic/c3/isp/Kconfig index 02c62a50a5e88eac665e27abf163e5d654faed3f..809208cd7e3aa7ca0821cb07366= ec73a47edb278 100644 --- a/drivers/media/platform/amlogic/c3/isp/Kconfig +++ b/drivers/media/platform/amlogic/c3/isp/Kconfig @@ -10,6 +10,7 @@ config VIDEO_C3_ISP select VIDEO_V4L2_SUBDEV_API select VIDEOBUF2_DMA_CONTIG select VIDEOBUF2_VMALLOC + select V4L2_ISP help Video4Linux2 driver for Amlogic C3 ISP pipeline. The C3 ISP is used for processing raw images and diff --git a/drivers/media/platform/amlogic/c3/isp/c3-isp-params.c b/driver= s/media/platform/amlogic/c3/isp/c3-isp-params.c index c80667dd766210d2b2e1ee60c8254a5814b9d81b..c2339d6dc1074818d333e0221b1= d6a407a41acd7 100644 --- a/drivers/media/platform/amlogic/c3/isp/c3-isp-params.c +++ b/drivers/media/platform/amlogic/c3/isp/c3-isp-params.c @@ -3,11 +3,13 @@ * Copyright (C) 2024 Amlogic, Inc. All rights reserved */ =20 +#include #include #include #include =20 #include +#include #include #include =20 @@ -51,11 +53,6 @@ union c3_isp_params_block { typedef void (*c3_isp_block_handler)(struct c3_isp_device *isp, const union c3_isp_params_block *block); =20 -struct c3_isp_params_handler { - size_t size; - c3_isp_block_handler handler; -}; - #define to_c3_isp_params_buffer(vbuf) \ container_of(vbuf, struct c3_isp_params_buffer, vb) =20 @@ -523,41 +520,36 @@ static void c3_isp_params_cfg_blc(struct c3_isp_devic= e *isp, ISP_TOP_BEO_CTRL_BLC_EN); } =20 -static const struct c3_isp_params_handler c3_isp_params_handlers[] =3D { - [C3_ISP_PARAMS_BLOCK_AWB_GAINS] =3D { - .size =3D sizeof(struct c3_isp_params_awb_gains), - .handler =3D c3_isp_params_cfg_awb_gains, - }, - [C3_ISP_PARAMS_BLOCK_AWB_CONFIG] =3D { - .size =3D sizeof(struct c3_isp_params_awb_config), - .handler =3D c3_isp_params_cfg_awb_config, - }, - [C3_ISP_PARAMS_BLOCK_AE_CONFIG] =3D { - .size =3D sizeof(struct c3_isp_params_ae_config), - .handler =3D c3_isp_params_cfg_ae_config, - }, - [C3_ISP_PARAMS_BLOCK_AF_CONFIG] =3D { - .size =3D sizeof(struct c3_isp_params_af_config), - .handler =3D c3_isp_params_cfg_af_config, - }, - [C3_ISP_PARAMS_BLOCK_PST_GAMMA] =3D { - .size =3D sizeof(struct c3_isp_params_pst_gamma), - .handler =3D c3_isp_params_cfg_pst_gamma, - }, - [C3_ISP_PARAMS_BLOCK_CCM] =3D { - .size =3D sizeof(struct c3_isp_params_ccm), - .handler =3D c3_isp_params_cfg_ccm, - }, - [C3_ISP_PARAMS_BLOCK_CSC] =3D { - .size =3D sizeof(struct c3_isp_params_csc), - .handler =3D c3_isp_params_cfg_csc, - }, - [C3_ISP_PARAMS_BLOCK_BLC] =3D { - .size =3D sizeof(struct c3_isp_params_blc), - .handler =3D c3_isp_params_cfg_blc, - }, +static const c3_isp_block_handler c3_isp_params_handlers[] =3D { + [C3_ISP_PARAMS_BLOCK_AWB_GAINS] =3D c3_isp_params_cfg_awb_gains, + [C3_ISP_PARAMS_BLOCK_AWB_CONFIG] =3D c3_isp_params_cfg_awb_config, + [C3_ISP_PARAMS_BLOCK_AE_CONFIG] =3D c3_isp_params_cfg_ae_config, + [C3_ISP_PARAMS_BLOCK_AF_CONFIG] =3D c3_isp_params_cfg_af_config, + [C3_ISP_PARAMS_BLOCK_PST_GAMMA] =3D c3_isp_params_cfg_pst_gamma, + [C3_ISP_PARAMS_BLOCK_CCM] =3D c3_isp_params_cfg_ccm, + [C3_ISP_PARAMS_BLOCK_CSC] =3D c3_isp_params_cfg_csc, + [C3_ISP_PARAMS_BLOCK_BLC] =3D c3_isp_params_cfg_blc, +}; + +#define C3_ISP_PARAMS_BLOCK_INFO(block, data) \ + [C3_ISP_PARAMS_BLOCK_ ## block] =3D { \ + .size =3D sizeof(struct c3_isp_params_ ## data), \ + } + +static const struct v4l2_isp_params_block_info c3_isp_params_blocks_info[]= =3D { + C3_ISP_PARAMS_BLOCK_INFO(AWB_GAINS, awb_gains), + C3_ISP_PARAMS_BLOCK_INFO(AWB_CONFIG, awb_config), + C3_ISP_PARAMS_BLOCK_INFO(AE_CONFIG, ae_config), + C3_ISP_PARAMS_BLOCK_INFO(AF_CONFIG, af_config), + C3_ISP_PARAMS_BLOCK_INFO(PST_GAMMA, pst_gamma), + C3_ISP_PARAMS_BLOCK_INFO(CCM, ccm), + C3_ISP_PARAMS_BLOCK_INFO(CSC, csc), + C3_ISP_PARAMS_BLOCK_INFO(BLC, blc), }; =20 +static_assert(ARRAY_SIZE(c3_isp_params_handlers) =3D=3D + ARRAY_SIZE(c3_isp_params_blocks_info)); + static void c3_isp_params_cfg_blocks(struct c3_isp_params *params) { struct c3_isp_params_cfg *config =3D params->buff->cfg; @@ -568,14 +560,14 @@ static void c3_isp_params_cfg_blocks(struct c3_isp_pa= rams *params) =20 /* Walk the list of parameter blocks and process them */ while (block_offset < config->data_size) { - const struct c3_isp_params_handler *block_handler; const union c3_isp_params_block *block; + c3_isp_block_handler block_handler; =20 block =3D (const union c3_isp_params_block *) &config->data[block_offset]; =20 - block_handler =3D &c3_isp_params_handlers[block->header.type]; - block_handler->handler(params->isp, block); + block_handler =3D c3_isp_params_handlers[block->header.type]; + block_handler(params->isp, block); =20 block_offset +=3D block->header.size; } @@ -771,26 +763,15 @@ static int c3_isp_params_vb2_buf_prepare(struct vb2_b= uffer *vb) struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buffer(vb); struct c3_isp_params_buffer *buf =3D to_c3_isp_params_buffer(vbuf); struct c3_isp_params *params =3D vb2_get_drv_priv(vb->vb2_queue); - struct c3_isp_params_cfg *cfg =3D buf->cfg; struct c3_isp_params_cfg *usr_cfg =3D vb2_plane_vaddr(vb, 0); size_t payload_size =3D vb2_get_plane_payload(vb, 0); - size_t header_size =3D offsetof(struct c3_isp_params_cfg, data); - size_t block_offset =3D 0; - size_t cfg_size; - - /* Payload size can't be greater than the destination buffer size */ - if (payload_size > params->vfmt.fmt.meta.buffersize) { - dev_dbg(params->isp->dev, - "Payload size is too large: %zu\n", payload_size); - return -EINVAL; - } + struct c3_isp_params_cfg *cfg =3D buf->cfg; + int ret; =20 - /* Payload size can't be smaller than the header size */ - if (payload_size < header_size) { - dev_dbg(params->isp->dev, - "Payload size is too small: %zu\n", payload_size); - return -EINVAL; - } + ret =3D v4l2_isp_params_validate_buffer_size(params->isp->dev, vb, + params->vfmt.fmt.meta.buffersize); + if (ret) + return ret; =20 /* * Use the internal scratch buffer to avoid userspace modifying @@ -798,70 +779,10 @@ static int c3_isp_params_vb2_buf_prepare(struct vb2_b= uffer *vb) */ memcpy(cfg, usr_cfg, payload_size); =20 - /* Only v0 is supported at the moment */ - if (cfg->version !=3D C3_ISP_PARAMS_BUFFER_V0) { - dev_dbg(params->isp->dev, - "Invalid params buffer version: %u\n", cfg->version); - return -EINVAL; - } - - /* Validate the size reported in the parameter buffer header */ - cfg_size =3D header_size + cfg->data_size; - if (cfg_size !=3D payload_size) { - dev_dbg(params->isp->dev, - "Data size %zu and payload size %zu are different\n", - cfg_size, payload_size); - return -EINVAL; - } - - /* Walk the list of parameter blocks and validate them */ - cfg_size =3D cfg->data_size; - while (cfg_size >=3D sizeof(struct c3_isp_params_block_header)) { - const struct c3_isp_params_block_header *block; - const struct c3_isp_params_handler *handler; - - block =3D (struct c3_isp_params_block_header *) - &cfg->data[block_offset]; - - if (block->type >=3D ARRAY_SIZE(c3_isp_params_handlers)) { - dev_dbg(params->isp->dev, - "Invalid params block type\n"); - return -EINVAL; - } - - if (block->size > cfg_size) { - dev_dbg(params->isp->dev, - "Block size is greater than cfg size\n"); - return -EINVAL; - } - - if ((block->flags & (C3_ISP_PARAMS_BLOCK_FL_ENABLE | - C3_ISP_PARAMS_BLOCK_FL_DISABLE)) =3D=3D - (C3_ISP_PARAMS_BLOCK_FL_ENABLE | - C3_ISP_PARAMS_BLOCK_FL_DISABLE)) { - dev_dbg(params->isp->dev, - "Invalid parameters block flags\n"); - return -EINVAL; - } - - handler =3D &c3_isp_params_handlers[block->type]; - if (block->size !=3D handler->size) { - dev_dbg(params->isp->dev, - "Invalid params block size\n"); - return -EINVAL; - } - - block_offset +=3D block->size; - cfg_size -=3D block->size; - } - - if (cfg_size) { - dev_dbg(params->isp->dev, - "Unexpected data after the params buffer end\n"); - return -EINVAL; - } - - return 0; + return v4l2_isp_params_validate_buffer(params->isp->dev, vb, + (struct v4l2_isp_params_buffer *)cfg, + c3_isp_params_blocks_info, + ARRAY_SIZE(c3_isp_params_blocks_info)); } =20 static int c3_isp_params_vb2_buf_init(struct vb2_buffer *vb) --=20 2.51.0 From nobody Thu Dec 18 21:45:19 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4F3F2F5A16; Sat, 8 Nov 2025 09:36:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594620; cv=none; b=J6t3XqA5xqIUwE/Pm+AhLDNz1hpjrjdizteeh6hbfpmCEtS3EptNhzSBjlxcuovJMO3huJ/zSZ/bwhxtVJXaif46u1XXw4VUVR9XwcSC7SEoCH62nMQqhYV8/0oHG6kK/avw+saLu04ZzeZ45JlUXXN3Wn8+8L/mBcRt0c4OY4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762594620; c=relaxed/simple; bh=unblC2giKYD3uiatEYi0ZweERga9XTWzkHw2hg2KQNc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K/fQfoBgNoHQCF4/idhD7t2FKIdksHf2+9yiRUIJft7VQReZPLRNcmO7hvuD6+XTL9v2eiu3T4AClPIO7Lql23j8O/gefCz22xAezo0NcvHrhDjtXipXOtm8yCpilZJdkyVv4Ob6rMNhhmsuDjcy7ATos1Y5Wlj4H8ERpClT/4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=X64BHdQ8; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="X64BHdQ8" Received: from [192.168.0.172] (mob-5-90-142-135.net.vodafone.it [5.90.142.135]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 70FE7F89; Sat, 8 Nov 2025 10:34:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1762594494; bh=unblC2giKYD3uiatEYi0ZweERga9XTWzkHw2hg2KQNc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=X64BHdQ88uTtFzdNQg26B6iI1LJ2SKGnhiLqrUiBLytUJvWMG50bpFqcF03qkHq/h c8BNSmIOGGvrkKF9gmZShfIquaHGRBQriAl1ly3T/W7DJeH4Fb50k1nF5NjIf4RRLr yi50HfJqaZuq2aRx2Njg9FjIwARqgklIiGp6MHKA= From: Jacopo Mondi Date: Sat, 08 Nov 2025 10:36:29 +0100 Subject: [PATCH v9 8/8] media: Documentation: kapi: Add v4l2 generic ISP support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251108-extensible-parameters-validation-v9-8-6a7e22aa57d0@ideasonboard.com> References: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> In-Reply-To: <20251108-extensible-parameters-validation-v9-0-6a7e22aa57d0@ideasonboard.com> To: Dafna Hirschfeld , Laurent Pinchart , Keke Li , Mauro Carvalho Chehab , Heiko Stuebner , Dan Scally , Sakari Ailus , Antoine Bouyer Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Jacopo Mondi , Michael Riesch , Laurent Pinchart , Lad Prabhakar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4236; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=unblC2giKYD3uiatEYi0ZweERga9XTWzkHw2hg2KQNc=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpDw8mugHbUy0HBAmf2IJaIWqdb45XHTSwvOHZz fepfGtFCNKJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaQ8PJgAKCRByNAaPFqFW PIYJD/4tgmgxZ2K/fAYcBmL31WCcEuC6OcXRWYEHzJKigLlwX9n4NUsq1ghWyo9NpYbRHKkt3cb krkukRHzjenZuhRB7YnF4ctA6WPxz13ctcyQ9xxt5A1LaI4vcsUERA7h+iNOR7z460rEXnqnnse iIP3zFHdvthzmLdmxak/XB0So9BRUFf1scrDbNmPbLn0FG+CN7KdR8ZJDv4yUmqDrOoRgrtwHa1 7s8TnBI10HbPXaI1/jdtms0uCmZUJWMc6Qs05Wx1YNjHDA2nZDHGX2nmi9CkCloraTSmD6QscXd az4RtNytADzN/gzG4/KaDRmDpN8+G415Vnpbyguz5huReu2ejz8aIP2QpHmV07DdyVToTKe5MiB HuPZ+pH8GSjq6Gkfx5GridMEfu9TGBJl/zsnE2y+TYBCFxmTjaoTL/erH9yUe6CmcQCx9Em8hHT Q2KAkgc1Znpk4cWyx2zCR5pNguzm7M6hRaXSYxZ483/L1SSJRDh/LA4xB8JHXTTbUykHl70d+Zb xkF2MNBSUHtrydAxRAH+HWXDtZk2tiHgIeHGmGSXElx78wFD0rXm1mOjMO3semHFLDwUxXUd4VH QypJe+I2cG8hn/enif50rVhru0ox2Vz/68HyKkinfKdWzHDlzfio4hbD+K23rdTSQvT7wiZ2E3i MUQiS8gCqaJH8og== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Add to the driver-api documentation the v4l2-isp.h types and helpers documentation. Reviewed-by: Daniel Scally Reviewed-by: Michael Riesch Acked-by: Sakari Ailus Reviewed-by: Laurent Pinchart Tested-by: Lad Prabhakar Signed-off-by: Jacopo Mondi --- Documentation/driver-api/media/v4l2-core.rst | 1 + Documentation/driver-api/media/v4l2-isp.rst | 49 ++++++++++++++++++++++++= ++++ MAINTAINERS | 1 + 3 files changed, 51 insertions(+) diff --git a/Documentation/driver-api/media/v4l2-core.rst b/Documentation/d= river-api/media/v4l2-core.rst index ad987c34ad2a8460bb95e97adc4d850d624e0b81..a5f5102c64cca57b57b54ab9588= 2b26286fb27de 100644 --- a/Documentation/driver-api/media/v4l2-core.rst +++ b/Documentation/driver-api/media/v4l2-core.rst @@ -27,3 +27,4 @@ Video4Linux devices v4l2-common v4l2-tveeprom v4l2-jpeg + v4l2-isp diff --git a/Documentation/driver-api/media/v4l2-isp.rst b/Documentation/dr= iver-api/media/v4l2-isp.rst new file mode 100644 index 0000000000000000000000000000000000000000..618ae614ff79424a9edb2350964= 4e89d57071b2a --- /dev/null +++ b/Documentation/driver-api/media/v4l2-isp.rst @@ -0,0 +1,49 @@ +.. SPDX-License-Identifier: GPL-2.0 + +V4L2 generic ISP parameters and statistics support +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Design rationale +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +ISP configuration parameters and statistics are processed and collected by +drivers and exchanged with userspace through data types that usually +reflect the ISP peripheral registers layout. + +Each ISP driver defines its own metadata output format for parameters and +a metadata capture format for statistics. The buffer layout is realized by= a +set of C structures that reflects the registers layout. The number and typ= es +of C structures is fixed by the format definition and becomes part of the = Linux +kernel uAPI/uABI interface. + +Because of the hard requirement of backward compatibility when extending t= he +user API/ABI interface, modifying an ISP driver capture or output metadata +format after it has been accepted by mainline is very hard if not impossib= le. + +It generally happens, in fact, that after the first accepted revision of a= n ISP +driver the buffers layout need to be modified, either to support new hardw= are +blocks, to fix bugs or to support different revisions of the hardware. + +Each of these situations would require defining a new metadata format, mak= ing it +really hard to maintain and extend drivers and requiring userspace to use +the correct format depending on the kernel revision in use. + +V4L2 ISP configuration parameters +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D + +For these reasons, Video4Linux2 defines generic types for ISP configuration +parameters and statistics. Drivers are still expected to define their own +formats for their metadata output and capture nodes, but the buffers layou= t can +be defined using the extensible and versioned types defined by +include/uapi/linux/media/v4l2-isp.h. + +Drivers are expected to provide the definitions of their supported ISP blo= cks +and the expected maximum size of a buffer. + +For driver developers a set of helper functions to assist them with valida= tion +of the buffer received from userspace is available in +drivers/media/v4l2-core/v4l2-isp.c + +V4L2 ISP support driver documentation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +.. kernel-doc:: include/media/v4l2-isp.h diff --git a/MAINTAINERS b/MAINTAINERS index f9a86528a153f635a5a3db5ce9cf6854f699f47f..931b0fc72279a5ce2830d1ce5d2= 845ed1a2ae633 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26859,6 +26859,7 @@ V4L2 GENERIC ISP PARAMETERS AND STATISTIC FORMATS M: Jacopo Mondi L: linux-media@vger.kernel.org S: Maintained +F: Documentation/driver-api/media/v4l2-isp.rst F: Documentation/userspace-api/media/v4l/v4l2-isp.rst F: drivers/media/v4l2-core/v4l2-isp.c F: include/media/v4l2-isp.h --=20 2.51.0