[PATCH v1 03/11] media: v4l2-isp: Add helper function to compute extended stats size

Antoine Bouyer
2026-04-13T16:04:40Z

v4l2-isp framework only supports extended buffer for generic ISP
configuration. This patch adds simple helper function to compute the
extended statistics buffer size, exactly the same as for extended
parameters, except that it uses the `v4l2_isp_stats_block_header`
structure definition to prevent conflict with the
`v4l2_isp_params_block_header` one.

Signed-off-by: Antoine Bouyer <antoine.bouyer@nxp.com>
---
include/media/v4l2-isp.h | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/include/media/v4l2-isp.h b/include/media/v4l2-isp.h
index f3a6d0edcb24..9a93a534e7b0 100644
--- a/include/media/v4l2-isp.h
+++ b/include/media/v4l2-isp.h
@@ -27,6 +27,19 @@ struct vb2_buffer;
#define v4l2_isp_params_buffer_size(max_params_size) \
(offsetof(struct v4l2_isp_params_buffer, data) + (max_params_size))

+/**
+ * v4l2_isp_stats_buffer_size - Calculate size of v4l2_isp_stats_buffer
+ * @max_stats_size: The total size of the ISP statistic blocks
+ *
+ * Users of the v4l2 extensible statistics buffers will have differing sized data
+ * arrays depending on their specific ISP blocks. Drivers and userspace will need
+ * to be able to calculate the appropriate size of the struct to accommodate all
+ * ISP statistics blocks provided by the platform.
+ * This macro provides a convenient tool for the calculation.
+ */
+#define v4l2_isp_stats_buffer_size(max_stats_size) \
+ (offsetof(struct v4l2_isp_stats_buffer, data) + (max_stats_size))
+
/**
* v4l2_isp_params_validate_buffer_size - Validate a V4L2 ISP buffer sizes
* @dev: the driver's device pointer
--
2.51.0