1 |
/* $MidnightBSD$ */ |
2 |
/* $FreeBSD: stable/10/lib/libusb/libusb.h 302275 2016-06-29 10:58:36Z hselasky $ */ |
3 |
/*- |
4 |
* Copyright (c) 2009 Sylvestre Gallon. All rights reserved. |
5 |
* |
6 |
* Redistribution and use in source and binary forms, with or without |
7 |
* modification, are permitted provided that the following conditions |
8 |
* are met: |
9 |
* 1. Redistributions of source code must retain the above copyright |
10 |
* notice, this list of conditions and the following disclaimer. |
11 |
* 2. Redistributions in binary form must reproduce the above copyright |
12 |
* notice, this list of conditions and the following disclaimer in the |
13 |
* documentation and/or other materials provided with the distribution. |
14 |
* |
15 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
16 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
19 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
20 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
21 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
22 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
23 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
24 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
25 |
* SUCH DAMAGE. |
26 |
*/ |
27 |
|
28 |
#ifndef __LIBUSB_H__ |
29 |
#define __LIBUSB_H__ |
30 |
|
31 |
#ifndef LIBUSB_GLOBAL_INCLUDE_FILE |
32 |
#include <stdint.h> |
33 |
#include <sys/time.h> |
34 |
#include <sys/types.h> |
35 |
#endif |
36 |
|
37 |
#define LIBUSB_API_VERSION 0x01000102 |
38 |
|
39 |
#define LIBUSB_CALL |
40 |
|
41 |
#ifdef __cplusplus |
42 |
extern "C" { |
43 |
#endif |
44 |
#if 0 |
45 |
} /* indent fix */ |
46 |
|
47 |
#endif |
48 |
|
49 |
/* libusb enums */ |
50 |
|
51 |
enum libusb_class_code { |
52 |
LIBUSB_CLASS_PER_INTERFACE = 0, |
53 |
LIBUSB_CLASS_AUDIO = 1, |
54 |
LIBUSB_CLASS_COMM = 2, |
55 |
LIBUSB_CLASS_HID = 3, |
56 |
LIBUSB_CLASS_PTP = 6, |
57 |
LIBUSB_CLASS_IMAGE = 6, |
58 |
LIBUSB_CLASS_PRINTER = 7, |
59 |
LIBUSB_CLASS_MASS_STORAGE = 8, |
60 |
LIBUSB_CLASS_HUB = 9, |
61 |
LIBUSB_CLASS_DATA = 10, |
62 |
LIBUSB_CLASS_SMART_CARD = 11, |
63 |
LIBUSB_CLASS_CONTENT_SECURITY = 13, |
64 |
LIBUSB_CLASS_VIDEO = 14, |
65 |
LIBUSB_CLASS_PERSONAL_HEALTHCARE = 15, |
66 |
LIBUSB_CLASS_DIAGNOSTIC_DEVICE = 0xdc, |
67 |
LIBUSB_CLASS_WIRELESS = 0xe0, |
68 |
LIBUSB_CLASS_APPLICATION = 0xfe, |
69 |
LIBUSB_CLASS_VENDOR_SPEC = 0xff, |
70 |
}; |
71 |
|
72 |
enum libusb_descriptor_type { |
73 |
LIBUSB_DT_DEVICE = 0x01, |
74 |
LIBUSB_DT_CONFIG = 0x02, |
75 |
LIBUSB_DT_STRING = 0x03, |
76 |
LIBUSB_DT_INTERFACE = 0x04, |
77 |
LIBUSB_DT_ENDPOINT = 0x05, |
78 |
LIBUSB_DT_HID = 0x21, |
79 |
LIBUSB_DT_REPORT = 0x22, |
80 |
LIBUSB_DT_PHYSICAL = 0x23, |
81 |
LIBUSB_DT_HUB = 0x29, |
82 |
LIBUSB_DT_BOS = 0x0f, |
83 |
LIBUSB_DT_DEVICE_CAPABILITY = 0x10, |
84 |
LIBUSB_DT_SS_ENDPOINT_COMPANION = 0x30, |
85 |
}; |
86 |
|
87 |
enum libusb_device_capability_type { |
88 |
LIBUSB_WIRELESS_USB_DEVICE_CAPABILITY = 0x1, |
89 |
LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY = 0x2, |
90 |
LIBUSB_SS_USB_DEVICE_CAPABILITY = 0x3, |
91 |
LIBUSB_CONTAINER_ID_DEVICE_CAPABILITY = 0x4, |
92 |
}; |
93 |
|
94 |
#define LIBUSB_DT_DEVICE_SIZE 18 |
95 |
#define LIBUSB_DT_CONFIG_SIZE 9 |
96 |
#define LIBUSB_DT_INTERFACE_SIZE 9 |
97 |
#define LIBUSB_DT_ENDPOINT_SIZE 7 |
98 |
#define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 |
99 |
#define LIBUSB_DT_HUB_NONVAR_SIZE 7 |
100 |
#define LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE 6 |
101 |
#define LIBUSB_DT_BOS_SIZE 5 |
102 |
#define LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE 7 |
103 |
#define LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE 10 |
104 |
|
105 |
#define LIBUSB_BT_USB_2_0_EXTENSION_SIZE 7 |
106 |
#define LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE 10 |
107 |
#define LIBUSB_BT_CONTAINER_ID_SIZE 20 |
108 |
|
109 |
#define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f |
110 |
#define LIBUSB_ENDPOINT_DIR_MASK 0x80 |
111 |
|
112 |
enum libusb_endpoint_direction { |
113 |
LIBUSB_ENDPOINT_IN = 0x80, |
114 |
LIBUSB_ENDPOINT_OUT = 0x00, |
115 |
}; |
116 |
|
117 |
#define LIBUSB_TRANSFER_TYPE_MASK 0x03 |
118 |
|
119 |
enum libusb_transfer_type { |
120 |
LIBUSB_TRANSFER_TYPE_CONTROL = 0, |
121 |
LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1, |
122 |
LIBUSB_TRANSFER_TYPE_BULK = 2, |
123 |
LIBUSB_TRANSFER_TYPE_INTERRUPT = 3, |
124 |
}; |
125 |
|
126 |
enum libusb_standard_request { |
127 |
LIBUSB_REQUEST_GET_STATUS = 0x00, |
128 |
LIBUSB_REQUEST_CLEAR_FEATURE = 0x01, |
129 |
LIBUSB_REQUEST_SET_FEATURE = 0x03, |
130 |
LIBUSB_REQUEST_SET_ADDRESS = 0x05, |
131 |
LIBUSB_REQUEST_GET_DESCRIPTOR = 0x06, |
132 |
LIBUSB_REQUEST_SET_DESCRIPTOR = 0x07, |
133 |
LIBUSB_REQUEST_GET_CONFIGURATION = 0x08, |
134 |
LIBUSB_REQUEST_SET_CONFIGURATION = 0x09, |
135 |
LIBUSB_REQUEST_GET_INTERFACE = 0x0A, |
136 |
LIBUSB_REQUEST_SET_INTERFACE = 0x0B, |
137 |
LIBUSB_REQUEST_SYNCH_FRAME = 0x0C, |
138 |
LIBUSB_REQUEST_SET_SEL = 0x30, |
139 |
LIBUSB_REQUEST_SET_ISOCH_DELAY = 0x31, |
140 |
}; |
141 |
|
142 |
enum libusb_request_type { |
143 |
LIBUSB_REQUEST_TYPE_STANDARD = (0x00 << 5), |
144 |
LIBUSB_REQUEST_TYPE_CLASS = (0x01 << 5), |
145 |
LIBUSB_REQUEST_TYPE_VENDOR = (0x02 << 5), |
146 |
LIBUSB_REQUEST_TYPE_RESERVED = (0x03 << 5), |
147 |
}; |
148 |
|
149 |
enum libusb_request_recipient { |
150 |
LIBUSB_RECIPIENT_DEVICE = 0x00, |
151 |
LIBUSB_RECIPIENT_INTERFACE = 0x01, |
152 |
LIBUSB_RECIPIENT_ENDPOINT = 0x02, |
153 |
LIBUSB_RECIPIENT_OTHER = 0x03, |
154 |
}; |
155 |
|
156 |
#define LIBUSB_ISO_SYNC_TYPE_MASK 0x0C |
157 |
|
158 |
enum libusb_iso_sync_type { |
159 |
LIBUSB_ISO_SYNC_TYPE_NONE = 0, |
160 |
LIBUSB_ISO_SYNC_TYPE_ASYNC = 1, |
161 |
LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 2, |
162 |
LIBUSB_ISO_SYNC_TYPE_SYNC = 3, |
163 |
}; |
164 |
|
165 |
#define LIBUSB_ISO_USAGE_TYPE_MASK 0x30 |
166 |
|
167 |
enum libusb_iso_usage_type { |
168 |
LIBUSB_ISO_USAGE_TYPE_DATA = 0, |
169 |
LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1, |
170 |
LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2, |
171 |
}; |
172 |
|
173 |
enum libusb_bos_type { |
174 |
LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 1, |
175 |
LIBUSB_BT_USB_2_0_EXTENSION = 2, |
176 |
LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 3, |
177 |
LIBUSB_BT_CONTAINER_ID = 4, |
178 |
}; |
179 |
|
180 |
enum libusb_error { |
181 |
LIBUSB_SUCCESS = 0, |
182 |
LIBUSB_ERROR_IO = -1, |
183 |
LIBUSB_ERROR_INVALID_PARAM = -2, |
184 |
LIBUSB_ERROR_ACCESS = -3, |
185 |
LIBUSB_ERROR_NO_DEVICE = -4, |
186 |
LIBUSB_ERROR_NOT_FOUND = -5, |
187 |
LIBUSB_ERROR_BUSY = -6, |
188 |
LIBUSB_ERROR_TIMEOUT = -7, |
189 |
LIBUSB_ERROR_OVERFLOW = -8, |
190 |
LIBUSB_ERROR_PIPE = -9, |
191 |
LIBUSB_ERROR_INTERRUPTED = -10, |
192 |
LIBUSB_ERROR_NO_MEM = -11, |
193 |
LIBUSB_ERROR_NOT_SUPPORTED = -12, |
194 |
LIBUSB_ERROR_OTHER = -99, |
195 |
}; |
196 |
|
197 |
enum libusb_speed { |
198 |
LIBUSB_SPEED_UNKNOWN = 0, |
199 |
LIBUSB_SPEED_LOW = 1, |
200 |
LIBUSB_SPEED_FULL = 2, |
201 |
LIBUSB_SPEED_HIGH = 3, |
202 |
LIBUSB_SPEED_SUPER = 4, |
203 |
}; |
204 |
|
205 |
enum libusb_transfer_status { |
206 |
LIBUSB_TRANSFER_COMPLETED, |
207 |
LIBUSB_TRANSFER_ERROR, |
208 |
LIBUSB_TRANSFER_TIMED_OUT, |
209 |
LIBUSB_TRANSFER_CANCELLED, |
210 |
LIBUSB_TRANSFER_STALL, |
211 |
LIBUSB_TRANSFER_NO_DEVICE, |
212 |
LIBUSB_TRANSFER_OVERFLOW, |
213 |
}; |
214 |
|
215 |
enum libusb_transfer_flags { |
216 |
LIBUSB_TRANSFER_SHORT_NOT_OK = 1 << 0, |
217 |
LIBUSB_TRANSFER_FREE_BUFFER = 1 << 1, |
218 |
LIBUSB_TRANSFER_FREE_TRANSFER = 1 << 2, |
219 |
}; |
220 |
|
221 |
enum libusb_log_level { |
222 |
LIBUSB_LOG_LEVEL_NONE = 0, |
223 |
LIBUSB_LOG_LEVEL_ERROR, |
224 |
LIBUSB_LOG_LEVEL_WARNING, |
225 |
LIBUSB_LOG_LEVEL_INFO, |
226 |
LIBUSB_LOG_LEVEL_DEBUG |
227 |
}; |
228 |
|
229 |
/* XXX */ |
230 |
/* libusb_set_debug should take parameters from libusb_log_level |
231 |
* above according to |
232 |
* http://libusb.sourceforge.net/api-1.0/group__lib.html |
233 |
*/ |
234 |
enum libusb_debug_level { |
235 |
LIBUSB_DEBUG_NO=0, |
236 |
LIBUSB_DEBUG_FUNCTION=1, |
237 |
LIBUSB_DEBUG_TRANSFER=2, |
238 |
}; |
239 |
|
240 |
#define LIBUSB_HOTPLUG_MATCH_ANY -1 |
241 |
|
242 |
typedef enum { |
243 |
LIBUSB_HOTPLUG_NO_FLAGS = 0, |
244 |
LIBUSB_HOTPLUG_ENUMERATE = 1 << 0, |
245 |
} libusb_hotplug_flag; |
246 |
|
247 |
typedef enum { |
248 |
LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 1, |
249 |
LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = 2, |
250 |
} libusb_hotplug_event; |
251 |
|
252 |
/* libusb structures */ |
253 |
|
254 |
struct libusb_context; |
255 |
struct libusb_device; |
256 |
struct libusb_transfer; |
257 |
struct libusb_device_handle; |
258 |
struct libusb_hotplug_callback_handle_struct; |
259 |
|
260 |
struct libusb_pollfd { |
261 |
int fd; |
262 |
short events; |
263 |
}; |
264 |
|
265 |
struct libusb_version { |
266 |
const uint16_t major; |
267 |
const uint16_t minor; |
268 |
const uint16_t micro; |
269 |
const uint16_t nano; |
270 |
const char *rc; |
271 |
const char *describe; |
272 |
}; |
273 |
|
274 |
typedef struct libusb_context libusb_context; |
275 |
typedef struct libusb_device libusb_device; |
276 |
typedef struct libusb_device_handle libusb_device_handle; |
277 |
typedef struct libusb_pollfd libusb_pollfd; |
278 |
typedef void (*libusb_pollfd_added_cb) (int fd, short events, void *user_data); |
279 |
typedef void (*libusb_pollfd_removed_cb) (int fd, void *user_data); |
280 |
typedef struct libusb_hotplug_callback_handle_struct *libusb_hotplug_callback_handle; |
281 |
|
282 |
typedef struct libusb_device_descriptor { |
283 |
uint8_t bLength; |
284 |
uint8_t bDescriptorType; |
285 |
uint16_t bcdUSB; |
286 |
uint8_t bDeviceClass; |
287 |
uint8_t bDeviceSubClass; |
288 |
uint8_t bDeviceProtocol; |
289 |
uint8_t bMaxPacketSize0; |
290 |
uint16_t idVendor; |
291 |
uint16_t idProduct; |
292 |
uint16_t bcdDevice; |
293 |
uint8_t iManufacturer; |
294 |
uint8_t iProduct; |
295 |
uint8_t iSerialNumber; |
296 |
uint8_t bNumConfigurations; |
297 |
} libusb_device_descriptor; |
298 |
|
299 |
typedef struct libusb_endpoint_descriptor { |
300 |
uint8_t bLength; |
301 |
uint8_t bDescriptorType; |
302 |
uint8_t bEndpointAddress; |
303 |
uint8_t bmAttributes; |
304 |
uint16_t wMaxPacketSize; |
305 |
uint8_t bInterval; |
306 |
uint8_t bRefresh; |
307 |
uint8_t bSynchAddress; |
308 |
uint8_t *extra; |
309 |
int extra_length; |
310 |
} libusb_endpoint_descriptor __aligned(sizeof(void *)); |
311 |
|
312 |
typedef struct libusb_ss_endpoint_companion_descriptor { |
313 |
uint8_t bLength; |
314 |
uint8_t bDescriptorType; |
315 |
uint8_t bMaxBurst; |
316 |
uint8_t bmAttributes; |
317 |
uint16_t wBytesPerInterval; |
318 |
} libusb_ss_endpoint_companion_descriptor __aligned(sizeof(void *)); |
319 |
|
320 |
typedef struct libusb_interface_descriptor { |
321 |
uint8_t bLength; |
322 |
uint8_t bDescriptorType; |
323 |
uint8_t bInterfaceNumber; |
324 |
uint8_t bAlternateSetting; |
325 |
uint8_t bNumEndpoints; |
326 |
uint8_t bInterfaceClass; |
327 |
uint8_t bInterfaceSubClass; |
328 |
uint8_t bInterfaceProtocol; |
329 |
uint8_t iInterface; |
330 |
struct libusb_endpoint_descriptor *endpoint; |
331 |
uint8_t *extra; |
332 |
int extra_length; |
333 |
} libusb_interface_descriptor __aligned(sizeof(void *)); |
334 |
|
335 |
typedef struct libusb_interface { |
336 |
struct libusb_interface_descriptor *altsetting; |
337 |
int num_altsetting; |
338 |
} libusb_interface __aligned(sizeof(void *)); |
339 |
|
340 |
typedef struct libusb_config_descriptor { |
341 |
uint8_t bLength; |
342 |
uint8_t bDescriptorType; |
343 |
uint16_t wTotalLength; |
344 |
uint8_t bNumInterfaces; |
345 |
uint8_t bConfigurationValue; |
346 |
uint8_t iConfiguration; |
347 |
uint8_t bmAttributes; |
348 |
uint8_t MaxPower; |
349 |
struct libusb_interface *interface; |
350 |
uint8_t *extra; |
351 |
int extra_length; |
352 |
} libusb_config_descriptor __aligned(sizeof(void *)); |
353 |
|
354 |
typedef struct libusb_usb_2_0_device_capability_descriptor { |
355 |
uint8_t bLength; |
356 |
uint8_t bDescriptorType; |
357 |
uint8_t bDevCapabilityType; |
358 |
uint32_t bmAttributes; |
359 |
#define LIBUSB_USB_2_0_CAPABILITY_LPM_SUPPORT (1 << 1) |
360 |
} libusb_usb_2_0_device_capability_descriptor __aligned(sizeof(void *)); |
361 |
|
362 |
typedef struct libusb_ss_usb_device_capability_descriptor { |
363 |
uint8_t bLength; |
364 |
uint8_t bDescriptorType; |
365 |
uint8_t bDevCapabilityType; |
366 |
uint8_t bmAttributes; |
367 |
#define LIBUSB_SS_USB_CAPABILITY_LPM_SUPPORT (1 << 1) |
368 |
uint16_t wSpeedSupported; |
369 |
#define LIBUSB_CAPABILITY_LOW_SPEED_OPERATION (1) |
370 |
#define LIBUSB_CAPABILITY_FULL_SPEED_OPERATION (1 << 1) |
371 |
#define LIBUSB_CAPABILITY_HIGH_SPEED_OPERATION (1 << 2) |
372 |
#define LIBUSB_CAPABILITY_5GBPS_OPERATION (1 << 3) |
373 |
uint8_t bFunctionalitySupport; |
374 |
uint8_t bU1DevExitLat; |
375 |
uint16_t wU2DevExitLat; |
376 |
} libusb_ss_usb_device_capability_descriptor __aligned(sizeof(void *)); |
377 |
|
378 |
typedef struct libusb_bos_dev_capability_descriptor { |
379 |
uint8_t bLength; |
380 |
uint8_t bDescriptorType; |
381 |
uint8_t bDevCapabilityType; |
382 |
uint8_t dev_capability_data[0]; |
383 |
} libusb_bos_dev_capability_descriptor __aligned(sizeof(void *)); |
384 |
|
385 |
typedef struct libusb_bos_descriptor { |
386 |
uint8_t bLength; |
387 |
uint8_t bDescriptorType; |
388 |
uint16_t wTotalLength; |
389 |
uint8_t bNumDeviceCapabilities; |
390 |
struct libusb_usb_2_0_device_capability_descriptor *usb_2_0_ext_cap; |
391 |
struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap; |
392 |
} libusb_bos_descriptor __aligned(sizeof(void *)); |
393 |
|
394 |
typedef struct libusb_usb_2_0_extension_descriptor { |
395 |
uint8_t bLength; |
396 |
uint8_t bDescriptorType; |
397 |
uint8_t bDevCapabilityType; |
398 |
uint32_t bmAttributes; |
399 |
} libusb_usb_2_0_extension_descriptor __aligned(sizeof(void *)); |
400 |
|
401 |
typedef struct libusb_container_id_descriptor { |
402 |
uint8_t bLength; |
403 |
uint8_t bDescriptorType; |
404 |
uint8_t bDevCapabilityType; |
405 |
uint8_t bReserved; |
406 |
uint8_t ContainerID[16]; |
407 |
} libusb_container_id_descriptor __aligned(sizeof(void *)); |
408 |
|
409 |
typedef struct libusb_control_setup { |
410 |
uint8_t bmRequestType; |
411 |
uint8_t bRequest; |
412 |
uint16_t wValue; |
413 |
uint16_t wIndex; |
414 |
uint16_t wLength; |
415 |
} libusb_control_setup; |
416 |
|
417 |
#define LIBUSB_CONTROL_SETUP_SIZE 8 /* bytes */ |
418 |
|
419 |
typedef struct libusb_iso_packet_descriptor { |
420 |
uint32_t length; |
421 |
uint32_t actual_length; |
422 |
enum libusb_transfer_status status; |
423 |
} libusb_iso_packet_descriptor __aligned(sizeof(void *)); |
424 |
|
425 |
typedef void (*libusb_transfer_cb_fn) (struct libusb_transfer *transfer); |
426 |
|
427 |
typedef struct libusb_transfer { |
428 |
libusb_device_handle *dev_handle; |
429 |
uint8_t flags; |
430 |
uint8_t endpoint; |
431 |
uint8_t type; |
432 |
uint32_t timeout; |
433 |
enum libusb_transfer_status status; |
434 |
int length; |
435 |
int actual_length; |
436 |
libusb_transfer_cb_fn callback; |
437 |
void *user_data; |
438 |
uint8_t *buffer; |
439 |
int num_iso_packets; |
440 |
struct libusb_iso_packet_descriptor iso_packet_desc[0]; |
441 |
} libusb_transfer __aligned(sizeof(void *)); |
442 |
|
443 |
/* Library initialisation */ |
444 |
|
445 |
void libusb_set_debug(libusb_context * ctx, int level); |
446 |
const struct libusb_version *libusb_get_version(void); |
447 |
const char *libusb_strerror(int code); |
448 |
const char *libusb_error_name(int code); |
449 |
int libusb_init(libusb_context ** context); |
450 |
void libusb_exit(struct libusb_context *ctx); |
451 |
|
452 |
/* Device handling and enumeration */ |
453 |
|
454 |
ssize_t libusb_get_device_list(libusb_context * ctx, libusb_device *** list); |
455 |
void libusb_free_device_list(libusb_device ** list, int unref_devices); |
456 |
uint8_t libusb_get_bus_number(libusb_device * dev); |
457 |
uint8_t libusb_get_port_number(libusb_device * dev); |
458 |
int libusb_get_port_numbers(libusb_device *dev, uint8_t *buf, uint8_t bufsize); |
459 |
int libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *buf, uint8_t bufsize); |
460 |
uint8_t libusb_get_device_address(libusb_device * dev); |
461 |
enum libusb_speed libusb_get_device_speed(libusb_device * dev); |
462 |
int libusb_clear_halt(libusb_device_handle *devh, uint8_t endpoint); |
463 |
int libusb_get_max_packet_size(libusb_device * dev, uint8_t endpoint); |
464 |
int libusb_get_max_iso_packet_size(libusb_device * dev, uint8_t endpoint); |
465 |
libusb_device *libusb_ref_device(libusb_device * dev); |
466 |
void libusb_unref_device(libusb_device * dev); |
467 |
int libusb_open(libusb_device * dev, libusb_device_handle ** devh); |
468 |
libusb_device_handle *libusb_open_device_with_vid_pid(libusb_context * ctx, uint16_t vendor_id, uint16_t product_id); |
469 |
void libusb_close(libusb_device_handle * devh); |
470 |
libusb_device *libusb_get_device(libusb_device_handle * devh); |
471 |
int libusb_get_configuration(libusb_device_handle * devh, int *config); |
472 |
int libusb_set_configuration(libusb_device_handle * devh, int configuration); |
473 |
int libusb_claim_interface(libusb_device_handle * devh, int interface_number); |
474 |
int libusb_release_interface(libusb_device_handle * devh, int interface_number); |
475 |
int libusb_reset_device(libusb_device_handle * devh); |
476 |
int libusb_check_connected(libusb_device_handle * devh); |
477 |
int libusb_kernel_driver_active(libusb_device_handle * devh, int interface); |
478 |
int libusb_get_driver_np(libusb_device_handle * devh, int interface, char *name, int namelen); |
479 |
int libusb_get_driver(libusb_device_handle * devh, int interface, char *name, int namelen); |
480 |
int libusb_detach_kernel_driver_np(libusb_device_handle * devh, int interface); |
481 |
int libusb_detach_kernel_driver(libusb_device_handle * devh, int interface); |
482 |
int libusb_attach_kernel_driver(libusb_device_handle * devh, int interface); |
483 |
int libusb_set_auto_detach_kernel_driver(libusb_device_handle *dev, int enable); |
484 |
int libusb_set_interface_alt_setting(libusb_device_handle * devh, int interface_number, int alternate_setting); |
485 |
|
486 |
/* USB Descriptors */ |
487 |
|
488 |
int libusb_get_device_descriptor(libusb_device * dev, struct libusb_device_descriptor *desc); |
489 |
int libusb_get_active_config_descriptor(libusb_device * dev, struct libusb_config_descriptor **config); |
490 |
int libusb_get_config_descriptor(libusb_device * dev, uint8_t config_index, struct libusb_config_descriptor **config); |
491 |
int libusb_get_config_descriptor_by_value(libusb_device * dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config); |
492 |
void libusb_free_config_descriptor(struct libusb_config_descriptor *config); |
493 |
int libusb_get_ss_endpoint_companion_descriptor(struct libusb_context *ctx, const struct libusb_endpoint_descriptor *endpoint, struct libusb_ss_endpoint_companion_descriptor **ep_comp); |
494 |
void libusb_free_ss_endpoint_companion_descriptor(struct libusb_ss_endpoint_companion_descriptor *ep_comp); |
495 |
int libusb_get_string_descriptor(libusb_device_handle * devh, uint8_t desc_index, uint16_t langid, unsigned char *data, int length); |
496 |
int libusb_get_string_descriptor_ascii(libusb_device_handle * devh, uint8_t desc_index, uint8_t *data, int length); |
497 |
int libusb_get_descriptor(libusb_device_handle * devh, uint8_t desc_type, uint8_t desc_index, uint8_t *data, int length); |
498 |
int libusb_parse_ss_endpoint_comp(const void *buf, int len, struct libusb_ss_endpoint_companion_descriptor **ep_comp); |
499 |
void libusb_free_ss_endpoint_comp(struct libusb_ss_endpoint_companion_descriptor *ep_comp); |
500 |
int libusb_parse_bos_descriptor(const void *buf, int len, struct libusb_bos_descriptor **bos); |
501 |
void libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos); |
502 |
int libusb_get_bos_descriptor(libusb_device_handle *handle, struct libusb_bos_descriptor **bos); |
503 |
int libusb_get_usb_2_0_extension_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension); |
504 |
void libusb_free_usb_2_0_extension_descriptor(struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension); |
505 |
int libusb_get_ss_usb_device_capability_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_capability); |
506 |
void libusb_free_ss_usb_device_capability_descriptor(struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_capability); |
507 |
int libusb_get_container_id_descriptor(struct libusb_context *ctx, struct libusb_bos_dev_capability_descriptor *dev_cap, struct libusb_container_id_descriptor **container_id); |
508 |
void libusb_free_container_id_descriptor(struct libusb_container_id_descriptor *container_id); |
509 |
|
510 |
/* Asynchronous device I/O */ |
511 |
|
512 |
struct libusb_transfer *libusb_alloc_transfer(int iso_packets); |
513 |
void libusb_free_transfer(struct libusb_transfer *transfer); |
514 |
int libusb_submit_transfer(struct libusb_transfer *transfer); |
515 |
int libusb_cancel_transfer(struct libusb_transfer *transfer); |
516 |
uint8_t *libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t index); |
517 |
uint8_t *libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, uint32_t index); |
518 |
void libusb_set_iso_packet_lengths(struct libusb_transfer *transfer, uint32_t length); |
519 |
uint8_t *libusb_control_transfer_get_data(struct libusb_transfer *transfer); |
520 |
struct libusb_control_setup *libusb_control_transfer_get_setup(struct libusb_transfer *transfer); |
521 |
void libusb_fill_control_setup(uint8_t *buf, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength); |
522 |
void libusb_fill_control_transfer(struct libusb_transfer *transfer, libusb_device_handle *devh, uint8_t *buf, libusb_transfer_cb_fn callback, void *user_data, uint32_t timeout); |
523 |
void libusb_fill_bulk_transfer(struct libusb_transfer *transfer, libusb_device_handle *devh, uint8_t endpoint, uint8_t *buf, int length, libusb_transfer_cb_fn callback, void *user_data, uint32_t timeout); |
524 |
void libusb_fill_interrupt_transfer(struct libusb_transfer *transfer, libusb_device_handle *devh, uint8_t endpoint, uint8_t *buf, int length, libusb_transfer_cb_fn callback, void *user_data, uint32_t timeout); |
525 |
void libusb_fill_iso_transfer(struct libusb_transfer *transfer, libusb_device_handle *devh, uint8_t endpoint, uint8_t *buf, int length, int npacket, libusb_transfer_cb_fn callback, void *user_data, uint32_t timeout); |
526 |
|
527 |
/* Polling and timing */ |
528 |
|
529 |
int libusb_try_lock_events(libusb_context * ctx); |
530 |
void libusb_lock_events(libusb_context * ctx); |
531 |
void libusb_unlock_events(libusb_context * ctx); |
532 |
int libusb_event_handling_ok(libusb_context * ctx); |
533 |
int libusb_event_handler_active(libusb_context * ctx); |
534 |
void libusb_lock_event_waiters(libusb_context * ctx); |
535 |
void libusb_unlock_event_waiters(libusb_context * ctx); |
536 |
int libusb_wait_for_event(libusb_context * ctx, struct timeval *tv); |
537 |
int libusb_handle_events_timeout_completed(libusb_context * ctx, struct timeval *tv, int *completed); |
538 |
int libusb_handle_events_completed(libusb_context * ctx, int *completed); |
539 |
int libusb_handle_events_timeout(libusb_context * ctx, struct timeval *tv); |
540 |
int libusb_handle_events(libusb_context * ctx); |
541 |
int libusb_handle_events_locked(libusb_context * ctx, struct timeval *tv); |
542 |
int libusb_get_next_timeout(libusb_context * ctx, struct timeval *tv); |
543 |
void libusb_set_pollfd_notifiers(libusb_context * ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data); |
544 |
const struct libusb_pollfd **libusb_get_pollfds(libusb_context * ctx); |
545 |
|
546 |
/* Synchronous device I/O */ |
547 |
|
548 |
int libusb_control_transfer(libusb_device_handle * devh, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint8_t *data, uint16_t wLength, uint32_t timeout); |
549 |
int libusb_bulk_transfer(libusb_device_handle * devh, uint8_t endpoint, uint8_t *data, int length, int *transferred, uint32_t timeout); |
550 |
int libusb_interrupt_transfer(libusb_device_handle * devh, uint8_t endpoint, uint8_t *data, int length, int *transferred, uint32_t timeout); |
551 |
|
552 |
/* Byte-order */ |
553 |
|
554 |
uint16_t libusb_cpu_to_le16(uint16_t x); |
555 |
uint16_t libusb_le16_to_cpu(uint16_t x); |
556 |
|
557 |
/* Hotplug support */ |
558 |
|
559 |
typedef int (*libusb_hotplug_callback_fn)(libusb_context *ctx, |
560 |
libusb_device *device, libusb_hotplug_event event, void *user_data); |
561 |
|
562 |
int libusb_hotplug_register_callback(libusb_context *ctx, libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, libusb_hotplug_callback_fn cb_fn, void *user_data, libusb_hotplug_callback_handle *handle); |
563 |
void libusb_hotplug_deregister_callback(libusb_context *ctx, libusb_hotplug_callback_handle handle); |
564 |
|
565 |
/* Streams support */ |
566 |
|
567 |
int libusb_alloc_streams(libusb_device_handle *dev, uint32_t num_streams, unsigned char *endpoints, int num_endpoints); |
568 |
int libusb_free_streams(libusb_device_handle *dev, unsigned char *endpoints, int num_endpoints); |
569 |
void libusb_transfer_set_stream_id(struct libusb_transfer *transfer, uint32_t stream_id); |
570 |
uint32_t libusb_transfer_get_stream_id(struct libusb_transfer *transfer); |
571 |
|
572 |
#if 0 |
573 |
{ /* indent fix */ |
574 |
#endif |
575 |
#ifdef __cplusplus |
576 |
} |
577 |
|
578 |
#endif |
579 |
|
580 |
#endif /* __LIBUSB_H__ */ |