Skip to contentSkip to conversation

Drop control handler argument support for v4l2_get_link_freq()

PATCH Superseded Sakari Ailus 3 participants 8 messages Aug 19, 2025 – Aug 21, 2025

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Drop control handler argument support for v4l2_get_link_freq()

Hi folks,

This set removes the workaround from v4l2_get_link_freq() that allowed calling it on a control handler. The Amlogic c3-mipi-csi2 driver is converted in the process as well.

As a result there's also no definition of v4l2_get_link_freq() without CONFIG_MEDIA_CONTROLLER but that should be fine now. The Amlogic patch is untested.

since v1:

- Remove redundant src_pad argument from c3_mipi_csi_start_stream().

Sakari Ailus (2):
media: amlogic: c3-mipi-csi2: Call v4l2_get_link_freq() on source pad
media: v4l2-common: Drop the workaround from v4l2_get_link_freq()

 .../amlogic/c3/mipi-csi2/c3-mipi-csi2.c         |  7 +++----
 drivers/media/v4l2-core/v4l2-common.c           | 17 ++++++++---------
 include/media/v4l2-common.h                     | 14 ++------------
 3 files changed, 13 insertions(+), 25 deletions(-)
Signature · 1 line
2.47.2
#1 lore raw

PATCH v2 1/2 media: amlogic: c3-mipi-csi2: Call v4l2_get_link_freq() on source pad

Call v4l2_get_link_freq() on the source pad so we can remove the workaround that allows calling it on a control handler.

---
 drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c +3 -4
index 1011ab3ebac7..b9e4ef3fc308 100644
@@ -388,13 +388,12 @@ static void c3_mipi_csi_cfg_host(struct c3_csi_device *csi)
 	c3_mipi_csi_write(csi, CSI2_HOST_N_LANES, csi->bus.num_data_lanes - 1);
 }
 
-static int c3_mipi_csi_start_stream(struct c3_csi_device *csi,
-				    struct v4l2_subdev *src_sd)
+static int c3_mipi_csi_start_stream(struct c3_csi_device *csi)
 {
 	s64 link_freq;
 	s64 lane_rate;
 
-	link_freq = v4l2_get_link_freq(src_sd->ctrl_handler, 0, 0);
+	link_freq = v4l2_get_link_freq(csi->src_pad, 0, 0);
 	if (link_freq < 0) {
 		dev_err(csi->dev,
 			"Unable to obtain link frequency: %lld\n", link_freq);
@@ -434,7 +433,7 @@ static int c3_mipi_csi_enable_streams(struct v4l2_subdev *sd,
 
 	pm_runtime_resume_and_get(csi->dev);
 
-	c3_mipi_csi_start_stream(csi, src_sd);
+	c3_mipi_csi_start_stream(csi);
 
 	ret = v4l2_subdev_enable_streams(src_sd, csi->src_pad->index, BIT(0));
 	if (ret) {
Signature · 1 line
2.47.2
maintainer Reviewed-by Tested-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] media: amlogic: c3-mipi-csi2: Call v4l2_get_link_freq() on source pad

Hi Sakari

Thanks for your patches.

Quoted 7 lines · Sakari Ailus

[ EXTERNAL EMAIL ]

Call v4l2_get_link_freq() on the source pad so we can remove the workaround that allows calling it on a control handler.

I have tested this patch series on C3, the result is OK.

Thanks.

Quoted 36 lines
---
  drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c +3 -5
index 1011ab3ebac7..b9e4ef3fc308 100644
@@ -388,13 +388,12 @@ static void c3_mipi_csi_cfg_host(struct c3_csi_device *csi)
         c3_mipi_csi_write(csi, CSI2_HOST_N_LANES, csi->bus.num_data_lanes - 1);
  }
 
-static int c3_mipi_csi_start_stream(struct c3_csi_device *csi,
-                                   struct v4l2_subdev *src_sd)
+static int c3_mipi_csi_start_stream(struct c3_csi_device *csi)
  {
         s64 link_freq;
         s64 lane_rate;
 
-       link_freq = v4l2_get_link_freq(src_sd->ctrl_handler, 0, 0);
+       link_freq = v4l2_get_link_freq(csi->src_pad, 0, 0);
         if (link_freq < 0) {
                 dev_err(csi->dev,
                         "Unable to obtain link frequency: %lld\n", link_freq);
@@ -434,7 +433,7 @@ static int c3_mipi_csi_enable_streams(struct v4l2_subdev *sd,
 
         pm_runtime_resume_and_get(csi->dev);
 
-       c3_mipi_csi_start_stream(csi, src_sd);
+       c3_mipi_csi_start_stream(csi);
 
         ret = v4l2_subdev_enable_streams(src_sd, csi->src_pad->index, BIT(0));
         if (ret) {
--

2.47.2

#3 lore raw

PATCH v2 2/2 media: v4l2-common: Drop the workaround from v4l2_get_link_freq()

In reply to Sakari Ailus

Remove the workaround that allowed calling v4l2_get_link_freq() on the control handler.

---
 drivers/media/v4l2-core/v4l2-common.c | 17 ++++++++---------
 include/media/v4l2-common.h           | 14 ++------------
 2 files changed, 10 insertions(+), 21 deletions(-)
drivers/media/v4l2-core/v4l2-common.c +8 -9
index a5334aa35992..0574f5d685f8 100644
@@ -512,8 +512,9 @@ int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
 }
 EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt);
 
-s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
-			      unsigned int mul, unsigned int div)
+#ifdef CONFIG_MEDIA_CONTROLLER
+static s64 v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
+				   unsigned int mul, unsigned int div)
 {
 	struct v4l2_ctrl *ctrl;
 	s64 freq;
@@ -548,11 +549,9 @@ s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
 
 	return freq > 0 ? freq : -EINVAL;
 }
-EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_ctrl);
 
-#ifdef CONFIG_MEDIA_CONTROLLER
-s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
-			     unsigned int div)
+s64 v4l2_get_link_freq(struct media_pad *pad, unsigned int mul,
+		       unsigned int div)
 {
 	struct v4l2_mbus_config mbus_config = {};
 	struct v4l2_subdev *sd;
@@ -571,10 +570,10 @@ s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
 	 * Fall back to using the link frequency control if the media bus config
 	 * doesn't provide a link frequency.
 	 */
-	return __v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div);
+	return v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div);
 }
-EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_pad);
-#endif /* CONFIG_MEDIA_CONTROLLER */
+EXPORT_SYMBOL_GPL(v4l2_get_link_freq);
+#endif
 
 /*
  * Simplify a fraction using a simple continued fraction decomposition. The
include/media/v4l2-common.h +2 -12
index 39dd0c78d70f..aedcfc81d12b 100644
@@ -578,19 +578,9 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,
  * * %-EINVAL: Invalid link frequency value
  */
 #ifdef CONFIG_MEDIA_CONTROLLER
-#define v4l2_get_link_freq(pad, mul, div)				\
-	_Generic(pad,							\
-		 struct media_pad *: __v4l2_get_link_freq_pad,		\
-		 struct v4l2_ctrl_handler *: __v4l2_get_link_freq_ctrl)	\
-	(pad, mul, div)
-s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
-			     unsigned int div);
-#else
-#define v4l2_get_link_freq(handler, mul, div)		\
-	__v4l2_get_link_freq_ctrl(handler, mul, div)
+s64 v4l2_get_link_freq(struct media_pad *pad, unsigned int mul,
+		       unsigned int div);
 #endif
-s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
-			      unsigned int mul, unsigned int div);
 
 void v4l2_simplify_fraction(u32 *numerator, u32 *denominator,
 		unsigned int n_terms, unsigned int threshold);
Signature · 1 line
2.47.2
#4 lore raw

Re: [PATCH v2 2/2] media: v4l2-common: Drop the workaround from v4l2_get_link_freq()

Quoted 41 lines · Sakari Ailus

Remove the workaround that allowed calling v4l2_get_link_freq() on the control handler.

---
 drivers/media/v4l2-core/v4l2-common.c | 17 ++++++++---------
 include/media/v4l2-common.h           | 14 ++------------
 2 files changed, 10 insertions(+), 21 deletions(-)
drivers/media/v4l2-core/v4l2-common.c +5 -6
index a5334aa35992..0574f5d685f8 100644
@@ -512,8 +512,9 @@ int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
 }
 EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt);
 
-s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
-			      unsigned int mul, unsigned int div)
+#ifdef CONFIG_MEDIA_CONTROLLER
+static s64 v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
+				   unsigned int mul, unsigned int div)
 {
 	struct v4l2_ctrl *ctrl;
 	s64 freq;
@@ -548,11 +549,9 @@ s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
 
 	return freq > 0 ? freq : -EINVAL;
 }
-EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_ctrl);
 
