diff mbox

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

Message ID 1465764110-7736-1-git-send-email-sakari.ailus@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sakari Ailus June 12, 2016, 8:41 p.m. UTC
From: Sakari Ailus <sakari.ailus@iki.fi>

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 <sakari.ailus@linux.intel.com>
---
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(-)

Comments

Ivaylo Dimitrov June 12, 2016, 9:48 p.m. UTC | #1
Hi,

On 12.06.2016 23:41, Sakari Ailus wrote:
> From: Sakari Ailus <sakari.ailus@iki.fi>
>
> 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 <sakari.ailus@linux.intel.com>
> ---
> 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.
>           </tgroup>
>         </table>
>       </section>
> -</section>
> +
> +    <section id="voice-coil-controls">
> +      <title>Voice Coil Control Reference</title>
> +
> +      <para>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.</para>
> +
> +      <table pgwide="1" frame="none" id="voice-coil-control-id">
> +      <title>Voice Coil Control IDs</title>
> +
> +      <tgroup cols="4">
> +        <colspec colname="c1" colwidth="1*" />
> +        <colspec colname="c2" colwidth="6*" />
> +        <colspec colname="c3" colwidth="2*" />
> +        <colspec colname="c4" colwidth="6*" />
> +        <spanspec namest="c1" nameend="c2" spanname="id" />
> +        <spanspec namest="c2" nameend="c4" spanname="descr" />
> +        <thead>
> +          <row>
> +            <entry spanname="id" align="left">ID</entry>
> +            <entry align="left">Type</entry>
> +          </row><row rowsep="1"><entry spanname="descr" align="left">Description</entry>
> +          </row>
> +        </thead>
> +        <tbody valign="top">
> +          <row><entry></entry></row>
> +          <row>
> +            <entry spanname="id"><constant>V4L2_CID_VOICE_COIL_CLASS</constant>&nbsp;</entry>
> +            <entry>class</entry>
> +          </row><row><entry spanname="descr">The Voice Coil class
> +descriptor. Calling &VIDIOC-QUERYCTRL; for this control will return a
> +description of this control class.</entry>
> +          </row>
> +          <row>
> +            <entry spanname="id"><constant>V4L2_CID_VOICE_COIL_CURRENT</constant>&nbsp;</entry>
> +            <entry>integer</entry>

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)?

> +          </row><row><entry spanname="descr">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.
> +          </entry>
> +          </row>
> +        </tbody>
> +      </tgroup>
> +      </table>
> +
> +      </section>
> +
> +  </section>
> 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		0x00a10000	/* FM Receiver controls */
>   #define V4L2_CTRL_CLASS_RF_TUNER	0x00a20000	/* RF tuner controls */
>   #define V4L2_CTRL_CLASS_DETECT		0x00a30000	/* Detection controls */
> +#define V4L2_CTRL_CLASS_VOICE_COIL	0x00a40000	/* 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pavel Machek June 17, 2016, 10:06 p.m. UTC | #2
Hi!

> -</section>
> +
> +    <section id="voice-coil-controls">
> +      <title>Voice Coil Control Reference</title>
> +
> +      <para>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.</para>

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
Pavel Machek June 17, 2016, 10:11 p.m. UTC | #3
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
Laurent Pinchart June 17, 2016, 10:39 p.m. UTC | #4
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.
Pavel Machek June 18, 2016, 11:28 a.m. UTC | #5
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
diff mbox

Patch

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.
         </tgroup>
       </table>
     </section>
-</section>
+
+    <section id="voice-coil-controls">
+      <title>Voice Coil Control Reference</title>
+
+      <para>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.</para>
+
+      <table pgwide="1" frame="none" id="voice-coil-control-id">
+      <title>Voice Coil Control IDs</title>
+
+      <tgroup cols="4">
+        <colspec colname="c1" colwidth="1*" />
+        <colspec colname="c2" colwidth="6*" />
+        <colspec colname="c3" colwidth="2*" />
+        <colspec colname="c4" colwidth="6*" />
+        <spanspec namest="c1" nameend="c2" spanname="id" />
+        <spanspec namest="c2" nameend="c4" spanname="descr" />
+        <thead>
+          <row>
+            <entry spanname="id" align="left">ID</entry>
+            <entry align="left">Type</entry>
+          </row><row rowsep="1"><entry spanname="descr" align="left">Description</entry>
+          </row>
+        </thead>
+        <tbody valign="top">
+          <row><entry></entry></row>
+          <row>
+            <entry spanname="id"><constant>V4L2_CID_VOICE_COIL_CLASS</constant>&nbsp;</entry>
+            <entry>class</entry>
+          </row><row><entry spanname="descr">The Voice Coil class
+descriptor. Calling &VIDIOC-QUERYCTRL; for this control will return a
+description of this control class.</entry>
+          </row>
+          <row>
+            <entry spanname="id"><constant>V4L2_CID_VOICE_COIL_CURRENT</constant>&nbsp;</entry>
+            <entry>integer</entry>
+          </row><row><entry spanname="descr">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.
+          </entry>
+          </row>
+        </tbody>
+      </tgroup>
+      </table>
+
+      </section>
+
+  </section>
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		0x00a10000	/* FM Receiver controls */
 #define V4L2_CTRL_CLASS_RF_TUNER	0x00a20000	/* RF tuner controls */
 #define V4L2_CTRL_CLASS_DETECT		0x00a30000	/* Detection controls */
+#define V4L2_CTRL_CLASS_VOICE_COIL	0x00a40000	/* 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