caf229b6a85e74f6df85b240241f0708b763dd9e
[linux-2.4.21-pre4.git] / include / linux / usbdevice_fs.h
1 /*****************************************************************************/
2
3 /*
4  *      usbdevice_fs.h  --  USB device file system.
5  *
6  *      Copyright (C) 2000
7  *          Thomas Sailer (sailer@ife.ee.ethz.ch)
8  *
9  *      This program is free software; you can redistribute it and/or modify
10  *      it under the terms of the GNU General Public License as published by
11  *      the Free Software Foundation; either version 2 of the License, or
12  *      (at your option) any later version.
13  *
14  *      This program is distributed in the hope that it will be useful,
15  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *      GNU General Public License for more details.
18  *
19  *      You should have received a copy of the GNU General Public License
20  *      along with this program; if not, write to the Free Software
21  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  *  History:
24  *   0.1  04.01.2000  Created
25  *
26  *  $Id: usbdevice_fs.h,v 1.1.1.1 2005/04/11 02:51:05 jack Exp $
27  */
28
29 /*****************************************************************************/
30
31 #ifndef _LINUX_USBDEVICE_FS_H
32 #define _LINUX_USBDEVICE_FS_H
33
34 #include <linux/types.h>
35
36 /* --------------------------------------------------------------------- */
37
38 #define USBDEVICE_SUPER_MAGIC 0x9fa2
39
40 /* usbdevfs ioctl codes */
41
42 struct usbdevfs_ctrltransfer {
43         __u8 requesttype;
44         __u8 request;
45         __u16 value;
46         __u16 index;
47         __u16 length;
48         __u32 timeout;  /* in milliseconds */
49         void *data;
50 };
51
52 struct usbdevfs_bulktransfer {
53         unsigned int ep;
54         unsigned int len;
55         unsigned int timeout; /* in milliseconds */
56         void *data;
57 };
58
59 struct usbdevfs_setinterface {
60         unsigned int interface;
61         unsigned int altsetting;
62 };
63
64 struct usbdevfs_disconnectsignal {
65         unsigned int signr;
66         void *context;
67 };
68
69 #define USBDEVFS_MAXDRIVERNAME 255
70
71 struct usbdevfs_getdriver {
72         unsigned int interface;
73         char driver[USBDEVFS_MAXDRIVERNAME + 1];
74 };
75
76 struct usbdevfs_connectinfo {
77         unsigned int devnum;
78         unsigned char slow;
79 };
80
81 #define USBDEVFS_URB_DISABLE_SPD           1
82 #define USBDEVFS_URB_ISO_ASAP              2
83 #define USBDEVFS_URB_QUEUE_BULK            0x10
84
85 #define USBDEVFS_URB_TYPE_ISO              0
86 #define USBDEVFS_URB_TYPE_INTERRUPT        1
87 #define USBDEVFS_URB_TYPE_CONTROL          2
88 #define USBDEVFS_URB_TYPE_BULK             3
89
90 struct usbdevfs_iso_packet_desc {
91         unsigned int length;
92         unsigned int actual_length;
93         unsigned int status;
94 };
95
96 struct usbdevfs_urb {
97         unsigned char type;
98         unsigned char endpoint;
99         int status;
100         unsigned int flags;
101         void *buffer;
102         int buffer_length;
103         int actual_length;
104         int start_frame;
105         int number_of_packets;
106         int error_count;
107         unsigned int signr;  /* signal to be sent on error, -1 if none should be sent */
108         void *usercontext;
109         struct usbdevfs_iso_packet_desc iso_frame_desc[0];
110 };
111
112 /* ioctls for talking to drivers in the usbcore module: */
113 struct usbdevfs_ioctl {
114         int     ifno;           /* interface 0..N ; negative numbers reserved */
115         int     ioctl_code;     /* MUST encode size + direction of data so the
116                                  * macros in <asm/ioctl.h> give correct values */
117         void    *data;          /* param buffer (in, or out) */
118 };
119
120 /* You can do most things with hubs just through control messages,
121  * except find out what device connects to what port. */
122 struct usbdevfs_hub_portinfo {
123         char nports;            /* number of downstream ports in this hub */
124         char port [127];        /* e.g. port 3 connects to device 27 */
125 };
126
127 #define USBDEVFS_CONTROL           _IOWR('U', 0, struct usbdevfs_ctrltransfer)
128 #define USBDEVFS_BULK              _IOWR('U', 2, struct usbdevfs_bulktransfer)
129 #define USBDEVFS_RESETEP           _IOR('U', 3, unsigned int)
130 #define USBDEVFS_SETINTERFACE      _IOR('U', 4, struct usbdevfs_setinterface)
131 #define USBDEVFS_SETCONFIGURATION  _IOR('U', 5, unsigned int)
132 #define USBDEVFS_GETDRIVER         _IOW('U', 8, struct usbdevfs_getdriver)
133 #define USBDEVFS_SUBMITURB         _IOR('U', 10, struct usbdevfs_urb)
134 #define USBDEVFS_DISCARDURB        _IO('U', 11)
135 #define USBDEVFS_REAPURB           _IOW('U', 12, void *)
136 #define USBDEVFS_REAPURBNDELAY     _IOW('U', 13, void *)
137 #define USBDEVFS_DISCSIGNAL        _IOR('U', 14, struct usbdevfs_disconnectsignal)
138 #define USBDEVFS_CLAIMINTERFACE    _IOR('U', 15, unsigned int)
139 #define USBDEVFS_RELEASEINTERFACE  _IOR('U', 16, unsigned int)
140 #define USBDEVFS_CONNECTINFO       _IOW('U', 17, struct usbdevfs_connectinfo)
141 #define USBDEVFS_IOCTL             _IOWR('U', 18, struct usbdevfs_ioctl)
142 #define USBDEVFS_HUB_PORTINFO      _IOR('U', 19, struct usbdevfs_hub_portinfo)
143 #define USBDEVFS_RESET             _IO('U', 20)
144 #define USBDEVFS_CLEAR_HALT        _IOR('U', 21, unsigned int)
145
146 /* --------------------------------------------------------------------- */
147
148 #ifdef __KERNEL__
149
150 #include <linux/list.h>
151 #include <asm/semaphore.h>
152
153 /*
154  * inode number macros
155  */
156 #define ITYPE(x)   ((x)&(0xf<<28))
157 #define ISPECIAL   (0<<28)
158 #define IBUS       (1<<28)
159 #define IDEVICE    (2<<28)
160 #define IBUSNR(x)  (((x)>>8)&0xff)
161 #define IDEVNR(x)  ((x)&0xff)
162
163 #define IROOT      1
164
165 struct dev_state {
166         struct list_head list;      /* state list */
167         struct rw_semaphore devsem; /* protects modifications to dev (dev == NULL indicating disconnect) */ 
168         struct usb_device *dev;
169         struct file *file;
170         spinlock_t lock;            /* protects the async urb lists */
171         struct list_head async_pending;
172         struct list_head async_completed;
173         wait_queue_head_t wait;     /* wake up if a request completed */
174         unsigned int discsignr;
175         struct task_struct *disctask;
176         void *disccontext;
177         unsigned long ifclaimed;
178 };
179
180 /* internal methods & data */
181 extern struct usb_driver usbdevfs_driver;
182 extern struct file_operations usbdevfs_drivers_fops;
183 extern struct file_operations usbdevfs_devices_fops;
184 extern struct file_operations usbdevfs_device_file_operations;
185 extern struct inode_operations usbdevfs_device_inode_operations;
186 extern struct inode_operations usbdevfs_bus_inode_operations;
187 extern struct file_operations usbdevfs_bus_file_operations;
188 extern void usbdevfs_conn_disc_event(void);
189
190 #endif /* __KERNEL__ */
191
192 /* --------------------------------------------------------------------- */
193 #endif /* _LINUX_USBDEVICE_FS_H */