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