mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics
@ 2026-12-04 11:11 Alain Volmat
  2026-12-04 11:11 ` [PATCH 01/11] media: stm32: dcmipp: add entity pointers into dcmipp-common.h Alain Volmat
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

The series adds two video devices connected to the isp subdev
of the dcmipp. The param video device is used in order to inject
controls into the isp for image processing such as demosaicing
filter, exposure, contrast, color conversion etc as well as
control the way statistics are produced.
A stats video device allows to extract statistics produced by
the dcmipp on each frame.

First part of the series rework existing code in order to help
addition of those video devices, such as in order to allow
synchronization of the sequence numbers of capture / stats
and params.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
Alain Volmat (11):
      media: stm32: dcmipp: add entity pointers into dcmipp-common.h
      media: stm32: dcmipp: add enum to name ISP subdev pads
      media: stm32: dcmipp: isp: keep a frame sequence counter at isp level
      media: stm32: dcmipp: capture: use ISP frame sequence for main & aux pipes
      media: uapi: st: dcmipp: add description of ISP stats & param buffers
      media: uapi: add STM32 DCMIPP ISP META formats
      media: stm32: dcmipp: isp: expose active sink format & compose
      media: stm32: dcmipp: addition of a statistics capture device
      media: stm32: dcmipp: addition of isp param output device
      media: stm32: dcmipp: isp: add 2 pads to be connected to isp-params & stats
      media: stm32: dcmipp: core: add isp-params & stats devices

 .../userspace-api/media/v4l/meta-formats.rst       |   1 +
 .../userspace-api/media/v4l/metafmt-st-dcmipp.rst  |  74 ++
 MAINTAINERS                                        |   2 +
 drivers/media/platform/st/stm32/Kconfig            |   2 +
 .../media/platform/st/stm32/stm32-dcmipp/Makefile  |   2 +-
 .../st/stm32/stm32-dcmipp/dcmipp-byteproc.c        |   9 +-
 .../st/stm32/stm32-dcmipp/dcmipp-capture.c         |  66 +-
 .../platform/st/stm32/stm32-dcmipp/dcmipp-common.h | 180 +++++
 .../platform/st/stm32/stm32-dcmipp/dcmipp-core.c   |  16 +
 .../platform/st/stm32/stm32-dcmipp/dcmipp-input.c  |   9 +-
 .../st/stm32/stm32-dcmipp/dcmipp-isp-params.c      | 860 +++++++++++++++++++++
 .../platform/st/stm32/stm32-dcmipp/dcmipp-isp.c    | 135 +++-
 .../st/stm32/stm32-dcmipp/dcmipp-pixelproc.c       |  14 +-
 .../st/stm32/stm32-dcmipp/dcmipp-statcap.c         | 773 ++++++++++++++++++
 drivers/media/v4l2-core/v4l2-ioctl.c               |   2 +
 include/uapi/linux/media/st/dcmipp_config.h        | 313 ++++++++
 include/uapi/linux/videodev2.h                     |   4 +
 17 files changed, 2354 insertions(+), 108 deletions(-)
---
base-commit: 4926041f4195fcacef0f84c0e388c3be2ddb2b71
change-id: 20261112-stm32mp-dcmipp-isp-stat-ctrls-513394b9235f

Best regards,
--  
Alain Volmat <alain.volmat@foss.st.com>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 01/11] media: stm32: dcmipp: add entity pointers into dcmipp-common.h
  2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
@ 2026-12-04 11:11 ` Alain Volmat
  2026-12-04 11:11 ` [PATCH 02/11] media: stm32: dcmipp: add enum to name ISP subdev pads Alain Volmat
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

Add typed pointers to each entity private structure into struct
dcmipp_device. Each entity sets its pointer upon init and clears it
upon release.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 .../st/stm32/stm32-dcmipp/dcmipp-byteproc.c        |   9 +-
 .../st/stm32/stm32-dcmipp/dcmipp-capture.c         |  53 +---------
 .../platform/st/stm32/stm32-dcmipp/dcmipp-common.h | 110 +++++++++++++++++++++
 .../platform/st/stm32/stm32-dcmipp/dcmipp-input.c  |   9 +-
 .../platform/st/stm32/stm32-dcmipp/dcmipp-isp.c    |  10 +-
 .../st/stm32/stm32-dcmipp/dcmipp-pixelproc.c       |  14 +--
 6 files changed, 121 insertions(+), 84 deletions(-)

diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c
index 346cfddcf229..94488c3b9cbf 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c
@@ -96,13 +96,6 @@ dcmipp_byteproc_pix_map_by_code(u32 code)
 	return NULL;
 }
 
-struct dcmipp_byteproc_device {
-	struct dcmipp_ent_device ved;
-	struct v4l2_subdev sd;
-	struct device *dev;
-	void __iomem *regs;
-};
-
 static const struct v4l2_mbus_framefmt fmt_default = {
 	.width = DCMIPP_FMT_WIDTH_DEFAULT,
 	.height = DCMIPP_FMT_HEIGHT_DEFAULT,
@@ -584,6 +577,7 @@ void dcmipp_byteproc_ent_release(struct dcmipp_ent_device *ved)
 	struct dcmipp_byteproc_device *byteproc =
 			container_of(ved, struct dcmipp_byteproc_device, ved);
 
+	ved->dcmipp->byteproc = NULL;
 	dcmipp_ent_sd_unregister(ved, &byteproc->sd);
 }
 
@@ -619,6 +613,7 @@ dcmipp_byteproc_ent_init(const char *entity_name,
 
 	byteproc->ved.dcmipp = dcmipp;
 	byteproc->dev = dcmipp->dev;
+	dcmipp->byteproc = byteproc;
 
 	return &byteproc->ved;
 }
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-capture.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-capture.c
index fe7767f908b7..4d35372c292b 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-capture.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-capture.c
@@ -187,56 +187,6 @@ struct dcmipp_buf {
 	struct list_head	list;
 };
 
-struct dcmipp_capture_device {
-	struct dcmipp_ent_device ved;
-	struct video_device vdev;
-	struct device *dev;
-	struct v4l2_pix_format format;
-	struct vb2_queue queue;
-	struct list_head buffers;
-	/*
-	 * Protects concurrent calls of buf queue / irq handler
-	 * and buffer handling related variables / lists
-	 */
-	spinlock_t irqlock;
-	/* mutex used as vdev and queue lock */
-	struct mutex lock;
-	u32 sequence;
-	struct v4l2_subdev *s_subdev;
-	u32 s_subdev_pad_nb;
-
-	enum dcmipp_state state;
-
-	/*
-	 * DCMIPP driver is handling 2 buffers
-	 * active: buffer into which DCMIPP is currently writing into
-	 * next: buffer given to the DCMIPP and which will become
-	 *       automatically active on next VSYNC
-	 */
-	struct dcmipp_buf *active, *next;
-
-	void __iomem *regs;
-
-	int pipe_id;
-
-	const struct dcmipp_capture_pix_map *pix_map;
-	unsigned int pix_map_array_size;
-
-	u32 cmsr2;
-
-	struct {
-		u32 errors;
-		u32 limit;
-		u32 overrun;
-		u32 buffers;
-		u32 vsync;
-		u32 frame;
-		u32 it;
-		u32 underrun;
-		u32 nactive;
-	} count;
-};
-
 static const struct dcmipp_capture_pix_map *
 dcmipp_capture_pix_map_by_pixelformat(struct dcmipp_capture_device *vcap,
 				      u32 pixelformat)
@@ -888,6 +838,7 @@ void dcmipp_capture_ent_release(struct dcmipp_ent_device *ved)
 	struct dcmipp_capture_device *vcap =
 		container_of(ved, struct dcmipp_capture_device, ved);
 
+	ved->dcmipp->capture[vcap->pipe_id] = NULL;
 	media_entity_cleanup(ved->ent);
 	vb2_video_unregister_device(&vcap->vdev);
 }
@@ -1243,6 +1194,8 @@ struct dcmipp_ent_device *dcmipp_capture_ent_init(const char *entity_name,
 		goto err_clean_m_ent;
 	}
 
+	dcmipp->capture[vcap->pipe_id] = vcap;
+
 	return &vcap->ved;
 
 err_clean_m_ent:
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
index 007912c3a7f8..aa32b64acf52 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
@@ -14,8 +14,10 @@
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <media/media-device.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-fwnode.h>
+#include <media/videobuf2-core.h>
 
 #define DCMIPP_PDEV_NAME "dcmipp"
 
@@ -58,6 +60,14 @@ do {									\
 		(fmt)->xfer_func = DCMIPP_XFER_FUNC_DEFAULT;		\
 } while (0)
 
+#define DCMIPP_NUM_PIPES	3
+
+struct dcmipp_inp_device;
+struct dcmipp_byteproc_device;
+struct dcmipp_capture_device;
+struct dcmipp_isp_device;
+struct dcmipp_pixelproc_device;
+
 struct dcmipp_device {
 	/* The platform device */
 	struct platform_device		pdev;
@@ -81,6 +91,18 @@ struct dcmipp_device {
 	/* Entities */
 	struct dcmipp_ent_device	**entity;
 
+	/*
+	 * Pointers to the entity private structures, allowing each entity to
+	 * access data of other entities of the pipeline. Pointers are NULL
+	 * for entities not present on a given DCMIPP variant. Arrays are
+	 * indexed by pipe id (pixelproc[0] is hence always NULL).
+	 */
+	struct dcmipp_inp_device	*input;
+	struct dcmipp_byteproc_device	*byteproc;
+	struct dcmipp_capture_device	*capture[DCMIPP_NUM_PIPES];
+	struct dcmipp_isp_device	*isp;
+	struct dcmipp_pixelproc_device	*pixelproc[DCMIPP_NUM_PIPES];
+
 	struct v4l2_async_notifier	notifier;
 };
 
@@ -168,6 +190,94 @@ enum dcmipp_state {
 	DCMIPP_RUNNING,
 };
 
+/* Entity private structures */
+struct dcmipp_buf;
+struct dcmipp_capture_pix_map;
+
+struct dcmipp_inp_device {
+	struct dcmipp_ent_device ved;
+	struct v4l2_subdev sd;
+	struct device *dev;
+	void __iomem *regs;
+};
+
+struct dcmipp_byteproc_device {
+	struct dcmipp_ent_device ved;
+	struct v4l2_subdev sd;
+	struct device *dev;
+	void __iomem *regs;
+};
+
+struct dcmipp_capture_device {
+	struct dcmipp_ent_device ved;
+	struct video_device vdev;
+	struct device *dev;
+	struct v4l2_pix_format format;
+	struct vb2_queue queue;
+	struct list_head buffers;
+	/*
+	 * Protects concurrent calls of buf queue / irq handler
+	 * and buffer handling related variables / lists
+	 */
+	spinlock_t irqlock;
+	/* mutex used as vdev and queue lock */
+	struct mutex lock;
+	u32 sequence;
+	struct v4l2_subdev *s_subdev;
+	u32 s_subdev_pad_nb;
+
+	enum dcmipp_state state;
+
+	/*
+	 * DCMIPP driver is handling 2 buffers
+	 * active: buffer into which DCMIPP is currently writing into
+	 * next: buffer given to the DCMIPP and which will become
+	 *       automatically active on next VSYNC
+	 */
+	struct dcmipp_buf *active, *next;
+
+	void __iomem *regs;
+
+	int pipe_id;
+
+	const struct dcmipp_capture_pix_map *pix_map;
+	unsigned int pix_map_array_size;
+
+	u32 cmsr2;
+
+	struct {
+		u32 errors;
+		u32 limit;
+		u32 overrun;
+		u32 buffers;
+		u32 vsync;
+		u32 frame;
+		u32 it;
+		u32 underrun;
+		u32 nactive;
+	} count;
+};
+
+struct dcmipp_isp_device {
+	struct dcmipp_ent_device ved;
+	struct v4l2_subdev sd;
+	struct device *dev;
+
+	void __iomem *regs;
+};
+
+struct dcmipp_pixelproc_device {
+	struct dcmipp_ent_device ved;
+	struct v4l2_subdev sd;
+	struct device *dev;
+	bool streaming;
+
+	void __iomem *regs;
+	struct v4l2_ctrl_handler ctrls;
+
+	u32 pipe_id;
+};
+
 /**
  * dcmipp_pads_init - initialize pads
  *
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c
index e66a9456deb6..28f1e63c5cad 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c
@@ -176,13 +176,6 @@ static inline const struct dcmipp_inp_pix_map *dcmipp_inp_pix_map_by_code
 	return NULL;
 }
 
-struct dcmipp_inp_device {
-	struct dcmipp_ent_device ved;
-	struct v4l2_subdev sd;
-	struct device *dev;
-	void __iomem *regs;
-};
-
 static const struct v4l2_mbus_framefmt fmt_default = {
 	.width = DCMIPP_FMT_WIDTH_DEFAULT,
 	.height = DCMIPP_FMT_HEIGHT_DEFAULT,
@@ -549,6 +542,7 @@ void dcmipp_inp_ent_release(struct dcmipp_ent_device *ved)
 	struct dcmipp_inp_device *inp =
 			container_of(ved, struct dcmipp_inp_device, ved);
 
+	ved->dcmipp->input = NULL;
 	dcmipp_ent_sd_unregister(ved, &inp->sd);
 }
 
@@ -588,6 +582,7 @@ struct dcmipp_ent_device *dcmipp_inp_ent_init(const char *entity_name,
 	}
 
 	inp->dev = dev;
+	dcmipp->input = inp;
 
 	return &inp->ved;
 }
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
index 088301c20547..2ddb1e27c5bb 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
@@ -40,14 +40,6 @@
 #define ISP_MEDIA_BUS_SINK_FMT_DEFAULT MEDIA_BUS_FMT_RGB565_1X16
 #define ISP_MEDIA_BUS_SRC_FMT_DEFAULT MEDIA_BUS_FMT_RGB888_1X24
 
-struct dcmipp_isp_device {
-	struct dcmipp_ent_device ved;
-	struct v4l2_subdev sd;
-	struct device *dev;
-
-	void __iomem *regs;
-};
-
 static const struct v4l2_mbus_framefmt fmt_default = {
 	.width = DCMIPP_FMT_WIDTH_DEFAULT,
 	.height = DCMIPP_FMT_HEIGHT_DEFAULT,
@@ -454,6 +446,7 @@ void dcmipp_isp_ent_release(struct dcmipp_ent_device *ved)
 	struct dcmipp_isp_device *isp =
 			container_of(ved, struct dcmipp_isp_device, ved);
 
+	ved->dcmipp->isp = NULL;
 	dcmipp_ent_sd_unregister(ved, &isp->sd);
 }
 
@@ -488,6 +481,7 @@ struct dcmipp_ent_device *dcmipp_isp_ent_init(const char *entity_name,
 
 	isp->ved.dcmipp = dcmipp;
 	isp->dev = dcmipp->dev;
+	dcmipp->isp = isp;
 
 	return &isp->ved;
 }
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
index 7d8e5f0863bf..883c6895de05 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-pixelproc.c
@@ -348,18 +348,6 @@ to_cconv_range(struct v4l2_mbus_framefmt *fmt)
 
 #define RANGE_STR(range) ((range) == RANGE_FULL ? "full" : "limited")
 
-struct dcmipp_pixelproc_device {
-	struct dcmipp_ent_device ved;
-	struct v4l2_subdev sd;
-	struct device *dev;
-	bool streaming;
-
-	void __iomem *regs;
-	struct v4l2_ctrl_handler ctrls;
-
-	u32 pipe_id;
-};
-
 static const struct v4l2_mbus_framefmt fmt_default = {
 	.width = DCMIPP_FMT_WIDTH_DEFAULT,
 	.height = DCMIPP_FMT_HEIGHT_DEFAULT,
@@ -864,6 +852,7 @@ void dcmipp_pixelproc_ent_release(struct dcmipp_ent_device *ved)
 	struct dcmipp_pixelproc_device *pixelproc =
 			container_of(ved, struct dcmipp_pixelproc_device, ved);
 
+	ved->dcmipp->pixelproc[pixelproc->pipe_id] = NULL;
 	dcmipp_ent_sd_unregister(ved, &pixelproc->sd);
 }
 
@@ -930,6 +919,7 @@ dcmipp_pixelproc_ent_init(const char *entity_name,
 		goto err_ctrl_handler_free;
 
 	pixelproc->ved.dcmipp = dcmipp;
+	dcmipp->pixelproc[pixelproc->pipe_id] = pixelproc;
 
 	return &pixelproc->ved;
 

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 02/11] media: stm32: dcmipp: add enum to name ISP subdev pads
  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 ` Alain Volmat
  2026-12-04 11:11 ` [PATCH 03/11] media: stm32: dcmipp: isp: keep a frame sequence counter at isp level Alain Volmat
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

Introduce an enum dcmipp_isp_pad in order to use macros
to identify a pad instead of magic numbers.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 .../platform/st/stm32/stm32-dcmipp/dcmipp-isp.c    | 41 +++++++++++++---------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
index 2ddb1e27c5bb..d8ce12a2cbcb 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
@@ -40,6 +40,14 @@
 #define ISP_MEDIA_BUS_SINK_FMT_DEFAULT MEDIA_BUS_FMT_RGB565_1X16
 #define ISP_MEDIA_BUS_SRC_FMT_DEFAULT MEDIA_BUS_FMT_RGB888_1X24
 
+/* enum for the isp pads */
+enum dcmipp_isp_pad {
+	DCMIPP_ISP_PAD_SINK_VIDEO,
+	DCMIPP_ISP_PAD_SOURCE_VIDEO_MAIN,
+	DCMIPP_ISP_PAD_SOURCE_VIDEO_AUX,
+	DCMIPP_ISP_PAD_MAX
+};
+
 static const struct v4l2_mbus_framefmt fmt_default = {
 	.width = DCMIPP_FMT_WIDTH_DEFAULT,
 	.height = DCMIPP_FMT_HEIGHT_DEFAULT,
@@ -137,7 +145,7 @@ static int dcmipp_isp_set_fmt(struct v4l2_subdev *sd,
 
 	if (IS_SINK(fmt->pad)) {
 		struct v4l2_mbus_framefmt *src_fmt =
-			v4l2_subdev_state_get_format(state, 1);
+			v4l2_subdev_state_get_format(state, DCMIPP_ISP_PAD_SOURCE_VIDEO_MAIN);
 		struct v4l2_rect r = {
 			.top = 0,
 			.left = 0,
@@ -146,18 +154,18 @@ static int dcmipp_isp_set_fmt(struct v4l2_subdev *sd,
 		};
 
 		/* Adjust SINK pad crop/compose */
-		*v4l2_subdev_state_get_crop(state, 0) = r;
-		*v4l2_subdev_state_get_compose(state, 0) = r;
+		*v4l2_subdev_state_get_crop(state, DCMIPP_ISP_PAD_SINK_VIDEO) = r;
+		*v4l2_subdev_state_get_compose(state, DCMIPP_ISP_PAD_SINK_VIDEO) = r;
 
 		/* Forward format to SRC pads */
 		*src_fmt = fmt->format;
 		src_fmt->code = dcmipp_pixelpipe_src_format(fmt->format.code);
-		*v4l2_subdev_state_get_format(state, 2) = *src_fmt;
+		*v4l2_subdev_state_get_format(state, DCMIPP_ISP_PAD_SOURCE_VIDEO_AUX) = *src_fmt;
 	} else {
 		struct v4l2_mbus_framefmt *sink_fmt =
-			v4l2_subdev_state_get_format(state, 0);
+			v4l2_subdev_state_get_format(state, DCMIPP_ISP_PAD_SINK_VIDEO);
 		struct v4l2_rect *compose =
-			v4l2_subdev_state_get_compose(state, 0);
+			v4l2_subdev_state_get_compose(state, DCMIPP_ISP_PAD_SINK_VIDEO);
 
 		fmt->format = *sink_fmt;
 		fmt->format.code = dcmipp_pixelpipe_src_format(sink_fmt->code);
@@ -166,8 +174,9 @@ static int dcmipp_isp_set_fmt(struct v4l2_subdev *sd,
 			fmt->format.height = compose->height;
 		}
 		/* Set to the 2nd SRC pad */
-		*v4l2_subdev_state_get_format(state, fmt->pad == 1 ? 2 : 1) =
-			fmt->format;
+		*v4l2_subdev_state_get_format(state, fmt->pad == DCMIPP_ISP_PAD_SOURCE_VIDEO_MAIN ?
+					      DCMIPP_ISP_PAD_SOURCE_VIDEO_AUX :
+					      DCMIPP_ISP_PAD_SOURCE_VIDEO_MAIN) = fmt->format;
 	}
 
 	/* Update the selected pad format */
@@ -266,7 +275,7 @@ static int dcmipp_isp_set_selection(struct v4l2_subdev *sd,
 static void dcmipp_isp_config_demosaicing(struct dcmipp_isp_device *isp,
 					  struct v4l2_subdev_state *state)
 {
-	__u32 code = v4l2_subdev_state_get_format(state, 0)->code;
+	__u32 code = v4l2_subdev_state_get_format(state, DCMIPP_ISP_PAD_SINK_VIDEO)->code;
 	unsigned int val = 0;
 
 	/* Disable demosaicing */
@@ -298,7 +307,7 @@ static bool dcmipp_isp_is_aux_output_enabled(struct dcmipp_isp_device *isp)
 	struct media_link *link;
 
 	for_each_media_entity_data_link(isp->ved.ent, link) {
-		if (link->source != &isp->ved.pads[2])
+		if (link->source != &isp->ved.pads[DCMIPP_ISP_PAD_SOURCE_VIDEO_AUX])
 			continue;
 
 		if (!(link->flags & MEDIA_LNK_FL_ENABLED))
@@ -314,8 +323,8 @@ static bool dcmipp_isp_is_aux_output_enabled(struct dcmipp_isp_device *isp)
 static void dcmipp_isp_config_decimation(struct dcmipp_isp_device *isp,
 					 struct v4l2_subdev_state *state)
 {
-	struct v4l2_rect *crop = v4l2_subdev_state_get_crop(state, 0);
-	struct v4l2_rect *compose = v4l2_subdev_state_get_compose(state, 0);
+	struct v4l2_rect *crop = v4l2_subdev_state_get_crop(state, DCMIPP_ISP_PAD_SINK_VIDEO);
+	struct v4l2_rect *compose = v4l2_subdev_state_get_compose(state, DCMIPP_ISP_PAD_SINK_VIDEO);
 	u32 decr;
 
 	decr = (fls(crop->width / compose->width) - 1) << DCMIPP_P1DECR_HDEC_SHIFT |
@@ -331,7 +340,7 @@ static int dcmipp_isp_enable_streams(struct v4l2_subdev *sd,
 				     u32 pad, u64 streams_mask)
 {
 	struct dcmipp_isp_device *isp = v4l2_get_subdevdata(sd);
-	struct v4l2_rect *crop = v4l2_subdev_state_get_crop(state, 0);
+	struct v4l2_rect *crop = v4l2_subdev_state_get_crop(state, DCMIPP_ISP_PAD_SINK_VIDEO);
 	struct v4l2_subdev *s_subdev;
 	struct media_pad *s_pad;
 	int ret;
@@ -341,7 +350,7 @@ static int dcmipp_isp_enable_streams(struct v4l2_subdev *sd,
 		return 0;
 
 	/* Get source subdev */
-	s_pad = media_pad_remote_pad_first(&sd->entity.pads[0]);
+	s_pad = media_pad_remote_pad_first(&sd->entity.pads[DCMIPP_ISP_PAD_SINK_VIDEO]);
 	if (!s_pad || !is_media_entity_v4l2_subdev(s_pad->entity))
 		return -EINVAL;
 	s_subdev = media_entity_to_v4l2_subdev(s_pad->entity);
@@ -353,7 +362,7 @@ static int dcmipp_isp_enable_streams(struct v4l2_subdev *sd,
 		reg_set(isp, DCMIPP_P1FSCR, DCMIPP_P1FSCR_PIPEDIFF);
 
 	/* Configure Statistic Removal */
-	crop = v4l2_subdev_state_get_crop(state, 0);
+	crop = v4l2_subdev_state_get_crop(state, DCMIPP_ISP_PAD_SINK_VIDEO);
 	reg_write(isp, DCMIPP_P1SRCR,
 		  ((crop->top << DCMIPP_P1SRCR_FIRSTLINEDEL_SHIFT) |
 		   (crop->height << DCMIPP_P1SRCR_LASTLINE_SHIFT) |
@@ -389,7 +398,7 @@ static int dcmipp_isp_disable_streams(struct v4l2_subdev *sd,
 		return 0;
 
 	/* Get source subdev */
-	s_pad = media_pad_remote_pad_first(&sd->entity.pads[0]);
+	s_pad = media_pad_remote_pad_first(&sd->entity.pads[DCMIPP_ISP_PAD_SINK_VIDEO]);
 	if (!s_pad || !is_media_entity_v4l2_subdev(s_pad->entity))
 		return -EINVAL;
 	s_subdev = media_entity_to_v4l2_subdev(s_pad->entity);

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 03/11] media: stm32: dcmipp: isp: keep a frame sequence counter at isp level
  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 ` Alain Volmat
  2026-12-04 11:11 ` [PATCH 04/11] media: stm32: dcmipp: capture: use ISP frame sequence for main & aux pipes Alain Volmat
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

In preparation of the introduction of ISP statistics and control,
add frame counting at the ISP subdev level so that this becomes the
reference for pipe1 (and pipe2 when fed from the ISP) as well as
ISP statistics and parameter video devices.

Export the helper dcmipp_isp_is_aux_output_enabled so that other
entities can query whether the ISP feeds the aux pipe.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 .../platform/st/stm32/stm32-dcmipp/dcmipp-common.h |  5 ++++
 .../platform/st/stm32/stm32-dcmipp/dcmipp-isp.c    | 31 +++++++++++++++++++---
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
index aa32b64acf52..442d4c90e591 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
@@ -264,6 +264,10 @@ struct dcmipp_isp_device {
 	struct device *dev;
 
 	void __iomem *regs;
+
+	u32 frame_sequence;
+
+	u32 vsync_mask;
 };
 
 struct dcmipp_pixelproc_device {
@@ -396,6 +400,7 @@ void dcmipp_capture_ent_release(struct dcmipp_ent_device *ved);
 struct dcmipp_ent_device *dcmipp_isp_ent_init(const char *entity_name,
 					      struct dcmipp_device *dcmipp);
 void dcmipp_isp_ent_release(struct dcmipp_ent_device *ved);
+bool dcmipp_isp_is_aux_output_enabled(struct dcmipp_isp_device *isp);
 struct dcmipp_ent_device *
 dcmipp_pixelproc_ent_init(const char *entity_name,
 			  struct dcmipp_device *dcmipp);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
index d8ce12a2cbcb..dfa3e27a02ee 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
@@ -37,6 +37,9 @@
 #define DCMIPP_P1DMCR_TYPE_GBRG		0x2
 #define DCMIPP_P1DMCR_TYPE_BGGR		0x3
 
+#define DCMIPP_CMSR2_P1VSYNCF	BIT(18)
+#define DCMIPP_CMSR2_P2VSYNCF	BIT(26)
+
 #define ISP_MEDIA_BUS_SINK_FMT_DEFAULT MEDIA_BUS_FMT_RGB565_1X16
 #define ISP_MEDIA_BUS_SRC_FMT_DEFAULT MEDIA_BUS_FMT_RGB888_1X24
 
@@ -302,7 +305,7 @@ static void dcmipp_isp_config_demosaicing(struct dcmipp_isp_device *isp,
 	reg_set(isp, DCMIPP_P1DMCR, val);
 }
 
-static bool dcmipp_isp_is_aux_output_enabled(struct dcmipp_isp_device *isp)
+bool dcmipp_isp_is_aux_output_enabled(struct dcmipp_isp_device *isp)
 {
 	struct media_link *link;
 
@@ -356,10 +359,13 @@ static int dcmipp_isp_enable_streams(struct v4l2_subdev *sd,
 	s_subdev = media_entity_to_v4l2_subdev(s_pad->entity);
 
 	/* Check if link between ISP & Pipe2 postproc is enabled */
-	if (dcmipp_isp_is_aux_output_enabled(isp))
+	isp->vsync_mask = DCMIPP_CMSR2_P1VSYNCF;
+	if (dcmipp_isp_is_aux_output_enabled(isp)) {
 		reg_clear(isp, DCMIPP_P1FSCR, DCMIPP_P1FSCR_PIPEDIFF);
-	else
+		isp->vsync_mask |= DCMIPP_CMSR2_P2VSYNCF;
+	} else {
 		reg_set(isp, DCMIPP_P1FSCR, DCMIPP_P1FSCR_PIPEDIFF);
+	}
 
 	/* Configure Statistic Removal */
 	crop = v4l2_subdev_state_get_crop(state, DCMIPP_ISP_PAD_SINK_VIDEO);
@@ -374,6 +380,9 @@ static int dcmipp_isp_enable_streams(struct v4l2_subdev *sd,
 	/* Configure Demosaicing */
 	dcmipp_isp_config_demosaicing(isp, state);
 
+	/* First VSYNC will increment the counter, making first frame 0 */
+	isp->frame_sequence = U32_MAX;
+
 	ret = v4l2_subdev_enable_streams(s_subdev, s_pad->index, BIT_ULL(0));
 	if (ret < 0) {
 		dev_err(isp->dev,
@@ -459,6 +468,20 @@ void dcmipp_isp_ent_release(struct dcmipp_ent_device *ved)
 	dcmipp_ent_sd_unregister(ved, &isp->sd);
 }
 
+static irqreturn_t dcmipp_isp_irq_callback(int irq, void *arg)
+{
+	struct dcmipp_isp_device *isp =
+			container_of(arg, struct dcmipp_isp_device, ved);
+
+	if (!v4l2_subdev_is_streaming(&isp->sd) ||
+	    !(isp->ved.cmsr2 & isp->vsync_mask))
+		return IRQ_HANDLED;
+
+	isp->frame_sequence++;
+
+	return IRQ_HANDLED;
+}
+
 struct dcmipp_ent_device *dcmipp_isp_ent_init(const char *entity_name,
 					      struct dcmipp_device *dcmipp)
 {
@@ -482,7 +505,7 @@ struct dcmipp_ent_device *dcmipp_isp_ent_init(const char *entity_name,
 				     MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER,
 				     ARRAY_SIZE(pads_flag), pads_flag,
 				     &dcmipp_isp_int_ops, &dcmipp_isp_ops,
-				     NULL, NULL);
+				     dcmipp_isp_irq_callback, NULL);
 	if (ret) {
 		kfree(isp);
 		return ERR_PTR(ret);

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 04/11] media: stm32: dcmipp: capture: use ISP frame sequence for main & aux pipes
  2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
                   ` (2 preceding siblings ...)
  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 ` Alain Volmat
  2026-12-04 11:11 ` [PATCH 05/11] media: uapi: st: dcmipp: add description of ISP stats & param buffers Alain Volmat
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

