mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alain Volmat <alain.volmat@foss.st.com>
To: Hugues Fruchet <hugues.fruchet@foss.st.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>
Cc: <linux-media@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	"Alain Volmat" <alain.volmat@foss.st.com>
Subject: [PATCH 05/11] media: uapi: st: dcmipp: add description of ISP stats & param buffers
Date: Fri, 4 Dec 2026 12:11:36 +0100	[thread overview]
Message-ID: <20261204-stm32mp-dcmipp-isp-stat-ctrls-v1-5-e809f8c193e6@foss.st.com> (raw)
In-Reply-To: <20261204-stm32mp-dcmipp-isp-stat-ctrls-v1-0-e809f8c193e6@foss.st.com>

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

Signed-off-by: Alain Volmat <alain.volmat@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@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


  parent reply	other threads:[~2026-12-04 11:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
2026-12-04 11:11 ` [PATCH 01/11] media: stm32: dcmipp: add entity pointers into dcmipp-common.h Alain Volmat
2026-12-04 11:11 ` [PATCH 02/11] media: stm32: dcmipp: add enum to name ISP subdev pads Alain Volmat
2026-12-04 11:11 ` [PATCH 03/11] media: stm32: dcmipp: isp: keep a frame sequence counter at isp level Alain Volmat
2026-12-04 11:11 ` [PATCH 04/11] media: stm32: dcmipp: capture: use ISP frame sequence for main & aux pipes Alain Volmat
2026-12-04 11:11 ` Alain Volmat [this message]
2026-12-04 11:11 ` [PATCH 06/11] media: uapi: add STM32 DCMIPP ISP META formats Alain Volmat
2026-12-04 11:11 ` [PATCH 07/11] media: stm32: dcmipp: isp: expose active sink format & compose Alain Volmat
2026-12-04 11:11 ` [PATCH 08/11] media: stm32: dcmipp: addition of a statistics capture device Alain Volmat
2026-12-04 11:11 ` [PATCH 09/11] media: stm32: dcmipp: addition of isp param output device Alain Volmat
2026-12-04 11:11 ` [PATCH 10/11] media: stm32: dcmipp: isp: add 2 pads to be connected to isp-params & stats Alain Volmat
2026-12-04 11:11 ` [PATCH 11/11] media: stm32: dcmipp: core: add isp-params & stats devices Alain Volmat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204-stm32mp-dcmipp-isp-stat-ctrls-v1-5-e809f8c193e6@foss.st.com \
    --to=alain.volmat@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=hugues.fruchet@foss.st.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mchehab@kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®