v4l2-ctrls: add auto focus mode and controls
Subsystems (2)
v3 cover v4l2-ctrls: add auto focus mode and controls
Hello,
This is third version of RFC patch series about adding auto focus mode and controls. The patch of the previous version bring about the issue to be able to execute only once, not repeatedly. Because the each modes are defined by menu type. To solve this, we add the new control of choosing focus mode, and if doing repeatedly, it's alright that you determine the focus mode and change the value of V4L2_CID_FOCUS_AUTO.
In the case of new added rectangle mode, these each controls belongs to 4 new controls, can make to point by the form of rectangle. These 4 new each control values mean left x coordinate, top y coordinate, width x length, height y length. It's similar to structure v4l2_rect.
You can find previous threads about this:
http://www.spinics.net/lists/linux-media/msg29446.html
Thanks and Regards,
Heungjun Kim
RFC PATCH v3 1/2 v4l2-ctrls: support various modes and 4 coordinates of rectangle auto focus
It supports various modes of auto focus. Each modes define as the enumerations of menu type.
V4L2_FOCUS_AUTO_NORMAL, V4L2_FOCUS_AUTO_MACRO, V4L2_FOCUS_AUTO_CONTINUOUS, V4L2_FOCUS_AUTO_FACE_DETECTION, V4L2_FOCUS_AUTO_RECTANGLE
In the cause of rectangle it needs the 4 kinds of coordinate control ID of integer type for expression about focus-spot, and each control ID means similar to the struct v4l2_rect.
V4L2_CID_FOCUS_AUTO_RECTANGLE_LEFT
V4L2_CID_FOCUS_AUTO_RECTANGLE_TOP
V4L2_CID_FOCUS_AUTO_RECTANGLE_WIDTH
V4L2_CID_FOCUS_AUTO_RECTANGLE_HEIGHT
--- drivers/media/video/v4l2-ctrls.c | 16 ++++++++++++++++ include/linux/videodev2.h | 13 +++++++++++++ 2 files changed, 29 insertions(+), 0 deletions(-)
drivers/media/video/v4l2-ctrls.c +16 -0
@@ -197,6 +197,14 @@ const char * const *v4l2_ctrl_get_menu(u32 id)"Aperture Priority Mode" ,NULL }; +static const char *const camera_focus_auto_mode[] = { +"Normal Mode" , +"Macro Mode" , +"Continuous Mode" , +"Face Detection Mode" , +"Rectangle Mode" , +NULL + };static const char *const colorfx[] = {"None" , "Black & White",
@@ -252,6 +260,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_MODE : +return camera_focus_auto_mode;case V4L2_CID_COLORFX :return colorfx;case V4L2_CID_TUNE_PREEMPHASIS :
@@ -365,6 +375,11 @@ 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_FOCUS_AUTO_MODE :return "Focus, Mode" ; +case V4L2_CID_FOCUS_AUTO_RECTANGLE_LEFT :return "Focus, Rectangle Left" ; +case V4L2_CID_FOCUS_AUTO_RECTANGLE_TOP :return "Focus, Rectangle Top" ; +case V4L2_CID_FOCUS_AUTO_RECTANGLE_WIDTH :return "Focus, Rectangle Width" ; +case V4L2_CID_FOCUS_AUTO_RECTANGLE_HEIGHT :return "Focus, Rectangle Height" ;/* FM Radio Modulator control */ /* Keep the order of the 'case's the same as in videodev2.h! */
@@ -450,6 +465,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_MODE :case V4L2_CID_COLORFX :case V4L2_CID_TUNE_PREEMPHASIS : *type =V4L2_CTRL_TYPE_MENU ;
include/linux/videodev2.h +13 -0
@@ -1389,6 +1389,19 @@ 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_FOCUS_AUTO_MODE (V4L2_CID_CAMERA_CLASS_BASE+19) +enum v4l2_focus_mode_type { +V4L2_FOCUS_AUTO_NORMAL =0 , +V4L2_FOCUS_AUTO_MACRO =1 , +V4L2_FOCUS_AUTO_CONTINUOUS =2 , +V4L2_FOCUS_AUTO_FACE_DETECTION =3 , +V4L2_FOCUS_AUTO_RECTANGLE =4 +}; +#define V4L2_CID_FOCUS_AUTO_RECTANGLE_LEFT (V4L2_CID_CAMERA_CLASS_BASE+20) +#define V4L2_CID_FOCUS_AUTO_RECTANGLE_TOP (V4L2_CID_CAMERA_CLASS_BASE+21) +#define V4L2_CID_FOCUS_AUTO_RECTANGLE_WIDTH (V4L2_CID_CAMERA_CLASS_BASE+22) +#define V4L2_CID_FOCUS_AUTO_RECTANGLE_HEIGHT (V4L2_CID_CAMERA_CLASS_BASE+23) +/* 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)
Signature · 1 line
1.7.0.4
RFC PATCH v3 2/2 v4l2-ctrls: update auto focus mode documentation
In reply to Kim, HeungJunAs following to change the boolean type of V4L2_CID_FOCUS_AUTO to menu type, this uvc is modified the usage of V4L2_CID_FOCUS_AUTO.
--- Documentation/DocBook/v4l/controls.xml | 67 +++++++++++++++++++++++++++++ Documentation/DocBook/v4l/videodev2.h.xml | 8 +++ 2 files changed, 75 insertions(+), 0 deletions(-)
Documentation/DocBook/v4l/controls.xml +67 -0
@@ -1860,6 +1860,73 @@ it one step further. This is a write-only control.</entry> </row> <row><entry></entry></row> + <row id="v4l2-focus-auto-mode-type"> + <entry spanname="id"><constant>V4L2_CID_FOCUS_AUTO_MODE</constant> </entry> + <entry>enum v4l2_focus_auto_mode_type</entry> + </row><row><entry spanname="descr">Enables setting modes of +auto focus. The focus has 5 kinds of mode, and each enumerations express +current auto focus mode in which the camera is. In the case of +V4L2_FOCUS_AUTO_RECTANGLE, this control id can be clustered with +4 control id which means focusing spot expressed by 4 point of rectangle. + </entry> + </row> + <row> + <entrytbl spanname="descr" cols="2"> + <tbody valign="top"> + <row> + <entry><constant>V4L2_FOCUS_AUTO_NORMAL</constant> </entry> + <entry>Normal mode Auto focus, single shot.</entry> + </row> + <row> + <entry><constant>V4L2_FOCUS_AUTO_MACRO</constant> </entry> + <entry>Macro mode Auto focus, single shot.</entry> + </row> + <row> + <entry><constant>V4L2_FOCUS_AUTO_CONTINUOUS</constant> </entry> + <entry>Continuous mode Auto focus, continuous shot.</entry> + </row> + <row> + <entry><constant>V4L2_FOCUS_AUTO_FACE_DETECTION</constant> </entry> + <entry>Face detection mode Auto focus, single shot.</entry> + </row> + <row> + <entry><constant>V4L2_FOCUS_AUTO_RECTANGLE</constant> </entry> + <entry>Rectangle mode Auto focus, single shot.</entry> + </row> + </tbody> + </entrytbl> + </row> + <row><entry></entry></row> + + <row> + <entry spanname="id"><constant>V4L2_CID_FOCUS_AUTO_RECTANGLE_LEFT</constant> </entry> + <entry>integer</entry> + </row><row><entry spanname="descr">This control means the left +side's point of the rectangle expressing focusing spot.</entry> + </row> + <row><entry></entry></row> + + <entry spanname="id"><constant>V4L2_CID_FOCUS_AUTO_RECTANGLE_TOP</constant> </entry> + <entry>integer</entry> + </row><row><entry spanname="descr">This control means the top +side's point of the rectangle expressing focusing spot.</entry> + </row> + <row><entry></entry></row> + + <entry spanname="id"><constant>V4L2_CID_FOCUS_AUTO_RECTANGLE_WIDTH</constant> </entry> + <entry>integer</entry> + </row><row><entry spanname="descr">This control means the width +length of the rectangle expressing focusing spot.</entry> + </row> + <row><entry></entry></row> + + <entry spanname="id"><constant>V4L2_CID_FOCUS_AUTO_RECTANGLE_HEIGHT</constant> </entry> + <entry>integer</entry> + </row><row><entry spanname="descr">This control means the height +length of the rectangle expressing focusing spot.</entry> + </row> + <row><entry></entry></row> + <row> <entry spanname="id"><constant>V4L2_CID_PRIVACY</constant> </entry> <entry>boolean</entry>
Documentation/DocBook/v4l/videodev2.h.xml +8 -0
@@ -1385,6 +1385,14 @@ enum <link linkend="v4l2-exposure-auto-type">v4l2_exposure_auto_type</link> { #define V4L2_CID_IRIS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+17) #define V4L2_CID_IRIS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+18) +enum <link linkend="v4l2-focus-auto-mode-type">v4l2_focus_auto_mode_type</link> { + V4L2_FOCUS_AUTO_NORMAL = 0, + V4L2_FOCUS_AUTO_MACRO = 1, + V4L2_FOCUS_AUTO_CONTINUOUS = 2, + V4L2_FOCUS_AUTO_FACE_DETECTION = 3, + V4L2_FOCUS_AUTO_RECTANGLE = 4 +}; + /* 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)
Signature · 1 line
1.7.0.4
The comments of 2/2 patch are wrong. It's my fault. Please ignore this. And I'll send again. Sorry to confuse.
2011-03-22 오후 5:34, Kim, HeungJun 쓴 글:
Quoted 24 lines
Hello,
This is third version of RFC patch series about adding auto focus mode and controls. The patch of the previous version bring about the issue to be able to execute only once, not repeatedly. Because the each modes are defined by menu type. To solve this, we add the new control of choosing focus mode, and if doing repeatedly, it's alright that you determine the focus mode and change the value of
V4L2_CID_FOCUS_AUTO.In the case of new added rectangle mode, these each controls belongs to 4 new controls, can make to point by the form of rectangle. These 4 new each control values mean left x coordinate, top y coordinate, width x length, height y length. It's similar to structure
v4l2_rect.You can find previous threads about this:
http://www.spinics.net/lists/linux-media/msg29446.htmlThanks and Regards,
Heungjun Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html