blob: 3b74666be027d438ed4631d2e872a1f606c2225a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*****************************************************************************/
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 */
26
27/*****************************************************************************/
28
29#ifndef _LINUX_USBDEVICE_FS_H
30#define _LINUX_USBDEVICE_FS_H
31
32#include <linux/types.h>
Jeff Garzike18fa702006-09-24 11:13:19 -040033#include <linux/magic.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35/* --------------------------------------------------------------------- */
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037/* usbdevfs ioctl codes */
38
39struct usbdevfs_ctrltransfer {
40 __u8 bRequestType;
41 __u8 bRequest;
42 __u16 wValue;
43 __u16 wIndex;
44 __u16 wLength;
45 __u32 timeout; /* in milliseconds */
46 void __user *data;
47};
48
49struct usbdevfs_bulktransfer {
50 unsigned int ep;
51 unsigned int len;
52 unsigned int timeout; /* in milliseconds */
53 void __user *data;
54};
55
56struct usbdevfs_setinterface {
57 unsigned int interface;
58 unsigned int altsetting;
59};
60
61struct usbdevfs_disconnectsignal {
62 unsigned int signr;
63 void __user *context;
64};
65
66#define USBDEVFS_MAXDRIVERNAME 255
67
68struct usbdevfs_getdriver {
69 unsigned int interface;
70 char driver[USBDEVFS_MAXDRIVERNAME + 1];
71};
72
73struct usbdevfs_connectinfo {
74 unsigned int devnum;
75 unsigned char slow;
76};
77
Alan Stern14722ef2008-04-17 10:18:11 -040078#define USBDEVFS_URB_SHORT_NOT_OK 0x01
79#define USBDEVFS_URB_ISO_ASAP 0x02
Alan Stern01c64602009-09-01 11:09:56 -040080#define USBDEVFS_URB_BULK_CONTINUATION 0x04
Alan Stern14722ef2008-04-17 10:18:11 -040081#define USBDEVFS_URB_NO_FSBR 0x20
82#define USBDEVFS_URB_ZERO_PACKET 0x40
83#define USBDEVFS_URB_NO_INTERRUPT 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
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
90struct usbdevfs_iso_packet_desc {
91 unsigned int length;
92 unsigned int actual_length;
93 unsigned int status;
94};
95
96struct usbdevfs_urb {
97 unsigned char type;
98 unsigned char endpoint;
99 int status;
100 unsigned int flags;
101 void __user *buffer;
102 int buffer_length;
103 int actual_length;
104 int start_frame;
105 int number_of_packets;
106 int error_count;
Phil Endecottbc594622007-10-29 20:40:30 +0000107 unsigned int signr; /* signal to be sent on completion,
108 or 0 if none should be sent. */
Marcin Slusarz7f9705b2007-12-16 03:23:20 +0100109 void __user *usercontext;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 struct usbdevfs_iso_packet_desc iso_frame_desc[0];
111};
112
113/* ioctls for talking directly to drivers */
114struct usbdevfs_ioctl {
115 int ifno; /* interface 0..N ; negative numbers reserved */
116 int ioctl_code; /* MUST encode size + direction of data so the
117 * macros in <asm/ioctl.h> give correct values */
118 void __user *data; /* param buffer (in, or out) */
119};
120
121/* You can do most things with hubs just through control messages,
122 * except find out what device connects to what port. */
123struct usbdevfs_hub_portinfo {
124 char nports; /* number of downstream ports in this hub */
125 char port [127]; /* e.g. port 3 connects to device 27 */
126};
127
Hans de Goede19181bc2012-07-04 09:18:02 +0200128/* Device capability flags */
129#define USBDEVFS_CAP_ZERO_PACKET 0x01
130#define USBDEVFS_CAP_BULK_CONTINUATION 0x02
131#define USBDEVFS_CAP_NO_PACKET_SIZE_LIM 0x04
Hans de Goede3d97ff62012-07-04 09:18:03 +0200132#define USBDEVFS_CAP_BULK_SCATTER_GATHER 0x08
Hans de Goede19181bc2012-07-04 09:18:02 +0200133
David Woodhouseeae19a72006-04-25 15:14:50 +0100134#ifdef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135#ifdef CONFIG_COMPAT
Harald Weltece441592005-09-03 11:27:08 +0200136#include <linux/compat.h>
Arnd Bergmann637e8a62009-11-14 02:28:05 +0100137
138struct usbdevfs_ctrltransfer32 {
139 u8 bRequestType;
140 u8 bRequest;
141 u16 wValue;
142 u16 wIndex;
143 u16 wLength;
144 u32 timeout; /* in milliseconds */
145 compat_caddr_t data;
146};
147
148struct usbdevfs_bulktransfer32 {
149 compat_uint_t ep;
150 compat_uint_t len;
151 compat_uint_t timeout; /* in milliseconds */
152 compat_caddr_t data;
153};
154
155struct usbdevfs_disconnectsignal32 {
156 compat_int_t signr;
157 compat_caddr_t context;
158};
159
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160struct usbdevfs_urb32 {
161 unsigned char type;
162 unsigned char endpoint;
163 compat_int_t status;
164 compat_uint_t flags;
165 compat_caddr_t buffer;
166 compat_int_t buffer_length;
167 compat_int_t actual_length;
168 compat_int_t start_frame;
169 compat_int_t number_of_packets;
170 compat_int_t error_count;
171 compat_uint_t signr;
172 compat_caddr_t usercontext; /* unused */
173 struct usbdevfs_iso_packet_desc iso_frame_desc[0];
174};
Pete Zaitcevc36fc882005-10-17 18:15:54 -0700175
176struct usbdevfs_ioctl32 {
177 s32 ifno;
178 s32 ioctl_code;
179 compat_caddr_t data;
180};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181#endif
David Woodhouseeae19a72006-04-25 15:14:50 +0100182#endif /* __KERNEL__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
184#define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer)
Arnd Bergmann637e8a62009-11-14 02:28:05 +0100185#define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186#define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer)
Arnd Bergmann637e8a62009-11-14 02:28:05 +0100187#define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188#define USBDEVFS_RESETEP _IOR('U', 3, unsigned int)
189#define USBDEVFS_SETINTERFACE _IOR('U', 4, struct usbdevfs_setinterface)
190#define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int)
191#define USBDEVFS_GETDRIVER _IOW('U', 8, struct usbdevfs_getdriver)
192#define USBDEVFS_SUBMITURB _IOR('U', 10, struct usbdevfs_urb)
193#define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32)
194#define USBDEVFS_DISCARDURB _IO('U', 11)
195#define USBDEVFS_REAPURB _IOW('U', 12, void *)
Mike Frysingerfc8d9192007-02-05 16:41:03 -0800196#define USBDEVFS_REAPURB32 _IOW('U', 12, __u32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197#define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *)
Mike Frysingerfc8d9192007-02-05 16:41:03 -0800198#define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, __u32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199#define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal)
Arnd Bergmann637e8a62009-11-14 02:28:05 +0100200#define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201#define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int)
202#define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)
203#define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo)
204#define USBDEVFS_IOCTL _IOWR('U', 18, struct usbdevfs_ioctl)
Pete Zaitcevc36fc882005-10-17 18:15:54 -0700205#define USBDEVFS_IOCTL32 _IOWR('U', 18, struct usbdevfs_ioctl32)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206#define USBDEVFS_HUB_PORTINFO _IOR('U', 19, struct usbdevfs_hub_portinfo)
207#define USBDEVFS_RESET _IO('U', 20)
208#define USBDEVFS_CLEAR_HALT _IOR('U', 21, unsigned int)
209#define USBDEVFS_DISCONNECT _IO('U', 22)
210#define USBDEVFS_CONNECT _IO('U', 23)
Alan Stern7cbe5dc2009-06-29 10:56:54 -0400211#define USBDEVFS_CLAIM_PORT _IOR('U', 24, unsigned int)
212#define USBDEVFS_RELEASE_PORT _IOR('U', 25, unsigned int)
Hans de Goede19181bc2012-07-04 09:18:02 +0200213#define USBDEVFS_GET_CAPABILITIES _IOR('U', 26, __u32)
214
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215#endif /* _LINUX_USBDEVICE_FS_H */