Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control
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
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: http://www.trulyamerica.com/wp-content/uploads/CM7945-B1200BA-E_V1.1.pdf> 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: http://www.datasheetspdf.com/datasheet/download.php?id=840322> 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
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
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
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 distinction between them at the documentation, > > people may just clone the existing
Re: [PATCH v3 1/2] v4l: Add camera voice coil lens control class, current control
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
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
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
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
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
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
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
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
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
[PATCH v3 0/2] v4l: Add camera voice coil lens control class, current control
Hello everyone, I wanted to refresh my voice coil lens patchset before we have more voice coil lens controller drivers. The VOCUS_ABSOLUTE control really is not a best control ID to control a voice coil driver's current. There may be additional controls in the class: the hardware I'm familiar with provides other controls (PWM vs. linear mode, resonance frequency and ringing compensation formula to name a few) but I'm not fully certain they're something that even should be told to the user --- let alone giving the user write access to them. My expectation is still that there will be more controls in the class. The PWM / linear mode might be one candidate: PWM saves power but it may cause other issues. These other issues might be something to ignore, depending on the use case. That will be anyway left for the future. since v2: - Don't remove the newline after control class definitions. - Move all ad5820 related changes to the second patch. Some were accidentally left to the patch adding the new control class. -- Kind regards, Sakari
[PATCH v2 1/2] v4l: Add camera voice coil lens control class, current control
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 ++ drivers/media/i2c/ad5820.c | 3 +++ include/uapi/linux/v4l2-controls.h | 9 ++- 3 files changed, 39 insertions(+), 1 deletion(-) 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/drivers/media/i2c/ad5820.c b/drivers/media/i2c/ad5820.c index a9026a91..7167b26 100644 --- a/drivers/media/i2c/ad5820.c +++ b/drivers/media/i2c/ad5820.c @@ -162,6 +162,7 @@ static int ad5820_set_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_FOCUS_ABSOLUTE: + case V4L2_CID_VOICE_COIL_CURRENT: coil->focus_absolute = ctrl->val; return ad5820_update_hw(coil); } @@ -192,6 +193,8 @@ static int ad5820_init_controls(struct ad5820_device *coil) */ v4l2_ctrl_new_std(&coil->ctrls, &ad5820_ctrl_ops, V4L2_CID_FOCUS_ABSOLUTE, 0, 1023, 1, 0); + v4l2_ctrl_new_std(&coil->ctrls, &ad5820_ctrl_ops, + V4L2_CID_VOICE_COIL_CURRENT, 0, 1023, 1, 0); if (coil->ctrls.error) return coil->ctrls.error; diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 0d2e1e0..c1efbc5 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -62,7 +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 */ #define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900) @@ -894,6 +894,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
v4l: Add camera voice coil lens control class, current control
Hi folks, I wanted to refresh my voice coil lens patchset before we have more voice coil lens controller drivers. The VOCUS_ABSOLUTE control really is not a best control ID to control a voice coil driver's current. There may be additional controls in the class: the hardware I'm familiar with provides other controls (PWM vs. linear mode, resonance frequency and ringing compensation formula to name a few) but I'm not fully certain they're something that even should be told to the user --- let alone giving the user write access to them. My expectation is still that there will be more controls in the class. The PWM / linear mode might be one candidate: PWM saves power but it may cause other issues. These other issues might be something to ignore, depending on the use case. That will be anyway left for the future. -- Kind regards, Sakari
Re: [PATCH 1/1] v4l: Add camera voice coil lens control class, current control
Hi! > If someone has analyzed the existing voice coil lens controllers and could > share the result, in term of what parameters need to be controlled by the > system and how they should be controlled, that would be very appreciated. > Even > better would be a real userspace implementation of a voice coil lens control > algorithm. Userspace implementation exists, it is called fcam-dev. What it does... Starts capture, selects focus speed, makes it go through focus range, looks for the sharpest image in the stream. Then it computes time when the image was sharpest and thus lens position, and goes back there. So for ad5820, we need basically focus position and focus speed. (And some 16/64 option). Other coil drivers also have PWM vs. linear option. Best regards, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] v4l: Add camera voice coil lens control class, current control
Hello, On Saturday 18 Jun 2016 00:11:49 Pavel Machek wrote: > Hi! > > >> I also don't think the FOCUS_ABSOLUTE controls is a really good one for > >> the voice coil lens current. I expect more voice coil lens controls > >> (linear vs. PWM mode, ringing compensation...) to be needed so I think > >> it's worth a new class. > > Well, I do agree that that the new class is fine (and have no problem > with your proposal), but I'd like to understand why FOCUS_ABSOLUTE is > unsuitable. I'm actually thinking about writing very simple userspace > camera, without autofocus, where user would just select > "infinity"/"1m"/"50cm" ... and for that FOCUS_ABSOLUTE is equivalent > to VOICE_COIL_CURRENT... > > > Right, I still think movement mode should be standard control :) > > What options would you like to see for movement mode? I've discussed this with Sakari offline a few days ago. I won't nack this patch, but to ack it I'd like to have a better understanding of the big picture when it comes to focus and lens control. The proposed new control can make sense when taken in isolation, but I can't tell whether it still would when associated with the other controls that would be needed to properly control a voice coil lens. If someone has analyzed the existing voice coil lens controllers and could share the result, in term of what parameters need to be controlled by the system and how they should be controlled, that would be very appreciated. Even better would be a real userspace implementation of a voice coil lens control algorithm. -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] v4l: Add camera voice coil lens control class, current control
Hi! > >I also don't think the FOCUS_ABSOLUTE controls is a really good one for > >the voice coil lens current. I expect more voice coil lens controls > >(linear vs. PWM mode, ringing compensation...) to be needed so I think > >it's worth a new class. Well, I do agree that that the new class is fine (and have no problem with your proposal), but I'd like to understand why FOCUS_ABSOLUTE is unsuitable. I'm actually thinking about writing very simple userspace camera, without autofocus, where user would just select "infinity"/"1m"/"50cm" ... and for that FOCUS_ABSOLUTE is equivalent to VOICE_COIL_CURRENT... > Right, I still think movement mode should be standard control :) What options would you like to see for movement mode? Thanks, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] v4l: Add camera voice coil lens control class, current control
Hi! > - > + > + > + Voice Coil 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 a "on the"? > + voice coil is used to move the lens away from the resting > + position which typically is (close to) infinity. Insert explanation that this all is for autofocus somewhere? > /* User-class control IDs */ > > @@ -974,4 +975,10 @@ enum v4l2_detect_md_mode { > #define V4L2_CID_DETECT_MD_THRESHOLD_GRID(V4L2_CID_DETECT_CLASS_BASE + 3) > #define V4L2_CID_DETECT_MD_REGION_GRID > (V4L2_CID_DETECT_CLASS_BASE + 4) > > +/* Voice coil lens driver control IDs defined by V4L2 */ Too many spaces after '/*'. Otherwise, you have my "acked-by". Thanks, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] v4l: Add camera voice coil lens control class, current control
Hi, On 12.06.2016 23:41, Sakari Ailus wrote: From: 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 --- Hi Pavel, I also don't think the FOCUS_ABSOLUTE controls is a really good one for the voice coil lens current. I expect more voice coil lens controls (linear vs. PWM mode, ringing compensation...) to be needed so I think it's worth a new class. Right, I still think movement mode should be standard control :) Cc others, too... Kind regards, Sakari Documentation/DocBook/media/v4l/controls.xml | 55 +++- include/uapi/linux/v4l2-controls.h | 7 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml index e2e5484..aa7169c 100644 --- a/Documentation/DocBook/media/v4l/controls.xml +++ b/Documentation/DocBook/media/v4l/controls.xml @@ -5502,4 +5502,57 @@ receiving given frequency when that control is set. This is a read-only control. - + + + Voice Coil 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 a There should be a magnet as well. + voice coil is used to move the lens away from the resting + position which typically is (close to) infinity. + + + Voice Coil Control IDs + + + + + + + + + + +ID +Type + Description + + + + + +V4L2_CID_VOICE_COIL_CLASS +class + The Voice Coil class +descriptor. Calling &VIDIOC-QUERYCTRL; for this control will return a +description of this control class. + + +V4L2_CID_VOICE_COIL_CURRENT +integer I think this is no better than FOCUS_ABSOLUTE - nor "absolute" neither "current" give any idea where is the lens (relatively to the rest position) without userspace doing some calculations. What about V4L2_CID_VOICE_COIL_POSITION, 0.000%-100.000% (pcm units)? + 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. + + + + + + + + + diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index b6a357a..c6b1261 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_DETECT0x00a3 /* Detection controls */ +#define V4L2_CTRL_CLASS_VOICE_COIL 0x00a4 /* Voice coil lens driver */ /* User-class control IDs */ @@ -974,4 +975,10 @@ enum v4l2_detect_md_mode { #define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3) #define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4) +/* Voice coil lens driver control IDs defined by V4L2 */ +#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) + #endif Ivo -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/1] v4l: Add camera voice coil lens control class, current control
From: 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 --- Hi Pavel, I also don't think the FOCUS_ABSOLUTE controls is a really good one for the voice coil lens current. I expect more voice coil lens controls (linear vs. PWM mode, ringing compensation...) to be needed so I think it's worth a new class. Cc others, too... Kind regards, Sakari Documentation/DocBook/media/v4l/controls.xml | 55 +++- include/uapi/linux/v4l2-controls.h | 7 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml index e2e5484..aa7169c 100644 --- a/Documentation/DocBook/media/v4l/controls.xml +++ b/Documentation/DocBook/media/v4l/controls.xml @@ -5502,4 +5502,57 @@ receiving given frequency when that control is set. This is a read-only control. - + + + Voice Coil 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 a + voice coil is used to move the lens away from the resting + position which typically is (close to) infinity. + + + Voice Coil Control IDs + + + + + + + + + + +ID +Type + Description + + + + + +V4L2_CID_VOICE_COIL_CLASS +class + The Voice Coil class +descriptor. Calling &VIDIOC-QUERYCTRL; for this control will return a +description of this control class. + + +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. + + + + + + + + + diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index b6a357a..c6b1261 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 */ /* User-class control IDs */ @@ -974,4 +975,10 @@ enum v4l2_detect_md_mode { #define V4L2_CID_DETECT_MD_THRESHOLD_GRID (V4L2_CID_DETECT_CLASS_BASE + 3) #define V4L2_CID_DETECT_MD_REGION_GRID (V4L2_CID_DETECT_CLASS_BASE + 4) +/* Voice coil lens driver control IDs defined by V4L2 */ +#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) + #endif -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html