[PATCH 04/11] media: stm32: dcmipp: capture: use ISP frame sequence for main & aux pipes

From: Alain Volmat

Date: Fri Dec 04 2026 - 06:12:26 EST


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@xxxxxxxxxxx>
---
.../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