blob: 5bbe3cb90c5c3ee2710d41cc21740d0ef2c21ea1 [file] [log] [blame]
Harald Welte822d66e2017-03-06 20:58:03 +01001#pragma once
2
3#include <libusb.h>
4
Harald Weltea6016352017-05-11 01:31:45 +02005#define USB_MAX_PATH_LEN 20
6
Harald Welte822d66e2017-03-06 20:58:03 +01007struct 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 */
14libusb_device **find_matching_usb_devs(const struct dev_id *dev_ids);
15
16/* structure describing a single matching interface found */
17struct 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 Weltea6016352017-05-11 01:31:45 +020026 /* physical path */
27 char path[USB_MAX_PATH_LEN];
Harald Welte822d66e2017-03-06 20:58:03 +010028 /* 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
44int 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
47int 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
51libusb_device_handle *usb_open_claim_interface(libusb_context *ctx,
52 const struct usb_interface_match *ifm);