From patchwork Sun Dec 4 15:16:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylwester Nawrocki X-Patchwork-Id: 8713 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1RXDo6-0005O6-Nz; Sun, 04 Dec 2011 16:16:47 +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 id 1RXDo5-0001eq-Hf; Sun, 04 Dec 2011 16:16:46 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754128Ab1LDPQm (ORCPT + 4 others); Sun, 4 Dec 2011 10:16:42 -0500 Received: from mail-ww0-f42.google.com ([74.125.82.42]:43962 "EHLO mail-ww0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754073Ab1LDPQl (ORCPT ); Sun, 4 Dec 2011 10:16:41 -0500 Received: by wgbds13 with SMTP id ds13so4912908wgb.1 for ; Sun, 04 Dec 2011 07:16:39 -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:in-reply-to:references; bh=6Vj36Ta2G5i4qJqGE7coinNumKDrfiAIYInnGYhZIG4=; b=lAyc0/JPmQTs/JcwcJnIAEtAElClDhXviC8Wr/kWkM1FNh9KXkU1n98dGyKON8J7Ox lK8SojKsljvXIYWvEzn/zR81YsfxCTnn9Oe1g3ChCy40B6YRnuz6bIL3CHFvCSaiRiur Q99V2wsIrU1aWbhq3b2dUWNn5LXOc7EtmRb2U= Received: by 10.180.4.167 with SMTP id l7mr8613641wil.51.1323011799662; Sun, 04 Dec 2011 07:16:39 -0800 (PST) Received: from localhost.localdomain (84-dzi-26.acn.waw.pl. [85.222.29.84]) by mx.google.com with ESMTPS id 28sm19857228wby.3.2011.12.04.07.16.37 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 04 Dec 2011 07:16:39 -0800 (PST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, sakari.ailus@iki.fi, hverkuil@xs4all.nl, riverful.kim@samsung.com, s.nawrocki@samsung.com, Sylwester Nawrocki , Kyungmin Park Subject: [RFC/PATCH 1/5] v4l: Convert V4L2_CID_FOCUS_AUTO control to a menu control Date: Sun, 4 Dec 2011 16:16:12 +0100 Message-Id: <1323011776-15967-2-git-send-email-snjw23@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1323011776-15967-1-git-send-email-snjw23@gmail.com> References: <1323011776-15967-1-git-send-email-snjw23@gmail.com> 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: 2011.12.4.150315 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' FORGED_FROM_GMAIL 0.1, MULTIPLE_RCPTS 0.1, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_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_WWW 0, __URI_NS ' X-LSpam-Score: -4.2 (----) X-LSpam-Report: No, score=-4.2 required=5.0 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, T_DKIM_INVALID=0.01 autolearn=ham Change the V4L2_CID_FOCUS_AUTO control type from boolean to a menu type. In case of boolean control we had values 0 and 1 corresponding to manual and automatic focus respectively. The V4L2_CID_FOCUS_AUTO menu control has currently following items: 0 - V4L2_FOCUS_MANUAL, 1 - V4L2_FOCUS_AUTO, 2 - V4L2_FOCUS_AUTO_MACRO, 3 - V4L2_FOCUS_AUTO_CONTINUOUS. To trigger single auto focus action in V4L2_FOCUS_AUTO mode the V4L2_DO_AUTO_FOCUS control can be used, which is also added in this patch. Signed-off-by: Heungjun Kim Signed-off-by: Kyungmin Park Signed-off-by: Sylwester Nawrocki --- Documentation/DocBook/media/v4l/controls.xml | 52 +++++++++++++++++++++++-- drivers/media/video/v4l2-ctrls.c | 13 ++++++- include/linux/videodev2.h | 8 ++++ 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml index 3bc5ee8..5ccb0b0 100644 --- a/Documentation/DocBook/media/v4l/controls.xml +++ b/Documentation/DocBook/media/v4l/controls.xml @@ -2782,12 +2782,54 @@ 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 -is enabled is undefined, drivers should ignore such requests. + enum v4l2_focus_auto_type + Determines the camera +focus mode. The effect of manual focus adjustments while +V4L2_CID_FOCUS_AUTO is not set to +V4L2_FOCUS_MANUAL is undefined, drivers should ignore such +requests. + + + + + + V4L2_FOCUS_MANUAL  + Manual focus. + + + V4L2_FOCUS_AUTO  + Single shot auto focus. When switched to +this mode the camera focuses on a subject just once. +V4L2_CID_DO_AUTO_FOCUS control can be used to manually +invoke auto focusing. + + + V4L2_FOCUS_AUTO_MACRO  + Macro (close-up) auto focus. Usually camera +auto focus algorithms do not attempt to focus on a subject that is +closer than a given distance. This mode can be used to tell the camera +to use minimum distance for focus that it is capable of. + + + V4L2_FOCUS_AUTO_CONTINUOUS  + Continuous auto focus. When switched to this +mode the camera continually adjusts focus. + + + + + + + + V4L2_CID_DO_AUTO_FOCUS  + button + When this control is set +the camera will perform one shot auto focus. The effect of using this +control when V4L2_CID_FOCUS_AUTO is in mode +different than V4L2_FOCUS_AUTO is undefined, +drivers should ignore such requests. diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 0f415da..7d8862f 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -221,6 +221,13 @@ const char * const *v4l2_ctrl_get_menu(u32 id) "Aperture Priority Mode", NULL }; + static const char * const camera_focus_auto[] = { + "Manual Focus", + "One-shot Auto Focus", + "Macro Auto Focus", + "Continuous Auto Focus", + NULL + }; static const char * const colorfx[] = { "None", "Black & White", @@ -388,6 +395,8 @@ 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_FOCUS_AUTO: + return camera_focus_auto; case V4L2_CID_COLORFX: return colorfx; case V4L2_CID_TUNE_PREEMPHASIS: @@ -567,6 +576,7 @@ const char *v4l2_ctrl_get_name(u32 id) 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_DO_AUTO_FOCUS: return "Do Auto Focus"; /* FM Radio Modulator control */ /* Keep the order of the 'case's the same as in videodev2.h! */ @@ -633,7 +643,6 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: case V4L2_CID_MPEG_VIDEO_PULLDOWN: case V4L2_CID_EXPOSURE_AUTO_PRIORITY: - case V4L2_CID_FOCUS_AUTO: case V4L2_CID_PRIVACY: case V4L2_CID_AUDIO_LIMITER_ENABLED: case V4L2_CID_AUDIO_COMPRESSION_ENABLED: @@ -658,6 +667,7 @@ 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_DO_AUTO_FOCUS: *type = V4L2_CTRL_TYPE_BUTTON; *flags |= V4L2_CTRL_FLAG_WRITE_ONLY; *min = *max = *step = *def = 0; @@ -679,6 +689,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_FOCUS_AUTO: case V4L2_CID_COLORFX: case V4L2_CID_TUNE_PREEMPHASIS: case V4L2_CID_FLASH_LED_MODE: diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 4b752d5..9acb514 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -1608,6 +1608,12 @@ enum v4l2_exposure_auto_type { #define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+10) #define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11) #define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12) +enum v4l2_focus_auto_type { + V4L2_FOCUS_MANUAL = 0, + V4L2_FOCUS_AUTO = 1, + V4L2_FOCUS_AUTO_MACRO = 2, + V4L2_FOCUS_AUTO_CONTINUOUS = 3, +}; #define V4L2_CID_ZOOM_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+13) #define V4L2_CID_ZOOM_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+14) @@ -1618,6 +1624,8 @@ 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_DO_AUTO_FOCUS (V4L2_CID_CAMERA_CLASS_BASE+19) + /* 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)