[media] V4L: Add camera auto focus controls
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Fri, 11 May 2012 09:37:03 +0000 (06:37 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 14 May 2012 17:30:26 +0000 (14:30 -0300)
Add following auto focus controls:

 - V4L2_CID_AUTO_FOCUS_START - single-shot auto focus start
 - V4L2_CID_AUTO_FOCUS_STOP -  single-shot auto focus stop
 - V4L2_CID_AUTO_FOCUS_STATUS - automatic focus status
 - V4L2_CID_AUTO_FOCUS_RANGE - automatic focus scan range selection

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Documentation/DocBook/media/v4l/compat.xml
Documentation/DocBook/media/v4l/controls.xml
Documentation/DocBook/media/v4l/v4l2.xml
drivers/media/video/v4l2-ctrls.c
include/linux/videodev2.h

index 149f65dfaa72bf574e206c002819c6a3cb144a83..dc61b013b8a8599e15b7048032fd53d1184eea98 100644 (file)
@@ -2435,6 +2435,21 @@ details.</para>
         <listitem>
          <para> Added <constant>V4L2_CID_COLORFX_CBCR</constant> control.</para>
         </listitem>
+        <listitem>
+         <para> Added camera controls <constant>V4L2_CID_AUTO_EXPOSURE_BIAS</constant>,
+         <constant>V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE</constant>,
+         <constant>V4L2_CID_IMAGE_STABILIZATION</constant>,
+         <constant>V4L2_CID_ISO_SENSITIVITY</constant>,
+         <constant>V4L2_CID_ISO_SENSITIVITY_AUTO</constant>,
+         <constant>V4L2_CID_EXPOSURE_METERING</constant>,
+         <constant>V4L2_CID_SCENE_MODE</constant>,
+         <constant>V4L2_CID_3A_LOCK</constant>,
+         <constant>V4L2_CID_AUTO_FOCUS_START</constant>,
+         <constant>V4L2_CID_AUTO_FOCUS_STOP</constant>,
+         <constant>V4L2_CID_AUTO_FOCUS_STATUS</constant> and
+         <constant>V4L2_CID_AUTO_FOCUS_RANGE</constant>.
+         </para>
+        </listitem>
       </orderedlist>
     </section>
 
@@ -2555,6 +2570,10 @@ ioctls.</para>
          <para>Sub-device selection API: &VIDIOC-SUBDEV-G-SELECTION;
          and &VIDIOC-SUBDEV-S-SELECTION; ioctls.</para>
         </listitem>
+        <listitem>
+         <para><link linkend="v4l2-auto-focus-area"><constant>
+         V4L2_CID_AUTO_FOCUS_AREA</constant></link> control.</para>
+        </listitem>
       </itemizedlist>
     </section>
 
index f38f06169795751cfd28ae3b349b22993fe6988f..132b0cc29832d5f157dad0b78745bd2a1fb009cb 100644 (file)
@@ -2976,12 +2976,106 @@ negative values towards infinity. This is a write-only control.</entry>
          <row>
            <entry spanname="id"><constant>V4L2_CID_FOCUS_AUTO</constant>&nbsp;</entry>
            <entry>boolean</entry>
-         </row><row><entry spanname="descr">Enables automatic focus
-adjustments. The effect of manual focus adjustments while this feature
+         </row><row><entry spanname="descr">Enables continuous automatic
+focus adjustments. The effect of manual focus adjustments while this feature
 is enabled is undefined, drivers should ignore such requests.</entry>
          </row>
          <row><entry></entry></row>
 
+         <row>
+           <entry spanname="id"><constant>V4L2_CID_AUTO_FOCUS_START</constant>&nbsp;</entry>
+           <entry>button</entry>
+         </row><row><entry spanname="descr">Starts single auto focus process.
+The effect of setting this control when <constant>V4L2_CID_FOCUS_AUTO</constant>
+is set to <constant>TRUE</constant> (1) is undefined, drivers should ignore
+such requests.</entry>
+         </row>
+         <row><entry></entry></row>
+
+         <row>
+           <entry spanname="id"><constant>V4L2_CID_AUTO_FOCUS_STOP</constant>&nbsp;</entry>
+           <entry>button</entry>
+         </row><row><entry spanname="descr">Aborts automatic focusing
+started with <constant>V4L2_CID_AUTO_FOCUS_START</constant> control. It is
+effective only when the continuous autofocus is disabled, that is when
+<constant>V4L2_CID_FOCUS_AUTO</constant> control is set to <constant>FALSE
+</constant> (0).</entry>
+         </row>
+         <row><entry></entry></row>
+
+         <row id="v4l2-auto-focus-status">
+           <entry spanname="id">
+             <constant>V4L2_CID_AUTO_FOCUS_STATUS</constant>&nbsp;</entry>
+           <entry>bitmask</entry>
+         </row>
+         <row><entry spanname="descr">The automatic focus status. This is a read-only
+         control.</entry>
+         </row>
+         <row>
+           <entrytbl spanname="descr" cols="2">
+             <tbody valign="top">
+               <row>
+                 <entry><constant>V4L2_AUTO_FOCUS_STATUS_IDLE</constant>&nbsp;</entry>
+                 <entry>Automatic focus is not active.</entry>
+               </row>
+               <row>
+                 <entry><constant>V4L2_AUTO_FOCUS_STATUS_BUSY</constant>&nbsp;</entry>
+                 <entry>Automatic focusing is in progress.</entry>
+               </row>
+               <row>
+                 <entry><constant>V4L2_AUTO_FOCUS_STATUS_REACHED</constant>&nbsp;</entry>
+                 <entry>Focus has been reached.</entry>
+               </row>
+               <row>
+                 <entry><constant>V4L2_AUTO_FOCUS_STATUS_FAILED</constant>&nbsp;</entry>
+                 <entry>Automatic focus has failed, the driver will not
+                 transition from this state until another action is
+                 performed by an application.</entry>
+               </row>
+             </tbody>
+           </entrytbl>
+         </row>
+         <row><entry spanname="descr">
+Setting <constant>V4L2_LOCK_FOCUS</constant> lock bit of the <constant>V4L2_CID_3A_LOCK
+</constant> control may stop updates of the <constant>V4L2_CID_AUTO_FOCUS_STATUS</constant>
+control value.</entry>
+         </row>
+         <row><entry></entry></row>
+
+         <row id="v4l2-auto-focus-range">
+           <entry spanname="id">
+             <constant>V4L2_CID_AUTO_FOCUS_RANGE</constant>&nbsp;</entry>
+           <entry>enum&nbsp;v4l2_auto_focus_range</entry>
+         </row>
+         <row><entry spanname="descr">Determines auto focus distance range
+for which lens may be adjusted. </entry>
+         </row>
+         <row>
+           <entrytbl spanname="descr" cols="2">
+             <tbody valign="top">
+               <row>
+                 <entry><constant>V4L2_AUTO_FOCUS_RANGE_AUTO</constant>&nbsp;</entry>
+                 <entry>The camera automatically selects the focus range.</entry>
+               </row>
+               <row>
+                 <entry><constant>V4L2_AUTO_FOCUS_RANGE_NORMAL</constant>&nbsp;</entry>
+                 <entry>Normal distance range, limited for best automatic focus
+performance.</entry>
+               </row>
+               <row>
+                 <entry><constant>V4L2_AUTO_FOCUS_RANGE_MACRO</constant>&nbsp;</entry>
+                 <entry>Macro (close-up) auto focus. The camera will
+use its minimum possible distance for auto focus.</entry>
+               </row>
+               <row>
+                 <entry><constant>V4L2_AUTO_FOCUS_RANGE_INFINITY</constant>&nbsp;</entry>
+                 <entry>The lens is set to focus on an object at infinite distance.</entry>
+               </row>
+             </tbody>
+           </entrytbl>
+         </row>
+         <row><entry></entry></row>
+
          <row>
            <entry spanname="id"><constant>V4L2_CID_ZOOM_ABSOLUTE</constant>&nbsp;</entry>
            <entry>integer</entry>
index 63242e2adc02f29d7728de9aaa65609f91c1edf8..e6fbbc6c17e119ae8f94cdd4b902d1d42a2fd2a5 100644 (file)
@@ -140,11 +140,18 @@ applications. -->
 
       <revision>
        <revnumber>3.5</revnumber>
-       <date>2012-04-02</date>
+       <date>2012-05-07</date>
        <authorinitials>sa, sn</authorinitials>
        <revremark>Added V4L2_CTRL_TYPE_INTEGER_MENU and V4L2 subdev
            selections API. Improved the description of V4L2_CID_COLORFX
            control, added V4L2_CID_COLORFX_CBCR control.
+           Added camera controls V4L2_CID_AUTO_EXPOSURE_BIAS,
+           V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE, V4L2_CID_IMAGE_STABILIZATION,
+           V4L2_CID_ISO_SENSITIVITY, V4L2_CID_ISO_SENSITIVITY_AUTO,
+           V4L2_CID_EXPOSURE_METERING, V4L2_CID_SCENE_MODE,
+           V4L2_CID_3A_LOCK, V4L2_CID_AUTO_FOCUS_START,
+           V4L2_CID_AUTO_FOCUS_STOP, V4L2_CID_AUTO_FOCUS_STATUS
+           and V4L2_CID_AUTO_FOCUS_RANGE.
        </revremark>
       </revision>
 
index a47b29270ba3c5c2d0a354e1bf91dd24e69d7402..a5fbace4c05944c06df10b96b7ec29ddb97c02bc 100644 (file)
@@ -236,6 +236,13 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
                "Spot",
                NULL
        };
