Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-05-13 Thread Pavel Machek
Hi!

> > > Nevertheless, V4L2_CID_FOCUS_ABSOLUTE
> > > is documented as follows (emphasis mine):
> > > 
> > >   This control sets the *focal point* of the camera to the specified
> > >   position. The unit is undefined. Positive values set the focus
> > >   closer to the camera, negative values towards infinity.
> > > 
> > > What you control in voice coil devices is current (in Ampères) and the
> > > current only has a relatively loose relation to the focal point.
> > 
> > The real problem I'm seeing here is that this control is already
> > used by voice coil motor (VCM). Several UVC-based Logitech cameras
> > come with VCM, like their QuickCam Pro-series webcams:
> > 
> > https://secure.logitech.com/en-hk/articles/3231
> > 
> > The voice coil can be seen on this picture:
> > 
> > https://photo.stackexchange.com/questions/48678/can-i-modify-a-logitech-c615-webcam-for-infinity-focus
> 
> There may be voice coil lens implementations that are indirectly controlled
> through this control. Those are hardware solutions that have been taken in
> UVC webcams, for instance. The UVC standard itself uses millimeters.
> 
> Lens systems based on voice coils generally cannot focus at a given exact
> distance for they have no concept of focussing at a particular distance.
> Instead, an auto focus algorithm analyses the image data (or statistics of
> image data) to control the lens --- in other words, to set current, not
> distance.

Well, you are right that voice coil does not focus on _exact_
distance. I guess nothing ever focuses on _exact_ distance ;-). (Ok,
voice coils may be worse then other systems.)

> As the auto focus algorithms require both image data (or statistics) and
> access to lens voice coil as well as for algorithmic complexity, they are
> typically implemented in user space.
> 
> In other words, the VOICE_COIL_CURRENT control is thus used by user space to
> implement what the user expects from FOCUS_AUTO control. It could be
> implemented in libv4l2 or a different user space component.
> VOICE_COIL_CURRENT control is not a control which is expected to be used by
> an end user application --- unlike FOCUS_AUTO.

End user application definitely _wants_ to control voice coil control
directly. Original Maemo application has landscape-mode, which
presumably just sets control to infinity. FCam application has full
manual focus. I'm writing SDLcam, it also has manual focus.

N900 camera has depth of field of 2 diopters. That means you can have
everything from 0.5m to infinity in focus... At normal range manual
focus makes a lot of sense. At macro range, yes, autofocus is needed.

Applications want to know focus in diopters... user wants to
know. Even when autofocus is active, it is good to know where the
camera is focused to monitor its progress.

> Additionally, there will be controls related to ringing compensation. The
> user (for an auto focus algorithm) still might want to disable the hardware
> ringing compensation so a menu control would be needed for the purpose.
> That's something that can well be addressed later on, just FYI.

Well, I don't see why we can't add ringing compensation controls to
the FOCUS_ABSOLUTE. Yes, userspace should know that it is the voice
coil. But userspace should be also able to get/set approximate focus
distance (diopters).

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-05-12 Thread Sakari Ailus
Hi Mauro,

On Wed, Apr 19, 2017 at 10:51:18AM -0300, Mauro Carvalho Chehab wrote:
> Em Sun, 16 Apr 2017 12:12:10 +0300
> Sakari Ailus  escreveu:
> 
> > Hi Mauro,
> > 
> > On Fri, Apr 14, 2017 at 11:23:32PM -0300, Mauro Carvalho Chehab wrote:
> > > Hi Sakari,
> > > 
> > > Em Tue, 14 Feb 2017 14:20:22 +0200
> > > Sakari Ailus  escreveu:
> > >   
> > > > Add a V4L2 control class for voice coil lens driver devices. These are
> > > > simple devices that are used to move a camera lens from its resting
> > > > position.  
> > > 
> > > From some past threads with this patch, you mentioned that:
> > > 
> > > "The FOCUS_ABSOLUTE control really is not a best control ID to
> > >  control a voice coil driver's current."
> > > 
> > > However, I'm not seeing any explanation there at the thread, at
> > > the patch description or at the documentation explaining why, and,
> > > more important, when someone should use the focus control or the
> > > camera voice coil control.  
> > 
> > It should be available in the thread.
> 
> The email thread is not registered at git logs nor at the API spec.
> 
> > Nevertheless, V4L2_CID_FOCUS_ABSOLUTE
> > is documented as follows (emphasis mine):
> > 
> > This control sets the *focal point* of the camera to the specified
> > position. The unit is undefined. Positive values set the focus
> > closer to the camera, negative values towards infinity.
> > 
> > What you control in voice coil devices is current (in Ampères) and the
> > current only has a relatively loose relation to the focal point.
> 
> The real problem I'm seeing here is that this control is already
> used by voice coil motor (VCM). Several UVC-based Logitech cameras
> come with VCM, like their QuickCam Pro-series webcams:
> 
>   https://secure.logitech.com/en-hk/articles/3231
> 
> The voice coil can be seen on this picture:
>   
> https://photo.stackexchange.com/questions/48678/can-i-modify-a-logitech-c615-webcam-for-infinity-focus