-#ifdef CONFIG_MEDIA_CONTROLLER
-s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
-			     unsigned int div)
+s64 v4l2_get_link_freq(struct media_pad *pad, unsigned int mul,
+		       unsigned int div)
 {
 	struct v4l2_mbus_config mbus_config = {};
 	struct v4l2_subdev *sd;

drivers/media/v4l2-core/v4l2-common.c s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul, · line 576

Quoted 10 lines
drivers/media/v4l2-core/v4l2-common.c +3 -3
@@ -571,10 +570,10 @@ s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
 	 * Fall back to using the link frequency control if the media bus config
 	 * doesn't provide a link frequency.
 	 */
-	return __v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div);
+	return v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div);
 }
-EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_pad);
-#endif /* CONFIG_MEDIA_CONTROLLER */
+EXPORT_SYMBOL_GPL(v4l2_get_link_freq);
+#endif

You can now merge the two functions into one.

include/media/v4l2-common.h int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat, · line 578

Quoted 9 lines
drivers/media/v4l2-core/v4l2-common.c +0 -0
 /*
  * Simplify a fraction using a simple continued fraction decomposition. The
include/media/v4l2-common.h +0 -0
index 39dd0c78d70f..aedcfc81d12b 100644
@@ -578,19 +578,9 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,
  * * %-EINVAL: Invalid link frequency value

The function documentation needs an update, the pad argument's description still mentions control handler. With that,

Quoted 20 lines
include/media/v4l2-common.h +2 -12
  */
 #ifdef CONFIG_MEDIA_CONTROLLER
-#define v4l2_get_link_freq(pad, mul, div)				\
-	_Generic(pad,							\
-		 struct media_pad *: __v4l2_get_link_freq_pad,		\
-		 struct v4l2_ctrl_handler *: __v4l2_get_link_freq_ctrl)	\
-	(pad, mul, div)
-s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
-			     unsigned int div);
-#else
-#define v4l2_get_link_freq(handler, mul, div)		\
-	__v4l2_get_link_freq_ctrl(handler, mul, div)
+s64 v4l2_get_link_freq(struct media_pad *pad, unsigned int mul,
+		       unsigned int div);
 #endif
-s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
-			      unsigned int mul, unsigned int div);
 
 void v4l2_simplify_fraction(u32 *numerator, u32 *denominator,
 		unsigned int n_terms, unsigned int threshold);
Signature · 3 lines
Regards,

Laurent Pinchart
#5 lore raw

Re: [PATCH v2 2/2] media: v4l2-common: Drop the workaround from v4l2_get_link_freq()

Hi Laurent,

Thanks for the review.

Quoted 46 lines · Laurent Pinchart
Quoted 45 lines · Sakari Ailus

Remove the workaround that allowed calling v4l2_get_link_freq() on the control handler.

---
 drivers/media/v4l2-core/v4l2-common.c | 17 ++++++++---------
 include/media/v4l2-common.h           | 14 ++------------
 2 files changed, 10 insertions(+), 21 deletions(-)
drivers/media/v4l2-core/v4l2-common.c +5 -7
index a5334aa35992..0574f5d685f8 100644
@@ -512,8 +512,9 @@ int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
 }
 EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt);
 
-s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
-			      unsigned int mul, unsigned int div)
+#ifdef CONFIG_MEDIA_CONTROLLER
+static s64 v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
+				   unsigned int mul, unsigned int div)
 {
 	struct v4l2_ctrl *ctrl;
 	s64 freq;
@@ -548,11 +549,9 @@ s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
 
 	return freq > 0 ? freq : -EINVAL;
 }
-EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_ctrl);
 
-#ifdef CONFIG_MEDIA_CONTROLLER
-s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
-			     unsigned int div)
+s64 v4l2_get_link_freq(struct media_pad *pad, unsigned int mul,
+		       unsigned int div)
 {
 	struct v4l2_mbus_config mbus_config = {};
 	struct v4l2_subdev *sd;
@@ -571,10 +570,10 @@ s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
 	 * Fall back to using the link frequency control if the media bus config
 	 * doesn't provide a link frequency.
 	 */
-	return __v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div);
Quoted 8 lines

drivers/media/v4l2-core/v4l2-common.c s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul, · line 576

Quoted 6 lines
drivers/media/v4l2-core/v4l2-common.c +3 -2
+	return v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div);
 }
-EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_pad);
-#endif /* CONFIG_MEDIA_CONTROLLER */
+EXPORT_SYMBOL_GPL(v4l2_get_link_freq);
+#endif

You can now merge the two functions into one.

