1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2607ca46eSDavid Howells /*****************************************************************************/ 3607ca46eSDavid Howells 4607ca46eSDavid Howells /* 5607ca46eSDavid Howells * usbdevice_fs.h -- USB device file system. 6607ca46eSDavid Howells * 7607ca46eSDavid Howells * Copyright (C) 2000 8607ca46eSDavid Howells * Thomas Sailer (sailer@ife.ee.ethz.ch) 9607ca46eSDavid Howells * 10607ca46eSDavid Howells * This program is free software; you can redistribute it and/or modify 11607ca46eSDavid Howells * it under the terms of the GNU General Public License as published by 12607ca46eSDavid Howells * the Free Software Foundation; either version 2 of the License, or 13607ca46eSDavid Howells * (at your option) any later version. 14607ca46eSDavid Howells * 15607ca46eSDavid Howells * This program is distributed in the hope that it will be useful, 16607ca46eSDavid Howells * but WITHOUT ANY WARRANTY; without even the implied warranty of 17607ca46eSDavid Howells * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18607ca46eSDavid Howells * GNU General Public License for more details. 19607ca46eSDavid Howells * 20607ca46eSDavid Howells * You should have received a copy of the GNU General Public License 21607ca46eSDavid Howells * along with this program; if not, write to the Free Software 22607ca46eSDavid Howells * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23607ca46eSDavid Howells * 24607ca46eSDavid Howells * History: 25607ca46eSDavid Howells * 0.1 04.01.2000 Created 26607ca46eSDavid Howells */ 27607ca46eSDavid Howells 28607ca46eSDavid Howells /*****************************************************************************/ 29607ca46eSDavid Howells 30607ca46eSDavid Howells #ifndef _UAPI_LINUX_USBDEVICE_FS_H 31607ca46eSDavid Howells #define _UAPI_LINUX_USBDEVICE_FS_H 32607ca46eSDavid Howells 33607ca46eSDavid Howells #include <linux/types.h> 34607ca46eSDavid Howells #include <linux/magic.h> 35607ca46eSDavid Howells 36607ca46eSDavid Howells /* --------------------------------------------------------------------- */ 37607ca46eSDavid Howells 38607ca46eSDavid Howells /* usbdevfs ioctl codes */ 39607ca46eSDavid Howells 40607ca46eSDavid Howells struct usbdevfs_ctrltransfer { 41607ca46eSDavid Howells __u8 bRequestType; 42607ca46eSDavid Howells __u8 bRequest; 43607ca46eSDavid Howells __u16 wValue; 44607ca46eSDavid Howells __u16 wIndex; 45607ca46eSDavid Howells __u16 wLength; 46607ca46eSDavid Howells __u32 timeout; /* in milliseconds */ 47607ca46eSDavid Howells void __user *data; 48607ca46eSDavid Howells }; 49607ca46eSDavid Howells 50607ca46eSDavid Howells struct usbdevfs_bulktransfer { 51607ca46eSDavid Howells unsigned int ep; 52607ca46eSDavid Howells unsigned int len; 53607ca46eSDavid Howells unsigned int timeout; /* in milliseconds */ 54607ca46eSDavid Howells void __user *data; 55607ca46eSDavid Howells }; 56607ca46eSDavid Howells 57607ca46eSDavid Howells struct usbdevfs_setinterface { 58607ca46eSDavid Howells unsigned int interface; 59607ca46eSDavid Howells unsigned int altsetting; 60607ca46eSDavid Howells }; 61607ca46eSDavid Howells 62607ca46eSDavid Howells struct usbdevfs_disconnectsignal { 63607ca46eSDavid Howells unsigned int signr; 64607ca46eSDavid Howells void __user *context; 65607ca46eSDavid Howells }; 66607ca46eSDavid Howells 67607ca46eSDavid Howells #define USBDEVFS_MAXDRIVERNAME 255 68607ca46eSDavid Howells 69607ca46eSDavid Howells struct usbdevfs_getdriver { 70607ca46eSDavid Howells unsigned int interface; 71607ca46eSDavid Howells char driver[USBDEVFS_MAXDRIVERNAME + 1]; 72607ca46eSDavid Howells }; 73607ca46eSDavid Howells 74607ca46eSDavid Howells struct usbdevfs_connectinfo { 75607ca46eSDavid Howells unsigned int devnum; 76607ca46eSDavid Howells unsigned char slow; 77607ca46eSDavid Howells }; 78607ca46eSDavid Howells 796d101f24SDmitry Torokhov struct usbdevfs_conninfo_ex { 806d101f24SDmitry Torokhov __u32 size; /* Size of the structure from the kernel's */ 816d101f24SDmitry Torokhov /* point of view. Can be used by userspace */ 826d101f24SDmitry Torokhov /* to determine how much data can be */ 836d101f24SDmitry Torokhov /* used/trusted. */ 846d101f24SDmitry Torokhov __u32 busnum; /* USB bus number, as enumerated by the */ 856d101f24SDmitry Torokhov /* kernel, the device is connected to. */ 866d101f24SDmitry Torokhov __u32 devnum; /* Device address on the bus. */ 876d101f24SDmitry Torokhov __u32 speed; /* USB_SPEED_* constants from ch9.h */ 88b119decaSStephen Rothwell __u8 num_ports; /* Number of ports the device is connected */ 896d101f24SDmitry Torokhov /* to on the way to the root hub. It may */ 906d101f24SDmitry Torokhov /* be bigger than size of 'ports' array so */ 916d101f24SDmitry Torokhov /* userspace can detect overflows. */ 92b119decaSStephen Rothwell __u8 ports[7]; /* List of ports on the way from the root */ 936d101f24SDmitry Torokhov /* hub to the device. Current limit in */ 946d101f24SDmitry Torokhov /* USB specification is 7 tiers (root hub, */ 956d101f24SDmitry Torokhov /* 5 intermediate hubs, device), which */ 966d101f24SDmitry Torokhov /* gives at most 6 port entries. */ 976d101f24SDmitry Torokhov }; 986d101f24SDmitry Torokhov 99607ca46eSDavid Howells #define USBDEVFS_URB_SHORT_NOT_OK 0x01 100607ca46eSDavid Howells #define USBDEVFS_URB_ISO_ASAP 0x02 101607ca46eSDavid Howells #define USBDEVFS_URB_BULK_CONTINUATION 0x04 102aa15d3d2SAlan Stern #define USBDEVFS_URB_NO_FSBR 0x20 /* Not used */ 103607ca46eSDavid Howells #define USBDEVFS_URB_ZERO_PACKET 0x40 104607ca46eSDavid Howells #define USBDEVFS_URB_NO_INTERRUPT 0x80 105607ca46eSDavid Howells 106607ca46eSDavid Howells #define USBDEVFS_URB_TYPE_ISO 0 107607ca46eSDavid Howells #define USBDEVFS_URB_TYPE_INTERRUPT 1 108607ca46eSDavid Howells #define USBDEVFS_URB_TYPE_CONTROL 2 109607ca46eSDavid Howells #define USBDEVFS_URB_TYPE_BULK 3 110607ca46eSDavid Howells 111607ca46eSDavid Howells struct usbdevfs_iso_packet_desc { 112607ca46eSDavid Howells unsigned int length; 113607ca46eSDavid Howells unsigned int actual_length; 114607ca46eSDavid Howells unsigned int status; 115607ca46eSDavid Howells }; 116607ca46eSDavid Howells 117607ca46eSDavid Howells struct usbdevfs_urb { 118607ca46eSDavid Howells unsigned char type; 119607ca46eSDavid Howells unsigned char endpoint; 120607ca46eSDavid Howells int status; 121607ca46eSDavid Howells unsigned int flags; 122607ca46eSDavid Howells void __user *buffer; 123607ca46eSDavid Howells int buffer_length; 124607ca46eSDavid Howells int actual_length; 125607ca46eSDavid Howells int start_frame; 126948cd8c1SHans de Goede union { 127948cd8c1SHans de Goede int number_of_packets; /* Only used for isoc urbs */ 128948cd8c1SHans de Goede unsigned int stream_id; /* Only used with bulk streams */ 129948cd8c1SHans de Goede }; 130607ca46eSDavid Howells int error_count; 131607ca46eSDavid Howells unsigned int signr; /* signal to be sent on completion, 132607ca46eSDavid Howells or 0 if none should be sent. */ 133607ca46eSDavid Howells void __user *usercontext; 134*94dfc73eSGustavo A. R. Silva struct usbdevfs_iso_packet_desc iso_frame_desc[]; 135607ca46eSDavid Howells }; 136607ca46eSDavid Howells 137607ca46eSDavid Howells /* ioctls for talking directly to drivers */ 138607ca46eSDavid Howells struct usbdevfs_ioctl { 139607ca46eSDavid Howells int ifno; /* interface 0..N ; negative numbers reserved */ 140607ca46eSDavid Howells int ioctl_code; /* MUST encode size + direction of data so the 141607ca46eSDavid Howells * macros in <asm/ioctl.h> give correct values */ 142607ca46eSDavid Howells void __user *data; /* param buffer (in, or out) */ 143607ca46eSDavid Howells }; 144607ca46eSDavid Howells 145607ca46eSDavid Howells /* You can do most things with hubs just through control messages, 146607ca46eSDavid Howells * except find out what device connects to what port. */ 147607ca46eSDavid Howells struct usbdevfs_hub_portinfo { 148607ca46eSDavid Howells char nports; /* number of downstream ports in this hub */ 149607ca46eSDavid Howells char port [127]; /* e.g. port 3 connects to device 27 */ 150607ca46eSDavid Howells }; 151607ca46eSDavid Howells 1523f2cee73SAlan Stern /* System and bus capability flags */ 153607ca46eSDavid Howells #define USBDEVFS_CAP_ZERO_PACKET 0x01 154607ca46eSDavid Howells #define USBDEVFS_CAP_BULK_CONTINUATION 0x02 155607ca46eSDavid Howells #define USBDEVFS_CAP_NO_PACKET_SIZE_LIM 0x04 156607ca46eSDavid Howells #define USBDEVFS_CAP_BULK_SCATTER_GATHER 0x08 1573f2cee73SAlan Stern #define USBDEVFS_CAP_REAP_AFTER_DISCONNECT 0x10 158f7d34b44SSteinar H. Gunderson #define USBDEVFS_CAP_MMAP 0x20 159d883f52eSReilly Grant #define USBDEVFS_CAP_DROP_PRIVILEGES 0x40 1606d101f24SDmitry Torokhov #define USBDEVFS_CAP_CONNINFO_EX 0x80 1614ed33505SAlan Stern #define USBDEVFS_CAP_SUSPEND 0x100 162607ca46eSDavid Howells 163607ca46eSDavid Howells /* USBDEVFS_DISCONNECT_CLAIM flags & struct */ 164607ca46eSDavid Howells 165607ca46eSDavid Howells /* disconnect-and-claim if the driver matches the driver field */ 166607ca46eSDavid Howells #define USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER 0x01 167607ca46eSDavid Howells /* disconnect-and-claim except when the driver matches the driver field */ 168607ca46eSDavid Howells #define USBDEVFS_DISCONNECT_CLAIM_EXCEPT_DRIVER 0x02 169607ca46eSDavid Howells 170607ca46eSDavid Howells struct usbdevfs_disconnect_claim { 171607ca46eSDavid Howells unsigned int interface; 172607ca46eSDavid Howells unsigned int flags; 173607ca46eSDavid Howells char driver[USBDEVFS_MAXDRIVERNAME + 1]; 174607ca46eSDavid Howells }; 175607ca46eSDavid Howells 176bcf7f6e3SHans de Goede struct usbdevfs_streams { 177bcf7f6e3SHans de Goede unsigned int num_streams; /* Not used by USBDEVFS_FREE_STREAMS */ 178bcf7f6e3SHans de Goede unsigned int num_eps; 179*94dfc73eSGustavo A. R. Silva unsigned char eps[]; 180bcf7f6e3SHans de Goede }; 181607ca46eSDavid Howells 182c01b244aSAlan Stern /* 183c01b244aSAlan Stern * USB_SPEED_* values returned by USBDEVFS_GET_SPEED are defined in 184c01b244aSAlan Stern * linux/usb/ch9.h 185c01b244aSAlan Stern */ 186c01b244aSAlan Stern 187607ca46eSDavid Howells #define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer) 188607ca46eSDavid Howells #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32) 189607ca46eSDavid Howells #define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer) 190607ca46eSDavid Howells #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32) 191607ca46eSDavid Howells #define USBDEVFS_RESETEP _IOR('U', 3, unsigned int) 192607ca46eSDavid Howells #define USBDEVFS_SETINTERFACE _IOR('U', 4, struct usbdevfs_setinterface) 193607ca46eSDavid Howells #define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int) 194607ca46eSDavid Howells #define USBDEVFS_GETDRIVER _IOW('U', 8, struct usbdevfs_getdriver) 195607ca46eSDavid Howells #define USBDEVFS_SUBMITURB _IOR('U', 10, struct usbdevfs_urb) 196607ca46eSDavid Howells #define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32) 197607ca46eSDavid Howells #define USBDEVFS_DISCARDURB _IO('U', 11) 198607ca46eSDavid Howells #define USBDEVFS_REAPURB _IOW('U', 12, void *) 199607ca46eSDavid Howells #define USBDEVFS_REAPURB32 _IOW('U', 12, __u32) 200607ca46eSDavid Howells #define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *) 201607ca46eSDavid Howells #define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, __u32) 202607ca46eSDavid Howells #define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal) 203607ca46eSDavid Howells #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32) 204607ca46eSDavid Howells #define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int) 205607ca46eSDavid Howells #define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int) 206607ca46eSDavid Howells #define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo) 207607ca46eSDavid Howells #define USBDEVFS_IOCTL _IOWR('U', 18, struct usbdevfs_ioctl) 208607ca46eSDavid Howells #define USBDEVFS_IOCTL32 _IOWR('U', 18, struct usbdevfs_ioctl32) 209607ca46eSDavid Howells #define USBDEVFS_HUB_PORTINFO _IOR('U', 19, struct usbdevfs_hub_portinfo) 210607ca46eSDavid Howells #define USBDEVFS_RESET _IO('U', 20) 211607ca46eSDavid Howells #define USBDEVFS_CLEAR_HALT _IOR('U', 21, unsigned int) 212607ca46eSDavid Howells #define USBDEVFS_DISCONNECT _IO('U', 22) 213607ca46eSDavid Howells #define USBDEVFS_CONNECT _IO('U', 23) 214607ca46eSDavid Howells #define USBDEVFS_CLAIM_PORT _IOR('U', 24, unsigned int) 215607ca46eSDavid Howells #define USBDEVFS_RELEASE_PORT _IOR('U', 25, unsigned int) 216607ca46eSDavid Howells #define USBDEVFS_GET_CAPABILITIES _IOR('U', 26, __u32) 217607ca46eSDavid Howells #define USBDEVFS_DISCONNECT_CLAIM _IOR('U', 27, struct usbdevfs_disconnect_claim) 218bcf7f6e3SHans de Goede #define USBDEVFS_ALLOC_STREAMS _IOR('U', 28, struct usbdevfs_streams) 219bcf7f6e3SHans de Goede #define USBDEVFS_FREE_STREAMS _IOR('U', 29, struct usbdevfs_streams) 220d883f52eSReilly Grant #define USBDEVFS_DROP_PRIVILEGES _IOW('U', 30, __u32) 221c01b244aSAlan Stern #define USBDEVFS_GET_SPEED _IO('U', 31) 2226d101f24SDmitry Torokhov /* 2236d101f24SDmitry Torokhov * Returns struct usbdevfs_conninfo_ex; length is variable to allow 2246d101f24SDmitry Torokhov * extending size of the data returned. 2256d101f24SDmitry Torokhov */ 2266d101f24SDmitry Torokhov #define USBDEVFS_CONNINFO_EX(len) _IOC(_IOC_READ, 'U', 32, len) 2277794f486SAlan Stern #define USBDEVFS_FORBID_SUSPEND _IO('U', 33) 2287794f486SAlan Stern #define USBDEVFS_ALLOW_SUSPEND _IO('U', 34) 2297794f486SAlan Stern #define USBDEVFS_WAIT_FOR_RESUME _IO('U', 35) 230607ca46eSDavid Howells 231607ca46eSDavid Howells #endif /* _UAPI_LINUX_USBDEVICE_FS_H */ 232