Commit 351509c6 authored by Ricardo Ribalda's avatar Ricardo Ribalda Committed by Mauro Carvalho Chehab

media: uvcvideo: Move guid to entity

Instead of having multiple copies of the entity guid on the code, move
it to the entity structure.
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 dc9455ff
...@@ -826,31 +826,10 @@ static void uvc_set_le_value(struct uvc_control_mapping *mapping, ...@@ -826,31 +826,10 @@ static void uvc_set_le_value(struct uvc_control_mapping *mapping,
* Terminal and unit management * Terminal and unit management
*/ */
static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING;
static const u8 uvc_camera_guid[16] = UVC_GUID_UVC_CAMERA;
static const u8 uvc_media_transport_input_guid[16] =
UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT;
static int uvc_entity_match_guid(const struct uvc_entity *entity, static int uvc_entity_match_guid(const struct uvc_entity *entity,
const u8 guid[16]) const u8 guid[16])
{ {
switch (UVC_ENTITY_TYPE(entity)) { return memcmp(entity->guid, guid, sizeof(entity->guid)) == 0;
case UVC_ITT_CAMERA:
return memcmp(uvc_camera_guid, guid, 16) == 0;
case UVC_ITT_MEDIA_TRANSPORT_INPUT:
return memcmp(uvc_media_transport_input_guid, guid, 16) == 0;
case UVC_VC_PROCESSING_UNIT:
return memcmp(uvc_processing_guid, guid, 16) == 0;
case UVC_VC_EXTENSION_UNIT:
return memcmp(entity->extension.guidExtensionCode,
guid, 16) == 0;
default:
return 0;
}
} }
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
...@@ -1776,8 +1755,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev, ...@@ -1776,8 +1755,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
if (data == NULL) if (data == NULL)
return -ENOMEM; return -ENOMEM;
memcpy(info->entity, ctrl->entity->extension.guidExtensionCode, memcpy(info->entity, ctrl->entity->guid, sizeof(info->entity));
sizeof(info->entity));
info->index = ctrl->index; info->index = ctrl->index;
info->selector = ctrl->index + 1; info->selector = ctrl->index + 1;
...@@ -1883,7 +1861,7 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain, ...@@ -1883,7 +1861,7 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
if (!found) { if (!found) {
uvc_trace(UVC_TRACE_CONTROL, "Control %pUl/%u not found.\n", uvc_trace(UVC_TRACE_CONTROL, "Control %pUl/%u not found.\n",
entity->extension.guidExtensionCode, xqry->selector); entity->guid, xqry->selector);
return -ENOENT; return -ENOENT;
} }
......
...@@ -1019,6 +1019,11 @@ static int uvc_parse_streaming(struct uvc_device *dev, ...@@ -1019,6 +1019,11 @@ static int uvc_parse_streaming(struct uvc_device *dev,
return ret; return ret;
} }
static const u8 uvc_camera_guid[16] = UVC_GUID_UVC_CAMERA;
static const u8 uvc_media_transport_input_guid[16] =
UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT;
static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING;
static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id, static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id,
unsigned int num_pads, unsigned int extra_size) unsigned int num_pads, unsigned int extra_size)
{ {
...@@ -1038,6 +1043,22 @@ static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id, ...@@ -1038,6 +1043,22 @@ static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id,
entity->id = id; entity->id = id;
entity->type = type; entity->type = type;
/*
* Set the GUID for standard entity types. For extension units, the GUID
* is initialized by the caller.
*/
switch (type) {
case UVC_ITT_CAMERA:
memcpy(entity->guid, uvc_camera_guid, 16);
break;
case UVC_ITT_MEDIA_TRANSPORT_INPUT:
memcpy(entity->guid, uvc_media_transport_input_guid, 16);
break;
case UVC_VC_PROCESSING_UNIT:
memcpy(entity->guid, uvc_processing_guid, 16);
break;
}
entity->num_links = 0; entity->num_links = 0;
entity->num_pads = num_pads; entity->num_pads = num_pads;
entity->pads = ((void *)(entity + 1)) + extra_size; entity->pads = ((void *)(entity + 1)) + extra_size;
...@@ -1109,7 +1130,7 @@ static int uvc_parse_vendor_control(struct uvc_device *dev, ...@@ -1109,7 +1130,7 @@ static int uvc_parse_vendor_control(struct uvc_device *dev,
if (unit == NULL) if (unit == NULL)
return -ENOMEM; return -ENOMEM;
memcpy(unit->extension.guidExtensionCode, &buffer[4], 16); memcpy(unit->guid, &buffer[4], 16);
unit->extension.bNumControls = buffer[20]; unit->extension.bNumControls = buffer[20];
memcpy(unit->baSourceID, &buffer[22], p); memcpy(unit->baSourceID, &buffer[22], p);
unit->extension.bControlSize = buffer[22+p]; unit->extension.bControlSize = buffer[22+p];
...@@ -1368,7 +1389,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev, ...@@ -1368,7 +1389,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
if (unit == NULL) if (unit == NULL)
return -ENOMEM; return -ENOMEM;
memcpy(unit->extension.guidExtensionCode, &buffer[4], 16); memcpy(unit->guid, &buffer[4], 16);
unit->extension.bNumControls = buffer[20]; unit->extension.bNumControls = buffer[20];
memcpy(unit->baSourceID, &buffer[22], p); memcpy(unit->baSourceID, &buffer[22], p);
unit->extension.bControlSize = buffer[22+p]; unit->extension.bControlSize = buffer[22+p];
......
...@@ -304,6 +304,7 @@ struct uvc_entity { ...@@ -304,6 +304,7 @@ struct uvc_entity {
u8 id; u8 id;
u16 type; u16 type;
char name[64]; char name[64];
u8 guid[16];
/* Media controller-related fields. */ /* Media controller-related fields. */
struct video_device *vdev; struct video_device *vdev;
...@@ -342,7 +343,6 @@ struct uvc_entity { ...@@ -342,7 +343,6 @@ struct uvc_entity {
} selector; } selector;
struct { struct {
u8 guidExtensionCode[16];
u8 bNumControls; u8 bNumControls;
u8 bControlSize; u8 bControlSize;
u8 *bmControls; u8 *bmControls;
......
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