1 /* $FreeBSD$ */ 2 /*- 3 * Copyright (c) 2009 Sylvestre Gallon. All rights reserved. 4 * 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. 13 * 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. 25 */ 26 27 #ifndef __LIBUSB_H__ 28 #define __LIBUSB_H__ 29 30 #ifndef LIBUSB_GLOBAL_INCLUDE_FILE 31 #include <stdint.h> 32 #include <sys/time.h> 33 #include <sys/types.h> 34 #endif 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 #if 0 40 } /* indent fix */ 41 42 #endif 43 44 /* libusb enums */ 45 46 enum libusb_class_code { 47 LIBUSB_CLASS_PER_INTERFACE = 0, 48 LIBUSB_CLASS_AUDIO = 1, 49 LIBUSB_CLASS_COMM = 2, 50 LIBUSB_CLASS_HID = 3, 51 LIBUSB_CLASS_PTP = 6, 52 LIBUSB_CLASS_PRINTER = 7, 53 LIBUSB_CLASS_MASS_STORAGE = 8, 54 LIBUSB_CLASS_HUB = 9, 55 LIBUSB_CLASS_DATA = 10, 56 LIBUSB_CLASS_VENDOR_SPEC = 0xff, 57 }; 58 59 enum libusb_descriptor_type { 60 LIBUSB_DT_DEVICE = 0x01, 61 LIBUSB_DT_CONFIG = 0x02, 62 LIBUSB_DT_STRING = 0x03, 63 LIBUSB_DT_INTERFACE = 0x04, 64 LIBUSB_DT_ENDPOINT = 0x05, 65 LIBUSB_DT_HID = 0x21, 66 LIBUSB_DT_REPORT = 0x22, 67 LIBUSB_DT_PHYSICAL = 0x23, 68 LIBUSB_DT_HUB = 0x29, 69 LIBUSB_DT_BOS = 0x0f, 70 LIBUSB_DT_DEVICE_CAPABILITY = 0x10, 71 LIBUSB_DT_SS_ENDPOINT_COMPANION = 0x30, 72 }; 73 74 enum libusb_device_capability_type { 75 LIBUSB_WIRELESS_USB_DEVICE_CAPABILITY = 0x1, 76 LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY = 0x2, 77 LIBUSB_SS_USB_DEVICE_CAPABILITY = 0x3, 78 LIBUSB_CONTAINER_ID_DEVICE_CAPABILITY = 0x4, 79 }; 80 81 #define LIBUSB_DT_DEVICE_SIZE 18 82 #define LIBUSB_DT_CONFIG_SIZE 9 83 #define LIBUSB_DT_INTERFACE_SIZE 9 84 #define LIBUSB_DT_ENDPOINT_SIZE 7 85 #define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 86 #define LIBUSB_DT_HUB_NONVAR_SIZE 7 87 #define LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE 6 88 #define LIBUSB_DT_BOS_SIZE 5 89 #define LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE 7 90 #define LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE 10 91 92 #define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f 93 #define LIBUSB_ENDPOINT_DIR_MASK 0x80 94 95 enum libusb_endpoint_direction { 96 LIBUSB_ENDPOINT_IN = 0x80, 97 LIBUSB_ENDPOINT_OUT = 0x00, 98 }; 99 100 #define LIBUSB_TRANSFER_TYPE_MASK 0x03 101 102 enum libusb_transfer_type { 103 LIBUSB_TRANSFER_TYPE_CONTROL = 0, 104 LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1, 105 LIBUSB_TRANSFER_TYPE_BULK = 2, 106 LIBUSB_TRANSFER_TYPE_INTERRUPT = 3, 107 }; 108 109 enum libusb_standard_request { 110 LIBUSB_REQUEST_GET_STATUS = 0x00, 111 LIBUSB_REQUEST_CLEAR_FEATURE = 0x01, 112 LIBUSB_REQUEST_SET_FEATURE = 0x03, 113 LIBUSB_REQUEST_SET_ADDRESS = 0x05, 114 LIBUSB_REQUEST_GET_DESCRIPTOR = 0x06, 115 LIBUSB_REQUEST_SET_DESCRIPTOR = 0x07, 116 LIBUSB_REQUEST_GET_CONFIGURATION = 0x08, 117 LIBUSB_REQUEST_SET_CONFIGURATION = 0x09, 118 LIBUSB_REQUEST_GET_INTERFACE = 0x0A, 119 LIBUSB_REQUEST_SET_INTERFACE = 0x0B, 120 LIBUSB_REQUEST_SYNCH_FRAME = 0x0C, 121 }; 122 123 enum libusb_request_type { 124 LIBUSB_REQUEST_TYPE_STANDARD = (0x00 << 5), 125 LIBUSB_REQUEST_TYPE_CLASS = (0x01 << 5), 126 LIBUSB_REQUEST_TYPE_VENDOR = (0x02 << 5), 127 LIBUSB_REQUEST_TYPE_RESERVED = (0x03 << 5), 128 }; 129 130 enum libusb_request_recipient { 131 LIBUSB_RECIPIENT_DEVICE = 0x00, 132 LIBUSB_RECIPIENT_INTERFACE = 0x01, 133 LIBUSB_RECIPIENT_ENDPOINT = 0x02, 134 LIBUSB_RECIPIENT_OTHER = 0x03, 135 }; 136 137 #define LIBUSB_ISO_SYNC_TYPE_MASK 0x0C 138 139 enum libusb_iso_sync_type { 140 LIBUSB_ISO_SYNC_TYPE_NONE = 0, 141 LIBUSB_ISO_SYNC_TYPE_ASYNC = 1, 142 LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 2, 143 LIBUSB_ISO_SYNC_TYPE_SYNC = 3, 144 }; 145 146 #define LIBUSB_ISO_USAGE_TYPE_MASK 0x30 147 148 enum libusb_iso_usage_type { 149 LIBUSB_ISO_USAGE_TYPE_DATA = 0, 150 LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1, 151 LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2, 152 }; 153 154 enum libusb_error { 155 LIBUSB_SUCCESS = 0, 156 LIBUSB_ERROR_IO = -1, 157 LIBUSB_ERROR_INVALID_PARAM = -2, 158 LIBUSB_ERROR_ACCESS = -3, 159 LIBUSB_ERROR_NO_DEVICE = -4, 160 LIBUSB_ERROR_NOT_FOUND = -5, 161 LIBUSB_ERROR_BUSY = -6, 162 LIBUSB_ERROR_TIMEOUT = -7, 163 LIBUSB_ERROR_OVERFLOW = -8, 164 LIBUSB_ERROR_PIPE = -9, 165 LIBUSB_ERROR_INTERRUPTED = -10, 166 LIBUSB_ERROR_NO_MEM = -11, 167 LIBUSB_ERROR_NOT_SUPPORTED = -12, 168 LIBUSB_ERROR_OTHER = -99, 169 }; 170 171 enum libusb_speed { 172 LIBUSB_SPEED_UNKNOWN = 0, 173 LIBUSB_SPEED_LOW = 1, 174 LIBUSB_SPEED_FULL = 2, 175 LIBUSB_SPEED_HIGH = 3, 176 LIBUSB_SPEED_SUPER = 4, 177 }; 178 179 enum libusb_transfer_status { 180 LIBUSB_TRANSFER_COMPLETED, 181 LIBUSB_TRANSFER_ERROR, 182 LIBUSB_TRANSFER_TIMED_OUT, 183 LIBUSB_TRANSFER_CANCELLED, 184 LIBUSB_TRANSFER_STALL, 185 LIBUSB_TRANSFER_NO_DEVICE, 186 LIBUSB_TRANSFER_OVERFLOW, 187 }; 188 189 enum libusb_transfer_flags { 190 LIBUSB_TRANSFER_SHORT_NOT_OK = 1 << 0, 191 LIBUSB_TRANSFER_FREE_BUFFER = 1 << 1, 192 LIBUSB_TRANSFER_FREE_TRANSFER = 1 << 2, 193 }; 194 195 enum libusb_log_level { 196 LIBUSB_LOG_LEVEL_NONE = 0, 197 LIBUSB_LOG_LEVEL_ERROR, 198 LIBUSB_LOG_LEVEL_WARNING, 199 LIBUSB_LOG_LEVEL_INFO, 200 LIBUSB_LOG_LEVEL_DEBUG 201 }; 202 203 /* XXX */ 204 /* libusb_set_debug should take parameters from libusb_log_level 205 * above according to 206 * http://libusb.sourceforge.net/api-1.0/group__lib.html 207 */ 208 enum libusb_debug_level { 209 LIBUSB_DEBUG_NO=0, 210 LIBUSB_DEBUG_FUNCTION=1, 211 LIBUSB_DEBUG_TRANSFER=2, 212 }; 213 214 /* libusb structures */ 215 216 struct libusb_context; 217 struct libusb_device; 218 struct libusb_transfer; 219 struct libusb_device_handle; 220 221 struct libusb_pollfd { 222 int fd; 223 short events; 224 }; 225 226 typedef struct libusb_context libusb_context; 227 typedef struct libusb_device libusb_device; 228 typedef struct libusb_device_handle libusb_device_handle; 229 typedef struct libusb_pollfd libusb_pollfd; 230 typedef void (*libusb_pollfd_added_cb) (int fd, short events, void *user_data); 231 typedef void (*libusb_pollfd_removed_cb) (int fd, void *user_data); 232 233 typedef struct libusb_device_descriptor { 234 uint8_t bLength; 235 uint8_t bDescriptorType; 236 uint16_t bcdUSB; 237 uint8_t bDeviceClass; 238 uint8_t bDeviceSubClass; 239 uint8_t bDeviceProtocol; 240 uint8_t bMaxPacketSize0; 241 uint16_t idVendor; 242 uint16_t idProduct; 243 uint16_t bcdDevice; 244 uint8_t iManufacturer; 245 uint8_t iProduct; 246 uint8_t iSerialNumber; 247 uint8_t bNumConfigurations; 248 } libusb_device_descriptor; 249 250 typedef struct libusb_endpoint_descriptor { 251 uint8_t bLength; 252 uint8_t bDescriptorType; 253 uint8_t bEndpointAddress; 254 uint8_t bmAttributes; 255 uint16_t wMaxPacketSize; 256 uint8_t bInterval; 257 uint8_t bRefresh; 258 uint8_t bSynchAddress; 259 uint8_t *extra; 260 int extra_length; 261 } libusb_endpoint_descriptor __aligned(sizeof(void *)); 262 263 typedef struct libusb_ss_endpoint_companion_descriptor { 264 uint8_t bLength; 265 uint8_t bDescriptorType; 266 uint8_t bMaxBurst; 267 uint8_t bmAttributes; 268 uint16_t wBytesPerInterval; 269 } libusb_ss_endpoint_companion_descriptor __aligned(sizeof(void *)); 270 271 typedef struct libusb_interface_descriptor { 272 uint8_t bLength; 273 uint8_t bDescriptorType; 274 uint8_t bInterfaceNumber; 275 uint8_t bAlternateSetting; 276 uint8_t bNumEndpoints; 277 uint8_t bInterfaceClass; 278 uint8_t bInterfaceSubClass; 279 uint8_t bInterfaceProtocol; 280 uint8_t iInterface; 281 struct libusb_endpoint_descriptor *endpoint; 282 uint8_t *extra; 283 int extra_length; 284 } libusb_interface_descriptor __aligned(sizeof(void *)); 285 286 typedef struct libusb_interface { 287 struct libusb_interface_descriptor *altsetting; 288 int num_altsetting; 289 } libusb_interface __aligned(sizeof(void *)); 290 291 typedef struct libusb_config_descriptor { 292 uint8_t bLength; 293 uint8_t bDescriptorType; 294 uint16_t wTotalLength; 295 uint8_t bNumInterfaces; 296 uint8_t bConfigurationValue; 297 uint8_t iConfiguration; 298 uint8_t bmAttributes; 299 uint8_t MaxPower; 300 struct libusb_interface *interface; 301 uint8_t *extra; 302 int extra_length; 303 } libusb_config_descriptor __aligned(sizeof(void *)); 304 305 typedef struct libusb_usb_2_0_device_capability_descriptor { 306 uint8_t bLength; 307 uint8_t bDescriptorType; 308 uint8_t bDevCapabilityType; 309 uint32_t bmAttributes; 310 #define LIBUSB_USB_2_0_CAPABILITY_LPM_SUPPORT (1 << 1) 311 } libusb_usb_2_0_device_capability_descriptor __aligned(sizeof(void *)); 312 313 typedef struct libusb_ss_usb_device_capability_descriptor { 314 uint8_t bLength; 315 uint8_t bDescriptorType; 316 uint8_t bDevCapabilityType; 317 uint8_t bmAttributes; 318 #define LIBUSB_SS_USB_CAPABILITY_LPM_SUPPORT (1 << 1) 319 uint16_t wSpeedSupported; 320 #define LIBUSB_CAPABILITY_LOW_SPEED_OPERATION (1) 321 #define LIBUSB_CAPABILITY_FULL_SPEED_OPERATION (1 << 1) 322 #define LIBUSB_CAPABILITY_HIGH_SPEED_OPERATION (1 << 2) 323 #define LIBUSB_CAPABILITY_5GBPS_OPERATION (1 << 3) 324 uint8_t bFunctionalitySupport; 325 uint8_t bU1DevExitLat; 326 uint16_t wU2DevExitLat; 327 } libusb_ss_usb_device_capability_descriptor __aligned(sizeof(void *)); 328 329 typedef struct libusb_bos_descriptor { 330 uint8_t bLength; 331 uint8_t bDescriptorType; 332 uint16_t wTotalLength; 333 uint8_t bNumDeviceCapabilities; 334 struct libusb_usb_2_0_device_capability_descriptor *usb_2_0_ext_cap; 335 struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap; 336 } libusb_bos_descriptor __aligned(sizeof(void *)); 337 338 typedef struct libusb_control_setup { 339 uint8_t bmRequestType; 340 uint8_t bRequest; 341 uint16_t wValue; 342 uint16_t wIndex; 343 uint16_t wLength; 344 } libusb_control_setup; 345 346 #define LIBUSB_CONTROL_SETUP_SIZE 8 /* bytes */ 347 348 typedef struct libusb_iso_packet_descriptor { 349 uint32_t length; 350 uint32_t actual_length; 351 enum libusb_transfer_status status; 352 } libusb_iso_packet_descriptor __aligned(sizeof(void *)); 353 354 typedef void (*libusb_transfer_cb_fn) (struct libusb_transfer *transfer); 355 356 typedef struct libusb_transfer { 357 libusb_device_handle *dev_handle; 358 uint8_t flags; 359 uint8_t endpoint; 360 uint8_t type; 361 uint32_t timeout; 362 enum libusb_transfer_status status; 363 int length; 364 int actual_length; 365 libusb_transfer_cb_fn callback; 366 void *user_data; 367 uint8_t *buffer; 368 int num_iso_packets; 369 struct libusb_iso_packet_descriptor iso_packet_desc[0]; 370 } libusb_transfer __aligned(sizeof(void *)); 371 372 /* Library initialisation */ 373 374 void libusb_set_debug(libusb_context * ctx, int level); 375 const char *libusb_strerror(int code); 376 const char *libusb_error_name(int code); 377 int libusb_init(libusb_context ** context); 378 void libusb_exit(struct libusb_context *ctx); 379 380 /* Device handling and enumeration */ 381 382 ssize_t libusb_get_device_list(libusb_context * ctx, libusb_device *** list); 383 void libusb_free_device_list(libusb_device ** list, int unref_devices); 384 uint8_t libusb_get_bus_number(libusb_device * dev); 385 int libusb_get_port_numbers(libusb_device *dev, uint8_t *buf, uint8_t bufsize); 386 int libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *buf, uint8_t bufsize); 387 uint8_t libusb_get_device_address(libusb_device * dev); 388 enum libusb_speed libusb_get_device_speed(libusb_device * dev); 389 int libusb_clear_halt(libusb_device_handle *devh, uint8_t endpoint); 390 int libusb_get_max_packet_size(libusb_device * dev, uint8_t endpoint); 391 int libusb_get_max_iso_packet_size(libusb_device * dev, uint8_t endpoint); 392 libusb_device *libusb_ref_device(libusb_device * dev); 393 void libusb_unref_device(libusb_device * dev); 394 int libusb_open(libusb_device * dev, libusb_device_handle ** devh); 395 libusb_device_handle *libusb_open_device_with_vid_pid(libusb_context * ctx, uint16_t vendor_id, uint16_t product_id); 396 void libusb_close(libusb_device_handle * devh); 397 libusb_device *libusb_get_device(libusb_device_handle * devh); 398 int libusb_get_configuration(libusb_device_handle * devh, int *config); 399 int libusb_set_configuration(libusb_device_handle * devh, int configuration); 400 int libusb_claim_interface(libusb_device_handle * devh, int interface_number); 401 int libusb_release_interface(libusb_device_handle * devh, int interface_number); 402 int libusb_reset_device(libusb_device_handle * devh); 403 int libusb_check_connected(libusb_device_handle * devh); 404 int libusb_kernel_driver_active(libusb_device_handle * devh, int interface); 405 int libusb_get_driver_np(libusb_device_handle * devh, int interface, char *name, int namelen); 406 int libusb_get_driver(libusb_device_handle * devh, int interface, char *name, int namelen); 407 int libusb_detach_kernel_driver_np(libusb_device_handle * devh, int interface); 408 int libusb_detach_kernel_driver(libusb_device_handle * devh, int interface); 409 int libusb_attach_kernel_driver(libusb_device_handle * devh, int interface); 410 int libusb_set_interface_alt_setting(libusb_device_handle * devh, int interface_number, int alternate_setting); 411 412 /* USB Descriptors */ 413 414 int libusb_get_device_descriptor(libusb_device * dev, struct libusb_device_descriptor *desc); 415 int libusb_get_active_config_descriptor(libusb_device * dev, struct libusb_config_descriptor **config); 416 int libusb_get_config_descriptor(libusb_device * dev, uint8_t config_index, struct libusb_config_descriptor **config); 417 int libusb_get_config_descriptor_by_value(libusb_device * dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config); 418 void libusb_free_config_descriptor(struct libusb_config_descriptor *config); 419 int libusb_get_string_descriptor(libusb_device_handle * devh, uint8_t desc_index, uint16_t langid, unsigned char *data, int length); 420 int libusb_get_string_descriptor_ascii(libusb_device_handle * devh, uint8_t desc_index, uint8_t *data, int length); 421 int libusb_get_descriptor(libusb_device_handle * devh, uint8_t desc_type, uint8_t desc_index, uint8_t *data, int length); 422 int libusb_parse_ss_endpoint_comp(const void *buf, int len, struct libusb_ss_endpoint_companion_descriptor **ep_comp); 423 void libusb_free_ss_endpoint_comp(struct libusb_ss_endpoint_companion_descriptor *ep_comp); 424 int libusb_parse_bos_descriptor(const void *buf, int len, struct libusb_bos_descriptor **bos); 425 void libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos); 426 427 /* Asynchronous device I/O */ 428 429 struct libusb_transfer *libusb_alloc_transfer(int iso_packets); 430 void libusb_free_transfer(struct libusb_transfer *transfer); 431 int libusb_submit_transfer(struct libusb_transfer *transfer); 432 int libusb_cancel_transfer(struct libusb_transfer *transfer); 433 uint8_t *libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t index); 434 uint8_t *libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, uint32_t index); 435 void libusb_set_iso_packet_lengths(struct libusb_transfer *transfer, uint32_t length); 436 uint8_t *libusb_control_transfer_get_data(struct libusb_transfer *transfer); 437 struct libusb_control_setup *libusb_control_transfer_get_setup(struct libusb_transfer *transfer); 438 void libusb_fill_control_setup(uint8_t *buf, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength); 439 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); 440 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); 441 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); 442 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); 443 444 /* Polling and timing */ 445 446 int libusb_try_lock_events(libusb_context * ctx); 447 void libusb_lock_events(libusb_context * ctx); 448 void libusb_unlock_events(libusb_context * ctx); 449 int libusb_event_handling_ok(libusb_context * ctx); 450 int libusb_event_handler_active(libusb_context * ctx); 451 void libusb_lock_event_waiters(libusb_context * ctx); 452 void libusb_unlock_event_waiters(libusb_context * ctx); 453 int libusb_wait_for_event(libusb_context * ctx, struct timeval *tv); 454 int libusb_handle_events_timeout_completed(libusb_context * ctx, struct timeval *tv, int *completed); 455 int libusb_handle_events_completed(libusb_context * ctx, int *completed); 456 int libusb_handle_events_timeout(libusb_context * ctx, struct timeval *tv); 457 int libusb_handle_events(libusb_context * ctx); 458 int libusb_handle_events_locked(libusb_context * ctx, struct timeval *tv); 459 int libusb_get_next_timeout(libusb_context * ctx, struct timeval *tv); 460 void libusb_set_pollfd_notifiers(libusb_context * ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data); 461 const struct libusb_pollfd **libusb_get_pollfds(libusb_context * ctx); 462 463 /* Synchronous device I/O */ 464 465 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); 466 int libusb_bulk_transfer(libusb_device_handle * devh, uint8_t endpoint, uint8_t *data, int length, int *transferred, uint32_t timeout); 467 int libusb_interrupt_transfer(libusb_device_handle * devh, uint8_t endpoint, uint8_t *data, int length, int *transferred, uint32_t timeout); 468 469 /* Byte-order */ 470 471 uint16_t libusb_cpu_to_le16(uint16_t x); 472 uint16_t libusb_le16_to_cpu(uint16_t x); 473 474 #if 0 475 { /* indent fix */ 476 #endif 477 #ifdef __cplusplus 478 } 479 480 #endif 481 482 #endif /* __LIBUSB_H__ */ 483