linux-rockchip.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] media: v4l2-subdev: Support const-awareness in state accessors
@ 2024-05-06 17:52 Laurent Pinchart
  2024-05-06 17:52 ` [PATCH 1/2] media: v4l2-subdev: Provide const-aware subdev " Laurent Pinchart
  2024-05-06 17:52 ` [PATCH 2/2] media: rkisp1: Mark subdev state pointers as const Laurent Pinchart
  0 siblings, 2 replies; 6+ messages in thread
From: Laurent Pinchart @ 2024-05-06 17:52 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Tomi Valkeinen, Hans Verkuil,
	Dafna Hirschfeld, linux-rockchip

Hello,

This small patch series comes from a mild annoyance I experienced during
a recent patch review, where I wanted to ask for a pointer to a
v4l2_subdev_state used to access the state in a read-only fashion to be
made const. This wasn't possible as the state accessors functions take a
non-const state pointer, in order to return pointers to mutable formats
and selection rectangles.

Patch 1/2 improves the state accessors to support const states, in the
same wait as the recently introduced container_of_const() macro.
Bikeshedding of the internal macro and function names is expected. Patch
2/2 then shows how this can be used in one driver.

Laurent Pinchart (2):
  media: v4l2-subdev: Provide const-aware subdev state accessors
  media: rkisp1: Mark subdev state pointers as const

 .../platform/rockchip/rkisp1/rkisp1-isp.c     |  8 +--
 .../platform/rockchip/rkisp1/rkisp1-resizer.c |  8 +--
 drivers/media/v4l2-core/v4l2-subdev.c         | 24 +++----
 include/media/v4l2-subdev.h                   | 66 +++++++++++++------
 4 files changed, 65 insertions(+), 41 deletions(-)


base-commit: e695668af8523b059127dfa8b261c76e7c9cde10
-- 
Regards,

Laurent Pinchart


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH 1/2] media: v4l2-subdev: Provide const-aware subdev state accessors
  2024-05-06 17:52 [PATCH 0/2] media: v4l2-subdev: Support const-awareness in state accessors Laurent Pinchart