There may be voice coil lens implementations that are indirectly controlled
through this control. Those are hardware solutions that have been taken in
UVC webcams, for instance. The UVC standard itself uses millimeters.

Lens systems based on voice coils generally cannot focus at a given exact
distance for they have no concept of focussing at a particular distance.
Instead, an auto focus algorithm analyses the image data (or statistics of
image data) to control the lens --- in other words, to set current, not
distance.

As the auto focus algorithms require both image data (or statistics) and
access to lens voice coil as well as for algorithmic complexity, they are
typically implemented in user space.

In other words, the VOICE_COIL_CURRENT control is thus used by user space to
implement what the user expects from FOCUS_AUTO control. It could be
implemented in libv4l2 or a different user space component.
VOICE_COIL_CURRENT control is not a control which is expected to be used by
an end user application --- unlike FOCUS_AUTO.

This camera module datasheet shows the dependency between current and lens
position. See "Performance Diagram" on page 16:



As you can see, lens position may start changing by applying a current
between 14 and 34 mA, but exactly how much is specific to a given camera
module unit. This means that there is no direct mapping between the current
and the focus distance.

Ringing compensation is another matter. Voice coils do ring unless it is
compensated, something that the user of a control focussing at a particular
distance expects. See the diagram on page 13:



Do note that even this is not uniform with systems with the dw9714 lens
controller: the properties depend on the lens spring spring constant and the
weight of the moving lens package, for instance.

For these reasons I do think that this warrants having a specific control
for such devices.

Additionally, there will be controls related to ringing compensation. The
user (for an auto focus algorithm) still might want to disable the hardware
ringing compensation so a menu control would be needed for the purpose.
That's something that can well be addressed later on, just FYI.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk


Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-04-28 Thread Mauro Carvalho Chehab
Em Sat, 29 Apr 2017 00:00:05 +0200
Pavel Machek  escreveu:

> Hi!
> 
> > Hmm... if the idea is to have a control that doesn't do ringing
> > compensation, then it should be clear at the control's descriptions
> > that:
> > 
> > - V4L2_CID_FOCUS_ABSOLUTE should be used if the VCM has ringing
> >   compensation;
> > - V4L2_CID_VOICE_COIL_CURRENT and V4L2_CID_VOICE_COIL_RING_COMPENSATION
> >   should be used otherwise.
> > 
> > Btw, if the rationale for this patch is to support devices without
> > ring compensation, so, both controls and their descriptions should
> > be added at the same time, together with a patchset that would be
> > using both.
> >   
> > > How about adding such an explanation added to the commit message?  
> > 
> > It is not enough. Documentation should be clear that VCM devices
> > with ring compensation should use V4L2_CID_FOCUS_ABSOLUTE.  
> 
> Is ring compensation actually a big deal? We do not publish enough
> information to userland about how fast the autofocus system is,
> anyway, so it looks like userland can't depend on such details...

Well, I guess a V4L2 event could be used to identify the VCM's
current position and/or notify when the movement finished.

Anyway, the point is:

If V4L2_CID_VOICE_COIL_CURRENT would do the same as:
V4L2_CID_FOCUS_ABSOLUTE
or:
max - V4L2_CID_FOCUS_ABSOLUTE

there's no reason to create a new control, as the existing control
was already created to control the VCM current [1].

[1] Ok, we need to better document it, but that's a separate issue

We should create a new control only if it is doing something
different than the "standard" way of controlling a Voice Coil Motor.

On such case, the difference between controlling VCM via
V4L2_CID_VOICE_COIL_CURRENT or via V4L2_CID_FOCUS_ABSOLUTE should be 
clearly stated, as we expect that the other devices with the same need 
will implement the same control set and the same max/min convention
(e. g. max integer value meaning closest focus, min integer value
meaning infinite).

Thanks,
Mauro


Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-04-28 Thread Pavel Machek
Hi!

