Harald Welte | 822d66e | 2017-03-06 20:58:03 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <libusb.h> |
| 4 | |
Harald Welte | a601635 | 2017-05-11 01:31:45 +0200 | [diff] [blame] | 5 | #define USB_MAX_PATH_LEN 20 |
| 6 | |
Harald Welte | 822d66e | 2017-03-06 20:58:03 +0100 | [diff] [blame] | 7 | struct dev_id { |
| 8 | uint16_t vendor_id; |
| 9 | uint16_t product_id; |
| 10 | }; |
| 11 | |
| 12 | /* Find any USB devices in the system matching the given Vendor and |
| 13 | * Product ID */ |
| 14 | libusb_device **find_matching_usb_devs(const struct dev_id *dev_ids); |
| 15 | |
| 16 | /* structure describing a single matching interface found */ |
| 17 | struct usb_interface_match { |
| 18 | /* libusb device E*/ |
| 19 | libusb_device *usb_dev; |
| 20 | /* Vendor ID of the device running matching interface */ |
| 21 | uint16_t vendor; |
| 22 | /* Product ID of the device running matching interface */ |
| 23 | uint16_t product; |
| 24 | /* USB Bus Address */ |
| 25 | uint8_t addr; |
Harald Welte | a601635 | 2017-05-11 01:31:45 +0200 | [diff] [blame] | 26 | /* physical path */ |
| 27 | char path[USB_MAX_PATH_LEN]; |
Harald Welte | 822d66e | 2017-03-06 20:58:03 +0100 | [diff] [blame] | 28 | /* configuration of matching interface */ |
| 29 | uint8_t configuration; |
| 30 | /* interface number of matching interface */ |
| 31 | uint8_t interface; |
| 32 | /* altsetting of matching interface */ |
| 33 | uint8_t altsetting; |
| 34 | /* bInterfaceClass of matching interface */ |
| 35 | uint8_t class; |
| 36 | /* bInterfaceSubClass of matching interface */ |
| 37 | uint8_t sub_class; |
| 38 | /* bInterfaceProtocol of matching interface */ |
| 39 | uint8_t protocol; |
| 40 | /* index of string descriptor of matching interface */ |
| 41 | uint8_t string_idx; |
| 42 | }; |
| 43 | |
| 44 | int dev_find_matching_interfaces(libusb_device *dev, int class, int sub_class, int protocol, |
| 45 | struct usb_interface_match *out, unsigned int out_len); |
| 46 | |
| 47 | int usb_match_interfaces(libusb_context *ctx, const struct dev_id *dev_ids, |
| 48 | int class, int sub_class, int protocol, |
| 49 | struct usb_interface_match *out, unsigned int out_len); |
| 50 | |
| 51 | libusb_device_handle *usb_open_claim_interface(libusb_context *ctx, |
| 52 | const struct usb_interface_match *ifm); |