+       static const char * const camera_auto_focus_range[] = {
+               "Auto",
+               "Normal",
+               "Macro",
+               "Infinity",
+               NULL
+       };
        static const char * const colorfx[] = {
                "None",
                "Black & White",
@@ -459,6 +466,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
                return camera_exposure_auto;
        case V4L2_CID_EXPOSURE_METERING:
                return camera_exposure_metering;
+       case V4L2_CID_AUTO_FOCUS_RANGE:
+               return camera_auto_focus_range;
        case V4L2_CID_COLORFX:
                return colorfx;
        case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
@@ -646,7 +655,7 @@ const char *v4l2_ctrl_get_name(u32 id)
        case V4L2_CID_TILT_ABSOLUTE:            return "Tilt, Absolute";
        case V4L2_CID_FOCUS_ABSOLUTE:           return "Focus, Absolute";
        case V4L2_CID_FOCUS_RELATIVE:           return "Focus, Relative";
-       case V4L2_CID_FOCUS_AUTO:               return "Focus, Automatic";
+       case V4L2_CID_FOCUS_AUTO:               return "Focus, Automatic Continuous";
        case V4L2_CID_ZOOM_ABSOLUTE:            return "Zoom, Absolute";
        case V4L2_CID_ZOOM_RELATIVE:            return "Zoom, Relative";
        case V4L2_CID_ZOOM_CONTINUOUS:          return "Zoom, Continuous";
@@ -662,6 +671,10 @@ const char *v4l2_ctrl_get_name(u32 id)
        case V4L2_CID_EXPOSURE_METERING:        return "Exposure, Metering Mode";
        case V4L2_CID_SCENE_MODE:               return "Scene Mode";
        case V4L2_CID_3A_LOCK:                  return "3A Lock";
+       case V4L2_CID_AUTO_FOCUS_START:         return "Auto Focus, Start";
+       case V4L2_CID_AUTO_FOCUS_STOP:          return "Auto Focus, Stop";
+       case V4L2_CID_AUTO_FOCUS_STATUS:        return "Auto Focus, Status";
+       case V4L2_CID_AUTO_FOCUS_RANGE:         return "Auto Focus, Range";
 
        /* FM Radio Modulator control */
        /* Keep the order of the 'case's the same as in videodev2.h! */
@@ -774,6 +787,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
        case V4L2_CID_TILT_RESET:
        case V4L2_CID_FLASH_STROBE:
        case V4L2_CID_FLASH_STROBE_STOP:
+       case V4L2_CID_AUTO_FOCUS_START:
+       case V4L2_CID_AUTO_FOCUS_STOP:
                *type = V4L2_CTRL_TYPE_BUTTON;
                *flags |= V4L2_CTRL_FLAG_WRITE_ONLY;
                *min = *max = *step = *def = 0;
@@ -797,6 +812,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
        case V4L2_CID_MPEG_STREAM_TYPE:
        case V4L2_CID_MPEG_STREAM_VBI_FMT:
        case V4L2_CID_EXPOSURE_AUTO:
+       case V4L2_CID_AUTO_FOCUS_RANGE:
        case V4L2_CID_COLORFX:
        case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
        case V4L2_CID_TUNE_PREEMPHASIS:
@@ -851,6 +867,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
        case V4L2_CID_FLASH_FAULT:
        case V4L2_CID_JPEG_ACTIVE_MARKER:
        case V4L2_CID_3A_LOCK:
+       case V4L2_CID_AUTO_FOCUS_STATUS:
                *type = V4L2_CTRL_TYPE_BITMASK;
                break;
        case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
@@ -913,6 +930,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
                *flags |= V4L2_CTRL_FLAG_WRITE_ONLY;
                break;
        case V4L2_CID_FLASH_STROBE_STATUS:
+       case V4L2_CID_AUTO_FOCUS_STATUS:
        case V4L2_CID_FLASH_READY:
                *flags |= V4L2_CTRL_FLAG_READ_ONLY;
                break;
index a9b03ae440370783b20b12c286dff128468ece30..dc3e3ea28f9979b001f4545b11d1b0ccbdb672ef 100644 (file)
@@ -1763,6 +1763,22 @@ enum v4l2_scene_mode {
 #define V4L2_LOCK_WHITE_BALANCE                        (1 << 1)
 #define V4L2_LOCK_FOCUS                                (1 << 2)
 
+#define V4L2_CID_AUTO_FOCUS_START              (V4L2_CID_CAMERA_CLASS_BASE+28)
+#define V4L2_CID_AUTO_FOCUS_STOP               (V4L2_CID_CAMERA_CLASS_BASE+29)
+#define V4L2_CID_AUTO_FOCUS_STATUS             (V4L2_CID_CAMERA_CLASS_BASE+30)
+#define V4L2_AUTO_FOCUS_STATUS_IDLE            (0 << 0)
+#define V4L2_AUTO_FOCUS_STATUS_BUSY            (1 << 0)
+#define V4L2_AUTO_FOCUS_STATUS_REACHED         (1 << 1)
+#define V4L2_AUTO_FOCUS_STATUS_FAILED          (1 << 2)
+
+#define V4L2_CID_AUTO_FOCUS_RANGE              (V4L2_CID_CAMERA_CLASS_BASE+31)
+enum v4l2_auto_focus_range {
+       V4L2_AUTO_FOCUS_RANGE_AUTO              = 0,
+       V4L2_AUTO_FOCUS_RANGE_NORMAL            = 1,
+       V4L2_AUTO_FOCUS_RANGE_MACRO             = 2,
+       V4L2_AUTO_FOCUS_RANGE_INFINITY          = 3,
+};
+
 /* FM Modulator class control IDs */
 #define V4L2_CID_FM_TX_CLASS_BASE              (V4L2_CTRL_CLASS_FM_TX | 0x900)
 #define V4L2_CID_FM_TX_CLASS                   (V4L2_CTRL_CLASS_FM_TX | 1)