All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCHv2 2/9] media: convert g/s_parm to g/s_frame_interval in subdevs
Date: Wed, 14 Feb 2018 15:30:41 -0200	[thread overview]
Message-ID: <20180214153041.6bd2d86a@vento.lan> (raw)
In-Reply-To: <d164e24c-ca5d-90ee-c396-12d373c78cd6@xs4all.nl>

Em Wed, 14 Feb 2018 18:16:55 +0100
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 14/02/18 18:02, Mauro Carvalho Chehab wrote:
> > Em Wed, 14 Feb 2018 17:34:17 +0100
> > Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> >   
> >> On 14/02/18 17:03, Mauro Carvalho Chehab wrote:  
> >>> Em Mon, 22 Jan 2018 13:31:18 +0100
> >>> Hans Verkuil <hverkuil@xs4all.nl> escreveu:
> >>>     
> >>>> From: Hans Verkuil <hans.verkuil@cisco.com>
> >>>>
> >>>> Convert all g/s_parm calls to g/s_frame_interval. This allows us
> >>>> to remove the g/s_parm ops since those are a duplicate of
> >>>> g/s_frame_interval.
> >>>>
> >>>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> >>>> ---
> >>>>  drivers/media/i2c/mt9v011.c                     | 31 +++++++-------------
> >>>>  drivers/media/i2c/ov6650.c                      | 35 +++++++++-------------
> >>>>  drivers/media/i2c/ov7670.c                      | 24 +++++++--------
> >>>>  drivers/media/i2c/ov7740.c                      | 31 +++++++-------------
> >>>>  drivers/media/i2c/tvp514x.c                     | 39 +++++++++----------------
> >>>>  drivers/media/i2c/vs6624.c                      | 29 +++++++-----------
> >>>>  drivers/media/platform/atmel/atmel-isc.c        | 10 ++-----
> >>>>  drivers/media/platform/atmel/atmel-isi.c        | 12 ++------
> >>>>  drivers/media/platform/blackfin/bfin_capture.c  | 14 +++------
> >>>>  drivers/media/platform/marvell-ccic/mcam-core.c | 12 ++++----
> >>>>  drivers/media/platform/soc_camera/soc_camera.c  | 10 ++++---
> >>>>  drivers/media/platform/via-camera.c             |  4 +--
> >>>>  drivers/media/usb/em28xx/em28xx-video.c         | 36 +++++++++++++++++++----
> >>>>  13 files changed, 122 insertions(+), 165 deletions(-)
> >>>>
> >>>> diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c
> >>>> index 5e29064fae91..3e23c5b0de1f 100644
> >>>> --- a/drivers/media/i2c/mt9v011.c
> >>>> +++ b/drivers/media/i2c/mt9v011.c
> >>>> @@ -364,33 +364,24 @@ static int mt9v011_set_fmt(struct v4l2_subdev *sd,
> >>>>  	return 0;
> >>>>  }
> >>>>  
> >>>> -static int mt9v011_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
> >>>> +static int mt9v011_g_frame_interval(struct v4l2_subdev *sd,
> >>>> +				    struct v4l2_subdev_frame_interval *ival)
> >>>>  {
> >>>> -	struct v4l2_captureparm *cp = &parms->parm.capture;
> >>>> -
> >>>> -	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> >>>> -		return -EINVAL;
> >>>> -
> >>>> -	memset(cp, 0, sizeof(struct v4l2_captureparm));
> >>>> -	cp->capability = V4L2_CAP_TIMEPERFRAME;
> >>>> +	memset(ival->reserved, 0, sizeof(ival->reserved));    
> >>>
> >>> Hmm.. why to repeat memset everywhere? If the hole idea is to stop abusing,
> >>> the best would be to do, instead:    
> >>
> >> g_frame_interval is called by bridge drivers through the subdev ops. So that
> >> path doesn't go through subdev_do_ioctl(). So it doesn't help putting it in
> >> v4l2-subdev.c.  
> > 
> > True, but you could also do the same for v4l2 ioctl() handling logic.
> > 
> > That would mean just two places with memset() instead of repeating the same
> > pattern everywhere.
> >   
> >> That doesn't mean it shouldn't be there as well. I believe my MC patch series
> >> actually adds the memset in subdev_do_ioctl.  
> 
> What could be done is that this patch https://patchwork.linuxtv.org/patch/46955/
> is applied first. After that these memsets can be removed since internally we
> don't need to touch them.

Works for me.

> >>  
> >>>
> >>> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> >>> index c5639817db34..b18b418c080f 100644
> >>> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> >>> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> >>> @@ -350,6 +350,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> >>>  		if (fi->pad >= sd->entity.num_pads)
> >>>  			return -EINVAL;
> >>>  
> >>> +		memset(fi->reserved, 0, sizeof(ival->reserved));
> >>>  		return v4l2_subdev_call(sd, video, g_frame_interval, arg);
> >>>  	}
> >>>  
> >>> (same applies to s_frame_interval).
> >>>
> >>>     
> >>>>  	calc_fps(sd,
> >>>> -		 &cp->timeperframe.numerator,
> >>>> -		 &cp->timeperframe.denominator);
> >>>> +		 &ival->interval.numerator,
> >>>> +		 &ival->interval.denominator);
> >>>>  
> >>>>  	return 0;
> >>>>  }
> >>>>  
> >>>> -static int mt9v011_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
> >>>> +static int mt9v011_s_frame_interval(struct v4l2_subdev *sd,
> >>>> +				    struct v4l2_subdev_frame_interval *ival)
> >>>>  {
> >>>> -	struct v4l2_captureparm *cp = &parms->parm.capture;
> >>>> -	struct v4l2_fract *tpf = &cp->timeperframe;
> >>>> +	struct v4l2_fract *tpf = &ival->interval;
> >>>>  	u16 speed;
> >>>>  
> >>>> -	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> >>>> -		return -EINVAL;
> >>>> -	if (cp->extendedmode != 0)
> >>>> -		return -EINVAL;
> >>>> -    
> >>>
> >>> Hmm... why are you removing those sanity checks everywhere?
> >>> The core doesn't do it.
> >>>
> >>> All the above comments also apply to the other files modified by
> >>> this patch.    
> >>
> >> struct v4l2_subdev_frame_interval has neither type nor extendedmode.
> >>
> >> The check for type is done in the v4l2_g/s_parm_cap helpers instead.  
> > 
> > Well, the subdev handler at v4l2-subdev.c doesn't seem to be checking it.  
> 
> ????
> 
> Are you confusing struct v4l2_streamparm with struct v4l2_subdev_frame_interval?
> 
> v4l2_subdev.c deals with the latter, and struct v4l2_subdev_frame_interval has
> no type field. There is nothing to check.
> 
> 'type' makes no sense in subdev drivers anyway since it refers to a buffer type
> and subdevs do not deal with buffers.

Yeah, you're right: those checks can be removed.

> >> And extendedmode is always set to 0.
> >>  
> >>>     
> >>>> +	memset(ival->reserved, 0, sizeof(ival->reserved));
> >>>>  	speed = calc_speed(sd, tpf->numerator, tpf->denominator);
> >>>>  
> >>>>  	mt9v011_write(sd, R0A_MT9V011_CLK_SPEED, speed);
> >>>> @@ -469,8 +460,8 @@ static const struct v4l2_subdev_core_ops mt9v011_core_ops = {
> >>>>  };
> >>>>  
> >>>>  static const struct v4l2_subdev_video_ops mt9v011_video_ops = {
> >>>> -	.g_parm = mt9v011_g_parm,
> >>>> -	.s_parm = mt9v011_s_parm,
> >>>> +	.g_frame_interval = mt9v011_g_frame_interval,
> >>>> +	.s_frame_interval = mt9v011_s_frame_interval,
> >>>>  };
> >>>>  
> >>>>  static const struct v4l2_subdev_pad_ops mt9v011_pad_ops = {
> >>>> diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
> >>>> index 8975d16b2b24..3f962dae7534 100644
> >>>> --- a/drivers/media/i2c/ov6650.c
> >>>> +++ b/drivers/media/i2c/ov6650.c
> >>>> @@ -201,7 +201,7 @@ struct ov6650 {
> >>>>  	struct v4l2_rect	rect;		/* sensor cropping window */
> >>>>  	unsigned long		pclk_limit;	/* from host */
> >>>>  	unsigned long		pclk_max;	/* from resolution and format */
> >>>> -	struct v4l2_fract	tpf;		/* as requested with s_parm */
> >>>> +	struct v4l2_fract	tpf;		/* as requested with s_frame_interval */
> >>>>  	u32 code;
> >>>>  	enum v4l2_colorspace	colorspace;
> >>>>  };
> >>>> @@ -723,42 +723,33 @@ static int ov6650_enum_mbus_code(struct v4l2_subdev *sd,
> >>>>  	return 0;
> >>>>  }
> >>>>  
> >>>> -static int ov6650_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
> >>>> +static int ov6650_g_frame_interval(struct v4l2_subdev *sd,
> >>>> +				   struct v4l2_subdev_frame_interval *ival)
> >>>>  {
> >>>>  	struct i2c_client *client = v4l2_get_subdevdata(sd);
> >>>>  	struct ov6650 *priv = to_ov6650(client);
> >>>> -	struct v4l2_captureparm *cp = &parms->parm.capture;
> >>>>  
> >>>> -	if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> >>>> -		return -EINVAL;
> >>>> -
> >>>> -	memset(cp, 0, sizeof(*cp));
> >>>> -	cp->capability = V4L2_CAP_TIMEPERFRAME;
> >>>> -	cp->timeperframe.numerator = GET_CLKRC_DIV(to_clkrc(&priv->tpf,
> >>>> +	memset(ival->reserved, 0, sizeof(ival->reserved));
> >>>> +	ival->interval.numerator = GET_CLKRC_DIV(to_clkrc(&priv->tpf,
> >>>>  			priv->pclk_limit, priv->pclk_max));
> >>>> -	cp->timeperframe.denominator = FRAME_RATE_MAX;
> >>>> +	ival->interval.denominator = FRAME_RATE_MAX;
> >>>>  
> >>>>  	dev_dbg(&client->dev, "Frame interval: %u/%u s\n",
> >>>> -		cp->timeperframe.numerator, cp->timeperframe.denominator);
> >>>> +		ival->interval.numerator, ival->interval.denominator);    
> >>>
> >>> Hmm... not sure if a debug is needed here. Yet, if this is needed, 
> >>> IMHO, it would make mroe sense to move it to the core.    
> >>
> >> The core doesn't see this if this subdev op is called from a bridge driver.  
> > 
> > True, but, when calling via a bridge driver, there's already a way to
> > enable such kind debug.  
> 
> It can debug VIDIOC_G/S_PARM, not the g_frame_interval op. Also, when called
> via a v4l-subdev device node there is currently NO core logging.
> 
> For the record, I don't really care about this debug statement myself one
> way or another, but changing this one way or another doesn't belong in this
> patch series.

Ok. Yet, IMHO, it is probably safe to just remove the debug statements
on the above driver, as I fail to see that just ov6650 driver would
need this.

> 
> Regards,
> 
> 	Hans



Thanks,
Mauro

  reply	other threads:[~2018-02-14 17:30 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 12:31 [PATCHv2 0/9] media: replace g/s_parm by g/s_frame_interval Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 1/9] v4l2-common: create v4l2_g/s_parm_cap helpers Hans Verkuil
2018-02-14 15:50   ` Mauro Carvalho Chehab
2018-02-14 16:23     ` Hans Verkuil
2018-02-14 16:35       ` Mauro Carvalho Chehab
2018-02-14 16:47         ` Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 2/9] media: convert g/s_parm to g/s_frame_interval in subdevs Hans Verkuil
2018-01-23 14:47   ` jacopo mondi
2018-01-23 14:52     ` Hans Verkuil
2018-02-14 16:03   ` Mauro Carvalho Chehab
2018-02-14 16:34     ` Hans Verkuil
2018-02-14 17:02       ` Mauro Carvalho Chehab
2018-02-14 17:16         ` Hans Verkuil
2018-02-14 17:30           ` Mauro Carvalho Chehab [this message]
2018-01-22 12:31 ` [PATCHv2 3/9] staging: atomisp: Kill subdev s_parm abuse Hans Verkuil
2018-02-14 16:14   ` Mauro Carvalho Chehab
2018-02-16  9:04     ` Sakari Ailus
2018-02-16 11:58       ` Mauro Carvalho Chehab
2018-02-19 11:01         ` Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 4/9] staging: atomisp: i2c: Disable non-preview configurations Hans Verkuil
2018-02-14 16:20   ` Mauro Carvalho Chehab
2018-02-16 10:12     ` Sakari Ailus
2018-02-16 12:04       ` Mauro Carvalho Chehab
2018-02-19 12:24         ` Sakari Ailus
2018-02-19 13:27   ` [PATCH v2.1 " Sakari Ailus
2018-02-19 13:30     ` Hans Verkuil
2018-02-19 13:48       ` Sakari Ailus
2018-02-19 13:58         ` Hans Verkuil
2018-02-19 14:05           ` Sakari Ailus
2018-01-22 12:31 ` [PATCHv2 5/9] staging: atomisp: i2c: Drop g_parm support in sensor drivers Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 6/9] staging: atomisp: mt9m114: Drop empty s_parm callback Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 7/9] staging: atomisp: Drop g_parm and s_parm subdev ops use Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 8/9] v4l2-subdev.h: remove obsolete g/s_parm Hans Verkuil
2018-01-22 12:31 ` [PATCHv2 9/9] vidioc-g-parm.rst: also allow _MPLANE buffer types Hans Verkuil
2018-01-22 12:38 ` [PATCHv2 0/9] media: replace g/s_parm by g/s_frame_interval Sakari Ailus

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=20180214153041.6bd2d86a@vento.lan \
    --to=mchehab@s-opensource.com \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jacopo+renesas@jmondi.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.