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