Laurent,
so it seems you are quite busy at the moment so I hacked the driver to
use v4l2_ctrl_get_name (patch attached)
I've tested the on a 2.6.31 kernel and it seems to be working OK, I
just remove the hardcoded name strings from uvc_ctrl_mappings and add
them back using  v4l2_ctrl_get_name in uvc_ctrl_init.
Don't know if this is enought but like I said everything seems to be
working as expexted.

Best regards,
Paulo

2009/9/18 Laurent Pinchart <[email protected]>:
> Hi Paulo,
>
> On Sunday 13 September 2009 15:32:20 Paulo Assis wrote:
>> Hi,
>> Currently, uvc driver and I guess all other v4l2 video drivers use
>> internal stored control strings.
>> This poses a problem when adding localization for this strings, since
>> they can change between drivers.
>> Even if driver developers are careful enough to return the same string
>> for the correspondent control ID, a slight difference: Brightness or
>> brightness is enough for a failed translation.
>> Since the control ID's are defined in the V4L2 API is there any
>> special reason why the correspondent control strings are not.
>> I may be failing to see this correctly but at least for me it seems
>> much logical that if all standard control IDs are already defined
>> there, then also the name string should be made available through this
>> central public API, making it exactly the same for all drivers.
>>
>> If I'm wrong please feel free to shut me up, and kick me in the but. :-)
>
> You're right, and there's already such a central public API. Have a look at
> v4l2_ctrl_get_name in drivers/media/video/v4l2-common.c.
>
> I'll try to switch the uvcvideo driver to v4l2_ctrl_get_name when I'll find
> some free time.
>
> --
> Regards,
>
> Laurent Pinchart
>
diff -rupN uvcvideo-756ad91a832e/linux/drivers/media/video/uvc/uvc_ctrl.c uvcvideo/linux/drivers/media/video/uvc/uvc_ctrl.c
--- uvcvideo-756ad91a832e/linux/drivers/media/video/uvc/uvc_ctrl.c	2009-09-02 07:12:26.000000000 +0100
+++ uvcvideo/linux/drivers/media/video/uvc/uvc_ctrl.c	2009-10-09 22:06:23.320462093 +0100
@@ -22,6 +22,7 @@
 #include <linux/vmalloc.h>
 #include <linux/wait.h>
 #include <asm/atomic.h>
+#include <media/v4l2-common.h>
 
 #include "uvcvideo.h"
 
