Linux-Media Archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 17/19] media: rcar-csi2: Store format in the subdev state
Date: Fri, 3 May 2024 01:00:00 +0300	[thread overview]
Message-ID: <20240502220000.GC4959@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20240502143232.GC3927860@ragnatech.se>

On Thu, May 02, 2024 at 04:32:32PM +0200, Niklas Söderlund wrote:
> Hi Jacpop,
> 
> Thanks for your work.
> 
> On 2024-04-30 12:39:53 +0200, Jacopo Mondi wrote:
> > Store the format in the subdevice state. Disallow setting format
> > on the source pads, as formats are set on the sink pad streams and
> > propagated to the source streams.
> > 
> > Now that the driver doesn't store the active format in the
> > driver-specific structure, also remove the mutex and use the lock
> > associated with the state.
> 
> Can't this whole patch be broken out to an independent patch and 
> upstreamed already independent from the streams work?

I think it's a good idea. We will need to move part of 15/19 here
(adding .init_state() and calling v4l2_subdev_init_finalize()).

> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > ---
> >  drivers/media/platform/renesas/rcar-csi2.c | 54 +++++++---------------
> >  1 file changed, 16 insertions(+), 38 deletions(-)
> > 
> > diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
> > index ffb73272543b..ed818a6fa655 100644
> > --- a/drivers/media/platform/renesas/rcar-csi2.c
> > +++ b/drivers/media/platform/renesas/rcar-csi2.c
> > @@ -621,8 +621,6 @@ struct rcar_csi2 {
> >  
> >  	int channel_vc[4];
> >  
> > -	struct mutex lock; /* Protects mf and stream_count. */
> > -	struct v4l2_mbus_framefmt mf;
> >  	int stream_count;
> >  
> >  	bool cphy;
> > @@ -1263,43 +1261,28 @@ static int rcsi2_s_stream(struct v4l2_subdev *sd, int enable)
> >  }
> >  
> >  static int rcsi2_set_pad_format(struct v4l2_subdev *sd,
> > -				struct v4l2_subdev_state *sd_state,
> > +				struct v4l2_subdev_state *state,
> >  				struct v4l2_subdev_format *format)
> >  {
> > -	struct rcar_csi2 *priv = sd_to_csi2(sd);
> > -	struct v4l2_mbus_framefmt *framefmt;
> > +	struct v4l2_mbus_framefmt *fmt;
> >  
> > -	mutex_lock(&priv->lock);
> > +	/*
> > +	 * Format is propagated from sink streams to source streams, so
> > +	 * disallow setting format on the source pads.
> > +	 */
> > +	if (format->pad > RCAR_CSI2_SINK)
> > +		return -EINVAL;

		return v4l2_subdev_get_fmt(sd, state, format);

> >  
> >  	if (!rcsi2_code_to_fmt(format->format.code))
> >  		format->format.code = rcar_csi2_formats[0].code;
> >  
> > -	if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
> > -		priv->mf = format->format;
> > -	} else {
> > -		framefmt = v4l2_subdev_state_get_format(sd_state, 0);
> > -		*framefmt = format->format;
> > -	}
> >  
> > -	mutex_unlock(&priv->lock);
> > +	fmt = v4l2_subdev_state_get_format(state, format->pad, format->stream);
> > +	*fmt = format->format;
> >  
> > -	return 0;
> > -}
> > -
> > -static int rcsi2_get_pad_format(struct v4l2_subdev *sd,
> > -				struct v4l2_subdev_state *sd_state,
> > -				struct v4l2_subdev_format *format)
> > -{
> > -	struct rcar_csi2 *priv = sd_to_csi2(sd);
> > -
> > -	mutex_lock(&priv->lock);
> > -
> > -	if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
> > -		format->format = priv->mf;
> > -	else
> > -		format->format = *v4l2_subdev_state_get_format(sd_state, 0);
> > -
> > -	mutex_unlock(&priv->lock);
> > +	fmt = v4l2_subdev_state_get_opposite_stream_format(state, format->pad,
> > +							   format->stream);
> > +	*fmt = format->format;
> >  
> >  	return 0;
> >  }
> > @@ -1310,7 +1293,7 @@ static const struct v4l2_subdev_video_ops rcar_csi2_video_ops = {
> >  
> >  static const struct v4l2_subdev_pad_ops rcar_csi2_pad_ops = {
> >  	.set_fmt = rcsi2_set_pad_format,
> > -	.get_fmt = rcsi2_get_pad_format,
> > +	.get_fmt = v4l2_subdev_get_fmt,
> >  };
> >  
> >  static const struct v4l2_subdev_ops rcar_csi2_subdev_ops = {
> > @@ -2031,20 +2014,19 @@ static int rcsi2_probe(struct platform_device *pdev)
> >  
> >  	priv->dev = &pdev->dev;
> >  
> > -	mutex_init(&priv->lock);
> >  	priv->stream_count = 0;
> >  
> >  	ret = rcsi2_probe_resources(priv, pdev);
> >  	if (ret) {
> >  		dev_err(priv->dev, "Failed to get resources\n");
> > -		goto error_mutex;
> > +		return ret;
> >  	}
> >  
> >  	platform_set_drvdata(pdev, priv);
> >  
> >  	ret = rcsi2_parse_dt(priv);
> >  	if (ret)
> > -		goto error_mutex;
> > +		return ret;
> >  
> >  	priv->subdev.owner = THIS_MODULE;
> >  	priv->subdev.dev = &pdev->dev;
> > @@ -2094,8 +2076,6 @@ static int rcsi2_probe(struct platform_device *pdev)
> >  error_async:
> >  	v4l2_async_nf_unregister(&priv->notifier);
> >  	v4l2_async_nf_cleanup(&priv->notifier);
> > -error_mutex:
> > -	mutex_destroy(&priv->lock);
> >  
> >  	return ret;
> >  }
> > @@ -2110,8 +2090,6 @@ static void rcsi2_remove(struct platform_device *pdev)
> >  	v4l2_subdev_cleanup(&priv->subdev);
> >  
> >  	pm_runtime_disable(&pdev->dev);
> > -
> > -	mutex_destroy(&priv->lock);
> >  }
> >  
> >  static struct platform_driver rcar_csi2_pdrv = {

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2024-05-02 22:00 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 10:39 [PATCH 00/19] media: renesas: rcar-csi2: Support multiple streams Jacopo Mondi
2024-04-30 10:39 ` [PATCH 01/19] media: adv748x: Add support for active state Jacopo Mondi
2024-05-02 17:34   ` Laurent Pinchart
2024-05-03  7:55     ` Jacopo Mondi
2024-05-03  8:24       ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 02/19] media: adv748x: Add flags to adv748x_subdev_init() Jacopo Mondi
2024-05-02 17:37   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 03/19] media: adv748x: Use V4L2 streams Jacopo Mondi
2024-05-02 17:40   ` Laurent Pinchart
2024-05-03  7:59     ` Jacopo Mondi
2024-05-03  8:31       ` Laurent Pinchart
2024-05-03  8:46         ` Tomi Valkeinen
2024-04-30 10:39 ` [PATCH 04/19] media: adv748x: Propagate format to opposite stream Jacopo Mondi
2024-05-02 17:41   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 05/19] media: adv748x: Implement set_routing() Jacopo Mondi
2024-05-02 17:49   ` Laurent Pinchart
2024-05-03  8:02     ` Jacopo Mondi
2024-04-30 10:39 ` [PATCH 06/19] media: adv748x: Use routes to configure VC Jacopo Mondi
2024-05-02 17:51   ` Laurent Pinchart
2024-05-02 17:52     ` Laurent Pinchart
2024-05-03  8:05       ` Jacopo Mondi
2024-04-30 10:39 ` [PATCH 07/19] media: adv748x: Implement .get_frame_desc() Jacopo Mondi
2024-05-02 17:57   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 08/19] media: max9286: Add support for subdev active state Jacopo Mondi
2024-05-02 18:10   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 09/19] media: max9286: Fix enum_mbus_code Jacopo Mondi
2024-05-02 18:14   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 10/19] media: max9286: Use frame interval from subdev state Jacopo Mondi
2024-05-02 18:23   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 11/19] media: max9286: Use V4L2 Streams Jacopo Mondi
2024-05-02 18:25   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 12/19] media: max9286: Implement .get_frame_desc() Jacopo Mondi
2024-05-02 18:32   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 13/19] media: max9286: Implement support for LINK_FREQ Jacopo Mondi
2024-05-02 18:36   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 14/19] media: max9286: Implement .get_mbus_config() Jacopo Mondi
2024-05-02 18:37   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 15/19] media: rcar-csi2: Add support for multiplexed streams Jacopo Mondi
2024-05-02 14:23   ` Niklas Söderlund
2024-05-02 18:41     ` Laurent Pinchart
2024-05-03  8:05       ` Jacopo Mondi
2024-04-30 10:39 ` [PATCH 16/19] media: rcar-csi2: Support multiplexed transmitters Jacopo Mondi
2024-05-02 14:30   ` Niklas Söderlund
2024-05-02 21:56     ` Laurent Pinchart
2024-05-03  8:07       ` Jacopo Mondi
2024-04-30 10:39 ` [PATCH 17/19] media: rcar-csi2: Store format in the subdev state Jacopo Mondi
2024-05-02 14:32   ` Niklas Söderlund
2024-05-02 22:00     ` Laurent Pinchart [this message]
2024-04-30 10:39 ` [PATCH 18/19] media: rcar-csi2: Implement set_routing Jacopo Mondi
2024-05-02 22:16   ` Laurent Pinchart
2024-04-30 10:39 ` [PATCH 19/19] media: rcar-vin: Fix YUYV8_1X16 handling for CSI-2 Jacopo Mondi
2024-05-02 14:33   ` Niklas Söderlund
2024-05-02 22:16     ` Laurent Pinchart
2024-04-30 11:17 ` [PATCH 00/19] media: renesas: rcar-csi2: Support multiple streams Niklas Söderlund
2024-04-30 11:51   ` Jacopo Mondi
2024-05-02 17:35     ` Laurent Pinchart

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=20240502220000.GC4959@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomi.valkeinen@ideasonboard.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).