From: Alain Volmat <alain.volmat@foss.st.com>
To: Hugues Fruchet <hugues.fruchet@foss.st.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>
Cc: <linux-media@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
"Alain Volmat" <alain.volmat@foss.st.com>
Subject: [PATCH 03/11] media: stm32: dcmipp: isp: keep a frame sequence counter at isp level
Date: Fri, 4 Dec 2026 12:11:34 +0100 [thread overview]
Message-ID: <20261204-stm32mp-dcmipp-isp-stat-ctrls-v1-3-e809f8c193e6@foss.st.com> (raw)
In-Reply-To: <20261204-stm32mp-dcmipp-isp-stat-ctrls-v1-0-e809f8c193e6@foss.st.com>
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
next prev parent reply other threads:[~2026-12-04 11:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
2026-12-04 11:11 ` [PATCH 01/11] media: stm32: dcmipp: add entity pointers into dcmipp-common.h Alain Volmat
2026-12-04 11:11 ` [PATCH 02/11] media: stm32: dcmipp: add enum to name ISP subdev pads Alain Volmat
2026-12-04 11:11 ` Alain Volmat [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204-stm32mp-dcmipp-isp-stat-ctrls-v1-3-e809f8c193e6@foss.st.com \
--to=alain.volmat@foss.st.com \
--cc=alexandre.torgue@foss.st.com \
--cc=hugues.fruchet@foss.st.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mchehab@kernel.org \
--cc=mcoquelin.stm32@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®