From patchwork Mon Jan 16 21:33:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylwester Nawrocki X-Patchwork-Id: 9547 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1RmuBq-0001bx-Br for patchwork@linuxtv.org; Mon, 16 Jan 2012 22:34:06 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-2) with esmtp for id 1RmuBp-0000qK-Gr; Mon, 16 Jan 2012 22:34:06 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756878Ab2APVeC (ORCPT ); Mon, 16 Jan 2012 16:34:02 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:40435 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756621Ab2APVeA (ORCPT ); Mon, 16 Jan 2012 16:34:00 -0500 Received: by eaac11 with SMTP id c11so348726eaa.19 for ; Mon, 16 Jan 2012 13:33:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=jLkfa99vVxNxxBUZIDzQp6tobL/lzyiXFPjch2PX5L8=; b=f70yUBqpS3hnT+uhG54MVis28BMgLHBu4+MupCdGlqm+zQn3oIuKPgmu7INA9ne/hI Uia7sBWfwWqkcxcCIlNUHo6WIh9lDnRgGMV6ZowhVnvQfd2l4hNnIK3v5sz16gZzbtKz egGFSofQEuwbdJj54QnLxNwbybRY+rpbZwahw= Received: by 10.213.6.206 with SMTP id a14mr4102325eba.75.1326749639175; Mon, 16 Jan 2012 13:33:59 -0800 (PST) Received: from localhost.localdomain (62-121-66-78.home.aster.pl. [62.121.66.78]) by mx.google.com with ESMTPS id n17sm2037310eei.3.2012.01.16.13.33.56 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jan 2012 13:33:58 -0800 (PST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: Hans Verkuil , Laurent Pinchart , Sakari Ailus , Sylwester Nawrocki Subject: [PATCH/RFC][DRAFT] V4L: Add camera auto focus controls Date: Mon, 16 Jan 2012 22:33:42 +0100 Message-Id: <1326749622-11446-1-git-send-email-sylvester.nawrocki@gmail.com> X-Mailer: git-send-email 1.7.4.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.16.212115 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' FORGED_FROM_GMAIL 0.1, MULTIPLE_RCPTS 0.1, BODY_SIZE_10000_PLUS 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_PATH 0, __URI_NO_WWW 0, __URI_NS ' The following auto focus controls are added: - V4L2_CID_AUTO_FOCUS_START - one-shot auto focus start - V4L2_CID_AUTO_FOCUS_STOP - one-shot auto focus start - V4L2_CID_AUTO_FOCUS_STATUS - auto focus status - V4L2_CID_AUTO_FOCUS_DISTANCE - auto focus scan reange selection - V4L2_CID_AUTO_FOCUS_SELECTION - auto focus area selection - V4L2_CID_AUTO_FOCUS_X_POSITION - horizontal AF spot position - V4L2_CID_AUTO_FOCUS_Y_POSITION - vertical AF spot position - V4L2_CID_AUTO_FOCUS_RECTANGLE_COUNT - number of AF statistics rectangles - V4L2_CID_AUTO_FOCUS_FACE_PRIORITY - enable/disable face priority auto focus Signed-off-by: Sylwester Nawrocki --- Hello, This is a draft of new Auto Focus controls, it incorporates comments from the previous discussions. I decided to drop the idea of of new pixel point control type for AF spot configuration, as the benefits from having it are minor comparing to the implementation efforts. Thanks, Sylwester --- Documentation/DocBook/media/v4l/controls.xml | 172 +++++++++++++++++++++++++- drivers/media/video/v4l2-ctrls.c | 44 +++++++- include/linux/videodev2.h | 28 ++++ 3 files changed, 241 insertions(+), 3 deletions(-) -- 1.7.4.1 -- 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 diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml index a1be378..1a5e90f 100644 --- a/Documentation/DocBook/media/v4l/controls.xml +++ b/Documentation/DocBook/media/v4l/controls.xml @@ -2798,13 +2798,181 @@ 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 + Start single auto focus action. +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 + Abort automatic focus started with +V4L2_CID_AUTO_FOCUS_START. This control is effective only +when the continuous automatic focus is disabled, i.e. +V4L2_CID_FOCUS_AUTO control is set to FALSE +(0). + + + + + + V4L2_CID_AUTO_FOCUS_STATUS  + enum v4l2_auto_focus_status + + The automatic focus status. This is a read-only + control. + + + + + + V4L2_AUTO_FOCUS_STATUS_IDLE  + Automatic focus is inactive. + + + V4L2_AUTO_FOCUS_STATUS_BUSY  + Automatic focusing is in progress and the focus is changing. + + + V4L2_AUTO_FOCUS_STATUS_SUCCESS  + Automatic focus has completed or is continued successfully. + + + V4L2_AUTO_FOCUS_STATUS_FAIL  + Automatic focus has failed. + + + + + + + + + V4L2_CID_AUTO_FOCUS_DISTANCE  + enum v4l2_auto_focus_distance + + The automatic focus distance range +for which lens may be adjusted. + + + + + + V4L2_AUTO_FOCUS_DISTANCE_NORMAL  + The normal distance range of the camera. It is limited +in order to achieve best auto focus performance. + + + V4L2_AUTO_FOCUS_DISTANCE_MACRO  + Macro (close-up) auto focus distance range. The camera +uses minimum possible distance, that it is capable of, for automatic focus. + + + V4L2_AUTO_FOCUS_DISTANCE_INFINITY  + The camera is focused permanently at its farthest +possible distance. This option is only supported by drivers that do not expose +V4L2_CID_FOCUS_ABSOLUTE control. + + + + + + + + + V4L2_CID_AUTO_FOCUS_SELECTION  + enum v4l2_auto_focus_selection + + This control determines which parts +of an image frame are used for the auto focus statistics computation. It is +valid for one-shot and continuous automatic focus. The effect of setting +this control when V4L2_CID_AUTO_FOCUS_FACE_PRIORITY +is set to TRUE(1) is undefined, drivers should ignore +such requests. + + + + + + V4L2_AUTO_FOCUS_SELECTION_NORMAL  + Normal auto focus where an entire frame is used for +the statistics computation. + + + V4L2_AUTO_FOCUS_SELECTION_SPOT  + Focus on object within a frame specified by coordinates +passed with V4L2_CID_AUTO_FOCUS_X_POSITION and +V4L2_CID_AUTO_FOCUS_Y_POSITION controls. When these controls are not +available the default point position is the center of a frame. + + + V4L2_AUTO_FOCUS_SELECTION_RECTANGLE  + The focus area is determined by one or more rectangles +specified by means of the selection API. For more details on the windows selection +see the V4L2_SELECTION_STAT_AF and +V4L2_SUBDEV_SELECTION_STAT_AF selection targets description. The +V4L2_CID_AUTO_FOCUS_RECTANGLE_COUNT control allows to +determine an overall number of the selection rectangles. + + + + + + + + V4L2_CID_AUTO_FOCUS_X_POSITION +   + integer + Determine position of the spot +in horizontal direction for V4L2_AUTO_FOCUS_SELECTION_SPOT +auto focus. The unit is 1 pixel. + + + + + V4L2_CID_AUTO_FOCUS_Y_POSITION +   + integer + Determine position of the spot +in verical direction for V4L2_AUTO_FOCUS_SELECTION_SPOT +auto focus. The unit is 1 pixel. + + + + + V4L2_CID_AUTO_FOCUS_RECTANGLE_COUNT +   + integer + Specify number of the automatic +focus statistics rectangles. + + + + + V4L2_CID_AUTO_FOCUS_FACE_PRIORITY +   + boolean + Enable or disable face priority +auto focus where the camera focus is driven by a face detection engine. +When this control is set to TRUE (1) the +V4L2_CID_AUTO_FOCUS_SELECTION control, if present, will be reset +to V4L2_AUTO_FOCUS_SELECTION_NORMAL by the driver. + + + + + V4L2_CID_ZOOM_ABSOLUTE  integer Specify the objective lens diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index da1f4c2..59afd60 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -221,6 +221,26 @@ const char * const *v4l2_ctrl_get_menu(u32 id) "Aperture Priority Mode", NULL }; + static const char * const camera_auto_focus_mode[] = { + "Auto Focus, Selection Normal", + "Auto Focus, Selection Spot", + "Auto Focus, Selection Rectangle", + NULL + }; + static const char * const camera_auto_focus_status[] = { + "Auto Focus Status, Idle", + "Auto Focus Status, Busy", + "Auto Focus Status, Success", + "Auto Focus Status, Fail", + NULL + }; + static const char * const camera_auto_focus_distance[] = { + "Auto Focus Distance, Normal", + "Auto Focus Distance, Macro", + "Auto Focus Distance, Infinity", + NULL + }; + static const char * const colorfx[] = { "None", "Black & White", @@ -388,6 +408,12 @@ const char * const *v4l2_ctrl_get_menu(u32 id) return camera_power_line_frequency; case V4L2_CID_EXPOSURE_AUTO: return camera_exposure_auto; + case V4L2_CID_AUTO_FOCUS_MODE: + return camera_auto_focus_mode; + case V4L2_CID_AUTO_FOCUS_DISTANCE: + return camera_auto_focus_distance; + case V4L2_CID_AUTO_FOCUS_STATUS: + return camera_auto_focus_status; case V4L2_CID_COLORFX: return colorfx; case V4L2_CID_TUNE_PREEMPHASIS: @@ -561,13 +587,22 @@ 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"; case V4L2_CID_PRIVACY: return "Privacy"; case V4L2_CID_IRIS_ABSOLUTE: return "Iris, Absolute"; case V4L2_CID_IRIS_RELATIVE: return "Iris, Relative"; + 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_DISTANCE: return "Auto Focus, Distance"; + case V4L2_CID_AUTO_FOCUS_SELECTION: return "Auto Focus, Selection"; + case V4L2_CID_AUTO_FOCUS_X_POSITION: return "Auto Focus, Position X"; + case V4L2_CID_AUTO_FOCUS_Y_POSITION: return "Auto Focus, Position Y"; + case V4L2_CID_AUTO_FOCUS_RECTANGLE_COUNT: return "Auto Focus, Rectangles Count"; + case V4L2_CID_AUTO_FOCUS_FACE_PRIORITY: return "Auto Focus, Face Priority"; /* FM Radio Modulator control */ /* Keep the order of the 'case's the same as in videodev2.h! */ @@ -635,6 +670,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_VIDEO_PULLDOWN: case V4L2_CID_EXPOSURE_AUTO_PRIORITY: case V4L2_CID_FOCUS_AUTO: + case V4L2_CID_AUTO_FOCUS_FACE_PRIORITY: case V4L2_CID_PRIVACY: case V4L2_CID_AUDIO_LIMITER_ENABLED: case V4L2_CID_AUDIO_COMPRESSION_ENABLED: @@ -659,6 +695,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; @@ -680,6 +718,9 @@ 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_MODE: + case V4L2_CID_AUTO_FOCUS_DISTANCE: + case V4L2_CID_AUTO_FOCUS_STATUS: case V4L2_CID_COLORFX: case V4L2_CID_TUNE_PREEMPHASIS: case V4L2_CID_FLASH_LED_MODE: @@ -770,6 +811,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 012a296..0808b12 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -1662,6 +1662,34 @@ enum v4l2_exposure_auto_type { #define V4L2_CID_IRIS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+17) #define V4L2_CID_IRIS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+18) +#define V4L2_CID_AUTO_FOCUS_START (V4L2_CID_CAMERA_CLASS_BASE+19) +#define V4L2_CID_AUTO_FOCUS_STOP (V4L2_CID_CAMERA_CLASS_BASE+20) +#define V4L2_CID_AUTO_FOCUS_STATUS (V4L2_CID_CAMERA_CLASS_BASE+21) +enum v4l2_auto_focus_status { + V4L2_AUTO_FOCUS_STATUS_IDLE = 0, + V4L2_AUTO_FOCUS_STATUS_BUSY = 1, + V4L2_AUTO_FOCUS_STATUS_SUCCESS = 2, + V4L2_AUTO_FOCUS_STATUS_FAIL = 3, +}; + +#define V4L2_CID_AUTO_FOCUS_DISTANCE (V4L2_CID_CAMERA_CLASS_BASE+22) +enum v4l2_auto_focus_distance { + V4L2_AUTO_FOCUS_DISTANCE_NORMAL = 0, + V4L2_AUTO_FOCUS_DISTANCE_MACRO = 1, + V4L2_AUTO_FOCUS_DISTANCE_INFINITY = 2, +}; + +#define V4L2_CID_AUTO_FOCUS_SELECTION (V4L2_CID_CAMERA_CLASS_BASE+23) +enum v4l2_auto_focus_selection { + V4L2_AUTO_FOCUS_SELECTION_NORMAL = 0, + V4L2_AUTO_FOCUS_SELECTION_SPOT = 1, + V4L2_AUTO_FOCUS_SELECTION_RECTANGLE = 2, +}; +#define V4L2_CID_AUTO_FOCUS_X_POSITION (V4L2_CID_CAMERA_CLASS_BASE+24) +#define V4L2_CID_AUTO_FOCUS_Y_POSITION (V4L2_CID_CAMERA_CLASS_BASE+25) +#define V4L2_CID_AUTO_FOCUS_RECTANGLE_COUNT (V4L2_CID_CAMERA_CLASS_BASE+26) +#define V4L2_CID_AUTO_FOCUS_FACE_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE+27) + /* 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)