1607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/*****************************************************************************/
2607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
3607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/*
4607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	usbdevice_fs.h  --  USB device file system.
5607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
6607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	Copyright (C) 2000
7607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *          Thomas Sailer (sailer@ife.ee.ethz.ch)
8607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
9607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	This program is free software; you can redistribute it and/or modify
10607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	it under the terms of the GNU General Public License as published by
11607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	the Free Software Foundation; either version 2 of the License, or
12607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	(at your option) any later version.
13607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
14607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	This program is distributed in the hope that it will be useful,
15607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	but WITHOUT ANY WARRANTY; without even the implied warranty of
16607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	GNU General Public License for more details.
18607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
19607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	You should have received a copy of the GNU General Public License
20607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	along with this program; if not, write to the Free Software
21607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *
23607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *  History:
24607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells *   0.1  04.01.2000  Created
25607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells */
26607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
27607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/*****************************************************************************/
28607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
29607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#ifndef _UAPI_LINUX_USBDEVICE_FS_H
30607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define _UAPI_LINUX_USBDEVICE_FS_H
31607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
32607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#include <linux/types.h>
33607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#include <linux/magic.h>
34607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
35607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* --------------------------------------------------------------------- */
36607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
37607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* usbdevfs ioctl codes */
38607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
39607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct usbdevfs_ctrltransfer {
40607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 bRequestType;
41607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u8 bRequest;
42607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u16 wValue;
43607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u16 wIndex;
44607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u16 wLength;
45607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	__u32 timeout;  /* in milliseconds */
46607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells 	void __user *data;
47607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
48607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
49607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct usbdevfs_bulktransfer {
50607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int ep;
51607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int len;
52607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int timeout; /* in milliseconds */
53607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	void __user *data;
54607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
55607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
56607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct usbdevfs_setinterface {
57607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int interface;
58607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int altsetting;
59607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
60607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
61607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct usbdevfs_disconnectsignal {
62607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int signr;
63607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	void __user *context;
64607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
65607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
66607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_MAXDRIVERNAME 255
67607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
68607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct usbdevfs_getdriver {
69607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int interface;
70607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	char driver[USBDEVFS_MAXDRIVERNAME + 1];
71607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
72607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
73607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct usbdevfs_connectinfo {
74607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int devnum;
75607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned char slow;
76607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
77607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
78607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_URB_SHORT_NOT_OK	0x01
79607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_URB_ISO_ASAP		0x02
80607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_URB_BULK_CONTINUATION	0x04
81607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_URB_NO_FSBR		0x20
82607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_URB_ZERO_PACKET	0x40
83607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_URB_NO_INTERRUPT	0x80
84607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
85607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_URB_TYPE_ISO		   0
86607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_URB_TYPE_INTERRUPT	   1
87607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_URB_TYPE_CONTROL	   2
88607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_URB_TYPE_BULK		   3
89607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
90607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct usbdevfs_iso_packet_desc {
91607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int length;
92607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int actual_length;
93607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int status;
94607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
95607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
96607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct usbdevfs_urb {
97607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned char type;
98607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned char endpoint;
99607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	int status;
100607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int flags;
101607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	void __user *buffer;
102607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	int buffer_length;
103607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	int actual_length;
104607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	int start_frame;
105948cd8c18c466fdcbe707bb2a42a148796bfccddHans de Goede	union {
106948cd8c18c466fdcbe707bb2a42a148796bfccddHans de Goede		int number_of_packets;	/* Only used for isoc urbs */
107948cd8c18c466fdcbe707bb2a42a148796bfccddHans de Goede		unsigned int stream_id;	/* Only used with bulk streams */
108948cd8c18c466fdcbe707bb2a42a148796bfccddHans de Goede	};
109607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	int error_count;
110607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int signr;	/* signal to be sent on completion,
111607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells				  or 0 if none should be sent. */
112607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	void __user *usercontext;
113607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	struct usbdevfs_iso_packet_desc iso_frame_desc[0];
114607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
115607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
116607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* ioctls for talking directly to drivers */
117607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct usbdevfs_ioctl {
118607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	int	ifno;		/* interface 0..N ; negative numbers reserved */
119607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	int	ioctl_code;	/* MUST encode size + direction of data so the
120607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells				 * macros in <asm/ioctl.h> give correct values */
121607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	void __user *data;	/* param buffer (in, or out) */
122607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
123607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
124607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* You can do most things with hubs just through control messages,
125607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells * except find out what device connects to what port. */
126607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct usbdevfs_hub_portinfo {
127607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	char nports;		/* number of downstream ports in this hub */
128607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	char port [127];	/* e.g. port 3 connects to device 27 */
129607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
130607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
131607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* Device capability flags */
132607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_CAP_ZERO_PACKET		0x01
133607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_CAP_BULK_CONTINUATION		0x02
134607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_CAP_NO_PACKET_SIZE_LIM		0x04
135607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_CAP_BULK_SCATTER_GATHER	0x08
136607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
137607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* USBDEVFS_DISCONNECT_CLAIM flags & struct */
138607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
139607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* disconnect-and-claim if the driver matches the driver field */
140607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER	0x01
141607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells/* disconnect-and-claim except when the driver matches the driver field */
142607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_DISCONNECT_CLAIM_EXCEPT_DRIVER	0x02
143607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
144607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howellsstruct usbdevfs_disconnect_claim {
145607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int interface;
146607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	unsigned int flags;
147607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells	char driver[USBDEVFS_MAXDRIVERNAME + 1];
148607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells};
149607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
150bcf7f6e39335af4f03da8c26a98185fd49754fccHans de Goedestruct usbdevfs_streams {
151bcf7f6e39335af4f03da8c26a98185fd49754fccHans de Goede	unsigned int num_streams; /* Not used by USBDEVFS_FREE_STREAMS */
152bcf7f6e39335af4f03da8c26a98185fd49754fccHans de Goede	unsigned int num_eps;
153bcf7f6e39335af4f03da8c26a98185fd49754fccHans de Goede	unsigned char eps[0];
154bcf7f6e39335af4f03da8c26a98185fd49754fccHans de Goede};
155607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
156607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_CONTROL           _IOWR('U', 0, struct usbdevfs_ctrltransfer)
157607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_CONTROL32           _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
158607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_BULK              _IOWR('U', 2, struct usbdevfs_bulktransfer)
159607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_BULK32              _IOWR('U', 2, struct usbdevfs_bulktransfer32)
160607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_RESETEP           _IOR('U', 3, unsigned int)
161607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_SETINTERFACE      _IOR('U', 4, struct usbdevfs_setinterface)
162607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_SETCONFIGURATION  _IOR('U', 5, unsigned int)
163607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_GETDRIVER         _IOW('U', 8, struct usbdevfs_getdriver)
164607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_SUBMITURB         _IOR('U', 10, struct usbdevfs_urb)
165607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_SUBMITURB32       _IOR('U', 10, struct usbdevfs_urb32)
166607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_DISCARDURB        _IO('U', 11)
167607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_REAPURB           _IOW('U', 12, void *)
168607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_REAPURB32         _IOW('U', 12, __u32)
169607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_REAPURBNDELAY     _IOW('U', 13, void *)
170607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_REAPURBNDELAY32   _IOW('U', 13, __u32)
171607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_DISCSIGNAL        _IOR('U', 14, struct usbdevfs_disconnectsignal)
172607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_DISCSIGNAL32      _IOR('U', 14, struct usbdevfs_disconnectsignal32)
173607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_CLAIMINTERFACE    _IOR('U', 15, unsigned int)
174607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_RELEASEINTERFACE  _IOR('U', 16, unsigned int)
175607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_CONNECTINFO       _IOW('U', 17, struct usbdevfs_connectinfo)
176607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_IOCTL             _IOWR('U', 18, struct usbdevfs_ioctl)
177607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_IOCTL32           _IOWR('U', 18, struct usbdevfs_ioctl32)
178607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_HUB_PORTINFO      _IOR('U', 19, struct usbdevfs_hub_portinfo)
179607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_RESET             _IO('U', 20)
180607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_CLEAR_HALT        _IOR('U', 21, unsigned int)
181607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_DISCONNECT        _IO('U', 22)
182607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_CONNECT           _IO('U', 23)
183607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_CLAIM_PORT        _IOR('U', 24, unsigned int)
184607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_RELEASE_PORT      _IOR('U', 25, unsigned int)
185607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_GET_CAPABILITIES  _IOR('U', 26, __u32)
186607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#define USBDEVFS_DISCONNECT_CLAIM  _IOR('U', 27, struct usbdevfs_disconnect_claim)
187bcf7f6e39335af4f03da8c26a98185fd49754fccHans de Goede#define USBDEVFS_ALLOC_STREAMS     _IOR('U', 28, struct usbdevfs_streams)
188bcf7f6e39335af4f03da8c26a98185fd49754fccHans de Goede#define USBDEVFS_FREE_STREAMS      _IOR('U', 29, struct usbdevfs_streams)
189607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells
190607ca46e97a1b6594b29647d98a32d545c24bdffDavid Howells#endif /* _UAPI_LINUX_USBDEVICE_FS_H */
191