usb_ioctl.h revision 194230
1/* $FreeBSD: head/sys/dev/usb/usb_ioctl.h 194230 2009-06-15 01:09:19Z thompsa $ */ 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 _USB_IOCTL_H_ 30#define _USB_IOCTL_H_ 31 32#include <sys/ioccom.h> 33 34/* Building "kdump" depends on these includes */ 35 36#include <dev/usb/usb_endian.h> 37#include <dev/usb/usb.h> 38 39#define USB_DEVICE_NAME "usbctl" 40#define USB_DEVICE_DIR "usb" 41#define USB_GENERIC_NAME "ugen" 42 43struct usb_read_dir { 44 void *urd_data; 45 uint32_t urd_startentry; 46 uint32_t urd_maxlen; 47}; 48 49struct usb_ctl_request { 50 void *ucr_data; 51 uint16_t ucr_flags; 52#define USB_SHORT_XFER_OK 0x0004 /* allow short reads */ 53#define USB_DELAY_STATUS_STAGE 0x0010 /* insert delay before STATUS stage */ 54#define USB_USER_DATA_PTR 0x0020 /* internal flag */ 55 uint16_t ucr_actlen; /* actual length transferred */ 56 uint8_t ucr_addr; /* zero - currently not used */ 57 struct usb_device_request ucr_request; 58}; 59 60struct usb_alt_interface { 61 uint8_t uai_interface_index; 62 uint8_t uai_alt_index; 63}; 64 65struct usb_gen_descriptor { 66 void *ugd_data; 67 uint16_t ugd_lang_id; 68 uint16_t ugd_maxlen; 69 uint16_t ugd_actlen; 70 uint16_t ugd_offset; 71 uint8_t ugd_config_index; 72 uint8_t ugd_string_index; 73 uint8_t ugd_iface_index; 74 uint8_t ugd_altif_index; 75 uint8_t ugd_endpt_index; 76 uint8_t ugd_report_type; 77 uint8_t reserved[8]; 78}; 79 80struct usb_device_info { 81 uint16_t udi_productNo; 82 uint16_t udi_vendorNo; 83 uint16_t udi_releaseNo; 84 uint16_t udi_power; /* power consumption in mA, 0 if 85 * selfpowered */ 86 uint8_t udi_bus; 87 uint8_t udi_addr; /* device address */ 88 uint8_t udi_index; /* device index */ 89 uint8_t udi_class; 90 uint8_t udi_subclass; 91 uint8_t udi_protocol; 92 uint8_t udi_config_no; /* current config number */ 93 uint8_t udi_config_index; /* current config index */ 94 uint8_t udi_speed; /* see "USB_SPEED_XXX" */ 95 uint8_t udi_mode; /* see "USB_MODE_XXX" */ 96 uint8_t udi_nports; 97 uint8_t udi_hubaddr; /* parent HUB address */ 98 uint8_t udi_hubindex; /* parent HUB device index */ 99 uint8_t udi_hubport; /* parent HUB port */ 100 uint8_t udi_power_mode; /* see "USB_POWER_MODE_XXX" */ 101 uint8_t udi_suspended; /* set if device is suspended */ 102 uint8_t udi_reserved[16]; /* leave space for the future */ 103 char udi_product[128]; 104 char udi_vendor[128]; 105 char udi_serial[64]; 106 char udi_release[8]; 107}; 108 109struct usb_device_stats { 110 uint32_t uds_requests_ok[4]; /* Indexed by transfer type UE_XXX */ 111 uint32_t uds_requests_fail[4]; /* Indexed by transfer type UE_XXX */ 112}; 113 114struct usb_fs_start { 115 uint8_t ep_index; 116}; 117 118struct usb_fs_stop { 119 uint8_t ep_index; 120}; 121 122struct usb_fs_complete { 123 uint8_t ep_index; 124}; 125 126/* This structure is used for all endpoint types */ 127struct usb_fs_endpoint { 128 /* 129 * NOTE: isochronous USB transfer only use one buffer, but can have 130 * multiple frame lengths ! 131 */ 132 void **ppBuffer; /* pointer to userland buffers */ 133 uint32_t *pLength; /* pointer to frame lengths, updated 134 * to actual length */ 135 uint32_t nFrames; /* number of frames */ 136 uint32_t aFrames; /* actual number of frames */ 137 uint16_t flags; 138 /* a single short frame will terminate */ 139#define USB_FS_FLAG_SINGLE_SHORT_OK 0x0001 140 /* multiple short frames are allowed */ 141#define USB_FS_FLAG_MULTI_SHORT_OK 0x0002 142 /* all frame(s) transmitted are short terminated */ 143#define USB_FS_FLAG_FORCE_SHORT 0x0004 144 /* will do a clear-stall before xfer */ 145#define USB_FS_FLAG_CLEAR_STALL 0x0008 146 uint16_t timeout; /* in milliseconds */ 147 /* isocronous completion time in milliseconds - used for echo cancel */ 148 uint16_t isoc_time_complete; 149 /* timeout value for no timeout */ 150#define USB_FS_TIMEOUT_NONE 0 151 uint8_t status; /* see USB_ERR_XXX */ 152}; 153 154struct usb_fs_init { 155 /* userland pointer to endpoints structure */ 156 struct usb_fs_endpoint *pEndpoints; 157 /* maximum number of endpoints */ 158 uint8_t ep_index_max; 159}; 160 161struct usb_fs_uninit { 162 uint8_t dummy; /* zero */ 163}; 164 165struct usb_fs_open { 166#define USB_FS_MAX_BUFSIZE (1 << 18) 167 uint32_t max_bufsize; 168#define USB_FS_MAX_FRAMES (1 << 12) 169 uint32_t max_frames; 170 uint16_t max_packet_length; /* read only */ 171 uint8_t dev_index; /* currently unused */ 172 uint8_t ep_index; 173 uint8_t ep_no; /* bEndpointNumber */ 174}; 175 176struct usb_fs_close { 177 uint8_t ep_index; 178}; 179 180struct usb_fs_clear_stall_sync { 181 uint8_t ep_index; 182}; 183 184struct usb_gen_quirk { 185 uint16_t index; /* Quirk Index */ 186 uint16_t vid; /* Vendor ID */ 187 uint16_t pid; /* Product ID */ 188 uint16_t bcdDeviceLow; /* Low Device Revision */ 189 uint16_t bcdDeviceHigh; /* High Device Revision */ 190 uint16_t reserved[2]; 191 /* 192 * String version of quirk including terminating zero. See UQ_XXX in 193 * "usb_quirk.h". 194 */ 195 char quirkname[64 - 14]; 196}; 197 198/* USB controller */ 199#define USB_REQUEST _IOWR('U', 1, struct usb_ctl_request) 200#define USB_SETDEBUG _IOW ('U', 2, int) 201#define USB_DISCOVER _IO ('U', 3) 202#define USB_DEVICEINFO _IOWR('U', 4, struct usb_device_info) 203#define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats) 204#define USB_DEVICEENUMERATE _IOW ('U', 6, int) 205 206/* Generic HID device */ 207#define USB_GET_REPORT_DESC _IOWR('U', 21, struct usb_gen_descriptor) 208#define USB_SET_IMMED _IOW ('U', 22, int) 209#define USB_GET_REPORT _IOWR('U', 23, struct usb_gen_descriptor) 210#define USB_SET_REPORT _IOW ('U', 24, struct usb_gen_descriptor) 211#define USB_GET_REPORT_ID _IOR ('U', 25, int) 212 213/* Generic USB device */ 214#define USB_GET_CONFIG _IOR ('U', 100, int) 215#define USB_SET_CONFIG _IOW ('U', 101, int) 216#define USB_GET_ALTINTERFACE _IOWR('U', 102, struct usb_alt_interface) 217#define USB_SET_ALTINTERFACE _IOWR('U', 103, struct usb_alt_interface) 218#define USB_GET_DEVICE_DESC _IOR ('U', 105, struct usb_device_descriptor) 219#define USB_GET_CONFIG_DESC _IOR ('U', 106, struct usb_config_descriptor) 220#define USB_GET_RX_INTERFACE_DESC _IOR ('U', 107, struct usb_interface_descriptor) 221#define USB_GET_RX_ENDPOINT_DESC _IOR ('U', 108, struct usb_endpoint_descriptor) 222#define USB_GET_FULL_DESC _IOWR('U', 109, struct usb_gen_descriptor) 223#define USB_GET_STRING_DESC _IOWR('U', 110, struct usb_gen_descriptor) 224#define USB_DO_REQUEST _IOWR('U', 111, struct usb_ctl_request) 225#define USB_GET_DEVICEINFO _IOR ('U', 112, struct usb_device_info) 226#define USB_SET_RX_SHORT_XFER _IOW ('U', 113, int) 227#define USB_SET_RX_TIMEOUT _IOW ('U', 114, int) 228#define USB_GET_RX_FRAME_SIZE _IOR ('U', 115, int) 229#define USB_GET_RX_BUFFER_SIZE _IOR ('U', 117, int) 230#define USB_SET_RX_BUFFER_SIZE _IOW ('U', 118, int) 231#define USB_SET_RX_STALL_FLAG _IOW ('U', 119, int) 232#define USB_SET_TX_STALL_FLAG _IOW ('U', 120, int) 233#define USB_GET_IFACE_DRIVER _IOWR('U', 121, struct usb_gen_descriptor) 234#define USB_CLAIM_INTERFACE _IOW ('U', 122, int) 235#define USB_RELEASE_INTERFACE _IOW ('U', 123, int) 236#define USB_IFACE_DRIVER_ACTIVE _IOW ('U', 124, int) 237#define USB_IFACE_DRIVER_DETACH _IOW ('U', 125, int) 238#define USB_GET_PLUGTIME _IOR ('U', 126, uint32_t) 239#define USB_READ_DIR _IOW ('U', 127, struct usb_read_dir) 240/* 128 - 135 unused */ 241#define USB_SET_TX_FORCE_SHORT _IOW ('U', 136, int) 242#define USB_SET_TX_TIMEOUT _IOW ('U', 137, int) 243#define USB_GET_TX_FRAME_SIZE _IOR ('U', 138, int) 244#define USB_GET_TX_BUFFER_SIZE _IOR ('U', 139, int) 245#define USB_SET_TX_BUFFER_SIZE _IOW ('U', 140, int) 246#define USB_GET_TX_INTERFACE_DESC _IOR ('U', 141, struct usb_interface_descriptor) 247#define USB_GET_TX_ENDPOINT_DESC _IOR ('U', 142, struct usb_endpoint_descriptor) 248#define USB_SET_PORT_ENABLE _IOW ('U', 143, int) 249#define USB_SET_PORT_DISABLE _IOW ('U', 144, int) 250#define USB_SET_POWER_MODE _IOW ('U', 145, int) 251#define USB_GET_POWER_MODE _IOR ('U', 146, int) 252#define USB_SET_TEMPLATE _IOW ('U', 147, int) 253#define USB_GET_TEMPLATE _IOR ('U', 148, int) 254 255/* Modem device */ 256#define USB_GET_CM_OVER_DATA _IOR ('U', 180, int) 257#define USB_SET_CM_OVER_DATA _IOW ('U', 181, int) 258 259/* USB file system interface */ 260#define USB_FS_START _IOW ('U', 192, struct usb_fs_start) 261#define USB_FS_STOP _IOW ('U', 193, struct usb_fs_stop) 262#define USB_FS_COMPLETE _IOR ('U', 194, struct usb_fs_complete) 263#define USB_FS_INIT _IOW ('U', 195, struct usb_fs_init) 264#define USB_FS_UNINIT _IOW ('U', 196, struct usb_fs_uninit) 265#define USB_FS_OPEN _IOWR('U', 197, struct usb_fs_open) 266#define USB_FS_CLOSE _IOW ('U', 198, struct usb_fs_close) 267#define USB_FS_CLEAR_STALL_SYNC _IOW ('U', 199, struct usb_fs_clear_stall_sync) 268 269/* USB quirk system interface */ 270#define USB_DEV_QUIRK_GET _IOWR('Q', 0, struct usb_gen_quirk) 271#define USB_QUIRK_NAME_GET _IOWR('Q', 1, struct usb_gen_quirk) 272#define USB_DEV_QUIRK_ADD _IOW ('Q', 2, struct usb_gen_quirk) 273#define USB_DEV_QUIRK_REMOVE _IOW ('Q', 3, struct usb_gen_quirk) 274 275#endif /* _USB_IOCTL_H_ */ 276