libusb.h (70d8f36aa445e4556ead4de32f9b7b4687d95098) libusb.h (4c0392e6fd10cd0ef9974ccfe16fb4a0f808711b)
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

--- 49 unchanged lines hidden (view full) ---

58 LIBUSB_DT_CONFIG = 0x02,
59 LIBUSB_DT_STRING = 0x03,
60 LIBUSB_DT_INTERFACE = 0x04,
61 LIBUSB_DT_ENDPOINT = 0x05,
62 LIBUSB_DT_HID = 0x21,
63 LIBUSB_DT_REPORT = 0x22,
64 LIBUSB_DT_PHYSICAL = 0x23,
65 LIBUSB_DT_HUB = 0x29,
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

--- 49 unchanged lines hidden (view full) ---

58 LIBUSB_DT_CONFIG = 0x02,
59 LIBUSB_DT_STRING = 0x03,
60 LIBUSB_DT_INTERFACE = 0x04,
61 LIBUSB_DT_ENDPOINT = 0x05,
62 LIBUSB_DT_HID = 0x21,
63 LIBUSB_DT_REPORT = 0x22,
64 LIBUSB_DT_PHYSICAL = 0x23,
65 LIBUSB_DT_HUB = 0x29,
66 LIBUSB_DT_BOS = 0x0f,
67 LIBUSB_DT_DEVICE_CAPABILITY = 0x10,
68 LIBUSB_DT_SS_ENDPOINT_COMPANION = 0x30,
66};
67
69};
70
71enum libusb_device_capability_type {
72 LIBUSB_WIRELESS_USB_DEVICE_CAPABILITY = 0x1,
73 LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY = 0x2,
74 LIBUSB_SS_USB_DEVICE_CAPABILITY = 0x3,
75 LIBUSB_CONTAINER_ID_DEVICE_CAPABILITY = 0x4,
76};
77
68#define LIBUSB_DT_DEVICE_SIZE 18
69#define LIBUSB_DT_CONFIG_SIZE 9
70#define LIBUSB_DT_INTERFACE_SIZE 9
71#define LIBUSB_DT_ENDPOINT_SIZE 7
72#define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9
73#define LIBUSB_DT_HUB_NONVAR_SIZE 7
78#define LIBUSB_DT_DEVICE_SIZE 18
79#define LIBUSB_DT_CONFIG_SIZE 9
80#define LIBUSB_DT_INTERFACE_SIZE 9
81#define LIBUSB_DT_ENDPOINT_SIZE 7
82#define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9
83#define LIBUSB_DT_HUB_NONVAR_SIZE 7
84#define LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE 6
85#define LIBUSB_DT_BOS_SIZE 5
86#define LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE 7
87#define LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE 10
74
75#define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f
76#define LIBUSB_ENDPOINT_DIR_MASK 0x80
77
78enum libusb_endpoint_direction {
79 LIBUSB_ENDPOINT_IN = 0x80,
80 LIBUSB_ENDPOINT_OUT = 0x00,
81};

--- 143 unchanged lines hidden (view full) ---

225 uint16_t wMaxPacketSize;
226 uint8_t bInterval;
227 uint8_t bRefresh;
228 uint8_t bSynchAddress;
229 uint8_t *extra;
230 int extra_length;
231} libusb_endpoint_descriptor __aligned(sizeof(void *));
232
88
89#define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f
90#define LIBUSB_ENDPOINT_DIR_MASK 0x80
91
92enum libusb_endpoint_direction {
93 LIBUSB_ENDPOINT_IN = 0x80,
94 LIBUSB_ENDPOINT_OUT = 0x00,
95};

--- 143 unchanged lines hidden (view full) ---