> Hmm... if the idea is to have a control that doesn't do ringing
> compensation, then it should be clear at the control's descriptions
> that:
> 
> - V4L2_CID_FOCUS_ABSOLUTE should be used if the VCM has ringing
>   compensation;
> - V4L2_CID_VOICE_COIL_CURRENT and V4L2_CID_VOICE_COIL_RING_COMPENSATION
>   should be used otherwise.
> 
> Btw, if the rationale for this patch is to support devices without
> ring compensation, so, both controls and their descriptions should
> be added at the same time, together with a patchset that would be
> using both.
> 
> > How about adding such an explanation added to the commit message?
> 
> It is not enough. Documentation should be clear that VCM devices
> with ring compensation should use V4L2_CID_FOCUS_ABSOLUTE.

Is ring compensation actually a big deal? We do not publish enough
information to userland about how fast the autofocus system is,
anyway, so it looks like userland can't depend on such details...
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-04-19 Thread Mauro Carvalho Chehab
Em Sun, 16 Apr 2017 12:12:10 +0300
Sakari Ailus  escreveu:

> Hi Mauro,
> 
> On Fri, Apr 14, 2017 at 11:23:32PM -0300, Mauro Carvalho Chehab wrote:
> > Hi Sakari,
> > 
> > Em Tue, 14 Feb 2017 14:20:22 +0200
> > Sakari Ailus  escreveu:
> >   
> > > Add a V4L2 control class for voice coil lens driver devices. These are
> > > simple devices that are used to move a camera lens from its resting
> > > position.  
> > 
> > From some past threads with this patch, you mentioned that:
> > 
> > "The FOCUS_ABSOLUTE control really is not a best control ID to
> >  control a voice coil driver's current."
> > 
> > However, I'm not seeing any explanation there at the thread, at
> > the patch description or at the documentation explaining why, and,
> > more important, when someone should use the focus control or the
> > camera voice coil control.  
> 
> It should be available in the thread.

The email thread is not registered at git logs nor at the API spec.

> Nevertheless, V4L2_CID_FOCUS_ABSOLUTE
> is documented as follows (emphasis mine):
> 
>   This control sets the *focal point* of the camera to the specified
>   position. The unit is undefined. Positive values set the focus
>   closer to the camera, negative values towards infinity.
> 
> What you control in voice coil devices is current (in Ampères) and the
> current only has a relatively loose relation to the focal point.

The real problem I'm seeing here is that this control is already
used by voice coil motor (VCM). Several UVC-based Logitech cameras
come with VCM, like their QuickCam Pro-series webcams:

https://secure.logitech.com/en-hk/articles/3231

The voice coil can be seen on this picture:

https://photo.stackexchange.com/questions/48678/can-i-modify-a-logitech-c615-webcam-for-infinity-focus

> Additionally, increasing the current brings the focus closer, not farther.

That's just a hardware/software implementation detail. One could use
a voice coil to do just the reverse: without any current, it would
be getting a minimal focus distance; with max current it would
go to infinite, or may have some firmware inside the hardware that
would be inverting the signal.

I have here a C920 camera. This model has V4L2_CID_FOCUS_ABSOLUTE:

ioctl(3, VIDIOC_G_EXT_CTRLS, {ctrl_class=V4L2_CTRL_CLASS_CAMERA, count=1, 
controls=[{id=V4L2_CID_FOCUS_ABSOLUTE, size=0, value=0, value64=0}]}) = 0
write(1, " focus_absolute "..., 97 
focus_absolute (int): min=0 max=250 step=5 default=0 value=0 flags=inactive

On this model, V4L2_CID_FOCUS_ABSOLUTE == infinite.

On a quick check at uvc driver, it seems that the driver itself
doesn't invert the value before sending to the device. So, 
I guess that, either the camera firmware do something like:
current = 250 - control_value
Or the VCM here is mounted, in hardware, to use less current
when focusing on a close object.

Looking on it on another side, this control was added on this changeset:

commit f9bd5843658e18a7097fc7258c60fb840109eaa8
Author: Brandon Philips 
Date:   Tue Apr 22 14:42:02 2008 -0300

V4L/DVB (7167): [v4l] Add camera class control definitions

Meant to be used on USB cameras. Until this changeset:

commit bee3d51156113363e952674504833b4bc92cf15e
Author: Pavel Machek 
Date:   Fri Aug 5 07:26:11 2016 -0300

[media] ad5820: Add driver for auto-focus coil

The only driver that were using it were uvcvideo.

As far as I remember, Brandon was working together with a Logitech
developer, in order to add support for those Quickcam Pro cameras.
So, what this control actually sets is the VCM.

That's why I don't see any need to add another control to do the same
thing.

> I anticipate adding controls for ringing compensation in the future.
> Virtually all other devices except this one do ringing compensation and
> there's some control to be done for that.

Hmm... if the idea is to have a control that doesn't do ringing
compensation, then it should be clear at the control's descriptions
that:

- V4L2_CID_FOCUS_ABSOLUTE should be used if the VCM has ringing
  compensation;
- V4L2_CID_VOICE_COIL_CURRENT and V4L2_CID_VOICE_COIL_RING_COMPENSATION
  should be used otherwise.

Btw, if the rationale for this patch is to support devices without
ring compensation, so, both controls and their descriptions should
be added at the same time, together with a patchset that would be
using both.

> How about adding such an explanation added to the commit message?

It is not enough. Documentation should be clear that VCM devices
with ring compensation should use V4L2_CID_FOCUS_ABSOLUTE.

> 
> > 
> > Worse than that, patch 2/2 gives the false sensation that both
> > controls are equal.
> > 
> > Ok, I understand that they need to be identical on the existing
> > driver, in order to keep backward compatibility, but I'm afraid
> > that, without a clear 

Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-04-16 Thread Sakari Ailus
Hi Mauro,

On Fri, Apr 14, 2017 at 11:23:32PM -0300, Mauro Carvalho Chehab wrote:
> Hi Sakari,
> 
> Em Tue, 14 Feb 2017 14:20:22 +0200
> Sakari Ailus  escreveu:
> 
> > Add a V4L2 control class for voice coil lens driver devices. These are
> > simple devices that are used to move a camera lens from its resting
> > position.
> 
> From some past threads with this patch, you mentioned that:
> 
> "The FOCUS_ABSOLUTE control really is not a best control ID to
>  control a voice coil driver's current."
> 
> However, I'm not seeing any explanation there at the thread, at
> the patch description or at the documentation explaining why, and,
> more important, when someone should use the focus control or the
> camera voice coil control.

It should be available in the thread. Nevertheless, V4L2_CID_FOCUS_ABSOLUTE
is documented as follows (emphasis mine):

This control sets the *focal point* of the camera to the specified
position. The unit is undefined. Positive values set the focus
closer to the camera, negative values towards infinity.

What you control in voice coil devices is current (in Ampères) and the
current only has a relatively loose relation to the focal point.
Additionally, increasing the current brings the focus closer, not farther.

I anticipate adding controls for ringing compensation in the future.
Virtually all other devices except this one do ringing compensation and
there's some control to be done for that.

How about adding such an explanation added to the commit message?

> 
> Worse than that, patch 2/2 gives the false sensation that both
> controls are equal.
> 
> Ok, I understand that they need to be identical on the existing
> driver, in order to keep backward compatibility, but I'm afraid
> that, without a clear distinction between them at the documentation,
> people may just clone the existing code on other drivers.

Indeed. The only reason that I'm not just replacing FOCUS_ABSOLUTE with the
new contorol is backwards compatibility. But as Pavel pointed out, he's
likely the sole user of this device that can only be found (as far as we
commonly are aware) in the Nokia N900.

I'm happy to just switch the control, and Pavel mentioned he's happy with
that. It would avoid copying the code in new drivers --- which I would most
certainly point out anyway.

> 
> So, please add more details to patch 1/2.

Let me know if you're happy with the above.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk


Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-04-15 Thread Pavel Machek
Hi!

> Worse than that, patch 2/2 gives the false sensation that both
> controls are equal.
> 
> Ok, I understand that they need to be identical on the existing
> driver, in order to keep backward compatibility, but I'm afraid
> that, without a clear distinction between them at the documentation,
> people may just clone the existing code on other drivers.

Actually, you don't need to workky about the backwards compatibility
there. I'm pretty sure I'm the only user, and I can adapt.

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-04-14 Thread Mauro Carvalho Chehab
Hi Sakari,

Em Tue, 14 Feb 2017 14:20:22 +0200
Sakari Ailus  escreveu:

> Add a V4L2 control class for voice coil lens driver devices. These are
> simple devices that are used to move a camera lens from its resting
> position.

>From some past threads with this patch, you mentioned that:

"The FOCUS_ABSOLUTE control really is not a best control ID to
 control a voice coil driver's current."

However, I'm not seeing any explanation there at the thread, at
the patch description or at the documentation explaining why, and,
more important, when someone should use the focus control or the
camera voice coil control.

Worse than that, patch 2/2 gives the false sensation that both
controls are equal.

Ok, I understand that they need to be identical on the existing
driver, in order to keep backward compatibility, but I'm afraid
that, without a clear distinction between them at the documentation,
people may just clone the existing code on other drivers.

So, please add more details to patch 1/2.

Regards,
Mauro

> 
> Signed-off-by: Sakari Ailus 
> ---
>  Documentation/media/uapi/v4l/extended-controls.rst | 28 
> ++
>  include/uapi/linux/v4l2-controls.h |  8 +++
>  2 files changed, 36 insertions(+)
> 
> diff --git a/Documentation/media/uapi/v4l/extended-controls.rst 
> b/Documentation/media/uapi/v4l/extended-controls.rst
> index abb1057..a75451a 100644
> --- a/Documentation/media/uapi/v4l/extended-controls.rst
> +++ b/Documentation/media/uapi/v4l/extended-controls.rst
> @@ -3022,6 +3022,34 @@ Image Process Control IDs
>  driver specific and are documented in :ref:`v4l-drivers`.
>  
>  
> +.. _voice-coil-lens-controls:
> +
> +Voice Coil Lens Control Reference
> +=
> +
> +The Voice Coil class controls are used to control voice coil lens
> +devices. These are very simple devices that consist of a voice coil, a
> +spring and a lens. The current applied on the voice coil is used to
> +move the lens away from the resting position which typically is (close
> +to) infinity. The higher the current applied, the closer the lens is
> +typically focused.
> +
> +.. _voice-coil-lens-control-is:
> +
> +Voice Coil Lens Control IDs
> +---
> +
> +``V4L2_CID_VOICE_COIL_CLASS (class)``
> +The VOICE_COIL class descriptor.
> +
> +``V4L2_CID_VOICE_COIL_CURRENT (integer)``
> +Current applied on a voice coil. The more current is applied, the
> +more is the position of the lens moved from its resting position.
> +Do note that there may be a ringing effect; the lens will
> +oscillate after changing the current applied unless the device
> +implements ringing compensation.
> +
> +
>  .. _dv-controls:
>  
>  Digital Video Control Reference
> diff --git a/include/uapi/linux/v4l2-controls.h 
> b/include/uapi/linux/v4l2-controls.h
> index 0d2e1e0..9ef152b 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -62,6 +62,7 @@
>  #define V4L2_CTRL_CLASS_FM_RX0x00a1  /* FM Receiver 
> controls */
>  #define V4L2_CTRL_CLASS_RF_TUNER 0x00a2  /* RF tuner controls */
>  #define V4L2_CTRL_CLASS_DETECT   0x00a3  /* Detection 
> controls */
> +#define V4L2_CTRL_CLASS_VOICE_COIL   0x00a4  /* Voice coil lens 
> driver controls */
>  
>  /* User-class control IDs */
>  
> @@ -894,6 +895,13 @@ enum v4l2_jpeg_chroma_subsampling {
>  #define V4L2_CID_TEST_PATTERN
> (V4L2_CID_IMAGE_PROC_CLASS_BASE + 3)
>  #define V4L2_CID_DEINTERLACING_MODE  (V4L2_CID_IMAGE_PROC_CLASS_BASE 
> + 4)
>  
> +/* Voice coil lens driver controls */
> +
> +#define V4L2_CID_VOICE_COIL_CLASS_BASE   
> (V4L2_CTRL_CLASS_VOICE_COIL | 0x900)
> +#define V4L2_CID_VOICE_COIL_CLASS(V4L2_CTRL_CLASS_VOICE_COIL | 1)
> +
> +#define V4L2_CID_VOICE_COIL_CURRENT  (V4L2_CID_VOICE_COIL_CLASS_BASE 
> + 1)
> +
>  
>  /*  DV-class control IDs defined by V4L2 */
>  #define V4L2_CID_DV_CLASS_BASE   (V4L2_CTRL_CLASS_DV | 
> 0x900)



