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