From nobody Thu Oct 2 15:15:47 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED89E2BE043; Mon, 15 Sep 2025 17:18: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=1757956723; cv=none; b=NwSGy1PzqZKU+uN6omCu/obvvXMSsvQfyOxYN7enuATFRsYS/hgNQtbddRWu3PtCQzK+e4TD4HGcha3wX+HOKZ/p57IwapPQJ3MASRnW3B0TiHT/HB8xgmEshVS0e+VVPbRBDRjkr0kbzKebtWg395FfOPPJE9xg2K/YDDsK9nw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757956723; c=relaxed/simple; bh=+cN0Nkg4synqsjTMriyb7/FljLTMktP0+zGLZo/1hjk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gJ40puJ7/Racy6qDq0oahlM/xzU+O5iRr3GfZcPLRCU7xVuHArNGK7jTPsF90LGwXQEV7CukkMkSmUI8VUinAxFWXbTExWiEpuIzwGfpAa0/GpNmrIvCGXRTZeZMCOqPICRcZsZqEVgGrgyJnvNGaCK9gXUhvP0Rjr3qsyxrocc= 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=g2vN5oih; 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="g2vN5oih" Received: from [192.168.0.172] (mob-5-90-56-182.net.vodafone.it [5.90.56.182]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 62D571189; Mon, 15 Sep 2025 19:17:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1757956640; bh=+cN0Nkg4synqsjTMriyb7/FljLTMktP0+zGLZo/1hjk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=g2vN5oihFVCOz5jVLtWhN5k4dRsDVYNxb35Cemiw9e19kh9y82aKJWvWhwzRHMvRW wTy1FmZXWLuTkYFvM0F9uCSMcnkMLY7W50iZmKMUgFixq/UQZuqDTpg3EVH0Zc8M+p VlpI8EQ06kGMvBAGNrnKghcgRUgOhmNtaVWc1+f8= From: Jacopo Mondi Date: Mon, 15 Sep 2025 19:18:11 +0200 Subject: [PATCH v5 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: <20250915-extensible-parameters-validation-v5-2-e6db94468af3@ideasonboard.com> References: <20250915-extensible-parameters-validation-v5-0-e6db94468af3@ideasonboard.com> In-Reply-To: <20250915-extensible-parameters-validation-v5-0-e6db94468af3@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=7688; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=+cN0Nkg4synqsjTMriyb7/FljLTMktP0+zGLZo/1hjk=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBoyEpp9AYbOOetgJMFAr+UmQHggPsgRFzpGIcSe pQW65Htmb+JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaMhKaQAKCRByNAaPFqFW PPwxD/sFecl9kiDsc9xT3r4NpLVKSKWR1eJjTuL8hg9XPerpCs0e+864C9bZQEfSLLpoC5ng1Uf koF5obB5jSLwLZH1OfPCq4ojZrPluMrXDbfLpMUbvwS7IOeEElIOMAWREHI9GbNqH3FczJwtI5U ORz50BxgP1eeh5S7Ou3ZpB0+FhYlrZcnSfYew5cQ+PGiVqFuFbr1cesAaAGF2thlD+himFFRv0E pexk0ZEokAkDkARzAeURfo190bvwzCSF710Q+9e1WpDL8zYLwtNCY28N1cBPR7VEgsqHc7srGXC 1sH8RfLfybm7joc7TwQDGorc8nz5KWyBgtv1iClffHphNjjMgQcIznc83uYGnWpxxbENmhngGVO ux8kLZDt/A6U3I0Tt9WVyPhwNj+fHV1NcJr4hY7fGWnjgvGctQulHF6U9ipbPf3QWKJcbpY9KsE 3ydV2u+5+H1HE9K8cLCkdz785qkE4lc5OF8fa2Ek7OTTbgYqz1LFg0SwD5uc93JBsm1kb2K2iKe cSbppFWcoW7cX+CkBxMnhmM6TbK/8mgC2bbWEuUNI50gdrVpYiGhdFoGSozJJ8xB9Ma1tJ2EcyQ j8juHR1Bi70YwXRAsBBSIlPTqCPcS6nkxKBc7GYAP2jb4FDNIdvM4otMVqPIBh6Bl25nxG5KKdN pUuAVGbzSN0SxUw== 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 --- include/uapi/linux/rkisp1-config.h | 104 ++++++++-------------------------= ---- 1 file changed, 22 insertions(+), 82 deletions(-) diff --git a/include/uapi/linux/rkisp1-config.h b/include/uapi/linux/rkisp1= -config.h index 3b060ea6eed71b87d79abc8401eae4e9c9f5323a..b90d94d3a852fb0af0fe4476494= 87e9e80aca795 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_PARAMS_FL_BLOCK_DISABLE +#define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE V4L2_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_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_params_block_header =20 /** * struct rkisp1_ext_params_bls_config - RkISP1 extensible params BLS conf= ig @@ -1594,21 +1546,7 @@ 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_params_buff= er`. * * 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 +1562,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 +1611,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_params_buffer)); +#endif /* __KERNEL__ */ + #endif /* _UAPI_RKISP1_CONFIG_H */ --=20 2.51.0