Thanks,
Mauro


Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-02-20 Thread Pavel Machek
Hi!

> > > > I wonder... should we somehow expose the range of diopters to
> > > > userspace? I believe userland camera application will need that
> > > > information.
> > > 
> > > It'd certainly be useful to be able to provide more information.
> > > 
> > > The question is: where to store it, and how? It depends on the voice
> > > coil, the spring constant, the lens and the distance of the lens from
> > > the sensor --- at least. Probably the sensor size as well.
> > > 
> > > On voice coil lenses it is also somewhat inexact.
> > 
> > I was thinking read-only attribute providing minimum and maximum
> > diopters in case there's linear relationship as on N900.
> > 
> > +#define V4L2_CID_VOICE_DIOPTERS_AT_REST (V4L2_CID_VOICE_COIL_CLASS_BASE + 
> > 2)
> > +#define V4L2_CID_VOICE_DIOPTERS_AT_MAX (V4L2_CID_VOICE_COIL_CLASS_BASE + 3)
> 
> Where do you store that information and how? Should the user be also told
> how the applied current affects the value?

The information would come from device tree.

User already knows minimum and maximum, so if he knows there's linear
relationship, he has complete picture. I'm not sure if there are some
voice coils with anything else then linear relationship. I guess we
could do

+#define V4L2_CID_VOICE_CURRENT_TO_DIOPTERS (V4L2_CID_VOICE_COIL_CLASS_BASE + 4)
#define ..._LINEAR 1

