linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benoit Parrot <bparrot@ti.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>, <linux-media@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [Patch 1/3] media: ov5640: add PIXEL_RATE control
Date: Tue, 1 Oct 2019 11:23:41 -0500	[thread overview]
Message-ID: <20191001162341.f2o7ruar2nifl5ws@ti.com> (raw)
In-Reply-To: <20191001075704.GA5449@paasikivi.fi.intel.com>

Hi Sakari,

Thanks for the review.

Sakari Ailus <sakari.ailus@linux.intel.com> wrote on Tue [2019-Oct-01 10:57:04 +0300]:
> Hi Benoit,
> 
> On Wed, Sep 25, 2019 at 10:22:59AM -0500, Benoit Parrot wrote:
> > Add v4l2 controls to report the pixel rates of each mode. This is
> > needed by some CSI2 receiver in order to perform proper DPHY
> > configuration.
> > 
> > Signed-off-by: Benoit Parrot <bparrot@ti.com>
> > ---
> >  drivers/media/i2c/ov5640.c | 25 +++++++++++++++++++++++++
> >  1 file changed, 25 insertions(+)
> > 
> > diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> > index 500d9bbff10b..c2a44f30d56e 100644
> > --- a/drivers/media/i2c/ov5640.c
> > +++ b/drivers/media/i2c/ov5640.c
> > @@ -193,6 +193,9 @@ struct ov5640_mode_info {
> >  
> >  struct ov5640_ctrls {
> >  	struct v4l2_ctrl_handler handler;
> > +	struct {
> > +		struct v4l2_ctrl *pixel_rate;
> > +	};
> >  	struct {
> >  		struct v4l2_ctrl *auto_exp;
> >  		struct v4l2_ctrl *exposure;
> > @@ -241,6 +244,7 @@ struct ov5640_dev {
> >  	const struct ov5640_mode_info *last_mode;
> >  	enum ov5640_frame_rate current_fr;
> >  	struct v4l2_fract frame_interval;
> > +	u64 pixel_rate;
> >  
> >  	struct ov5640_ctrls ctrls;
> >  
> > @@ -2202,6 +2206,7 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd,
> >  	const struct ov5640_mode_info *new_mode;
> >  	struct v4l2_mbus_framefmt *mbus_fmt = &format->format;
> >  	struct v4l2_mbus_framefmt *fmt;
> > +	u64 rate;
> >  	int ret;
> >  
> >  	if (format->pad != 0)
> > @@ -2233,6 +2238,12 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd,
> >  	if (mbus_fmt->code != sensor->fmt.code)
> >  		sensor->pending_fmt_change = true;
> >  
> > +	rate = sensor->current_mode->vtot * sensor->current_mode->htot;
> > +	rate *= ov5640_framerates[sensor->current_fr];
> > +	sensor->pixel_rate = rate;
> > +
> > +	__v4l2_ctrl_s_ctrl_int64(sensor->ctrls.pixel_rate,
> > +				 sensor->pixel_rate);
> >  out:
> >  	mutex_unlock(&sensor->lock);
> >  	return ret;
> > @@ -2657,6 +2668,13 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
> >  	/* we can use our own mutex for the ctrl lock */
> >  	hdl->lock = &sensor->lock;
> >  
> > +	/* Clock related controls */
> > +	ctrls->pixel_rate =
> > +		v4l2_ctrl_new_std(hdl, ops,
> > +				  V4L2_CID_PIXEL_RATE, 0, INT_MAX, 1,
> > +				  55969920);
> 
> Could you calculate this value instead of using a seemingly random number?

Yes I guess I could, especially if I make a helper function for it :).

> 
> > +	ctrls->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;
> > +
> >  	/* Auto/manual white balance */
> >  	ctrls->auto_wb = v4l2_ctrl_new_std(hdl, ops,
> >  					   V4L2_CID_AUTO_WHITE_BALANCE,
> > @@ -2782,6 +2800,7 @@ static int ov5640_s_frame_interval(struct v4l2_subdev *sd,
> >  	struct ov5640_dev *sensor = to_ov5640_dev(sd);
> >  	const struct ov5640_mode_info *mode;
> >  	int frame_rate, ret = 0;
> > +	u64 rate;
> >  
> >  	if (fi->pad != 0)
> >  		return -EINVAL;
> > @@ -2816,6 +2835,12 @@ static int ov5640_s_frame_interval(struct v4l2_subdev *sd,
> >  		sensor->frame_interval = fi->interval;
> >  		sensor->current_mode = mode;
> >  		sensor->pending_mode_change = true;
> > +
> > +		rate = sensor->current_mode->vtot * sensor->current_mode->htot;
> > +		rate *= ov5640_framerates[sensor->current_fr];
> > +		sensor->pixel_rate = rate;
> 
> I think it'd be better to have a function to calculate the value instead of
> duplicating the code here.

Yes I'll create a helper function.

Benoit

> 
> > +		__v4l2_ctrl_s_ctrl_int64(sensor->ctrls.pixel_rate,
> > +					 sensor->pixel_rate);
> >  	}
> >  out:
> >  	mutex_unlock(&sensor->lock);
> 
> -- 
> Kind regards,
> 
> Sakari Ailus
> sakari.ailus@linux.intel.com

  reply	other threads:[~2019-10-01 16:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-25 15:22 [Patch 0/3] media: ov5640: updates Benoit Parrot
2019-09-25 15:22 ` [Patch 1/3] media: ov5640: add PIXEL_RATE control Benoit Parrot
2019-10-01  7:57   ` Sakari Ailus
2019-10-01 16:23     ` Benoit Parrot [this message]
2019-10-02  7:59       ` Jacopo Mondi
2019-10-02 12:14         ` Benoit Parrot
2019-10-02 12:35           ` Sakari Ailus
2019-10-02 12:40             ` Benoit Parrot
2019-10-02 14:32           ` Jacopo Mondi
2019-10-02 15:06             ` Benoit Parrot
2019-10-03  6:55               ` Jacopo Mondi
2019-09-25 15:23 ` [Patch 2/3] media: ov5640: Fix 1920x1080 mode to remove extra enable/disable Benoit Parrot
2019-09-25 15:23 ` [Patch 3/3] media: ov5640: Make 2592x1944 mode only available at 15 fps Benoit Parrot

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=20191001162341.f2o7ruar2nifl5ws@ti.com \
    --to=bparrot@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.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 NNTP newsgroup(s).