[PATCH 2/5] media/i2c: max96717: implement the .get_frame_desc() operation

Laurentiu Palcu posted 5 patches 1 year ago
[PATCH 2/5] media/i2c: max96717: implement the .get_frame_desc() operation
Posted by Laurentiu Palcu 1 year ago
Since the max96717 serializer can work with various sensors, we need to
implement the .get_frame_desc() callback to get the VCs and DTs for the
incoming stream(s).

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
---
 drivers/media/i2c/max96717.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/media/i2c/max96717.c b/drivers/media/i2c/max96717.c
index b1116aade0687..6a668a004c717 100644
--- a/drivers/media/i2c/max96717.c
+++ b/drivers/media/i2c/max96717.c
@@ -575,12 +575,33 @@ static int max96717_disable_streams(struct v4l2_subdev *sd,
 	return 0;
 }
 
+static int max96717_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
+				   struct v4l2_mbus_frame_desc *fd)
+{
+	struct max96717_priv *priv = sd_to_max96717(sd);
+	int ret;
+	struct v4l2_mbus_frame_desc source_fd;
+
+	if (pad != MAX96717_PAD_SOURCE)
+		return -EINVAL;
+
+	ret = v4l2_subdev_call(priv->source_sd, pad, get_frame_desc,
+			       priv->source_sd_pad, &source_fd);
+	if (ret)
+		return ret;
+
+	*fd = source_fd;
+
+	return 0;
+}
+
 static const struct v4l2_subdev_pad_ops max96717_pad_ops = {
 	.enable_streams = max96717_enable_streams,
 	.disable_streams = max96717_disable_streams,
 	.set_routing = max96717_set_routing,
 	.get_fmt = v4l2_subdev_get_fmt,
 	.set_fmt = max96717_set_fmt,
+	.get_frame_desc = max96717_get_frame_desc,
 };
 
 static const struct v4l2_subdev_core_ops max96717_subdev_core_ops = {
-- 
2.34.1
Re: [PATCH 2/5] media/i2c: max96717: implement the .get_frame_desc() operation
Posted by Julien Massot 11 months, 3 weeks ago
Hi,

On Fri, 2025-02-07 at 13:29 +0200, Laurentiu Palcu wrote:
> Since the max96717 serializer can work with various sensors, we need to
> implement the .get_frame_desc() callback to get the VCs and DTs for the
> incoming stream(s).
> 
> Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
> ---
>  drivers/media/i2c/max96717.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/media/i2c/max96717.c b/drivers/media/i2c/max96717.c
> index b1116aade0687..6a668a004c717 100644
> --- a/drivers/media/i2c/max96717.c
> +++ b/drivers/media/i2c/max96717.c
> @@ -575,12 +575,33 @@ static int max96717_disable_streams(struct v4l2_subdev *sd,
>  	return 0;
>  }
>  
> +static int max96717_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
> +				   struct v4l2_mbus_frame_desc *fd)
> +{
> +	struct max96717_priv *priv = sd_to_max96717(sd);
> +	int ret;
> +	struct v4l2_mbus_frame_desc source_fd;
> +
> +	if (pad != MAX96717_PAD_SOURCE)
> +		return -EINVAL;
> +
Please check priv->source_sd first, we support the case where we only have a test pattern from
the serializer. Then we can simply return the result of v4l2_subdev_call.

        return v4l2_subdev_call(priv->source_sd, pad, get_frame_desc,
			       priv->source_sd_pad, fd);

> +	ret = v4l2_subdev_call(priv->source_sd, pad, get_frame_desc,
> +			       priv->source_sd_pad, &source_fd);
> +	if (ret)
> +		return ret;
> +
> +	*fd = source_fd;
> +
> +	return 0;
> +}
> +
>  static const struct v4l2_subdev_pad_ops max96717_pad_ops = {
>  	.enable_streams = max96717_enable_streams,
>  	.disable_streams = max96717_disable_streams,
>  	.set_routing = max96717_set_routing,
>  	.get_fmt = v4l2_subdev_get_fmt,
>  	.set_fmt = max96717_set_fmt,
> +	.get_frame_desc = max96717_get_frame_desc,
>  };
>  
>  static const struct v4l2_subdev_core_ops max96717_subdev_core_ops = {

Regards,
-- 
Julien
Re: [PATCH 2/5] media/i2c: max96717: implement the .get_frame_desc() operation
Posted by Laurentiu Palcu 11 months, 1 week ago
Hi,

On Tue, Feb 18, 2025 at 02:29:30PM +0100, Julien Massot wrote:
> Hi,
> 
> On Fri, 2025-02-07 at 13:29 +0200, Laurentiu Palcu wrote:
> > Since the max96717 serializer can work with various sensors, we need to
> > implement the .get_frame_desc() callback to get the VCs and DTs for the
> > incoming stream(s).
> > 
> > Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
> > ---
> >  drivers/media/i2c/max96717.c | 21 +++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> > 
> > diff --git a/drivers/media/i2c/max96717.c b/drivers/media/i2c/max96717.c
> > index b1116aade0687..6a668a004c717 100644
> > --- a/drivers/media/i2c/max96717.c
> > +++ b/drivers/media/i2c/max96717.c
> > @@ -575,12 +575,33 @@ static int max96717_disable_streams(struct v4l2_subdev *sd,
> >  	return 0;
> >  }
> >  
> > +static int max96717_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
> > +				   struct v4l2_mbus_frame_desc *fd)
> > +{
> > +	struct max96717_priv *priv = sd_to_max96717(sd);
> > +	int ret;
> > +	struct v4l2_mbus_frame_desc source_fd;
> > +
> > +	if (pad != MAX96717_PAD_SOURCE)
> > +		return -EINVAL;
> > +
> Please check priv->source_sd first, we support the case where we only have a test pattern from
> the serializer. Then we can simply return the result of v4l2_subdev_call.
> 
>         return v4l2_subdev_call(priv->source_sd, pad, get_frame_desc,
> 			       priv->source_sd_pad, fd);

Ok, I guess I missed the test pattern functionality completely.

Thanks,
Laurentiu

> 
> > +	ret = v4l2_subdev_call(priv->source_sd, pad, get_frame_desc,
> > +			       priv->source_sd_pad, &source_fd);
> > +	if (ret)
> > +		return ret;
> > +
> > +	*fd = source_fd;
> > +
> > +	return 0;
> > +}
> > +
> >  static const struct v4l2_subdev_pad_ops max96717_pad_ops = {
> >  	.enable_streams = max96717_enable_streams,
> >  	.disable_streams = max96717_disable_streams,
> >  	.set_routing = max96717_set_routing,
> >  	.get_fmt = v4l2_subdev_get_fmt,
> >  	.set_fmt = max96717_set_fmt,
> > +	.get_frame_desc = max96717_get_frame_desc,
> >  };
> >  
> >  static const struct v4l2_subdev_core_ops max96717_subdev_core_ops = {
> 
> Regards,
> -- 
> Julien