...

> I also wonder whether that's the best way to provide the information to the
> user --- we have things such as devices that are a part of a camera module
> and telling the user on which side of the device the camera is located.
> 
> We've been planning to have a property API for this to provide the user with
> a tree of key-value pairs, with details unsettled as of yet, so it's
> certainly nothing that could be used yet.

You know the design better than I do. I believe read-only properties
would be easy enough for this.

> Do you have a user application that could make use of such information?

fcam-dev,
yes. https://gitlab.com/pavelm/fcam-devhttps://gitlab.com/pavelm/fcam-dev

I don't promise to make neccessary modifications -- currently it
hardcodes 0 and 20 diopters -- but it allows manual or automatic
focus; in both modes it is good to tell user where he is focusing, and
it is pretty much mandatory in the manual mode.

Best regards,
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-02-20 Thread Sakari Ailus
Hi Pavel,

On Wed, Feb 15, 2017 at 09:09:09AM +0100, Pavel Machek wrote:
> Hi!
> 
> > On 02/15/17 00:47, Pavel Machek wrote:
> > > On Tue 2017-02-14 14:20:22, Sakari Ailus wrote:
> > >> Add a V4L2 control class for voice coil lens driver devices. These are
> > >> simple devices that are used to move a camera lens from its resting
> > >> position.
> > >>
> > >> Signed-off-by: Sakari Ailus 
> > > 
> > > Looks good to me.
> > > 
> > > I wonder... should we somehow expose the range of diopters to
> > > userspace? I believe userland camera application will need that
> > > information.
> > 
> > It'd certainly be useful to be able to provide more information.
> > 
> > The question is: where to store it, and how? It depends on the voice
> > coil, the spring constant, the lens and the distance of the lens from
> > the sensor --- at least. Probably the sensor size as well.
> > 
> > On voice coil lenses it is also somewhat inexact.
> 
> I was thinking read-only attribute providing minimum and maximum
> diopters in case there's linear relationship as on N900.
> 
> +#define V4L2_CID_VOICE_DIOPTERS_AT_REST (V4L2_CID_VOICE_COIL_CLASS_BASE + 2)
> +#define V4L2_CID_VOICE_DIOPTERS_AT_MAX (V4L2_CID_VOICE_COIL_CLASS_BASE + 3)

Where do you store that information and how? Should the user be also told
how the applied current affects the value?

I also wonder whether that's the best way to provide the information to the
user --- we have things such as devices that are a part of a camera module
and telling the user on which side of the device the camera is located.

We've been planning to have a property API for this to provide the user with
a tree of key-value pairs, with details unsettled as of yet, so it's
certainly nothing that could be used yet.

Do you have a user application that could make use of such information?

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk


Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-02-15 Thread Pavel Machek
Hi!

> On 02/15/17 00:47, Pavel Machek wrote:
> > On Tue 2017-02-14 14:20:22, Sakari Ailus wrote:
> >> Add a V4L2 control class for voice coil lens driver devices. These are
> >> simple devices that are used to move a camera lens from its resting
> >> position.
> >>
> >> Signed-off-by: Sakari Ailus 
> > 
> > Looks good to me.
> > 
> > I wonder... should we somehow expose the range of diopters to
> > userspace? I believe userland camera application will need that
> > information.
> 
> It'd certainly be useful to be able to provide more information.
> 
> The question is: where to store it, and how? It depends on the voice
> coil, the spring constant, the lens and the distance of the lens from
> the sensor --- at least. Probably the sensor size as well.
> 
> On voice coil lenses it is also somewhat inexact.

