68bf261d5d6a710a494b86e413ff130d56643334
[rtmpclient.git] / app / src / main / jni / libusb-1.0.22 / libusb / os / windows_nt_shared_types.h
1 #pragma once
2
3 #include "windows_common.h"
4
5 #include <pshpack1.h>
6
7 typedef struct USB_DEVICE_DESCRIPTOR {
8         UCHAR  bLength;
9         UCHAR  bDescriptorType;
10         USHORT bcdUSB;
11         UCHAR  bDeviceClass;
12         UCHAR  bDeviceSubClass;
13         UCHAR  bDeviceProtocol;
14         UCHAR  bMaxPacketSize0;
15         USHORT idVendor;
16         USHORT idProduct;
17         USHORT bcdDevice;
18         UCHAR  iManufacturer;
19         UCHAR  iProduct;
20         UCHAR  iSerialNumber;
21         UCHAR  bNumConfigurations;
22 } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
23
24 typedef struct USB_CONFIGURATION_DESCRIPTOR {
25         UCHAR  bLength;
26         UCHAR  bDescriptorType;
27         USHORT wTotalLength;
28         UCHAR  bNumInterfaces;
29         UCHAR  bConfigurationValue;
30         UCHAR  iConfiguration;
31         UCHAR  bmAttributes;
32         UCHAR  MaxPower;
33 } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
34
35 #include <poppack.h>
36
37 #define MAX_DEVICE_ID_LEN       200
38
39 typedef struct USB_DK_DEVICE_ID {
40         WCHAR DeviceID[MAX_DEVICE_ID_LEN];
41         WCHAR InstanceID[MAX_DEVICE_ID_LEN];
42 } USB_DK_DEVICE_ID, *PUSB_DK_DEVICE_ID;
43
44 typedef struct USB_DK_DEVICE_INFO {
45         USB_DK_DEVICE_ID ID;
46         ULONG64 FilterID;
47         ULONG64 Port;
48         ULONG64 Speed;
49         USB_DEVICE_DESCRIPTOR DeviceDescriptor;
50 } USB_DK_DEVICE_INFO, *PUSB_DK_DEVICE_INFO;
51
52 typedef struct USB_DK_ISO_TRANSFER_RESULT {
53         ULONG64 ActualLength;
54         ULONG64 TransferResult;
55 } USB_DK_ISO_TRANSFER_RESULT, *PUSB_DK_ISO_TRANSFER_RESULT;
56
57 typedef struct USB_DK_GEN_TRANSFER_RESULT {
58         ULONG64 BytesTransferred;
59         ULONG64 UsbdStatus; // USBD_STATUS code
60 } USB_DK_GEN_TRANSFER_RESULT, *PUSB_DK_GEN_TRANSFER_RESULT;
61
62 typedef struct USB_DK_TRANSFER_RESULT {
63         USB_DK_GEN_TRANSFER_RESULT GenResult;
64         PVOID64 IsochronousResultsArray; // array of USB_DK_ISO_TRANSFER_RESULT
65 } USB_DK_TRANSFER_RESULT, *PUSB_DK_TRANSFER_RESULT;
66
67 typedef struct USB_DK_TRANSFER_REQUEST {
68         ULONG64 EndpointAddress;
69         PVOID64 Buffer;
70         ULONG64 BufferLength;
71         ULONG64 TransferType;
72         ULONG64 IsochronousPacketsArraySize;
73         PVOID64 IsochronousPacketsArray;
74         USB_DK_TRANSFER_RESULT Result;
75 } USB_DK_TRANSFER_REQUEST, *PUSB_DK_TRANSFER_REQUEST;
76
77 struct usbdk_device_priv {
78         USB_DK_DEVICE_INFO info;
79         PUSB_CONFIGURATION_DESCRIPTOR *config_descriptors;
80         HANDLE redirector_handle;
81         HANDLE system_handle;
82         uint8_t active_configuration;
83 };
84
85 struct winusb_device_priv {
86         bool initialized;
87         bool root_hub;
88         uint8_t active_config;
89         uint8_t depth; // distance to HCD
90         const struct windows_usb_api_backend *apib;
91         char *dev_id;
92         char *path;  // device interface path
93         int sub_api; // for WinUSB-like APIs
94         struct {
95                 char *path; // each interface needs a device interface path,
96                 const struct windows_usb_api_backend *apib; // an API backend (multiple drivers support),
97                 int sub_api;
98                 int8_t nb_endpoints; // and a set of endpoint addresses (USB_MAXENDPOINTS)
99                 uint8_t *endpoint;
100                 bool restricted_functionality;  // indicates if the interface functionality is restricted
101                                                 // by Windows (eg. HID keyboards or mice cannot do R/W)
102         } usb_interface[USB_MAXINTERFACES];
103         struct hid_device_priv *hid;
104         USB_DEVICE_DESCRIPTOR dev_descriptor;
105         PUSB_CONFIGURATION_DESCRIPTOR *config_descriptor; // list of pointers to the cached config descriptors
106 };
107
108 struct usbdk_device_handle_priv {
109         // Not currently used
110         char dummy;
111 };
112
113 struct winusb_device_handle_priv {
114         int active_interface;
115         struct {
116                 HANDLE dev_handle; // WinUSB needs an extra handle for the file
117                 HANDLE api_handle; // used by the API to communicate with the device
118         } interface_handle[USB_MAXINTERFACES];
119         int autoclaim_count[USB_MAXINTERFACES]; // For auto-release
120 };
121
122 struct usbdk_transfer_priv {
123         USB_DK_TRANSFER_REQUEST request;
124         struct winfd pollable_fd;
125         HANDLE system_handle;
126         PULONG64 IsochronousPacketsArray;
127         PUSB_DK_ISO_TRANSFER_RESULT IsochronousResultsArray;
128 };
129
130 struct winusb_transfer_priv {
131         struct winfd pollable_fd;
132         HANDLE handle;
133         uint8_t interface_number;
134         uint8_t *hid_buffer; // 1 byte extended data buffer, required for HID
135         uint8_t *hid_dest;   // transfer buffer destination, required for HID
136         size_t hid_expected_size;
137         void *iso_context;
138 };