102ac6454SAndrew Thompson /* $FreeBSD$ */ 202ac6454SAndrew Thompson /*- 3718cf2ccSPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 4718cf2ccSPedro F. Giffuni * 502ac6454SAndrew Thompson * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 602ac6454SAndrew Thompson * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 702ac6454SAndrew Thompson * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 802ac6454SAndrew Thompson * 902ac6454SAndrew Thompson * Redistribution and use in source and binary forms, with or without 1002ac6454SAndrew Thompson * modification, are permitted provided that the following conditions 1102ac6454SAndrew Thompson * are met: 1202ac6454SAndrew Thompson * 1. Redistributions of source code must retain the above copyright 1302ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer. 1402ac6454SAndrew Thompson * 2. Redistributions in binary form must reproduce the above copyright 1502ac6454SAndrew Thompson * notice, this list of conditions and the following disclaimer in the 1602ac6454SAndrew Thompson * documentation and/or other materials provided with the distribution. 1702ac6454SAndrew Thompson * 1802ac6454SAndrew Thompson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1902ac6454SAndrew Thompson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2002ac6454SAndrew Thompson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2102ac6454SAndrew Thompson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2202ac6454SAndrew Thompson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2302ac6454SAndrew Thompson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2402ac6454SAndrew Thompson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2502ac6454SAndrew Thompson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2602ac6454SAndrew Thompson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2702ac6454SAndrew Thompson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2802ac6454SAndrew Thompson * SUCH DAMAGE. 2902ac6454SAndrew Thompson */ 3002ac6454SAndrew Thompson 3175973647SAndrew Thompson #ifndef _USB_IOCTL_H_ 3275973647SAndrew Thompson #define _USB_IOCTL_H_ 3302ac6454SAndrew Thompson 34d2b99310SHans Petter Selasky #ifndef USB_GLOBAL_INCLUDE_FILE 3502ac6454SAndrew Thompson #include <sys/ioccom.h> 3662a963c5SHans Petter Selasky #include <sys/cdefs.h> 3702ac6454SAndrew Thompson 3802ac6454SAndrew Thompson /* Building "kdump" depends on these includes */ 3902ac6454SAndrew Thompson 4002ac6454SAndrew Thompson #include <dev/usb/usb_endian.h> 4102ac6454SAndrew Thompson #include <dev/usb/usb.h> 42d2b99310SHans Petter Selasky #endif 4302ac6454SAndrew Thompson 44ee3e3ff5SAndrew Thompson #define USB_DEVICE_NAME "usbctl" 45ee3e3ff5SAndrew Thompson #define USB_DEVICE_DIR "usb" 4602ac6454SAndrew Thompson #define USB_GENERIC_NAME "ugen" 47399e6543SHans Petter Selasky #define USB_TEMPLATE_SYSCTL "hw.usb.template" /* integer type */ 48399e6543SHans Petter Selasky 4962a963c5SHans Petter Selasky /* 5062a963c5SHans Petter Selasky * Align IOCTL structures to hide differences when running 32-bit 5162a963c5SHans Petter Selasky * programs under 64-bit kernels: 5262a963c5SHans Petter Selasky */ 5362a963c5SHans Petter Selasky #ifdef COMPAT_32BIT 5462a963c5SHans Petter Selasky #define USB_IOCTL_STRUCT_ALIGN(n) __aligned(n) 5562a963c5SHans Petter Selasky #else 5662a963c5SHans Petter Selasky #define USB_IOCTL_STRUCT_ALIGN(n) 5762a963c5SHans Petter Selasky #endif 5862a963c5SHans Petter Selasky 59399e6543SHans Petter Selasky /* Definition of valid template sysctl values */ 60399e6543SHans Petter Selasky 61399e6543SHans Petter Selasky enum { 62399e6543SHans Petter Selasky USB_TEMP_MSC, /* USB Mass Storage */ 63399e6543SHans Petter Selasky USB_TEMP_CDCE, /* USB CDC Ethernet */ 64399e6543SHans Petter Selasky USB_TEMP_MTP, /* Message Transfer Protocol */ 65399e6543SHans Petter Selasky USB_TEMP_MODEM, /* USB CDC Modem */ 66399e6543SHans Petter Selasky USB_TEMP_AUDIO, /* USB Audio */ 67399e6543SHans Petter Selasky USB_TEMP_KBD, /* USB Keyboard */ 68399e6543SHans Petter Selasky USB_TEMP_MOUSE, /* USB Mouse */ 69f9478f91SHans Petter Selasky USB_TEMP_PHONE, /* USB Phone */ 703e420a3eSRuslan Bukin USB_TEMP_SERIALNET, /* USB CDC Ethernet and Modem */ 710a76fe7cSHans Petter Selasky USB_TEMP_MIDI, /* USB MIDI */ 723dc87e52SEdward Tomasz Napierala USB_TEMP_MULTI, /* USB Ethernet, serial, and storage */ 7363722e52SEdward Tomasz Napierala USB_TEMP_CDCEEM, /* USB Ethernet Emulation Model */ 74399e6543SHans Petter Selasky USB_TEMP_MAX, 75399e6543SHans Petter Selasky }; 7602ac6454SAndrew Thompson 77760bc48eSAndrew Thompson struct usb_read_dir { 7851fd3d75SHans Petter Selasky #ifdef COMPAT_32BIT 7951fd3d75SHans Petter Selasky uint64_t urd_data; 8051fd3d75SHans Petter Selasky #else 8102ac6454SAndrew Thompson void *urd_data; 8251fd3d75SHans Petter Selasky #endif 8302ac6454SAndrew Thompson uint32_t urd_startentry; 8402ac6454SAndrew Thompson uint32_t urd_maxlen; 8562a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(8); 8602ac6454SAndrew Thompson 87760bc48eSAndrew Thompson struct usb_ctl_request { 8851fd3d75SHans Petter Selasky #ifdef COMPAT_32BIT 8951fd3d75SHans Petter Selasky uint64_t ucr_data; 9051fd3d75SHans Petter Selasky #else 9102ac6454SAndrew Thompson void *ucr_data; 9251fd3d75SHans Petter Selasky #endif 9302ac6454SAndrew Thompson uint16_t ucr_flags; 9402ac6454SAndrew Thompson uint16_t ucr_actlen; /* actual length transferred */ 9502ac6454SAndrew Thompson uint8_t ucr_addr; /* zero - currently not used */ 96760bc48eSAndrew Thompson struct usb_device_request ucr_request; 9762a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(8); 9802ac6454SAndrew Thompson 99760bc48eSAndrew Thompson struct usb_alt_interface { 10002ac6454SAndrew Thompson uint8_t uai_interface_index; 10102ac6454SAndrew Thompson uint8_t uai_alt_index; 10262a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(1); 10302ac6454SAndrew Thompson 104760bc48eSAndrew Thompson struct usb_gen_descriptor { 10551fd3d75SHans Petter Selasky #ifdef COMPAT_32BIT 10651fd3d75SHans Petter Selasky uint64_t ugd_data; 10751fd3d75SHans Petter Selasky #else 10802ac6454SAndrew Thompson void *ugd_data; 10951fd3d75SHans Petter Selasky #endif 11002ac6454SAndrew Thompson uint16_t ugd_lang_id; 11102ac6454SAndrew Thompson uint16_t ugd_maxlen; 11202ac6454SAndrew Thompson uint16_t ugd_actlen; 11302ac6454SAndrew Thompson uint16_t ugd_offset; 11402ac6454SAndrew Thompson uint8_t ugd_config_index; 11502ac6454SAndrew Thompson uint8_t ugd_string_index; 11602ac6454SAndrew Thompson uint8_t ugd_iface_index; 11702ac6454SAndrew Thompson uint8_t ugd_altif_index; 11802ac6454SAndrew Thompson uint8_t ugd_endpt_index; 11902ac6454SAndrew Thompson uint8_t ugd_report_type; 12002ac6454SAndrew Thompson uint8_t reserved[8]; 12162a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(8); 12202ac6454SAndrew Thompson 123760bc48eSAndrew Thompson struct usb_device_info { 12402ac6454SAndrew Thompson uint16_t udi_productNo; 12502ac6454SAndrew Thompson uint16_t udi_vendorNo; 12602ac6454SAndrew Thompson uint16_t udi_releaseNo; 12702ac6454SAndrew Thompson uint16_t udi_power; /* power consumption in mA, 0 if 12802ac6454SAndrew Thompson * selfpowered */ 12902ac6454SAndrew Thompson uint8_t udi_bus; 13002ac6454SAndrew Thompson uint8_t udi_addr; /* device address */ 13102ac6454SAndrew Thompson uint8_t udi_index; /* device index */ 13202ac6454SAndrew Thompson uint8_t udi_class; 13302ac6454SAndrew Thompson uint8_t udi_subclass; 13402ac6454SAndrew Thompson uint8_t udi_protocol; 13502ac6454SAndrew Thompson uint8_t udi_config_no; /* current config number */ 13602ac6454SAndrew Thompson uint8_t udi_config_index; /* current config index */ 13702ac6454SAndrew Thompson uint8_t udi_speed; /* see "USB_SPEED_XXX" */ 13802ac6454SAndrew Thompson uint8_t udi_mode; /* see "USB_MODE_XXX" */ 13902ac6454SAndrew Thompson uint8_t udi_nports; 14002ac6454SAndrew Thompson uint8_t udi_hubaddr; /* parent HUB address */ 14102ac6454SAndrew Thompson uint8_t udi_hubindex; /* parent HUB device index */ 14202ac6454SAndrew Thompson uint8_t udi_hubport; /* parent HUB port */ 14302ac6454SAndrew Thompson uint8_t udi_power_mode; /* see "USB_POWER_MODE_XXX" */ 14402ac6454SAndrew Thompson uint8_t udi_suspended; /* set if device is suspended */ 14502ac6454SAndrew Thompson uint8_t udi_reserved[16]; /* leave space for the future */ 14602ac6454SAndrew Thompson char udi_product[128]; 14702ac6454SAndrew Thompson char udi_vendor[128]; 14802ac6454SAndrew Thompson char udi_serial[64]; 14902ac6454SAndrew Thompson char udi_release[8]; 15062a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(2); 15102ac6454SAndrew Thompson 152c77a24c2SHans Petter Selasky #define USB_DEVICE_PORT_PATH_MAX 32 153c77a24c2SHans Petter Selasky 154c77a24c2SHans Petter Selasky struct usb_device_port_path { 155c77a24c2SHans Petter Selasky uint8_t udp_bus; /* which bus we are on */ 156c77a24c2SHans Petter Selasky uint8_t udp_index; /* which device index */ 157c77a24c2SHans Petter Selasky uint8_t udp_port_level; /* how many levels: 0, 1, 2 ... */ 158c77a24c2SHans Petter Selasky uint8_t udp_port_no[USB_DEVICE_PORT_PATH_MAX]; 15962a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(1); 160c77a24c2SHans Petter Selasky 161760bc48eSAndrew Thompson struct usb_device_stats { 16202ac6454SAndrew Thompson uint32_t uds_requests_ok[4]; /* Indexed by transfer type UE_XXX */ 16302ac6454SAndrew Thompson uint32_t uds_requests_fail[4]; /* Indexed by transfer type UE_XXX */ 16462a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(4); 16502ac6454SAndrew Thompson 166760bc48eSAndrew Thompson struct usb_fs_start { 16702ac6454SAndrew Thompson uint8_t ep_index; 16862a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(1); 16902ac6454SAndrew Thompson 170760bc48eSAndrew Thompson struct usb_fs_stop { 17102ac6454SAndrew Thompson uint8_t ep_index; 17262a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(1); 17302ac6454SAndrew Thompson 174760bc48eSAndrew Thompson struct usb_fs_complete { 17502ac6454SAndrew Thompson uint8_t ep_index; 17662a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(1); 17702ac6454SAndrew Thompson 17802ac6454SAndrew Thompson /* This structure is used for all endpoint types */ 179760bc48eSAndrew Thompson struct usb_fs_endpoint { 18002ac6454SAndrew Thompson /* 18102ac6454SAndrew Thompson * NOTE: isochronous USB transfer only use one buffer, but can have 18202ac6454SAndrew Thompson * multiple frame lengths ! 18302ac6454SAndrew Thompson */ 18451fd3d75SHans Petter Selasky #ifdef COMPAT_32BIT 18551fd3d75SHans Petter Selasky uint64_t ppBuffer; 18651fd3d75SHans Petter Selasky uint64_t pLength; 18751fd3d75SHans Petter Selasky #else 18802ac6454SAndrew Thompson void **ppBuffer; /* pointer to userland buffers */ 18902ac6454SAndrew Thompson uint32_t *pLength; /* pointer to frame lengths, updated 19002ac6454SAndrew Thompson * to actual length */ 19151fd3d75SHans Petter Selasky #endif 19202ac6454SAndrew Thompson uint32_t nFrames; /* number of frames */ 19302ac6454SAndrew Thompson uint32_t aFrames; /* actual number of frames */ 19402ac6454SAndrew Thompson uint16_t flags; 19502ac6454SAndrew Thompson /* a single short frame will terminate */ 19602ac6454SAndrew Thompson #define USB_FS_FLAG_SINGLE_SHORT_OK 0x0001 19702ac6454SAndrew Thompson /* multiple short frames are allowed */ 19802ac6454SAndrew Thompson #define USB_FS_FLAG_MULTI_SHORT_OK 0x0002 19902ac6454SAndrew Thompson /* all frame(s) transmitted are short terminated */ 20002ac6454SAndrew Thompson #define USB_FS_FLAG_FORCE_SHORT 0x0004 20102ac6454SAndrew Thompson /* will do a clear-stall before xfer */ 20202ac6454SAndrew Thompson #define USB_FS_FLAG_CLEAR_STALL 0x0008 20302ac6454SAndrew Thompson uint16_t timeout; /* in milliseconds */ 20402ac6454SAndrew Thompson /* isocronous completion time in milliseconds - used for echo cancel */ 20502ac6454SAndrew Thompson uint16_t isoc_time_complete; 20602ac6454SAndrew Thompson /* timeout value for no timeout */ 20702ac6454SAndrew Thompson #define USB_FS_TIMEOUT_NONE 0 208ed6d949aSAndrew Thompson int status; /* see USB_ERR_XXX */ 20962a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(8); 21002ac6454SAndrew Thompson 211760bc48eSAndrew Thompson struct usb_fs_init { 21202ac6454SAndrew Thompson /* userland pointer to endpoints structure */ 21351fd3d75SHans Petter Selasky #ifdef COMPAT_32BIT 21451fd3d75SHans Petter Selasky uint64_t pEndpoints; 21551fd3d75SHans Petter Selasky #else 216760bc48eSAndrew Thompson struct usb_fs_endpoint *pEndpoints; 21751fd3d75SHans Petter Selasky #endif 21802ac6454SAndrew Thompson /* maximum number of endpoints */ 21902ac6454SAndrew Thompson uint8_t ep_index_max; 22062a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(8); 22102ac6454SAndrew Thompson 222760bc48eSAndrew Thompson struct usb_fs_uninit { 22302ac6454SAndrew Thompson uint8_t dummy; /* zero */ 22462a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(1); 22502ac6454SAndrew Thompson 226760bc48eSAndrew Thompson struct usb_fs_open { 2274631d7f7SHans Petter Selasky #define USB_FS_MAX_BUFSIZE (1 << 25) /* 32 MBytes */ 22802ac6454SAndrew Thompson uint32_t max_bufsize; 2291c497368SHans Petter Selasky #define USB_FS_MAX_FRAMES (1U << 12) 2301c497368SHans Petter Selasky #define USB_FS_MAX_FRAMES_PRE_SCALE (1U << 31) /* for ISOCHRONOUS transfers */ 2311c497368SHans Petter Selasky uint32_t max_frames; /* read and write */ 23202ac6454SAndrew Thompson uint16_t max_packet_length; /* read only */ 23302ac6454SAndrew Thompson uint8_t dev_index; /* currently unused */ 23402ac6454SAndrew Thompson uint8_t ep_index; 23502ac6454SAndrew Thompson uint8_t ep_no; /* bEndpointNumber */ 23662a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(4); 23702ac6454SAndrew Thompson 238e9cec016SHans Petter Selasky struct usb_fs_open_stream { 239a5cf1aaaSHans Petter Selasky struct usb_fs_open fs_open; 24062a963c5SHans Petter Selasky uint16_t stream_id; /* stream ID */ 24162a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(4); 242a5cf1aaaSHans Petter Selasky 243760bc48eSAndrew Thompson struct usb_fs_close { 24402ac6454SAndrew Thompson uint8_t ep_index; 24562a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(1); 24602ac6454SAndrew Thompson 247760bc48eSAndrew Thompson struct usb_fs_clear_stall_sync { 24802ac6454SAndrew Thompson uint8_t ep_index; 24962a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(1); 25002ac6454SAndrew Thompson 251760bc48eSAndrew Thompson struct usb_gen_quirk { 25202ac6454SAndrew Thompson uint16_t index; /* Quirk Index */ 25302ac6454SAndrew Thompson uint16_t vid; /* Vendor ID */ 25402ac6454SAndrew Thompson uint16_t pid; /* Product ID */ 25502ac6454SAndrew Thompson uint16_t bcdDeviceLow; /* Low Device Revision */ 25602ac6454SAndrew Thompson uint16_t bcdDeviceHigh; /* High Device Revision */ 25702ac6454SAndrew Thompson uint16_t reserved[2]; 25802ac6454SAndrew Thompson /* 25962a963c5SHans Petter Selasky * String version of quirk including terminating zero. See 26062a963c5SHans Petter Selasky * UQ_XXX in "usb_quirk.h". 26102ac6454SAndrew Thompson */ 26202ac6454SAndrew Thompson char quirkname[64 - 14]; 26362a963c5SHans Petter Selasky } USB_IOCTL_STRUCT_ALIGN(2); 26402ac6454SAndrew Thompson 26502ac6454SAndrew Thompson /* USB controller */ 266760bc48eSAndrew Thompson #define USB_REQUEST _IOWR('U', 1, struct usb_ctl_request) 26702ac6454SAndrew Thompson #define USB_SETDEBUG _IOW ('U', 2, int) 26802ac6454SAndrew Thompson #define USB_DISCOVER _IO ('U', 3) 269760bc48eSAndrew Thompson #define USB_DEVICEINFO _IOWR('U', 4, struct usb_device_info) 270760bc48eSAndrew Thompson #define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats) 27102ac6454SAndrew Thompson #define USB_DEVICEENUMERATE _IOW ('U', 6, int) 27202ac6454SAndrew Thompson 27394773907SVladimir Kondratyev /* Generic HID device. Numbers 26 and 30-39 are occupied by hidraw. */ 274760bc48eSAndrew Thompson #define USB_GET_REPORT_DESC _IOWR('U', 21, struct usb_gen_descriptor) 27502ac6454SAndrew Thompson #define USB_SET_IMMED _IOW ('U', 22, int) 276760bc48eSAndrew Thompson #define USB_GET_REPORT _IOWR('U', 23, struct usb_gen_descriptor) 277760bc48eSAndrew Thompson #define USB_SET_REPORT _IOW ('U', 24, struct usb_gen_descriptor) 27802ac6454SAndrew Thompson #define USB_GET_REPORT_ID _IOR ('U', 25, int) 27902ac6454SAndrew Thompson 28002ac6454SAndrew Thompson /* Generic USB device */ 28102ac6454SAndrew Thompson #define USB_GET_CONFIG _IOR ('U', 100, int) 28202ac6454SAndrew Thompson #define USB_SET_CONFIG _IOW ('U', 101, int) 283760bc48eSAndrew Thompson #define USB_GET_ALTINTERFACE _IOWR('U', 102, struct usb_alt_interface) 284760bc48eSAndrew Thompson #define USB_SET_ALTINTERFACE _IOWR('U', 103, struct usb_alt_interface) 285760bc48eSAndrew Thompson #define USB_GET_DEVICE_DESC _IOR ('U', 105, struct usb_device_descriptor) 286760bc48eSAndrew Thompson #define USB_GET_CONFIG_DESC _IOR ('U', 106, struct usb_config_descriptor) 287760bc48eSAndrew Thompson #define USB_GET_RX_INTERFACE_DESC _IOR ('U', 107, struct usb_interface_descriptor) 288760bc48eSAndrew Thompson #define USB_GET_RX_ENDPOINT_DESC _IOR ('U', 108, struct usb_endpoint_descriptor) 289760bc48eSAndrew Thompson #define USB_GET_FULL_DESC _IOWR('U', 109, struct usb_gen_descriptor) 290760bc48eSAndrew Thompson #define USB_GET_STRING_DESC _IOWR('U', 110, struct usb_gen_descriptor) 291760bc48eSAndrew Thompson #define USB_DO_REQUEST _IOWR('U', 111, struct usb_ctl_request) 292760bc48eSAndrew Thompson #define USB_GET_DEVICEINFO _IOR ('U', 112, struct usb_device_info) 29302ac6454SAndrew Thompson #define USB_SET_RX_SHORT_XFER _IOW ('U', 113, int) 29402ac6454SAndrew Thompson #define USB_SET_RX_TIMEOUT _IOW ('U', 114, int) 29502ac6454SAndrew Thompson #define USB_GET_RX_FRAME_SIZE _IOR ('U', 115, int) 29602ac6454SAndrew Thompson #define USB_GET_RX_BUFFER_SIZE _IOR ('U', 117, int) 29702ac6454SAndrew Thompson #define USB_SET_RX_BUFFER_SIZE _IOW ('U', 118, int) 29802ac6454SAndrew Thompson #define USB_SET_RX_STALL_FLAG _IOW ('U', 119, int) 29902ac6454SAndrew Thompson #define USB_SET_TX_STALL_FLAG _IOW ('U', 120, int) 300760bc48eSAndrew Thompson #define USB_GET_IFACE_DRIVER _IOWR('U', 121, struct usb_gen_descriptor) 30102ac6454SAndrew Thompson #define USB_CLAIM_INTERFACE _IOW ('U', 122, int) 30202ac6454SAndrew Thompson #define USB_RELEASE_INTERFACE _IOW ('U', 123, int) 30302ac6454SAndrew Thompson #define USB_IFACE_DRIVER_ACTIVE _IOW ('U', 124, int) 30402ac6454SAndrew Thompson #define USB_IFACE_DRIVER_DETACH _IOW ('U', 125, int) 30502ac6454SAndrew Thompson #define USB_GET_PLUGTIME _IOR ('U', 126, uint32_t) 306760bc48eSAndrew Thompson #define USB_READ_DIR _IOW ('U', 127, struct usb_read_dir) 307c77a24c2SHans Petter Selasky /* 128 - 133 unused */ 308c77a24c2SHans Petter Selasky #define USB_GET_DEV_PORT_PATH _IOR ('U', 134, struct usb_device_port_path) 309aafcb732SHans Petter Selasky #define USB_GET_POWER_USAGE _IOR ('U', 135, int) 31002ac6454SAndrew Thompson #define USB_SET_TX_FORCE_SHORT _IOW ('U', 136, int) 31102ac6454SAndrew Thompson #define USB_SET_TX_TIMEOUT _IOW ('U', 137, int) 31202ac6454SAndrew Thompson #define USB_GET_TX_FRAME_SIZE _IOR ('U', 138, int) 31302ac6454SAndrew Thompson #define USB_GET_TX_BUFFER_SIZE _IOR ('U', 139, int) 31402ac6454SAndrew Thompson #define USB_SET_TX_BUFFER_SIZE _IOW ('U', 140, int) 315760bc48eSAndrew Thompson #define USB_GET_TX_INTERFACE_DESC _IOR ('U', 141, struct usb_interface_descriptor) 316760bc48eSAndrew Thompson #define USB_GET_TX_ENDPOINT_DESC _IOR ('U', 142, struct usb_endpoint_descriptor) 31702ac6454SAndrew Thompson #define USB_SET_PORT_ENABLE _IOW ('U', 143, int) 31802ac6454SAndrew Thompson #define USB_SET_PORT_DISABLE _IOW ('U', 144, int) 31902ac6454SAndrew Thompson #define USB_SET_POWER_MODE _IOW ('U', 145, int) 32002ac6454SAndrew Thompson #define USB_GET_POWER_MODE _IOR ('U', 146, int) 321f78fa6b6SAndrew Thompson #define USB_SET_TEMPLATE _IOW ('U', 147, int) 322f78fa6b6SAndrew Thompson #define USB_GET_TEMPLATE _IOR ('U', 148, int) 32302ac6454SAndrew Thompson 32402ac6454SAndrew Thompson /* Modem device */ 32502ac6454SAndrew Thompson #define USB_GET_CM_OVER_DATA _IOR ('U', 180, int) 32602ac6454SAndrew Thompson #define USB_SET_CM_OVER_DATA _IOW ('U', 181, int) 32702ac6454SAndrew Thompson 32817c78d34SHans Petter Selasky /* GPIO control */ 32917c78d34SHans Petter Selasky #define USB_GET_GPIO _IOR ('U', 182, int) 33017c78d34SHans Petter Selasky #define USB_SET_GPIO _IOW ('U', 183, int) 33117c78d34SHans Petter Selasky 33202ac6454SAndrew Thompson /* USB file system interface */ 333760bc48eSAndrew Thompson #define USB_FS_START _IOW ('U', 192, struct usb_fs_start) 334760bc48eSAndrew Thompson #define USB_FS_STOP _IOW ('U', 193, struct usb_fs_stop) 335760bc48eSAndrew Thompson #define USB_FS_COMPLETE _IOR ('U', 194, struct usb_fs_complete) 336760bc48eSAndrew Thompson #define USB_FS_INIT _IOW ('U', 195, struct usb_fs_init) 337760bc48eSAndrew Thompson #define USB_FS_UNINIT _IOW ('U', 196, struct usb_fs_uninit) 338760bc48eSAndrew Thompson #define USB_FS_OPEN _IOWR('U', 197, struct usb_fs_open) 339760bc48eSAndrew Thompson #define USB_FS_CLOSE _IOW ('U', 198, struct usb_fs_close) 340760bc48eSAndrew Thompson #define USB_FS_CLEAR_STALL_SYNC _IOW ('U', 199, struct usb_fs_clear_stall_sync) 341e9cec016SHans Petter Selasky #define USB_FS_OPEN_STREAM _IOWR('U', 200, struct usb_fs_open_stream) 34202ac6454SAndrew Thompson 34302ac6454SAndrew Thompson /* USB quirk system interface */ 344760bc48eSAndrew Thompson #define USB_DEV_QUIRK_GET _IOWR('Q', 0, struct usb_gen_quirk) 345760bc48eSAndrew Thompson #define USB_QUIRK_NAME_GET _IOWR('Q', 1, struct usb_gen_quirk) 346760bc48eSAndrew Thompson #define USB_DEV_QUIRK_ADD _IOW ('Q', 2, struct usb_gen_quirk) 347760bc48eSAndrew Thompson #define USB_DEV_QUIRK_REMOVE _IOW ('Q', 3, struct usb_gen_quirk) 34802ac6454SAndrew Thompson 34945b48cbcSBrooks Davis #ifdef _KERNEL 35045b48cbcSBrooks Davis #ifdef COMPAT_FREEBSD32 35145b48cbcSBrooks Davis 35245b48cbcSBrooks Davis struct usb_read_dir32 { 35345b48cbcSBrooks Davis uint32_t urd_data; 35445b48cbcSBrooks Davis uint32_t urd_startentry; 35545b48cbcSBrooks Davis uint32_t urd_maxlen; 35645b48cbcSBrooks Davis }; 35745b48cbcSBrooks Davis #define USB_READ_DIR32 \ 35845b48cbcSBrooks Davis _IOC_NEWTYPE(USB_READ_DIR, struct usb_read_dir32) 35945b48cbcSBrooks Davis 36045b48cbcSBrooks Davis struct usb_ctl_request32 { 36145b48cbcSBrooks Davis uint32_t ucr_data; 36245b48cbcSBrooks Davis uint16_t ucr_flags; 36345b48cbcSBrooks Davis uint16_t ucr_actlen; 36445b48cbcSBrooks Davis uint8_t ucr_addr; 36545b48cbcSBrooks Davis struct usb_device_request ucr_request; 36645b48cbcSBrooks Davis }; 36745b48cbcSBrooks Davis #define USB_REQUEST32 _IOC_NEWTYPE(USB_REQUEST, struct usb_ctl_request32) 36845b48cbcSBrooks Davis #define USB_DO_REQUEST32 _IOC_NEWTYPE(USB_DO_REQUEST, struct usb_ctl_request32) 36945b48cbcSBrooks Davis 37045b48cbcSBrooks Davis struct usb_gen_descriptor32 { 37145b48cbcSBrooks Davis uint32_t ugd_data; /* void * */ 37245b48cbcSBrooks Davis uint16_t ugd_lang_id; 37345b48cbcSBrooks Davis uint16_t ugd_maxlen; 37445b48cbcSBrooks Davis uint16_t ugd_actlen; 37545b48cbcSBrooks Davis uint16_t ugd_offset; 37645b48cbcSBrooks Davis uint8_t ugd_config_index; 37745b48cbcSBrooks Davis uint8_t ugd_string_index; 37845b48cbcSBrooks Davis uint8_t ugd_iface_index; 37945b48cbcSBrooks Davis uint8_t ugd_altif_index; 38045b48cbcSBrooks Davis uint8_t ugd_endpt_index; 38145b48cbcSBrooks Davis uint8_t ugd_report_type; 38245b48cbcSBrooks Davis uint8_t reserved[8]; 38345b48cbcSBrooks Davis }; 38445b48cbcSBrooks Davis 38545b48cbcSBrooks Davis #define USB_GET_REPORT_DESC32 \ 38645b48cbcSBrooks Davis _IOC_NEWTYPE(USB_GET_REPORT_DESC, struct usb_gen_descriptor32) 38745b48cbcSBrooks Davis #define USB_GET_REPORT32 \ 38845b48cbcSBrooks Davis _IOC_NEWTYPE(USB_GET_REPORT, struct usb_gen_descriptor32) 38945b48cbcSBrooks Davis #define USB_SET_REPORT32 \ 39045b48cbcSBrooks Davis _IOC_NEWTYPE(USB_SET_REPORT, struct usb_gen_descriptor32) 39145b48cbcSBrooks Davis #define USB_GET_FULL_DESC32 \ 39245b48cbcSBrooks Davis _IOC_NEWTYPE(USB_GET_FULL_DESC, struct usb_gen_descriptor32) 39345b48cbcSBrooks Davis #define USB_GET_STRING_DESC32 \ 39445b48cbcSBrooks Davis _IOC_NEWTYPE(USB_GET_STRING_DESC, struct usb_gen_descriptor32) 39545b48cbcSBrooks Davis #define USB_GET_IFACE_DRIVER32 \ 39645b48cbcSBrooks Davis _IOC_NEWTYPE(USB_GET_IFACE_DRIVER, struct usb_gen_descriptor32) 39745b48cbcSBrooks Davis 39845b48cbcSBrooks Davis void usb_gen_descriptor_from32(struct usb_gen_descriptor *ugd, 39945b48cbcSBrooks Davis const struct usb_gen_descriptor32 *ugd32); 40045b48cbcSBrooks Davis void update_usb_gen_descriptor32(struct usb_gen_descriptor32 *ugd32, 40145b48cbcSBrooks Davis struct usb_gen_descriptor *ugd); 40245b48cbcSBrooks Davis 403*0ec590d2SBrooks Davis struct usb_fs_endpoint32 { 404*0ec590d2SBrooks Davis uint32_t ppBuffer; /* void ** */ 405*0ec590d2SBrooks Davis uint32_t pLength; /* uint32_t * */ 406*0ec590d2SBrooks Davis uint32_t nFrames; 407*0ec590d2SBrooks Davis uint32_t aFrames; 408*0ec590d2SBrooks Davis uint16_t flags; 409*0ec590d2SBrooks Davis uint16_t timeout; 410*0ec590d2SBrooks Davis uint16_t isoc_time_complete; 411*0ec590d2SBrooks Davis int status; 412*0ec590d2SBrooks Davis }; 413*0ec590d2SBrooks Davis 414*0ec590d2SBrooks Davis struct usb_fs_init32 { 415*0ec590d2SBrooks Davis uint32_t pEndpoints; /* struct usb_fs_endpoint32 * */ 416*0ec590d2SBrooks Davis uint8_t ep_index_max; 417*0ec590d2SBrooks Davis }; 418*0ec590d2SBrooks Davis 419*0ec590d2SBrooks Davis #define USB_FS_INIT32 _IOC_NEWTYPE(USB_FS_INIT, struct usb_fs_init32) 420*0ec590d2SBrooks Davis 42145b48cbcSBrooks Davis #endif /* COMPAT_FREEBSD32 */ 42245b48cbcSBrooks Davis #endif /* _KERNEL */ 42345b48cbcSBrooks Davis 42475973647SAndrew Thompson #endif /* _USB_IOCTL_H_ */ 425