@@ -356,7 +357,7 @@ static void uvc_ctrl_set_zoom(struct uvc
 static struct uvc_control_mapping uvc_ctrl_mappings[] = {
 	{
 		.id		= V4L2_CID_BRIGHTNESS,
-		.name		= "Brightness",
+		//.name		= "Brightness",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_BRIGHTNESS_CONTROL,
 		.size		= 16,
@@ -366,7 +367,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_CONTRAST,
-		.name		= "Contrast",
+		//.name		= "Contrast",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_CONTRAST_CONTROL,
 		.size		= 16,
@@ -376,7 +377,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_HUE,
-		.name		= "Hue",
+		//.name		= "Hue",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_HUE_CONTROL,
 		.size		= 16,
@@ -386,7 +387,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_SATURATION,
-		.name		= "Saturation",
+		//.name		= "Saturation",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_SATURATION_CONTROL,
 		.size		= 16,
@@ -396,7 +397,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_SHARPNESS,
-		.name		= "Sharpness",
+		//.name		= "Sharpness",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_SHARPNESS_CONTROL,
 		.size		= 16,
@@ -406,7 +407,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_GAMMA,
-		.name		= "Gamma",
+		//.name		= "Gamma",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_GAMMA_CONTROL,
 		.size		= 16,
@@ -416,7 +417,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_BACKLIGHT_COMPENSATION,
-		.name		= "Backlight Compensation",
+		//.name		= "Backlight Compensation",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_BACKLIGHT_COMPENSATION_CONTROL,
 		.size		= 16,
@@ -426,7 +427,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_GAIN,
-		.name		= "Gain",
+		//.name		= "Gain",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_GAIN_CONTROL,
 		.size		= 16,
@@ -436,7 +437,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_POWER_LINE_FREQUENCY,
-		.name		= "Power Line Frequency",
+		//.name		= "Power Line Frequency",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
 		.size		= 2,
@@ -448,7 +449,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_HUE_AUTO,
-		.name		= "Hue, Auto",
+		//.name		= "Hue, Auto",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_HUE_AUTO_CONTROL,
 		.size		= 1,
@@ -458,7 +459,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_EXPOSURE_AUTO,
-		.name		= "Exposure, Auto",
+		//.name		= "Exposure, Auto",
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_AE_MODE_CONTROL,
 		.size		= 4,
@@ -470,7 +471,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_EXPOSURE_AUTO_PRIORITY,
-		.name		= "Exposure, Auto Priority",
+		//.name		= "Exposure, Auto Priority",
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_AE_PRIORITY_CONTROL,
 		.size		= 1,
@@ -480,7 +481,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_EXPOSURE_ABSOLUTE,
-		.name		= "Exposure (Absolute)",
+		//.name		= "Exposure (Absolute)",
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL,
 		.size		= 32,
@@ -490,7 +491,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_AUTO_WHITE_BALANCE,
-		.name		= "White Balance Temperature, Auto",
+		//.name		= "White Balance Temperature, Auto",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL,
 		.size		= 1,
@@ -500,7 +501,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_WHITE_BALANCE_TEMPERATURE,
-		.name		= "White Balance Temperature",
+		//.name		= "White Balance Temperature",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL,
 		.size		= 16,
@@ -510,7 +511,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_AUTO_WHITE_BALANCE,
-		.name		= "White Balance Component, Auto",
+		//.name		= "White Balance Component, Auto",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL,
 		.size		= 1,
@@ -520,7 +521,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_BLUE_BALANCE,
-		.name		= "White Balance Blue Component",
+		//.name		= "White Balance Blue Component",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL,
 		.size		= 16,
@@ -530,7 +531,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_RED_BALANCE,
-		.name		= "White Balance Red Component",
+		//.name		= "White Balance Red Component",
 		.entity		= UVC_GUID_UVC_PROCESSING,
 		.selector	= UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL,
 		.size		= 16,
@@ -540,7 +541,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_FOCUS_ABSOLUTE,
-		.name		= "Focus (absolute)",
+		//.name		= "Focus (absolute)",
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_FOCUS_ABSOLUTE_CONTROL,
 		.size		= 16,
@@ -550,7 +551,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_FOCUS_AUTO,
-		.name		= "Focus, Auto",
+		//.name		= "Focus, Auto",
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_FOCUS_AUTO_CONTROL,
 		.size		= 1,
@@ -560,7 +561,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_ZOOM_ABSOLUTE,
-		.name		= "Zoom, Absolute",
+		//.name		= "Zoom, Absolute",
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_ZOOM_ABSOLUTE_CONTROL,
 		.size		= 16,
@@ -570,7 +571,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_ZOOM_CONTINUOUS,
-		.name		= "Zoom, Continuous",
+		//.name		= "Zoom, Continuous",
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_ZOOM_RELATIVE_CONTROL,
 		.size		= 0,
@@ -582,7 +583,7 @@ static struct uvc_control_mapping uvc_ct
 	},
 	{
 		.id		= V4L2_CID_PRIVACY,
-		.name		= "Privacy",
+		//.name		= "Privacy",
 		.entity		= UVC_GUID_UVC_CAMERA,
 		.selector	= UVC_CT_PRIVACY_CONTROL,
 		.size		= 1,
@@ -595,7 +596,7 @@ static struct uvc_control_mapping uvc_ct
 /* ------------------------------------------------------------------------
  * Utility functions
  */
-
+ 
 static inline __u8 *uvc_ctrl_data(struct uvc_control *ctrl, int id)
 {
 	return ctrl->data + id * ctrl->info->size;
@@ -1528,6 +1529,11 @@ void uvc_ctrl_init(void)
 		uvc_ctrl_add_info(ctrl);
 
 	for (; mapping < mend; ++mapping)
+	{
+		/* set v4l2 control name if defined */ 
+		if (v4l2_ctrl_get_name(mapping->id))
+			strlcpy(mapping->name, v4l2_ctrl_get_name(mapping->id), 32);
 		uvc_ctrl_add_mapping(mapping);
+	}
 }
 
_______________________________________________
Linux-uvc-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to