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 02/11] media: stm32: dcmipp: add enum to name ISP subdev pads
Date: Fri, 4 Dec 2026 12:11:33 +0100	[thread overview]
Message-ID: <20261204-stm32mp-dcmipp-isp-stat-ctrls-v1-2-e809f8c193e6@foss.st.com> (raw)
In-Reply-To: <20261204-stm32mp-dcmipp-isp-stat-ctrls-v1-0-e809f8c193e6@foss.st.com>

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


  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 ` Alain Volmat [this message]
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

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-2-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®