[PATCH 58/74] media: uapi: Add CAMSS ISP statistics definition
From: bod
Date: Mon Oct 05 2026 - 13:50:17 EST
From: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx>
Add V4L2_META_FMT_QCOM_ISP_STATS, the statistics counterpart of the CAMSS
ISP parameters. Statistics use the v4l2-isp extensible format: the driver
serialises one block per statistics engine into a struct v4l2_isp_buffer,
each block embedding a struct v4l2_isp_block_header with a type from
enum camss_stats_block_type.
The first block is the AEC Bayer histogram, CAMSS_STATS_AEC_BHIST:
1024 bins counting the luma of each 2x2 Bayer quad in the histogram's
region.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx>
---
drivers/media/v4l2-core/v4l2-ioctl.c | 1 +
include/uapi/linux/qcom-camss-config.h | 33 +++++++++++++++++++++++++++++++++
include/uapi/linux/videodev2.h | 3 +++
3 files changed, 37 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index a2b650f4ec3c3..e5eccb62e76b2 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1471,6 +1471,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_META_FMT_C3ISP_STATS: descr = "Amlogic C3 ISP Statistics"; break;
case V4L2_META_FMT_MALI_C55_PARAMS: descr = "ARM Mali-C55 ISP Parameters"; break;
case V4L2_META_FMT_MALI_C55_STATS: descr = "ARM Mali-C55 ISP 3A Statistics"; break;
+ case V4L2_META_FMT_QCOM_ISP_STATS: descr = "Qualcomm CAMSS ISP Statistics"; break;
case V4L2_PIX_FMT_NV12_8L128: descr = "NV12 (8x128 Linear)"; break;
case V4L2_PIX_FMT_NV12M_8L128: descr = "NV12M (8x128 Linear)"; break;
case V4L2_PIX_FMT_NV12_10BE_8L128: descr = "10-bit NV12 (8x128 Linear, BE)"; break;
diff --git a/include/uapi/linux/qcom-camss-config.h b/include/uapi/linux/qcom-camss-config.h
index aa3d97cfcc78e..23c12b8955ef6 100644
--- a/include/uapi/linux/qcom-camss-config.h
+++ b/include/uapi/linux/qcom-camss-config.h
@@ -209,4 +209,37 @@ struct camss_params_gamma {
sizeof(struct camss_params_color_correct) +\
sizeof(struct camss_params_gamma))
+/**
+ * enum camss_stats_block_type - CAMSS ISP statistics block identifiers
+ *
+ * Each value identifies one statistics block in a
+ * V4L2_META_FMT_QCOM_ISP_STATS buffer. The value is placed in the @type field
+ * of &struct v4l2_isp_block_header.
+ *
+ * @CAMSS_STATS_AEC_BHIST: AEC Bayer histogram, &struct camss_stats_bhist
+ */
+enum camss_stats_block_type {
+ CAMSS_STATS_AEC_BHIST = 1,
+};
+
+/* Number of bins in a Bayer histogram. */
+#define CAMSS_STATS_BHIST_BINS 1024
+
+/**
+ * struct camss_stats_bhist - Bayer histogram
+ *
+ * Histogram of the luma of each 2x2 Bayer quad inside the histogram's region,
+ * over CAMSS_STATS_BHIST_BINS equal bins spanning its input range. Quads
+ * whose luma falls outside the input range are not counted.
+ *
+ * @header: block header; @header.type = CAMSS_STATS_AEC_BHIST
+ * @bins: number of quads per bin
+ */
+struct camss_stats_bhist {
+ struct v4l2_isp_block_header header;
+ __u32 bins[CAMSS_STATS_BHIST_BINS];
+} __attribute__((aligned(8)));
+
+#define CAMSS_STATS_MAX_PAYLOAD sizeof(struct camss_stats_bhist)
+
#endif /* _UAPI_LINUX_QCOM_CAMSS_CONFIG_H */
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index eda4492e40dc1..700ea9b646979 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -889,6 +889,9 @@ struct v4l2_pix_format {
#define V4L2_META_FMT_MALI_C55_PARAMS v4l2_fourcc('C', '5', '5', 'P') /* ARM Mali-C55 Parameters */
#define V4L2_META_FMT_MALI_C55_STATS v4l2_fourcc('C', '5', '5', 'S') /* ARM Mali-C55 3A Statistics */
+/* Vendor specific - used for Qualcomm CAMSS ISP */
+#define V4L2_META_FMT_QCOM_ISP_STATS v4l2_fourcc('Q', 'C', 'I', 'S') /* Qualcomm CAMSS ISP Statistics */
+
#ifdef __KERNEL__
/*
* Line-based metadata formats. Remember to update v4l_fill_fmtdesc() when
--
2.55.0