I was thinking read-only attribute providing minimum and maximum
diopters in case there's linear relationship as on N900.

+#define V4L2_CID_VOICE_DIOPTERS_AT_REST (V4L2_CID_VOICE_COIL_CLASS_BASE + 2)
+#define V4L2_CID_VOICE_DIOPTERS_AT_MAX (V4L2_CID_VOICE_COIL_CLASS_BASE + 3)

?

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-02-14 Thread Sakari Ailus
Hi Pavel,

On 02/15/17 00:47, Pavel Machek wrote:
> On Tue 2017-02-14 14:20:22, Sakari Ailus wrote:
>> Add a V4L2 control class for voice coil lens driver devices. These are
>> simple devices that are used to move a camera lens from its resting
>> position.
>>
>> Signed-off-by: Sakari Ailus 
> 
> Looks good to me.
> 
> I wonder... should we somehow expose the range of diopters to
> userspace? I believe userland camera application will need that
> information.

It'd certainly be useful to be able to provide more information.

The question is: where to store it, and how? It depends on the voice
coil, the spring constant, the lens and the distance of the lens from
the sensor --- at least. Probably the sensor size as well.

On voice coil lenses it is also somewhat inexact.

-- 
Kind regards,

Sakari Ailus
sakari.ai...@linux.intel.com



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-02-14 Thread Pavel Machek
On Tue 2017-02-14 14:20:22, Sakari Ailus wrote:
> Add a V4L2 control class for voice coil lens driver devices. These are
> simple devices that are used to move a camera lens from its resting
> position.
> 
> Signed-off-by: Sakari Ailus 

Looks good to me.

I wonder... should we somehow expose the range of diopters to
userspace? I believe userland camera application will need that
information.

Thanks,
Pavel

> ---
>  Documentation/media/uapi/v4l/extended-controls.rst | 28 
> ++
>  include/uapi/linux/v4l2-controls.h |  8 +++
>  2 files changed, 36 insertions(+)
> 
> diff --git a/Documentation/media/uapi/v4l/extended-controls.rst 
> b/Documentation/media/uapi/v4l/extended-controls.rst
> index abb1057..a75451a 100644
> --- a/Documentation/media/uapi/v4l/extended-controls.rst
> +++ b/Documentation/media/uapi/v4l/extended-controls.rst
> @@ -3022,6 +3022,34 @@ Image Process Control IDs
>  driver specific and are documented in :ref:`v4l-drivers`.
>  
>  
> +.. _voice-coil-lens-controls:
> +
> +Voice Coil Lens Control Reference
> +=
> +
> +The Voice Coil class controls are used to control voice coil lens
> +devices. These are very simple devices that consist of a voice coil, a
> +spring and a lens. The current applied on the voice coil is used to
> +move the lens away from the resting position which typically is (close
> +to) infinity. The higher the current applied, the closer the lens is
> +typically focused.
> +
> +.. _voice-coil-lens-control-is:
> +
> +Voice Coil Lens Control IDs
> +---
> +
> +``V4L2_CID_VOICE_COIL_CLASS (class)``
> +The VOICE_COIL class descriptor.
> +
> +``V4L2_CID_VOICE_COIL_CURRENT (integer)``
> +Current applied on a voice coil. The more current is applied, the
> +more is the position of the lens moved from its resting position.
> +Do note that there may be a ringing effect; the lens will
> +oscillate after changing the current applied unless the device
> +implements ringing compensation.
> +
> +
>  .. _dv-controls:
>  
>  Digital Video Control Reference
> diff --git a/include/uapi/linux/v4l2-controls.h 
> b/include/uapi/linux/v4l2-controls.h
> index 0d2e1e0..9ef152b 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -62,6 +62,7 @@
>  #define V4L2_CTRL_CLASS_FM_RX0x00a1  /* FM Receiver 
> controls */
>  #define V4L2_CTRL_CLASS_RF_TUNER 0x00a2  /* RF tuner controls */
>  #define V4L2_CTRL_CLASS_DETECT   0x00a3  /* Detection 
> controls */
> +#define V4L2_CTRL_CLASS_VOICE_COIL   0x00a4  /* Voice coil lens 
> driver controls */
>  
>  /* User-class control IDs */
>  
> @@ -894,6 +895,13 @@ enum v4l2_jpeg_chroma_subsampling {
>  #define V4L2_CID_TEST_PATTERN
> (V4L2_CID_IMAGE_PROC_CLASS_BASE + 3)
>  #define V4L2_CID_DEINTERLACING_MODE  (V4L2_CID_IMAGE_PROC_CLASS_BASE 
> + 4)
>  
> +/* Voice coil lens driver controls */
> +
> +#define V4L2_CID_VOICE_COIL_CLASS_BASE   
> (V4L2_CTRL_CLASS_VOICE_COIL | 0x900)
> +#define V4L2_CID_VOICE_COIL_CLASS(V4L2_CTRL_CLASS_VOICE_COIL | 1)
> +
> +#define V4L2_CID_VOICE_COIL_CURRENT  (V4L2_CID_VOICE_COIL_CLASS_BASE 
> + 1)
> +
>  
>  /*  DV-class control IDs defined by V4L2 */
>  #define V4L2_CID_DV_CLASS_BASE   (V4L2_CTRL_CLASS_DV | 
> 0x900)

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


[PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control

2017-02-14 Thread Sakari Ailus
Add a V4L2 control class for voice coil lens driver devices. These are
simple devices that are used to move a camera lens from its resting
position.

Signed-off-by: Sakari Ailus 
---
 Documentation/media/uapi/v4l/extended-controls.rst | 28 ++
 include/uapi/linux/v4l2-controls.h |  8 +++
 2 files changed, 36 insertions(+)

diff --git a/Documentation/media/uapi/v4l/extended-controls.rst 
b/Documentation/media/uapi/v4l/extended-controls.rst
index abb1057..a75451a 100644
--- a/Documentation/media/uapi/v4l/extended-controls.rst
+++ b/Documentation/media/uapi/v4l/extended-controls.rst
@@ -3022,6 +3022,34 @@ Image Process Control IDs
 driver specific and are documented in :ref:`v4l-drivers`.
 
 
+.. _voice-coil-lens-controls:
+
+Voice Coil Lens Control Reference
+=
+
+The Voice Coil class controls are used to control voice coil lens
+devices. These are very simple devices that consist of a voice coil, a
+spring and a lens. The current applied on the voice coil is used to
+move the lens away from the resting position which typically is (close
+to) infinity. The higher the current applied, the closer the lens is
+typically focused.
+
+.. _voice-coil-lens-control-is:
+
+Voice Coil Lens Control IDs
+---
+
+``V4L2_CID_VOICE_COIL_CLASS (class)``
+The VOICE_COIL class descriptor.
+
+``V4L2_CID_VOICE_COIL_CURRENT (integer)``
+Current applied on a voice coil. The more current is applied, the
+more is the position of the lens moved from its resting position.
+Do note that there may be a ringing effect; the lens will
+oscillate after changing the current applied unless the device
+implements ringing compensation.
+
+
 .. _dv-controls:
 
 Digital Video Control Reference
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index 0d2e1e0..9ef152b 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -62,6 +62,7 @@
 #define V4L2_CTRL_CLASS_FM_RX  0x00a1  /* FM Receiver controls 
*/
 #define V4L2_CTRL_CLASS_RF_TUNER   0x00a2  /* RF tuner controls */
 #define V4L2_CTRL_CLASS_DETECT 0x00a3  /* Detection controls */
+#define V4L2_CTRL_CLASS_VOICE_COIL 0x00a4  /* Voice coil lens 
driver controls */
 
 /* User-class control IDs */
 
@@ -894,6 +895,13 @@ enum v4l2_jpeg_chroma_subsampling {
 #define V4L2_CID_TEST_PATTERN  (V4L2_CID_IMAGE_PROC_CLASS_BASE 
+ 3)
 #define V4L2_CID_DEINTERLACING_MODE(V4L2_CID_IMAGE_PROC_CLASS_BASE 
+ 4)
 
+/* Voice coil lens driver controls */
+
+#define V4L2_CID_VOICE_COIL_CLASS_BASE (V4L2_CTRL_CLASS_VOICE_COIL | 
0x900)
+#define V4L2_CID_VOICE_COIL_CLASS  (V4L2_CTRL_CLASS_VOICE_COIL | 1)
+
+#define V4L2_CID_VOICE_COIL_CURRENT(V4L2_CID_VOICE_COIL_CLASS_BASE 
+ 1)
+
 
 /*  DV-class control IDs defined by V4L2 */
 #define V4L2_CID_DV_CLASS_BASE (V4L2_CTRL_CLASS_DV | 0x900)
-- 
2.7.4