From nobody Sun Feb 8 00:49:43 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 D6F4521859A; Tue, 7 Oct 2025 18:12:29 +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=1759860752; cv=none; b=L/a7Fu08pqpbKfdm05Wy1vAY+/DfZKV8rnst8C2Ow/lYb5V8eoR8/36WgkjCYpDdPwd8kKi4pBnjhlSzhGNHSOuKmbmiL0qmuBXskYQhUY0yZ93K7NGV5ABcmPV1YtkE81tMIgw5olis09L5jXtqiwQuRMnj1waj7lGssfjwgyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759860752; c=relaxed/simple; bh=LQ2X9ugosfqjzqJXgTJjdNawJro7eGQYKpCuJDqnl3E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YQOFo3HwHriDlpbrUNZg13wGb6BwG/wNDwufFKtIFDAujDyiOb1HIGvrA3e/oTQUDz48mGjSHeVJ2IUAIOPTVlEykYqGmaAFMyZYbKR9BU8p2xA8y4bCEa6tz1ZtwNZSFzzB7VQKfCSIBX9S6U2rzkpE2wTCYkCOx4L1rUdZO8A= 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=IpYMUryx; 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="IpYMUryx" 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 20B2C669; Tue, 7 Oct 2025 20:10:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1759860652; bh=LQ2X9ugosfqjzqJXgTJjdNawJro7eGQYKpCuJDqnl3E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IpYMUryxdYAmQyX++xxaGaJooAuDNgJIWRDYvWiEON9PAa3MB6C99lEkIXR3WmdF9 WKTVJv6wRa+RJaScm+G2tYsdBX36Sn/Qzyz5+oj5hDuCI3eSiiTZF78ygPOzkFzXqX DePSJjBSO/sES4ABJU0uEmmHjGoprIVZJR0vPFKM= From: Jacopo Mondi Date: Tue, 07 Oct 2025 20:12:10 +0200 Subject: [PATCH v6 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: <20251007-extensible-parameters-validation-v6-1-5f719d9f39e5@ideasonboard.com> References: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@ideasonboard.com> In-Reply-To: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@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=5520; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=LQ2X9ugosfqjzqJXgTJjdNawJro7eGQYKpCuJDqnl3E=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo5VgGrygJqfNGY1xYv5oRICWSDDOsg0DE3Drj5 CiN4NWNk6SJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaOVYBgAKCRByNAaPFqFW PLD/D/4xjERbaUwksFLCcpjILoM50nEq+dQp+Padycu+U7HfkioBgSqOnBPOqJeuemvLtnO3zGR NDjsn2bic3I1E2VlVej44O6RhP3+4VibdHwbEWiA3dwjNGqE+EYhSGXVfYUdZQ87IdhIJvDxLw7 F0Eq7QR/SAQ/HXdyeWuOT2hib+zfwiscaSfncuwPYVYMsAdTUY9eyXM8QS8LPkrpQsEllmJ/21a bw2Uygo/BVL5mWdQQjbtQSUDVzYdgHuSqcHWghwwu3ghiLl9YPdhL9XrViQ2SBaQvdp0ZkvKwGE eTtYTPCH32m6xtq/1J8Uye5045AWnsxHIr3VROeC5BMBpQrbGeQMmYYSZhwdnJAbv2hVCkXPiWs 0F16V4foFP1EBbSFYvtzkyG0X65iTi6Mrc1G4l+JTPlFyrPfCmcBnBDpePDqKy+f43te7SePxGG +y/VQU/8vf+k+twvYphwXUOc6/JmU6a3gphqfq4KU9ee6RXIhcs23vO0WKE9Yzn6ynyAFx6b32q 2GOk6DuH3YRckiRsuFXXhq+J0CA5BvEZEupJeDocwDN3nWlkqH1DByuYaBe1bhM5En22L1rp7+Y SLOTOWKsNMs32C2rlE3faOEBokqQxJKhvkfO/FjLir/pSa1D0lGUoR4aK0K8kf820XAFkjYOAJj LcyvATowMjKBCfA== 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 Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- MAINTAINERS | 6 +++ include/uapi/linux/media/v4l2-isp.h | 82 +++++++++++++++++++++++++++++++++= ++++ 2 files changed, 88 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ee8cb2db483f6a5e96b62b6f2edd05b1427b69f5..e82c3d0758d6033fe8fcd56ffde= 2c03c4319fd11 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26410,6 +26410,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..809c950456b5048bd659db9d9f9= 349d87070d0f1 --- /dev/null +++ b/include/uapi/linux/media/v4l2-isp.h @@ -0,0 +1,82 @@ +/* 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 + +#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 Sun Feb 8 00:49:43 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 25AC22E7BCF; Tue, 7 Oct 2025 18:12:32 +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=1759860755; cv=none; b=dKz0RZxFdIjpzJU/UB1UOJZDYZAFhcuAKrf7ZlJEE+PXed5JOAskq8+odDVDi8IvOi2JXY+tGI/ezKTCnDk9+BZQKDeUWePiDk1SsT7VPL6LOBTbc3ZREqRj9CCbF5Z23LvYQxDhe6gWXzigLFi0nqNRU0ZoiwgWZ2yhTuACh0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759860755; c=relaxed/simple; bh=Oer7+SVKkWs5I3y4KWYiwuqB2+mjnGg10Pkx15hV7Tw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YLs6qHzFVJmCG8awnsa3w1AYZTMP1KNkmjZscbVzvVEBaPf8J11TmYIJ5EJWNjvt2z1LtyAOlUHnMm9rnsFpxoQ9ttlArDk4HdDVTDthtuAxv5Ok20m0DsL95ubIoBtulQDymHb1X1M6pKm1Sq8hgtgdlGL4veIXBPUV8GNDisc= 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=AJpFJS4u; 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="AJpFJS4u" 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 EF4F46DF; Tue, 7 Oct 2025 20:10:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1759860653; bh=Oer7+SVKkWs5I3y4KWYiwuqB2+mjnGg10Pkx15hV7Tw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AJpFJS4ugHVhILrxmsmH0w32GivukdwFyLzzU/TnrAgMyWfhIJi5Zwba2XhEBI6FK WdFGr0/ka9hJNTcyrlrz4Gu/1RpHMXeDq0Oh32zraWfpW9zgT2/i01GSaQ8wTrHT81 PFlbZW/5C4ComJgWZefZT3/2U+izk0GCsx2Rv1HQ= From: Jacopo Mondi Date: Tue, 07 Oct 2025 20:12:11 +0200 Subject: [PATCH v6 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: <20251007-extensible-parameters-validation-v6-2-5f719d9f39e5@ideasonboard.com> References: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@ideasonboard.com> In-Reply-To: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@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=7792; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=Oer7+SVKkWs5I3y4KWYiwuqB2+mjnGg10Pkx15hV7Tw=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo5VgHDdDt9pOTiHUjSpxE1iMmeeqJ/QvJMN9xU 30WTBcJR9+JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaOVYBwAKCRByNAaPFqFW PLZfD/4h0gAJuib5Mf74/spCyTtPoqvsweZdYawcX8vF+IuMGerRmEjEdb/8119s8KahmRTNkOz wCOOIwvNqDuvnGUeTPFGeWr6xE/pwczuz9rryaF83Y/chDaLEinODdzPuqK96bqcbGo+N8cNZqZ C7ihY3hj9qZHi9AZMG5O+VQD4kDgc1xxkDdkMww2jewG/95mVg2JN1NZggBd9iHnSo8uVC78aQq zT/zwhF76JXsNwKH5W93jL2+i/z4X0xHmJJf7A5hObZs2yvZrjVYF853lK49ZLSQYVPBkzJbD1K mMDlUlPsKEJLJjiAQniS3NOvEzFhiYurUQqCVdmL9mDjIjMQQfM5HAgPRWTFJmisZiDggWO8utm QpccJuxx6gDASfcp91bbkbZn/VZsyX4EMG9KgpTyI796FHbVETwxVRuLCev0oqXlI8l1sWoLs2P dh7ilDuk5KcP1lrEaaNOtOQUtIK0MK6YQama9uUCmXpcPjB4WQd9VpRNd+R2lmDkW1R5cjGbjys RSqcG6VxMV9UXzVXEFamiauppwekEU/j4GINBK+Zb7ooViOjA/MWFpMLAPTLjNxCz+EbMJbHT9d 9Js74k1n6FUJMNE0MReAH5x4clP2nSwbKSOVfP7Be5bZryR/h5ad9KkDzXpLB+IPNivnrTqQguz IqQwELHlfUwDPUg== 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 Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/uapi/linux/rkisp1-config.h | 105 ++++++++-------------------------= ---- 1 file changed, 23 insertions(+), 82 deletions(-) diff --git a/include/uapi/linux/rkisp1-config.h b/include/uapi/linux/rkisp1= -config.h index 3b060ea6eed71b87d79abc8401eae4e9c9f5323a..950020c62781ad19db149200a28= 5c206ef000a37 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 @@ -1594,21 +1546,8 @@ enum rksip1_ext_param_buffer_version { /** * 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 Sun Feb 8 00:49:43 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 01A0F2E92B2; Tue, 7 Oct 2025 18:12:33 +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=1759860756; cv=none; b=ssLTaRSAP3vgW0ON5GNJN2iJWh0FC06KLUKtPfSJciSxQUhXtyDkjO6Br0ZZP/flgKwaRDtZEwm8wQmaMYn1qxsvl6TXuK9eDcFluB8lBUZXH4Ag0/Fzqo/YtnF8GVAgpeDf0lWjZFj5u6m6CSeZ0tT07BOVrIIAnDNFDfgeOWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759860756; c=relaxed/simple; bh=+yKUAufID2ymtUvRzYBcn3lD1Ig8KtqcIi5vjhdvizY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V9wlEo7fCJzLQ0gxZ5VQvnPnoiAeqLrUXa5XF1uxOPBATL5jm+qhwqZ1Z2kgkqPkY7Kq4so4Bl2ZjHooa38ySKuQKdBKhdGbZs9PUiVXV58lhxzeNyvZqpO5K6s1YezvPpUFBoXw6zX9UHao8kxXS+lBFsUbSYp0+KI8NcbGZw0= 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=TOy0Oz6N; 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="TOy0Oz6N" 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 CCB586F3; Tue, 7 Oct 2025 20:10:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1759860654; bh=+yKUAufID2ymtUvRzYBcn3lD1Ig8KtqcIi5vjhdvizY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TOy0Oz6NNWTYBT8r89JTTUOjKjsAklCdYfyafyle0b/GScxB5TnWe8TyDPJ/Z/A2l BKYIxDNOmNrDUDrXrrnzYc9PNsic8atKLSL/gzFF1Q2FVTyv8mNR7HRwa2WL+qwIw/ Pwn8/+ment1kYnjVtc148dWBjULMeVbizrSSsAYI= From: Jacopo Mondi Date: Tue, 07 Oct 2025 20:12:12 +0200 Subject: [PATCH v6 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: <20251007-extensible-parameters-validation-v6-3-5f719d9f39e5@ideasonboard.com> References: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@ideasonboard.com> In-Reply-To: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@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=6557; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=+yKUAufID2ymtUvRzYBcn3lD1Ig8KtqcIi5vjhdvizY=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo5VgHzUhgtfFHffsI0t5vSIkHCB9tFNvyGejEs vZAVDpR9ryJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaOVYBwAKCRByNAaPFqFW PPkfD/0ToxHpask61Po9H1McGo929B7oFKCP6qc7EqBK6FeV/6xv+HN8aBZHCm77QKordKEqvAe Vt8/PtL4yv9Fnt/RMijhhtJtY4Q5UY1AuWnFqTCUj8feIGPztv8zTlZkzkxmqSEKLFSSrMipHIQ RTAAU8KHOMF4i5LUl12EDg2fUjXLTU36AKrLe0SApb9pPPEwAvnevxy0a84S3xIDyjDO74PBsvC ZHnugAvkyXDCghvqgOCE6IQnNtMoPzP+1wGfMhyYQiYz8FkckuVvEsMP/0+flC01RsaEB8v2VCT 5E9l/NhQ5NauIP0aztyiRSAM5wuG0AUiiARrLPsIYu8K15GBr/IWaTF0KdqQYCP6Vus74bdOALX UuwbMBaeB/1w5T9zDFKpwspaU40Y8rbVFITOdj9qhESqh3KzJLFnTS5xtCNxdBSSkQl/hcYnQVW Lid9BrWhmxS3Ziyl1L6hgt3lJeuWS3hYzizvd+674U2YlFYKn7eNcPbEIFtyc/nFxXNUhsvp/6e INrtzOOk1VIub/hXFHW6+Krswv0V1zuoGVuudbcs+GsE32Ap2FQTD/ssMXUggUs5KTThxwudCrK U5ac9KUY1zhSxc2siePLaIjGYhvtQXfjPBg3rSvq9p2953bPDIgbVYirSwDD01yjpXU6gWwye1/ fzZAp68a5J5ZELw== 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 Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/uapi/linux/media/amlogic/c3-isp-config.h | 90 ++++++--------------= ---- 1 file changed, 23 insertions(+), 67 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..be0022bd141fedf8e603a6e194f= f0b0dce5148d0 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 @@ -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 Sun Feb 8 00:49:43 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 0F61E2E9EB1; Tue, 7 Oct 2025 18:12:36 +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=1759860759; cv=none; b=rOCMX1gZ3scOUKzd5L7UMpIrss+d9nSMZUDTyWNLsCC9HQs3C1Z2MITZrI4QSWPmlV+x+nXfGWdvfDJzxHLLtP+UOeWKtdEVks59LK9bqjvplmXpTXU8O+Ugw/oYhxjBmp51C4zMx1RCbxwj1snTTiuXlWhLfXEhNIj240eoKHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759860759; c=relaxed/simple; bh=lzx6pD2axhUMQg7cawHwevY5H1fq1fXzh8aNOBiMlps=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WC0ei5w0Ry9VtM9pcTQPuk/wW9aBBxxWq0Gki47o1VqPcgBNRsVzuyQetxMlS7JUNUE4V1zXUepfdKTjen6HMZdy2ddFf5WHZAVVIyyBdgXEub9OgIRgAc4F2ewANHMu4cv4Ck/6FZ1h9tBeeu9ueJ8lfoB8+aZX1lFIRvfHIDQ= 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=Pv85tzUg; 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="Pv85tzUg" 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 AADFD929; Tue, 7 Oct 2025 20:10:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1759860655; bh=lzx6pD2axhUMQg7cawHwevY5H1fq1fXzh8aNOBiMlps=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Pv85tzUgLiUKYzoNJY76MYAvevMA/8qfItZM2Y15K4epWCGINwO5uHMMEcrvIrqIn KXl3J9TD/Ho3kd+FaYue8Fsd9tFDSYeBp3IW14I51l5yzHI88oKsErmlF44nFRXxWK yO6ItSAzk+U655X0iZK7XDFw3Fd938ESLeDveiMs= From: Jacopo Mondi Date: Tue, 07 Oct 2025 20:12:13 +0200 Subject: [PATCH v6 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: <20251007-extensible-parameters-validation-v6-4-5f719d9f39e5@ideasonboard.com> References: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@ideasonboard.com> In-Reply-To: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@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=7257; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=lzx6pD2axhUMQg7cawHwevY5H1fq1fXzh8aNOBiMlps=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo5VgH3cSaK2EgTsBev7wXrnA6iFpYHHWtVRvp+ onwYzR4mE2JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaOVYBwAKCRByNAaPFqFW PAdzEADE4K7q7d3M7Q7v8FarH3ECKrjqqqHvDkzYMFfC74BbCusUKqGIakA1wM0i5jN8+prKeEN 2eZr0oy1jprxk13kGcgKAknWgOOC06esuo3sQQ4xVVlzdXMqF3VG55an90IRwMy7a0r+On6P3KA ugR13laRhhhHKRru5TcIESh7sbYH/e0LNL1WpruoRm/rr20+6cNgxOa4Uv7jd/OuNNN7NJblXOj tMbho72LuFilae7kmdfPRjTZjb2IMkgAhrwDSU/atu6PaeMQhDQGY1bVB5cd/FKM06RgQJFndKh HZGazX5yma2E3MbEyS+OjRw2vSxQuDcucwi3n/i3ObYIZSN4SnHo/ww9OwemK7P92LnXM7DqLSY hzBSodLHgdtqTJyVrx01uf+dUqzZY7dSavVvxbK2qbEuZg7A922+7RyG2B3sdZKNRZAyP9Zt/iC NsGsTHiT7KbaWpunILM0qfcfQ4ntLtlFe+9p67wT/iPrwgTTvEpQhBiZTjtcw3d1iCnmTNhG8x5 dOl5IFFN8B/r1KgogpHVKJk3PPZD5OSll1O03HJSQG3NWuYx3cBV0B/ot2Am7iaX264bp8uqS4i ne+IZcTELIRz2Q24ERzANh5UkQUjhNimzRlGq8fRG50Yr77WBhBPB5JAVBoMN0FsAYNUzXucx8i SWHB0vOjxOjnTsw== 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 Signed-off-by: Jacopo Mondi --- .../userspace-api/media/v4l/meta-formats.rst | 1 + Documentation/userspace-api/media/v4l/v4l2-isp.rst | 121 +++++++++++++++++= ++++ MAINTAINERS | 1 + 3 files changed, 123 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/meta-formats.rst b/Docum= entation/userspace-api/media/v4l/meta-formats.rst index 0de80328c36bf148051a19abe9e5241234ddfe5c..261483f8e4d832d3d0ce8aa11df= 4b4eb1645f22f 100644 --- a/Documentation/userspace-api/media/v4l/meta-formats.rst +++ b/Documentation/userspace-api/media/v4l/meta-formats.rst @@ -24,3 +24,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..41078558ba5cc1faf922a9b9112= e64c99ff37080 --- /dev/null +++ b/Documentation/userspace-api/media/v4l/v4l2-isp.rst @@ -0,0 +1,121 @@ +.. 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 by the driver at a specific time point and dr= ivers +use them to populate a *statistics buffer* which is then returned to users= pace. + +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 capture and output node respectively, implementing the +:c:type:`v4l2_meta_format` interface. Each ISP driver defines a metadata c= apture +and output format to be used on those video nodes, and the buffer layout a= nd +organization is fixed by the format definition. + +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 it +sometimes happens for most peripherals in Linux, ISP drivers development is +often an iterative process, where sometimes not all the hardware features = are +supported in the first version that lands in the kernel, and some parts of= the +interface have to later be modified for bug-fixes or improvements. + +If any later bug-fix/improvement requires changes to the metadata formats, +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 cature formats that describe ISP configuration parameters were mo= st +the time realized by defining C structures that reflect the ISP registers = layout +and gets populated by userspace before queueing the buffer to the ISP. Each +C structure usually corresponds to one ISP *processing block*, with each b= lock +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 the in the above described uAPI/= uABI +problems. + +Generic ISP parameters +---------------------- + +The generic ISP configuration parameters format is realized by a defining a +single C structure that contains an header, followed by a binary buffer wh= ere +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 e82c3d0758d6033fe8fcd56ffde2c03c4319fd11..bbc92829c3c413de7d7ba77f182= a6916728b1a8c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26414,6 +26414,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 Sun Feb 8 00:49:43 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 78DCE2E9ECC; Tue, 7 Oct 2025 18:12:37 +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=1759860760; cv=none; b=BLNNtGEKc8DpvyYmTJwVisLuPxwDCfRepnZbXX575PbcA9AzCZ55kb2riJTnz3QJYwmYRGO+twF6C50p2ICfdrR9DXeRQCV6FHK7PB8jEqhkfZQ5C4GPC6gv4Z7nV2vUJnPAwYscctCU0VG+YZp71jENd7Evrat8bk8VsC290dc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759860760; c=relaxed/simple; bh=gaVIBOMsqDepQjal6ydmfk9LMZ3g+ZkoHS6cx8St+7I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ejjQOwUrCi7QJWQcyD7NIOcHpqzawbQvi4Na3FuSwMHGHk4D880Qm6fn8JLbEWwFZEMVhD47KZ+IB/854Cfx44hB/pJtrtcDwE6El5UcoeW4OU68FtIchHNRYhmff331OjlHQgl1ibGv+fZHjz51xn+/B5tSxeOqdMJ3xaJqBAY= 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=mfVSmCAS; 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="mfVSmCAS" 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 81C35EB5; Tue, 7 Oct 2025 20:10:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1759860656; bh=gaVIBOMsqDepQjal6ydmfk9LMZ3g+ZkoHS6cx8St+7I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mfVSmCASxxH1uOm2hz4ePAlam4qSwegZzixN3I6K5krQPTcZQWBboSFHVtdSiM3up sTmlZF51Bbadsu8KGGah5HbxU7ASb6C/vVTGda1Gpxm6bkusVPHbKHiVe5/dn49EXA 54ng7Pz1IfNUaDHnm1pq609AjZxidrp/PT5vA5L4= From: Jacopo Mondi Date: Tue, 07 Oct 2025 20:12:14 +0200 Subject: [PATCH v6 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: <20251007-extensible-parameters-validation-v6-5-5f719d9f39e5@ideasonboard.com> References: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@ideasonboard.com> In-Reply-To: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@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=10289; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=gaVIBOMsqDepQjal6ydmfk9LMZ3g+ZkoHS6cx8St+7I=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo5VgHtSzhzxu6ZUseIDgAeRfYQQCc+eWQucwvY Uj7FAwpU7eJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaOVYBwAKCRByNAaPFqFW PMjYD/9Z1yQ2AN/cz7dE9B80U2Bl33bYHlqRRlhrV0wTowPxNxckQ37m4ZbCAxYHAmaQ+yrtPOR 04REGqE1wsj7L2Lh77LG0Na/xz2fHIbbHdpfpnvnr39PCT7tNuOTvR7ggs/58zdl15b4dUuYRnC 0GRe5NEeM6ggX0/2GCWRoGaTbKSCfCs/eQXVym/98/ft15jzJx5bB+kJxjD2BQt6b+S6sENuQVY tnFSPKRZo0QdK1hWuRizLMh71d9YoCtmsy3FICXuZQINegYgK8rKIv3j+LW1gBJ5DaEcwpLyZKJ a36YrHWwlr8nLTZJDgzAkife1AMxnYf85y7ixG0Z35b/Qzf3NOBHrlk1ZSQLV+E5tVNx1tLCAb0 BTPFR4UmWCII/V/1PZi1WYnisz9Qd7nRKsluM6dlqDqHXJyGPVL/NEkRoCAQsKJLIj033FyjjLk /sYXgK6WK/ZGixliLekvcpYCo18GMG8YazobK0KsSEc9mWHaDZ5eo4ULOwFlbXIIY/Z69JmaNbr 8NFY1qbv8lmR3TZHUCOw+N8n1gUeqFurnhJO8PU26C1Iwk6AwKl3EdNTy0638Sgj34owQEAjYiI PwDwYE9OtO8t3lC7dkCGccb+R03g+XH79Zv+MJ1B+ztcx+rdXaXAEgeannO5+LEmsGGOv3spiDw 9268LBZiM2satZQ== 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 Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- MAINTAINERS | 2 + drivers/media/v4l2-core/Kconfig | 4 ++ drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-isp.c | 114 +++++++++++++++++++++++++++++++++= ++++ include/media/v4l2-isp.h | 91 +++++++++++++++++++++++++++++ 5 files changed, 212 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index bbc92829c3c413de7d7ba77f182a6916728b1a8c..ce57cf3774f6270bfaeffcea8fa= 63bcbd0a90dbd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26415,6 +26415,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..0ae840e16b4710c350fd8671de8= c1663d3ea1e26 --- /dev/null +++ b/drivers/media/v4l2-core/v4l2-isp.c @@ -0,0 +1,114 @@ +// 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; + + /* 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 Sun Feb 8 00:49:43 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 A918C21D58B; Tue, 7 Oct 2025 18:12:40 +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=1759860762; cv=none; b=C6seALin1NweE/6ZGJWlRqgwPTSv7/zyq7Q0+7VafExjcq9gAMUJWOemJvZWbSV9xlbW9+3ATWDcRaQ9wXqaY8A7StAZNWdfx/5qefZlkfGkJGQNsM1QYVyi20EOopZZ7N3ysQxyX1ifP+ecFuHw7eH/23Tw/uJ2W7UVJUsVl6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759860762; c=relaxed/simple; bh=CMSnpKWFm8f6XNXGl5yxfM39oQyAVrbdQCzRsiilxxg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TtH6hWiIt8IIRUhRhlAV4LF5bxekU0QikMlXJAMWjkKy01xe7Tm9SxdzkJdLXDY3l83/dO5eocHy6cOar5t10nFHotDTfAfMUU+1KyhcL+dd4LuK+CxiSmMQqTlxWQV8KbERJBMAgNJdv0vxKsd2ywmaumsQYZNlaGE6+MqOlLY= 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=ZAQCMMou; 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="ZAQCMMou" 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 74FD2EBA; Tue, 7 Oct 2025 20:10:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1759860657; bh=CMSnpKWFm8f6XNXGl5yxfM39oQyAVrbdQCzRsiilxxg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZAQCMMoumIqaa0eEy06lC3j0q9xyq7A7NqBgu0hL9OyZMxdANWiMz1inSmugkstUy Vva2VfrRSp2+1ICVI4Kfghw8bRYtIvbVnQMiUl4dbm/laYNnR+yQTIYIPOzIkbgoKL ULxx66FNnBtA9efzwbwymngLymFASnjp9l9M0p5M= From: Jacopo Mondi Date: Tue, 07 Oct 2025 20:12:15 +0200 Subject: [PATCH v6 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: <20251007-extensible-parameters-validation-v6-6-5f719d9f39e5@ideasonboard.com> References: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@ideasonboard.com> In-Reply-To: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@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=12850; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=CMSnpKWFm8f6XNXGl5yxfM39oQyAVrbdQCzRsiilxxg=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo5VgHH/oMp1C7/8X/Ms0vwkM77ZZ/iX4ZUsw/0 NCl4zpm+O6JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaOVYBwAKCRByNAaPFqFW PC3LEACn7xuhDwTCrhW+XxCaUFEPQ7Tyq8neeaQ9/IF6huMiSKT0FA7VFXSBjdoLjpRazE6le3I TvgFJUJzl+CxxMQzZzIrF+j5oJG5TEUMO+MRRzmxQYOwoACs2jGcYZBBYwpQXS6DWpmwhlWYStK OfIwj7LnUCYtvCVYS3YL1zMwcdn/q9pEL+4fbrtW2iYKvkGd5T5Dz32MakB0bO6MqnDzOy53JXn vnoim0ilTk2CqGIkqZfWkpkTyNTdsCr02O74Ul7LNZ9XAKOkK0n3DHrlkOVE3iDSTahHxhzeDU7 OcifPCz8UjEOjMA8sSNB3iIMC3AnigqGYCx795kLkHcivxGHaGvKJDnIfm10J9FW/dY2xJcH5Tu bHJhbsOZKHqqfY5qawrLBQE9TsraPnDyOsrAAHIV8O4Kq6XQoStpkRVyr79RhYkP2ev2nc0tg8C +z6paJpti7yAXS7sfINzMJOAzmbWUzDQYpvDHrLvxlqc/a3bZqEPpiP0rm1zITpgqVOqDurZm+9 eZmQdbDmt5DoECUF1p6uq6RajCYpOdN8fedVKd0SjiRp5W0KGsnlu0bR2nRDQn3WrtZ9tqrdjEy b1jLXLCtMYgxbdzElKNdNfH7AW5B8fvOJWe1nJpZgWso17vZ/cWbo2xPFPWK6kdzvC2o2FdEhzE ZHCeW6CLEFjUQEA== 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 Signed-off-by: Jacopo Mondi --- drivers/media/platform/rockchip/rkisp1/Kconfig | 1 + .../media/platform/rockchip/rkisp1/rkisp1-params.c | 183 +++++++++--------= ---- 2 files changed, 81 insertions(+), 103 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..7946adb1c7f322042d39a269715= a674ce347794f 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,24 @@ 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; + int ret; =20 - /* - * 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) { + /* Only v1 is supported at the moment. */ + if (usr_cfg->version !=3D RKISP1_EXT_PARAM_BUFFER_V1) { dev_dbg(params->rkisp1->dev, - "Too large buffer payload size %zu\n", payload_size); + "Unsupported extensible parameters version: %u\n", + usr_cfg->version); return -EINVAL; } =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 +2716,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 Sun Feb 8 00:49:43 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 C264F2EA46F; Tue, 7 Oct 2025 18:12:41 +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=1759860763; cv=none; b=o6Azl5uRcxsp2QZZYNz6RccL3faRKRGP5CHnalYWFD4cw/s+0uWmZR+3jx8T35kAChKJrrdA58+TXfUfsTRLhHhi7n+zv6Jy7WeDEu7vI/eG9UI7kSChut8U+2x+mcfTXMIcD1BVxCTgGfbDQLHXdZzdCxTF/VNuBIre+dr7VW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759860763; c=relaxed/simple; bh=jIJYy3RpHeSZ4gcjU37lge3RwOH4+fCoxiq+QmxKE0s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J0oj8WJYomwucs9tQxpD/YlqiCpbBXQcqrl1cmJ6NhsvUFguBcKCxdf7/y8Ui1v3649JruAHFSi0W2KqmQgVycgzZGu8oi6VDKn1z4jKVL75d8Eoz+zwE6ZxJPkwr1WlTnsCAhH9qHhz60JcD4PGskaHn580kc9wMetD1gp9Q1A= 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=U6Ft1Ogs; 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="U6Ft1Ogs" 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 488F51122; Tue, 7 Oct 2025 20:10:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1759860657; bh=jIJYy3RpHeSZ4gcjU37lge3RwOH4+fCoxiq+QmxKE0s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=U6Ft1OgsJAfOI6mEHDL7XEqFwSGFxtR6ytJlz9FcVofXVvGGwphBStXTvAk8Eri1S ocNIktFf+HJttTXcWQ/Rq2OaZDl9X/90qtTgJoTB1bQ8+DSvNPgQjaaHesHrefU7Pu LFcd5SMz05ZeHFyDDOH9TMYD2yDi3eRW0zV07PcQ= From: Jacopo Mondi Date: Tue, 07 Oct 2025 20:12:16 +0200 Subject: [PATCH v6 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: <20251007-extensible-parameters-validation-v6-7-5f719d9f39e5@ideasonboard.com> References: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@ideasonboard.com> In-Reply-To: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@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=8312; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=jIJYy3RpHeSZ4gcjU37lge3RwOH4+fCoxiq+QmxKE0s=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo5VgH8uf8WBJb9o4fwEmUn5Wh09PLkgoKfKeaW HpTgXW7CXaJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaOVYBwAKCRByNAaPFqFW PGQOD/9DMnT53okXZYfpatc2q/ixPhhiPwUbPzM8nWAzkMP4CVREHoA11ZHyzRGtdcv0mxrwUoB YSuB8Km3e7bqvJlnjWqwxt6G1OVJ5JucCQybMrH944MBCUXQ/PB9F1+R1fN8lqFRYMu/iSJcNAc +2e3YB8+IdSIlnvVCTJQ7FTAJSgpPtXoc5LX7FyyaXFsYbGsryWqMAj9p0XeDn3Hlpct9Auu8Ny wr+ToXBfBPFnNXyj7TDkw4BRk319Wnd6VsOsYCIfUZ7WRT1ISGYpQxvFSChZkaAmhn5zM6x53KE 4d7Wa5LOaZ2rpz3Nq0RhIam+OBnA9p04KOX4oCrnDhwwSkYpSUEaXSV2VkYjLYVPUcThxe33lm4 /nSAL6uNkpriPl2kQ/q7dAQpEToaDkUQQa8nR4ScnKfokymZe/KRZILOC5c8iGvZL9E5A9ttdzw iln0oxiNUQP7TI6N3ncPs7oawSioUXeD1h9/c12RKiRLllQO6L3PVGA1++lr2SWZ5DeeLQoSK0d SCSyEnif55NfZuMlTODShh4CvAVbz1UrN219DuhD99bpXcIjaIjhfN7N2IQ2gqXdaXQ4G6GqbwU jd8i3sB4W+zrRGviO640FMNhz46k78//ylDMY43uT5OBSoB6p7Jb24TAMi/SUm9Hsre4N2KnqiZ MRIS6/KKVxX/BrA== 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 Signed-off-by: Jacopo Mondi --- drivers/media/platform/amlogic/c3/isp/Kconfig | 1 + .../media/platform/amlogic/c3/isp/c3-isp-params.c | 125 +++++------------= ---- 2 files changed, 31 insertions(+), 95 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..408a7b0137cf889d6a7e027b1fc= 23402fad52df4 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,22 @@ 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; + struct c3_isp_params_cfg *cfg =3D buf->cfg; + int ret; =20 - /* 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); + /* Only v0 is supported at the moment */ + if (usr_cfg->version !=3D C3_ISP_PARAMS_BUFFER_V0) { + dev_dbg(params->isp->dev, "Invalid params buffer version: %u\n", + usr_cfg->version); return -EINVAL; } =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 +793,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 Sun Feb 8 00:49:43 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 4B4BC2EA730; Tue, 7 Oct 2025 18:12:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759860766; cv=none; b=V62p2t2VmdsfAPCwM40o632M1xHQZ5AGCuGseJPHl0f5n2xW57KDcHG7miAoEwou7+I/gqmAxkwlrIc+arFAER0s0/SqY5R6HSgOopsRkzIFf6wAZFOhGd7cV8KCMo6EHMPZXfLU7YJZfpIU3h5fhizqVCRXoljvUem0wztysnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759860766; c=relaxed/simple; bh=fRNAq+7Vwl4fQf6vUPlq/4N8C9MKRnK183sb4wt4bYA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WP/dvZ9K/DaBk7Cm62PJsGOWwrxfNAqYmL0SHfBPMnyEAUNuL0fuqtPF998tPFfTUUMmCo+A1mRltnnXGs4oNjuz2TRNX9gPAVpI2YnzIKpzR7p34KS4ikkaHLueYXOfjo/LD1GRSK0WHN4afzwk8N6lQFmDieTpU66yNJQ9d/s= 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=SnzNFG4Y; 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="SnzNFG4Y" 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 2FD11176E; Tue, 7 Oct 2025 20:10:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1759860658; bh=fRNAq+7Vwl4fQf6vUPlq/4N8C9MKRnK183sb4wt4bYA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SnzNFG4YPniiEOt0x1ZOG/nQenfRyoxwc3wvuk96Q25nSXihj1g/y/pVkIRDObXWv 6tCQ/nPy9R+7D5hXnR2XWzoYsoiej4vpPs4880lsEFutWATUQyNR2KkJ0bzqd97NCQ D9+shzw1qHdjddq4KFJgjGmARFuksQkcSu2ZfkQU= From: Jacopo Mondi Date: Tue, 07 Oct 2025 20:12:17 +0200 Subject: [PATCH v6 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: <20251007-extensible-parameters-validation-v6-8-5f719d9f39e5@ideasonboard.com> References: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@ideasonboard.com> In-Reply-To: <20251007-extensible-parameters-validation-v6-0-5f719d9f39e5@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=4037; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=fRNAq+7Vwl4fQf6vUPlq/4N8C9MKRnK183sb4wt4bYA=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo5VgI0xwJGet2PlIF1bFPXELitwqxSqG/wm5Hq ap8bvh9LpiJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaOVYCAAKCRByNAaPFqFW PMrHD/9urGh/V7FTx039JFkbeV+uzEENfmfp1T/iAziV4l0Od0YI3HoiqZb1lcoFIaITXiVNAAr I8NoecyNdI7D5zoX2NtS7oP25sA1N9Y90BMmxq9bxUwthJLkK9wET4fmA92G6EEQQ5v4MXoZ0UB j/dArouVAkAn7bS2mYNhJObclv4FnyxXzizJea+baEQ6ZFy0oOCdYjwn8IUdvac/+APINGM5QYG sqlxAfQS0wotcywyxoHn+N/v2Qsy+hQK1jrHhUgYoafjk+B2xBJEfpD8S7g0aa+gRav0O5iXJU6 erNEt1gROljj6O03TznmHMxez0820oy3Gi5igjOAVf0b68jFLoLqMMqfptjuZLZkDzksJiZ7Xv0 4tt9X32gijv5T26PBj6blkSDIXjAPDxi8FgNZLJr+8uKZ51uw/A0KuKEYHj4GmRje7hmiU+0SOB BqCLGwrPOhBTxgVU1xysmK1K4TP4VuNwk9JURCzx2d4dYirKHg2DDfLeKFBZHDdzUJEyVOJDUKA oRCW5j1bGBFt7d6j7WLhiCkb7ybVYUpOYSP9YCfF5Spy2Ki1YBS1t5V3lL9L/Jsc/qQD7S3KpmQ koKdjSiSun4YfuLHjf2QHzRvU0CGUDDbLuq5MAquOMETr8jdBBJB7JzmD1j39n/+wMudjkb6ZVa tC1NXOXKr338zSg== 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 Signed-off-by: Jacopo Mondi --- Documentation/driver-api/media/v4l2-core.rst | 1 + Documentation/driver-api/media/v4l2-isp.rst | 49 ++++++++++++++++++++++++= ++++ MAINTAINERS | 1 + 3 files changed, 51 insertions(+) diff --git a/Documentation/driver-api/media/v4l2-core.rst b/Documentation/d= river-api/media/v4l2-core.rst index ad987c34ad2a8460bb95e97adc4d850d624e0b81..a5f5102c64cca57b57b54ab9588= 2b26286fb27de 100644 --- a/Documentation/driver-api/media/v4l2-core.rst +++ b/Documentation/driver-api/media/v4l2-core.rst @@ -27,3 +27,4 @@ Video4Linux devices v4l2-common v4l2-tveeprom v4l2-jpeg + v4l2-isp diff --git a/Documentation/driver-api/media/v4l2-isp.rst b/Documentation/dr= iver-api/media/v4l2-isp.rst new file mode 100644 index 0000000000000000000000000000000000000000..42c2550602979609e92a09e3cd1= fe3dcbafd6416 --- /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 capture format for parameters and +a metadata output 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 facts, that after the first accepted revision of = an +ISP driver the buffer layout need to be modified, either to support new ha= rdware +blocks, fix bugs found later on or support different revisions of the same= IP. + +Each of these situation would require defining a new metadata format, maki= ng it +really hard to maintain and extend drivers and requiring userspace to use a +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 buffer layout= 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 the form of helper +functions 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 ce57cf3774f6270bfaeffcea8fa63bcbd0a90dbd..ea3ef6544b44df404edcf7926a2= 802d63f0a40de 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26414,6 +26414,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