linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sylwester Nawrocki <s.nawrocki@samsung.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>, linux-media@vger.kernel.org
Subject: Re: [PATCH RFC v3 2/6] v4l2-ctrl: Add helper function for control range update
Date: Thu, 14 Mar 2013 14:03:30 +0100	[thread overview]
Message-ID: <3327486.Mtsf9JCdgL@avalon> (raw)
In-Reply-To: <5141B6F6.7080909@samsung.com>

Hi Sylwester,

On Thursday 14 March 2013 12:39:34 Sylwester Nawrocki wrote:
> On 03/14/2013 08:10 AM, Hans Verkuil wrote:
> > On Tue March 12 2013 07:56:25 Hans Verkuil wrote:
> >> On Wed January 23 2013 23:21:57 Sylwester Nawrocki wrote:
> >>> This patch adds a helper function that allows to modify range,
> >>> i.e. minimum, maximum, step and default value of a v4l2 control,
> >>> after the control has been created and initialized. This is helpful
> >>> in situations when range of a control depends on user configurable
> >>> parameters, e.g. camera sensor absolute exposure time depending on
> >>> an output image resolution and frame rate.
> >>> 
> >>> v4l2_ctrl_modify_range() function allows to modify range of an
> >>> INTEGER, BOOL, MENU, INTEGER_MENU and BITMASK type controls.
> >>> 
> >>> Based on a patch from Hans Verkuil
> >>> http://patchwork.linuxtv.org/patch/8654.
> >>> 
> >>> Signed-off-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
> >>> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
> >> 
> >> I've been playing around with this a bit, using this vivi patch:
> >> 
> >> diff --git a/drivers/media/platform/vivi.c
> >> b/drivers/media/platform/vivi.c
> >> index c46d2e8..85bc314 100644
> >> --- a/drivers/media/platform/vivi.c
> >> +++ b/drivers/media/platform/vivi.c
> >> @@ -1093,6 +1093,15 @@ static int vidioc_s_input(struct file *file, void
> >> *priv, unsigned int i)>> 
> >>  		return 0;
> >>  	
> >>  	dev->input = i;
> >> 
> >> +	/*
> >> +	 * Modify the brightness range depending on the input.
> >> +	 * This makes it easy to use vivi to test if applications can
> >> +	 * handle control range modifications and is also how this is
> >> +	 * typically used in practice as different inputs may be hooked
> >> +	 * up to different receivers with different control ranges.
> >> +	 */
> >> +	v4l2_ctrl_modify_range(dev->brightness,
> >> +			128 * i, 255 + 128 * i, 1, 127 + 128 * i);
> >> 
> >>  	precalculate_bars(dev);
> >>  	precalculate_line(dev);
> >>  	return 0;
> >> 
> >> And it made me wonder if it wouldn't be more sensible if modify_range
> >> would also update the current value to the new default value?
> > 
> > Actually, thinking about it some more, I believe that modify_range should
> > actually include the new control value as argument. That way the caller
> > can decide what to do: use the current value (which then might be
> > clamped), use the default_value or use a remembered previous value.
> > 
> > If you agree with this, then I'll make a patch for it. I just need to know
> > what the only user of this call (ov9650.c) should do. I suspect it should
> > use the default value as the new value, but I'm not certain.
> 
> Sorry for the delay. I suppose if we choose either clamping the new value
> or setting it to the default value there will always be users that wanted
> other behaviour than currently implemented. In ov9650 case it seemed
> clamping the value of the exposure control to <min, max> when the image
> size changed a best option. Using the default value each time control's
> range changed would cause changes of the exposure time, even though current
> exposure value would still be inside of new range.
> Thus I think best option for ov9650 would be to use previous value of the
> control, which would then be clamped to <min, max>. This way changes of
> the exposure time caused by the output format change could be minimized.

I agree. If we don't make the new value configurable I would prefer clamping 
the current value. Adding an argument to the function is reasonable, but I 
don't know if we will have use cases for that. Maybe we can clamp the current 
value for now and add the argument if drivers need it in the future.

-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2013-03-14 13:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23 22:21 [PATCH RFC v3 0/6] OV9650/52 sensor driver and some v4l2 core additions Sylwester Nawrocki
2013-01-23 22:21 ` [PATCH RFC v3 1/6] [media] Add header file defining standard image sizes Sylwester Nawrocki
2013-01-23 22:21 ` [PATCH RFC v3 2/6] v4l2-ctrl: Add helper function for control range update Sylwester Nawrocki
2013-03-12  6:56   ` Hans Verkuil
2013-03-14  7:10     ` Hans Verkuil
2013-03-14 11:39       ` Sylwester Nawrocki
2013-03-14 13:03         ` Laurent Pinchart [this message]
2013-01-23 22:21 ` [PATCH RFC v3 3/6] V4L: Add v4l2_event_subdev_unsubscribe() helper function Sylwester Nawrocki
2013-01-23 22:21 ` [PATCH RFC v3 4/6] V4L: Add v4l2_ctrl_subdev_subscribe_event() " Sylwester Nawrocki
2013-01-23 22:22 ` [PATCH RFC v3 5/6] V4L: Add v4l2_ctrl_subdev_log_status() " Sylwester Nawrocki
2013-01-23 22:22 ` [PATCH RFC v3 6/6] V4L: Add driver for OV9650/52 image sensors Sylwester Nawrocki

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=3327486.Mtsf9JCdgL@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=s.nawrocki@samsung.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).