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

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


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

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 11:11 [PATCH 00/11] media: stm32: dcmipp: addition of ISP params & statistics Alain Volmat
2026-12-04 11:11 ` [PATCH 01/11] media: stm32: dcmipp: add entity pointers into dcmipp-common.h Alain Volmat
2026-12-04 11:11 ` [PATCH 02/11] media: stm32: dcmipp: add enum to name ISP subdev pads Alain Volmat
2026-12-04 11:11 ` [PATCH 03/11] media: stm32: dcmipp: isp: keep a frame sequence counter at isp level Alain Volmat
2026-12-04 11:11 ` [PATCH 04/11] media: stm32: dcmipp: capture: use ISP frame sequence for main & aux pipes Alain Volmat
2026-12-04 11:11 ` [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 ` Alain Volmat [this message]
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-10-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®