From nobody Sat Feb 7 17:48:51 2026 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 C87E22EB86C; Mon, 20 Oct 2025 08:25:01 +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=1760948703; cv=none; b=Vwki2fe47rHsNNRh+s484qxVKDRuQzRf61W2niN7FP/kAzoC9fc5y0av/e+PbV5CmJ52Y8AGppvd9h+0qlXt/mIEfc8WoV8AotCK8gSGTOyvY1iluF0arnsHkXbQuzihzUU+A2y5BwLAJbZu5ZgBGwU7T2SGtAcp23sAh8caYeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760948703; c=relaxed/simple; bh=Hf+mZVh/21OUTmvHUpHmYMXcMyGNzYqP900JsER1oH0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DoNxuHZ3A6QXMUezqAUYSp7aFqiiRRktEU02i9cG3ljsWVKXHf4U8r2BD3jPXwhMO7LixWObkezTXvNpj6sj+wiIH6gslmfKEKuiG3DyoDjdqrQFzUo6AcyFGACQOZvZB8CVnwNJbSVrC7pFv77JurBBM3BIavcDwyCxZE3rEBI= 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=ojklEwlh; 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="ojklEwlh" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8669F1116; Mon, 20 Oct 2025 10:23:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760948596; bh=Hf+mZVh/21OUTmvHUpHmYMXcMyGNzYqP900JsER1oH0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ojklEwlhYOqITshz00TVK0juS1OgjQHxBPpcMCZktghSARYMLdVpArGGU0zyguug3 yNCr3xk9LXIUsldkmT0CqsjLQe9cI5AsbuY/vyc6yE8+2trImmRQ2kMefwcM/Rd04y GxPSGhSYftIG0VhWMcl0aMzcwNiE3oOvbKPnToGc= From: Jacopo Mondi Date: Mon, 20 Oct 2025 10:24:47 +0200 Subject: [PATCH v8 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: <20251020-extensible-parameters-validation-v8-1-afba4ba7b42d@ideasonboard.com> References: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@ideasonboard.com> In-Reply-To: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6398; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=Hf+mZVh/21OUTmvHUpHmYMXcMyGNzYqP900JsER1oH0=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo9fHX8D+twJn48EIwve+Jbu+M5/6sKEm0nl4uE EuR8+S+Z3CJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaPXx1wAKCRByNAaPFqFW PDlXD/9QXQKgF8/QaKK3apST+wAmtomhqqny2ZnSWi192RvOt8Fly10F9RnCYce0fXcRJPEr2EJ Vki6yE4u/2Cn3OM2J2R22/r1f8zjj2LcDAE5NoJo2QkOc9viNLtJwgj8tscEF01WprShMJ1yOqr f9sosL6CqRvb5uErFFdWqTcZZECSzbkR0jy59/UG1i32dyTamvBJHb7Md0aYrIuRNT8BQP6J+FP pNTcHyzHHUmeel9XwiyJ+gkbCyEJI4GEYPTLA/E+UmtV3TnjgsuXsUnp5g02teWy+MQqQHFb5Ji KWB5wzRJN+bnVV/XYmRbXCtiAHwVOHRfNUrI/VTm2Qz7Qtmko5QfB17xjsIrULIgCEBasiymf0E Ayxv3TtMm7oe+BCzUJWtYbt9E0zEZjh/cJirncmmgLUBeOHzzTK7rxLaQ7yb7eed8IaDX0oGVVw 3PjRGY/BcMyOIedf4ArP6s7dw7ZzPj942DJHYKSsGNTlYrmjiReIY7w/epeaeeHmAc7LQV2qUwr ZdzUqUOtmRFTV092sxqWR0AJ160Z+z1xvnA4YoEZzDicftKq1D1ewgRl/DQNsSUZMBLjBhXBJdt ObPAkADBZVGr5yJd1IhgIa3Y7nIN9yRsf+Nq3UitZbOhqp/HCjX5hnzWN5CyMckWGXTJE8xKb0S e6gvfpZUZp4ZJdQ== 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 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 f7351fced572eff0a18038095ec1724047890b55..d925745077f21e5a1388a30217a= 24beeb4fff3b5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26852,6 +26852,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 Sat Feb 7 17:48:51 2026 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 751892EC09C; Mon, 20 Oct 2025 08:25:04 +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=1760948708; cv=none; b=XYt73KM7GFNCgp/1yyUQXivTvL0tc9MO4WOLZBxV08roT53lADiyNXfdLoGF8YsP3I3nZcrNyJ7XE54P9r4igs6lKdSS9my4IAxAdYt6LGYzXErJj4BWNZQRYLNdZ6sLy7yFtQqL9PBlhJ8cSOmNOG07SikbrBXmVzJJdHJrLdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760948708; c=relaxed/simple; bh=Qt/KIkLEpIuxH9gr4qxLMxJDjtudieBA/D3aSJugI8A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jYxjJsDBfWzE00evcgNb3sIKnumw5Gjjl6/IQfiLFw2CeG2Pmw1Qj8WE8bicgrnhpo/Ycey39o41bFWYn+TS6+MguTDcaOGluFhHgUKXiHg27kvtvFK8YR7Z5TQQ8HVZ4iPvxi4BP0z9/uZAhCnCkoMvJ/Jeb9K3qly35Rup1gg= 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=kn3An67x; 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="kn3An67x" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 772DB192C; Mon, 20 Oct 2025 10:23:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760948597; bh=Qt/KIkLEpIuxH9gr4qxLMxJDjtudieBA/D3aSJugI8A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kn3An67xswfMFyyc4ymVeOWicxGfcuAWcC0C6ge4DNE6SCwZEy8PR7lreZfrwhe9v 4vBO2EAbxuj2iLJE9e5Sutzt4hWfS4HB3SKUkE0GPqEJyExNYFZ6c7Qg5xvcIs/UoQ SnOM1uND3Gw5/JNzjYniU+zBBPz5SXf2YuxZza8M= From: Jacopo Mondi Date: Mon, 20 Oct 2025 10:24:48 +0200 Subject: [PATCH v8 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: <20251020-extensible-parameters-validation-v8-2-afba4ba7b42d@ideasonboard.com> References: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@ideasonboard.com> In-Reply-To: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8137; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=Qt/KIkLEpIuxH9gr4qxLMxJDjtudieBA/D3aSJugI8A=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo9fHXj+jli8/zK6f1SHWPEa37NGakaNtUk6/3J dMCw0eKR8CJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaPXx1wAKCRByNAaPFqFW PED4EACt7pj5RVFsmqv0JqbS9mQc3jWjweU66KprpCta8J++9G+DmtoRz695mOL0yrGoxSGscVR uyyi3qrBHf79sueUikixZQeb1z8kpZ2AHZUgALYyV/YMVVh9FlgNo559PmzuAFc79MAee6vzC+K DeVaMmwl36ZvJazEN4KyupY7/ILRdPX0bD7f8gu28pSDFaUNY+VfRqzSlwwY6GxDyu/4oabPECu vT/R7ho/nWSQhM81kEMUxDrCeSPVSHpUL9NqRD6S0PddV4EzngpN+F/T+Mkk+A4T3dLZv0lDaAf pLYr0BTZvQwFJex5JjT4tInox//qaARQtkeT5XJOo9NylvIwI4OGRLt0N/kpyNUNXz9QjrgnQlM aNoLEV7R0LsOZh/UCRztcqo6jBrS6BeLE6qAQCxT1B50N1456wBHQ1DexDV03Eiz3iGAKC/+eY2 zZj0J4DEIlMYBq6XMZHnv01inFxTNWysQy4GH51fUEqv3iDSlZtcMa8Z6F47ZJsOYHyz2vgLrf/ y76M0PeVv4CTAO38t38kF2/da7e9JarYddjU0YIIg+EgySya5GDyU5WlF4LF+N0EGeVVzeqTpos kGguZQlczYuR2ONgvLUbYgEJHL96M3IllVL9cesDS61mQdSry3cz/C/V0XZwAhnS5vt6BGh3HvV HgapCHZWHRcfoGg== 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 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 Sat Feb 7 17:48:51 2026 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 752612EC09D; Mon, 20 Oct 2025 08:25:05 +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=1760948708; cv=none; b=X/Lgs1+8c1BbgIn4oLludPNy+VGj5FkajBaHycTRZY1D3ZtyyOmDn7a3F6Kdwiq3fEVhL+1EhFeeIOrKCaGGc5HdlHB3i7jFAglms3Vi3QfXoVPKasma9Oh9pvcpmIxi6gNRcbGxyhv1DGLniFHDvKuY0i9y47X4vX5Ox4F1HQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760948708; c=relaxed/simple; bh=9ds5WhlrzJQppmDtccCFQ4pALhxTK+AT+VJO5bNqkWI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=elUJxYnWCjLaBcuTuuH0/3HV6TkAVUn1bAkPde1+PMcAwxMUKsYPyNY6QMnd+iPEt7p7HtcqzU9E5csZd/8yxVKeWOtAJ8ZMoQh8J+LA8DwnqWI3bnbnVQiggGeMK+JQ2ljFwJJtylFMcSPEyXqWieD2sLj9N7Uj39gKV2/ulII= 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=kGpkf5V4; 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="kGpkf5V4" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 693DB19B5; Mon, 20 Oct 2025 10:23:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760948598; bh=9ds5WhlrzJQppmDtccCFQ4pALhxTK+AT+VJO5bNqkWI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kGpkf5V4o+RlBNItkDaV8kqRO8a10Jn0gPR2qMV5+D3OoAUoFEjUlJyu6VHlpqCaw 8bYGXCa+Qp3ot43rV5mhoJg8sYJYC5LWIufZVy9JYGOleS4T4glkxU5zjJByBsQt9X bvy9y3TVWDUnue5b2hB1gAKRQk8BSljHxVdeeEBQ= From: Jacopo Mondi Date: Mon, 20 Oct 2025 10:24:49 +0200 Subject: [PATCH v8 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: <20251020-extensible-parameters-validation-v8-3-afba4ba7b42d@ideasonboard.com> References: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@ideasonboard.com> In-Reply-To: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6875; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=9ds5WhlrzJQppmDtccCFQ4pALhxTK+AT+VJO5bNqkWI=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo9fHXPoZnOtzu3U/Yqdh1baHVBlN9Ze5GG0PKh XijvkqEDVCJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaPXx1wAKCRByNAaPFqFW PChbEACdbzH3Sd/VmVLQgrB0ZJ6xmAUnfsdXZRz4rG6nXeYKMeBa1z5G22X2dhZ0Whf9XKqZEat yHcBrIwrl3fC+WftiYH/sUSWuPm9nv0KUn6dGtU/yPfPmmEoDJPaggnhajTKeaTKbX0heGbYKpg mC5VYtLuXxKnbrMtYBiGErvx646mUchUp4A0smHXmi2yp8T4hFwNjVlCEoBFgaXnwBAmD7SPFeW 8cEB57KIGcgiuMCX6ZppXhLcjymbms396Cq8kOGnbRMLHYD0WSLZIo+MqsGmbuQB/LJa+gGCq5X 43B3U4PF3ozQHH/heDvAPJ1QoTyGqU5zr45zAEzuUnLBLFovm5GkMW0kZmhdefmXINL1plZxfq2 kfABWehk270lPNCdNNwq6Nmmw+ENqT5nvboXHBAIW4yliFrx/SKGxOQuzRppDSpJFW7iLYtswEH mkjQ3zpZwpgnxgtsBlyvPN4EDM7ql8rIhlm70jYzk+DiDNVRO0WiaBmdp5zIDIlj3qfPCjZbppP /LP9QWdAbGh901yx4iW4h1VmNno5gGATBw8P9NZvFYZUd88DVr+MjWTgV22QYr0Pj6URMMguows qJ0GtnZYy2hnU0ldtKjGx9/UjZbwiYcNTxlXqHWcrJ1wKnyuwMOGWAjDx78zvOJ9Mq+eMrfAlAR SRrxOHDkHqwJ1eQ== 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 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 Sat Feb 7 17:48:51 2026 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 D36342ECD36; Mon, 20 Oct 2025 08:25:09 +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=1760948711; cv=none; b=Wt7PP5n5p/SuV7PPxVRu29EoQDUo5eI/JFaiux3FO1yZ6xPoErHKOWGMd4vXSt/27ZEiNacMNEerwFewiUhK5qC83nLU1Y3+IAna1YuK8S1oCcXbYgKfEt7z95kuMTlG/VYXvQ8nf7VvDShvgngUBQlPBgcgGtnVAVK4GXtnQJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760948711; c=relaxed/simple; bh=wpVWTqfmtcFpVy1LRpYeJajyDqC3wdOZWbgWcEU0KDA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZELpTFZNUy24jYSo3lfctcUlFJ92xZMGNPMBwHsY4taWtCZ4Zg86ZS2Z7mfX55iHOccRpIhL4MJra6AQhZgQVHB1CscI+pnX0bYEnXgYUlYPl7SKWFHGCfWO5XG2A0NV00KiTqvR2+foDBmDVn4AYYtCrE4/ES85cZ3JfVvoQA8= 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=TwqVlWTd; 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="TwqVlWTd" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5FB751E34; Mon, 20 Oct 2025 10:23:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760948599; bh=wpVWTqfmtcFpVy1LRpYeJajyDqC3wdOZWbgWcEU0KDA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TwqVlWTdHoshBZD9W8pzPO1mrQFW21X2+ioWivRgZtJPk62pQceDVNJNCrMqNPUVd yJ8gV69BPV52E4QFldpidoj+MtK20sgqMBeFzB+qZ2JK5I4rrdGLXHkE/cZt6Et+2N O9q6L9nkeCtQNmF78j2Is5f9Tno139+bJ4MC78i4= From: Jacopo Mondi Date: Mon, 20 Oct 2025 10:24:50 +0200 Subject: [PATCH v8 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: <20251020-extensible-parameters-validation-v8-4-afba4ba7b42d@ideasonboard.com> References: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@ideasonboard.com> In-Reply-To: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7302; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=wpVWTqfmtcFpVy1LRpYeJajyDqC3wdOZWbgWcEU0KDA=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo9fHYU9bN8VJN3Ly7EKmk5tIyqxZy6tFRby+c5 TnoEFSVbQqJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaPXx2AAKCRByNAaPFqFW PA01D/0Z9EA5x4y79Y/lBL0Q2pzpINm9Wi+yeTnFoMBhBU5Hn+KNaAvKMMViYKeOOTM2v/Mccdt aNuLx/AwUHC6IAsKBNbbhTM3CG9KmY/nCX3yvH9JeEtIBiCL4NnKY6q7MjrqLxuptID1nb5MGJy JBE9+oRaZxPW3tay5PUX+2uBMWwAnmEAqQE73Mz0x2gBCuibsr5OdMwSbCKlGg7r1F2pLuofFuk +hXPUcNnkxcqru8D0CghQ6Gtg2tejuMuUfGjtpOQnDDAAHMPHtRx8CJv2C0oK9g8cb58+TLNbqH 2wg3RKN2glpgKb6fAGC9LTiqVhF6RLbea7PF8WIxvREZ1WB2Rgu1AsZgDhT9uo0QDZ0yGqakx3M H+TLS8UxbOT67zVqno4mfRC2xuAmrOMFroRpPLC9qdmFDQpbGbQBgEPkYmSG1N7ebDfIjt85sjr BoMiNLkg/3aNcSbNZ6XmuFISEE5rncGW93VElF06GSJozP6LN0YCbZTGwGoLdycXwB8HlpXIZ2U w7F/P7CKL43FbTpu9h3ZWhjyOAfMHOFZ8k+DlDx0PCc5ml0LPlquRDy7SAaEW1kLlKqVXsPbHFG r/HkkdCko4jLanVW1D+latdiaKinYmkP8ReQjfVDsIstzC+ZpZWja3M8SZ0lSTpQ7U0E83fAysB F0pzhEH3x7nn12Q== 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 Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- .../userspace-api/media/v4l/meta-formats.rst | 1 + Documentation/userspace-api/media/v4l/v4l2-isp.rst | 120 +++++++++++++++++= ++++ MAINTAINERS | 1 + 3 files changed, 122 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..b53df722ed29117c3827314e844= fc4de61343f40 --- /dev/null +++ b/Documentation/userspace-api/media/v4l/v4l2-isp.rst @@ -0,0 +1,120 @@ +.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later + +.. _v4l2-isp: + +************************ +Generic V4L2 ISP formats +************************ + +ISP configuration and statistics: theory of operations +=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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D + +ISP configuration parameters are computed by userspace and programmed into= a +*parameters buffer* which is queued to the ISP driver on a per-frame basis. + +ISP statistics are collected at a specific time point and drivers use them= to +populate a *statistics buffer* which is then returned to userspace. + +The parameters and statistics buffers are organized in a driver-specific +way, and their data layout differs between one driver and another. + +ISP drivers generally exchange parameters and statistics with userspace th= rough +a metadata output and capture node respectively, implementing the +:c:type:`v4l2_meta_format` interface. Each ISP driver defines one metadata +capture format and one metadata output format to be used on those video no= des, +and the buffer content layout and organization is fixed by the format defi= nition. + +The uAPI/ABI problem +-------------------- + +By upstreaming the metadata formats that describe the parameters and stati= stics +buffers layout, driver developers make them part of the Linux kernel ABI. = As for +most peripherals, ISP driver development in Linux is often an iterative pr= ocess, +in which not all of the hardware features are supported in the first versi= on. + +The support for new features and/or bug fixes may land in the kernel at a = later +stage and require changes to the metadata formats definition. This is +considered an ABI breakage that is strictly forbidden by the Linux kernel +policies. For this reason, any change in the ISP parameters and statistics +buffer layout would require defining a new metadata format. + +For these reasons Video4Linux2 has introduced support for generic ISP para= meters +and statistics data types, designed with the goal of being: + +- Extensible: new features can be added later on without breaking the exis= ting + interface +- Versioned: different versions of the format can be defined without + breaking the existing interface + +ISP configuration +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Before the introduction of generic formats +------------------------------------------ + +Metadata output formats that describe ISP configuration parameters were +typically realized by defining C structures that reflect the ISP registers +layout and get populated by userspace before queueing the buffer to the IS= P. +Each C structure usually corresponds to one ISP *processing block*, with e= ach +block implementing one of the ISP supported features. + +The number of supported ISP blocks, the layout of their configuration data= are +fixed by the format definition, incurring in the above described uAPI/uABI +problem. + +Generic ISP parameters +---------------------- + +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 parameters buff= er +header which is followed by a binary buffer of ISP configuration parameter= s. +Userspace shall correctly populate the buffer header with the versioning +information and with the size (in bytes) of the binary data buffer where i= t 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 an= d not +accepted. + +Any further extension to the parameters layout that happens after the ISP = driver +has been merged in Linux 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 d925745077f21e5a1388a30217a24beeb4fff3b5..f52237d57710cadff78b297d2b4= 610b508f55092 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26856,6 +26856,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 Sat Feb 7 17:48:51 2026 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 D35B52ECD33; Mon, 20 Oct 2025 08:25:09 +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=1760948712; cv=none; b=gI9FMLDglxjmHHJIXvbMX8Lz6EdHrBaZvlXyolQMr6sW2f4wWJAZTZMQcH3L4KB+JmQdf+OIvAjKdsD3VCR+1Wb878jHMjQ8JUa6Wcq//qNWVRDK9Gi0lC4Rc//v0Lty+DKyGlqCVVtWoLBy5JfHOjsi17WWafsU1tri4Yy9Gqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760948712; c=relaxed/simple; bh=hXgsCNBTjDN6TqNGJKYJFlmcjUn+m1HbOuF2i3shnKw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SXV8ejaYPqTbrvbd0bNz3Ji9VKxLMC5FOVuK74q0aJFrPVVhPyZak76UWeEVn53DN8G9NOvaCJuHM2iNHxRriFiIhIuNvhEQhomMaHu4ZeJ/O+BiLt38ZM4bEwMjtTaJ1Zda0vxhqGaDHWPrxMhBExO5LCgxzli2b9QUEFYPF8A= 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=WoYtI5ut; 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="WoYtI5ut" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 464351E44; Mon, 20 Oct 2025 10:23:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760948600; bh=hXgsCNBTjDN6TqNGJKYJFlmcjUn+m1HbOuF2i3shnKw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WoYtI5ut/34/CSh36a7rylVg194XGnJA1lU4Egn8xTfymwaC20infGgPxolk6nTrY wcK3cw9QUuPHyhB8/EsRpvlpbiCAn8pOjEEB83noaOopQwnfCpVxd8qE/wST+j6Rtv c802URWmxUmE40+I5n8Cz3DEcKkF7+7BcTwc2bGY= From: Jacopo Mondi Date: Mon, 20 Oct 2025 10:24:51 +0200 Subject: [PATCH v8 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: <20251020-extensible-parameters-validation-v8-5-afba4ba7b42d@ideasonboard.com> References: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@ideasonboard.com> In-Reply-To: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=10899; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=hXgsCNBTjDN6TqNGJKYJFlmcjUn+m1HbOuF2i3shnKw=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo9fHYbLGkyWQmSn5ba+4TSa2/xPUyKVyZGgNvF 55iKbkicBGJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaPXx2AAKCRByNAaPFqFW PA4uEACyA1QwABiJQdUIbbovCrNg71qiXMHRO7lERVJNfEWJIK5qDsgikODU75qADluUoA59sP6 gYtNlkWZAnO63dG3KbHF6KrpUHd/8HgMNSPF7rDIFhsSixZFo493QP+Njofawz9TKUGBWJVNv4w rdMOfM4pM1cUqbp9Igd1MdGa6JU4LkoVXE1Ejc1Qvrvb5kWpF0xf45Lpu3e2lXCFufiDNriI2Rq GSpKlwX05ThdJejNzNvBPnwciF8YL9qmeBWBVBBHf/r8BjjWXMdhK5YWqlU/LXESbF5X6/Usxpa tT+Zp70XgYAtWXc74QSE/pdLqCI1CMLwo9JIEw8UxkhwjE9wz7iOp8SupYgT6U0zDdvkwlMZB5Q +wdBYMdR/9EhmCK2TQP8RGEbXbHNRyanjoMt5+K5FPJVAU7W2AFwhAEDcSZJnTk2h7RGdGrpzKA ijmBjVsApQ5Zjsi7Zc68/ZUc4ofhWtnztZAgpixn8wk/+4fi7NLdasv/xWtCrYfscBKDTFGvvFB v2BdYk/hX9NH5Qlt+V3jDFD356nHRKQokaE4JVrRcovuJCFE3XR7Yf5gFSHmVijwlN0zv8qKeka 5rYGehe2ooLh34nb1jFXX5YesYQgJtN7En8bBw9i5dpLLOjZGngjHYHepq9H9R+Ov+aa9zqcN4l +NL4GfzbsTWNZOg== 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 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 f52237d57710cadff78b297d2b4610b508f55092..5833f82caa7f2f734bb0e1be144= ade2109b23988 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26857,6 +26857,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 Sat Feb 7 17:48:51 2026 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 56A1D2EBBA2; Mon, 20 Oct 2025 08:25:13 +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=1760948715; cv=none; b=WjAAMEM0m681srGRt5nxMkd86tTZn2zFniDQv/UeFcVPudrsnsW+p2tfbr2jgPehrZJ4gp2uEgno7lQwvq4m9EmkjVMP2SLQCPINRKbvRORlX6rIML+q2tK95G+QmM9HOZshsfXMRvGK8E8JkGLuuxr3eHGuOpx1k9Aq7nDFbmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760948715; c=relaxed/simple; bh=fPMnxVdTFOQgQm0O4y1ScD0/38pb8OIHKrqFCNc1sjU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SGg9qAsmbdug5ZYEqOYljMsktfQ8HT3fzctINqnMKRqjspat5P0IyuRODqukqcBroE3ADx6Ch2hEETUeBaiAkq+3pAftZi0L7EKw3eEZxl00ZnpaD0WL3u6bLG3QcVvAR5QuttoyRq+oIc/eYS4B84taGTBXDefIQmbPIut0nfs= 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=KOBRooxW; 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="KOBRooxW" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 411891E79; Mon, 20 Oct 2025 10:23:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760948600; bh=fPMnxVdTFOQgQm0O4y1ScD0/38pb8OIHKrqFCNc1sjU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KOBRooxWguh4TPvk53/puSDYXFIXPPGig/RTp/3InhlI0HcOd8h/YWQzln9SOcmuo IM0BntMkPTrgeQo3+KE2COjYq2Od4oyR4ddbKIxSwIVI2+0pr1WDqODRtSI4F0wz06 fAT+01GaKAxn2bvOvbCAZfsx2v1/Ojr65uwRdy1o= From: Jacopo Mondi Date: Mon, 20 Oct 2025 10:24:52 +0200 Subject: [PATCH v8 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: <20251020-extensible-parameters-validation-v8-6-afba4ba7b42d@ideasonboard.com> References: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@ideasonboard.com> In-Reply-To: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=12723; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=fPMnxVdTFOQgQm0O4y1ScD0/38pb8OIHKrqFCNc1sjU=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo9fHYWxbdrASuhFsapXl+nQ84Uep0Q6QU7Xd31 LLXpjGj0DOJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaPXx2AAKCRByNAaPFqFW PLnXD/0ZhlifplsC6hfIaFnK/i/nuHVx1/qfr4VkwwEJtjr/vkadpCJtSaKe2Sjqkedml/vLgng fAbXA83nCyJYjziliE6HL2t/7epsoxrFzSMRtlpns60sCtNtsbVXb2uujRJuGVVjYs/T70Mt3Mz 7idUO8ghmKz4i5B07nXfFqNq3L+FUgygWleV9Mnw4LR7/QKcJsW706tpVNr3MVE8B/HU2rZnbQ0 4odCzJ9Ak2C34aocmSt60kZX+n7CJFzOMW0jeUGL0CkBY8i5ICpdw908ieTU8pDwl9PYa8/cOo9 uzg7JvCYCOieHJV2v0B5tgMKnDItYVIrQllqjd0mCNZ1K4bxKPi9h7Ivn5y/ZCLzHWU7rJSQ8UR UhLRKuks6ebGq/IjUVp2Wp98Lg2Gw1qhuAeIfGO1sqZNND1Tf7UN0KBzNnS8DWv2k+Nl44P9qzi aqu171rxsZSINi8h9bf/yDEHARqXkM0CmU1trZlBVIZLql+CKdSDzsG2P6Ygep4S+uLHJVv/792 Y+G2S+JMJANeTnKVdi/tMjj6ggLvEaaMN44lNMEP0fLnK7Leih6v4he0IjFXMhnbvrOM80aImyb MHsEsPuHvgHJKXrShluJMEwBuk/qLmyPKVBQGqBdoITAFdsjjao14ujCj9N53S5g8TygNNFcpMH 3+uNvtCE3ljOP+w== 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 Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/Kconfig | 1 + .../media/platform/rockchip/rkisp1/rkisp1-params.c | 183 +++++++++--------= ---- 2 files changed, 77 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..a880a46d2eefefc6474b36dc5aa= 69b4f3dce51d1 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include /* for ISP params */ =20 @@ -2097,122 +2098,166 @@ 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 +static const struct v4l2_isp_params_block_info rkisp1_ext_params_blocks_in= fo[] =3D { + [RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS] =3D { + .size =3D sizeof(struct rkisp1_ext_params_bls_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC] =3D { + .size =3D sizeof(struct rkisp1_ext_params_dpcc_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG] =3D { + .size =3D sizeof(struct rkisp1_ext_params_sdg_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN] =3D { + .size =3D sizeof(struct rkisp1_ext_params_awb_gain_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT] =3D { + .size =3D sizeof(struct rkisp1_ext_params_flt_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM] =3D { + .size =3D sizeof(struct rkisp1_ext_params_bdm_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK] =3D { + .size =3D sizeof(struct rkisp1_ext_params_ctk_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC] =3D { + .size =3D sizeof(struct rkisp1_ext_params_goc_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF] =3D { + .size =3D sizeof(struct rkisp1_ext_params_dpf_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH] =3D { + .size =3D sizeof(struct rkisp1_ext_params_dpf_strength_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC] =3D { + .size =3D sizeof(struct rkisp1_ext_params_cproc_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_IE] =3D { + .size =3D sizeof(struct rkisp1_ext_params_ie_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC] =3D { + .size =3D sizeof(struct rkisp1_ext_params_lsc_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS] =3D { + .size =3D sizeof(struct rkisp1_ext_params_awb_meas_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS] =3D { + .size =3D sizeof(struct rkisp1_ext_params_hst_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS] =3D { + .size =3D sizeof(struct rkisp1_ext_params_aec_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS] =3D { + .size =3D sizeof(struct rkisp1_ext_params_afc_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS] =3D { + .size =3D sizeof(struct rkisp1_ext_params_compand_bls_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND] =3D { + .size =3D sizeof(struct rkisp1_ext_params_compand_curve_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS] =3D { + .size =3D sizeof(struct rkisp1_ext_params_compand_curve_config), + }, + [RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR] =3D { + .size =3D sizeof(struct rkisp1_ext_params_wdr_config), + }, +}; + static void rkisp1_ext_params_config(struct rkisp1_params *params, struct rkisp1_ext_params_cfg *cfg, u32 block_group_mask) @@ -2646,31 +2691,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 +2708,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 Sat Feb 7 17:48:51 2026 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 A3EE52EC09C; Mon, 20 Oct 2025 08:25:13 +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=1760948715; cv=none; b=LseULuekgckKSQMP+rmygR7EWVD+iIEPICQKTAYY0CBZKzQZZcABpKZunwGZ/F1HJ0uyhXlXZiSzqpJO441/6gDqi3cT9M+6gUa1tfsmepuZ1j+kgMnagevAmgRGv0FvkqX9FiLy26uHAilD6GoGsXNYLS9a/M/SbYoClT2KPYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760948715; c=relaxed/simple; bh=7d66zFdIcUfNi1vjZ57PHiUP9ORNzyBprs9PXVWyxwA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TqODKBkfqFNjeGrX/3krqbnNERfsHZ76BaLqobakiIg9rQBti7MQH7MJGSMZW+2s0LmiG6s4sDFmWgUGZeJtB3Q91TCc48tH0LZxQdFoi+LSUZ3op2g1t6YUX+X/QipTaIaBcG/8zkOtU/ATUAw+/UdW44rdYGtlcAUL56yZtsM= 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=pe88rvER; 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="pe88rvER" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2054D43; Mon, 20 Oct 2025 10:23:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760948601; bh=7d66zFdIcUfNi1vjZ57PHiUP9ORNzyBprs9PXVWyxwA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pe88rvERNllri8hs11PIu48hiKF2qCt/8aeUJuNhC12ddzaQC9HHSeT84Plxiz6/+ fBpN9WKjYyphjBBGt3Zc9QmSHHWznfeauZtI9aK6mg1jN2Ru2j8NU87w3+3H8AwY4d PYEVbsb/8nDNdpuLVGVYz3DEbuqMba1YEHdE+m8k= From: Jacopo Mondi Date: Mon, 20 Oct 2025 10:24:53 +0200 Subject: [PATCH v8 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: <20251020-extensible-parameters-validation-v8-7-afba4ba7b42d@ideasonboard.com> References: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@ideasonboard.com> In-Reply-To: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8176; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=7d66zFdIcUfNi1vjZ57PHiUP9ORNzyBprs9PXVWyxwA=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo9fHYRGyovYCqc/pw6dwc+xchRfreXRIvNCtGq K1rVbzSrS2JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaPXx2AAKCRByNAaPFqFW PD6/D/9j9Wk2KOR8vvUVXwbs8rZ3ZIrEW2ORGU4gJCCsM7LqSX7FC2Bxdx7Cuc+dlKVNauYcp0W lEsFx3ptn15GujCzZuV63WOCGMXcVT+wC8RGmdhGfAgi8Xrk1y/0jSIfrJ263BAE7fL6btu4toR fDrTAW4fEdJC1+BD8yNcF8iLgRTuSv8Cr8UlQzGEULSPY3rpg4S5Wv931MNVde33F+XI/G4IUVm 2ras9KxSurU4RBY4/uQ7n4vMUTFmSnx9zvRNQ9/zu5mT59tp2MKBn+DLsNkE+0X36LcvjJ+TYj0 LZD+9stdyXDtSxNtJPBsKW0SsPE+YQrgXS7hwdj1ZT6R9FdQeHWsmkbRJUob5l6x9vneiyoXxC3 8O0NyywyIC52y+dfG27SXSdJLnmFKqSYPf0XUfjk7wjD6hsEDwUUrg/EJ3z9xauo5rH0tbNze8l BeG9ffeUUu13ADAolTm/tKxvuupJPHVD2Wf3l5LJ6lliMvloze+NshlPBsQj5W/y021aRGu/+Ye JvMk9AgB4gVCz144QDcSv3130IeaWap0Ee5Va+BXDt8VfwbQuOzsMSLr9SOAQgAr0ZoJj5o4121 vsR6M4aOgi3mGoJIvuMokqv3impQ8ianpVRF2kcd8xEX2DxVbToQA77szXFfO1JlfYzEfenTOwt QFmXvQyfoYE4vKg== 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 Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- drivers/media/platform/amlogic/c3/isp/Kconfig | 1 + .../media/platform/amlogic/c3/isp/c3-isp-params.c | 124 +++++------------= ---- 2 files changed, 27 insertions(+), 98 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..0e031d64de312cfdf0a52a46f70= edbaf07563359 100644 --- a/drivers/media/platform/amlogic/c3/isp/c3-isp-params.c +++ b/drivers/media/platform/amlogic/c3/isp/c3-isp-params.c @@ -8,6 +8,7 @@ #include =20 #include +#include #include #include =20 @@ -51,11 +52,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,38 +519,41 @@ 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 { +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, +}; + +static const struct v4l2_isp_params_block_info c3_isp_params_blocks_info[]= =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, }, }; =20 @@ -568,14 +567,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 +770,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 +786,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 Sat Feb 7 17:48:51 2026 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 C7D6E2EFD86; Mon, 20 Oct 2025 08:25:16 +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=1760948718; cv=none; b=S8upzrwNayn4OcruOn1YJY2ZptR0jAwpgjy2C31PWz2ykmTCoNX0mBi8CZ+vQPV04kyd8lf1L6anwZWFUjHQVNcIW4QPJK+CkJ4kL0bLPmcCuOjubWQ4C6f9czfioHYEU0rqNYe7BvtK4Wm/eUzi2h2S+upaIGkLDC7zVtDSEZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760948718; c=relaxed/simple; bh=aphqrnjnIHEaL1McVyPsfsz1ESyLlGYYkbJKH8NlHMg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U55Q96wtZmWAcNVUani3BMHnSqURAG9OxR3TgdfE72OWhmdJryNq4UVc+l9cPuo6hoJqQxdpFGYOoGjL8lRXNCIKiLaG0kioqAvAMQ0yvhCoIIYNxhS9P2a2l8tvYIBEw58/Umuy8cf7DFMk4Mism4pvzpiKPuZrHgE8F6EnF8A= 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=Z+Fc3I3k; 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="Z+Fc3I3k" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0F8001116; Mon, 20 Oct 2025 10:23:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1760948603; bh=aphqrnjnIHEaL1McVyPsfsz1ESyLlGYYkbJKH8NlHMg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Z+Fc3I3kwwM42ZJWD1OKt3Rcuuawr4d2kcM1vAoJfi35Qq4959AiJVgxr1XH+gG7d s4SVp5poG+AZXZyizdsbvZLRLQzEbZakvE98xyC0yTtnzujJOtb/hYI18Dx1WOnJ1k CljDBws2gl4v8LfVnlWUpnhM9PRt1oUIM63gi4D8= From: Jacopo Mondi Date: Mon, 20 Oct 2025 10:24:54 +0200 Subject: [PATCH v8 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: <20251020-extensible-parameters-validation-v8-8-afba4ba7b42d@ideasonboard.com> References: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@ideasonboard.com> In-Reply-To: <20251020-extensible-parameters-validation-v8-0-afba4ba7b42d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4112; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=aphqrnjnIHEaL1McVyPsfsz1ESyLlGYYkbJKH8NlHMg=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo9fHYLuapdMSCrbxyTfvkamWN3atlzp6On/gWa Ullsu6bJlWJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaPXx2AAKCRByNAaPFqFW PMebD/40IT9AUTtqWZ1ILnE5CPIbzJn7CE5LICF8T/arumBlmCly/EBuhRr2Cc5lMTkqPq8BIR3 JzCsZmxP9yTspZctBCJ+ZvHC3GSur4e2GXJgJQa2DW98j6MJpx20A1q6Lb1+/hWag4G+xk1/PH+ yJfj/eZ3MOQStCijZOadI+l5jrUa70H3dzY2UCiB7FFog2/YMYFclF3LBe41lNNPt8qot0Trc65 bpmu56bfff00/AwdmoWkahb34YVztUxsuFkwnAUVqNlUGGy3DnTlWsRwTYdlGyUax3mbnWKJE0I 7TfqzvONQ+0SZmHpu8vQTIa65cjA6WgyuhnhMnnOGaei4mHelvbAjJi+IuUrZXgyvwbJ3tKY66E jIf/eDzd+LiDltTTWTc68j5mHybg0USzv9dObAvWpxJ+gEloSVhxD6upum5sVSGFhRsLATswqnA 1FdGI18PiuzQ0rCcuQbrdcwA9IxAzbzhEHQ6fqpd9F1aWZOQklr7rGssEDY+GVNuotQztE9SlsG YJ59FjfbRShIG2PZKk6w1JE0y3VhsCj29fSwxeu3efR95MAp1iQdL7AscBI0yeoCHnBR+4cbWNu XK0E6QC7MbsXwrLJpyLsknPdH8dDGKO5a9V2JdICIWdOED3hRTT1SBKiAXrDKplYNL6QsPWJWVe imETzVRPh5GckEA== 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 Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- 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..150ba39b257b23e6a8ca1a34804= 7f5b55588fbf7 --- /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, +the control flags 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 5833f82caa7f2f734bb0e1be144ade2109b23988..cd1137c7754538d02bd72521fec= 6c89e082246d2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26856,6 +26856,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