From 2272ab657b508ece04bf015da6c23f61711bac81 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 11 May 2012 06:37:03 -0300 Subject: [PATCH] [media] V4L: Add camera auto focus controls 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 Signed-off-by: Kyungmin Park Signed-off-by: Mauro Carvalho Chehab --- Documentation/DocBook/media/v4l/compat.xml | 19 ++++++ Documentation/DocBook/media/v4l/controls.xml | 98 +++++++++++++++++++++++++++- Documentation/DocBook/media/v4l/v4l2.xml | 9 ++- drivers/media/video/v4l2-ctrls.c | 20 +++++- include/linux/videodev2.h | 16 +++++ 5 files changed, 158 insertions(+), 4 deletions(-) diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml index 149f65d..dc61b01 100644 --- a/Documentation/DocBook/media/v4l/compat.xml +++ b/Documentation/DocBook/media/v4l/compat.xml @@ -2435,6 +2435,21 @@ details. 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. + + @@ -2555,6 +2570,10 @@ ioctls. Sub-device selection API: &VIDIOC-SUBDEV-G-SELECTION; and &VIDIOC-SUBDEV-S-SELECTION; ioctls. + + + V4L2_CID_AUTO_FOCUS_AREA control. + diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml index f38f061..132b0cc 100644 --- a/Documentation/DocBook/media/v4l/controls.xml +++ b/Documentation/DocBook/media/v4l/controls.xml @@ -2976,13 +2976,107 @@ negative values towards infinity. This is a write-only control. V4L2_CID_FOCUS_AUTO  boolean - Enables automatic focus -adjustments. The effect of manual focus adjustments while this feature + Enables continuous automatic +focus adjustments. The effect of manual focus adjustments while this feature is enabled is undefined, drivers should ignore such requests. + V4L2_CID_AUTO_FOCUS_START  + button + Starts single auto focus process. +The effect of setting this control when V4L2_CID_FOCUS_AUTO +is set to TRUE (1) is undefined, drivers should ignore +such requests. + + + + + V4L2_CID_AUTO_FOCUS_STOP  + button + Aborts automatic focusing +started with V4L2_CID_AUTO_FOCUS_START control. It is +effective only when the continuous autofocus is disabled, that is when +V4L2_CID_FOCUS_AUTO control is set to FALSE + (0). + + + + + + V4L2_CID_AUTO_FOCUS_STATUS  + bitmask + + The automatic focus status. This is a read-only + control. + + + + + + V4L2_AUTO_FOCUS_STATUS_IDLE  + Automatic focus is not active. + + + V4L2_AUTO_FOCUS_STATUS_BUSY  + Automatic focusing is in progress. + + + V4L2_AUTO_FOCUS_STATUS_REACHED  + Focus has been reached. + + + V4L2_AUTO_FOCUS_STATUS_FAILED  + Automatic focus has failed, the driver will not + transition from this state until another action is + performed by an application. + + + + + +Setting V4L2_LOCK_FOCUS lock bit of the V4L2_CID_3A_LOCK + control may stop updates of the V4L2_CID_AUTO_FOCUS_STATUS +control value. + + + + + + V4L2_CID_AUTO_FOCUS_RANGE  + enum v4l2_auto_focus_range + + Determines auto focus distance range +for which lens may be adjusted. + + + + + + V4L2_AUTO_FOCUS_RANGE_AUTO  + The camera automatically selects the focus range. + + + V4L2_AUTO_FOCUS_RANGE_NORMAL  + Normal distance range, limited for best automatic focus +performance. + + + V4L2_AUTO_FOCUS_RANGE_MACRO  + Macro (close-up) auto focus. The camera will +use its minimum possible distance for auto focus. + + + V4L2_AUTO_FOCUS_RANGE_INFINITY  + The lens is set to focus on an object at infinite distance. + + + + + + + V4L2_CID_ZOOM_ABSOLUTE  integer Specify the objective lens diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml index 63242e2..e6fbbc6 100644 --- a/Documentation/DocBook/media/v4l/v4l2.xml +++ b/Documentation/DocBook/media/v4l/v4l2.xml @@ -140,11 +140,18 @@ applications. --> 3.5 - 2012-04-02 + 2012-05-07 sa, sn 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. diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index a47b292..a5fbace 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -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; diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index a9b03ae..dc3e3ea 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -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) -- 2.7.4