1#ifndef __LINUX_H__
2#define __LINUX_H__
3
4#include <unistd.h>
5#include <sys/stat.h>
6#include <sys/ioctl.h>
7
8struct usb_ctrltransfer {
9	/* keep in sync with usbdevice_fs.h:usbdevfs_ctrltransfer */
10	u_int8_t  bRequestType;
11	u_int8_t  bRequest;
12	u_int16_t wValue;
13	u_int16_t wIndex;
14	u_int16_t wLength;
15
16	u_int32_t timeout;	/* in milliseconds */
17
18	/* pointer to data */
19	void *data;
20};
21
22struct usb_bulktransfer {
23	/* keep in sync with usbdevice_fs.h:usbdevfs_bulktransfer */
24	unsigned int ep;
25	unsigned int len;
26	unsigned int timeout;	/* in milliseconds */
27
28	/* pointer to data */
29	void *data;
30};
31
32struct usb_setinterface {
33	/* keep in sync with usbdevice_fs.h:usbdevfs_setinterface */
34	unsigned int interface;
35	unsigned int altsetting;
36};
37
38#define USB_MAXDRIVERNAME 255
39
40struct usb_getdriver {
41	unsigned int interface;
42	char driver[USB_MAXDRIVERNAME + 1];
43};
44
45#define USB_URB_DISABLE_SPD	1
46#define USB_URB_ISO_ASAP	2
47#define USB_URB_QUEUE_BULK	0x10
48
49#define USB_URB_TYPE_ISO	0
50#define USB_URB_TYPE_INTERRUPT	1
51#define USB_URB_TYPE_CONTROL	2
52#define USB_URB_TYPE_BULK	3
53
54struct usb_iso_packet_desc {
55	unsigned int length;
56	unsigned int actual_length;
57	unsigned int status;
58};
59
60struct usb_urb {
61	unsigned char type;
62	unsigned char endpoint;
63	int status;
64	unsigned int flags;
65	void *buffer;
66	int buffer_length;
67	int actual_length;
68	int start_frame;
69	int number_of_packets;
70	int error_count;
71	unsigned int signr;  /* signal to be sent on error, -1 if none should be sent */
72	void *usercontext;
73	struct usb_iso_packet_desc iso_frame_desc[0];
74};
75
76struct usb_bulk {
77        unsigned int ep;
78        unsigned int len;
79        unsigned int timeout; /* in milliseconds */
80        void *data;
81};
82
83struct usb_connectinfo {
84	unsigned int devnum;
85	unsigned char slow;
86};
87
88struct usb_ioctl {
89	int ifno;	/* interface 0..N ; negative numbers reserved */
90	int ioctl_code;	/* MUST encode size + direction of data so the
91			 * macros in <asm/ioctl.h> give correct values */
92	void *data;	/* param buffer (in, or out) */
93};
94
95struct usb_hub_portinfo {
96	unsigned char numports;
97	unsigned char port[127];	/* port to device num mapping */
98};
99
100#define IOCTL_USB_CONTROL	_IOWR('U', 0, struct usb_ctrltransfer)
101#define IOCTL_USB_BULK		_IOWR('U', 2, struct usb_bulktransfer)
102#define IOCTL_USB_RESETEP	_IOR('U', 3, unsigned int)
103#define IOCTL_USB_SETINTF	_IOR('U', 4, struct usb_setinterface)
104#define IOCTL_USB_SETCONFIG	_IOR('U', 5, unsigned int)
105#define IOCTL_USB_GETDRIVER	_IOW('U', 8, struct usb_getdriver)
106#define IOCTL_USB_SUBMITURB	_IOR('U', 10, struct usb_urb)
107#define IOCTL_USB_DISCARDURB	_IO('U', 11)
108#define IOCTL_USB_REAPURB	_IOW('U', 12, void *)
109#define IOCTL_USB_REAPURBNDELAY	_IOW('U', 13, void *)
110#define IOCTL_USB_CLAIMINTF	_IOR('U', 15, unsigned int)
111#define IOCTL_USB_RELEASEINTF	_IOR('U', 16, unsigned int)
112#define IOCTL_USB_CONNECTINFO	_IOW('U', 17, struct usb_connectinfo)
113#define IOCTL_USB_IOCTL         _IOWR('U', 18, struct usb_ioctl)
114#define IOCTL_USB_HUB_PORTINFO	_IOR('U', 19, struct usb_hub_portinfo)
115#define IOCTL_USB_RESET		_IO('U', 20)
116#define IOCTL_USB_CLEAR_HALT	_IOR('U', 21, unsigned int)
117#define IOCTL_USB_DISCONNECT	_IO('U', 22)
118#define IOCTL_USB_CONNECT	_IO('U', 23)
119
120/*
121 * IOCTL_USB_HUB_PORTINFO, IOCTL_USB_DISCONNECT and IOCTL_USB_CONNECT
122 * all work via IOCTL_USB_IOCTL
123 */
124
125#endif
126
127