LINUX&UVC处理单元描述符
2024-03-19
142
0
不同的UVC版本,其UVC处理单元描述格式稍有不同。
关于UVC处理单元描述符各字段的详细说明可详见:https://www.usbzh.com/article/detail-84.html
对于UVC1.1/1.5版本,其内容如下:
UINT8 bLength;
UINT8 bDescriptorType;
UINT8 bDescriptorSubtype;
UINT8 bUnitID;
UINT8 bSourceID;
UINT16 wMaxMultiplier;
UINT8 bControlSize;
UINT8 bmControls[3];
UINT8 iProcessing;
UINT8 bmVideoStandards;
而对于UVC1.0则其内容如下:
UINT8 bLength;
UINT8 bDescriptorType;
UINT8 bDescriptorSubtype;
UINT8 bUnitID;
UINT8 bSourceID;
UINT16 wMaxMultiplier;
UINT8 bControlSize;
UINT8 bmControls[2];
UINT8 iProcessing;
UVC1.0相对于UVC1.1/1.5,其bControlSize的值从2变成了3,故bmControls数组变从2变成了3字节。
另一个就是多了一个bmVideoStandards字节。
所以,UVC1.1/UVC1.5总的长度bLength为13字节,而UVC1.0为11字节。
case UVC_VC_PROCESSING_UNIT:
n = buflen >= 8 ? buffer[7] : 0;
p = dev->uvc_version >= 0x0110 ? 10 : 9;
if (buflen < p + n) {
uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
"interface %d PROCESSING_UNIT error\n",
udev->devnum, alts->desc.bInterfaceNumber);
return -EINVAL;
}
unit = uvc_alloc_entity(buffer[2], buffer[3], 2, n);
if (unit == NULL)
return -ENOMEM;
memcpy(unit->baSourceID, &buffer[4], 1);
unit->processing.wMaxMultiplier =get_unaligned_le16(&buffer[5]);
unit->processing.bControlSize = buffer[7];
unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
memcpy(unit->processing.bmControls, &buffer[8], n);
if (dev->uvc_version >= 0x0110)
unit->processing.bmVideoStandards = buffer[9+n];
if (buffer[8+n] != 0)
usb_string(udev, buffer[8+n], unit->name, sizeof(unit->name));
else
sprintf(unit->name, "Processing %u", buffer[3]);
list_add_tail(&unit->list, &dev->entities);
break;