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_connectinfo {
77	unsigned int devnum;
78	unsigned char slow;
79};
80
81struct usb_ioctl {
82	int ifno;	/* interface 0..N ; negative numbers reserved */
83	int ioctl_code;	/* MUST encode size + direction of data so the
84			 * macros in <asm/ioctl.h> give correct values */
85	void *data;	/* param buffer (in, or out) */
86};
87
88struct usb_hub_portinfo {
89	unsigned char numports;
90	unsigned char port[127];	/* port to device num mapping */
91};
92
93#define IOCTL_USB_CONTROL	_IOWR('U', 0, struct usb_ctrltransfer)
94#define IOCTL_USB_BULK		_IOWR('U', 2, struct usb_bulktransfer)
95#define IOCTL_USB_RESETEP	_IOR('U', 3, unsigned int)
96#define IOCTL_USB_SETINTF	_IOR('U', 4, struct usb_setinterface)
97#define IOCTL_USB_SETCONFIG	_IOR('U', 5, unsigned int)
98#define IOCTL_USB_GETDRIVER	_IOW('U', 8, struct usb_getdriver)
99#define IOCTL_USB_SUBMITURB	_IOR('U', 10, struct usb_urb)
100#define IOCTL_USB_DISCARDURB	_IO('U', 11)
101#define IOCTL_USB_REAPURB	_IOW('U', 12, void *)
102#define IOCTL_USB_REAPURBNDELAY	_IOW('U', 13, void *)
103#define IOCTL_USB_CLAIMINTF	_IOR('U', 15, unsigned int)
104#define IOCTL_USB_RELEASEINTF	_IOR('U', 16, unsigned int)
105#define IOCTL_USB_CONNECTINFO	_IOW('U', 17, struct usb_connectinfo)
106#define IOCTL_USB_IOCTL         _IOWR('U', 18, struct usb_ioctl)
107#define IOCTL_USB_HUB_PORTINFO	_IOR('U', 19, struct usb_hub_portinfo)
108#define IOCTL_USB_RESET		_IO('U', 20)
109#define IOCTL_USB_CLEAR_HALT	_IOR('U', 21, unsigned int)
110#define IOCTL_USB_DISCONNECT	_IO('U', 22)
111#define IOCTL_USB_CONNECT	_IO('U', 23)
112
113/*
114 * IOCTL_USB_HUB_PORTINFO, IOCTL_USB_DISCONNECT and IOCTL_USB_CONNECT
115 * all work via IOCTL_USB_IOCTL
116 */
117
118#endif
119
120