1 | #ifndef _USBI_H_
|
---|
2 | #define _USBI_H_
|
---|
3 |
|
---|
4 | #include "lusb0_usb.h"
|
---|
5 |
|
---|
6 | #include "error.h"
|
---|
7 |
|
---|
8 | typedef unsigned char uint8_t;
|
---|
9 | typedef unsigned short uint16_t;
|
---|
10 | typedef unsigned long uint32_t;
|
---|
11 |
|
---|
12 | extern int usb_debug;
|
---|
13 |
|
---|
14 | /* Some quick and generic macros for the simple kind of lists we use */
|
---|
15 | #define LIST_ADD(begin, ent) \
|
---|
16 | do { \
|
---|
17 | if (begin) { \
|
---|
18 | ent->next = begin; \
|
---|
19 | ent->next->prev = ent; \
|
---|
20 | } else \
|
---|
21 | ent->next = NULL; \
|
---|
22 | ent->prev = NULL; \
|
---|
23 | begin = ent; \
|
---|
24 | } while(0)
|
---|
25 |
|
---|
26 | #define LIST_DEL(begin, ent) \
|
---|
27 | do { \
|
---|
28 | if (ent->prev) \
|
---|
29 | ent->prev->next = ent->next; \
|
---|
30 | else \
|
---|
31 | begin = ent->next; \
|
---|
32 | if (ent->next) \
|
---|
33 | ent->next->prev = ent->prev; \
|
---|
34 | ent->prev = NULL; \
|
---|
35 | ent->next = NULL; \
|
---|
36 | } while (0)
|
---|
37 |
|
---|
38 | #define DESC_HEADER_LENGTH 2
|
---|
39 | #define DEVICE_DESC_LENGTH 18
|
---|
40 | #define CONFIG_DESC_LENGTH 9
|
---|
41 | #define INTERFACE_DESC_LENGTH 9
|
---|
42 | #define ENDPOINT_DESC_LENGTH 7
|
---|
43 | #define ENDPOINT_AUDIO_DESC_LENGTH 9
|
---|
44 |
|
---|
45 | struct usb_dev_handle
|
---|
46 | {
|
---|
47 | int fd;
|
---|
48 |
|
---|
49 | struct usb_bus *bus;
|
---|
50 | struct usb_device *device;
|
---|
51 |
|
---|
52 | int config;
|
---|
53 | int interface;
|
---|
54 | int altsetting;
|
---|
55 |
|
---|
56 | /* Added by RMT so implementations can store other per-open-device data */
|
---|
57 | void *impl_info;
|
---|
58 | };
|
---|
59 |
|
---|
60 | /* descriptors.c */
|
---|
61 | int usb_parse_descriptor(unsigned char *source, char *description, void *dest);
|
---|
62 | int usb_parse_configuration(struct usb_config_descriptor *config,
|
---|
63 | unsigned char *buffer);
|
---|
64 | void usb_fetch_and_parse_descriptors(usb_dev_handle *udev);
|
---|
65 | void usb_destroy_configuration(struct usb_device *dev);
|
---|
66 |
|
---|
67 | /* OS specific routines */
|
---|
68 | int usb_os_find_busses(struct usb_bus **busses);
|
---|
69 | int usb_os_find_devices(struct usb_bus *bus, struct usb_device **devices);
|
---|
70 | int usb_os_determine_children(struct usb_bus *bus);
|
---|
71 | void usb_os_init(void);
|
---|
72 | int usb_os_open(usb_dev_handle *dev);
|
---|
73 | int usb_os_close(usb_dev_handle *dev);
|
---|
74 |
|
---|
75 | void usb_free_dev(struct usb_device *dev);
|
---|
76 | void usb_free_bus(struct usb_bus *bus);
|
---|
77 |
|
---|
78 | #endif /* _USBI_H_ */
|
---|
79 |
|
---|