[PATCH v3 01/15] media: rcar-csi2: Use the pad version of v4l2_get_link_freq()

Tomi Valkeinen posted 15 patches 6 months, 2 weeks ago
There is a newer version of this series
[PATCH v3 01/15] media: rcar-csi2: Use the pad version of v4l2_get_link_freq()
Posted by Tomi Valkeinen 6 months, 2 weeks ago
Use the new version of v4l2_get_link_freq() which supports media_pad as
a parameter.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
---
 drivers/media/platform/renesas/rcar-csi2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
index 9979de4f6ef1..ddbdde23c122 100644
--- a/drivers/media/platform/renesas/rcar-csi2.c
+++ b/drivers/media/platform/renesas/rcar-csi2.c
@@ -954,6 +954,7 @@ static int rcsi2_set_phypll(struct rcar_csi2 *priv, unsigned int mbps)
 static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
 			   unsigned int lanes)
 {
+	struct media_pad *remote_pad;
 	struct v4l2_subdev *source;
 	s64 freq;
 	u64 mbps;
@@ -962,8 +963,9 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
 		return -ENODEV;
 
 	source = priv->remote;
+	remote_pad = &source->entity.pads[priv->remote_pad];
 
-	freq = v4l2_get_link_freq(source->ctrl_handler, bpp, 2 * lanes);
+	freq = v4l2_get_link_freq(remote_pad, bpp, 2 * lanes);
 	if (freq < 0) {
 		int ret = (int)freq;
 

-- 
2.43.0
Re: [PATCH v3 01/15] media: rcar-csi2: Use the pad version of v4l2_get_link_freq()
Posted by Niklas Söderlund 6 months, 1 week ago
Hi Tomi,

Thanks for your work.

On 2025-05-30 16:50:30 +0300, Tomi Valkeinen wrote:
> Use the new version of v4l2_get_link_freq() which supports media_pad as
> a parameter.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  drivers/media/platform/renesas/rcar-csi2.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
> index 9979de4f6ef1..ddbdde23c122 100644
> --- a/drivers/media/platform/renesas/rcar-csi2.c
> +++ b/drivers/media/platform/renesas/rcar-csi2.c
> @@ -954,6 +954,7 @@ static int rcsi2_set_phypll(struct rcar_csi2 *priv, unsigned int mbps)
>  static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
>  			   unsigned int lanes)
>  {
> +	struct media_pad *remote_pad;
>  	struct v4l2_subdev *source;
>  	s64 freq;
>  	u64 mbps;
> @@ -962,8 +963,9 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
>  		return -ENODEV;
>  
>  	source = priv->remote;
> +	remote_pad = &source->entity.pads[priv->remote_pad];
>  
> -	freq = v4l2_get_link_freq(source->ctrl_handler, bpp, 2 * lanes);
> +	freq = v4l2_get_link_freq(remote_pad, bpp, 2 * lanes);
>  	if (freq < 0) {
>  		int ret = (int)freq;
>  
> 
> -- 
> 2.43.0
> 

-- 
Kind Regards,
Niklas Söderlund
Re: [PATCH v3 01/15] media: rcar-csi2: Use the pad version of v4l2_get_link_freq()
Posted by Laurent Pinchart 6 months, 2 weeks ago
Hi Tomi,

Thank you for the patch.

On Fri, May 30, 2025 at 04:50:30PM +0300, Tomi Valkeinen wrote:
> Use the new version of v4l2_get_link_freq() which supports media_pad as
> a parameter.

The commit message should explain why. With that fixed,

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> ---
>  drivers/media/platform/renesas/rcar-csi2.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
> index 9979de4f6ef1..ddbdde23c122 100644
> --- a/drivers/media/platform/renesas/rcar-csi2.c
> +++ b/drivers/media/platform/renesas/rcar-csi2.c
> @@ -954,6 +954,7 @@ static int rcsi2_set_phypll(struct rcar_csi2 *priv, unsigned int mbps)
>  static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
>  			   unsigned int lanes)
>  {
> +	struct media_pad *remote_pad;
>  	struct v4l2_subdev *source;
>  	s64 freq;
>  	u64 mbps;
> @@ -962,8 +963,9 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
>  		return -ENODEV;
>  
>  	source = priv->remote;
> +	remote_pad = &source->entity.pads[priv->remote_pad];
>  
> -	freq = v4l2_get_link_freq(source->ctrl_handler, bpp, 2 * lanes);
> +	freq = v4l2_get_link_freq(remote_pad, bpp, 2 * lanes);
>  	if (freq < 0) {
>  		int ret = (int)freq;
>  

-- 
Regards,

Laurent Pinchart
Re: [PATCH v3 01/15] media: rcar-csi2: Use the pad version of v4l2_get_link_freq()
Posted by Niklas Söderlund 5 months, 2 weeks ago
On 2025-06-02 12:43:21 +0300, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Fri, May 30, 2025 at 04:50:30PM +0300, Tomi Valkeinen wrote:
> > Use the new version of v4l2_get_link_freq() which supports media_pad as
> > a parameter.
> 
> The commit message should explain why. With that fixed,

How about this,

The pad aware version of v4l2_get_link_freq() tries to retrieve the link 
frequency from the media bus configuration using the get_mbus_config 
operation, and only if the subdevice do not implement this operation 
fall-back to the old method of getting it using the V4L2_CID_LINK_FREQ 
or V4L2_CID_PIXEL_RATE control.

Update the VIN driver to use the pad aware version to be able to support 
subdevices that only provides the link frequency in the media bus 
configuration. As the implementation falls-back to the old method if the 
subdevice don't support get_mbus_config, or don't provide a link 
frequency in the v4l2_mbus_config struct, this is fully backward 
compatible.

> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> 
> > Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> > ---
> >  drivers/media/platform/renesas/rcar-csi2.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
> > index 9979de4f6ef1..ddbdde23c122 100644
> > --- a/drivers/media/platform/renesas/rcar-csi2.c
> > +++ b/drivers/media/platform/renesas/rcar-csi2.c
> > @@ -954,6 +954,7 @@ static int rcsi2_set_phypll(struct rcar_csi2 *priv, unsigned int mbps)
> >  static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
> >  			   unsigned int lanes)
> >  {
> > +	struct media_pad *remote_pad;
> >  	struct v4l2_subdev *source;
> >  	s64 freq;
> >  	u64 mbps;
> > @@ -962,8 +963,9 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
> >  		return -ENODEV;
> >  
> >  	source = priv->remote;
> > +	remote_pad = &source->entity.pads[priv->remote_pad];
> >  
> > -	freq = v4l2_get_link_freq(source->ctrl_handler, bpp, 2 * lanes);
> > +	freq = v4l2_get_link_freq(remote_pad, bpp, 2 * lanes);
> >  	if (freq < 0) {
> >  		int ret = (int)freq;
> >  
> 
> -- 
> Regards,
> 
> Laurent Pinchart

-- 
Kind Regards,
Niklas Söderlund
Re: [PATCH v3 01/15] media: rcar-csi2: Use the pad version of v4l2_get_link_freq()
Posted by Laurent Pinchart 5 months, 2 weeks ago
On Wed, Jul 02, 2025 at 05:07:11PM +0200, Niklas Söderlund wrote:
> On 2025-06-02 12:43:21 +0300, Laurent Pinchart wrote:
> > On Fri, May 30, 2025 at 04:50:30PM +0300, Tomi Valkeinen wrote:
> > > Use the new version of v4l2_get_link_freq() which supports media_pad as
> > > a parameter.
> > 
> > The commit message should explain why. With that fixed,
> 
> How about this,
> 
> The pad aware version of v4l2_get_link_freq() tries to retrieve the link 

s/pad aware/pad-aware/

> frequency from the media bus configuration using the get_mbus_config 
> operation, and only if the subdevice do not implement this operation 

s/do not/does not/

> fall-back to the old method of getting it using the V4L2_CID_LINK_FREQ 

s/fall-back/falls back/

> or V4L2_CID_PIXEL_RATE control.
> 
> Update the VIN driver to use the pad aware version to be able to support 

s/pad aware/pad-aware/

> subdevices that only provides the link frequency in the media bus 
> configuration. As the implementation falls-back to the old method if the 

s/falls-back/falls back/

> subdevice don't support get_mbus_config, or don't provide a link 

s/don't/doesn't/g

> frequency in the v4l2_mbus_config struct, this is fully backward 
> compatible.

Looks good to me.

As discussed privately, this patch is needed to avoid breakages with the
latest GMSL2/3 drivers posted in [1] on Gen4 platforms. As the patch
makes sense on its own without the rest of the series, I'll take it in
my tree.

[1] lore.kernel.org/linux-media/20250702132104.1537926-1-demonsingur@gmail.com

> > Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > 
> > > Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
> > > ---
> > >  drivers/media/platform/renesas/rcar-csi2.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
> > > index 9979de4f6ef1..ddbdde23c122 100644
> > > --- a/drivers/media/platform/renesas/rcar-csi2.c
> > > +++ b/drivers/media/platform/renesas/rcar-csi2.c
> > > @@ -954,6 +954,7 @@ static int rcsi2_set_phypll(struct rcar_csi2 *priv, unsigned int mbps)
> > >  static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
> > >  			   unsigned int lanes)
> > >  {
> > > +	struct media_pad *remote_pad;
> > >  	struct v4l2_subdev *source;
> > >  	s64 freq;
> > >  	u64 mbps;
> > > @@ -962,8 +963,9 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp,
> > >  		return -ENODEV;
> > >  
> > >  	source = priv->remote;
> > > +	remote_pad = &source->entity.pads[priv->remote_pad];
> > >  
> > > -	freq = v4l2_get_link_freq(source->ctrl_handler, bpp, 2 * lanes);
> > > +	freq = v4l2_get_link_freq(remote_pad, bpp, 2 * lanes);
> > >  	if (freq < 0) {
> > >  		int ret = (int)freq;
> > >  

-- 
Regards,

Laurent Pinchart