239 uint16_t wMaxPacketSize;
240 uint8_t bInterval;
241 uint8_t bRefresh;
242 uint8_t bSynchAddress;
243 uint8_t *extra;
244 int extra_length;
245} libusb_endpoint_descriptor __aligned(sizeof(void *));
246
247typedef struct libusb_ss_endpoint_companion_descriptor {
248 uint8_t bLength;
249 uint8_t bDescriptorType;
250 uint8_t bMaxBurst;
251 uint8_t bmAttributes;
252 uint16_t wBytesPerInterval;
253} libusb_ss_endpoint_companion_descriptor __aligned(sizeof(void *));
254
233typedef struct libusb_interface_descriptor {
234 uint8_t bLength;
235 uint8_t bDescriptorType;
236 uint8_t bInterfaceNumber;
237 uint8_t bAlternateSetting;
238 uint8_t bNumEndpoints;
239 uint8_t bInterfaceClass;
240 uint8_t bInterfaceSubClass;

--- 18 unchanged lines hidden (view full) ---

259 uint8_t iConfiguration;
260 uint8_t bmAttributes;
261 uint8_t MaxPower;
262 struct libusb_interface *interface;
263 uint8_t *extra;
264 int extra_length;
265} libusb_config_descriptor __aligned(sizeof(void *));
266
255typedef struct libusb_interface_descriptor {
256 uint8_t bLength;
257 uint8_t bDescriptorType;
258 uint8_t bInterfaceNumber;
259 uint8_t bAlternateSetting;
260 uint8_t bNumEndpoints;
261 uint8_t bInterfaceClass;
262 uint8_t bInterfaceSubClass;

--- 18 unchanged lines hidden (view full) ---

281 uint8_t iConfiguration;
282 uint8_t bmAttributes;
283 uint8_t MaxPower;
284 struct libusb_interface *interface;
285 uint8_t *extra;
286 int extra_length;
287} libusb_config_descriptor __aligned(sizeof(void *));
288
289typedef struct libusb_usb_2_0_device_capability_descriptor {
290 uint8_t bLength;
291 uint8_t bDescriptorType;
292 uint8_t bDevCapabilityType;
293 uint32_t bmAttributes;
294#define LIBUSB_USB_2_0_CAPABILITY_LPM_SUPPORT (1 << 1)
295} libusb_usb_2_0_device_capability_descriptor __aligned(sizeof(void *));
296
297typedef struct libusb_ss_usb_device_capability_descriptor {
298 uint8_t bLength;
299 uint8_t bDescriptorType;
300 uint8_t bDevCapabilityType;
301 uint8_t bmAttributes;
302#define LIBUSB_SS_USB_CAPABILITY_LPM_SUPPORT (1 << 1)
303 uint16_t wSpeedSupported;
304#define LIBUSB_CAPABILITY_LOW_SPEED_OPERATION (1)
305#define LIBUSB_CAPABILITY_FULL_SPEED_OPERATION (1 << 1)
306#define LIBUSB_CAPABILITY_HIGH_SPEED_OPERATION (1 << 2)
307#define LIBUSB_CAPABILITY_5GBPS_OPERATION (1 << 3)
308 uint8_t bFunctionalitySupport;
309 uint8_t bU1DevExitLat;
310 uint16_t wU2DevExitLat;
311} libusb_ss_usb_device_capability_descriptor __aligned(sizeof(void *));
312
313typedef struct libusb_bos_descriptor {
314 uint8_t bLength;
315 uint8_t bDescriptorType;
316 uint16_t wTotalLength;
317 uint8_t bNumDeviceCapabilities;
318 struct libusb_usb_2_0_device_capability_descriptor *usb_2_0_ext_cap;
319 struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap;
320} libusb_bos_descriptor __aligned(sizeof(void *));
321
267typedef struct libusb_control_setup {
268 uint8_t bmRequestType;
269 uint8_t bRequest;
270 uint16_t wValue;
271 uint16_t wIndex;
272 uint16_t wLength;
273} libusb_control_setup;
274

--- 65 unchanged lines hidden (view full) ---

340
341int libusb_get_device_descriptor(libusb_device * dev, struct libusb_device_descriptor *desc);
342int libusb_get_active_config_descriptor(libusb_device * dev, struct libusb_config_descriptor **config);
343int libusb_get_config_descriptor(libusb_device * dev, uint8_t config_index, struct libusb_config_descriptor **config);
344int libusb_get_config_descriptor_by_value(libusb_device * dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
345void libusb_free_config_descriptor(struct libusb_config_descriptor *config);
346int libusb_get_string_descriptor_ascii(libusb_device_handle * devh, uint8_t desc_index, uint8_t *data, int length);
347int libusb_get_descriptor(libusb_device_handle * devh, uint8_t desc_type, uint8_t desc_index, uint8_t *data, int length);
322typedef struct libusb_control_setup {
323 uint8_t bmRequestType;
324 uint8_t bRequest;
325 uint16_t wValue;
326 uint16_t wIndex;
327 uint16_t wLength;
328} libusb_control_setup;
329

--- 65 unchanged lines hidden (view full) ---

395
396int libusb_get_device_descriptor(libusb_device * dev, struct libusb_device_descriptor *desc);
397int libusb_get_active_config_descriptor(libusb_device * dev, struct libusb_config_descriptor **config);
398int libusb_get_config_descriptor(libusb_device * dev, uint8_t config_index, struct libusb_config_descriptor **config);
399int libusb_get_config_descriptor_by_value(libusb_device * dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
400void libusb_free_config_descriptor(struct libusb_config_descriptor *config);
401int libusb_get_string_descriptor_ascii(libusb_device_handle * devh, uint8_t desc_index, uint8_t *data, int length);
402int libusb_get_descriptor(libusb_device_handle * devh, uint8_t desc_type, uint8_t desc_index, uint8_t *data, int length);
403int libusb_parse_ss_endpoint_comp(const void *buf, int len, struct libusb_ss_endpoint_companion_descriptor **ep_comp);
404void libusb_free_ss_endpoint_comp(struct libusb_ss_endpoint_companion_descriptor *ep_comp);
405int libusb_parse_bos_descriptor(const void *buf, int len, struct libusb_bos_descriptor **bos);
406void libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
348
349/* Asynchronous device I/O */
350
351struct libusb_transfer *libusb_alloc_transfer(int iso_packets);
352void libusb_free_transfer(struct libusb_transfer *transfer);
353int libusb_submit_transfer(struct libusb_transfer *transfer);
354int libusb_cancel_transfer(struct libusb_transfer *transfer);
355uint8_t *libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t index);

--- 47 unchanged lines hidden ---
407
408/* Asynchronous device I/O */
409
410struct libusb_transfer *libusb_alloc_transfer(int iso_packets);
411void libusb_free_transfer(struct libusb_transfer *transfer);
412int libusb_submit_transfer(struct libusb_transfer *transfer);
413int libusb_cancel_transfer(struct libusb_transfer *transfer);
414uint8_t *libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t index);

--- 47 unchanged lines hidden ---