From nobody Sat Jun 13 20:56:12 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 5C34A47886A; Tue, 5 May 2026 14: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=1777990364; cv=none; b=U1tfcbiEdj4LE2tlE1m6bqBdsbP2pNrvVlNPXD0YdgfhLmlTU53pCKlI0iH4+C5dAsXCBtf+0jBqNHCcaXU1ERe7JTa+BkHpQMOGPcNV8VCMU+SMATY6HJvCnzr7QiqUpkjPX/MHAwBaB/00YGWut57HPnpVVY4LzhBN22AppRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777990364; c=relaxed/simple; bh=LRf2P2Yp3G9LI6eOo1E5UnmDigQDKrKdASOmK21O+k8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WMoOoshXYte/N6QfXADmDyBZ5tn46RyBIa178E7PzVGDau1WtRIs5lk9g4ys44H88v4zFMbDobQAL6kDHZruD6MoSn2sHLs04xHP1B0p5b7a+NynHQkvb9jUX5kNoMyM566198LX4Ro11TFPQBAJWYcCOZhExNtJkrr23EgqGRU= 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=D23akZBN; 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="D23akZBN" Received: from [192.168.1.83] (unknown [IPv6:2001:b07:6462:5de2:520d:d7a3:63ca:99e8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EE5C9CF5; Tue, 5 May 2026 16:12:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777990355; bh=LRf2P2Yp3G9LI6eOo1E5UnmDigQDKrKdASOmK21O+k8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=D23akZBNXy2MvR0xPhoM3HznyDzxo6inX3Rn5aVMBjz+UYXjpHFzfpWBtBplex40Q +din/BjU+plUWak05QThlzjNBPyMQ/qYR05kkySWzTIv3JUaGfTm+QT9o0nQz1fCYH 0DmV8PcSSsXXdqfeHkEjCCFK3Kb4Vpgb2Nr7HzBU= From: Jacopo Mondi Date: Tue, 05 May 2026 16:12:12 +0200 Subject: [PATCH 1/6] media: uapi: v4l2-isp: Add extensible statistics 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: <20260505-extensible-stats-v1-1-e16f326b8dad@ideasonboard.com> References: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> In-Reply-To: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> To: Mauro Carvalho Chehab , Daniel Scally , Keke Li , Antoine Bouyer , Jai Luthra , =?utf-8?q?Niklas_S=C3=B6derlund?= , Ricardo Ribalda Cc: Laurent Pinchart , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=9161; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=55DjFZFYN639/R9D++B4U/hE0NeYkRpq4Y9eKFWsgd4=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBp+frT4HJrAZukmCANA4Lo3RU5EhQSkHAU51Bto e0nLLOAwNqJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCafn60wAKCRByNAaPFqFW PCRvD/44vA95refpOUJWSTKyKHhxo3OOSg2AS4t8MwGnQvAdTgKPgeLuMGMtv5sd3lEyu08Dn74 9cyxoO/iY4M4IfIz++En5368Jq+Yn5GYsyYstRysb1ZkbcMjnemRqbxoHk7qlgnxGKSCygOJ88/ E47oEjnhhPkXQtBdzJkhODiaGS4wgwojHDZSCfkZa3+8Roywzz7H8ZrCLert+XFcqc5Bd8zUjgT VvUeKYPPGtdC7SvVfXNj1+GlBwH0rgz1dcv1KY0ozRHHq9FB4pAa4xn3orkD0E4L1URLweSp9AK TqdH88u7PQQ5HotEPZ/PvdYoeHWdyc6COqM4LXHRyErP7zCSQ6bdGmYYeV+cp9GdEPfyM7Zg9cv jJNzdEyVTveCrM2d3iqq7zRznVSTFG8/qU+iM7ueTMN63p/0YhicSGbQ2MVBCrYLCABzeIyLhqq da3aRySZtmusRuE+VlrjOeFhoxQB1DjPPup43noidxTHjCeCtCA2G3XLYFKqWqUdZAtleWAP6Qw eGP5OH3ZRB68C4BxRu3K84vuAT84wm6KaW/7t3t8pF9gFmgkK4UV9ItMA9AK9+O8LYG8u0gV7aO fMEojN1X8X4F3bNlwtoKfrPvEyVMdaPHM+kzrl2IQzMkmD0xP4s2VzM0THTfHjas/PtmJylQWbS rpmpIuQ+XDyzYWg== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B From: Antoine Bouyer Extend the v4l2-isp extensible format introduced for isp parameters buffers to the support buffers of ISP statistic. Like for ISP configuration purpose, that will help supporting various ISP hardware versions reporting different statistics data with less impact on userspace. Rename all 'v4l2_isp_params' types to generic 'v4l2_isp' types to prepare to use them for statistics as well and maintain the existing types for compatibility with existing userspace only. Signed-off-by: Antoine Bouyer [Rework to remove 'v4l2_isp_stats' and unify types] Signed-off-by: Jacopo Mondi Reviewed-by: Niklas S=C3=B6derlund --- include/uapi/linux/media/v4l2-isp.h | 125 +++++++++++++++++++++++---------= ---- 1 file changed, 79 insertions(+), 46 deletions(-) diff --git a/include/uapi/linux/media/v4l2-isp.h b/include/uapi/linux/media= /v4l2-isp.h index 779168f9058e..e4607e1217e1 100644 --- a/include/uapi/linux/media/v4l2-isp.h +++ b/include/uapi/linux/media/v4l2-isp.h @@ -13,25 +13,33 @@ #include =20 /** - * enum v4l2_isp_params_version - V4L2 ISP parameters versioning + * enum v4l2_isp_version - V4L2 ISP serialization format versioning * - * @V4L2_ISP_PARAMS_VERSION_V0: First version of the V4L2 ISP parameters f= ormat - * (for compatibility) - * @V4L2_ISP_PARAMS_VERSION_V1: First version of the V4L2 ISP parameters f= ormat + * @V4L2_ISP_VERSION_V0: First version of the V4L2 ISP serialization format + * (for compatibility) + * @V4L2_ISP_VERSION_V1: First version of the V4L2 ISP serialization format * * V0 and V1 are identical in order to support drivers compatible with the= V4L2 - * ISP parameters format already upstreamed which use either 0 or 1 as the= ir - * versioning identifier. Both V0 and V1 refers to the first version of the - * V4L2 ISP parameters format. + * ISP format already upstreamed which use either 0 or 1 as their versioni= ng + * identifier. Both V0 and V1 refers to the first version of the V4L2 ISP + * serialization format. * - * Future revisions of the V4L2 ISP parameters format should start from the + * Future revisions of the V4L2 ISP serialization format should start from= the * value of 2. */ -enum v4l2_isp_params_version { - V4L2_ISP_PARAMS_VERSION_V0 =3D 0, - V4L2_ISP_PARAMS_VERSION_V1 +enum v4l2_isp_version { + V4L2_ISP_VERSION_V0 =3D 0, + V4L2_ISP_VERSION_V1 }; =20 +/* + * Compatibility with existing users of v4l2_isp_params which pre-date the + * introduction of v4l2_isp_stats. + */ +#define v4l2_isp_params_version v4l2_isp_version +#define V4L2_ISP_PARAMS_VERSION_V0 V4L2_ISP_VERSION_V0 +#define V4L2_ISP_PARAMS_VERSION_V1 V4L2_ISP_VERSION_V1 + #define V4L2_ISP_PARAMS_FL_BLOCK_DISABLE (1U << 0) #define V4L2_ISP_PARAMS_FL_BLOCK_ENABLE (1U << 1) =20 @@ -39,64 +47,89 @@ enum v4l2_isp_params_version { * 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 DRIVER_SPECIFIC_FLAG0 ((1U << V4L2_ISP_FL_DRIVER_FLAGS(0)) + * #define DRIVER_SPECIFIC_FLAG1 ((1U << V4L2_ISP_FL_DRIVER_FLAGS(1)) */ -#define V4L2_ISP_PARAMS_FL_DRIVER_FLAGS(n) ((n) + 8) +#define V4L2_ISP_FL_DRIVER_FLAGS(n) ((n) + 8) =20 /** - * struct v4l2_isp_params_block_header - V4L2 extensible parameters block = header - * @type: The parameters block type (driver-specific) + * struct v4l2_isp_block_header - V4L2 extensible block header + * @type: The parameters or statistics block type (driver-specific) * @flags: A bitmask of block flags (driver-specific) - * @size: Size (in bytes) of the parameters block, including this header + * @size: Size (in bytes) of the 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. + * This structure represents the common part of all the ISP configuration = or + * statistic blocks. Each block shall embed an instance of this structure = type + * as its first member, followed by the block-specific configuration or + * statistic 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. + * type. The @size field specifies the size of the block, including this + * header. * - * The @flags field is a bitmask of per-block flags V4L2_PARAMS_ISP_FL_* a= nd - * driver-specific flags specified by the driver header. + * The @flags field is a bitmask of per-block flags. If a block is used for + * configuration parameters this field can be a combination of + * V4L2_ISP_PARAMS_FL_* and driver-specific flags. If a block is used + * for statistics this fields is used to report optional + * driver-specific flags, if any. */ -struct v4l2_isp_params_block_header { +struct v4l2_isp_block_header { __u16 type; __u16 flags; __u32 size; } __attribute__((aligned(8))); =20 /** - * 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 + * v4l2_isp_params_block_header - V4L2 extensible parameters block header + * + * Compatibility with existing users of v4l2_isp_params_block_header + * which pre-date the introduction of v4l2_isp_block_header. + */ +#define v4l2_isp_params_block_header v4l2_isp_block_header + +/** + * struct v4l2_isp_buffer - V4L2 extensible buffer + * @version: The extensible buffer version (driver-specific) + * @data_size: The data effective size, excluding this header + * @data: The configuration or statistics 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. + * This structure contains ISP configuration parameters or ISP hardware + * statistics serialized into a data buffer. Each block is represented by a + * block-specific structure which contains a :c:type:`v4l2_isp_block_heade= r` + * entry as first member. * - * 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 + * When used for ISP parameters, userspace populates the @data buffer with + * configuration parameters for the blocks that it intends to configure. A= s a + * consequence, the data buffer effective size changes according to the nu= mber + * of ISP blocks that userspace intends to configure. + * + * When used to report ISP statistics, the driver populates the @data buff= er + * with statistics for each supported measurement block. + * + * The buffer is versioned by the @version field to allow modifying + * and extending its definition. The writer shall populate the @version fi= eld + * to inform the reader about the version it intends to use. The reader wi= ll + * 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. + * For each ISP block, a block-specific structure is appended to the @data + * buffer, one after the other without gaps in between. The writer shall + * populate the @data_size field with the effective size, in bytes, of the + * @data buffer. */ -struct v4l2_isp_params_buffer { +struct v4l2_isp_buffer { __u32 version; __u32 data_size; __u8 data[] __counted_by(data_size); }; =20 +/** + * v4l2_isp_params_buffer - V4L2 extensible parameters compatibility + * + * Compatibility with existing users of v4l2_isp_params_buffer which + * pre-date the introduction of v4l2_isp_buffer. + */ +#define v4l2_isp_params_buffer v4l2_isp_buffer + #endif /* _UAPI_V4L2_ISP_H_ */ --=20 2.53.0 From nobody Sat Jun 13 20:56:12 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 2E9E248032F; Tue, 5 May 2026 14:12:46 +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=1777990368; cv=none; b=mDrjZFqiAd3HJYluZnwjCYhZZFvUobRseXonY/4uE+3+vC6o0bP8fOZhXgUPY9SzPRdQRpODfJXunyBuuqaavPK5e1XFAv/GW1rZt6ddNjxgMBZRjmeCGGwYvMH8rn4YqE9nngsyxloDESy5VSxm84qPIMcq+eEv/HhG71ChpwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777990368; c=relaxed/simple; bh=6cpwZlYBX25LxZlVKKxAzE8ienKp5EIXWJ0alPjFWO0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=q+hJwH5jwWvYQuG8cPDWQXNF/jhV6YZaMwx8BvSohWL29wbgSe3XKyMVQjuVI3lvRBuP5yOFsuVPE9r+wOCvBvdb0CpKUEMNzhF+85oaLUEyaC2Exq5z6nfLdrgEHIv13RJhupcFSby6C+dqCUFRK7kbpU5S8dVtSf+DPfb/mdM= 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=r9fK/Usz; 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="r9fK/Usz" Received: from [192.168.1.83] (unknown [IPv6:2001:b07:6462:5de2:520d:d7a3:63ca:99e8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DBE341121; Tue, 5 May 2026 16:12:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777990356; bh=6cpwZlYBX25LxZlVKKxAzE8ienKp5EIXWJ0alPjFWO0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=r9fK/UszoDf5or5mcWna9IttkBeY/J9JrNUDgnvZgfhaOmQkRvl5ZQMcygME6q3+C DThsxedbURTEZ4swqqrIA+VBOszSsca4tHFcGoWC7RtvfyjL757ZhGox0C5vxWl9i1 8cR8PvkB3PZ1e12w7X5cXTbEzCQnZc3g9oICu4Vc= From: Jacopo Mondi Date: Tue, 05 May 2026 16:12:13 +0200 Subject: [PATCH 2/6] media: Documentation: uapi: Update V4L2 ISP for extensible stats 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: <20260505-extensible-stats-v1-2-e16f326b8dad@ideasonboard.com> References: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> In-Reply-To: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> To: Mauro Carvalho Chehab , Daniel Scally , Keke Li , Antoine Bouyer , Jai Luthra , =?utf-8?q?Niklas_S=C3=B6derlund?= , Ricardo Ribalda Cc: Laurent Pinchart , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4275; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=FjWOxxtsPzgrK1twE+7vwZ0Gd7DpMY7KtdZmVJPZXUc=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBp+frTNWKRrAxUy6GsyyPfHamSHH2RZbEp9QVo5 ByVHW6NkKWJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCafn60wAKCRByNAaPFqFW PJncD/9EBmK1fSgSGP7/1mBXxYcTH837Dcw4KgGowxEHKlLAPKRNXrjDv5JmvdvQJ2apg1ew6c5 9WXrqzCxjwA9JLXlWNZHTQbxiNgBZhwsLAmi0EodybmbMiqNl8E+rl70/ylfpUUTGbITmenY0bm Cf6dAEirBXt6P8mvCCtbFj/atoc8+f3h8jhvJugdqya7+fSpJTYwxnrBLo+JKrMhtEsyMw6w2nY GrkzcEtu9zRxR0bLcKpR7PRGnIRC8R81sMvs2jIJlB/sobJSIsavEzZXCwhJm80EGg/yAh5XKPU cd2I7i8/cGN0UEbikUTgtsaulN/i9IIPOfCWg9BTyAMYkUDURFkmto65EBI0JGvF+knhtSHTBgm L3tQbs+0LV8BE4D36E8mGrcyq06GNAc2XV35HTmVcepeHeGE+8wTZIKkVY10+st2yeEaet7H7Mp tUDbEHGWDVQtlz8P0JZSICfDpHyf3JN3Z+gF4okTkDd79w8NLQlZBH4IUQIRTUlv2tvpSCAsfEb qJasJSs7l1j5PyPjl63GJ/ZlWCqzYe6BEry2V4wDpBI2eSNbw9CPj4X/qhXfFTHkj/gkvdGN4Ok ukPgDRoRixcj8947SNh7s8u/fzW/tc2WHdEWAwbp006CsP3JRfPoH6NpHjhSBISBk64hg2CdhHm zQ9IYVT2gC57tVQ== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B From: Antoine Bouyer Rework the userspace-api documentation of V4L2 ISP to support statistics. Update all occurences of 'v4l2_isp_param' types to match the uAPI changes and add a section to document the statistics serialization format. Signed-off-by: Antoine Bouyer [Update on uAPI changes] Signed-off-by: Jacopo Mondi Reviewed-by: Niklas S=C3=B6derlund --- Documentation/userspace-api/media/v4l/v4l2-isp.rst | 45 ++++++++++++++++--= ---- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/v4l2-isp.rst b/Documenta= tion/userspace-api/media/v4l/v4l2-isp.rst index facf6dba1ca7..8a3f05b5e85f 100644 --- a/Documentation/userspace-api/media/v4l/v4l2-isp.rst +++ b/Documentation/userspace-api/media/v4l/v4l2-isp.rst @@ -18,22 +18,22 @@ single C structure that contains a header, followed by = a binary buffer where userspace programs a variable number of ISP configuration data block, one = for each supported ISP feature. =20 -The :c:type:`v4l2_isp_params_buffer` structure defines the buffer header w= hich -is followed by a binary buffer of ISP configuration data. Userspace shall -correctly populate the buffer header with the generic parameters format ve= rsion -and with the size (in bytes) of the binary data buffer where it will store= the -ISP blocks configuration. - -Each *ISP configuration block* is preceded by an header implemented by the -:c:type:`v4l2_isp_params_block_header` structure, followed by the configur= ation +The :c:type:`v4l2_isp_buffer` structure defines the buffer header which is +followed by a binary buffer of ISP configuration data. Userspace shall cor= rectly +populate the buffer header with the serialization format version and with = the +size (in bytes) of the binary data buffer where it will store the ISP bloc= ks +configuration. + +Each *ISP configuration block* is preceded by a header implemented by the +:c:type:`v4l2_isp_block_header` structure, followed by the configuration parameters for that specific block, defined by the ISP driver specific data types. =20 Userspace applications are responsible for correctly populating each block= 's header fields (type, flags and size) and the block-specific parameters. =20 -ISP block enabling, disabling and configuration ------------------------------------------------ +ISP parameters block enabling, disabling and configuration +---------------------------------------------------------- =20 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 @@ -59,7 +59,30 @@ definition without invalidating the existing ones. ISP statistics =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -Support for generic statistics format is not yet implemented in Video4Linu= x2. +The generic ISP statistics format is identical to the generic ISP configur= ation +parameters format. It is realized by defining a C structure that contains a +header, followed by binary buffer where the ISP driver copies a variable n= umber +of ISP statistics blocks. + +Extensible statistics buffers have :c:type:`v4l2_isp_buffer` header follow= ed by +a binary buffer of ISP statistics data. ISP drivers populate the buffer he= ader +with the serialization format version and with the size (in bytes) of the = binary +data buffer where ISP statistics data are serialized. Applications shall +validate that the serialization format version matches the expected one an= d that +the buffer size doesn't exceed the maximum size for a statistics buffer as +declared by the driver's uAPI header. + +Each *ISP statistics block* is preceded by a header implemented by the +:c:type:`v4l2_isp_block_header` structure, followed by the statistics data= for +that specific block. The driver might optionally report platform-specific = flags +associated with each statistics block. + +Applications inspect the statistics block type as reported in the header a= nd +validates the reported size matches the block's expected size before acces= sing +the ISP statistics data. + +Extension to the statistics format can be implemented by adding new blocks +definition without invalidating the existing ones. =20 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 --=20 2.53.0 From nobody Sat Jun 13 20:56:12 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 308EB42B72D; Tue, 5 May 2026 14:12:46 +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=1777990368; cv=none; b=JpPVbRdzsXJMswxY4pLxReHhIzlF2e0NTyMohrRZ1PQdMBejl4ZWoR2j7D9ehBiEkQk2HwdZyIrrZH+SmmvciY4eUOb/4Lpa0CLDODpi3E12vzdzQxhtg36QipT+E6SVH1SJiBZz6e0cXMgCFGMnsWrRGCMfm2oMPemwByU2YOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777990368; c=relaxed/simple; bh=bpglAInsweFej64GPG8NT2v508+PDgnI8avIUtvLiQQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ts1Vj84nmjKfYw2/dKh8qy7HjDAG8/fhL3RW00wU6rorO4qafpL8E+rosgnZnvv7Cw6ZVBll3YZngkXZG6kQ9w91irMOu7eKepvkTr3XHSIIqbCUjR4nfNPhmUesAu8gozaY08swir/d64DO6ofafsBazChaVUtFfj34byxiU/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=IoQxL31U; 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="IoQxL31U" Received: from [192.168.1.83] (unknown [IPv6:2001:b07:6462:5de2:520d:d7a3:63ca:99e8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C493A1C4D; Tue, 5 May 2026 16:12:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777990357; bh=bpglAInsweFej64GPG8NT2v508+PDgnI8avIUtvLiQQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IoQxL31UcZimQo7tcSRIxCMdVNycibTKvpArA6TPtVrwN+HmEYI4hWgswlcYkW8N9 SZfiqqichCtGVGM547ND81JHZoa6Rpo1VR/l82FTfDkOychbMClWJGBwr5xlc/mYtS tOLWyfL+bVgm7rxA7X2IT3QlIc8pNfoNcyEYS/fA= From: Jacopo Mondi Date: Tue, 05 May 2026 16:12:14 +0200 Subject: [PATCH 3/6] media: v4l2-isp: Rename v4l2_isp_params_buffer_size 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: <20260505-extensible-stats-v1-3-e16f326b8dad@ideasonboard.com> References: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> In-Reply-To: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> To: Mauro Carvalho Chehab , Daniel Scally , Keke Li , Antoine Bouyer , Jai Luthra , =?utf-8?q?Niklas_S=C3=B6derlund?= , Ricardo Ribalda Cc: Laurent Pinchart , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4462; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=bpglAInsweFej64GPG8NT2v508+PDgnI8avIUtvLiQQ=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBp+frTn3dYArrSheys/cCo0h0d6yo2bEmmdT3zf YfO8K2x66+JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCafn60wAKCRByNAaPFqFW PCWWEACONzcAC8EEY/2YP9BA71Mg0o/0WoSoKfiVYf04Sqo8LRiPMIaDODzhY3uITUj/xDCnMUX sgVNT8aOKpvBS+12lHYiPBmKvuGsjavLsfo+f2IHHkHVDVx8/UgaKrsBC+xHS2HhM2Jlp69cNVM qxwJ0uUW2t2vlxhtmeT8zz4dOCTD35byyPoiQ0VV2ZpuEiVtjoclQrixmdB+xHrJWDBpwlu5pjn O9klgSV5zuKTTMqu7bo4N5WArVf66296tvl8HD6jbHHdsW+WiOVWVzOgbJmt2LAfSkWNfksY3hQ lCcMBxsXojAaXi26oopTkYpALiC8CKH5GV3x4Xy4hbk6dUz4Aln4KBZDl8kiZmHw47+3LWPP7Xp 7GgugFQZPuUyOqrq6MBs+77rqCcWknh0X9OuoVhfopFCGmZ+f53NoWLB0X70IPyWr5466fRMnaG eI/oXIMgfV2e9aREQRMH29fDZeDXfr3uW6zS3bIQohgbMsPNhXvjEAj1emd6UvdEyihDWVq09zo UqTx6H6cw8eAPJBpbXD96d1QmrUYxlouPXWyNaUJ27uVHa7WXwcF1WzH/wvc9OL/tf0EPOei1Fc gKP1JngBxM6Hhg93Dzz0ehDY9n+Uwimb3hfbkTByLe72AFH05X/ANVx5mWiayCeC04sSAgTR8jV Y+hgY/Paw/SZ3HA== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Rename v4l2_isp_params_buffer_size() to v4l2_isp_buffer_size() to support statistics. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas S=C3=B6derlund --- .../media/platform/arm/mali-c55/mali-c55-params.c | 12 ++++++------ include/media/v4l2-isp.h | 22 +++++++++++++-----= ---- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/driver= s/media/platform/arm/mali-c55/mali-c55-params.c index de0e9d898db7..dc483f0322d6 100644 --- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c +++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c @@ -487,7 +487,7 @@ static int mali_c55_params_g_fmt_meta_out(struct file *= file, void *fh, { static const struct v4l2_meta_format mfmt =3D { .dataformat =3D V4L2_META_FMT_MALI_C55_PARAMS, - .buffersize =3D v4l2_isp_params_buffer_size(MALI_C55_PARAMS_MAX_SIZE), + .buffersize =3D v4l2_isp_buffer_size(MALI_C55_PARAMS_MAX_SIZE), }; =20 f->fmt.meta =3D mfmt; @@ -540,13 +540,13 @@ mali_c55_params_queue_setup(struct vb2_queue *q, unsi= gned int *num_buffers, if (*num_planes && *num_planes > 1) return -EINVAL; =20 - if (sizes[0] && sizes[0] < v4l2_isp_params_buffer_size(MALI_C55_PARAMS_MA= X_SIZE)) + if (sizes[0] && sizes[0] < v4l2_isp_buffer_size(MALI_C55_PARAMS_MAX_SIZE)) return -EINVAL; =20 *num_planes =3D 1; =20 if (!sizes[0]) - sizes[0] =3D v4l2_isp_params_buffer_size(MALI_C55_PARAMS_MAX_SIZE); + sizes[0] =3D v4l2_isp_buffer_size(MALI_C55_PARAMS_MAX_SIZE); =20 return 0; } @@ -556,7 +556,7 @@ static int mali_c55_params_buf_init(struct vb2_buffer *= vb) struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buffer(vb); struct mali_c55_params_buf *buf =3D to_mali_c55_params_buf(vbuf); =20 - buf->config =3D kvmalloc(v4l2_isp_params_buffer_size(MALI_C55_PARAMS_MAX_= SIZE), + buf->config =3D kvmalloc(v4l2_isp_buffer_size(MALI_C55_PARAMS_MAX_SIZE), GFP_KERNEL); if (!buf->config) return -ENOMEM; @@ -583,7 +583,7 @@ static int mali_c55_params_buf_prepare(struct vb2_buffe= r *vb) int ret; =20 ret =3D v4l2_isp_params_validate_buffer_size(mali_c55->dev, vb, - v4l2_isp_params_buffer_size(MALI_C55_PARAMS_MAX_SIZE)); + v4l2_isp_buffer_size(MALI_C55_PARAMS_MAX_SIZE)); if (ret) return ret; =20 @@ -593,7 +593,7 @@ static int mali_c55_params_buf_prepare(struct vb2_buffe= r *vb) * changed to the buffer content whilst the driver processes it. */ =20 - memcpy(buf->config, config, v4l2_isp_params_buffer_size(MALI_C55_PARAMS_M= AX_SIZE)); + memcpy(buf->config, config, v4l2_isp_buffer_size(MALI_C55_PARAMS_MAX_SIZE= )); =20 return v4l2_isp_params_validate_buffer(mali_c55->dev, vb, buf->config, mali_c55_params_block_types_info, diff --git a/include/media/v4l2-isp.h b/include/media/v4l2-isp.h index f3a6d0edcb24..d70ed6b431e7 100644 --- a/include/media/v4l2-isp.h +++ b/include/media/v4l2-isp.h @@ -15,17 +15,21 @@ struct device; struct vb2_buffer; =20 /** - * v4l2_isp_params_buffer_size - Calculate size of v4l2_isp_params_buffer - * @max_params_size: The total size of the ISP configuration blocks + * v4l2_isp_buffer_size - Calculate size of v4l2_isp_buffer + * @max_size: The total size of the ISP configuration or statistics blocks + * + * Users of v4l2-isp will have differing sized data arrays for parameters = and + * statistics, depending on their specific blocks. Drivers need to be able= to + * calculate the appropriate size of the buffer to accommodate all ISP blo= cks + * supported by the platform. This macro provides a convenient tool for the + * calculation. + * + * The intended users of this function are drivers initializing the size + * of their metadata (parameters and statistics) buffers. * - * 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)) +#define v4l2_isp_buffer_size(max_size) \ + (offsetof(struct v4l2_isp_buffer, data) + (max_size)) =20 /** * v4l2_isp_params_validate_buffer_size - Validate a V4L2 ISP buffer sizes --=20 2.53.0 From nobody Sat Jun 13 20:56:12 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 7A44147F2E8; Tue, 5 May 2026 14:12:49 +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=1777990378; cv=none; b=Gwdr2jvYpBPKKCJ0rFZDHGwIWXmSGHN+ccTPFT/mmqIRiLEvetIgzZX57G4d/xqZYD6nDetNUrAwOeeGhZBpZR6ZKxv0tk3FOHMNLU+QRfPIKBR9v/gMQ9w09H3SKTrhp3OOUHD+qbg4jlKQT940q6u4GsrXVAGDmpNg3ENZjGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777990378; c=relaxed/simple; bh=41S+ZeIQVev9eVoYtAcBbO2DN3BHJm0Mrl6dgk7LAJg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L3RRbhptkapH/VpejrIasgL6VH9SHgofbdibdxGynHnhcDJFggtrdetfAxioaEKMoBfHnhHtc8krFHCeUJgCBBRfoDdnu/tTppeg7IR1PwqYISsSxDdmGr+clCAhUlNFIPMzm8UTjULlPzv9/5bEdFuN4Eymdrhqo8X3Y5ZG2jQ= 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=NL6HMGll; 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="NL6HMGll" Received: from [192.168.1.83] (unknown [IPv6:2001:b07:6462:5de2:520d:d7a3:63ca:99e8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AEBC92451; Tue, 5 May 2026 16:12:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777990358; bh=41S+ZeIQVev9eVoYtAcBbO2DN3BHJm0Mrl6dgk7LAJg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NL6HMGllt+pQ4CHmqvNsRXnWhMwpmk32bBWPyvuzcS9J4171fBo+6uhsUAQBxb6aF eRlh4afLvQJ1i6XT9Gek1mZWspiu2o6XLRprMLS2a4Hyq6mPISksSfFR87oVBWxyWi wfKvSDvmPUM/qNayVUj1+lqJOPx7RJ+uT/mWAghE= From: Jacopo Mondi Date: Tue, 05 May 2026 16:12:15 +0200 Subject: [PATCH 4/6] media: v4l2-isp: Add per-block validation callback 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: <20260505-extensible-stats-v1-4-e16f326b8dad@ideasonboard.com> References: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> In-Reply-To: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> To: Mauro Carvalho Chehab , Daniel Scally , Keke Li , Antoine Bouyer , Jai Luthra , =?utf-8?q?Niklas_S=C3=B6derlund?= , Ricardo Ribalda Cc: Laurent Pinchart , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2781; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=41S+ZeIQVev9eVoYtAcBbO2DN3BHJm0Mrl6dgk7LAJg=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBp+frTVSWF7yv4xDBcD0gjY4dugGG9XfOy++9yV VVorFkXOA+JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCafn60wAKCRByNAaPFqFW PIz8EACj7V+zRXC4u5qfikTaL6FKwppx79pILp9nFP7AlqQTjG0kvz8AxwMO2P4Ttz6GGcJFrFY Heynk/Ml4WTxVH/XYjO0pFr87dQFWAdofepBDQP/mWBf9SnPGAxl/C7fOy+3SGqaX9RwFbXp2EK /zNZFPWfPOmvu7dKYFFgTs/DSlZplqeIBwWWwmCaI/eX7B/T06sJ2eynOBW5AU1VnwnMg+WPDuB PCCIBbhtMeojhD6wYXskV8Og34XHcrE+mWSd+oe/NXdpmZgibs/YV5WMYMkmaIrFK1/4jCmYxW+ BM1MzeHbAGjLTa73eUxzIwLhtF6tef/Q/jSQX8/otFT+NBT/SH70iJxDzvf3z3TLjUIsxhXP5Dr 25zkHLqJUbndWEN1jY+8DUgmq41Ag3+ZK2g3RPJ9B1sb/AeWAnw5AKogAzquPY/6eP0Cdxb6+Nm mGchhHWy0rZcQVkwjXkV2W2cEvX0usdWqojT5+ZZSFmkFbSw8uTBDAmhxfiHlwQCLHHgJ+lh4T7 eMRIwFOKHDZK8T0ZMBttYvuyCnGQLWlAMV7Wkk45aaz0YnrJ2hYWjeDaZxwidZq04tGSyamw7VH pNF3gskzYgQyQNzPHESonll4oprEM3faSSLHS/PLFsG+OXAb/onE53JdwbCVV3unxxOVwKPP1LR 1CgTUy7xNDrIrWA== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Drivers are expected to provide to the helper function v4l2_isp_params_validate_buffer() a list of 'struct v4l2_isp_params_block_type_info' entries, one for each supported ISP block. The type 'struct v4l2_isp_params_block_type_info' so far only contained the expected block size for the core framework to validate the declared block size against the expected one. For some blocks, drivers might want to implement more precise per-block validations. Add a function pointer member to 'struct v4l2_isp_params_block_type_info' to allow drivers to register a callback and call it from the core framework during validation. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas S=C3=B6derlund --- drivers/media/v4l2-core/v4l2-isp.c | 4 ++++ include/media/v4l2-isp.h | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-isp.c b/drivers/media/v4l2-core/v= 4l2-isp.c index 29831f7032e9..10760659f8a3 100644 --- a/drivers/media/v4l2-core/v4l2-isp.c +++ b/drivers/media/v4l2-core/v4l2-isp.c @@ -114,6 +114,10 @@ int v4l2_isp_params_validate_buffer(struct device *dev= , struct vb2_buffer *vb, return -EINVAL; } =20 + if (type_info->block_validate && + type_info->block_validate(dev, block)) + return -EINVAL; + block_offset +=3D block->size; buffer_size -=3D block->size; } diff --git a/include/media/v4l2-isp.h b/include/media/v4l2-isp.h index d70ed6b431e7..1f35a52f978a 100644 --- a/include/media/v4l2-isp.h +++ b/include/media/v4l2-isp.h @@ -55,17 +55,22 @@ int v4l2_isp_params_validate_buffer_size(struct device = *dev, /** * struct v4l2_isp_params_block_type_info - V4L2 ISP per-block-type info * @size: the block type expected size + * @block_validate: driver's callback to implement per-block validation * * The v4l2_isp_params_block_type_info collects information of the ISP - * configuration block types for validation purposes. It currently only co= ntains - * the expected block type size. + * configuration block types for validation purposes. It contains the expe= cted + * block type size and a function pointer where drivers can register a cal= lback + * for additional per-block validation purposes. The validation function is + * expected to return 0 on success or a negative error number for errors. * * Drivers shall prepare a list of block type info, indexed by block type,= one * for each supported ISP block type and correctly populate them with the - * expected block type size. + * expected block type size and the optional callback. */ struct v4l2_isp_params_block_type_info { size_t size; + int (*block_validate)(struct device *dev, + const struct v4l2_isp_block_header *block); }; =20 /** --=20 2.53.0 From nobody Sat Jun 13 20:56:12 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 7A4DE47F2FB; Tue, 5 May 2026 14:12:49 +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=1777990380; cv=none; b=ShGECdinPNMbwOt6J2a6cJCiNdjigEGaXLwdmpMpbPWv5yBG3Yera4VokyU71Kk2FFxYSLwOBld5t65uHxjnbBJyRPBFaYYQ2g7WVgqOsxbReNr9XYbz+QNYJ591IejDjIzP4W8tjMDsotn7P2FJUa1Q0KvlInBZAAyogFS6f5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777990380; c=relaxed/simple; bh=oNsDyr6uZzYV3a0cCi0urCH+ptz1GQyQi5/4NRsNn4Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YLU4IvKPwJ+z4QLMT7fehwcBUZIuFxMxq1riVsYATDfVzNlUwVDg5awBXF6Hy5jKTuesSFae6uryiU58aT6q4OorXnhRR8wtlpNuVhzp2mO9XBBVt9akjUUoJKaHNtaP7VzMdf3hBO0IklBxOuViXGY3AFcJ1IZH9MxpiONnmsQ= 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=Wgk4k//q; 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="Wgk4k//q" Received: from [192.168.1.83] (unknown [IPv6:2001:b07:6462:5de2:520d:d7a3:63ca:99e8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A1B8525A5; Tue, 5 May 2026 16:12:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777990359; bh=oNsDyr6uZzYV3a0cCi0urCH+ptz1GQyQi5/4NRsNn4Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Wgk4k//qbnibymttqy/+7QS8YMZ4rTsowIaGAKsHXAn+FcHYV56hC3Rq+36JwnqkN 9KikoDzOQKzTuP96EHxMf+iLxXSIoTloaswXlfZTAFbYc3lFXuAh4UVH3NtbALzt43 AY3Jnmzs9/O8Z85tjOEvg9ZQIOLu1rXmuTkoFSDI= From: Jacopo Mondi Date: Tue, 05 May 2026 16:12:16 +0200 Subject: [PATCH 5/6] media: amlogic-c3: Implement per-block 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: <20260505-extensible-stats-v1-5-e16f326b8dad@ideasonboard.com> References: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> In-Reply-To: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> To: Mauro Carvalho Chehab , Daniel Scally , Keke Li , Antoine Bouyer , Jai Luthra , =?utf-8?q?Niklas_S=C3=B6derlund?= , Ricardo Ribalda Cc: Laurent Pinchart , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2645; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=oNsDyr6uZzYV3a0cCi0urCH+ptz1GQyQi5/4NRsNn4Q=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBp+frUFGUUfHWvhDdsFPSw5E4ysiqXgLk9nmwEp tjBnpAhKqOJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCafn61AAKCRByNAaPFqFW PLxDD/9vh83Fran6CpinIVndOaHQNOxAaWb+KyzQvg7tsIr5X0Fpe783K0t4klgLaXF3citw4sQ I21FmxCCeUUfcpGW2aERp25WMboR9qvbktPk944VPaCFauiT76KbIDtpntNkv4LUxqqVkuTgFYp 6TFoGwXCsoyqHd4Z8F585wc08lK+NT4BErXeTErKU8mSYo+TPSTeiYbLqdHhhAUm/EH5qiDpqN7 Fb183rc9vkqyOBFW8gK5of8VVwmSkSOlc5CR0QKhPPW+PxrSII62sID9vF+Z/Ua15jhe9np+Btc 794e1OSKquxXmebMUD6Thb6Im9TS3DLnUB/nwKodr8dkJ2YPEzJfbhsQvTI68dge3Zjat6gkEXW aUB65OTQqjukyDOj7rc0UQZtAvJ5k2kgvdIrMgJW4qT6HYEAcspe0llEFviQW/+TalGEOQm9H+M 1XlZpj136r3P7PkMgU1pQsVgqEzRVo3AviQK5kSI1v8rLnkzORzBQkmxvW7gYrnrMk5QInJgAmn tLeYhGw5mHoSXYKE3FA4wWMdReQwTR8AHXvGv9hKl8GeaAjWLwxKDMQsOjQgSzNQazUY/04Md6j mVXyy+me3+VE6yCX0RCd1+TNjTZbYQ1/yeUfUAkYWUICQGSL0O4xzx2ccwFau29Mqu3A8h0XVau isiLudGqU8F7wUA== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Use the newly introduced per-block validation in v4l2-isp framework to implement a validation callback for the AWB and AE configuration blocks to make sure the configured metering zones do not exceed the hardware capabilities. Signed-off-by: Jacopo Mondi --- .../media/platform/amlogic/c3/isp/c3-isp-params.c | 42 ++++++++++++++++++= ++-- 1 file changed, 39 insertions(+), 3 deletions(-) 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 6f9ca7a7dd88..6d5d332599df 100644 --- a/drivers/media/platform/amlogic/c3/isp/c3-isp-params.c +++ b/drivers/media/platform/amlogic/c3/isp/c3-isp-params.c @@ -531,16 +531,52 @@ static const c3_isp_block_handler c3_isp_params_handl= ers[] =3D { [C3_ISP_PARAMS_BLOCK_BLC] =3D c3_isp_params_cfg_blc, }; =20 -#define C3_ISP_PARAMS_BLOCK_INFO(block, data) \ +static int +c3_isp_params_awb_config_validate(struct device *dev, + const struct v4l2_isp_block_header *block) +{ + const struct c3_isp_params_awb_config *cfg =3D + (const struct c3_isp_params_awb_config *)block; + + if (cfg->horiz_zones_num * cfg->vert_zones_num > C3_ISP_AWB_MAX_ZONES) { + dev_dbg(dev, "Invalid number of AWB measurement zones\n"); + return -EINVAL; + } + + return 0; +} + +static int +c3_isp_params_ae_config_validate(struct device *dev, + const struct v4l2_isp_block_header *block) +{ + const struct c3_isp_params_ae_config *cfg =3D + (const struct c3_isp_params_ae_config *)block; + + if (cfg->horiz_zones_num * cfg->vert_zones_num > C3_ISP_AE_MAX_ZONES) { + dev_dbg(dev, "Invalid number of AE measurement zones\n"); + return -EINVAL; + } + + return 0; +} + +#define C3_ISP_PARAMS_BLOCK_INFO_CBK(block, data, cbk) \ [C3_ISP_PARAMS_BLOCK_ ## block] =3D { \ .size =3D sizeof(struct c3_isp_params_ ## data), \ + .block_validate =3D (cbk)\ } =20 +#define C3_ISP_PARAMS_BLOCK_INFO(block, data) \ + C3_ISP_PARAMS_BLOCK_INFO_CBK(block, data, NULL) + static const struct v4l2_isp_params_block_type_info c3_isp_params_block_types_info[] =3D { C3_ISP_PARAMS_BLOCK_INFO(AWB_GAINS, awb_gains), - C3_ISP_PARAMS_BLOCK_INFO(AWB_CONFIG, awb_config), - C3_ISP_PARAMS_BLOCK_INFO(AE_CONFIG, ae_config), + C3_ISP_PARAMS_BLOCK_INFO_CBK(AWB_CONFIG, awb_config, + &c3_isp_params_awb_config_validate), + C3_ISP_PARAMS_BLOCK_INFO_CBK(AE_CONFIG, ae_config, + &c3_isp_params_ae_config_validate), C3_ISP_PARAMS_BLOCK_INFO(AF_CONFIG, af_config), C3_ISP_PARAMS_BLOCK_INFO(PST_GAMMA, pst_gamma), C3_ISP_PARAMS_BLOCK_INFO(CCM, ccm), --=20 2.53.0 From nobody Sat Jun 13 20:56:12 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 DCD523E51D7; Tue, 5 May 2026 14:12:59 +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=1777990381; cv=none; b=dBjvRicM4jZDswknxH9KeMVletYkHa2wWFpCKHCeLoceMKlmrAhz8nvweI510lT4Ai8wHfothx45Bv1Cm4F8glmppWJqZdAg44jp9vkgM3IWcsJzCaBxr6gAGrvzIKjd/YadwToOkMtEH3oSkoxODFSC30DlYJq5eNbtA8q/FeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777990381; c=relaxed/simple; bh=sdg+In5npj58wlKZzHtgpFYt9UT5solngSihfomc5jk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Za8l8MIEKiFkM694EsSZ/py8l/KLvt3ovv8kCuTZL7MzaGNsZQjVtAxPFkWHf0Fo62ifCxClBH4X4GIMSExABm/mjZiLiQQOXoPzWdssN9eqCIiKAiFZiyJn2u1SI178xu86zvxpbVtn2jWNC6vVkJgkEj3HSpc8YE/Fx2ATT58= 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=hdH9ZZXK; 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="hdH9ZZXK" Received: from [192.168.1.83] (unknown [IPv6:2001:b07:6462:5de2:520d:d7a3:63ca:99e8]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 90A5125BF; Tue, 5 May 2026 16:12:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777990360; bh=sdg+In5npj58wlKZzHtgpFYt9UT5solngSihfomc5jk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hdH9ZZXK1AIqKK5NHZmFsCb5gC3KYOW8ZPV5wHZdzNl6Jkat6ToJ1m2fQC1fqW8B1 VYyJLvnqZKIhSYJ5SNYVQfUMfr+0h6xHfwA+z0JURSHCld77yJZR6fe15VRp4zwTfD /9lVquU/erDwqmlLmQJ9ezjPOCNzYkSq9WBvCko4= From: Jacopo Mondi Date: Tue, 05 May 2026 16:12:17 +0200 Subject: [PATCH 6/6] media: v4l2-isp: Add helpers for stats buffer 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: <20260505-extensible-stats-v1-6-e16f326b8dad@ideasonboard.com> References: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> In-Reply-To: <20260505-extensible-stats-v1-0-e16f326b8dad@ideasonboard.com> To: Mauro Carvalho Chehab , Daniel Scally , Keke Li , Antoine Bouyer , Jai Luthra , =?utf-8?q?Niklas_S=C3=B6derlund?= , Ricardo Ribalda Cc: Laurent Pinchart , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=6244; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=sdg+In5npj58wlKZzHtgpFYt9UT5solngSihfomc5jk=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBp+frUrkDEtpN+ZvdNQrCSRcAuqoSUqYJgqoP1L tsxDLhAmHuJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCafn61AAKCRByNAaPFqFW POlzD/4hKIvLmuY3xF9HZu3dCAy/7Kov3tsZnAVtxcGP7t1cl6IqWSfMpwbePgn0kCb/XDm54kh OX9JKk+00jHYn0lrbYpjyQ2IdJ0I9qc9P8YKnRX4uWQZdwZljoKmbZfwRHn7FD0BrbbpRtd6hM2 40NSW22m3As5ZydVXGP/smjG+aj48GFjZIpiN2yph736ckXL1qrT5Uto4Gr81ki4EYIR0n33bpu dQ8p+JyC3n2pfTSrIRMFwD+Erey3w0a5a5MXS79UDYgDPC8iu3+DRMLhxS571ABgGj8jOU1Q7UL pQBCTbz+iYQufHp1/cLgTNrag6d74/B0bBJfNJrvKsX2a7VpYw5644sKTN3enBZnOOLRmcurnrU De9qQErh44iuDSZJWknPJUuJPcF7FiUxBP495IL47zgyTAF8AMgJwIwww2bZwOo2aPUG9Yk+9SI fUcB20sQUwfqGWg8Vm+xvTJI7BWKdAHN+M4pvJhwi9J3fyVjvN5xEdplf8+Vtft2c7NT5CudhqH 57K4Hk0kjTJkajvGbh5Wr5Ia3VIOJXnKcq2OQlZFERHGAI6cDg0F4mXmctVfUPM0k04mN9xy7Dc Zx+RCf0qehVvtEIeCVbJ8CdAMFzyfSSBkzi8R71wTMYbREeWHJeEgS6FzpF9P22H4nFLSfgJUcJ 6fpyShkywuBnmlQ== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Add two helper functions to v4l2-isp to handle statistics: - v4l2_isp_stats_init_buffer() to initialize a statistics buffer - v4l2_isp_stats_init_block() to initialize a statistics block in the next available memory location of a buffer The v4l2_isp_stats_init_buffer() resets the data size counter of the buffer and initializes its 'version' field. The v4l2_isp_stats_init_block() helper accepts the type of the stats block about to be populated, an array of per-block-type information and the maximum size of the v4l2-isp buffer. If enough space for the new block is available, the function increments the v4l2_isp_buffer.data_size counter, initializes the new stats block header and returns a pointer to the block for the driver to populate it. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas S=C3=B6derlund --- drivers/media/v4l2-core/v4l2-isp.c | 52 +++++++++++++++++++++++++++++++++ include/media/v4l2-isp.h | 59 ++++++++++++++++++++++++++++++++++= +++- 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-isp.c b/drivers/media/v4l2-core/v= 4l2-isp.c index 10760659f8a3..8482010776d4 100644 --- a/drivers/media/v4l2-core/v4l2-isp.c +++ b/drivers/media/v4l2-core/v4l2-isp.c @@ -131,6 +131,58 @@ int v4l2_isp_params_validate_buffer(struct device *dev= , struct vb2_buffer *vb, } EXPORT_SYMBOL_GPL(v4l2_isp_params_validate_buffer); =20 +void v4l2_isp_stats_init_buffer(struct v4l2_isp_buffer *buf, + enum v4l2_isp_version version) +{ + if (WARN_ON(!buf)) + return; + + if (WARN_ON(version > V4L2_ISP_VERSION_V1)) + return; + + buf->version =3D version; + buf->data_size =3D 0; +} +EXPORT_SYMBOL_GPL(v4l2_isp_stats_init_buffer); + +struct v4l2_isp_block_header * +v4l2_isp_stats_init_block(struct device *dev, struct v4l2_isp_buffer *buf, + const struct v4l2_isp_stats_block_type_info *type_info, + size_t num_block_types, unsigned int block_type, + size_t max_size) +{ + const struct v4l2_isp_stats_block_type_info *block_info; + struct v4l2_isp_block_header *header; + size_t used; + + if (WARN_ON(!dev || !buf || !type_info)) + return ERR_PTR(-EINVAL); + + if (block_type >=3D num_block_types) { + dev_err(dev, "Invalid block type %u\n", block_type); + return ERR_PTR(-EINVAL); + } + + block_info =3D &type_info[block_type]; + used =3D buf->data_size; + + if (used + block_info->size > max_size) { + dev_err(dev, "No space for stats block type %u of size %zu\n", + block_type, block_info->size); + return ERR_PTR(-ENOMEM); + } + + buf->data_size +=3D block_info->size; + + header =3D (struct v4l2_isp_block_header *)&buf->data[used]; + header->type =3D block_type; + header->size =3D block_info->size; + header->flags =3D 0; + + return header; +} +EXPORT_SYMBOL_GPL(v4l2_isp_stats_init_block); + MODULE_LICENSE("GPL"); MODULE_AUTHOR("Jacopo Mondi