When the pipe is fed by the ISP (always for the MAIN and depending on
the media graph for the AUX), the sequence number is based on the
frame counter coming from the ISP subdev. This will allow to have
frame sequence number matching with sequence number used also in the
ISP statistics / control buffers.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 .../media/platform/st/stm32/stm32-dcmipp/dcmipp-capture.c   | 13 ++++++++++++-
 .../media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h    |  2 ++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-capture.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-capture.c
index 4d35372c292b..2eb0e1997f78 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-capture.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-capture.c
@@ -558,6 +558,11 @@ static int dcmipp_capture_start_streaming(struct vb2_queue *vq,
 		goto err_pm_put;
 	}
 
+	/* MAIN pipe is always fed by the ISP, AUX pipe only if linked to it */
+	vcap->isp_fed = vcap->pipe_id == 1 ||
+			(vcap->pipe_id == 2 && vcap->ved.dcmipp->isp &&
+			 dcmipp_isp_is_aux_output_enabled(vcap->ved.dcmipp->isp));
+
 	ret = v4l2_subdev_enable_streams(vcap->s_subdev,
 					 vcap->s_subdev_pad_nb, BIT_ULL(0));
 	if (ret)
@@ -854,7 +859,10 @@ static void dcmipp_buffer_done(struct dcmipp_capture_device *vcap,
 
 	vbuf = &buf->vb;
 
-	vbuf->sequence = vcap->sequence++;
+	if (vcap->isp_fed)
+		vbuf->sequence = vcap->active_sequence;
+	else
+		vbuf->sequence = vcap->sequence++;
 	vbuf->field = V4L2_FIELD_NONE;
 	vbuf->vb2_buf.timestamp = ktime_get_ns();
 	vb2_set_plane_payload(&vbuf->vb2_buf, 0, bytesused);
@@ -969,6 +977,9 @@ static irqreturn_t dcmipp_capture_irq_thread(int irq, void *arg)
 
 	if (vcap->cmsr2 & cmsr2_pxvsyncf) {
 		vcap->count.vsync++;
+
+		if (vcap->isp_fed)
+			vcap->active_sequence = vcap->ved.dcmipp->isp->frame_sequence;
 		if (vcap->state == DCMIPP_WAIT_FOR_BUFFER) {
 			vcap->count.underrun++;
 			goto out;
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
index 442d4c90e591..b40ed25dcf73 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
@@ -223,6 +223,8 @@ struct dcmipp_capture_device {
 	/* mutex used as vdev and queue lock */
 	struct mutex lock;
 	u32 sequence;
+	bool isp_fed;
+	u32 active_sequence;
 	struct v4l2_subdev *s_subdev;
 	u32 s_subdev_pad_nb;
 

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 05/11] media: uapi: st: dcmipp: add description of ISP stats & param buffers
  2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
                   ` (3 preceding siblings ...)
  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
  2026-12-04 11:11 ` [PATCH 06/11] media: uapi: add STM32 DCMIPP ISP META formats Alain Volmat
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 06/11] media: uapi: add STM32 DCMIPP ISP META formats
  2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
                   ` (4 preceding siblings ...)
  2026-12-04 11:11 ` [PATCH 05/11] media: uapi: st: dcmipp: add description of ISP stats & param buffers Alain Volmat
@ 2026-12-04 11:11 ` Alain Volmat
  2026-12-04 11:11 ` [PATCH 07/11] media: stm32: dcmipp: isp: expose active sink format & compose Alain Volmat
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

Add uAPI for STM32 DCMIPP ISP META formats (parameters / statistics)
  V4L2_META_FMT_ST_DCMIPP_ISP_PARAMS
  V4L2_META_FMT_ST_DCMIPP_ISP_STAT

Change-Id: I1baa9f2660e69c4fe7f27ef0828c4d756ba635ef
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 .../userspace-api/media/v4l/meta-formats.rst       |  1 +
 .../userspace-api/media/v4l/metafmt-st-dcmipp.rst  | 74 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 drivers/media/v4l2-core/v4l2-ioctl.c               |  2 +
 include/uapi/linux/videodev2.h                     |  4 ++
 5 files changed, 82 insertions(+)

diff --git a/Documentation/userspace-api/media/v4l/meta-formats.rst b/Documentation/userspace-api/media/v4l/meta-formats.rst
index b5455229837e..19f9016076b4 100644
--- a/Documentation/userspace-api/media/v4l/meta-formats.rst
+++ b/Documentation/userspace-api/media/v4l/meta-formats.rst
@@ -22,6 +22,7 @@ These formats are used for the :ref:`metadata` interface only.
     metafmt-pisp-fe
     metafmt-rkisp1
     metafmt-rppx1
+    metafmt-st-dcmipp
     metafmt-uvc
     metafmt-uvc-msxu-1-5
     metafmt-vivid
diff --git a/Documentation/userspace-api/media/v4l/metafmt-st-dcmipp.rst b/Documentation/userspace-api/media/v4l/metafmt-st-dcmipp.rst
new file mode 100644
index 000000000000..5e4157cacf76
--- /dev/null
+++ b/Documentation/userspace-api/media/v4l/metafmt-st-dcmipp.rst
@@ -0,0 +1,74 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. _v4l2-meta-fmt-st-dcmipp-isp-params:
+.. _v4l2-meta-fmt-st-dcmipp-isp-stat:
+
+*****************************************************************************************
+V4L2_META_FMT_ST_DCMIPP_ISP_PARAMS ('STIP'), V4L2_META_FMT_ST_DCMIPP_ISP_STAT ('STIS')
+*****************************************************************************************
+
+Configuration Parameters
+========================
+
+The configuration parameters of the STM32 DCMIPP ISP are passed to the
+``dcmipp_main_isp_params_output`` metadata output video device, using the
+:c:type:`v4l2_meta_format` interface. Userspace must populate the type member
+with a value from :c:type:`stm32_dcmipp_params_block_type`.
+
+Parameters are applied once per frame and take effect on the frame following
+the one for which the buffer is returned (see the buffer sequence number).
+
+.. code-block:: c
+
+	struct v4l2_isp_buffer *params = (struct v4l2_isp_buffer *)buffer;
+	struct stm32_dcmipp_params_blc *blc;
+
+	params->version = V4L2_ISP_VERSION_V1;
+	params->data_size = 0;
+
+	blc = (struct stm32_dcmipp_params_blc *)params->data;
+	blc->header.type = STM32_DCMIPP_PARAMS_BLOCK_TYPE_BLC;
+	blc->header.flags = V4L2_ISP_PARAMS_FL_BLOCK_ENABLE;
+	blc->header.size = sizeof(*blc);
+	blc->blc_r = 16;
+	blc->blc_g = 16;
+	blc->blc_b = 16;
+
+	params->data_size += sizeof(*blc);
+
+Statistics
+==========
+
+The statistics are captured from the ``dcmipp_main_isp_stat_capture`` metadata
+capture video node using the :c:type:`v4l2_meta_format` interface.
+Blocks present within the metadata can be identified via the value
+:c:type:`stm32_dcmipp_stats_block_type`.  Which blocks are present depends on the
+statistics profile selected through the ``STM32_DCMIPP_PARAMS_BLOCK_TYPE_STAT``
+parameters block.
+
+.. code-block:: c
+
+	const struct v4l2_isp_buffer *stats = (struct v4l2_isp_buffer *)buf;
+	size_t offset = 0;
+
+	while (offset < stats->data_size) {
+		const union stm32_dcmipp_stats_block *block =
+			(const void *)(stats->data + offset);
+
+		offset += block->header.size;
+
+		switch (block->header.type) {
+		case STM32_DCMIPP_STATS_BLOCK_TYPE_PRE:
+		case STM32_DCMIPP_STATS_BLOCK_TYPE_POST:
+			/* block->avr_bins */
+			break;
+		case STM32_DCMIPP_STATS_BLOCK_TYPE_BPR:
+			/* block->bpr */
+			break;
+		}
+	}
+
+STM32 DCMIPP uAPI data types
+============================
+
+.. kernel-doc:: include/uapi/linux/media/st/dcmipp_config.h
diff --git a/MAINTAINERS b/MAINTAINERS
index cbf3d071801e..f98287fb0843 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16951,6 +16951,7 @@ S:	Supported
 T:	git git://linuxtv.org/media.git
 F:	Documentation/devicetree/bindings/media/st,stm32-dcmi.yaml
 F:	Documentation/devicetree/bindings/media/st,stm32-dcmipp.yaml
+F:	Documentation/userspace-api/media/v4l/metafmt-st-dcmipp.rst
 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
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 17ba1ae70735..479c58906a22 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1473,6 +1473,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 	case V4L2_META_FMT_MALI_C55_STATS:	descr = "ARM Mali-C55 ISP 3A Statistics"; break;
 	case V4L2_META_FMT_RPPX1_PARAMS:	descr = "Dreamchip RPP-X1 ISP Parameters"; break;
 	case V4L2_META_FMT_RPPX1_STATS:	descr = "Dreamchip RPP-X1 ISP Statistics"; break;
+	case V4L2_META_FMT_ST_DCMIPP_ISP_PARAMS: descr = "STM32 DCMIPP ISP Parameters"; break;
+	case V4L2_META_FMT_ST_DCMIPP_ISP_STAT:	descr = "STM32 DCMIPP 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/videodev2.h b/include/uapi/linux/videodev2.h
index 5373dba640fa..61af3fe86f8b 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -893,6 +893,10 @@ struct v4l2_pix_format {
 #define V4L2_META_FMT_RPPX1_PARAMS	v4l2_fourcc('D', 'R', '1', 'P') /* Dreamchip RPP-X1 Parameters */
 #define V4L2_META_FMT_RPPX1_STATS	v4l2_fourcc('D', 'R', '1', 'S') /* Dreamchip RPP-X1 Statistics */
 
+/* Vendor specific - used for STM32_DCMIPP camera sub-system */
+#define V4L2_META_FMT_ST_DCMIPP_ISP_PARAMS	v4l2_fourcc('S', 'T', 'I', 'P') /* STM32 DCMIPP ISP Parameters */
+#define V4L2_META_FMT_ST_DCMIPP_ISP_STAT	v4l2_fourcc('S', 'T', 'I', 'S') /* STM32 DCMIPP ISP Statistics */
+
 #ifdef __KERNEL__
 /*
  * Line-based metadata formats. Remember to update v4l_fill_fmtdesc() when

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 07/11] media: stm32: dcmipp: isp: expose active sink format & compose
  2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
                   ` (5 preceding siblings ...)
  2026-12-04 11:11 ` [PATCH 06/11] media: uapi: add STM32 DCMIPP ISP META formats Alain Volmat
@ 2026-12-04 11:11 ` Alain Volmat
  2026-12-04 11:11 ` [PATCH 08/11] media: stm32: dcmipp: addition of a statistics capture device Alain Volmat
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

Expose the ISP subdev active sink format and compose size via the dcmipp
main structure in order to be used by ISP statistics video device.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h | 3 +++
 drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c    | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
index b40ed25dcf73..21ee903ae3a8 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
@@ -267,6 +267,9 @@ struct dcmipp_isp_device {
 
 	void __iomem *regs;
 
+	u32 sink_code;
+	struct v4l2_rect sink_compose;
+
 	u32 frame_sequence;
 
 	u32 vsync_mask;
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
index dfa3e27a02ee..4678b6fefafc 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
@@ -380,6 +380,10 @@ static int dcmipp_isp_enable_streams(struct v4l2_subdev *sd,
 	/* Configure Demosaicing */
 	dcmipp_isp_config_demosaicing(isp, state);
 
+	/* Make the active frame information available to other entities */
+	isp->sink_code = v4l2_subdev_state_get_format(state, DCMIPP_ISP_PAD_SINK_VIDEO)->code;
+	isp->sink_compose = *v4l2_subdev_state_get_compose(state, DCMIPP_ISP_PAD_SINK_VIDEO);
+
 	/* First VSYNC will increment the counter, making first frame 0 */
 	isp->frame_sequence = U32_MAX;
 

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 08/11] media: stm32: dcmipp: addition of a statistics capture device
  2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
                   ` (6 preceding siblings ...)
  2026-12-04 11:11 ` [PATCH 07/11] media: stm32: dcmipp: isp: expose active sink format & compose Alain Volmat
@ 2026-12-04 11:11 ` Alain Volmat
  2026-12-04 11:11 ` [PATCH 09/11] media: stm32: dcmipp: addition of isp param output device Alain Volmat
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

This commit adds the statistics capture device from which
application are able to grab buffers containing structured
frame statistics gathered by the DCMIPP ISP block.

The statistics produced depends on configuration done via the
ISP parameter buffer given by the video output device for ISP
parameters.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 drivers/media/platform/st/stm32/Kconfig            |   2 +
 .../media/platform/st/stm32/stm32-dcmipp/Makefile  |   2 +-
 .../platform/st/stm32/stm32-dcmipp/dcmipp-common.h |  56 ++
 .../platform/st/stm32/stm32-dcmipp/dcmipp-isp.c    |   1 +
 .../st/stm32/stm32-dcmipp/dcmipp-statcap.c         | 773 +++++++++++++++++++++
 5 files changed, 833 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/st/stm32/Kconfig b/drivers/media/platform/st/stm32/Kconfig
index f12e67bcc9bc..8ac1b1943e15 100644
--- a/drivers/media/platform/st/stm32/Kconfig
+++ b/drivers/media/platform/st/stm32/Kconfig
@@ -37,6 +37,8 @@ config VIDEO_STM32_DCMIPP
 	depends on ARCH_STM32 || COMPILE_TEST
 	select MEDIA_CONTROLLER
 	select VIDEOBUF2_DMA_CONTIG
+	select V4L2_ISP
+	select VIDEOBUF2_VMALLOC
 	select VIDEO_V4L2_SUBDEV_API
 	select V4L2_FWNODE
 	help
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/Makefile b/drivers/media/platform/st/stm32/stm32-dcmipp/Makefile
index e35d45a0aca2..7af3c68cebdf 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/Makefile
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 stm32-dcmipp-y := dcmipp-core.o dcmipp-common.o dcmipp-input.o dcmipp-byteproc.o dcmipp-capture.o
-stm32-dcmipp-y += dcmipp-pixelcommon.o dcmipp-isp.o dcmipp-pixelproc.o
+stm32-dcmipp-y += dcmipp-pixelcommon.o dcmipp-isp.o dcmipp-pixelproc.o dcmipp-statcap.o
 
 obj-$(CONFIG_VIDEO_STM32_DCMIPP) += stm32-dcmipp.o
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
index 21ee903ae3a8..3a1e3085128f 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
@@ -19,6 +19,8 @@
 #include <media/v4l2-fwnode.h>
 #include <media/videobuf2-core.h>
 
+#include <uapi/linux/media/st/dcmipp_config.h>
+
 #define DCMIPP_PDEV_NAME "dcmipp"
 
 #define DCMIPP_FRAME_MAX_WIDTH 4096
@@ -270,6 +272,10 @@ struct dcmipp_isp_device {
 	u32 sink_code;
 	struct v4l2_rect sink_compose;
 
+	/* Statistics extraction configuration set by the isp-params device */
+	struct stm32_dcmipp_params_stat stat_cfg;
+	bool stat_cfg_updated;
+
 	u32 frame_sequence;
 
 	u32 vsync_mask;
@@ -287,6 +293,52 @@ struct dcmipp_pixelproc_device {
 	u32 pipe_id;
 };
 
+/* This structure describe the state right after the VSYNC comes */
+enum stat_capture_state {
+	COLD_START,		/* Shadow: AVERAGE (RGB), Physical: stopped */
+	/* Full capture profile */
+	PHY_AV_RGB_SHA_BIN_0,	/* Shadow: BIN_0, Physical: AVERAGE (RGB) */
+	PHY_BIN_0_SHA_BIN_1,	/* Shadow: BIN_1, Physical: BIN_0 */
+	PHY_BIN_1_SHA_BIN_2,	/* Shadow: BIN_2, Physical: BIN_1 */
+	PHY_BIN_2_SHA_BIN_3,	/* Shadow: BIN_3, Physical: BIN_2 */
+	PHY_BIN_3_SHA_AV_RGB,	/* Shadow: AVERAGE (RGB), Physical: BIN_3 */
+	/* Average pre-post profile */
+	PHY_AV_RGB,	/* Shadow: AVERAGE (RGB), Physical: AVERAGE (RGB) */
+	AV_READ,	/* Capturing AVERAGE / Accumulators with valid AVERAGE */
+};
+
+struct dcmipp_statcap_device {
+	struct dcmipp_ent_device ved;
+	struct video_device vdev;
+	struct device *dev;
+	struct media_pad pad;
+	struct vb2_queue queue;
+	struct list_head buffers;
+	/* Protects the access of variables shared within the interrupt */
+	spinlock_t irqlock;
+	/* Protect this data structure */
+	struct mutex lock;
+	struct v4l2_subdev *s_subdev;
+	struct media_pad *s_pad;
+	u32 frame_format;
+	struct v4l2_rect stat_region;
+	u32 stat_location;
+	bool stat_ready;
+	/* Set while the irq thread may access registers, protected by irqlock */
+	bool streaming;
+
+	/* current and prev state of the capture stat machine */
+	enum stat_capture_state capture_state;
+	enum stat_capture_state prev_capture_state;
+
+	void __iomem *regs;
+
+	/* Local copy of statistics */
+	struct stm32_dcmipp_stats_avr_bins stat_pre;
+	struct stm32_dcmipp_stats_avr_bins stat_post;
+	u32 bad_pixel_count;
+};
+
 /**
  * dcmipp_pads_init - initialize pads
  *
@@ -410,5 +462,9 @@ struct dcmipp_ent_device *
 dcmipp_pixelproc_ent_init(const char *entity_name,
 			  struct dcmipp_device *dcmipp);
 void dcmipp_pixelproc_ent_release(struct dcmipp_ent_device *ved);
+struct dcmipp_ent_device *
+dcmipp_statcap_ent_init(const char *entity_name,
+			struct dcmipp_device *dcmipp);
+void dcmipp_statcap_ent_release(struct dcmipp_ent_device *ved);
 
 #endif
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
index 4678b6fefafc..2d941f1e867c 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
@@ -502,6 +502,7 @@ struct dcmipp_ent_device *dcmipp_isp_ent_init(const char *entity_name,
 		return ERR_PTR(-ENOMEM);
 
 	isp->regs = dcmipp->regs;
+	isp->stat_cfg.bin_comp = STM32_DCMIPP_ISP_STAT_BIN_COMP_L;
 
 	/* Initialize ved and sd */
 	ret = dcmipp_ent_sd_register(&isp->ved, &isp->sd,
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-statcap.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-statcap.c
new file mode 100644
index 000000000000..48696dd8b57e
--- /dev/null
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-statcap.c
@@ -0,0 +1,773 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Driver for STM32 Digital Camera Memory Interface Pixel Processor
+ *
+ * Copyright (C) STMicroelectronics SA 2026
+ * Authors: Alain Volmat <alain.volmat@foss.st.com>
+ *          Fabien Dessenne <fabien.dessenne@foss.st.com>
+ *          Hugues Fruchet <hugues.fruchet@foss.st.com>
+ *          for STMicroelectronics.
+ */
+
+#include <linux/math64.h>
+#include <linux/pm_runtime.h>
+#include <media/v4l2-ioctl.h>
+#include <media/v4l2-isp.h>
+#include <media/v4l2-mc.h>
+#include <media/videobuf2-core.h>
+#include <media/videobuf2-vmalloc.h>
+
+#include "dcmipp-common.h"
+
+#define DCMIPP_STATS_BUF_SIZE	v4l2_isp_buffer_size(STM32_DCMIPP_STATS_MAX_SIZE)
+
+static const struct v4l2_isp_stats_block_type_info dcmipp_stats_blocks_info[] = {
+	[STM32_DCMIPP_STATS_BLOCK_TYPE_PRE] = {
+		.size = sizeof(struct stm32_dcmipp_stats_avr_bins),
+	},
+	[STM32_DCMIPP_STATS_BLOCK_TYPE_POST] = {
+		.size = sizeof(struct stm32_dcmipp_stats_avr_bins),
+	},
+	[STM32_DCMIPP_STATS_BLOCK_TYPE_BPR] = {
+		.size = sizeof(struct stm32_dcmipp_stats_bpr),
+	},
+};
+
+#define DCMIPP_P1BPRSR			0x828
+#define DCMIPP_P1BPRSR_BADCNT_MASK	GENMASK(11, 0)
+
+#define DCMIPP_P1STXCR(a)		(0x850 + ((a) * 0x4))
+#define DCMIPP_P1STXCR_ENABLE		BIT(0)
+#define DCMIPP_P1STXCR_BINS_SHIFT	2
+#define DCMIPP_P1STXCR_SRC_COMP_SHIFT	4
+#define DCMIPP_P1STXCR_SRC_LOC_PRE	0
+#define DCMIPP_P1STXCR_SRC_LOC_POST	1
+#define DCMIPP_P1STXCR_SRC_LOC_SHIFT	6
+#define DCMIPP_P1STXCR_MODE_AVERAGE	0
+#define DCMIPP_P1STXCR_MODE_BINS	BIT(7)
+
+#define DCMIPP_P1STSTR			0x85c
+#define DCMIPP_P1STSTR_HSTART_SHIFT	0
+#define DCMIPP_P1STSTR_HSTART_MASK	GENMASK(11, 0)
+#define DCMIPP_P1STSTR_VSTART_SHIFT	16
+#define DCMIPP_P1STSTR_VSTART_MASK	GENMASK(27, 16)
+
+#define DCMIPP_P1STSZR			0x860
+#define DCMIPP_P1STSZR_HSIZE_SHIFT	0
+#define DCMIPP_P1STSZR_HSIZE_MASK	GENMASK(11, 0)
+#define DCMIPP_P1STSZR_VSIZE_SHIFT	16
+#define DCMIPP_P1STSZR_VSIZE_MASK	GENMASK(27, 16)
+#define DCMIPP_P1STSZR_ENABLE		BIT(31)
+
+#define DCMIPP_P1STXSR(a)		(0x864 + ((a) * 0x4))
+
+struct dcmipp_buf {
+	struct vb2_v4l2_buffer	vb;
+	struct list_head	list;
+};
+
+enum component {
+	COMP_RED = 0,
+	COMP_GREEN,
+	COMP_BLUE,
+};
+
+static int dcmipp_statcap_get_subdev_pad(struct dcmipp_statcap_device *vcap,
+					 struct v4l2_subdev **s_subdev,
+					 struct media_pad **s_pad)
+{
+	struct media_pad *pad;
+
+	if (!vcap->s_subdev || !vcap->s_pad) {
+		pad = media_pad_remote_pad_first(&vcap->vdev.entity.pads[0]);
+		if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
+			return -EINVAL;
+		vcap->s_subdev = media_entity_to_v4l2_subdev(pad->entity);
+		vcap->s_pad = pad;
+	}
+
+	if (s_subdev)
+		*s_subdev = vcap->s_subdev;
+	if (s_pad)
+		*s_pad = vcap->s_pad;
+
+	return 0;
+}
+
+static int dcmipp_statcap_querycap(struct file *file, void *priv,
+				   struct v4l2_capability *cap)
+{
+	strscpy(cap->driver, DCMIPP_PDEV_NAME, sizeof(cap->driver));
+	strscpy(cap->card, KBUILD_MODNAME, sizeof(cap->card));
+
+	return 0;
+}
+
+static int dcmipp_statcap_g_fmt_meta_cap(struct file *file, void *priv,
+					 struct v4l2_format *f)
+{
+	struct v4l2_meta_format *meta = &f->fmt.meta;
+
+	memset(meta, 0, sizeof(*meta));
+	meta->dataformat = V4L2_META_FMT_ST_DCMIPP_ISP_STAT;
+	meta->buffersize = DCMIPP_STATS_BUF_SIZE;
+
+	return 0;
+}
+
+static int dcmipp_statcap_enum_fmt_meta_cap(struct file *file, void *priv,
+					    struct v4l2_fmtdesc *f)
+{
+	if (f->index > 0)
+		return -EINVAL;
+
+	if (f->mbus_code && f->mbus_code != MEDIA_BUS_FMT_METADATA_FIXED)
+		return -EINVAL;
+
+	f->pixelformat = V4L2_META_FMT_ST_DCMIPP_ISP_STAT;
+
+	return 0;
+}
+
+static const struct v4l2_file_operations dcmipp_statcap_fops = {
+	.owner		= THIS_MODULE,
+	.open		= v4l2_fh_open,
+	.release	= vb2_fop_release,
+	.poll		= vb2_fop_poll,
+	.unlocked_ioctl = video_ioctl2,
+	.mmap           = vb2_fop_mmap,
+};
+
+static const struct v4l2_ioctl_ops dcmipp_statcap_ioctl_ops = {
+	.vidioc_querycap = dcmipp_statcap_querycap,
+
+	.vidioc_enum_fmt_meta_cap = dcmipp_statcap_enum_fmt_meta_cap,
+	.vidioc_g_fmt_meta_cap = dcmipp_statcap_g_fmt_meta_cap,
+	.vidioc_s_fmt_meta_cap = dcmipp_statcap_g_fmt_meta_cap,
+	.vidioc_try_fmt_meta_cap = dcmipp_statcap_g_fmt_meta_cap,
+
+	.vidioc_reqbufs = vb2_ioctl_reqbufs,
+	.vidioc_create_bufs = vb2_ioctl_create_bufs,
+	.vidioc_prepare_buf = vb2_ioctl_prepare_buf,
+	.vidioc_querybuf = vb2_ioctl_querybuf,
+	.vidioc_qbuf = vb2_ioctl_qbuf,
+	.vidioc_dqbuf = vb2_ioctl_dqbuf,
+	.vidioc_expbuf = vb2_ioctl_expbuf,
+	.vidioc_streamon = vb2_ioctl_streamon,
+	.vidioc_streamoff = vb2_ioctl_streamoff,
+};
+
+static int dcmipp_statcap_start_streaming(struct vb2_queue *vq,
+					  unsigned int count)
+{
+	struct dcmipp_statcap_device *vcap = vb2_get_drv_priv(vq);
+	struct media_entity *entity = &vcap->vdev.entity;
+	struct dcmipp_buf *buf, *node;
+	struct v4l2_subdev *s_subdev;
+	struct media_pad *s_pad;
+	int ret;
+
+	ret = pm_runtime_resume_and_get(vcap->dev);
+	if (ret < 0) {
+		dev_err(vcap->dev, "%s: Failed to start streaming, cannot get sync (%d)\n",
+			__func__, ret);
+		goto err_buffer_done;
+	}
+
+	ret = media_pipeline_start(entity->pads, &vcap->ved.dcmipp->pipe);
+	if (ret) {
+		dev_dbg(vcap->dev, "%s: Failed to start streaming, media pipeline start error (%d)\n",
+			__func__, ret);
+		goto err_pm_put;
+	}
+
+	/* Get pointer to the source subdev */
+	ret = dcmipp_statcap_get_subdev_pad(vcap, &s_subdev, &s_pad);
+	if (ret)
+		goto err_media_pipeline_stop;
+
+	/* Start all the elements within pipeline */
+	ret = v4l2_subdev_enable_streams(s_subdev, s_pad->index, BIT_ULL(0));
+	if (ret) {
+		dev_err(vcap->dev, "failed to start streaming (%d)\n", ret);
+		goto err_media_pipeline_stop;
+	}
+
+	spin_lock_irq(&vcap->irqlock);
+	vcap->capture_state = COLD_START;
+	vcap->streaming = true;
+	spin_unlock_irq(&vcap->irqlock);
+
+	return 0;
+
+err_media_pipeline_stop:
+	media_pipeline_stop(entity->pads);
+err_pm_put:
+	pm_runtime_put(vcap->dev);
+err_buffer_done:
+	spin_lock_irq(&vcap->irqlock);
+	/*
+	 * Return all buffers to vb2 in QUEUED state.
+	 * This will give ownership back to userspace
+	 */
+	list_for_each_entry_safe(buf, node, &vcap->buffers, list) {
+		list_del_init(&buf->list);
+		vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_QUEUED);
+	}
+	spin_unlock_irq(&vcap->irqlock);
+
+	return ret;
+}
+
+/*
+ * Stop the stream engine. Any remaining buffers in the stream queue are
+ * dequeued and passed on to the vb2 framework marked as STATE_ERROR.
+ */
+static void dcmipp_statcap_stop_streaming(struct vb2_queue *vq)
+{
+	struct dcmipp_statcap_device *vcap = vb2_get_drv_priv(vq);
+	struct dcmipp_buf *buf, *node;
+	struct v4l2_subdev *s_subdev;
+	struct media_pad *s_pad;
+	int ret;
+
+	spin_lock_irq(&vcap->irqlock);
+	vcap->streaming = false;
+	vcap->capture_state = COLD_START;
+	spin_unlock_irq(&vcap->irqlock);
+
+	ret = dcmipp_statcap_get_subdev_pad(vcap, &s_subdev, &s_pad);
+	if (ret) {
+		dev_warn(vcap->dev, "Failed to get source subdev / pad\n");
+		return;
+	}
+
+	ret = v4l2_subdev_disable_streams(s_subdev, s_pad->index, BIT_ULL(0));
+	if (ret)
+		dev_err(vcap->dev, "failed to stop streaming (%d)\n", ret);
+
+	/* Stop the media pipeline */
+	media_pipeline_stop(vcap->vdev.entity.pads);
+
+	spin_lock_irq(&vcap->irqlock);
+
+	/* Return all queued buffers to vb2 in ERROR state */
+	list_for_each_entry_safe(buf, node, &vcap->buffers, list) {
+		list_del_init(&buf->list);
+		vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
+	}
+	INIT_LIST_HEAD(&vcap->buffers);
+
+	spin_unlock_irq(&vcap->irqlock);
+
+	pm_runtime_put(vcap->dev);
+}
+
+static int dcmipp_statcap_buf_prepare(struct vb2_buffer *vb)
+{
+	if (vb2_plane_size(vb, 0) < DCMIPP_STATS_BUF_SIZE)
+		return -EINVAL;
+
+	vb2_set_plane_payload(vb, 0, DCMIPP_STATS_BUF_SIZE);
+
+	return 0;
+}
+
+static void dcmipp_statcap_buf_queue(struct vb2_buffer *vb2_buf)
+{
+	struct dcmipp_statcap_device *vcap = vb2_get_drv_priv(vb2_buf->vb2_queue);
+	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb2_buf);
+	struct dcmipp_buf *buf = container_of(vbuf, struct dcmipp_buf, vb);
+
+	spin_lock_irq(&vcap->irqlock);
+	list_add_tail(&buf->list, &vcap->buffers);
+	spin_unlock_irq(&vcap->irqlock);
+}
+
+static int dcmipp_statcap_queue_setup(struct vb2_queue *vq,
+				      unsigned int *nbuffers,
+				      unsigned int *nplanes,
+				      unsigned int sizes[],
+				      struct device *alloc_devs[])
+{
+	if (*nplanes)
+		return sizes[0] < DCMIPP_STATS_BUF_SIZE ? -EINVAL : 0;
+
+	*nplanes = 1;
+	sizes[0] = DCMIPP_STATS_BUF_SIZE;
+
+	return 0;
+}
+
+static int dcmipp_statcap_buf_init(struct vb2_buffer *vb)
+{
+	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
+	struct dcmipp_buf *buf = container_of(vbuf, struct dcmipp_buf, vb);
+
+	INIT_LIST_HEAD(&buf->list);
+
+	return 0;
+}
+
+static const struct vb2_ops dcmipp_statcap_qops = {
+	.start_streaming	= dcmipp_statcap_start_streaming,
+	.stop_streaming		= dcmipp_statcap_stop_streaming,
+	.buf_init		= dcmipp_statcap_buf_init,
+	.buf_prepare		= dcmipp_statcap_buf_prepare,
+	.buf_queue		= dcmipp_statcap_buf_queue,
+	.queue_setup		= dcmipp_statcap_queue_setup,
+};
+
+static void dcmipp_statcap_release(struct video_device *vdev)
+{
+	struct dcmipp_statcap_device *vcap =
+		container_of(vdev, struct dcmipp_statcap_device, vdev);
+
+	mutex_destroy(&vcap->lock);
+
+	kfree(vcap);
+}
+
+void dcmipp_statcap_ent_release(struct dcmipp_ent_device *ved)
+{
+	struct dcmipp_statcap_device *vcap =
+		container_of(ved, struct dcmipp_statcap_device, ved);
+
+	media_entity_cleanup(ved->ent);
+	vb2_video_unregister_device(&vcap->vdev);
+}
+
+static union stm32_dcmipp_stats_block *
+dcmipp_statcap_init_block(struct dcmipp_statcap_device *vcap,
+			  struct v4l2_isp_buffer *stats, unsigned int type)
+{
+	return (union stm32_dcmipp_stats_block *)
+		v4l2_isp_stats_init_block(vcap->dev, stats,
+					  dcmipp_stats_blocks_info,
+					  ARRAY_SIZE(dcmipp_stats_blocks_info),
+					  type, STM32_DCMIPP_STATS_MAX_SIZE);
+}
+
+static void
+dcmipp_statcap_fill_avr_bins(union stm32_dcmipp_stats_block *block,
+			     const struct stm32_dcmipp_stats_avr_bins *src)
+{
+	memcpy(block->avr_bins.average_rgb, src->average_rgb,
+	       sizeof(src->average_rgb));
+	memcpy(block->avr_bins.bins, src->bins, sizeof(src->bins));
+	block->avr_bins.reserved = 0;
+}
+
+static void dcmipp_statcap_buffer_done(struct dcmipp_statcap_device *vcap,
+				       struct dcmipp_buf *dcmipp_buf)
+{
+	const struct stm32_dcmipp_params_stat *cfg = &vcap->ved.dcmipp->isp->stat_cfg;
+	struct v4l2_isp_buffer *stats;
+	union stm32_dcmipp_stats_block *block;
+
+	stats = vb2_plane_vaddr(&dcmipp_buf->vb.vb2_buf, 0);
+	v4l2_isp_stats_init_buffer(stats, V4L2_ISP_VERSION_V1);
+
+	if (cfg->profile != STM32_DCMIPP_ISP_STAT_PROFILE_AVERAGE_POST) {
+		block = dcmipp_statcap_init_block(vcap, stats,
+						  STM32_DCMIPP_STATS_BLOCK_TYPE_PRE);
+		if (IS_ERR(block))
+			goto err;
+		dcmipp_statcap_fill_avr_bins(block, &vcap->stat_pre);
+	}
+
+	if (cfg->profile != STM32_DCMIPP_ISP_STAT_PROFILE_AVERAGE_PRE) {
+		block = dcmipp_statcap_init_block(vcap, stats,
+						  STM32_DCMIPP_STATS_BLOCK_TYPE_POST);
+		if (IS_ERR(block))
+			goto err;
+		dcmipp_statcap_fill_avr_bins(block, &vcap->stat_post);
+	}
+
+	block = dcmipp_statcap_init_block(vcap, stats,
+					  STM32_DCMIPP_STATS_BLOCK_TYPE_BPR);
+	if (IS_ERR(block))
+		goto err;
+	block->bpr.bad_pixel_count = vcap->bad_pixel_count;
+	block->bpr.reserved = 0;
+
+	vb2_set_plane_payload(&dcmipp_buf->vb.vb2_buf, 0,
+			      v4l2_isp_buffer_size(stats->data_size));
+	/*
+	 * Accumulators read upon this VSYNC contain values of the frame which
+	 * has just ended, that is the last frame used to build these stats
+	 */
+	dcmipp_buf->vb.sequence = vcap->ved.dcmipp->isp->frame_sequence - 1;
+	dcmipp_buf->vb.vb2_buf.timestamp = ktime_get_ns();
+	vb2_buffer_done(&dcmipp_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
+	return;
+
+err:
+	vb2_buffer_done(&dcmipp_buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
+}
+
+static u32 dcmipp_statcap_get_src(u32 location, u32 comp)
+{
+	return (location << DCMIPP_P1STXCR_SRC_LOC_SHIFT) | (comp << DCMIPP_P1STXCR_SRC_COMP_SHIFT);
+}
+
+static void dcmipp_statcap_read_avg_stats(struct dcmipp_statcap_device *vcap)
+{
+	struct stm32_dcmipp_stats_avr_bins *avr_bins =
+		vcap->stat_location == DCMIPP_P1STXCR_SRC_LOC_PRE ? &vcap->stat_pre :
+								    &vcap->stat_post;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(vcap->stat_pre.average_rgb); i++) {
+		/* 64 bits since the normalization overflows 32 bits */
+		u64 avg = reg_read(vcap, DCMIPP_P1STXSR(i));
+
+		/* Normalize values */
+		avg <<= 8;
+
+		/* Depending on the position & component, need to adjust in case of Bayer */
+		if (vcap->stat_location == DCMIPP_P1STXCR_SRC_LOC_PRE &&
+		    vcap->frame_format >= MEDIA_BUS_FMT_SBGGR8_1X8 &&
+		    vcap->frame_format <= MEDIA_BUS_FMT_SRGGB16_1X16) {
+			/* raw bayer: RGB component not present for all pixels */
+			if (i == COMP_RED || i == COMP_BLUE)
+				avg *= 4;
+			else if (i == COMP_GREEN)
+				avg *= 2;
+		}
+
+		/* Divide by number of pixels */
+		avr_bins->average_rgb[i] =
+			div_u64(avg, vcap->stat_region.width * vcap->stat_region.height);
+	}
+}
+
+static void dcmipp_statcap_config_area(struct dcmipp_statcap_device *vcap,
+				       const struct stm32_dcmipp_params_stat *cfg)
+{
+	const struct v4l2_rect *frame = &vcap->ved.dcmipp->isp->sink_compose;
+
+	if (cfg->width &&
+	    cfg->left + cfg->width <= frame->width &&
+	    cfg->top + cfg->height <= frame->height) {
+		vcap->stat_region.left = cfg->left;
+		vcap->stat_region.top = cfg->top;
+		vcap->stat_region.width = cfg->width;
+		vcap->stat_region.height = cfg->height;
+
+		reg_clear(vcap, DCMIPP_P1STSTR,
+			  DCMIPP_P1STSTR_HSTART_MASK | DCMIPP_P1STSTR_VSTART_MASK);
+		reg_set(vcap, DCMIPP_P1STSTR,
+			(cfg->left << DCMIPP_P1STSTR_HSTART_SHIFT) |
+			(cfg->top << DCMIPP_P1STSTR_VSTART_SHIFT));
+
+		reg_clear(vcap, DCMIPP_P1STSZR,
+			  DCMIPP_P1STSZR_HSIZE_MASK | DCMIPP_P1STSZR_VSIZE_MASK);
+		reg_set(vcap, DCMIPP_P1STSZR,
+			(cfg->width << DCMIPP_P1STSZR_HSIZE_SHIFT) |
+			(cfg->height << DCMIPP_P1STSZR_VSIZE_SHIFT) |
+			DCMIPP_P1STSZR_ENABLE);
+		return;
+	}
+
+	if (cfg->width)
+		dev_dbg(vcap->dev, "Stat area not fitting into frame, using whole frame\n");
+
+	/* Statistics computed over the whole frame */
+	vcap->stat_region = *frame;
+	reg_clear(vcap, DCMIPP_P1STSZR, DCMIPP_P1STSZR_ENABLE);
+}
+
+static void dcmipp_statcap_update_local_buf(struct dcmipp_statcap_device *vcap)
+{
+	const struct stm32_dcmipp_params_stat *cfg = &vcap->ved.dcmipp->isp->stat_cfg;
+	struct stm32_dcmipp_stats_avr_bins *avr_bins =
+		vcap->stat_location == DCMIPP_P1STXCR_SRC_LOC_PRE ? &vcap->stat_pre :
+								    &vcap->stat_post;
+	int i;
+
+	/* Read the bad pixel count stat and store it locally */
+	vcap->bad_pixel_count = reg_read(vcap, DCMIPP_P1BPRSR) &
+					 DCMIPP_P1BPRSR_BADCNT_MASK;
+
+	/*
+	 * This is the core function for statistic extraction, within the
+	 * irq thread, on EACH VSYNC we update the shadow registers to
+	 * read accumulators values, (except on first few frames), store
+	 * them into the internal structure, and update the shadow registers
+	 * to be able to get new values 2 VSYNCs after (the values read at
+	 * the next VSYNC being already based on the configuration that has
+	 * just been written on the previous VSYNC
+	 */
+	switch (vcap->capture_state) {
+	case COLD_START:
+		vcap->stat_ready = false;
+		memset(&vcap->stat_pre, 0, sizeof(vcap->stat_pre));
+		memset(&vcap->stat_post, 0, sizeof(vcap->stat_post));
+
+		/* Get frame format info from ISP sink pad */
+		vcap->frame_format = vcap->ved.dcmipp->isp->sink_code;
+
+		dcmipp_statcap_config_area(vcap, cfg);
+
+		/*
+		 * All stats profile starts from the PRE statistics, except the
+		 * AVERAGE POST
+		 */
+		if (cfg->profile == STM32_DCMIPP_ISP_STAT_PROFILE_AVERAGE_POST)
+			vcap->stat_location = DCMIPP_P1STXCR_SRC_LOC_POST;
+		else
+			vcap->stat_location = DCMIPP_P1STXCR_SRC_LOC_PRE;
+		/*
+		 * We've just started, set control registers to capture
+		 * AVERAGES (RGB) and leave
+		 */
+		for (i = 0; i < 3; i++)
+			reg_write(vcap, DCMIPP_P1STXCR(i),
+				  DCMIPP_P1STXCR_MODE_AVERAGE |
+				  dcmipp_statcap_get_src(vcap->stat_location, i) |
+				  cfg->avg_filter << DCMIPP_P1STXCR_BINS_SHIFT |
+				  DCMIPP_P1STXCR_ENABLE);
+		break;
+
+	case PHY_AV_RGB_SHA_BIN_0:
+		/* Set control registers to capture the 1st set of BINS */
+		for (i = 0; i < 3; i++)
+			reg_write(vcap, DCMIPP_P1STXCR(i),
+				  DCMIPP_P1STXCR_MODE_BINS |
+				  dcmipp_statcap_get_src(vcap->stat_location, cfg->bin_comp) |
+				  0 << DCMIPP_P1STXCR_BINS_SHIFT |
+				  DCMIPP_P1STXCR_ENABLE);
+
+		if (vcap->prev_capture_state == PHY_BIN_3_SHA_AV_RGB) {
+			/* The data capture refer to the previous location */
+			avr_bins = !(vcap->stat_location == DCMIPP_P1STXCR_SRC_LOC_PRE) ?
+					&vcap->stat_pre : &vcap->stat_post;
+			/* Accumulators contains the 4th set of BINS */
+			for (i = 0; i < 3; i++)
+				avr_bins->bins[i + 9] = reg_read(vcap, DCMIPP_P1STXSR(i));
+			/* By the time we get the 4th POST BINS, stat_location is again in PRE */
+			if (vcap->stat_location == DCMIPP_P1STXCR_SRC_LOC_PRE)
+				vcap->stat_ready = true;
+		}
+		break;
+
+	case PHY_BIN_0_SHA_BIN_1:
+		/* Set control registers to capture the 2nd set of BINS */
+		for (i = 0; i < 3; i++)
+			reg_write(vcap, DCMIPP_P1STXCR(i),
+				  DCMIPP_P1STXCR_MODE_BINS |
+				  dcmipp_statcap_get_src(vcap->stat_location, cfg->bin_comp) |
+				  1 << DCMIPP_P1STXCR_BINS_SHIFT |
+				  DCMIPP_P1STXCR_ENABLE);
+
+		/* Accumulators contains the AVERAGES (RGB) */
+		dcmipp_statcap_read_avg_stats(vcap);
+		break;
+
+	case PHY_BIN_1_SHA_BIN_2:
+		/* Set control registers to capture the 3rd set of BINS */
+		for (i = 0; i < 3; i++)
+			reg_write(vcap, DCMIPP_P1STXCR(i),
+				  DCMIPP_P1STXCR_MODE_BINS |
+				  dcmipp_statcap_get_src(vcap->stat_location, cfg->bin_comp) |
+				  2 << DCMIPP_P1STXCR_BINS_SHIFT |
+				  DCMIPP_P1STXCR_ENABLE);
+
+		/* Accumulators contains the 1st set of BINS */
+		for (i = 0; i < 3; i++)
+			avr_bins->bins[i] = reg_read(vcap, DCMIPP_P1STXSR(i));
+		break;
+
+	case PHY_BIN_2_SHA_BIN_3:
+		/* Set control registers to capture the 4th set of BINS */
+		for (i = 0; i < 3; i++)
+			reg_write(vcap, DCMIPP_P1STXCR(i),
+				  DCMIPP_P1STXCR_MODE_BINS |
+				  dcmipp_statcap_get_src(vcap->stat_location, cfg->bin_comp) |
+				  3 << DCMIPP_P1STXCR_BINS_SHIFT |
+				  DCMIPP_P1STXCR_ENABLE);
+
+		/* Accumulators contains the 2nd set of BINS */
+		for (i = 0; i < 3; i++)
+			avr_bins->bins[i + 3] = reg_read(vcap, DCMIPP_P1STXSR(i));
+		break;
+
+	case PHY_BIN_3_SHA_AV_RGB:
+		/* Set control registers to capture the AVERAGES (RGB) */
+		for (i = 0; i < 3; i++)
+			/* Usage of !location is on purpose to switch to the other location */
+			reg_write(vcap, DCMIPP_P1STXCR(i),
+				  DCMIPP_P1STXCR_MODE_AVERAGE |
+				  dcmipp_statcap_get_src(!vcap->stat_location, i) |
+				  cfg->avg_filter << DCMIPP_P1STXCR_BINS_SHIFT |
+				  DCMIPP_P1STXCR_ENABLE);
+
+		/* Accumulators contains the 3rd set of BINS */
+		for (i = 0; i < 3; i++)
+			avr_bins->bins[i + 6] = reg_read(vcap, DCMIPP_P1STXSR(i));
+		break;
+
+	case AV_READ:
+		/* State used for the AVERAGE PRE capture mode */
+		dcmipp_statcap_read_avg_stats(vcap);
+		vcap->stat_ready = true;
+		break;
+
+	default:
+		break;
+	}
+
+	/* Update the capture_state & prev_capture_state */
+	switch (cfg->profile) {
+	case STM32_DCMIPP_ISP_STAT_PROFILE_FULL:
+		vcap->prev_capture_state = vcap->capture_state;
+		if (vcap->capture_state < PHY_BIN_3_SHA_AV_RGB) {
+			vcap->capture_state++;
+		} else {
+			vcap->stat_location = !vcap->stat_location;
+			vcap->capture_state = PHY_AV_RGB_SHA_BIN_0;
+		}
+		break;
+
+	case STM32_DCMIPP_ISP_STAT_PROFILE_AVERAGE_PRE:
+	case STM32_DCMIPP_ISP_STAT_PROFILE_AVERAGE_POST:
+		if (vcap->capture_state == COLD_START)
+			vcap->capture_state = PHY_AV_RGB;
+		else if (vcap->capture_state == PHY_AV_RGB)
+			vcap->capture_state = AV_READ;
+		break;
+	}
+}
+
+static irqreturn_t dcmipp_statcap_irq_thread(int irq, void *arg)
+{
+	struct dcmipp_statcap_device *vcap =
+			container_of(arg, struct dcmipp_statcap_device, ved);
+	struct dcmipp_isp_device *isp = vcap->ved.dcmipp->isp;
+	struct dcmipp_buf *cur_buf = NULL;
+
+	/* The statistics state machine progresses once per frame */
+	if (!(vcap->ved.cmsr2 & isp->vsync_mask))
+		return IRQ_HANDLED;
+
+	spin_lock_irq(&vcap->irqlock);
+
+	/* We only do things if we are streaming */
+	if (!vcap->streaming) {
+		spin_unlock_irq(&vcap->irqlock);
+		return IRQ_HANDLED;
+	}
+
+	/* Restart the capture cycle upon statistics configuration change */
+	if (isp->stat_cfg_updated) {
+		isp->stat_cfg_updated = false;
+		vcap->capture_state = COLD_START;
+	}
+
+	dcmipp_statcap_update_local_buf(vcap);
+
+	/* If a full capture cycle has been done, output data to a buffer */
+	if (vcap->stat_ready) {
+		/* Get an available buffer */
+		if (!list_empty(&vcap->buffers)) {
+			cur_buf = list_first_entry(&vcap->buffers, struct dcmipp_buf, list);
+			list_del(&cur_buf->list);
+		}
+		if (cur_buf)
+			dcmipp_statcap_buffer_done(vcap, cur_buf);
+	}
+
+	spin_unlock_irq(&vcap->irqlock);
+
+	return IRQ_HANDLED;
+}
+
+struct dcmipp_ent_device *
+dcmipp_statcap_ent_init(const char *entity_name, struct dcmipp_device *dcmipp)
+{
+	struct dcmipp_statcap_device *vcap;
+	struct device *dev = dcmipp->dev;
+	struct video_device *vdev;
+	struct vb2_queue *q;
+	int ret = 0;
+
+	/* Allocate the dcmipp_statcap_device struct */
+	vcap = kzalloc_obj(*vcap);
+	if (!vcap)
+		return ERR_PTR(-ENOMEM);
+
+	vcap->ved.dcmipp = dcmipp;
+
+	/* Initialize the media entity */
+	vcap->vdev.entity.name = entity_name;
+	vcap->vdev.entity.function = MEDIA_ENT_F_IO_V4L;
+	vcap->pad.flags = MEDIA_PAD_FL_SINK;
+	ret = media_entity_pads_init(&vcap->vdev.entity, 1, &vcap->pad);
+	if (ret)
+		goto err_free_vcap;
+
+	/* Initialize the lock */
+	mutex_init(&vcap->lock);
+
+	/* Initialize the vb2 queue */
+	q = &vcap->queue;
+	q->type = V4L2_BUF_TYPE_META_CAPTURE;
+	q->io_modes = VB2_MMAP | VB2_DMABUF;
+	q->lock = &vcap->lock;
+	q->drv_priv = vcap;
+	q->buf_struct_size = sizeof(struct dcmipp_buf);
+	q->ops = &dcmipp_statcap_qops;
+	q->mem_ops = &vb2_vmalloc_memops;
+	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+	q->min_queued_buffers = 1;
+	q->dev = dev;
+
+	ret = vb2_queue_init(q);
+	if (ret) {
+		dev_err(dev, "%s: vb2 queue init failed (err=%d)\n",
+			entity_name, ret);
+		goto err_clean_m_ent;
+	}
+
+	/* Initialize buffer list and its lock */
+	INIT_LIST_HEAD(&vcap->buffers);
+	spin_lock_init(&vcap->irqlock);
+
+	/* Fill the dcmipp_ent_device struct */
+	vcap->ved.ent = &vcap->vdev.entity;
+	vcap->ved.handler = NULL;
+	vcap->ved.thread_fn = dcmipp_statcap_irq_thread;
+	vcap->dev = dev;
+	vcap->regs = dcmipp->regs;
+
+	/* Initialize the video_device struct */
+	vdev = &vcap->vdev;
+	vdev->device_caps = V4L2_CAP_META_CAPTURE | V4L2_CAP_STREAMING |
+			    V4L2_CAP_IO_MC;
+	vdev->release = dcmipp_statcap_release;
+	vdev->fops = &dcmipp_statcap_fops;
+	vdev->ioctl_ops = &dcmipp_statcap_ioctl_ops;
+	vdev->lock = &vcap->lock;
+	vdev->queue = q;
+	vdev->v4l2_dev = &dcmipp->v4l2_dev;
+	strscpy(vdev->name, entity_name, sizeof(vdev->name));
+	video_set_drvdata(vdev, &vcap->ved);
+
+	/* Register the video_device with the v4l2 and the media framework */
+	ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
+	if (ret) {
+		dev_err(dev, "%s: video register failed (err=%d)\n",
+			vcap->vdev.name, ret);
+		goto err_clean_m_ent;
+	}
+
+	return &vcap->ved;
+
+err_clean_m_ent:
+	media_entity_cleanup(&vcap->vdev.entity);
+err_free_vcap:
+	kfree(vcap);
+
+	return ERR_PTR(ret);
+}

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 09/11] media: stm32: dcmipp: addition of isp param output device
  2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
                   ` (7 preceding siblings ...)
  2026-12-04 11:11 ` [PATCH 08/11] media: stm32: dcmipp: addition of a statistics capture device Alain Volmat
@ 2026-12-04 11:11 ` 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
  10 siblings, 0 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

Addition of the output metadata device used to inject ISP parameters.

The parameters buffer is in charge of configuring the ISP processing
blocks (such as demosaicing filter, exposure, contrast etc ..) but
also parameters used to generate the statistics via the stat capture
video device.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 .../media/platform/st/stm32/stm32-dcmipp/Makefile  |   2 +-
 .../platform/st/stm32/stm32-dcmipp/dcmipp-common.h |   4 +
 .../st/stm32/stm32-dcmipp/dcmipp-isp-params.c      | 860 +++++++++++++++++++++
 3 files changed, 865 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/Makefile b/drivers/media/platform/st/stm32/stm32-dcmipp/Makefile
index 7af3c68cebdf..e6cf321994a5 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/Makefile
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 stm32-dcmipp-y := dcmipp-core.o dcmipp-common.o dcmipp-input.o dcmipp-byteproc.o dcmipp-capture.o
-stm32-dcmipp-y += dcmipp-pixelcommon.o dcmipp-isp.o dcmipp-pixelproc.o dcmipp-statcap.o
+stm32-dcmipp-y += dcmipp-pixelcommon.o dcmipp-isp.o dcmipp-pixelproc.o dcmipp-statcap.o dcmipp-isp-params.o
 
 obj-$(CONFIG_VIDEO_STM32_DCMIPP) += stm32-dcmipp.o
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
index 3a1e3085128f..226a2ab59445 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
@@ -466,5 +466,9 @@ struct dcmipp_ent_device *
 dcmipp_statcap_ent_init(const char *entity_name,
 			struct dcmipp_device *dcmipp);
 void dcmipp_statcap_ent_release(struct dcmipp_ent_device *ved);
+struct dcmipp_ent_device *
+dcmipp_isp_params_ent_init(const char *entity_name,
+			   struct dcmipp_device *dcmipp);
+void dcmipp_isp_params_ent_release(struct dcmipp_ent_device *ved);
 
 #endif
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp-params.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp-params.c
new file mode 100644
index 000000000000..b01aafda21ba
--- /dev/null
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp-params.c
@@ -0,0 +1,860 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Driver for STM32 Digital Camera Memory Interface Pixel Processor
+ *
+ * Copyright (C) STMicroelectronics SA 2023
+ * Authors: Alain Volmat <alain.volmat@foss.st.com>
+ *          Fabien Dessenne <fabien.dessenne@foss.st.com>
+ *          Hugues Fruchet <hugues.fruchet@foss.st.com>
+ *          for STMicroelectronics.
+ */
+
+#include <linux/iopoll.h>
+#include <linux/pm_runtime.h>
+#include <media/v4l2-ioctl.h>
+#include <media/v4l2-isp.h>
+#include <media/v4l2-mc.h>
+#include <media/videobuf2-core.h>
+#include <media/videobuf2-vmalloc.h>
+#include <uapi/linux/media/st/dcmipp_config.h>
+
+#include "dcmipp-common.h"
+
+#define DCMIPP_PARAMS_BUF_SIZE	v4l2_isp_buffer_size(STM32_DCMIPP_PARAMS_MAX_SIZE)
+
+struct dcmipp_buf {
+	struct vb2_v4l2_buffer	vb;
+	struct list_head	list;
+	/* Kernel copy of the parameters, protected against userspace changes */
+	struct v4l2_isp_buffer	*config;
+};
+
+struct dcmipp_isp_params_device {
+	struct dcmipp_ent_device ved;
+	struct video_device vdev;
+	struct device *dev;
+	struct media_pad pad;
+	struct vb2_queue queue;
+	struct list_head buffers;
+	/* Protects the access of variables shared within the interrupt */
+	spinlock_t irqlock;
+	/* mutex used as vdev and queue lock */
+	struct mutex lock;
+
+	void __iomem *regs;
+};
+
+static int dcmipp_isp_params_querycap(struct file *file, void *priv,
+				      struct v4l2_capability *cap)
+{
+	strscpy(cap->driver, DCMIPP_PDEV_NAME, sizeof(cap->driver));
+	strscpy(cap->card, KBUILD_MODNAME, sizeof(cap->card));
+
+	return 0;
+}
+
+static int dcmipp_isp_params_g_fmt_meta_out(struct file *file, void *priv,
+					    struct v4l2_format *f)
+{
+	struct v4l2_meta_format *meta = &f->fmt.meta;
+
+	if (f->type != V4L2_BUF_TYPE_META_OUTPUT)
+		return -EINVAL;
+
+	memset(meta, 0, sizeof(*meta));
+	meta->dataformat = V4L2_META_FMT_ST_DCMIPP_ISP_PARAMS;
+	meta->buffersize = DCMIPP_PARAMS_BUF_SIZE;
+
+	return 0;
+}
+
+static int dcmipp_isp_params_enum_fmt_meta_out(struct file *file, void *priv,
+					       struct v4l2_fmtdesc *f)
+{
+	if (f->index > 0 || f->type != V4L2_BUF_TYPE_META_OUTPUT)
+		return -EINVAL;
+
+	if (f->mbus_code && f->mbus_code != MEDIA_BUS_FMT_METADATA_FIXED)
+		return -EINVAL;
+
+	f->pixelformat = V4L2_META_FMT_ST_DCMIPP_ISP_PARAMS;
+
+	return 0;
+}
+
+static const struct v4l2_ioctl_ops dcmipp_isp_params_ioctl_ops = {
+	.vidioc_querycap = dcmipp_isp_params_querycap,
+
+	.vidioc_enum_fmt_meta_out = dcmipp_isp_params_enum_fmt_meta_out,
+	.vidioc_g_fmt_meta_out = dcmipp_isp_params_g_fmt_meta_out,
+	.vidioc_s_fmt_meta_out = dcmipp_isp_params_g_fmt_meta_out,
+	.vidioc_try_fmt_meta_out = dcmipp_isp_params_g_fmt_meta_out,
+
+	.vidioc_reqbufs = vb2_ioctl_reqbufs,
+	.vidioc_create_bufs = vb2_ioctl_create_bufs,
+	.vidioc_prepare_buf = vb2_ioctl_prepare_buf,
+	.vidioc_querybuf = vb2_ioctl_querybuf,
+	.vidioc_qbuf = vb2_ioctl_qbuf,
+	.vidioc_dqbuf = vb2_ioctl_dqbuf,
+	.vidioc_expbuf = vb2_ioctl_expbuf,
+	.vidioc_streamon = vb2_ioctl_streamon,
+	.vidioc_streamoff = vb2_ioctl_streamoff,
+};
+
+/*
+ * Stop the stream engine. Any remaining buffers in the stream queue are
+ * dequeued and passed on to the vb2 framework marked as STATE_ERROR.
+ */
+static void dcmipp_isp_params_stop_streaming(struct vb2_queue *vq)
+{
+	struct dcmipp_isp_params_device *vout = vb2_get_drv_priv(vq);
+	struct dcmipp_buf *buf, *node;
+
+	spin_lock_irq(&vout->irqlock);
+
+	/* Return all queued buffers to vb2 in ERROR state */
+	list_for_each_entry_safe(buf, node, &vout->buffers, list) {
+		list_del_init(&buf->list);
+		vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
+	}
+	INIT_LIST_HEAD(&vout->buffers);
+
+	spin_unlock_irq(&vout->irqlock);
+}
+
+static int dcmipp_isp_params_buf_prepare(struct vb2_buffer *vb);
+
+static void dcmipp_isp_params_buf_queue(struct vb2_buffer *vb2_buf)
+{
+	struct dcmipp_isp_params_device *vout =
+		vb2_get_drv_priv(vb2_buf->vb2_queue);
+	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb2_buf);
+	struct dcmipp_buf *buf = container_of(vbuf, struct dcmipp_buf, vb);
+
+	spin_lock_irq(&vout->irqlock);
+	list_add_tail(&buf->list, &vout->buffers);
+	spin_unlock_irq(&vout->irqlock);
+}
+
+static int dcmipp_isp_params_queue_setup(struct vb2_queue *vq,
+					 unsigned int *nbuffers,
+					 unsigned int *nplanes,
+					 unsigned int sizes[],
+					 struct device *alloc_devs[])
+{
+	if (*nplanes)
+		return sizes[0] < DCMIPP_PARAMS_BUF_SIZE ? -EINVAL : 0;
+
+	*nplanes = 1;
+	sizes[0] = DCMIPP_PARAMS_BUF_SIZE;
+
+	return 0;
+}
+
+static int dcmipp_isp_params_buf_init(struct vb2_buffer *vb)
+{
+	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
+	struct dcmipp_buf *buf = container_of(vbuf, struct dcmipp_buf, vb);
+
+	INIT_LIST_HEAD(&buf->list);
+
+	buf->config = kvmalloc(DCMIPP_PARAMS_BUF_SIZE, GFP_KERNEL);
+	if (!buf->config)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void dcmipp_isp_params_buf_cleanup(struct vb2_buffer *vb)
+{
+	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
+	struct dcmipp_buf *buf = container_of(vbuf, struct dcmipp_buf, vb);
+
+	kvfree(buf->config);
+	buf->config = NULL;
+}
+
+static const struct vb2_ops dcmipp_isp_params_qops = {
+	.stop_streaming		= dcmipp_isp_params_stop_streaming,
+	.buf_init		= dcmipp_isp_params_buf_init,
+	.buf_cleanup		= dcmipp_isp_params_buf_cleanup,
+	.buf_prepare		= dcmipp_isp_params_buf_prepare,
+	.buf_queue		= dcmipp_isp_params_buf_queue,
+
+	.queue_setup		= dcmipp_isp_params_queue_setup,
+};
+
+static void dcmipp_isp_params_release(struct video_device *vdev)
+{
+	struct dcmipp_isp_params_device *vout =
+		container_of(vdev, struct dcmipp_isp_params_device, vdev);
+
+	mutex_destroy(&vout->lock);
+
+	kfree(vout);
+}
+
+void dcmipp_isp_params_ent_release(struct dcmipp_ent_device *ved)
+{
+	struct dcmipp_isp_params_device *vout =
+		container_of(ved, struct dcmipp_isp_params_device, ved);
+
+	media_entity_cleanup(ved->ent);
+	vb2_video_unregister_device(&vout->vdev);
+}
+
+/*
+ * Blocks without ENABLE / DISABLE flag keep their current enable state.
+ * DISABLE blocks only contain their header.
+ */
+#define DCMIPP_PARAMS_IS_DISABLE(cfg) \
+	((cfg)->header.flags & V4L2_ISP_PARAMS_FL_BLOCK_DISABLE)
+
+static u32 dcmipp_isp_params_en(struct dcmipp_isp_params_device *vout, u32 reg,
+				u32 bit, u16 flags)
+{
+	if (flags & V4L2_ISP_PARAMS_FL_BLOCK_ENABLE)
+		return bit;
+	if (flags & V4L2_ISP_PARAMS_FL_BLOCK_DISABLE)
+		return 0;
+
+	return reg_read(vout, reg) & bit;
+}
+
+/* Blocks without enable bit can not be disabled */
+static int dcmipp_isp_params_valid_no_disable(struct device *dev,
+					      const struct v4l2_isp_block_header *block)
+{
+	if (block->flags & V4L2_ISP_PARAMS_FL_BLOCK_DISABLE) {
+		dev_dbg(dev, "Block type %u can not be disabled\n", block->type);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+#define DCMIPP_P1BPRCR			0x824
+#define DCMIPP_P1BPRCR_ENABLE		BIT(0)
+#define DCMIPP_P1BPRCR_STRENGTH_SHIFT	1
+#define DCMIPP_P1BPRCR_STRENGTH_MASK	0x07
+static int dcmipp_isp_params_valid_bpr(struct device *dev,
+				       const struct v4l2_isp_block_header *block)
+{
+	const struct stm32_dcmipp_params_bpr *cfg =
+		container_of(block, struct stm32_dcmipp_params_bpr, header);
+
+	if (DCMIPP_PARAMS_IS_DISABLE(cfg))
+		return 0;
+
+	if (memchr_inv(cfg->reserved, 0, sizeof(cfg->reserved)))
+		return -EINVAL;
+
+	if (cfg->strength & ~DCMIPP_P1BPRCR_STRENGTH_MASK)
+		return -EINVAL;
+
+	return 0;
+}
+
+static void
+dcmipp_isp_params_apply_bpr(struct dcmipp_isp_params_device *vout,
+			    const struct stm32_dcmipp_params_bpr *cfg)
+{
+	if (DCMIPP_PARAMS_IS_DISABLE(cfg)) {
+		reg_clear(vout, DCMIPP_P1BPRCR, DCMIPP_P1BPRCR_ENABLE);
+		return;
+	}
+
+	reg_write(vout, DCMIPP_P1BPRCR,
+		  dcmipp_isp_params_en(vout, DCMIPP_P1BPRCR,
+				       DCMIPP_P1BPRCR_ENABLE,
+				       cfg->header.flags) |
+		  cfg->strength << DCMIPP_P1BPRCR_STRENGTH_SHIFT);
+}
+
+#define DCMIPP_P1BLCCR			0x840
+#define DCMIPP_P1BLCCR_ENABLE		BIT(0)
+#define DCMIPP_P1BLCCR_BLCB_SHIFT	8
+#define DCMIPP_P1BLCCR_BLCG_SHIFT	16
+#define DCMIPP_P1BLCCR_BLCR_SHIFT	24
+static int dcmipp_isp_params_valid_blc(struct device *dev,
+				       const struct v4l2_isp_block_header *block)
+{
+	const struct stm32_dcmipp_params_blc *cfg =
+		container_of(block, struct stm32_dcmipp_params_blc, header);
+
+	if (DCMIPP_PARAMS_IS_DISABLE(cfg))
+		return 0;
+
+	if (memchr_inv(cfg->reserved, 0, sizeof(cfg->reserved)))
+		return -EINVAL;
+
+	return 0;
+}
+
+static void
+dcmipp_isp_params_apply_blc(struct dcmipp_isp_params_device *vout,
+			    const struct stm32_dcmipp_params_blc *cfg)
+{
+	if (DCMIPP_PARAMS_IS_DISABLE(cfg)) {
+		reg_clear(vout, DCMIPP_P1BLCCR, DCMIPP_P1BLCCR_ENABLE);
+		return;
+	}
+
+	reg_write(vout, DCMIPP_P1BLCCR,
+		  dcmipp_isp_params_en(vout, DCMIPP_P1BLCCR,
+				       DCMIPP_P1BLCCR_ENABLE,
+				       cfg->header.flags) |
+		  cfg->blc_r << DCMIPP_P1BLCCR_BLCR_SHIFT |
+		  cfg->blc_g << DCMIPP_P1BLCCR_BLCG_SHIFT |
+		  cfg->blc_b << DCMIPP_P1BLCCR_BLCB_SHIFT);
+}
+
+#define DCMIPP_P1EXCR1			0x844
+#define DCMIPP_P1EXCR1_ENABLE		BIT(0)
+#define DCMIPP_P1EXCR1_MULTR_SHIFT	20
+#define DCMIPP_P1EXCR1_SHFR_SHIFT	28
+#define DCMIPP_P1EXCR1_SHFR_MASK	0x07
+
+#define DCMIPP_P1EXCR2			0x848
+#define DCMIPP_P1EXCR2_MULTB_SHIFT	4
+#define DCMIPP_P1EXCR2_SHFB_SHIFT	12
+#define DCMIPP_P1EXCR2_MULTG_SHIFT	20
+#define DCMIPP_P1EXCR2_SHFG_SHIFT	28
+
+static int dcmipp_isp_params_valid_ex(struct device *dev,
+				      const struct v4l2_isp_block_header *block)
+{
+	const struct stm32_dcmipp_params_ex *cfg =
+		container_of(block, struct stm32_dcmipp_params_ex, header);
+
+	if (DCMIPP_PARAMS_IS_DISABLE(cfg))
+		return 0;
+
+	if (memchr_inv(cfg->reserved, 0, sizeof(cfg->reserved)))
+		return -EINVAL;
+
+	if (cfg->shift_r & ~DCMIPP_P1EXCR1_SHFR_MASK ||
+	    cfg->shift_g & ~DCMIPP_P1EXCR1_SHFR_MASK ||
+	    cfg->shift_b & ~DCMIPP_P1EXCR1_SHFR_MASK)
+		return -EINVAL;
+
+	return 0;
+}
+
+static void
+dcmipp_isp_params_apply_ex(struct dcmipp_isp_params_device *vout,
+			   const struct stm32_dcmipp_params_ex *cfg)
+{
+	if (DCMIPP_PARAMS_IS_DISABLE(cfg)) {
+		reg_clear(vout, DCMIPP_P1EXCR1, DCMIPP_P1EXCR1_ENABLE);
+		return;
+	}
+
+	reg_write(vout, DCMIPP_P1EXCR1,
+		  dcmipp_isp_params_en(vout, DCMIPP_P1EXCR1,
+				       DCMIPP_P1EXCR1_ENABLE,
+				       cfg->header.flags) |
+		  cfg->mult_r << DCMIPP_P1EXCR1_MULTR_SHIFT |
+		  cfg->shift_r << DCMIPP_P1EXCR1_SHFR_SHIFT);
+
+	reg_write(vout, DCMIPP_P1EXCR2,
+		  cfg->mult_b << DCMIPP_P1EXCR2_MULTB_SHIFT |
+		  cfg->shift_b << DCMIPP_P1EXCR2_SHFB_SHIFT |
+		  cfg->mult_g << DCMIPP_P1EXCR2_MULTG_SHIFT |
+		  cfg->shift_g << DCMIPP_P1EXCR2_SHFG_SHIFT);
+}
+
+#define DCMIPP_P1DMCR			0x870
+#define DCMIPP_P1DMCR_PEAK_SHIFT	16
+#define DCMIPP_P1DMCR_PEAK_MASK		0x07
+#define DCMIPP_P1DMCR_LINEV_SHIFT	20
+#define DCMIPP_P1DMCR_LINEV_MASK	0x07
+#define DCMIPP_P1DMCR_LINEH_SHIFT	24
+#define DCMIPP_P1DMCR_LINEH_MASK	0x07
+#define DCMIPP_P1DMCR_EDGE_SHIFT	28
+#define DCMIPP_P1DMCR_EDGE_MASK		0x07
+static int dcmipp_isp_params_valid_dm(struct device *dev,
+				      const struct v4l2_isp_block_header *block)
+{
+	const struct stm32_dcmipp_params_dm *cfg =
+		container_of(block, struct stm32_dcmipp_params_dm, header);
+	int ret;
+
+	ret = dcmipp_isp_params_valid_no_disable(dev, block);
+	if (ret)
+		return ret;
+
+	if (memchr_inv(cfg->reserved, 0, sizeof(cfg->reserved)))
+		return -EINVAL;
+
+	if (cfg->edge & ~DCMIPP_P1DMCR_EDGE_MASK ||
+	    cfg->lineh & ~DCMIPP_P1DMCR_LINEH_MASK ||
+	    cfg->linev & ~DCMIPP_P1DMCR_LINEV_MASK ||
+	    cfg->peak & ~DCMIPP_P1DMCR_PEAK_MASK)
+		return -EINVAL;
+
+	return 0;
+}
+
+static void
+dcmipp_isp_params_apply_dm(struct dcmipp_isp_params_device *vout,
+			   const struct stm32_dcmipp_params_dm *cfg)
+{
+	u32 dmcr, mask;
+
+	mask = DCMIPP_P1DMCR_PEAK_MASK << DCMIPP_P1DMCR_PEAK_SHIFT |
+	       DCMIPP_P1DMCR_LINEV_MASK << DCMIPP_P1DMCR_LINEV_SHIFT |
+	       DCMIPP_P1DMCR_LINEH_MASK << DCMIPP_P1DMCR_LINEH_SHIFT |
+	       DCMIPP_P1DMCR_EDGE_MASK << DCMIPP_P1DMCR_EDGE_SHIFT;
+
+	dmcr = reg_read(vout, DCMIPP_P1DMCR) & ~mask;
+	reg_write(vout, DCMIPP_P1DMCR, dmcr |
+		  cfg->peak << DCMIPP_P1DMCR_PEAK_SHIFT |
+		  cfg->lineh << DCMIPP_P1DMCR_LINEH_SHIFT |
+		  cfg->linev << DCMIPP_P1DMCR_LINEV_SHIFT |
+		  cfg->edge << DCMIPP_P1DMCR_EDGE_SHIFT);
+}
+
+#define DCMIPP_P1CCCR			0x880
+#define DCMIPP_P1CCCR_ENABLE		BIT(0)
+#define DCMIPP_P1CCCR_TYPE_YUV		0
+#define DCMIPP_P1CCCR_TYPE_RGB		BIT(1)
+#define DCMIPP_P1CCCR_CLAMP		BIT(2)
+#define DCMIPP_P1CCRR_RGB_MASK		0x7ff
+#define DCMIPP_P1CCRR_A_MASK		0x3ff
+#define DCMIPP_P1CCRR1			0x884
+#define DCMIPP_P1CCRR1_RG_SHIFT		16
+#define DCMIPP_P1CCRR1_RR_SHIFT		0
+#define DCMIPP_P1CCRR2			0x888
+#define DCMIPP_P1CCRR2_RA_SHIFT		16
+#define DCMIPP_P1CCRR2_RB_SHIFT		0
+#define DCMIPP_P1CCGR1			0x88c
+#define DCMIPP_P1CCGR1_GG_SHIFT		16
+#define DCMIPP_P1CCGR1_GR_SHIFT		0
+#define DCMIPP_P1CCGR2			0x890
+#define DCMIPP_P1CCGR2_GA_SHIFT		16
+#define DCMIPP_P1CCGR2_GB_SHIFT		0
+#define DCMIPP_P1CCBR1			0x894
+#define DCMIPP_P1CCBR1_BG_SHIFT		16
+#define DCMIPP_P1CCBR1_BR_SHIFT		0
+#define DCMIPP_P1CCBR2			0x898
+#define DCMIPP_P1CCBR2_BA_SHIFT		16
+#define DCMIPP_P1CCBR2_BB_SHIFT		0
+static int dcmipp_isp_params_valid_cc(struct device *dev,
+				      const struct v4l2_isp_block_header *block)
+{
+	const struct stm32_dcmipp_params_cc *cfg =
+		container_of(block, struct stm32_dcmipp_params_cc, header);
+
+	if (DCMIPP_PARAMS_IS_DISABLE(cfg))
+		return 0;
+
+	if (cfg->reserved)
+		return -EINVAL;
+
+	if (cfg->clamp > STM32_DCMIPP_ISP_CC_CLAMP_YUV235)
+		return -EINVAL;
+
+	if (cfg->rr & ~DCMIPP_P1CCRR_RGB_MASK || cfg->rg & ~DCMIPP_P1CCRR_RGB_MASK ||
+	    cfg->rb & ~DCMIPP_P1CCRR_RGB_MASK || cfg->gr & ~DCMIPP_P1CCRR_RGB_MASK ||
+	    cfg->gg & ~DCMIPP_P1CCRR_RGB_MASK || cfg->gb & ~DCMIPP_P1CCRR_RGB_MASK ||
+	    cfg->br & ~DCMIPP_P1CCRR_RGB_MASK || cfg->bg & ~DCMIPP_P1CCRR_RGB_MASK ||
+	    cfg->bb & ~DCMIPP_P1CCRR_RGB_MASK || cfg->ra & ~DCMIPP_P1CCRR_A_MASK ||
+	    cfg->ga & ~DCMIPP_P1CCRR_A_MASK || cfg->ba & ~DCMIPP_P1CCRR_A_MASK)
+		return -EINVAL;
+
+	return 0;
+}
+
+static void
+dcmipp_isp_params_apply_cc(struct dcmipp_isp_params_device *vout,
+			   const struct stm32_dcmipp_params_cc *cfg)
+{
+	u32 cccr;
+
+	if (DCMIPP_PARAMS_IS_DISABLE(cfg)) {
+		reg_clear(vout, DCMIPP_P1CCCR, DCMIPP_P1CCCR_ENABLE);
+		return;
+	}
+
+	cccr = dcmipp_isp_params_en(vout, DCMIPP_P1CCCR, DCMIPP_P1CCCR_ENABLE,
+				    cfg->header.flags);
+
+	if (cfg->clamp != STM32_DCMIPP_ISP_CC_CLAMP_DISABLED) {
+		cccr |= DCMIPP_P1CCCR_CLAMP;
+		cccr |= cfg->clamp == STM32_DCMIPP_ISP_CC_CLAMP_YUV235 ?
+			DCMIPP_P1CCCR_TYPE_YUV : DCMIPP_P1CCCR_TYPE_RGB;
+	}
+
+	reg_write(vout, DCMIPP_P1CCCR, cccr);
+	reg_write(vout, DCMIPP_P1CCRR1,
+		  cfg->rr << DCMIPP_P1CCRR1_RR_SHIFT |
+		  cfg->rg << DCMIPP_P1CCRR1_RG_SHIFT);
+	reg_write(vout, DCMIPP_P1CCRR2,
+		  cfg->ra << DCMIPP_P1CCRR2_RA_SHIFT |
+		  cfg->rb << DCMIPP_P1CCRR2_RB_SHIFT);
+	reg_write(vout, DCMIPP_P1CCGR1,
+		  cfg->gr << DCMIPP_P1CCGR1_GR_SHIFT |
+		  cfg->gg << DCMIPP_P1CCGR1_GG_SHIFT);
+	reg_write(vout, DCMIPP_P1CCGR2,
+		  cfg->gb << DCMIPP_P1CCGR2_GB_SHIFT |
+		  cfg->ga << DCMIPP_P1CCGR2_GA_SHIFT);
+	reg_write(vout, DCMIPP_P1CCBR1,
+		  cfg->br << DCMIPP_P1CCBR1_BR_SHIFT |
+		  cfg->bg << DCMIPP_P1CCBR1_BG_SHIFT);
+	reg_write(vout, DCMIPP_P1CCBR2,
+		  cfg->bb << DCMIPP_P1CCBR2_BB_SHIFT |
+		  cfg->ba << DCMIPP_P1CCBR2_BA_SHIFT);
+}
+
+#define DCMIPP_P1CTCR1			0x8a0
+#define DCMIPP_P1CTCR1_ENABLE		BIT(0)
+#define DCMIPP_P1CTCR_LUM_MASK		0x3f
+#define DCMIPP_P1CTCR1_LUM0_SHIFT	9
+
+#define DCMIPP_P1CTCR2			0x8a4
+#define DCMIPP_P1CTCR2_LUM4_SHIFT	1
+#define DCMIPP_P1CTCR2_LUM3_SHIFT	9
+#define DCMIPP_P1CTCR2_LUM2_SHIFT	17
+#define DCMIPP_P1CTCR2_LUM1_SHIFT	25
+
+#define DCMIPP_P1CTCR3			0x8a8
+#define DCMIPP_P1CTCR3_LUM8_SHIFT	1
+#define DCMIPP_P1CTCR3_LUM7_SHIFT	9
+#define DCMIPP_P1CTCR3_LUM6_SHIFT	17
+#define DCMIPP_P1CTCR3_LUM5_SHIFT	25
+static int dcmipp_isp_params_valid_ce(struct device *dev,
+				      const struct v4l2_isp_block_header *block)
+{
+	const struct stm32_dcmipp_params_ce *cfg =
+		container_of(block, struct stm32_dcmipp_params_ce, header);
+	int i;
+
+	if (DCMIPP_PARAMS_IS_DISABLE(cfg))
+		return 0;
+
+	if (memchr_inv(cfg->reserved, 0, sizeof(cfg->reserved)))
+		return -EINVAL;
+
+	for (i = 0; i < ARRAY_SIZE(cfg->lum); i++)
+		if (cfg->lum[i] & ~DCMIPP_P1CTCR_LUM_MASK)
+			return -EINVAL;
+
+	return 0;
+}
+
+static void
+dcmipp_isp_params_apply_ce(struct dcmipp_isp_params_device *vout,
+			   const struct stm32_dcmipp_params_ce *cfg)
+{
+	if (DCMIPP_PARAMS_IS_DISABLE(cfg)) {
+		reg_clear(vout, DCMIPP_P1CTCR1, DCMIPP_P1CTCR1_ENABLE);
+		return;
+	}
+
+	reg_write(vout, DCMIPP_P1CTCR1,
+		  dcmipp_isp_params_en(vout, DCMIPP_P1CTCR1,
+				       DCMIPP_P1CTCR1_ENABLE,
+				       cfg->header.flags) |
+		  cfg->lum[0] << DCMIPP_P1CTCR1_LUM0_SHIFT);
+	reg_write(vout, DCMIPP_P1CTCR2,
+		  cfg->lum[1] << DCMIPP_P1CTCR2_LUM1_SHIFT |
+		  cfg->lum[2] << DCMIPP_P1CTCR2_LUM2_SHIFT |
+		  cfg->lum[3] << DCMIPP_P1CTCR2_LUM3_SHIFT |
+		  cfg->lum[4] << DCMIPP_P1CTCR2_LUM4_SHIFT);
+	reg_write(vout, DCMIPP_P1CTCR3,
+		  cfg->lum[5] << DCMIPP_P1CTCR3_LUM5_SHIFT |
+		  cfg->lum[6] << DCMIPP_P1CTCR3_LUM6_SHIFT |
+		  cfg->lum[7] << DCMIPP_P1CTCR3_LUM7_SHIFT |
+		  cfg->lum[8] << DCMIPP_P1CTCR3_LUM8_SHIFT);
+}
+
+#define DCMIPP_STAT_AREA_MAX	0xfff
+static int dcmipp_isp_params_valid_stat(struct device *dev,
+					const struct v4l2_isp_block_header *block)
+{
+	const struct stm32_dcmipp_params_stat *cfg =
+		container_of(block, struct stm32_dcmipp_params_stat, header);
+	int ret;
+
+	ret = dcmipp_isp_params_valid_no_disable(dev, block);
+	if (ret)
+		return ret;
+
+	if (memchr_inv(cfg->reserved, 0, sizeof(cfg->reserved)))
+		return -EINVAL;
+
+	if (cfg->profile > STM32_DCMIPP_ISP_STAT_PROFILE_AVERAGE_POST ||
+	    cfg->avg_filter > STM32_DCMIPP_ISP_STAT_AVG_FILTER_EXCL64 ||
+	    cfg->bin_comp > STM32_DCMIPP_ISP_STAT_BIN_COMP_L)
+		return -EINVAL;
+
+	if (cfg->left > DCMIPP_STAT_AREA_MAX || cfg->top > DCMIPP_STAT_AREA_MAX ||
+	    cfg->width > DCMIPP_STAT_AREA_MAX || cfg->height > DCMIPP_STAT_AREA_MAX)
+		return -EINVAL;
+
+	/* Either the whole frame (all 0) or a valid area */
+	if (!cfg->width || !cfg->height) {
+		if (cfg->width || cfg->height || cfg->left || cfg->top)
+			return -EINVAL;
+	}
+
+	return 0;
+}
+
+static void
+dcmipp_isp_params_apply_stat(struct dcmipp_isp_params_device *vout,
+			     const struct stm32_dcmipp_params_stat *cfg)
+{
+	struct dcmipp_isp_device *isp = vout->ved.dcmipp->isp;
+	struct stm32_dcmipp_params_stat *cur = &isp->stat_cfg;
+
+	/* Only flag an update if the configuration has actually changed */
+	if (cur->left == cfg->left && cur->top == cfg->top &&
+	    cur->width == cfg->width && cur->height == cfg->height &&
+	    cur->profile == cfg->profile &&
+	    cur->avg_filter == cfg->avg_filter &&
+	    cur->bin_comp == cfg->bin_comp)
+		return;
+
+	cur->left = cfg->left;
+	cur->top = cfg->top;
+	cur->width = cfg->width;
+	cur->height = cfg->height;
+	cur->profile = cfg->profile;
+	cur->avg_filter = cfg->avg_filter;
+	cur->bin_comp = cfg->bin_comp;
+	isp->stat_cfg_updated = true;
+}
+
+#define DCMIPP_PARAMS_BLOCK_INFO(type, block, validate)			\
+	[STM32_DCMIPP_PARAMS_BLOCK_TYPE_ ## type] = {			\
+		.size = sizeof(struct stm32_dcmipp_params_ ## block),	\
+		.block_validate = validate,				\
+	}
+
+static const struct v4l2_isp_params_block_type_info
+dcmipp_isp_params_blocks_info[] = {
+	DCMIPP_PARAMS_BLOCK_INFO(BPR, bpr, dcmipp_isp_params_valid_bpr),
+	DCMIPP_PARAMS_BLOCK_INFO(BLC, blc, dcmipp_isp_params_valid_blc),
+	DCMIPP_PARAMS_BLOCK_INFO(EX, ex, dcmipp_isp_params_valid_ex),
+	DCMIPP_PARAMS_BLOCK_INFO(DM, dm, dcmipp_isp_params_valid_dm),
+	DCMIPP_PARAMS_BLOCK_INFO(CC, cc, dcmipp_isp_params_valid_cc),
+	DCMIPP_PARAMS_BLOCK_INFO(CE, ce, dcmipp_isp_params_valid_ce),
+	DCMIPP_PARAMS_BLOCK_INFO(STAT, stat, dcmipp_isp_params_valid_stat),
+};
+
+static int dcmipp_isp_params_buf_prepare(struct vb2_buffer *vb)
+{
+	struct dcmipp_isp_params_device *vout = vb2_get_drv_priv(vb->vb2_queue);
+	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
+	struct dcmipp_buf *buf = container_of(vbuf, struct dcmipp_buf, vb);
+	struct v4l2_isp_buffer *config = vb2_plane_vaddr(vb, 0);
+	int ret;
+
+	if (!config)
+		return -EFAULT;
+
+	ret = v4l2_isp_params_validate_buffer_size(vout->dev, vb,
+						   DCMIPP_PARAMS_BUF_SIZE);
+	if (ret)
+		return ret;
+
+	/*
+	 * Work on a kernel copy of the parameters to protect against userspace
+	 * changing the buffer content once validated.
+	 */
+	memcpy(buf->config, config, vb2_get_plane_payload(vb, 0));
+
+	return v4l2_isp_params_validate_buffer(vout->dev, vb, buf->config,
+					       dcmipp_isp_params_blocks_info,
+					       ARRAY_SIZE(dcmipp_isp_params_blocks_info));
+}
+
+static void
+dcmipp_isp_params_apply(struct dcmipp_isp_params_device *vout,
+			const struct v4l2_isp_buffer *buf)
+{
+	size_t offset = 0;
+
+	/* The buffer has been fully validated in buf_prepare() */
+	while (offset < buf->data_size) {
+		const union stm32_dcmipp_params_block *block =
+			(const union stm32_dcmipp_params_block *)&buf->data[offset];
+
+		switch (block->header.type) {
+		case STM32_DCMIPP_PARAMS_BLOCK_TYPE_BPR:
+			dcmipp_isp_params_apply_bpr(vout, &block->bpr);
+			break;
+		case STM32_DCMIPP_PARAMS_BLOCK_TYPE_BLC:
+			dcmipp_isp_params_apply_blc(vout, &block->blc);
+			break;
+		case STM32_DCMIPP_PARAMS_BLOCK_TYPE_EX:
+			dcmipp_isp_params_apply_ex(vout, &block->ex);
+			break;
+		case STM32_DCMIPP_PARAMS_BLOCK_TYPE_DM:
+			dcmipp_isp_params_apply_dm(vout, &block->dm);
+			break;
+		case STM32_DCMIPP_PARAMS_BLOCK_TYPE_CC:
+			dcmipp_isp_params_apply_cc(vout, &block->cc);
+			break;
+		case STM32_DCMIPP_PARAMS_BLOCK_TYPE_CE:
+			dcmipp_isp_params_apply_ce(vout, &block->ce);
+			break;
+		case STM32_DCMIPP_PARAMS_BLOCK_TYPE_STAT:
+			dcmipp_isp_params_apply_stat(vout, &block->stat);
+			break;
+		}
+
+		offset += block->header.size;
+	}
+}
+
+static irqreturn_t dcmipp_isp_params_irq_thread(int irq, void *arg)
+{
+	struct dcmipp_isp_params_device *vout =
+			container_of(arg, struct dcmipp_isp_params_device, ved);
+	u32 cmsr2 = vout->ved.cmsr2;
+	struct dcmipp_buf *cur_buf = NULL;
+
+	/* Parameters are applied once per frame, upon VSYNC of the pipes fed by the ISP */
+	if (!(cmsr2 & vout->ved.dcmipp->isp->vsync_mask))
+		return IRQ_HANDLED;
+
+	spin_lock_irq(&vout->irqlock);
+
+	/* Get an available buffer */
+	if (list_empty(&vout->buffers))
+		goto out;
+
+	cur_buf = list_first_entry(&vout->buffers, struct dcmipp_buf, list);
+	list_del(&cur_buf->list);
+
+	/* Handle the params configuration */
+	dcmipp_isp_params_apply(vout, cur_buf->config);
+
+	/*
+	 * ISP registers being shadowed, parameters written now are taken into
+	 * account on next VSYNC, hence apply to the next frame
+	 */
+	cur_buf->vb.sequence = vout->ved.dcmipp->isp->frame_sequence + 1;
+	cur_buf->vb.vb2_buf.timestamp = ktime_get_ns();
+	vb2_buffer_done(&cur_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
+
+out:
+	spin_unlock_irq(&vout->irqlock);
+
+	return IRQ_HANDLED;
+}
+
+/* Metadata have no format to be validated against the ISP pad */
+static int dcmipp_isp_params_link_validate(struct media_link *link)
+{
+	return 0;
+}
+
+static const struct media_entity_operations dcmipp_isp_params_entity_ops = {
+	.link_validate = dcmipp_isp_params_link_validate,
+};
+
+static const struct v4l2_file_operations dcmipp_isp_params_fops = {
+	.owner		= THIS_MODULE,
+	.open		= v4l2_fh_open,
+	.release	= vb2_fop_release,
+	.mmap           = vb2_fop_mmap,
+	.poll		= vb2_fop_poll,
+	.unlocked_ioctl = video_ioctl2,
+};
+
+struct dcmipp_ent_device *
+dcmipp_isp_params_ent_init(const char *entity_name,
+			   struct dcmipp_device *dcmipp)
+{
+	struct dcmipp_isp_params_device *vout;
+	struct device *dev = dcmipp->dev;
+	struct video_device *vdev;
+	struct vb2_queue *q;
+	int ret = 0;
+
+	/* Allocate the dcmipp_cap_device struct */
+	vout = kzalloc_obj(*vout);
+	if (!vout)
+		return ERR_PTR(-ENOMEM);
+
+	vout->ved.dcmipp = dcmipp;
+
+	/* Initialize the media entity */
+	vout->vdev.entity.name = entity_name;
+	vout->vdev.entity.function = MEDIA_ENT_F_IO_V4L;
+	vout->vdev.entity.ops = &dcmipp_isp_params_entity_ops;
+	vout->pad.flags = MEDIA_PAD_FL_SOURCE;
+	ret = media_entity_pads_init(&vout->vdev.entity, 1, &vout->pad);
+	if (ret)
+		goto err_free_vout;
+
+	/* Initialize the lock */
+	mutex_init(&vout->lock);
+
+	/* Initialize the vb2 queue */
+	q = &vout->queue;
+	q->type = V4L2_BUF_TYPE_META_OUTPUT;
+	q->io_modes = VB2_MMAP | VB2_DMABUF;
+	q->lock = &vout->lock;
+	q->drv_priv = vout;
+	q->buf_struct_size = sizeof(struct dcmipp_buf);
+	q->ops = &dcmipp_isp_params_qops;
+	q->mem_ops = &vb2_vmalloc_memops;
+	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+	q->min_queued_buffers = 1;
+	q->dev = dev;
+
+	ret = vb2_queue_init(q);
+	if (ret) {
+		dev_err(dev, "%s: vb2 queue init failed (err=%d)\n",
+			entity_name, ret);
+		goto err_entity_cleanup;
+	}
+
+	/* Initialize buffer list and its lock */
+	INIT_LIST_HEAD(&vout->buffers);
+	spin_lock_init(&vout->irqlock);
+
+	/* Fill the dcmipp_ent_device struct */
+	vout->ved.ent = &vout->vdev.entity;
+	vout->ved.handler = NULL;
+	vout->ved.thread_fn = dcmipp_isp_params_irq_thread;
+	vout->dev = dev;
+	vout->regs = dcmipp->regs;
+
+	/* Initialize the video_device struct */
+	vdev = &vout->vdev;
+	vdev->device_caps = V4L2_CAP_META_OUTPUT | V4L2_CAP_STREAMING |
+			    V4L2_CAP_IO_MC;
+	vdev->vfl_dir = VFL_DIR_TX;
+	vdev->release = dcmipp_isp_params_release;
+	vdev->fops = &dcmipp_isp_params_fops;
+	vdev->ioctl_ops = &dcmipp_isp_params_ioctl_ops;
+	vdev->lock = &vout->lock;
+	vdev->queue = q;
+	vdev->v4l2_dev = &dcmipp->v4l2_dev;
+	strscpy(vdev->name, entity_name, sizeof(vdev->name));
+	video_set_drvdata(vdev, &vout->ved);
+
+	/* Register the video_device with the v4l2 and the media framework */
+	ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
+	if (ret) {
+		dev_err(dev, "%s: video register failed (err=%d)\n",
+			vout->vdev.name, ret);
+		goto err_entity_cleanup;
+	}
+
+	return &vout->ved;
+
+err_entity_cleanup:
+	media_entity_cleanup(&vout->vdev.entity);
+	mutex_destroy(&vout->lock);
+err_free_vout:
+	kfree(vout);
+
+	return ERR_PTR(ret);
+}

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 10/11] media: stm32: dcmipp: isp: add 2 pads to be connected to isp-params & stats
  2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
                   ` (8 preceding siblings ...)
  2026-12-04 11:11 ` [PATCH 09/11] media: stm32: dcmipp: addition of isp param output device Alain Volmat
@ 2026-12-04 11:11 ` Alain Volmat
  2026-12-04 11:11 ` [PATCH 11/11] media: stm32: dcmipp: core: add isp-params & stats devices Alain Volmat
  10 siblings, 0 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

Addition of pad 3 and pad 4 into the dcmipp-isp subdevice in order to
connect the isp parameter output device and isp stats capture device.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 .../platform/st/stm32/stm32-dcmipp/dcmipp-isp.c    | 52 ++++++++++++++++++++--
 1 file changed, 48 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
index 2d941f1e867c..381a80f7c383 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-isp.c
@@ -39,6 +39,7 @@
 
 #define DCMIPP_CMSR2_P1VSYNCF	BIT(18)
 #define DCMIPP_CMSR2_P2VSYNCF	BIT(26)
+#define IS_META_PAD(pad) ((pad) >= DCMIPP_ISP_PAD_SINK_PARAMS)
 
 #define ISP_MEDIA_BUS_SINK_FMT_DEFAULT MEDIA_BUS_FMT_RGB565_1X16
 #define ISP_MEDIA_BUS_SRC_FMT_DEFAULT MEDIA_BUS_FMT_RGB888_1X24
@@ -48,6 +49,8 @@ enum dcmipp_isp_pad {
 	DCMIPP_ISP_PAD_SINK_VIDEO,
 	DCMIPP_ISP_PAD_SOURCE_VIDEO_MAIN,
 	DCMIPP_ISP_PAD_SOURCE_VIDEO_AUX,
+	DCMIPP_ISP_PAD_SINK_PARAMS,
+	DCMIPP_ISP_PAD_SOURCE_STATS,
 	DCMIPP_ISP_PAD_MAX
 };
 
@@ -97,9 +100,11 @@ static void dcmipp_isp_adjust_fmt(struct v4l2_mbus_framefmt *fmt, u32 pad)
 static int dcmipp_isp_init_state(struct v4l2_subdev *sd,
 				 struct v4l2_subdev_state *state)
 {
-	for (unsigned int i = 0; i < sd->entity.num_pads; i++) {
-		struct v4l2_mbus_framefmt *mf;
+	struct v4l2_mbus_framefmt *mf;
+	unsigned int i;
 
+	/* Initialize the sink & source pads of data */
+	for (i = 0; i < DCMIPP_ISP_PAD_SINK_PARAMS; i++) {
 		mf = v4l2_subdev_state_get_format(state, i);
 		*mf = fmt_default;
 		mf->code = IS_SRC(i) ? ISP_MEDIA_BUS_SRC_FMT_DEFAULT :
@@ -118,6 +123,15 @@ static int dcmipp_isp_init_state(struct v4l2_subdev *sd,
 		}
 	}
 
+	/* Initialize isp params & isp stats pads */
+	mf = v4l2_subdev_state_get_format(state, DCMIPP_ISP_PAD_SINK_PARAMS);
+	mf->width = 0;
+	mf->height = 0;
+	mf->field = V4L2_FIELD_NONE;
+	mf->code = MEDIA_BUS_FMT_METADATA_FIXED;
+
+	*v4l2_subdev_state_get_format(state, DCMIPP_ISP_PAD_SOURCE_STATS) = *mf;
+
 	return 0;
 }
 
@@ -125,6 +139,14 @@ static int dcmipp_isp_enum_mbus_code(struct v4l2_subdev *sd,
 				     struct v4l2_subdev_state *state,
 				     struct v4l2_subdev_mbus_code_enum *code)
 {
+	if (IS_META_PAD(code->pad)) {
+		if (code->index)
+			return -EINVAL;
+
+		code->code = MEDIA_BUS_FMT_METADATA_FIXED;
+		return 0;
+	}
+
 	return dcmipp_pixelpipe_enum_mbus_code(DCMIPP_ISP, code);
 }
 
@@ -132,6 +154,9 @@ static int dcmipp_isp_enum_frame_size(struct v4l2_subdev *sd,
 				      struct v4l2_subdev_state *state,
 				      struct v4l2_subdev_frame_size_enum *fse)
 {
+	if (IS_META_PAD(fse->pad))
+		return -EINVAL;
+
 	return dcmipp_pixelpipe_enum_frame_size(DCMIPP_ISP, fse);
 }
 
@@ -144,6 +169,12 @@ static int dcmipp_isp_set_fmt(struct v4l2_subdev *sd,
 	    v4l2_subdev_is_streaming(sd))
 		return -EBUSY;
 
+	/* Metadata pads have a fixed format */
+	if (IS_META_PAD(fmt->pad)) {
+		fmt->format = *v4l2_subdev_state_get_format(state, fmt->pad);
+		return 0;
+	}
+
 	dcmipp_isp_adjust_fmt(&fmt->format, fmt->pad);
 
 	if (IS_SINK(fmt->pad)) {
@@ -260,7 +291,8 @@ static int dcmipp_isp_set_selection(struct v4l2_subdev *sd,
 	}
 
 	/* Update the source pad size */
-	for (pad = 1; pad < sd->entity.num_pads; pad++) {
+	for (pad = DCMIPP_ISP_PAD_SOURCE_VIDEO_MAIN;
+	     pad <= DCMIPP_ISP_PAD_SOURCE_VIDEO_AUX; pad++) {
 		src_fmt = v4l2_subdev_state_get_format(state, pad);
 		src_fmt->width = s->r.width;
 		src_fmt->height = s->r.height;
@@ -431,12 +463,23 @@ static int dcmipp_isp_disable_streams(struct v4l2_subdev *sd,
 	return 0;
 }
 
+static int dcmipp_isp_get_selection(struct v4l2_subdev *sd,
+				    const struct v4l2_subdev_client_info *ci,
+				    struct v4l2_subdev_state *state,
+				    struct v4l2_subdev_selection *s)
+{
+	if (IS_META_PAD(s->pad))
+		return -EINVAL;
+
+	return dcmipp_pixelpipe_get_selection(sd, ci, state, s);
+}
+
 static const struct v4l2_subdev_pad_ops dcmipp_isp_pad_ops = {
 	.enum_mbus_code		= dcmipp_isp_enum_mbus_code,
 	.enum_frame_size	= dcmipp_isp_enum_frame_size,
 	.get_fmt		= v4l2_subdev_get_fmt,
 	.set_fmt		= dcmipp_isp_set_fmt,
-	.get_selection		= dcmipp_pixelpipe_get_selection,
+	.get_selection		= dcmipp_isp_get_selection,
 	.set_selection		= dcmipp_isp_set_selection,
 	.enable_streams		= dcmipp_isp_enable_streams,
 	.disable_streams	= dcmipp_isp_disable_streams,
@@ -493,6 +536,7 @@ struct dcmipp_ent_device *dcmipp_isp_ent_init(const char *entity_name,
 	const unsigned long pads_flag[] = {
 		MEDIA_PAD_FL_SINK, MEDIA_PAD_FL_SOURCE,
 		MEDIA_PAD_FL_SOURCE,
+		MEDIA_PAD_FL_SINK, MEDIA_PAD_FL_SOURCE,
 	};
 	int ret;
 

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 11/11] media: stm32: dcmipp: core: add isp-params & stats devices
  2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
                   ` (9 preceding siblings ...)
  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 ` Alain Volmat
  10 siblings, 0 replies; 12+ messages in thread
From: Alain Volmat @ 2026-12-04 11:11 UTC (permalink / raw)
  To: Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin, Alexandre Torgue
  Cc: linux-media, linux-stm32, linux-arm-kernel, linux-kernel, Alain Volmat

Connect dcmipp-statcap and dcmipp-isp-param devices to the isp subdev

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
 .../media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c   | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
index 59481be9aa82..d3c85d8fdf70 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
@@ -80,6 +80,8 @@ static const struct dcmipp_pipeline_config stm32mp13_pipe_cfg = {
 #define	ID_MAIN_CAPTURE	5
 #define	ID_AUX_POSTPROC 6
 #define	ID_AUX_CAPTURE 7
+#define	ID_ISP_STAT_CAPTURE 8
+#define	ID_ISP_PARAMS_OUTPUT 9
 static const struct dcmipp_ent_config stm32mp25_ent_config[] = {
 	{
 		.name = "dcmipp_input",
@@ -121,6 +123,16 @@ static const struct dcmipp_ent_config stm32mp25_ent_config[] = {
 		.init = dcmipp_capture_ent_init,
 		.release = dcmipp_capture_ent_release,
 	},
+	{
+		.name = "dcmipp_main_isp_stat_capture",
+		.init = dcmipp_statcap_ent_init,
+		.release = dcmipp_statcap_ent_release,
+	},
+	{
+		.name = "dcmipp_main_isp_params_output",
+		.init = dcmipp_isp_params_ent_init,
+		.release = dcmipp_isp_params_ent_release,
+	},
 };
 
 static const struct dcmipp_ent_link stm32mp25_ent_links[] = {
@@ -131,6 +143,10 @@ static const struct dcmipp_ent_link stm32mp25_ent_links[] = {
 	DCMIPP_ENT_LINK(ID_MAIN_ISP,	1, ID_MAIN_POSTPROC,  0,
 			MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE),
 	DCMIPP_ENT_LINK(ID_MAIN_ISP,	2, ID_AUX_POSTPROC,  0, 0),
+	DCMIPP_ENT_LINK(ID_ISP_PARAMS_OUTPUT,	0, ID_MAIN_ISP,	3,
+			MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE),
+	DCMIPP_ENT_LINK(ID_MAIN_ISP,	4, ID_ISP_STAT_CAPTURE,  0,
+			MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE),
 	DCMIPP_ENT_LINK(ID_MAIN_POSTPROC,	1, ID_MAIN_CAPTURE,  0,
 			MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE),
 	DCMIPP_ENT_LINK(ID_INPUT,	3, ID_AUX_POSTPROC,  0, 0),

-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-12-04 11:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 05/11] media: uapi: st: dcmipp: add description of ISP stats & param buffers Alain Volmat
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

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®