usb_ioctl.h revision 185087
1/* $FreeBSD: head/sys/dev/usb2/include/usb2_ioctl.h 185087 2008-11-19 08:56:35Z alfred $ */ 2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 5 * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#ifndef _USB2_IOCTL_H_ 30#define _USB2_IOCTL_H_ 31 32#include <sys/ioccom.h> 33 34/* Building "kdump" depends on these includes */ 35 36#include <dev/usb2/include/usb2_endian.h> 37#include <dev/usb2/include/usb2_standard.h> 38 39#define USB_DEVICE_NAME "usb" 40#define USB_GENERIC_NAME "ugen" 41 42/* definition of USB power mode */ 43#define USB_POWER_MODE_OFF 0 /* turn off device */ 44#define USB_POWER_MODE_ON 1 /* always on */ 45#define USB_POWER_MODE_SAVE 2 /* automatic suspend and resume */ 46#define USB_POWER_MODE_SUSPEND 3 /* force suspend */ 47#define USB_POWER_MODE_RESUME 4 /* force resume */ 48 49struct usb2_read_dir { 50 void *urd_data; 51 uint32_t urd_startentry; 52 uint32_t urd_maxlen; 53}; 54 55struct usb2_ctl_request { 56 void *ucr_data; 57 uint16_t ucr_flags; 58#define USB_USE_POLLING 0x0001 /* internal flag */ 59#define USB_SHORT_XFER_OK 0x0004 /* allow short reads */ 60#define USB_DELAY_STATUS_STAGE 0x0010 /* insert delay before STATUS stage */ 61#define USB_USER_DATA_PTR 0x0020 /* internal flag */ 62 uint16_t ucr_actlen; /* actual length transferred */ 63 uint8_t ucr_addr; /* zero - currently not used */ 64 struct usb2_device_request ucr_request; 65}; 66 67struct usb2_alt_interface { 68 uint8_t uai_interface_index; 69 uint8_t uai_alt_index; 70}; 71 72struct usb2_gen_descriptor { 73 void *ugd_data; 74 uint16_t ugd_lang_id; 75 uint16_t ugd_maxlen; 76 uint16_t ugd_actlen; 77 uint16_t ugd_offset; 78 uint8_t ugd_config_index; 79 uint8_t ugd_string_index; 80 uint8_t ugd_iface_index; 81 uint8_t ugd_altif_index; 82 uint8_t ugd_endpt_index; 83 uint8_t ugd_report_type; 84 uint8_t reserved[8]; 85}; 86 87struct usb2_device_names { 88 char *udn_devnames_ptr; /* userland pointer to comma separated 89 * list of device names */ 90 uint16_t udn_devnames_len; /* maximum string length including 91 * terminating zero */ 92}; 93 94struct usb2_device_info { 95 uint16_t udi_productNo; 96 uint16_t udi_vendorNo; 97 uint16_t udi_releaseNo; 98 uint16_t udi_power; /* power consumption in mA, 0 if 99 * selfpowered */ 100 uint8_t udi_bus; 101 uint8_t udi_addr; /* device address */ 102 uint8_t udi_index; /* device index */ 103 uint8_t udi_class; 104 uint8_t udi_subclass; 105 uint8_t udi_protocol; 106 uint8_t udi_config_no; /* current config number */ 107 uint8_t udi_config_index; /* current config index */ 108 uint8_t udi_speed; /* see "USB_SPEED_XXX" */ 109 uint8_t udi_mode; /* see "USB_MODE_XXX" */ 110 uint8_t udi_nports; 111 uint8_t udi_hubaddr; /* parent HUB address */ 112 uint8_t udi_hubindex; /* parent HUB device index */ 113 uint8_t udi_hubport; /* parent HUB port */ 114 uint8_t udi_power_mode; /* see "USB_POWER_MODE_XXX" */ 115 uint8_t udi_suspended; /* set if device is suspended */ 116 uint8_t udi_reserved[16]; /* leave space for the future */ 117 char udi_product[128]; 118 char udi_vendor[128]; 119 char udi_serial[64]; 120 char udi_release[8]; 121}; 122 123struct usb2_device_stats { 124 uint32_t uds_requests_ok[4]; /* Indexed by transfer type UE_XXX */ 125 uint32_t uds_requests_fail[4]; /* Indexed by transfer type UE_XXX */ 126}; 127 128struct usb2_fs_start { 129 uint8_t ep_index; 130}; 131 132struct usb2_fs_stop { 133 uint8_t ep_index; 134}; 135 136struct usb2_fs_complete { 137 uint8_t ep_index; 138}; 139 140/* This structure is used for all endpoint types */ 141struct usb2_fs_endpoint { 142 /* 143 * NOTE: isochronous USB transfer only use one buffer, but can have 144 * multiple frame lengths ! 145 */ 146 void **ppBuffer; /* pointer to userland buffers */ 147 uint32_t *pLength; /* pointer to frame lengths, updated 148 * to actual length */ 149 uint32_t nFrames; /* number of frames */ 150 uint32_t aFrames; /* actual number of frames */ 151 uint16_t flags; 152 /* a single short frame will terminate */ 153#define USB_FS_FLAG_SINGLE_SHORT_OK 0x0001 154 /* multiple short frames are allowed */ 155#define USB_FS_FLAG_MULTI_SHORT_OK 0x0002 156 /* all frame(s) transmitted are short terminated */ 157#define USB_FS_FLAG_FORCE_SHORT 0x0004 158 /* will do a clear-stall before xfer */ 159#define USB_FS_FLAG_CLEAR_STALL 0x0008 160 uint16_t timeout; /* in milliseconds */ 161 /* isocronous completion time in milliseconds - used for echo cancel */ 162 uint16_t isoc_time_complete; 163 /* timeout value for no timeout */ 164#define USB_FS_TIMEOUT_NONE 0 165 uint8_t status; /* see USB_ERR_XXX */ 166}; 167 168struct usb2_fs_init { 169 /* userland pointer to endpoints structure */ 170 struct usb2_fs_endpoint *pEndpoints; 171 /* maximum number of endpoints */ 172 uint8_t ep_index_max; 173}; 174 175struct usb2_fs_uninit { 176 uint8_t dummy; /* zero */ 177}; 178 179struct usb2_fs_open { 180#define USB_FS_MAX_BUFSIZE (1 << 18) 181 uint32_t max_bufsize; 182#define USB_FS_MAX_FRAMES (1 << 12) 183 uint32_t max_frames; 184 uint16_t max_packet_length; /* read only */ 185 uint8_t dev_index; /* currently unused */ 186 uint8_t ep_index; 187 uint8_t ep_no; /* bEndpointNumber */ 188}; 189 190struct usb2_fs_close { 191 uint8_t ep_index; 192}; 193 194struct usb2_fs_clear_stall_sync { 195 uint8_t ep_index; 196}; 197 198struct usb2_dev_perm { 199 /* Access information */ 200 uint32_t user_id; 201 uint32_t group_id; 202 uint16_t mode; 203 204 /* Device location */ 205 uint16_t bus_index; 206 uint16_t dev_index; 207 uint16_t iface_index; 208}; 209 210struct usb2_gen_quirk { 211 uint16_t index; /* Quirk Index */ 212 uint16_t vid; /* Vendor ID */ 213 uint16_t pid; /* Product ID */ 214 uint16_t bcdDeviceLow; /* Low Device Revision */ 215 uint16_t bcdDeviceHigh; /* High Device Revision */ 216 uint16_t reserved[2]; 217 /* 218 * String version of quirk including terminating zero. See UQ_XXX in 219 * "usb2_quirk.h". 220 */ 221 char quirkname[64 - 14]; 222}; 223 224/* USB controller */ 225#define USB_REQUEST _IOWR('U', 1, struct usb2_ctl_request) 226#define USB_SETDEBUG _IOW ('U', 2, int) 227#define USB_DISCOVER _IO ('U', 3) 228#define USB_DEVICEINFO _IOWR('U', 4, struct usb2_device_info) 229#define USB_DEVICESTATS _IOR ('U', 5, struct usb2_device_stats) 230#define USB_DEVICEENUMERATE _IOW ('U', 6, int) 231 232/* Generic HID device */ 233#define USB_GET_REPORT_DESC _IOR ('U', 21, struct usb2_gen_descriptor) 234#define USB_SET_IMMED _IOW ('U', 22, int) 235#define USB_GET_REPORT _IOWR('U', 23, struct usb2_gen_descriptor) 236#define USB_SET_REPORT _IOW ('U', 24, struct usb2_gen_descriptor) 237#define USB_GET_REPORT_ID _IOR ('U', 25, int) 238 239/* Generic USB device */ 240#define USB_GET_CONFIG _IOR ('U', 100, int) 241#define USB_SET_CONFIG _IOW ('U', 101, int) 242#define USB_GET_ALTINTERFACE _IOWR('U', 102, struct usb2_alt_interface) 243#define USB_SET_ALTINTERFACE _IOWR('U', 103, struct usb2_alt_interface) 244#define USB_GET_DEVICE_DESC _IOR ('U', 105, struct usb2_device_descriptor) 245#define USB_GET_CONFIG_DESC _IOR ('U', 106, struct usb2_config_descriptor) 246#define USB_GET_RX_INTERFACE_DESC _IOR ('U', 107, struct usb2_interface_descriptor) 247#define USB_GET_RX_ENDPOINT_DESC _IOR ('U', 108, struct usb2_endpoint_descriptor) 248#define USB_GET_FULL_DESC _IOWR('U', 109, struct usb2_gen_descriptor) 249#define USB_GET_STRING_DESC _IOWR('U', 110, struct usb2_gen_descriptor) 250#define USB_DO_REQUEST _IOWR('U', 111, struct usb2_ctl_request) 251#define USB_GET_DEVICEINFO _IOR ('U', 112, struct usb2_device_info) 252#define USB_SET_RX_SHORT_XFER _IOW ('U', 113, int) 253#define USB_SET_RX_TIMEOUT _IOW ('U', 114, int) 254#define USB_GET_RX_FRAME_SIZE _IOR ('U', 115, int) 255#define USB_GET_RX_BUFFER_SIZE _IOR ('U', 117, int) 256#define USB_SET_RX_BUFFER_SIZE _IOW ('U', 118, int) 257#define USB_SET_RX_STALL_FLAG _IOW ('U', 119, int) 258#define USB_SET_TX_STALL_FLAG _IOW ('U', 120, int) 259#define USB_GET_DEVICENAMES _IOW ('U', 121, struct usb2_device_names) 260#define USB_CLAIM_INTERFACE _IOW ('U', 122, int) 261#define USB_RELEASE_INTERFACE _IOW ('U', 123, int) 262#define USB_IFACE_DRIVER_ACTIVE _IOW ('U', 124, int) 263#define USB_IFACE_DRIVER_DETACH _IOW ('U', 125, int) 264#define USB_GET_PLUGTIME _IOR ('U', 126, uint32_t) 265#define USB_READ_DIR _IOW ('U', 127, struct usb2_read_dir) 266#define USB_SET_ROOT_PERM _IOW ('U', 128, struct usb2_dev_perm) 267#define USB_SET_BUS_PERM _IOW ('U', 129, struct usb2_dev_perm) 268#define USB_SET_DEVICE_PERM _IOW ('U', 130, struct usb2_dev_perm) 269#define USB_SET_IFACE_PERM _IOW ('U', 131, struct usb2_dev_perm) 270#define USB_GET_ROOT_PERM _IOWR('U', 132, struct usb2_dev_perm) 271#define USB_GET_BUS_PERM _IOWR('U', 133, struct usb2_dev_perm) 272#define USB_GET_DEVICE_PERM _IOWR('U', 134, struct usb2_dev_perm) 273#define USB_GET_IFACE_PERM _IOWR('U', 135, struct usb2_dev_perm) 274#define USB_SET_TX_FORCE_SHORT _IOW ('U', 136, int) 275#define USB_SET_TX_TIMEOUT _IOW ('U', 137, int) 276#define USB_GET_TX_FRAME_SIZE _IOR ('U', 138, int) 277#define USB_GET_TX_BUFFER_SIZE _IOR ('U', 139, int) 278#define USB_SET_TX_BUFFER_SIZE _IOW ('U', 140, int) 279#define USB_GET_TX_INTERFACE_DESC _IOR ('U', 141, struct usb2_interface_descriptor) 280#define USB_GET_TX_ENDPOINT_DESC _IOR ('U', 142, struct usb2_endpoint_descriptor) 281#define USB_SET_PORT_ENABLE _IOW ('U', 143, int) 282#define USB_SET_PORT_DISABLE _IOW ('U', 144, int) 283#define USB_SET_POWER_MODE _IOW ('U', 145, int) 284#define USB_GET_POWER_MODE _IOR ('U', 146, int) 285 286/* Modem device */ 287#define USB_GET_CM_OVER_DATA _IOR ('U', 180, int) 288#define USB_SET_CM_OVER_DATA _IOW ('U', 181, int) 289 290/* USB file system interface */ 291#define USB_FS_START _IOW ('U', 192, struct usb2_fs_start) 292#define USB_FS_STOP _IOW ('U', 193, struct usb2_fs_stop) 293#define USB_FS_COMPLETE _IOR ('U', 194, struct usb2_fs_complete) 294#define USB_FS_INIT _IOW ('U', 195, struct usb2_fs_init) 295#define USB_FS_UNINIT _IOW ('U', 196, struct usb2_fs_uninit) 296#define USB_FS_OPEN _IOWR('U', 197, struct usb2_fs_open) 297#define USB_FS_CLOSE _IOW ('U', 198, struct usb2_fs_close) 298#define USB_FS_CLEAR_STALL_SYNC _IOW ('U', 199, struct usb2_fs_clear_stall_sync) 299 300/* USB quirk system interface */ 301#define USB_DEV_QUIRK_GET _IOWR('Q', 0, struct usb2_gen_quirk) 302#define USB_QUIRK_NAME_GET _IOWR('Q', 1, struct usb2_gen_quirk) 303#define USB_DEV_QUIRK_ADD _IOW ('Q', 2, struct usb2_gen_quirk) 304#define USB_DEV_QUIRK_REMOVE _IOW ('Q', 3, struct usb2_gen_quirk) 305 306#endif /* _USB2_IOCTL_H_ */ 307