I could do that but the end result would be somewhat less clear so I prefer keeping the two separate. I don't have a strong opinion though.

Quoted 13 lines

include/media/v4l2-common.h int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat, · line 578

Quoted 10 lines
drivers/media/v4l2-core/v4l2-common.c +0 -0
 /*
  * Simplify a fraction using a simple continued fraction decomposition. The
include/media/v4l2-common.h +0 -0
index 39dd0c78d70f..aedcfc81d12b 100644
@@ -578,19 +578,9 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,
  * * %-EINVAL: Invalid link frequency value

The function documentation needs an update, the pad argument's description still mentions control handler. With that,

What happens with that?

I'll fix this for v3.

Quoted 22 lines
Quoted 21 lines
include/media/v4l2-common.h +2 -12
  */
 #ifdef CONFIG_MEDIA_CONTROLLER
-#define v4l2_get_link_freq(pad, mul, div)				\
-	_Generic(pad,							\
-		 struct media_pad *: __v4l2_get_link_freq_pad,		\
-		 struct v4l2_ctrl_handler *: __v4l2_get_link_freq_ctrl)	\
-	(pad, mul, div)
-s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
-			     unsigned int div);
-#else
-#define v4l2_get_link_freq(handler, mul, div)		\
-	__v4l2_get_link_freq_ctrl(handler, mul, div)
+s64 v4l2_get_link_freq(struct media_pad *pad, unsigned int mul,
+		       unsigned int div);
 #endif
-s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
-			      unsigned int mul, unsigned int div);
 
 void v4l2_simplify_fraction(u32 *numerator, u32 *denominator,
 		unsigned int n_terms, unsigned int threshold);
Signature · 3 lines
Kind regards,

Sakari Ailus
#6 lore raw

Re: [PATCH v2 2/2] media: v4l2-common: Drop the workaround from v4l2_get_link_freq()

Quoted 56 lines · Sakari Ailus
Quoted 46 lines · Laurent Pinchart
Quoted 45 lines · Sakari Ailus

Remove the workaround that allowed calling v4l2_get_link_freq() on the control handler.

---
 drivers/media/v4l2-core/v4l2-common.c | 17 ++++++++---------
 include/media/v4l2-common.h           | 14 ++------------
 2 files changed, 10 insertions(+), 21 deletions(-)
drivers/media/v4l2-core/v4l2-common.c +5 -7
index a5334aa35992..0574f5d685f8 100644
@@ -512,8 +512,9 @@ int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
 }
 EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt);
 
-s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
-			      unsigned int mul, unsigned int div)
+#ifdef CONFIG_MEDIA_CONTROLLER
+static s64 v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
+				   unsigned int mul, unsigned int div)
 {
 	struct v4l2_ctrl *ctrl;
 	s64 freq;
@@ -548,11 +549,9 @@ s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
 
 	return freq > 0 ? freq : -EINVAL;
 }
-EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_ctrl);
 
-#ifdef CONFIG_MEDIA_CONTROLLER
-s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
-			     unsigned int div)
+s64 v4l2_get_link_freq(struct media_pad *pad, unsigned int mul,
+		       unsigned int div)
 {
 	struct v4l2_mbus_config mbus_config = {};
 	struct v4l2_subdev *sd;
@@ -571,10 +570,10 @@ s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
 	 * Fall back to using the link frequency control if the media bus config
 	 * doesn't provide a link frequency.
 	 */
-	return __v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div);
Quoted 8 lines

drivers/media/v4l2-core/v4l2-common.c s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul, · line 576

Quoted 6 lines
drivers/media/v4l2-core/v4l2-common.c +3 -2
+	return v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div);
 }
-EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_pad);
-#endif /* CONFIG_MEDIA_CONTROLLER */
+EXPORT_SYMBOL_GPL(v4l2_get_link_freq);
+#endif

You can now merge the two functions into one.

Quoted 2 lines

I could do that but the end result would be somewhat less clear so I prefer keeping the two separate. I don't have a strong opinion though.

I think it would be clearer to keep everything in a single function, but that's a slight preference. Up to you.

Quoted 13 lines
Quoted 12 lines

include/media/v4l2-common.h int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat, · line 578

