Commit 70fa906d authored by Ricardo Ribalda's avatar Ricardo Ribalda Committed by Mauro Carvalho Chehab

media: uvcvideo: Use control names from framework

The framework already contains a map of IDs to names, lets use it when
possible.
Reviewed-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Suggested-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 8865c537
...@@ -432,7 +432,6 @@ static void uvc_ctrl_set_rel_speed(struct uvc_control_mapping *mapping, ...@@ -432,7 +432,6 @@ static void uvc_ctrl_set_rel_speed(struct uvc_control_mapping *mapping,
static const struct uvc_control_mapping uvc_ctrl_mappings[] = { static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
{ {
.id = V4L2_CID_BRIGHTNESS, .id = V4L2_CID_BRIGHTNESS,
.name = "Brightness",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_BRIGHTNESS_CONTROL, .selector = UVC_PU_BRIGHTNESS_CONTROL,
.size = 16, .size = 16,
...@@ -442,7 +441,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -442,7 +441,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_CONTRAST, .id = V4L2_CID_CONTRAST,
.name = "Contrast",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_CONTRAST_CONTROL, .selector = UVC_PU_CONTRAST_CONTROL,
.size = 16, .size = 16,
...@@ -452,7 +450,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -452,7 +450,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_HUE, .id = V4L2_CID_HUE,
.name = "Hue",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_HUE_CONTROL, .selector = UVC_PU_HUE_CONTROL,
.size = 16, .size = 16,
...@@ -464,7 +461,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -464,7 +461,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_SATURATION, .id = V4L2_CID_SATURATION,
.name = "Saturation",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_SATURATION_CONTROL, .selector = UVC_PU_SATURATION_CONTROL,
.size = 16, .size = 16,
...@@ -474,7 +470,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -474,7 +470,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_SHARPNESS, .id = V4L2_CID_SHARPNESS,
.name = "Sharpness",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_SHARPNESS_CONTROL, .selector = UVC_PU_SHARPNESS_CONTROL,
.size = 16, .size = 16,
...@@ -484,7 +479,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -484,7 +479,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_GAMMA, .id = V4L2_CID_GAMMA,
.name = "Gamma",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_GAMMA_CONTROL, .selector = UVC_PU_GAMMA_CONTROL,
.size = 16, .size = 16,
...@@ -494,7 +488,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -494,7 +488,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_BACKLIGHT_COMPENSATION, .id = V4L2_CID_BACKLIGHT_COMPENSATION,
.name = "Backlight Compensation",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_BACKLIGHT_COMPENSATION_CONTROL, .selector = UVC_PU_BACKLIGHT_COMPENSATION_CONTROL,
.size = 16, .size = 16,
...@@ -504,7 +497,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -504,7 +497,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_GAIN, .id = V4L2_CID_GAIN,
.name = "Gain",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_GAIN_CONTROL, .selector = UVC_PU_GAIN_CONTROL,
.size = 16, .size = 16,
...@@ -514,7 +506,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -514,7 +506,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_POWER_LINE_FREQUENCY, .id = V4L2_CID_POWER_LINE_FREQUENCY,
.name = "Power Line Frequency",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
.size = 2, .size = 2,
...@@ -526,7 +517,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -526,7 +517,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_HUE_AUTO, .id = V4L2_CID_HUE_AUTO,
.name = "Hue, Auto",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_HUE_AUTO_CONTROL, .selector = UVC_PU_HUE_AUTO_CONTROL,
.size = 1, .size = 1,
...@@ -537,7 +527,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -537,7 +527,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_EXPOSURE_AUTO, .id = V4L2_CID_EXPOSURE_AUTO,
.name = "Exposure, Auto",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_AE_MODE_CONTROL, .selector = UVC_CT_AE_MODE_CONTROL,
.size = 4, .size = 4,
...@@ -550,7 +539,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -550,7 +539,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_EXPOSURE_AUTO_PRIORITY, .id = V4L2_CID_EXPOSURE_AUTO_PRIORITY,
.name = "Exposure, Auto Priority",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_AE_PRIORITY_CONTROL, .selector = UVC_CT_AE_PRIORITY_CONTROL,
.size = 1, .size = 1,
...@@ -560,7 +548,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -560,7 +548,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_EXPOSURE_ABSOLUTE, .id = V4L2_CID_EXPOSURE_ABSOLUTE,
.name = "Exposure (Absolute)",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL, .selector = UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL,
.size = 32, .size = 32,
...@@ -572,7 +559,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -572,7 +559,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_AUTO_WHITE_BALANCE, .id = V4L2_CID_AUTO_WHITE_BALANCE,
.name = "White Balance Temperature, Auto",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, .selector = UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL,
.size = 1, .size = 1,
...@@ -583,7 +569,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -583,7 +569,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_WHITE_BALANCE_TEMPERATURE, .id = V4L2_CID_WHITE_BALANCE_TEMPERATURE,
.name = "White Balance Temperature",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL, .selector = UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL,
.size = 16, .size = 16,
...@@ -595,7 +580,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -595,7 +580,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_AUTO_WHITE_BALANCE, .id = V4L2_CID_AUTO_WHITE_BALANCE,
.name = "White Balance Component, Auto",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL, .selector = UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL,
.size = 1, .size = 1,
...@@ -607,7 +591,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -607,7 +591,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_BLUE_BALANCE, .id = V4L2_CID_BLUE_BALANCE,
.name = "White Balance Blue Component",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL, .selector = UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL,
.size = 16, .size = 16,
...@@ -619,7 +602,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -619,7 +602,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_RED_BALANCE, .id = V4L2_CID_RED_BALANCE,
.name = "White Balance Red Component",
.entity = UVC_GUID_UVC_PROCESSING, .entity = UVC_GUID_UVC_PROCESSING,
.selector = UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL, .selector = UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL,
.size = 16, .size = 16,
...@@ -631,7 +613,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -631,7 +613,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_FOCUS_ABSOLUTE, .id = V4L2_CID_FOCUS_ABSOLUTE,
.name = "Focus (absolute)",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_FOCUS_ABSOLUTE_CONTROL, .selector = UVC_CT_FOCUS_ABSOLUTE_CONTROL,
.size = 16, .size = 16,
...@@ -643,7 +624,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -643,7 +624,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_FOCUS_AUTO, .id = V4L2_CID_FOCUS_AUTO,
.name = "Focus, Auto",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_FOCUS_AUTO_CONTROL, .selector = UVC_CT_FOCUS_AUTO_CONTROL,
.size = 1, .size = 1,
...@@ -654,7 +634,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -654,7 +634,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_IRIS_ABSOLUTE, .id = V4L2_CID_IRIS_ABSOLUTE,
.name = "Iris, Absolute",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_IRIS_ABSOLUTE_CONTROL, .selector = UVC_CT_IRIS_ABSOLUTE_CONTROL,
.size = 16, .size = 16,
...@@ -664,7 +643,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -664,7 +643,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_IRIS_RELATIVE, .id = V4L2_CID_IRIS_RELATIVE,
.name = "Iris, Relative",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_IRIS_RELATIVE_CONTROL, .selector = UVC_CT_IRIS_RELATIVE_CONTROL,
.size = 8, .size = 8,
...@@ -674,7 +652,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -674,7 +652,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_ZOOM_ABSOLUTE, .id = V4L2_CID_ZOOM_ABSOLUTE,
.name = "Zoom, Absolute",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_ZOOM_ABSOLUTE_CONTROL, .selector = UVC_CT_ZOOM_ABSOLUTE_CONTROL,
.size = 16, .size = 16,
...@@ -684,7 +661,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -684,7 +661,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_ZOOM_CONTINUOUS, .id = V4L2_CID_ZOOM_CONTINUOUS,
.name = "Zoom, Continuous",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_ZOOM_RELATIVE_CONTROL, .selector = UVC_CT_ZOOM_RELATIVE_CONTROL,
.size = 0, .size = 0,
...@@ -696,7 +672,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -696,7 +672,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_PAN_ABSOLUTE, .id = V4L2_CID_PAN_ABSOLUTE,
.name = "Pan (Absolute)",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_PANTILT_ABSOLUTE_CONTROL, .selector = UVC_CT_PANTILT_ABSOLUTE_CONTROL,
.size = 32, .size = 32,
...@@ -706,7 +681,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -706,7 +681,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_TILT_ABSOLUTE, .id = V4L2_CID_TILT_ABSOLUTE,
.name = "Tilt (Absolute)",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_PANTILT_ABSOLUTE_CONTROL, .selector = UVC_CT_PANTILT_ABSOLUTE_CONTROL,
.size = 32, .size = 32,
...@@ -716,7 +690,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -716,7 +690,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_PAN_SPEED, .id = V4L2_CID_PAN_SPEED,
.name = "Pan (Speed)",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_PANTILT_RELATIVE_CONTROL, .selector = UVC_CT_PANTILT_RELATIVE_CONTROL,
.size = 16, .size = 16,
...@@ -728,7 +701,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -728,7 +701,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_TILT_SPEED, .id = V4L2_CID_TILT_SPEED,
.name = "Tilt (Speed)",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_PANTILT_RELATIVE_CONTROL, .selector = UVC_CT_PANTILT_RELATIVE_CONTROL,
.size = 16, .size = 16,
...@@ -740,7 +712,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -740,7 +712,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_PRIVACY, .id = V4L2_CID_PRIVACY,
.name = "Privacy",
.entity = UVC_GUID_UVC_CAMERA, .entity = UVC_GUID_UVC_CAMERA,
.selector = UVC_CT_PRIVACY_CONTROL, .selector = UVC_CT_PRIVACY_CONTROL,
.size = 1, .size = 1,
...@@ -750,7 +721,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { ...@@ -750,7 +721,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
}, },
{ {
.id = V4L2_CID_PRIVACY, .id = V4L2_CID_PRIVACY,
.name = "Privacy",
.entity = UVC_GUID_EXT_GPIO_CONTROLLER, .entity = UVC_GUID_EXT_GPIO_CONTROLLER,
.selector = UVC_CT_PRIVACY_CONTROL, .selector = UVC_CT_PRIVACY_CONTROL,
.size = 1, .size = 1,
...@@ -1072,6 +1042,20 @@ static int uvc_query_v4l2_class(struct uvc_video_chain *chain, u32 req_id, ...@@ -1072,6 +1042,20 @@ static int uvc_query_v4l2_class(struct uvc_video_chain *chain, u32 req_id,
return 0; return 0;
} }
static const char *uvc_map_get_name(const struct uvc_control_mapping *map)
{
const char *name;
if (map->name)
return map->name;
name = v4l2_ctrl_get_name(map->id);
if (name)
return name;
return "Unknown Control";
}
static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
struct uvc_control *ctrl, struct uvc_control *ctrl,
struct uvc_control_mapping *mapping, struct uvc_control_mapping *mapping,
...@@ -1085,7 +1069,8 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, ...@@ -1085,7 +1069,8 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
memset(v4l2_ctrl, 0, sizeof(*v4l2_ctrl)); memset(v4l2_ctrl, 0, sizeof(*v4l2_ctrl));
v4l2_ctrl->id = mapping->id; v4l2_ctrl->id = mapping->id;
v4l2_ctrl->type = mapping->v4l2_type; v4l2_ctrl->type = mapping->v4l2_type;
strscpy(v4l2_ctrl->name, mapping->name, sizeof(v4l2_ctrl->name)); strscpy(v4l2_ctrl->name, uvc_map_get_name(mapping),
sizeof(v4l2_ctrl->name));
v4l2_ctrl->flags = 0; v4l2_ctrl->flags = 0;
if (!(ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR)) if (!(ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR))
...@@ -2177,7 +2162,8 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, ...@@ -2177,7 +2162,8 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
list_add_tail(&map->list, &ctrl->info.mappings); list_add_tail(&map->list, &ctrl->info.mappings);
uvc_dbg(chain->dev, CONTROL, "Adding mapping '%s' to control %pUl/%u\n", uvc_dbg(chain->dev, CONTROL, "Adding mapping '%s' to control %pUl/%u\n",
map->name, ctrl->info.entity, ctrl->info.selector); uvc_map_get_name(map), ctrl->info.entity,
ctrl->info.selector);
return 0; return 0;
} }
...@@ -2195,7 +2181,7 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, ...@@ -2195,7 +2181,7 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
if (mapping->id & ~V4L2_CTRL_ID_MASK) { if (mapping->id & ~V4L2_CTRL_ID_MASK) {
uvc_dbg(dev, CONTROL, uvc_dbg(dev, CONTROL,
"Can't add mapping '%s', control id 0x%08x is invalid\n", "Can't add mapping '%s', control id 0x%08x is invalid\n",
mapping->name, mapping->id); uvc_map_get_name(mapping), mapping->id);
return -EINVAL; return -EINVAL;
} }
...@@ -2242,7 +2228,7 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, ...@@ -2242,7 +2228,7 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
if (mapping->id == map->id) { if (mapping->id == map->id) {
uvc_dbg(dev, CONTROL, uvc_dbg(dev, CONTROL,
"Can't add mapping '%s', control id 0x%08x already exists\n", "Can't add mapping '%s', control id 0x%08x already exists\n",
mapping->name, mapping->id); uvc_map_get_name(mapping), mapping->id);
ret = -EEXIST; ret = -EEXIST;
goto done; goto done;
} }
...@@ -2253,7 +2239,7 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, ...@@ -2253,7 +2239,7 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
atomic_dec(&dev->nmappings); atomic_dec(&dev->nmappings);
uvc_dbg(dev, CONTROL, uvc_dbg(dev, CONTROL,
"Can't add mapping '%s', maximum mappings count (%u) exceeded\n", "Can't add mapping '%s', maximum mappings count (%u) exceeded\n",
mapping->name, UVC_MAX_CONTROL_MAPPINGS); uvc_map_get_name(mapping), UVC_MAX_CONTROL_MAPPINGS);
ret = -ENOMEM; ret = -ENOMEM;
goto done; goto done;
} }
...@@ -2462,6 +2448,7 @@ static void uvc_ctrl_cleanup_mappings(struct uvc_device *dev, ...@@ -2462,6 +2448,7 @@ static void uvc_ctrl_cleanup_mappings(struct uvc_device *dev,
list_for_each_entry_safe(mapping, nm, &ctrl->info.mappings, list) { list_for_each_entry_safe(mapping, nm, &ctrl->info.mappings, list) {
list_del(&mapping->list); list_del(&mapping->list);
kfree(mapping->menu_info); kfree(mapping->menu_info);
kfree(mapping->name);
kfree(mapping); kfree(mapping);
} }
} }
......
...@@ -40,7 +40,13 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, ...@@ -40,7 +40,13 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
return -ENOMEM; return -ENOMEM;
map->id = xmap->id; map->id = xmap->id;
memcpy(map->name, xmap->name, sizeof(map->name)); /* Non standard control id. */
if (v4l2_ctrl_get_name(map->id) == NULL) {
map->name = kmemdup(xmap->name, sizeof(xmap->name),
GFP_KERNEL);
if (!map->name)
return -ENOMEM;
}
memcpy(map->entity, xmap->entity, sizeof(map->entity)); memcpy(map->entity, xmap->entity, sizeof(map->entity));
map->selector = xmap->selector; map->selector = xmap->selector;
map->size = xmap->size; map->size = xmap->size;
......
...@@ -241,7 +241,7 @@ struct uvc_control_mapping { ...@@ -241,7 +241,7 @@ struct uvc_control_mapping {
struct list_head ev_subs; struct list_head ev_subs;
u32 id; u32 id;
u8 name[32]; char *name;
u8 entity[16]; u8 entity[16];
u8 selector; u8 selector;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment