[PATCH 05/11] media: uapi: st: dcmipp: add description of ISP stats & param buffers

Alain Volmat alain.volmat at foss.st.com
Fri Dec 4 03:11:36 PST 2026


Introduce structures used to control DCMIPP ISP as well as gather
generated statistics.

Signed-off-by: Alain Volmat <alain.volmat at foss.st.com>
---
 MAINTAINERS                                 |   1 +
 include/uapi/linux/media/st/dcmipp_config.h | 313 ++++++++++++++++++++++++++++
 2 files changed, 314 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 222b7fc2c3aa..cbf3d071801e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16953,6 +16953,7 @@ F:	Documentation/devicetree/bindings/media/st,stm32-dcmi.yaml
 F:	Documentation/devicetree/bindings/media/st,stm32-dcmipp.yaml
 F:	drivers/media/platform/st/stm32/stm32-dcmi.c
 F:	drivers/media/platform/st/stm32/stm32-dcmipp/*
+F:	include/uapi/linux/media/st/dcmipp_config.h
 
 MEDIA INPUT INFRASTRUCTURE (V4L/DVB)
 M:	Mauro Carvalho Chehab <mchehab at kernel.org>
diff --git a/include/uapi/linux/media/st/dcmipp_config.h b/include/uapi/linux/media/st/dcmipp_config.h
index ad8d146820ea..d833ebe31d1c 100644
--- a/include/uapi/linux/media/st/dcmipp_config.h
+++ b/include/uapi/linux/media/st/dcmipp_config.h
@@ -10,7 +10,320 @@
 
 #include <linux/types.h>
 #include <linux/v4l2-controls.h>
+#include <linux/media/v4l2-isp.h>
 
 #define V4L2_CID_DCMIPP_PIXELPROC_GAMMA_CORRECTION_ENABLE	(V4L2_CID_USER_DCMIPP_BASE + 0x0)
 
+/**
+ * enum stm32_dcmipp_params_block_type - STM32 DCMIPP ISP parameters block types
+ *
+ * Block types to be used in &v4l2_isp_block_header.type of the blocks of a
+ * &struct v4l2_isp_buffer (parameters) queued on the isp-params device.
+ * Except for the DM and STAT blocks, each block can be enabled or disabled
+ * using the V4L2_ISP_PARAMS_FL_BLOCK_ENABLE / V4L2_ISP_PARAMS_FL_BLOCK_DISABLE
+ * flags. A disabled block may only contain its header. If none of these flags
+ * is set, the block is configured and its enable state is left unchanged.
+ *
+ * @STM32_DCMIPP_PARAMS_BLOCK_TYPE_BPR: bad pixel removal
+ * @STM32_DCMIPP_PARAMS_BLOCK_TYPE_BLC: black level correction
+ * @STM32_DCMIPP_PARAMS_BLOCK_TYPE_EX: exposure control
+ * @STM32_DCMIPP_PARAMS_BLOCK_TYPE_DM: demosaicing filters
+ * @STM32_DCMIPP_PARAMS_BLOCK_TYPE_CC: color conversion
+ * @STM32_DCMIPP_PARAMS_BLOCK_TYPE_CE: contrast enhancement
+ * @STM32_DCMIPP_PARAMS_BLOCK_TYPE_STAT: statistics extraction
+ */
+enum stm32_dcmipp_params_block_type {
+	STM32_DCMIPP_PARAMS_BLOCK_TYPE_BPR,
+	STM32_DCMIPP_PARAMS_BLOCK_TYPE_BLC,
+	STM32_DCMIPP_PARAMS_BLOCK_TYPE_EX,
+	STM32_DCMIPP_PARAMS_BLOCK_TYPE_DM,
+	STM32_DCMIPP_PARAMS_BLOCK_TYPE_CC,
+	STM32_DCMIPP_PARAMS_BLOCK_TYPE_CE,
+	STM32_DCMIPP_PARAMS_BLOCK_TYPE_STAT,
+};
+
+/**
+ * struct stm32_dcmipp_params_bpr - bad pixel removal
+ *
+ * @header: block header
+ * @strength: strength (aggressiveness) of the bad pixel detection (0-7)
+ * @reserved: reserved for future use, must be set to 0
+ */
+struct stm32_dcmipp_params_bpr {
+	struct v4l2_isp_block_header header;
+	__u8 strength;
+	__u8 reserved[7];
+};
+
+/**
+ * struct stm32_dcmipp_params_blc - black level correction
+ *
+ * @header: block header
+ * @blc_r: correction on the red component
+ * @blc_g: correction on the green component
+ * @blc_b: correction on the blue component
+ * @reserved: reserved for future use, must be set to 0
+ */
+struct stm32_dcmipp_params_blc {
+	struct v4l2_isp_block_header header;
+	__u8 blc_r;
+	__u8 blc_g;
+	__u8 blc_b;
+	__u8 reserved[5];
+};
+
+/**
+ * struct stm32_dcmipp_params_ex - exposure control
+ *
+ * @header: block header
+ * @shift_r: red component exposure shift (0-7)
+ * @mult_r: red component exposure multiplier
+ * @shift_g: green component exposure shift (0-7)
+ * @mult_g: green component exposure multiplier
+ * @shift_b: blue component exposure shift (0-7)
+ * @mult_b: blue component exposure multiplier
+ * @reserved: reserved for future use, must be set to 0
+ */
+struct stm32_dcmipp_params_ex {
+	struct v4l2_isp_block_header header;
+	__u8 shift_r;
+	__u8 mult_r;
+	__u8 shift_g;
+	__u8 mult_g;
+	__u8 shift_b;
+	__u8 mult_b;
+	__u8 reserved[2];
+};
+
+/**
+ * struct stm32_dcmipp_params_dm - demosaicing filters
+ *
+ * @header: block header
+ * @edge: strength of the edge detection (0-7)
+ * @lineh: strength of the horizontal line detection (0-7)
+ * @linev: strength of the vertical line detection (0-7)
+ * @peak: strength of the peak detection (0-7)
+ * @reserved: reserved for future use, must be set to 0
+ *
+ * The demosaicing block enable/disable is controlled by the
+ * dcmipp isp subdevice depending on formats applied to it.
+ * This only controls the filters applied when enabled.
+ *
+ */
+struct stm32_dcmipp_params_dm {
+	struct v4l2_isp_block_header header;
+	__u8 edge;
+	__u8 lineh;
+	__u8 linev;
+	__u8 peak;
+	__u8 reserved[4];
+};
+
+enum stm32_dcmipp_isp_cc_clamp {
+	STM32_DCMIPP_ISP_CC_CLAMP_DISABLED,
+	STM32_DCMIPP_ISP_CC_CLAMP_Y235_U240_V240,
+	STM32_DCMIPP_ISP_CC_CLAMP_YUV235,
+};
+
+/**
+ * struct stm32_dcmipp_params_cc - color conversion
+ *
+ * The matrix coefficients (@rr, @rg, @rb, @gr, @gg, @gb, @br, @bg, @bb) are
+ * signed 11-bit values in 2.8 fixed point format in two's complement.
+ * The added values (@ra, @ga, @ba) are signed 10-bit integers in two's complement.
+ * Bits above the 11 (respectively 10) bits of a value must be set to 0.
+ *
+ * @header: block header
+ * @clamp: clamp configuration (from enum stm32_dcmipp_isp_cc_clamp)
+ * @rr: row 1 col 1 value of the matrix
+ * @rg: row 1 col 2 value of the matrix
+ * @rb: row 1 col 3 value of the matrix
+ * @ra: row 1 added value of the matrix
+ * @gr: row 2 col 1 value of the matrix
+ * @gg: row 2 col 2 value of the matrix
+ * @gb: row 2 col 3 value of the matrix
+ * @ga: row 2 added value of the matrix
+ * @br: row 3 col 1 value of the matrix
+ * @bg: row 3 col 2 value of the matrix
+ * @bb: row 3 col 3 value of the matrix
+ * @ba: row 3 added value of the matrix
+ * @reserved: reserved for future use, must be set to 0
+ */
+struct stm32_dcmipp_params_cc {
+	struct v4l2_isp_block_header header;
+	__u32 clamp;
+	__u16 rr;
+	__u16 rg;
+	__u16 rb;
+	__u16 ra;
+	__u16 gr;
+	__u16 gg;
+	__u16 gb;
+	__u16 ga;
+	__u16 br;
+	__u16 bg;
+	__u16 bb;
+	__u16 ba;
+	__u32 reserved;
+};
+
+/**
+ * struct stm32_dcmipp_params_ce - contrast enhancement
+ *
+ * @header: block header
+ * @lum: 9 elements table of luminance enhancement (value 16 is neutral)
+ * @reserved: reserved for future use, must be set to 0
+ */
+struct stm32_dcmipp_params_ce {
+	struct v4l2_isp_block_header header;
+	__u8 lum[9];
+	__u8 reserved[7];
+};
+
+#define STM32_DCMIPP_ISP_STAT_PROFILE_FULL		0
+#define STM32_DCMIPP_ISP_STAT_PROFILE_AVERAGE_PRE	1
+#define STM32_DCMIPP_ISP_STAT_PROFILE_AVERAGE_POST	2
+
+#define STM32_DCMIPP_ISP_STAT_AVG_FILTER_NONE		0
+#define STM32_DCMIPP_ISP_STAT_AVG_FILTER_EXCL16		1
+#define STM32_DCMIPP_ISP_STAT_AVG_FILTER_EXCL32		2
+#define STM32_DCMIPP_ISP_STAT_AVG_FILTER_EXCL64		3
+
+#define STM32_DCMIPP_ISP_STAT_BIN_COMP_R		0
+#define STM32_DCMIPP_ISP_STAT_BIN_COMP_G		1
+#define STM32_DCMIPP_ISP_STAT_BIN_COMP_B		2
+#define STM32_DCMIPP_ISP_STAT_BIN_COMP_L		3
+
+/**
+ * struct stm32_dcmipp_params_stat - statistics extraction
+ *
+ * @header: block header
+ * @left: left start (in pixel) of the statistics area
+ * @top: top start (in pixel) of the statistics area
+ * @width: width (in pixel) of the statistics area
+ * @height: height (in pixel) of the statistics area
+ * @profile: statistics capture profile (STM32_DCMIPP_ISP_STAT_PROFILE_*)
+ *	     FULL: average and bins, both pre and post demosaicing
+ *	     AVERAGE_PRE: average only, pre demosaicing
+ *	     AVERAGE_POST: average only, post demosaicing
+ * @avg_filter: filter excluding pixels from the average computation
+ *		(STM32_DCMIPP_ISP_STAT_AVG_FILTER_*)
+ * @bin_comp: component used for the bins extraction
+ *	      (STM32_DCMIPP_ISP_STAT_BIN_COMP_*), L being the luminance
+ * @reserved: reserved for future use, must be set to 0
+ *
+ * A width and height of 0 (together with a left and top of 0) select the
+ * whole frame as statistics area.
+ * The statistic block is always enabled hence ENABLE/DISABLE flags
+ * are ignored.
+ */
+struct stm32_dcmipp_params_stat {
+	struct v4l2_isp_block_header header;
+	__u16 left;
+	__u16 top;
+	__u16 width;
+	__u16 height;
+	__u8 profile;
+	__u8 avg_filter;
+	__u8 bin_comp;
+	__u8 reserved[5];
+};
+
+/**
+ * union stm32_dcmipp_params_block - all the STM32 DCMIPP parameters blocks
+ *
+ * @header: common header of all blocks
+ * @bpr: bad pixel removal
+ * @blc: black level correction
+ * @ex: exposure control
+ * @dm: demosaicing filters
+ * @cc: color conversion
+ * @ce: contrast enhancement
+ * @stat: statistics extraction
+ */
+union stm32_dcmipp_params_block {
+	struct v4l2_isp_block_header header;
+	struct stm32_dcmipp_params_bpr bpr;
+	struct stm32_dcmipp_params_blc blc;
+	struct stm32_dcmipp_params_ex ex;
+	struct stm32_dcmipp_params_dm dm;
+	struct stm32_dcmipp_params_cc cc;
+	struct stm32_dcmipp_params_ce ce;
+	struct stm32_dcmipp_params_stat stat;
+};
+
+/* Maximum size of the data[] member of the parameters buffer */
+#define STM32_DCMIPP_PARAMS_MAX_SIZE				\
+	(sizeof(struct stm32_dcmipp_params_bpr) +		\
+	 sizeof(struct stm32_dcmipp_params_blc) +		\
+	 sizeof(struct stm32_dcmipp_params_ex) +		\
+	 sizeof(struct stm32_dcmipp_params_dm) +		\
+	 sizeof(struct stm32_dcmipp_params_cc) +		\
+	 sizeof(struct stm32_dcmipp_params_ce) +		\
+	 sizeof(struct stm32_dcmipp_params_stat))
+
+/**
+ * enum stm32_dcmipp_stats_block_type - STM32 DCMIPP ISP statistics block types
+ *
+ * Block types reported in &v4l2_isp_block_header.type of the blocks of a
+ * &struct v4l2_isp_buffer (statistics) dequeued from the statistics device.
+ *
+ * @STM32_DCMIPP_STATS_BLOCK_TYPE_PRE: average & bins before demosaicing, only
+ *	reported with the FULL and AVERAGE_PRE profiles
+ * @STM32_DCMIPP_STATS_BLOCK_TYPE_POST: average & bins after demosaicing, only
+ *	reported with the FULL and AVERAGE_POST profiles
+ * @STM32_DCMIPP_STATS_BLOCK_TYPE_BPR: bad pixel count, always reported
+ */
+enum stm32_dcmipp_stats_block_type {
+	STM32_DCMIPP_STATS_BLOCK_TYPE_PRE,
+	STM32_DCMIPP_STATS_BLOCK_TYPE_POST,
+	STM32_DCMIPP_STATS_BLOCK_TYPE_BPR,
+};
+
+/**
+ * struct stm32_dcmipp_stats_avr_bins - average & bins statistics
+ *
+ * @header: block header
+ * @average_rgb: average value of the R/G/B components
+ * @bins: 12 values histogram (only valid with the FULL profile)
+ * @reserved: reserved for future use
+ */
+struct stm32_dcmipp_stats_avr_bins {
+	struct v4l2_isp_block_header header;
+	__u32 average_rgb[3];
+	__u32 bins[12];
+	__u32 reserved;
+};
+
+/**
+ * struct stm32_dcmipp_stats_bpr - bad pixel statistics
+ *
+ * @header: block header
+ * @bad_pixel_count: number of bad pixels detected in the frame
+ * @reserved: reserved for future use
+ */
+struct stm32_dcmipp_stats_bpr {
+	struct v4l2_isp_block_header header;
+	__u32 bad_pixel_count;
+	__u32 reserved;
+};
+
+/**
+ * union stm32_dcmipp_stats_block - all the STM32 DCMIPP statistics blocks
+ *
+ * @header: common header of all blocks
+ * @avr_bins: average & bins statistics
+ * @bpr: bad pixel statistics
+ */
+union stm32_dcmipp_stats_block {
+	struct v4l2_isp_block_header header;
+	struct stm32_dcmipp_stats_avr_bins avr_bins;
+	struct stm32_dcmipp_stats_bpr bpr;
+};
+
+/* Maximum size of the data[] member of the statistics buffer */
+#define STM32_DCMIPP_STATS_MAX_SIZE				\
+	(2 * sizeof(struct stm32_dcmipp_stats_avr_bins) +	\
+	 sizeof(struct stm32_dcmipp_stats_bpr))
+
 #endif /* __UAPI_DCMIPP_CONFIG_H */

-- 
2.34.1




More information about the linux-arm-kernel mailing list