Quoted 9 lines
drivers/media/v4l2-core/v4l2-common.c +0 -0
 /*
  * Simplify a fraction using a simple continued fraction decomposition. The
include/media/v4l2-common.h +0 -0
index 39dd0c78d70f..aedcfc81d12b 100644
@@ -578,19 +578,9 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,
  * * %-EINVAL: Invalid link frequency value

The function documentation needs an update, the pad argument's description still mentions control handler. With that,

Quoted 1 line

What happens with that?

With that I'll be fine with the patch :-)

Quoted 22 lines

I'll fix this for v3.

Quoted 20 lines
Quoted 20 lines
include/media/v4l2-common.h +2 -12
  */
 #ifdef CONFIG_MEDIA_CONTROLLER
-#define v4l2_get_link_freq(pad, mul, div)				\
-	_Generic(pad,							\
-		 struct media_pad *: __v4l2_get_link_freq_pad,		\
-		 struct v4l2_ctrl_handler *: __v4l2_get_link_freq_ctrl)	\
-	(pad, mul, div)
-s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
-			     unsigned int div);
-#else
-#define v4l2_get_link_freq(handler, mul, div)		\
-	__v4l2_get_link_freq_ctrl(handler, mul, div)
+s64 v4l2_get_link_freq(struct media_pad *pad, unsigned int mul,
+		       unsigned int div);
 #endif
-s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
-			      unsigned int mul, unsigned int div);
 
 void v4l2_simplify_fraction(u32 *numerator, u32 *denominator,
 		unsigned int n_terms, unsigned int threshold);
Signature · 3 lines
Regards,

Laurent Pinchart
#7 lore raw

Re: [PATCH v2 2/2] media: v4l2-common: Drop the workaround from v4l2_get_link_freq()

Hi Laurent,

Quoted 57 lines · Laurent Pinchart
Quoted 56 lines · Sakari Ailus
Quoted 54 lines · Laurent Pinchart
Quoted 41 lines · Sakari Ailus

Remove the workaround that allowed calling v4l2_get_link_freq() on the control handler.

---
 drivers/media/v4l2-core/v4l2-common.c | 17 ++++++++---------
 include/media/v4l2-common.h           | 14 ++------------
 2 files changed, 10 insertions(+), 21 deletions(-)
drivers/media/v4l2-core/v4l2-common.c +5 -6
index a5334aa35992..0574f5d685f8 100644
@@ -512,8 +512,9 @@ int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat,
 }
 EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt);
 
-s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
-			      unsigned int mul, unsigned int div)
+#ifdef CONFIG_MEDIA_CONTROLLER
+static s64 v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
+				   unsigned int mul, unsigned int div)
 {
 	struct v4l2_ctrl *ctrl;
 	s64 freq;
@@ -548,11 +549,9 @@ s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,
 
 	return freq > 0 ? freq : -EINVAL;
 }
-EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_ctrl);
 
-#ifdef CONFIG_MEDIA_CONTROLLER
-s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
-			     unsigned int div)
+s64 v4l2_get_link_freq(struct media_pad *pad, unsigned int mul,
+		       unsigned int div)
 {
 	struct v4l2_mbus_config mbus_config = {};
 	struct v4l2_subdev *sd;

drivers/media/v4l2-core/v4l2-common.c s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul, · line 576

Quoted 10 lines
drivers/media/v4l2-core/v4l2-common.c +3 -3
@@ -571,10 +570,10 @@ s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,
 	 * Fall back to using the link frequency control if the media bus config
 	 * doesn't provide a link frequency.
 	 */
-	return __v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div);
+	return v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div);
 }
-EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_pad);
-#endif /* CONFIG_MEDIA_CONTROLLER */
+EXPORT_SYMBOL_GPL(v4l2_get_link_freq);
+#endif

You can now merge the two functions into one.

Quoted 5 lines
Quoted 2 lines

I could do that but the end result would be somewhat less clear so I prefer keeping the two separate. I don't have a strong opinion though.

I think it would be clearer to keep everything in a single function, but that's a slight preference. Up to you.

Ack. I keep it as-is for now.

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

include/media/v4l2-common.h int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat, · line 578

Quoted 10 lines
drivers/media/v4l2-core/v4l2-common.c +0 -0
 /*
  * Simplify a fraction using a simple continued fraction decomposition. The
include/media/v4l2-common.h +0 -0
index 39dd0c78d70f..aedcfc81d12b 100644
@@ -578,19 +578,9 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,
  * * %-EINVAL: Invalid link frequency value

The function documentation needs an update, the pad argument's description still mentions control handler. With that,

Quoted 3 lines
Quoted 1 line

What happens with that?

With that I'll be fine with the patch :-)

\o/

Signature · 3 lines
Regards,

Sakari Ailus