Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /*****************************************************************************/
0003 
0004 /*
0005  *  usbdevice_fs.h  --  USB device file system.
0006  *
0007  *  Copyright (C) 2000
0008  *          Thomas Sailer (sailer@ife.ee.ethz.ch)
0009  *
0010  *  This program is free software; you can redistribute it and/or modify
0011  *  it under the terms of the GNU General Public License as published by
0012  *  the Free Software Foundation; either version 2 of the License, or
0013  *  (at your option) any later version.
0014  *
0015  *  This program is distributed in the hope that it will be useful,
0016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018  *  GNU General Public License for more details.
0019  *
0020  *  You should have received a copy of the GNU General Public License
0021  *  along with this program; if not, write to the Free Software
0022  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0023  *
0024  *  History:
0025  *   0.1  04.01.2000  Created
0026  */
0027 
0028 /*****************************************************************************/
0029 
0030 #ifndef _UAPI_LINUX_USBDEVICE_FS_H
0031 #define _UAPI_LINUX_USBDEVICE_FS_H
0032 
0033 #include <linux/types.h>
0034 #include <linux/magic.h>
0035 
0036 /* --------------------------------------------------------------------- */
0037 
0038 /* usbdevfs ioctl codes */
0039 
0040 struct usbdevfs_ctrltransfer {
0041     __u8 bRequestType;
0042     __u8 bRequest;
0043     __u16 wValue;
0044     __u16 wIndex;
0045     __u16 wLength;
0046     __u32 timeout;  /* in milliseconds */
0047     void __user *data;
0048 };
0049 
0050 struct usbdevfs_bulktransfer {
0051     unsigned int ep;
0052     unsigned int len;
0053     unsigned int timeout; /* in milliseconds */
0054     void __user *data;
0055 };
0056 
0057 struct usbdevfs_setinterface {
0058     unsigned int interface;
0059     unsigned int altsetting;
0060 };
0061 
0062 struct usbdevfs_disconnectsignal {
0063     unsigned int signr;
0064     void __user *context;
0065 };
0066 
0067 #define USBDEVFS_MAXDRIVERNAME 255
0068 
0069 struct usbdevfs_getdriver {
0070     unsigned int interface;
0071     char driver[USBDEVFS_MAXDRIVERNAME + 1];
0072 };
0073 
0074 struct usbdevfs_connectinfo {
0075     unsigned int devnum;
0076     unsigned char slow;
0077 };
0078 
0079 struct usbdevfs_conninfo_ex {
0080     __u32 size;     /* Size of the structure from the kernel's */
0081                 /* point of view. Can be used by userspace */
0082                 /* to determine how much data can be       */
0083                 /* used/trusted.                           */
0084     __u32 busnum;           /* USB bus number, as enumerated by the    */
0085                 /* kernel, the device is connected to.     */
0086     __u32 devnum;           /* Device address on the bus.              */
0087     __u32 speed;        /* USB_SPEED_* constants from ch9.h        */
0088     __u8 num_ports;     /* Number of ports the device is connected */
0089                 /* to on the way to the root hub. It may   */
0090                 /* be bigger than size of 'ports' array so */
0091                 /* userspace can detect overflows.         */
0092     __u8 ports[7];      /* List of ports on the way from the root  */
0093                 /* hub to the device. Current limit in     */
0094                 /* USB specification is 7 tiers (root hub, */
0095                 /* 5 intermediate hubs, device), which     */
0096                 /* gives at most 6 port entries.           */
0097 };
0098 
0099 #define USBDEVFS_URB_SHORT_NOT_OK   0x01
0100 #define USBDEVFS_URB_ISO_ASAP       0x02
0101 #define USBDEVFS_URB_BULK_CONTINUATION  0x04
0102 #define USBDEVFS_URB_NO_FSBR        0x20    /* Not used */
0103 #define USBDEVFS_URB_ZERO_PACKET    0x40
0104 #define USBDEVFS_URB_NO_INTERRUPT   0x80
0105 
0106 #define USBDEVFS_URB_TYPE_ISO          0
0107 #define USBDEVFS_URB_TYPE_INTERRUPT    1
0108 #define USBDEVFS_URB_TYPE_CONTROL      2
0109 #define USBDEVFS_URB_TYPE_BULK         3
0110 
0111 struct usbdevfs_iso_packet_desc {
0112     unsigned int length;
0113     unsigned int actual_length;
0114     unsigned int status;
0115 };
0116 
0117 struct usbdevfs_urb {
0118     unsigned char type;
0119     unsigned char endpoint;
0120     int status;
0121     unsigned int flags;
0122     void __user *buffer;
0123     int buffer_length;
0124     int actual_length;
0125     int start_frame;
0126     union {
0127         int number_of_packets;  /* Only used for isoc urbs */
0128         unsigned int stream_id; /* Only used with bulk streams */
0129     };
0130     int error_count;
0131     unsigned int signr; /* signal to be sent on completion,
0132                   or 0 if none should be sent. */
0133     void __user *usercontext;
0134     struct usbdevfs_iso_packet_desc iso_frame_desc[];
0135 };
0136 
0137 /* ioctls for talking directly to drivers */
0138 struct usbdevfs_ioctl {
0139     int ifno;       /* interface 0..N ; negative numbers reserved */
0140     int ioctl_code; /* MUST encode size + direction of data so the
0141                  * macros in <asm/ioctl.h> give correct values */
0142     void __user *data;  /* param buffer (in, or out) */
0143 };
0144 
0145 /* You can do most things with hubs just through control messages,
0146  * except find out what device connects to what port. */
0147 struct usbdevfs_hub_portinfo {
0148     char nports;        /* number of downstream ports in this hub */
0149     char port [127];    /* e.g. port 3 connects to device 27 */
0150 };
0151 
0152 /* System and bus capability flags */
0153 #define USBDEVFS_CAP_ZERO_PACKET        0x01
0154 #define USBDEVFS_CAP_BULK_CONTINUATION      0x02
0155 #define USBDEVFS_CAP_NO_PACKET_SIZE_LIM     0x04
0156 #define USBDEVFS_CAP_BULK_SCATTER_GATHER    0x08
0157 #define USBDEVFS_CAP_REAP_AFTER_DISCONNECT  0x10
0158 #define USBDEVFS_CAP_MMAP           0x20
0159 #define USBDEVFS_CAP_DROP_PRIVILEGES        0x40
0160 #define USBDEVFS_CAP_CONNINFO_EX        0x80
0161 #define USBDEVFS_CAP_SUSPEND            0x100
0162 
0163 /* USBDEVFS_DISCONNECT_CLAIM flags & struct */
0164 
0165 /* disconnect-and-claim if the driver matches the driver field */
0166 #define USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER 0x01
0167 /* disconnect-and-claim except when the driver matches the driver field */
0168 #define USBDEVFS_DISCONNECT_CLAIM_EXCEPT_DRIVER 0x02
0169 
0170 struct usbdevfs_disconnect_claim {
0171     unsigned int interface;
0172     unsigned int flags;
0173     char driver[USBDEVFS_MAXDRIVERNAME + 1];
0174 };
0175 
0176 struct usbdevfs_streams {
0177     unsigned int num_streams; /* Not used by USBDEVFS_FREE_STREAMS */
0178     unsigned int num_eps;
0179     unsigned char eps[];
0180 };
0181 
0182 /*
0183  * USB_SPEED_* values returned by USBDEVFS_GET_SPEED are defined in
0184  * linux/usb/ch9.h
0185  */
0186 
0187 #define USBDEVFS_CONTROL           _IOWR('U', 0, struct usbdevfs_ctrltransfer)
0188 #define USBDEVFS_CONTROL32           _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
0189 #define USBDEVFS_BULK              _IOWR('U', 2, struct usbdevfs_bulktransfer)
0190 #define USBDEVFS_BULK32              _IOWR('U', 2, struct usbdevfs_bulktransfer32)
0191 #define USBDEVFS_RESETEP           _IOR('U', 3, unsigned int)
0192 #define USBDEVFS_SETINTERFACE      _IOR('U', 4, struct usbdevfs_setinterface)
0193 #define USBDEVFS_SETCONFIGURATION  _IOR('U', 5, unsigned int)
0194 #define USBDEVFS_GETDRIVER         _IOW('U', 8, struct usbdevfs_getdriver)
0195 #define USBDEVFS_SUBMITURB         _IOR('U', 10, struct usbdevfs_urb)
0196 #define USBDEVFS_SUBMITURB32       _IOR('U', 10, struct usbdevfs_urb32)
0197 #define USBDEVFS_DISCARDURB        _IO('U', 11)
0198 #define USBDEVFS_REAPURB           _IOW('U', 12, void *)
0199 #define USBDEVFS_REAPURB32         _IOW('U', 12, __u32)
0200 #define USBDEVFS_REAPURBNDELAY     _IOW('U', 13, void *)
0201 #define USBDEVFS_REAPURBNDELAY32   _IOW('U', 13, __u32)
0202 #define USBDEVFS_DISCSIGNAL        _IOR('U', 14, struct usbdevfs_disconnectsignal)
0203 #define USBDEVFS_DISCSIGNAL32      _IOR('U', 14, struct usbdevfs_disconnectsignal32)
0204 #define USBDEVFS_CLAIMINTERFACE    _IOR('U', 15, unsigned int)
0205 #define USBDEVFS_RELEASEINTERFACE  _IOR('U', 16, unsigned int)
0206 #define USBDEVFS_CONNECTINFO       _IOW('U', 17, struct usbdevfs_connectinfo)
0207 #define USBDEVFS_IOCTL             _IOWR('U', 18, struct usbdevfs_ioctl)
0208 #define USBDEVFS_IOCTL32           _IOWR('U', 18, struct usbdevfs_ioctl32)
0209 #define USBDEVFS_HUB_PORTINFO      _IOR('U', 19, struct usbdevfs_hub_portinfo)
0210 #define USBDEVFS_RESET             _IO('U', 20)
0211 #define USBDEVFS_CLEAR_HALT        _IOR('U', 21, unsigned int)
0212 #define USBDEVFS_DISCONNECT        _IO('U', 22)
0213 #define USBDEVFS_CONNECT           _IO('U', 23)
0214 #define USBDEVFS_CLAIM_PORT        _IOR('U', 24, unsigned int)
0215 #define USBDEVFS_RELEASE_PORT      _IOR('U', 25, unsigned int)
0216 #define USBDEVFS_GET_CAPABILITIES  _IOR('U', 26, __u32)
0217 #define USBDEVFS_DISCONNECT_CLAIM  _IOR('U', 27, struct usbdevfs_disconnect_claim)
0218 #define USBDEVFS_ALLOC_STREAMS     _IOR('U', 28, struct usbdevfs_streams)
0219 #define USBDEVFS_FREE_STREAMS      _IOR('U', 29, struct usbdevfs_streams)
0220 #define USBDEVFS_DROP_PRIVILEGES   _IOW('U', 30, __u32)
0221 #define USBDEVFS_GET_SPEED         _IO('U', 31)
0222 /*
0223  * Returns struct usbdevfs_conninfo_ex; length is variable to allow
0224  * extending size of the data returned.
0225  */
0226 #define USBDEVFS_CONNINFO_EX(len)  _IOC(_IOC_READ, 'U', 32, len)
0227 #define USBDEVFS_FORBID_SUSPEND    _IO('U', 33)
0228 #define USBDEVFS_ALLOW_SUSPEND     _IO('U', 34)
0229 #define USBDEVFS_WAIT_FOR_RESUME   _IO('U', 35)
0230 
0231 #endif /* _UAPI_LINUX_USBDEVICE_FS_H */