@ 2024-05-06 17:52 ` Laurent Pinchart
  2024-05-06 21:53   ` Sakari Ailus
  2024-05-06 17:52 ` [PATCH 2/2] media: rkisp1: Mark subdev state pointers as const Laurent Pinchart
  1 sibling, 1 reply; 6+ messages in thread
From: Laurent Pinchart @ 2024-05-06 17:52 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Tomi Valkeinen, Hans Verkuil,
	Dafna Hirschfeld, linux-rockchip

It would be useful to mark instances of v4l2_subdev_state structures as
const when code needs to access them read-only. This isn't currently
possible, as the v4l2_subdev_state_get_*() accessor functions take a
non-const pointer to the state.

Use _Generic() to provide two different versions of the accessors, for
const and non-const states respectively. The former returns a const
pointer to the requested format, rectangle or interval, implementing
const-correctness. The latter returns a non-const pointer, preserving
the current behaviour for drivers.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Bike-shedding about names and the 4 leading underscores is allowed (and
expected).
---
 drivers/media/v4l2-core/v4l2-subdev.c | 24 +++++-----
 include/media/v4l2-subdev.h           | 66 ++++++++++++++++++---------
 2 files changed, 57 insertions(+), 33 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 83c6d1e36871..af1fbc28c8f0 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1616,8 +1616,8 @@ void v4l2_subdev_cleanup(struct v4l2_subdev *sd)
 EXPORT_SYMBOL_GPL(v4l2_subdev_cleanup);
 
 struct v4l2_mbus_framefmt *
-__v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
-			       unsigned int pad, u32 stream)
+____v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
+				 unsigned int pad, u32 stream)
 {
 	struct v4l2_subdev_stream_configs *stream_configs;
 	unsigned int i;
@@ -1647,11 +1647,11 @@ __v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
 
 	return NULL;
 }
-EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_format);
+EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_format);
 
 struct v4l2_rect *
-__v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
-			     u32 stream)
+____v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
+			       u32 stream)
 {
 	struct v4l2_subdev_stream_configs *stream_configs;
 	unsigned int i;
@@ -1681,11 +1681,11 @@ __v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
 
 	return NULL;
 }
-EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_crop);
+EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_crop);
 
 struct v4l2_rect *
-__v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
-				unsigned int pad, u32 stream)
+____v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
+				  unsigned int pad, u32 stream)
 {
 	struct v4l2_subdev_stream_configs *stream_configs;
 	unsigned int i;
@@ -1715,11 +1715,11 @@ __v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
 
 	return NULL;
 }
-EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_compose);
+EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_compose);
 
 struct v4l2_fract *
-__v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
-				 unsigned int pad, u32 stream)
+____v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
+				   unsigned int pad, u32 stream)
 {
 	struct v4l2_subdev_stream_configs *stream_configs;
 	unsigned int i;
@@ -1751,7 +1751,7 @@ __v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
 
 	return NULL;
 }
-EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_interval);
+EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_interval);
 
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
 
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index e30c463d90e5..ba722ab501c1 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -1340,21 +1340,27 @@ void v4l2_subdev_cleanup(struct v4l2_subdev *sd);
  */
 /*
  * Wrap v4l2_subdev_state_get_format(), allowing the function to be called with
- * two or three arguments. The purpose of the __v4l2_subdev_state_get_format()
+ * two or three arguments. The purpose of the __v4l2_subdev_state_gen_call()
  * macro below is to come up with the name of the function or macro to call,
  * using the last two arguments (_stream and _pad). The selected function or
  * macro is then called using the arguments specified by the caller. A similar
  * arrangement is used for v4l2_subdev_state_crop() and
  * v4l2_subdev_state_compose() below.
  */
-#define v4l2_subdev_state_get_format(state, pad, ...)			\
-	__v4l2_subdev_state_gen_call(format, ##__VA_ARGS__, , _pad)	\
+#define v4l2_subdev_state_get_format(state, pad, ...)				\
+	__v4l2_subdev_state_gen_call(format, ##__VA_ARGS__, , _pad)		\
 		(state, pad, ##__VA_ARGS__)
-#define __v4l2_subdev_state_get_format_pad(state, pad)	\
+#define __v4l2_subdev_state_get_format_pad(state, pad)				\
 	__v4l2_subdev_state_get_format(state, pad, 0)
+#define __v4l2_subdev_state_get_format(state, pad, stream)			\
+	_Generic(state,								\
+		const struct v4l2_subdev_state *: ((const struct v4l2_mbus_framefmt *)	\
+			____v4l2_subdev_state_get_format((struct v4l2_subdev_state *)state, pad, stream)), \
+		default: ____v4l2_subdev_state_get_format((struct v4l2_subdev_state *)state, pad, stream) \
+	)
 struct v4l2_mbus_framefmt *
-__v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
-			       unsigned int pad, u32 stream);
+____v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
+				 unsigned int pad, u32 stream);
 
 /**
  * v4l2_subdev_state_get_crop() - Get pointer to a stream crop rectangle
@@ -1368,14 +1374,20 @@ __v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
  * For stream-unaware drivers the crop rectangle for the corresponding pad is
  * returned. If the pad does not exist, NULL is returned.
  */
-#define v4l2_subdev_state_get_crop(state, pad, ...)			\
-	__v4l2_subdev_state_gen_call(crop, ##__VA_ARGS__, , _pad)	\
+#define v4l2_subdev_state_get_crop(state, pad, ...)				\
+	__v4l2_subdev_state_gen_call(crop, ##__VA_ARGS__, , _pad)		\
 		(state, pad, ##__VA_ARGS__)
-#define __v4l2_subdev_state_get_crop_pad(state, pad)	\
+#define __v4l2_subdev_state_get_crop_pad(state, pad)				\
 	__v4l2_subdev_state_get_crop(state, pad, 0)
+#define __v4l2_subdev_state_get_crop(state, pad, stream)			\
+	_Generic(state,								\
+		const struct v4l2_subdev_state *: ((const struct v4l2_rect *)		\
+			____v4l2_subdev_state_get_crop((struct v4l2_subdev_state *)state, pad, stream)), \
+		default: ____v4l2_subdev_state_get_crop((struct v4l2_subdev_state *)state, pad, stream) \
+	)
 struct v4l2_rect *
-__v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
-			     u32 stream);
+____v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
+			       u32 stream);
 
 /**
  * v4l2_subdev_state_get_compose() - Get pointer to a stream compose rectangle
@@ -1389,14 +1401,20 @@ __v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
  * For stream-unaware drivers the compose rectangle for the corresponding pad is
  * returned. If the pad does not exist, NULL is returned.
  */
-#define v4l2_subdev_state_get_compose(state, pad, ...)			\
-	__v4l2_subdev_state_gen_call(compose, ##__VA_ARGS__, , _pad)	\
+#define v4l2_subdev_state_get_compose(state, pad, ...)				\
+	__v4l2_subdev_state_gen_call(compose, ##__VA_ARGS__, , _pad)		\
 		(state, pad, ##__VA_ARGS__)
-#define __v4l2_subdev_state_get_compose_pad(state, pad)	\
+#define __v4l2_subdev_state_get_compose_pad(state, pad)				\
 	__v4l2_subdev_state_get_compose(state, pad, 0)
+#define __v4l2_subdev_state_get_compose(state, pad, stream)			\
+	_Generic(state,								\
+		const struct v4l2_subdev_state *: ((const struct v4l2_rect *)		\
+			____v4l2_subdev_state_get_compose((struct v4l2_subdev_state *)state, pad, stream)), \
+		default: ____v4l2_subdev_state_get_compose((struct v4l2_subdev_state *)state, pad, stream) \
+	)
 struct v4l2_rect *
-__v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
-				unsigned int pad, u32 stream);
+____v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
+				  unsigned int pad, u32 stream);
 
 /**
  * v4l2_subdev_state_get_interval() - Get pointer to a stream frame interval
@@ -1410,14 +1428,20 @@ __v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
  * For stream-unaware drivers the frame interval for the corresponding pad is
  * returned. If the pad does not exist, NULL is returned.
  */
-#define v4l2_subdev_state_get_interval(state, pad, ...)			\
-	__v4l2_subdev_state_gen_call(interval, ##__VA_ARGS__, , _pad)	\
+#define v4l2_subdev_state_get_interval(state, pad, ...)				\
+	__v4l2_subdev_state_gen_call(interval, ##__VA_ARGS__, , _pad)		\
 		(state, pad, ##__VA_ARGS__)
-#define __v4l2_subdev_state_get_interval_pad(state, pad)	\
+#define __v4l2_subdev_state_get_interval_pad(state, pad)			\
 	__v4l2_subdev_state_get_interval(state, pad, 0)
+#define __v4l2_subdev_state_get_interval(state, pad, stream)			\
+	_Generic(state,								\
+		const struct v4l2_subdev_state *: ((const struct v4l2_frac *)		\
+			____v4l2_subdev_state_get_interval((struct v4l2_subdev_state *)state, pad, stream)), \
+		default: ____v4l2_subdev_state_get_interval((struct v4l2_subdev_state *)state, pad, stream) \
+	)
 struct v4l2_fract *
-__v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
-				 unsigned int pad, u32 stream);
+____v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
+				   unsigned int pad, u32 stream);
 
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
 
-- 
Regards,

Laurent Pinchart


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH 2/2] media: rkisp1: Mark subdev state pointers as const
  2024-05-06 17:52 [PATCH 0/2] media: v4l2-subdev: Support const-awareness in state accessors Laurent Pinchart
  2024-05-06 17:52 ` [PATCH 1/2] media: v4l2-subdev: Provide const-aware subdev " Laurent Pinchart
