关于UVC相机驱动信息配置的一些总结
2025-01-14
1
0
UVC相机驱动信息主要包括两大类:分别为USB信息获取和系统信息获取。
USB信息获取
USB信息包括设备描述符、配置描述符、字符串描述符及配置选择,接口选择及UVC特定类请求等。这些信息都是通过IRP_MJ_INTERNAL_DEVICE_CONTROL请求实现的。
其具体对应的是IRP_MJ_INTERNAL_DEVICE_CONTROL控制请求,其控制码为IOCTL_INTERNAL_USB_SUBMIT_URB。
当控制码为IOCTL_INTERNAL_USB_SUBMIT_URB时,其IRP当前IO_STACK_LOCATION对构体成员>Parameters.Others.Argument1参数解析为URB指针。
PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp);
if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_INTERNAL_USB_SUBMIT_URB)
{
PURB Urb = (PURB)IoStack->Parameters.Others.Argument1;
}
URB是USB请求包,其又根据成员Function的功能号又区分为同的USB请求。
USHORT function = Urb->UrbHeader.Function;
这些请求码的值可能为:
//
// URB request codes
//
#define URB_FUNCTION_SELECT_CONFIGURATION 0x0000
#define URB_FUNCTION_SELECT_INTERFACE 0x0001
#define URB_FUNCTION_ABORT_PIPE 0x0002
#define URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL 0x0003
#define URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL 0x0004
#define URB_FUNCTION_GET_FRAME_LENGTH 0x0005
#define URB_FUNCTION_SET_FRAME_LENGTH 0x0006
#define URB_FUNCTION_GET_CURRENT_FRAME_NUMBER 0x0007
#define URB_FUNCTION_CONTROL_TRANSFER 0x0008
#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER 0x0009
#define URB_FUNCTION_ISOCH_TRANSFER 0x000A
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 0x000B
#define URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE 0x000C
#define URB_FUNCTION_SET_FEATURE_TO_DEVICE 0x000D
#define URB_FUNCTION_SET_FEATURE_TO_INTERFACE 0x000E
#define URB_FUNCTION_SET_FEATURE_TO_ENDPOINT 0x000F
#define URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE 0x0010
#define URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE 0x0011
#define URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT 0x0012
#define URB_FUNCTION_GET_STATUS_FROM_DEVICE 0x0013
#define URB_FUNCTION_GET_STATUS_FROM_INTERFACE 0x0014
#define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT 0x0015
#define URB_FUNCTION_RESERVED_0X0016 0x0016
#define URB_FUNCTION_VENDOR_DEVICE 0x0017
#define URB_FUNCTION_VENDOR_INTERFACE 0x0018
#define URB_FUNCTION_VENDOR_ENDPOINT 0x0019
#define URB_FUNCTION_CLASS_DEVICE 0x001A
#define URB_FUNCTION_CLASS_INTERFACE 0x001B
#define URB_FUNCTION_CLASS_ENDPOINT 0x001C
#define URB_FUNCTION_RESERVE_0X001D 0x001D
// previously URB_FUNCTION_RESET_PIPE
#define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001E
#define URB_FUNCTION_CLASS_OTHER 0x001F
#define URB_FUNCTION_VENDOR_OTHER 0x0020
#define URB_FUNCTION_GET_STATUS_FROM_OTHER 0x0021
#define URB_FUNCTION_CLEAR_FEATURE_TO_OTHER 0x0022
#define URB_FUNCTION_SET_FEATURE_TO_OTHER 0x0023
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT 0x0024
#define URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT 0x0025
#define URB_FUNCTION_GET_CONFIGURATION 0x0026
#define URB_FUNCTION_GET_INTERFACE 0x0027
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE 0x0028
#define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE 0x0029
// Reserve 0x002B-0x002F
#define URB_FUNCTION_RESERVE_0X002B 0x002B
#define URB_FUNCTION_RESERVE_0X002C 0x002C
#define URB_FUNCTION_RESERVE_0X002D 0x002D
#define URB_FUNCTION_RESERVE_0X002E 0x002E
#define URB_FUNCTION_RESERVE_0X002F 0x002F
// USB 2.0 calls start at 0x0030
#if (_WIN32_WINNT >= 0x0501)
#define URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR 0x002A
#define URB_FUNCTION_SYNC_RESET_PIPE 0x0030
#define URB_FUNCTION_SYNC_CLEAR_STALL 0x0031
#endif
#if (_WIN32_WINNT >= 0x0600)
#define URB_FUNCTION_CONTROL_TRANSFER_EX 0x0032
#define URB_FUNCTION_RESERVE_0X0033 0x0033
#define URB_FUNCTION_RESERVE_0X0034 0x0034
#endif
#if (NTDDI_VERSION >= NTDDI_WIN8)
#define URB_FUNCTION_OPEN_STATIC_STREAMS 0x0035
#define URB_FUNCTION_CLOSE_STATIC_STREAMS 0x0036
#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER_USING_CHAINED_MDL 0x0037
#define URB_FUNCTION_ISOCH_TRANSFER_USING_CHAINED_MDL 0x0038
#endif
系统信息获取
系统信息主要是Windows系统信息的获取。这些信息是通过IRP_MJ_PNP实现的。其对应的MinorFunction主要有:
IRP_MN_QUERY_ID、IRP_MN_QUERY_DEVICE_TEXT。
PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation(Irp)
RP_MN_QUERY_DEVICE_TEXT
RP_MN_QUERY_DEVICE_TEXT解析为:
DEVICE_TEXT_TYPE textype = irpStack->Parameters.QueryDeviceText.DeviceTextType;
值有:
typedef enum {
DeviceTextDescription = 0, // DeviceDesc property
DeviceTextLocationInformation = 1 // DeviceLocation property
} DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;
IRP_MN_QUERY_ID
当为IRP_MN_QUERY_ID时。
BUS_QUERY_ID_TYPE id = irpStack->Parameters.QueryId.IdType;
类型有:
typedef enum {
BusQueryDeviceID = 0, // <Enumerator>\<Enumerator-specific device id>
BusQueryHardwareIDs = 1, // Hardware ids
BusQueryCompatibleIDs = 2, // compatible device ids
BusQueryInstanceID = 3, // persistent id for this instance of the device
BusQueryDeviceSerialNumber = 4, // serial number for this device
BusQueryContainerID = 5 // unique id of the device's physical container
} BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936