Skip to contentSkip to conversation

v4l2-ctrls: modify uvc driver to use new menu type of V4L2_CID_FOCUS_AUTO

RFC PATCH Superseded Kim, HeungJun 2 participants 5 messages Feb 25, 2011 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

RFC PATCH v2 2/3 v4l2-ctrls: modify uvc driver to use new menu type of V4L2_CID_FOCUS_AUTO

As 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.

---
 drivers/media/video/uvc/uvc_ctrl.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
drivers/media/video/uvc/uvc_ctrl.c +10 -3
index 59f8a9a..795fd3f 100644
@@ -333,6 +333,11 @@ static struct uvc_menu_info exposure_auto_controls[] = {
 	{ 8, "Aperture Priority Mode" },
 };
 
+static struct uvc_menu_info focus_auto_controls[] = {
+	{ 2, "Auto Mode" },
+	{ 1, "Manual Mode" },
+};
+
 static __s32 uvc_ctrl_get_zoom(struct uvc_control_mapping *mapping,
 	__u8 query, const __u8 *data)
 {
@@ -558,10 +563,12 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
 		.name		= "Focus, Auto",
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_FOCUS_AUTO_CONTROL,
-		.size		= 1,
+		.size		= 2,
 		.offset		= 0,
-		.v4l2_type	= V4L2_CTRL_TYPE_BOOLEAN,
-		.data_type	= UVC_CTRL_DATA_TYPE_BOOLEAN,
+		.v4l2_type	= V4L2_CTRL_TYPE_MENU,
+		.data_type	= UVC_CTRL_DATA_TYPE_BITMASK,
+		.menu_info	= focus_auto_controls,
+		.menu_count	= ARRAY_SIZE(focus_auto_controls),
 	},
 	{
 		.id		= V4L2_CID_IRIS_ABSOLUTE,
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 14 lines · HeungJun

As 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.

---
 drivers/media/video/uvc/uvc_ctrl.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/media/video/uvc/uvc_ctrl.c index 59f8a9a..795fd3f 100644

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_menu_info exposure_auto_controls[] = · line 338

Quoted 6 lines
drivers/media/video/uvc/uvc_ctrl.c +3 -0
@@ -333,6 +333,11 @@ static struct uvc_menu_info exposure_auto_controls[] =
 { { 8, "Aperture Priority Mode" },
 };
 
+static struct uvc_menu_info focus_auto_controls[] = {
+	{ 2, "Auto Mode" },
+	{ 1, "Manual Mode" },

According to the UVC spec, this should be 0 for manual mode and 1 for auto mode.

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_control_mapping uvc_ctrl_mappings[] · line 566

Quoted 11 lines
drivers/media/video/uvc/uvc_ctrl.c +3 -1
+};
+
 static __s32 uvc_ctrl_get_zoom(struct uvc_control_mapping *mapping,
 	__u8 query, const __u8 *data)
 {
@@ -558,10 +563,12 @@ static struct uvc_control_mapping uvc_ctrl_mappings[]
 = { .name		= "Focus, Auto",
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_FOCUS_AUTO_CONTROL,
-		.size		= 1,
+		.size		= 2,

Why do you change the control size ?

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_control_mapping uvc_ctrl_mappings[] = { · line 569

Quoted 5 lines
drivers/media/video/uvc/uvc_ctrl.c +2 -2
 		.offset		= 0,
-		.v4l2_type	= V4L2_CTRL_TYPE_BOOLEAN,
-		.data_type	= UVC_CTRL_DATA_TYPE_BOOLEAN,
+		.v4l2_type	= V4L2_CTRL_TYPE_MENU,
+		.data_type	= UVC_CTRL_DATA_TYPE_BITMASK,

The UVC control is still a boolean.

Quoted 5 lines
drivers/media/video/uvc/uvc_ctrl.c +2 -0
+		.menu_info	= focus_auto_controls,
+		.menu_count	= ARRAY_SIZE(focus_auto_controls),
 	},
 	{
 		.id		= V4L2_CID_IRIS_ABSOLUTE,
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw

Hi Laurent,

2011-02-25 오후 6:20, Laurent Pinchart 쓴 글:

Quoted 18 lines · HeungJun
Quoted 17 lines

As 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.

---
 drivers/media/video/uvc/uvc_ctrl.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/media/video/uvc/uvc_ctrl.c index 59f8a9a..795fd3f 100644

drivers/media/video/uvc/uvc_ctrl.c +0 -0
@@ -333,6 +333,11 @@ static struct uvc_menu_info exposure_auto_controls[] =
 { { 8, "Aperture Priority Mode" },
 };
 
Quoted 6 lines

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_menu_info exposure_auto_controls[] = { · line 338

Quoted 3 lines
drivers/media/video/uvc/uvc_ctrl.c +3 -0
+static struct uvc_menu_info focus_auto_controls[] = {
+	{ 2, "Auto Mode" },
+	{ 1, "Manual Mode" },

According to the UVC spec, this should be 0 for manual mode and 1 for auto mode.

OK, I'll modify this values depends on below my question......

Quoted 15 lines

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_control_mapping uvc_ctrl_mappings[] · line 566

Quoted 12 lines
drivers/media/video/uvc/uvc_ctrl.c +3 -1
+};
+
 static __s32 uvc_ctrl_get_zoom(struct uvc_control_mapping *mapping,
 	__u8 query, const __u8 *data)
 {
@@ -558,10 +563,12 @@ static struct uvc_control_mapping uvc_ctrl_mappings[]
 = { .name		= "Focus, Auto",
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_FOCUS_AUTO_CONTROL,
-		.size		= 1,
+		.size		= 2,

Why do you change the control size ?

Quoted 7 lines

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_control_mapping uvc_ctrl_mappings[] = { · line 569

Quoted 5 lines
drivers/media/video/uvc/uvc_ctrl.c +2 -2
 		.offset		= 0,
-		.v4l2_type	= V4L2_CTRL_TYPE_BOOLEAN,
-		.data_type	= UVC_CTRL_DATA_TYPE_BOOLEAN,
+		.v4l2_type	= V4L2_CTRL_TYPE_MENU,
+		.data_type	= UVC_CTRL_DATA_TYPE_BITMASK,

The UVC control is still a boolean.

You're saying that, the control size should be 1 because it's right to maintain the boolean type, So, then, the uvc driver dosen't needed to be changed. is it right?

Thanks for the reviews, and I'll wait answer.

Regards,
Heungjun KIm

#3 lore raw

Hi,

Quoted 59 lines · HeungJun

2011-02-25 오후 6:20, Laurent Pinchart 쓴 글:

Quoted 18 lines · HeungJun
Quoted 17 lines

As 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.

---

 drivers/media/video/uvc/uvc_ctrl.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/media/video/uvc/uvc_ctrl.c index 59f8a9a..795fd3f 100644

drivers/media/video/uvc/uvc_ctrl.c +0 -0
@@ -333,6 +333,11 @@ static struct uvc_menu_info
 exposure_auto_controls[] = { { 8, "Aperture Priority Mode" },
 
Quoted 8 lines

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_menu_info exposure_auto_controls[] = { · line 338

Quoted 5 lines
drivers/media/video/uvc/uvc_ctrl.c +3 -0
 };
 
+static struct uvc_menu_info focus_auto_controls[] = {
+	{ 2, "Auto Mode" },
+	{ 1, "Manual Mode" },

According to the UVC spec, this should be 0 for manual mode and 1 for auto mode.

OK, I'll modify this values depends on below my question......

Quoted 20 lines
Quoted 10 lines
drivers/media/video/uvc/uvc_ctrl.c +2 -0
+};
+
 
 static __s32 uvc_ctrl_get_zoom(struct uvc_control_mapping *mapping,
drivers/media/video/uvc/uvc_ctrl.c +0 -0
 	__u8 query, const __u8 *data)
 
 {

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_control_mapping · line 568

Quoted 7 lines
drivers/media/video/uvc/uvc_ctrl.c +1 -1
@@ -558,10 +563,12 @@ static struct uvc_control_mapping
 uvc_ctrl_mappings[] = { .name		= "Focus, Auto",
 
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_FOCUS_AUTO_CONTROL,
 
-		.size		= 1,
+		.size		= 2,

Why do you change the control size ?

Quoted 8 lines

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_control_mapping uvc_ctrl_mappings[] = { · line 569

Quoted 6 lines
drivers/media/video/uvc/uvc_ctrl.c +2 -2
 		.offset		= 0,
 
-		.v4l2_type	= V4L2_CTRL_TYPE_BOOLEAN,
-		.data_type	= UVC_CTRL_DATA_TYPE_BOOLEAN,
+		.v4l2_type	= V4L2_CTRL_TYPE_MENU,
+		.data_type	= UVC_CTRL_DATA_TYPE_BITMASK,

The UVC control is still a boolean.

Quoted 3 lines

You're saying that, the control size should be 1 because it's right to maintain the boolean type, So, then, the uvc driver dosen't needed to be changed. is it right?

You still need to change v4l2_type from V4L2_CTRL_TYPE_BOOLEAN to V4L2_CTRL_TYPE_MENU, and add the menu entries. I don't see a need to change anything else.

Signature · 3 lines
Regards,

Laurent Pinchart
#4 lore raw

2011-02-25 오후 7:25, Laurent Pinchart 쓴 글:

Quoted 62 lines

Hi,

Quoted 59 lines · HeungJun

2011-02-25 오후 6:20, Laurent Pinchart 쓴 글:

Quoted 18 lines · HeungJun
Quoted 17 lines

As 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.

---

 drivers/media/video/uvc/uvc_ctrl.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/media/video/uvc/uvc_ctrl.c index 59f8a9a..795fd3f 100644

drivers/media/video/uvc/uvc_ctrl.c +0 -0
@@ -333,6 +333,11 @@ static struct uvc_menu_info
 exposure_auto_controls[] = { { 8, "Aperture Priority Mode" },
 
Quoted 8 lines

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_menu_info exposure_auto_controls[] = { · line 338

Quoted 5 lines
drivers/media/video/uvc/uvc_ctrl.c +3 -0
 };
 
+static struct uvc_menu_info focus_auto_controls[] = {
+	{ 2, "Auto Mode" },
+	{ 1, "Manual Mode" },

According to the UVC spec, this should be 0 for manual mode and 1 for auto mode.

OK, I'll modify this values depends on below my question......

Quoted 28 lines
Quoted 10 lines
drivers/media/video/uvc/uvc_ctrl.c +2 -0
+};
+
 
 static __s32 uvc_ctrl_get_zoom(struct uvc_control_mapping *mapping,
drivers/media/video/uvc/uvc_ctrl.c +0 -0
 	__u8 query, const __u8 *data)
 
 {

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_control_mapping · line 568

Quoted 7 lines
drivers/media/video/uvc/uvc_ctrl.c +1 -1
@@ -558,10 +563,12 @@ static struct uvc_control_mapping
 uvc_ctrl_mappings[] = { .name		= "Focus, Auto",
 
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_FOCUS_AUTO_CONTROL,
 
-		.size		= 1,
+		.size		= 2,

Why do you change the control size ?

drivers/media/video/uvc/uvc_ctrl.c static struct uvc_control_mapping uvc_ctrl_mappings[] = { · line 569

Quoted 6 lines
drivers/media/video/uvc/uvc_ctrl.c +2 -2
 		.offset		= 0,
 
-		.v4l2_type	= V4L2_CTRL_TYPE_BOOLEAN,
-		.data_type	= UVC_CTRL_DATA_TYPE_BOOLEAN,
+		.v4l2_type	= V4L2_CTRL_TYPE_MENU,
+		.data_type	= UVC_CTRL_DATA_TYPE_BITMASK,

The UVC control is still a boolean.

Quoted 8 lines
Quoted 3 lines

You're saying that, the control size should be 1 because it's right to maintain the boolean type, So, then, the uvc driver dosen't needed to be changed. is it right?

You still need to change v4l2_type from V4L2_CTRL_TYPE_BOOLEAN to V4L2_CTRL_TYPE_MENU, and add the menu entries. I don't see a need to change anything else.

Ah ok. I I confused a little. Thanks for the good catch.

Together focus name patch, I'll re-send patch.

Regards,
Heungjun Kim