@ 2024-05-06 17:52 ` Laurent Pinchart
  2024-05-14 20:07   ` Nicolas Dufresne
  1 sibling, 1 reply; 6+ messages in thread
From: Laurent Pinchart @ 2024-05-06 17:52 UTC (permalink / raw)
  To: linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Tomi Valkeinen, Hans Verkuil,
	Dafna Hirschfeld, linux-rockchip

Several subdev state pointers are used to access the state read-only.
Mark them as const.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c     | 8 ++++----
 drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c
index e45a213baf49..91301d17d356 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c
@@ -173,7 +173,7 @@ static void rkisp1_gasket_disable(struct rkisp1_device *rkisp1)
  * or at the frame end interrupt
  */
 static void rkisp1_config_ism(struct rkisp1_isp *isp,
-			      struct v4l2_subdev_state *sd_state)
+			      const struct v4l2_subdev_state *sd_state)
 {
 	const struct v4l2_rect *src_crop =
 		v4l2_subdev_state_get_crop(sd_state,
@@ -201,7 +201,7 @@ static void rkisp1_config_ism(struct rkisp1_isp *isp,
  * configure ISP blocks with input format, size......
  */
 static int rkisp1_config_isp(struct rkisp1_isp *isp,
-			     struct v4l2_subdev_state *sd_state,
+			     const struct v4l2_subdev_state *sd_state,
 			     enum v4l2_mbus_type mbus_type, u32 mbus_flags)
 {
 	struct rkisp1_device *rkisp1 = isp->rkisp1;
@@ -309,7 +309,7 @@ static int rkisp1_config_isp(struct rkisp1_isp *isp,
 	if (src_fmt->pixel_enc == V4L2_PIXEL_ENC_BAYER) {
 		rkisp1_params_disable(&rkisp1->params);
 	} else {
-		struct v4l2_mbus_framefmt *src_frm;
+		const struct v4l2_mbus_framefmt *src_frm;
 
 		src_frm = v4l2_subdev_state_get_format(sd_state,
 						       RKISP1_ISP_PAD_SOURCE_VIDEO);
@@ -429,7 +429,7 @@ static void rkisp1_config_clk(struct rkisp1_isp *isp)
 }
 
 static int rkisp1_isp_start(struct rkisp1_isp *isp,
-			    struct v4l2_subdev_state *sd_state,
+			    const struct v4l2_subdev_state *sd_state,
 			    struct media_pad *source)
 {
 	struct rkisp1_device *rkisp1 = isp->rkisp1;
diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c
index 6f3931ca5b51..1fa991227fa9 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c
@@ -135,11 +135,11 @@ static void rkisp1_dcrop_disable(struct rkisp1_resizer *rsz,
 
 /* configure dual-crop unit */
 static void rkisp1_dcrop_config(struct rkisp1_resizer *rsz,
-				struct v4l2_subdev_state *sd_state)
+				const struct v4l2_subdev_state *sd_state)
 {
 	struct rkisp1_device *rkisp1 = rsz->rkisp1;
-	struct v4l2_mbus_framefmt *sink_fmt;
-	struct v4l2_rect *sink_crop;
+	const struct v4l2_mbus_framefmt *sink_fmt;
+	const struct v4l2_rect *sink_crop;
 	u32 dc_ctrl;
 
 	sink_crop = v4l2_subdev_state_get_crop(sd_state, RKISP1_RSZ_PAD_SINK);
@@ -264,7 +264,7 @@ static void rkisp1_rsz_config_regs(struct rkisp1_resizer *rsz,
 }
 
 static void rkisp1_rsz_config(struct rkisp1_resizer *rsz,
-			      struct v4l2_subdev_state *sd_state,
+			      const struct v4l2_subdev_state *sd_state,
 			      enum rkisp1_shadow_regs_when when)
 {
 	const struct rkisp1_rsz_yuv_mbus_info *sink_yuv_info, *src_yuv_info;
-- 
Regards,

Laurent Pinchart


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH 1/2] media: v4l2-subdev: Provide const-aware subdev state accessors
  2024-05-06 17:52 ` [PATCH 1/2] media: v4l2-subdev: Provide const-aware subdev " Laurent Pinchart
@ 2024-05-06 21:53   ` Sakari Ailus
  2024-05-07  6:04     ` Laurent Pinchart
  0 siblings, 1 reply; 6+ messages in thread
From: Sakari Ailus @ 2024-05-06 21:53 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, linux-renesas-soc, Tomi Valkeinen, Hans Verkuil,
	Dafna Hirschfeld, linux-rockchip

Hi Laurent,

Thanks for the patch.

On Mon, May 06, 2024 at 08:52:54PM +0300, Laurent Pinchart wrote:
> It would be useful to mark instances of v4l2_subdev_state structures as
> const when code needs to access them read-only. This isn't currently
> possible, as the v4l2_subdev_state_get_*() accessor functions take a
> non-const pointer to the state.
> 
> Use _Generic() to provide two different versions of the accessors, for
> const and non-const states respectively. The former returns a const
> pointer to the requested format, rectangle or interval, implementing
> const-correctness. The latter returns a non-const pointer, preserving
> the current behaviour for drivers.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> Bike-shedding about names and the 4 leading underscores is allowed (and
> expected).
> ---
>  drivers/media/v4l2-core/v4l2-subdev.c | 24 +++++-----
>  include/media/v4l2-subdev.h           | 66 ++++++++++++++++++---------
>  2 files changed, 57 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index 83c6d1e36871..af1fbc28c8f0 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -1616,8 +1616,8 @@ void v4l2_subdev_cleanup(struct v4l2_subdev *sd)
>  EXPORT_SYMBOL_GPL(v4l2_subdev_cleanup);
>  
>  struct v4l2_mbus_framefmt *
> -__v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
> -			       unsigned int pad, u32 stream)
> +____v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
> +				 unsigned int pad, u32 stream)
>  {
>  	struct v4l2_subdev_stream_configs *stream_configs;
>  	unsigned int i;
> @@ -1647,11 +1647,11 @@ __v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
>  
>  	return NULL;
>  }
> -EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_format);
> +EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_format);
>  
>  struct v4l2_rect *
> -__v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
> -			     u32 stream)
> +____v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
> +			       u32 stream)
>  {
>  	struct v4l2_subdev_stream_configs *stream_configs;
>  	unsigned int i;
> @@ -1681,11 +1681,11 @@ __v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
>  
>  	return NULL;
>  }
> -EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_crop);
> +EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_crop);
>  
>  struct v4l2_rect *
> -__v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
> -				unsigned int pad, u32 stream)
> +____v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
> +				  unsigned int pad, u32 stream)
>  {
>  	struct v4l2_subdev_stream_configs *stream_configs;
>  	unsigned int i;
> @@ -1715,11 +1715,11 @@ __v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
>  
>  	return NULL;
>  }
> -EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_compose);
> +EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_compose);
>  
>  struct v4l2_fract *
> -__v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
> -				 unsigned int pad, u32 stream)
> +____v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
> +				   unsigned int pad, u32 stream)
>  {
>  	struct v4l2_subdev_stream_configs *stream_configs;
>  	unsigned int i;
> @@ -1751,7 +1751,7 @@ __v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
>  
>  	return NULL;
>  }
> -EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_interval);
> +EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_interval);
>  
>  #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
>  
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index e30c463d90e5..ba722ab501c1 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -1340,21 +1340,27 @@ void v4l2_subdev_cleanup(struct v4l2_subdev *sd);
>   */
>  /*
>   * Wrap v4l2_subdev_state_get_format(), allowing the function to be called with
> - * two or three arguments. The purpose of the __v4l2_subdev_state_get_format()
> + * two or three arguments. The purpose of the __v4l2_subdev_state_gen_call()
>   * macro below is to come up with the name of the function or macro to call,
>   * using the last two arguments (_stream and _pad). The selected function or
>   * macro is then called using the arguments specified by the caller. A similar
>   * arrangement is used for v4l2_subdev_state_crop() and
>   * v4l2_subdev_state_compose() below.
>   */
> -#define v4l2_subdev_state_get_format(state, pad, ...)			\
> -	__v4l2_subdev_state_gen_call(format, ##__VA_ARGS__, , _pad)	\
> +#define v4l2_subdev_state_get_format(state, pad, ...)				\
> +	__v4l2_subdev_state_gen_call(format, ##__VA_ARGS__, , _pad)		\
>  		(state, pad, ##__VA_ARGS__)
> -#define __v4l2_subdev_state_get_format_pad(state, pad)	\
> +#define __v4l2_subdev_state_get_format_pad(state, pad)				\
>  	__v4l2_subdev_state_get_format(state, pad, 0)
> +#define __v4l2_subdev_state_get_format(state, pad, stream)			\
> +	_Generic(state,								\
> +		const struct v4l2_subdev_state *: ((const struct v4l2_mbus_framefmt *)	\
> +			____v4l2_subdev_state_get_format((struct v4l2_subdev_state *)state, pad, stream)), \
> +		default: ____v4l2_subdev_state_get_format((struct v4l2_subdev_state *)state, pad, stream) \
> +	)
>  struct v4l2_mbus_framefmt *
> -__v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
> -			       unsigned int pad, u32 stream);
> +____v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
> +				 unsigned int pad, u32 stream);
>  
>  /**
>   * v4l2_subdev_state_get_crop() - Get pointer to a stream crop rectangle
> @@ -1368,14 +1374,20 @@ __v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
>   * For stream-unaware drivers the crop rectangle for the corresponding pad is
>   * returned. If the pad does not exist, NULL is returned.
>   */
> -#define v4l2_subdev_state_get_crop(state, pad, ...)			\
> -	__v4l2_subdev_state_gen_call(crop, ##__VA_ARGS__, , _pad)	\
> +#define v4l2_subdev_state_get_crop(state, pad, ...)				\
> +	__v4l2_subdev_state_gen_call(crop, ##__VA_ARGS__, , _pad)		\
>  		(state, pad, ##__VA_ARGS__)
> -#define __v4l2_subdev_state_get_crop_pad(state, pad)	\
> +#define __v4l2_subdev_state_get_crop_pad(state, pad)				\
>  	__v4l2_subdev_state_get_crop(state, pad, 0)
> +#define __v4l2_subdev_state_get_crop(state, pad, stream)			\
> +	_Generic(state,								\
> +		const struct v4l2_subdev_state *: ((const struct v4l2_rect *)		\
> +			____v4l2_subdev_state_get_crop((struct v4l2_subdev_state *)state, pad, stream)), \
> +		default: ____v4l2_subdev_state_get_crop((struct v4l2_subdev_state *)state, pad, stream) \
> +	)
>  struct v4l2_rect *
> -__v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
> -			     u32 stream);
> +____v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
> +			       u32 stream);
>  
>  /**
>   * v4l2_subdev_state_get_compose() - Get pointer to a stream compose rectangle
> @@ -1389,14 +1401,20 @@ __v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
>   * For stream-unaware drivers the compose rectangle for the corresponding pad is
>   * returned. If the pad does not exist, NULL is returned.
>   */
> -#define v4l2_subdev_state_get_compose(state, pad, ...)			\
> -	__v4l2_subdev_state_gen_call(compose, ##__VA_ARGS__, , _pad)	\
> +#define v4l2_subdev_state_get_compose(state, pad, ...)				\
> +	__v4l2_subdev_state_gen_call(compose, ##__VA_ARGS__, , _pad)		\
>  		(state, pad, ##__VA_ARGS__)
> -#define __v4l2_subdev_state_get_compose_pad(state, pad)	\
> +#define __v4l2_subdev_state_get_compose_pad(state, pad)				\
>  	__v4l2_subdev_state_get_compose(state, pad, 0)
> +#define __v4l2_subdev_state_get_compose(state, pad, stream)			\
> +	_Generic(state,								\
> +		const struct v4l2_subdev_state *: ((const struct v4l2_rect *)		\
> +			____v4l2_subdev_state_get_compose((struct v4l2_subdev_state *)state, pad, stream)), \
> +		default: ____v4l2_subdev_state_get_compose((struct v4l2_subdev_state *)state, pad, stream) \
> +	)
>  struct v4l2_rect *
> -__v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
> -				unsigned int pad, u32 stream);
> +____v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
> +				  unsigned int pad, u32 stream);
>  
>  /**
>   * v4l2_subdev_state_get_interval() - Get pointer to a stream frame interval
> @@ -1410,14 +1428,20 @@ __v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
>   * For stream-unaware drivers the frame interval for the corresponding pad is
>   * returned. If the pad does not exist, NULL is returned.
>   */
> -#define v4l2_subdev_state_get_interval(state, pad, ...)			\
> -	__v4l2_subdev_state_gen_call(interval, ##__VA_ARGS__, , _pad)	\
> +#define v4l2_subdev_state_get_interval(state, pad, ...)				\
> +	__v4l2_subdev_state_gen_call(interval, ##__VA_ARGS__, , _pad)		\
>  		(state, pad, ##__VA_ARGS__)
> -#define __v4l2_subdev_state_get_interval_pad(state, pad)	\
> +#define __v4l2_subdev_state_get_interval_pad(state, pad)			\
>  	__v4l2_subdev_state_get_interval(state, pad, 0)
> +#define __v4l2_subdev_state_get_interval(state, pad, stream)			\
> +	_Generic(state,								\
> +		const struct v4l2_subdev_state *: ((const struct v4l2_frac *)		\
> +			____v4l2_subdev_state_get_interval((struct v4l2_subdev_state *)state, pad, stream)), \
> +		default: ____v4l2_subdev_state_get_interval((struct v4l2_subdev_state *)state, pad, stream) \

Is the cast necessary in the latter case? It would seem like we lose most
of the type safety checks as a result.

Could this be implemented using a similar arrangement than the gen_call
macro above, so that we wouldn't have three very similar sets of macros
here?

> +	)
>  struct v4l2_fract *
> -__v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
> -				 unsigned int pad, u32 stream);
> +____v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
> +				   unsigned int pad, u32 stream);
>  
>  #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
>  

-- 
Kind regards,

Sakari Ailus

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH 1/2] media: v4l2-subdev: Provide const-aware subdev state accessors
  2024-05-06 21:53   ` Sakari Ailus
@ 2024-05-07  6:04     ` Laurent Pinchart
  0 siblings, 0 replies; 6+ messages in thread
From: Laurent Pinchart @ 2024-05-07  6:04 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: linux-media, linux-renesas-soc, Tomi Valkeinen, Hans Verkuil,
	Dafna Hirschfeld, linux-rockchip

On Mon, May 06, 2024 at 09:53:18PM +0000, Sakari Ailus wrote:
> Hi Laurent,
> 
> Thanks for the patch.
> 
> On Mon, May 06, 2024 at 08:52:54PM +0300, Laurent Pinchart wrote:
> > It would be useful to mark instances of v4l2_subdev_state structures as
> > const when code needs to access them read-only. This isn't currently
> > possible, as the v4l2_subdev_state_get_*() accessor functions take a
> > non-const pointer to the state.
> > 
> > Use _Generic() to provide two different versions of the accessors, for
> > const and non-const states respectively. The former returns a const
> > pointer to the requested format, rectangle or interval, implementing
> > const-correctness. The latter returns a non-const pointer, preserving
> > the current behaviour for drivers.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > Bike-shedding about names and the 4 leading underscores is allowed (and
> > expected).
> > ---
> >  drivers/media/v4l2-core/v4l2-subdev.c | 24 +++++-----
> >  include/media/v4l2-subdev.h           | 66 ++++++++++++++++++---------
> >  2 files changed, 57 insertions(+), 33 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> > index 83c6d1e36871..af1fbc28c8f0 100644
> > --- a/drivers/media/v4l2-core/v4l2-subdev.c
> > +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> > @@ -1616,8 +1616,8 @@ void v4l2_subdev_cleanup(struct v4l2_subdev *sd)
> >  EXPORT_SYMBOL_GPL(v4l2_subdev_cleanup);
> >  
> >  struct v4l2_mbus_framefmt *
> > -__v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
> > -			       unsigned int pad, u32 stream)
> > +____v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
> > +				 unsigned int pad, u32 stream)
> >  {
> >  	struct v4l2_subdev_stream_configs *stream_configs;
> >  	unsigned int i;
> > @@ -1647,11 +1647,11 @@ __v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
> >  
> >  	return NULL;
> >  }
> > -EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_format);
> > +EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_format);
> >  
> >  struct v4l2_rect *
> > -__v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
> > -			     u32 stream)
> > +____v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
> > +			       u32 stream)
> >  {
> >  	struct v4l2_subdev_stream_configs *stream_configs;
> >  	unsigned int i;
> > @@ -1681,11 +1681,11 @@ __v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
> >  
> >  	return NULL;
> >  }
> > -EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_crop);
> > +EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_crop);
> >  
> >  struct v4l2_rect *
> > -__v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
> > -				unsigned int pad, u32 stream)
> > +____v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
> > +				  unsigned int pad, u32 stream)
> >  {
> >  	struct v4l2_subdev_stream_configs *stream_configs;
> >  	unsigned int i;
> > @@ -1715,11 +1715,11 @@ __v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
> >  
> >  	return NULL;
> >  }
> > -EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_compose);
> > +EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_compose);
> >  
> >  struct v4l2_fract *
> > -__v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
> > -				 unsigned int pad, u32 stream)
> > +____v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
> > +				   unsigned int pad, u32 stream)
> >  {
> >  	struct v4l2_subdev_stream_configs *stream_configs;
> >  	unsigned int i;
> > @@ -1751,7 +1751,7 @@ __v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
> >  
> >  	return NULL;
> >  }
> > -EXPORT_SYMBOL_GPL(__v4l2_subdev_state_get_interval);
> > +EXPORT_SYMBOL_GPL(____v4l2_subdev_state_get_interval);
> >  
> >  #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
> >  
> > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> > index e30c463d90e5..ba722ab501c1 100644
> > --- a/include/media/v4l2-subdev.h
> > +++ b/include/media/v4l2-subdev.h
> > @@ -1340,21 +1340,27 @@ void v4l2_subdev_cleanup(struct v4l2_subdev *sd);
> >   */
> >  /*
> >   * Wrap v4l2_subdev_state_get_format(), allowing the function to be called with
> > - * two or three arguments. The purpose of the __v4l2_subdev_state_get_format()
> > + * two or three arguments. The purpose of the __v4l2_subdev_state_gen_call()
> >   * macro below is to come up with the name of the function or macro to call,
> >   * using the last two arguments (_stream and _pad). The selected function or
> >   * macro is then called using the arguments specified by the caller. A similar
> >   * arrangement is used for v4l2_subdev_state_crop() and
> >   * v4l2_subdev_state_compose() below.
> >   */
> > -#define v4l2_subdev_state_get_format(state, pad, ...)			\
> > -	__v4l2_subdev_state_gen_call(format, ##__VA_ARGS__, , _pad)	\
> > +#define v4l2_subdev_state_get_format(state, pad, ...)				\
> > +	__v4l2_subdev_state_gen_call(format, ##__VA_ARGS__, , _pad)		\
> >  		(state, pad, ##__VA_ARGS__)
> > -#define __v4l2_subdev_state_get_format_pad(state, pad)	\
> > +#define __v4l2_subdev_state_get_format_pad(state, pad)				\
> >  	__v4l2_subdev_state_get_format(state, pad, 0)
> > +#define __v4l2_subdev_state_get_format(state, pad, stream)			\
> > +	_Generic(state,								\
> > +		const struct v4l2_subdev_state *: ((const struct v4l2_mbus_framefmt *)	\
> > +			____v4l2_subdev_state_get_format((struct v4l2_subdev_state *)state, pad, stream)), \
> > +		default: ____v4l2_subdev_state_get_format((struct v4l2_subdev_state *)state, pad, stream) \
> > +	)
> >  struct v4l2_mbus_framefmt *
> > -__v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
> > -			       unsigned int pad, u32 stream);
> > +____v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
> > +				 unsigned int pad, u32 stream);
> >  
> >  /**
> >   * v4l2_subdev_state_get_crop() - Get pointer to a stream crop rectangle
> > @@ -1368,14 +1374,20 @@ __v4l2_subdev_state_get_format(struct v4l2_subdev_state *state,
> >   * For stream-unaware drivers the crop rectangle for the corresponding pad is
> >   * returned. If the pad does not exist, NULL is returned.
> >   */
> > -#define v4l2_subdev_state_get_crop(state, pad, ...)			\
> > -	__v4l2_subdev_state_gen_call(crop, ##__VA_ARGS__, , _pad)	\
> > +#define v4l2_subdev_state_get_crop(state, pad, ...)				\
> > +	__v4l2_subdev_state_gen_call(crop, ##__VA_ARGS__, , _pad)		\
> >  		(state, pad, ##__VA_ARGS__)
> > -#define __v4l2_subdev_state_get_crop_pad(state, pad)	\
> > +#define __v4l2_subdev_state_get_crop_pad(state, pad)				\
> >  	__v4l2_subdev_state_get_crop(state, pad, 0)
> > +#define __v4l2_subdev_state_get_crop(state, pad, stream)			\
> > +	_Generic(state,								\
> > +		const struct v4l2_subdev_state *: ((const struct v4l2_rect *)		\
> > +			____v4l2_subdev_state_get_crop((struct v4l2_subdev_state *)state, pad, stream)), \
> > +		default: ____v4l2_subdev_state_get_crop((struct v4l2_subdev_state *)state, pad, stream) \
> > +	)
> >  struct v4l2_rect *
> > -__v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
> > -			     u32 stream);
> > +____v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
> > +			       u32 stream);
> >  
> >  /**
> >   * v4l2_subdev_state_get_compose() - Get pointer to a stream compose rectangle
> > @@ -1389,14 +1401,20 @@ __v4l2_subdev_state_get_crop(struct v4l2_subdev_state *state, unsigned int pad,
> >   * For stream-unaware drivers the compose rectangle for the corresponding pad is
> >   * returned. If the pad does not exist, NULL is returned.
> >   */
> > -#define v4l2_subdev_state_get_compose(state, pad, ...)			\
> > -	__v4l2_subdev_state_gen_call(compose, ##__VA_ARGS__, , _pad)	\
> > +#define v4l2_subdev_state_get_compose(state, pad, ...)				\
> > +	__v4l2_subdev_state_gen_call(compose, ##__VA_ARGS__, , _pad)		\
> >  		(state, pad, ##__VA_ARGS__)
> > -#define __v4l2_subdev_state_get_compose_pad(state, pad)	\
> > +#define __v4l2_subdev_state_get_compose_pad(state, pad)				\
> >  	__v4l2_subdev_state_get_compose(state, pad, 0)
> > +#define __v4l2_subdev_state_get_compose(state, pad, stream)			\
> > +	_Generic(state,								\
> > +		const struct v4l2_subdev_state *: ((const struct v4l2_rect *)		\
> > +			____v4l2_subdev_state_get_compose((struct v4l2_subdev_state *)state, pad, stream)), \
> > +		default: ____v4l2_subdev_state_get_compose((struct v4l2_subdev_state *)state, pad, stream) \
> > +	)
> >  struct v4l2_rect *
> > -__v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
> > -				unsigned int pad, u32 stream);
> > +____v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
> > +				  unsigned int pad, u32 stream);
> >  
> >  /**
> >   * v4l2_subdev_state_get_interval() - Get pointer to a stream frame interval
> > @@ -1410,14 +1428,20 @@ __v4l2_subdev_state_get_compose(struct v4l2_subdev_state *state,
> >   * For stream-unaware drivers the frame interval for the corresponding pad is
> >   * returned. If the pad does not exist, NULL is returned.
> >   */
> > -#define v4l2_subdev_state_get_interval(state, pad, ...)			\
> > -	__v4l2_subdev_state_gen_call(interval, ##__VA_ARGS__, , _pad)	\
> > +#define v4l2_subdev_state_get_interval(state, pad, ...)				\
> > +	__v4l2_subdev_state_gen_call(interval, ##__VA_ARGS__, , _pad)		\
> >  		(state, pad, ##__VA_ARGS__)
> > -#define __v4l2_subdev_state_get_interval_pad(state, pad)	\
> > +#define __v4l2_subdev_state_get_interval_pad(state, pad)			\
> >  	__v4l2_subdev_state_get_interval(state, pad, 0)
> > +#define __v4l2_subdev_state_get_interval(state, pad, stream)			\
> > +	_Generic(state,								\
> > +		const struct v4l2_subdev_state *: ((const struct v4l2_frac *)		\
> > +			____v4l2_subdev_state_get_interval((struct v4l2_subdev_state *)state, pad, stream)), \
> > +		default: ____v4l2_subdev_state_get_interval((struct v4l2_subdev_state *)state, pad, stream) \
> 
> Is the cast necessary in the latter case? It would seem like we lose most
> of the type safety checks as a result.

It is, and I was surprised by it. The reason is that all branches of the
_Generic statement must compile, even the ones that are not selected.
When the macro is called with a const state, the first branch is taken,
but the second branch must compile too. Without the cast, the compiler
complains that the state argument passed to
____v4l2_subdev_state_get_interval() is const.

> Could this be implemented using a similar arrangement than the gen_call
> macro above, so that we wouldn't have three very similar sets of macros
> here?

I've sent a v2 that does that.

> > +	)
> >  struct v4l2_fract *
> > -__v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
> > -				 unsigned int pad, u32 stream);
> > +____v4l2_subdev_state_get_interval(struct v4l2_subdev_state *state,
> > +				   unsigned int pad, u32 stream);
> >  
> >  #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
> >  

-- 
Regards,

Laurent Pinchart

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH 2/2] media: rkisp1: Mark subdev state pointers as const
  2024-05-06 17:52 ` [PATCH 2/2] media: rkisp1: Mark subdev state pointers as const Laurent Pinchart
@ 2024-05-14 20:07   ` Nicolas Dufresne
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Dufresne @ 2024-05-14 20:07 UTC (permalink / raw)
  To: Laurent Pinchart, linux-media
  Cc: linux-renesas-soc, Sakari Ailus, Tomi Valkeinen, Hans Verkuil,
	Dafna Hirschfeld, linux-rockchip

Just passed by this one ...

Le lundi 06 mai 2024 à 20:52 +0300, Laurent Pinchart a écrit :
> Several subdev state pointers are used to access the state read-only.
> Mark them as const.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

> ---
>  drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c     | 8 ++++----
>  drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c | 8 ++++----
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c
> index e45a213baf49..91301d17d356 100644
> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c
> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c
> @@ -173,7 +173,7 @@ static void rkisp1_gasket_disable(struct rkisp1_device *rkisp1)
>   * or at the frame end interrupt
>   */
>  static void rkisp1_config_ism(struct rkisp1_isp *isp,
> -			      struct v4l2_subdev_state *sd_state)
> +			      const struct v4l2_subdev_state *sd_state)
>  {
>  	const struct v4l2_rect *src_crop =
>  		v4l2_subdev_state_get_crop(sd_state,
> @@ -201,7 +201,7 @@ static void rkisp1_config_ism(struct rkisp1_isp *isp,
>   * configure ISP blocks with input format, size......
>   */
>  static int rkisp1_config_isp(struct rkisp1_isp *isp,
> -			     struct v4l2_subdev_state *sd_state,
> +			     const struct v4l2_subdev_state *sd_state,
>  			     enum v4l2_mbus_type mbus_type, u32 mbus_flags)
>  {
>  	struct rkisp1_device *rkisp1 = isp->rkisp1;
> @@ -309,7 +309,7 @@ static int rkisp1_config_isp(struct rkisp1_isp *isp,
>  	if (src_fmt->pixel_enc == V4L2_PIXEL_ENC_BAYER) {
>  		rkisp1_params_disable(&rkisp1->params);
>  	} else {
> -		struct v4l2_mbus_framefmt *src_frm;
> +		const struct v4l2_mbus_framefmt *src_frm;
>  
>  		src_frm = v4l2_subdev_state_get_format(sd_state,
>  						       RKISP1_ISP_PAD_SOURCE_VIDEO);
> @@ -429,7 +429,7 @@ static void rkisp1_config_clk(struct rkisp1_isp *isp)
>  }
>  
>  static int rkisp1_isp_start(struct rkisp1_isp *isp,
> -			    struct v4l2_subdev_state *sd_state,
> +			    const struct v4l2_subdev_state *sd_state,
>  			    struct media_pad *source)
>  {
>  	struct rkisp1_device *rkisp1 = isp->rkisp1;
> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c
> index 6f3931ca5b51..1fa991227fa9 100644
> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c
> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c
> @@ -135,11 +135,11 @@ static void rkisp1_dcrop_disable(struct rkisp1_resizer *rsz,
>  
>  /* configure dual-crop unit */
>  static void rkisp1_dcrop_config(struct rkisp1_resizer *rsz,
> -				struct v4l2_subdev_state *sd_state)
> +				const struct v4l2_subdev_state *sd_state)
>  {
>  	struct rkisp1_device *rkisp1 = rsz->rkisp1;
> -	struct v4l2_mbus_framefmt *sink_fmt;
> -	struct v4l2_rect *sink_crop;
> +	const struct v4l2_mbus_framefmt *sink_fmt;
> +	const struct v4l2_rect *sink_crop;
>  	u32 dc_ctrl;
>  
>  	sink_crop = v4l2_subdev_state_get_crop(sd_state, RKISP1_RSZ_PAD_SINK);
> @@ -264,7 +264,7 @@ static void rkisp1_rsz_config_regs(struct rkisp1_resizer *rsz,
>  }
>  
>  static void rkisp1_rsz_config(struct rkisp1_resizer *rsz,
> -			      struct v4l2_subdev_state *sd_state,
> +			      const struct v4l2_subdev_state *sd_state,
>  			      enum rkisp1_shadow_regs_when when)
>  {
>  	const struct rkisp1_rsz_yuv_mbus_info *sink_yuv_info, *src_yuv_info;


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

end of thread, other threads:[~2024-05-14 20:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06 17:52 [PATCH 0/2] media: v4l2-subdev: Support const-awareness in state accessors Laurent Pinchart
2024-05-06 17:52 ` [PATCH 1/2] media: v4l2-subdev: Provide const-aware subdev " Laurent Pinchart
2024-05-06 21:53   ` Sakari Ailus
2024-05-07  6:04     ` Laurent Pinchart
2024-05-06 17:52 ` [PATCH 2/2] media: rkisp1: Mark subdev state pointers as const Laurent Pinchart
2024-05-14 20:07   ` Nicolas Dufresne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).