1 /* $FreeBSD$ */ 2 /*- 3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 5 * Copyright (c) 2008 Hans Petter Selasky. 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 #include <sys/stdint.h> 30 #include <sys/stddef.h> 31 #include <sys/param.h> 32 #include <sys/queue.h> 33 #include <sys/types.h> 34 #include <sys/systm.h> 35 #include <sys/kernel.h> 36 #include <sys/bus.h> 37 #include <sys/module.h> 38 #include <sys/lock.h> 39 #include <sys/mutex.h> 40 #include <sys/condvar.h> 41 #include <sys/sysctl.h> 42 #include <sys/sx.h> 43 #include <sys/unistd.h> 44 #include <sys/callout.h> 45 #include <sys/malloc.h> 46 #include <sys/priv.h> 47 48 #include <dev/usb/usb.h> 49 #include <dev/usb/usb_ioctl.h> 50 #include <dev/usb/usbdi.h> 51 #include "usbdevs.h" 52 53 #define USB_DEBUG_VAR usb_debug 54 #include <dev/usb/usb_debug.h> 55 #include <dev/usb/usb_dynamic.h> 56 57 #include <dev/usb/quirk/usb_quirk.h> 58 59 MODULE_DEPEND(usb_quirk, usb, 1, 1, 1); 60 MODULE_VERSION(usb_quirk, 1); 61 62 #define USB_DEV_QUIRKS_MAX 256 63 #define USB_SUB_QUIRKS_MAX 8 64 65 struct usb_quirk_entry { 66 uint16_t vid; 67 uint16_t pid; 68 uint16_t lo_rev; 69 uint16_t hi_rev; 70 uint16_t quirks[USB_SUB_QUIRKS_MAX]; 71 }; 72 73 static struct mtx usb_quirk_mtx; 74 75 #define USB_QUIRK_VP(v,p,l,h,...) \ 76 { .vid = (v), .pid = (p), .lo_rev = (l), .hi_rev = (h), \ 77 .quirks = { __VA_ARGS__ } } 78 #define USB_QUIRK(v,p,l,h,...) \ 79 USB_QUIRK_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, l, h, __VA_ARGS__) 80 81 static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRKS_MAX] = { 82 USB_QUIRK(ASUS, LCM, 0x0000, 0xffff, UQ_HID_IGNORE), 83 USB_QUIRK(INSIDEOUT, EDGEPORT4, 0x094, 0x094, UQ_SWAP_UNICODE), 84 USB_QUIRK(DALLAS, J6502, 0x0a2, 0x0a2, UQ_BAD_ADC), 85 USB_QUIRK(DALLAS, J6502, 0x0a2, 0x0a2, UQ_AU_NO_XU), 86 USB_QUIRK(ALTEC, ADA70, 0x103, 0x103, UQ_BAD_ADC), 87 USB_QUIRK(ALTEC, ASC495, 0x000, 0x000, UQ_BAD_AUDIO), 88 USB_QUIRK(QTRONIX, 980N, 0x110, 0x110, UQ_SPUR_BUT_UP), 89 USB_QUIRK(ALCOR2, KBD_HUB, 0x001, 0x001, UQ_SPUR_BUT_UP), 90 USB_QUIRK(MCT, HUB0100, 0x102, 0x102, UQ_BUS_POWERED), 91 USB_QUIRK(MCT, USB232, 0x102, 0x102, UQ_BUS_POWERED), 92 USB_QUIRK(TI, UTUSB41, 0x110, 0x110, UQ_POWER_CLAIM), 93 USB_QUIRK(TELEX, MIC1, 0x009, 0x009, UQ_AU_NO_FRAC), 94 USB_QUIRK(SILICONPORTALS, YAPPHONE, 0x100, 0x100, UQ_AU_INP_ASYNC), 95 USB_QUIRK(LOGITECH, UN53B, 0x0000, 0xffff, UQ_NO_STRINGS), 96 USB_QUIRK(ELSA, MODEM1, 0x0000, 0xffff, UQ_CFG_INDEX_1), 97 /* Quirks for printer devices */ 98 USB_QUIRK(HP, 895C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 99 USB_QUIRK(HP, 880C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 100 USB_QUIRK(HP, 815C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 101 USB_QUIRK(HP, 810C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 102 USB_QUIRK(HP, 830C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 103 USB_QUIRK(HP, 1220C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 104 USB_QUIRK(XEROX, WCM15, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 105 /* Devices which should be ignored by uhid */ 106 USB_QUIRK(APC, UPS, 0x0000, 0xffff, UQ_HID_IGNORE), 107 USB_QUIRK(BELKIN, F6C550AVR, 0x0000, 0xffff, UQ_HID_IGNORE), 108 USB_QUIRK(CYBERPOWER, 1500CAVRLCD, 0x0000, 0xffff, UQ_HID_IGNORE), 109 USB_QUIRK(CYPRESS, SILVERSHIELD, 0x0000, 0xffff, UQ_HID_IGNORE), 110 USB_QUIRK(DELORME, EARTHMATE, 0x0000, 0xffff, UQ_HID_IGNORE), 111 USB_QUIRK(ITUNERNET, USBLCD2X20, 0x0000, 0xffff, UQ_HID_IGNORE), 112 USB_QUIRK(ITUNERNET, USBLCD4X20, 0x0000, 0xffff, UQ_HID_IGNORE), 113 USB_QUIRK(LIEBERT, POWERSURE_PXT, 0x0000, 0xffff, UQ_HID_IGNORE), 114 USB_QUIRK(MGE, UPS1, 0x0000, 0xffff, UQ_HID_IGNORE), 115 USB_QUIRK(MGE, UPS2, 0x0000, 0xffff, UQ_HID_IGNORE), 116 USB_QUIRK(APPLE, IPHONE, 0x0000, 0xffff, UQ_HID_IGNORE), 117 USB_QUIRK(APPLE, IPHONE_3G, 0x0000, 0xffff, UQ_HID_IGNORE), 118 USB_QUIRK(MEGATEC, UPS, 0x0000, 0xffff, UQ_HID_IGNORE), 119 /* Devices which should be ignored by both ukbd and uhid */ 120 USB_QUIRK(CYPRESS, WISPY1A, 0x0000, 0xffff, UQ_KBD_IGNORE, UQ_HID_IGNORE), 121 USB_QUIRK(METAGEEK, WISPY1B, 0x0000, 0xffff, UQ_KBD_IGNORE, UQ_HID_IGNORE), 122 USB_QUIRK(METAGEEK, WISPY24X, 0x0000, 0xffff, UQ_KBD_IGNORE, UQ_HID_IGNORE), 123 USB_QUIRK(METAGEEK2, WISPYDBX, 0x0000, 0xffff, UQ_KBD_IGNORE, UQ_HID_IGNORE), 124 USB_QUIRK(TENX, UAUDIO0, 0x0101, 0x0101, UQ_AUDIO_SWAP_LR), 125 /* MS keyboards do weird things */ 126 USB_QUIRK(MICROSOFT, WLINTELLIMOUSE, 0x0000, 0xffff, UQ_MS_LEADING_BYTE), 127 /* umodem(4) device quirks */ 128 USB_QUIRK(METRICOM, RICOCHET_GS, 0x100, 0x100, UQ_ASSUME_CM_OVER_DATA), 129 USB_QUIRK(SANYO, SCP4900, 0x000, 0x000, UQ_ASSUME_CM_OVER_DATA), 130 USB_QUIRK(MOTOROLA2, T720C, 0x001, 0x001, UQ_ASSUME_CM_OVER_DATA), 131 USB_QUIRK(EICON, DIVA852, 0x100, 0x100, UQ_ASSUME_CM_OVER_DATA), 132 USB_QUIRK(SIEMENS2, ES75, 0x000, 0x000, UQ_ASSUME_CM_OVER_DATA), 133 USB_QUIRK(QUALCOMM, CDMA_MSM, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 134 USB_QUIRK(QUALCOMM2, CDMA_MSM, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 135 USB_QUIRK(CURITEL, UM150, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 136 USB_QUIRK(CURITEL, UM175, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 137 138 /* USB Mass Storage Class Quirks */ 139 USB_QUIRK_VP(USB_VENDOR_ASAHIOPTICAL, 0, UQ_MSC_NO_RS_CLEAR_UA, 140 UQ_MATCH_VENDOR_ONLY), 141 USB_QUIRK(ADDON, ATTACHE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 142 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 143 USB_QUIRK(ADDON, A256MB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 144 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 145 USB_QUIRK(ADDON, DISKPRO512, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 146 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 147 USB_QUIRK(ADDONICS2, CABLE_205, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 148 UQ_MSC_FORCE_PROTO_SCSI), 149 USB_QUIRK(AIPTEK, POCKETCAM3M, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 150 UQ_MSC_FORCE_PROTO_SCSI), 151 USB_QUIRK(AIPTEK2, SUNPLUS_TECH, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 152 USB_QUIRK(ALCOR, SDCR_6335, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY, 153 UQ_MSC_NO_SYNC_CACHE), 154 USB_QUIRK(ALCOR, SDCR_6362, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY, 155 UQ_MSC_NO_SYNC_CACHE), 156 USB_QUIRK(ALCOR, AU6390, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 157 USB_QUIRK(ALCOR, UMCR_9361, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 158 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 159 USB_QUIRK(ALCOR, TRANSCEND, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 160 UQ_MSC_NO_SYNC_CACHE, UQ_MSC_NO_TEST_UNIT_READY), 161 USB_QUIRK(APACER, HT202, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY, 162 UQ_MSC_NO_SYNC_CACHE), 163 USB_QUIRK(ASAHIOPTICAL, OPTIO230, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 164 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 165 USB_QUIRK(ASAHIOPTICAL, OPTIO330, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 166 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 167 USB_QUIRK(BELKIN, USB2SCSI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 168 UQ_MSC_FORCE_PROTO_SCSI), 169 USB_QUIRK(CASIO, QV_DIGICAM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 170 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 171 USB_QUIRK(CCYU, ED1064, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 172 UQ_MSC_FORCE_PROTO_SCSI), 173 USB_QUIRK(CENTURY, EX35QUAT, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 174 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 175 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 176 USB_QUIRK(CENTURY, EX35SW4_SB4, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 177 USB_QUIRK(CYPRESS, XX6830XX, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 178 UQ_MSC_NO_SYNC_CACHE), 179 USB_QUIRK(DESKNOTE, UCR_61S2B, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 180 UQ_MSC_FORCE_PROTO_SCSI), 181 USB_QUIRK(DMI, CFSM_RW, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI, 182 UQ_MSC_NO_GETMAXLUN), 183 USB_QUIRK(DMI, DISK, 0x000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 184 USB_QUIRK(EPSON, STYLUS_875DC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 185 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 186 USB_QUIRK(EPSON, STYLUS_895, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 187 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 188 USB_QUIRK(FEIYA, 5IN1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 189 UQ_MSC_FORCE_PROTO_SCSI), 190 USB_QUIRK(FREECOM, DVD, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 191 USB_QUIRK(FREECOM, HDD, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 192 USB_QUIRK(FUJIPHOTO, MASS0100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 193 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_NO_SYNC_CACHE), 194 USB_QUIRK(GENESYS, GL641USB2IDE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 195 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 196 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE, UQ_MSC_NO_SYNC_CACHE), 197 USB_QUIRK(GENESYS, GL641USB2IDE_2, 0x0000, 0xffff, 198 UQ_MSC_FORCE_WIRE_BBB, UQ_MSC_FORCE_PROTO_ATAPI, 199 UQ_MSC_FORCE_SHORT_INQ, UQ_MSC_NO_START_STOP, 200 UQ_MSC_IGNORE_RESIDUE), 201 USB_QUIRK(GENESYS, GL641USB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 202 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 203 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 204 USB_QUIRK(GENESYS, GL641USB_2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 205 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_WRONG_CSWSIG), 206 USB_QUIRK(HAGIWARA, FG, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 207 UQ_MSC_FORCE_PROTO_SCSI), 208 USB_QUIRK(HAGIWARA, FGSM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 209 UQ_MSC_FORCE_PROTO_SCSI), 210 USB_QUIRK(HITACHI, DVDCAM_DZ_MV100A, 0x0000, 0xffff, 211 UQ_MSC_FORCE_WIRE_CBI, UQ_MSC_FORCE_PROTO_SCSI, 212 UQ_MSC_NO_GETMAXLUN), 213 USB_QUIRK(HITACHI, DVDCAM_USB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 214 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 215 USB_QUIRK(HP, CDW4E, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_ATAPI), 216 USB_QUIRK(HP, CDW8200, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 217 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_TEST_UNIT_READY, 218 UQ_MSC_NO_START_STOP), 219 USB_QUIRK(IMAGINATION, DBX1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 220 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_WRONG_CSWSIG), 221 USB_QUIRK(INSYSTEM, USBCABLE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 222 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_TEST_UNIT_READY, 223 UQ_MSC_NO_START_STOP, UQ_MSC_ALT_IFACE_1), 224 USB_QUIRK(INSYSTEM, ATAPI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 225 UQ_MSC_FORCE_PROTO_RBC), 226 USB_QUIRK(INSYSTEM, STORAGE_V2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 227 UQ_MSC_FORCE_PROTO_RBC), 228 USB_QUIRK(IODATA, IU_CD2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 229 UQ_MSC_FORCE_PROTO_SCSI), 230 USB_QUIRK(IODATA, DVR_UEH8, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 231 UQ_MSC_FORCE_PROTO_SCSI), 232 USB_QUIRK(IOMEGA, ZIP100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 233 UQ_MSC_FORCE_PROTO_SCSI, 234 UQ_MSC_NO_TEST_UNIT_READY), /* XXX ZIP drives can also use ATAPI */ 235 USB_QUIRK(JMICRON, JM20336, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 236 USB_QUIRK(JMICRON, JM20337, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 237 UQ_MSC_FORCE_PROTO_SCSI, 238 UQ_MSC_NO_SYNC_CACHE), 239 USB_QUIRK(KYOCERA, FINECAM_L3, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 240 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 241 USB_QUIRK(KYOCERA, FINECAM_S3X, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 242 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 243 USB_QUIRK(KYOCERA, FINECAM_S4, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 244 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 245 USB_QUIRK(KYOCERA, FINECAM_S5, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 246 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 247 USB_QUIRK(LACIE, HD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 248 UQ_MSC_FORCE_PROTO_RBC), 249 USB_QUIRK(LEXAR, CF_READER, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 250 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 251 USB_QUIRK(LEXAR, JUMPSHOT, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 252 USB_QUIRK(LOGITEC, LDR_H443SU2, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 253 USB_QUIRK(LOGITEC, LDR_H443U2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 254 UQ_MSC_FORCE_PROTO_SCSI,), 255 USB_QUIRK(MELCO, DUBPXXG, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 256 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 257 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 258 USB_QUIRK(MICROTECH, DPCM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 259 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_TEST_UNIT_READY, 260 UQ_MSC_NO_START_STOP), 261 USB_QUIRK(MICROTECH, SCSIDB25, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 262 UQ_MSC_FORCE_PROTO_SCSI), 263 USB_QUIRK(MICROTECH, SCSIHD50, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 264 UQ_MSC_FORCE_PROTO_SCSI), 265 USB_QUIRK(MINOLTA, E223, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 266 USB_QUIRK(MINOLTA, F300, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 267 UQ_MSC_FORCE_PROTO_SCSI), 268 USB_QUIRK(MITSUMI, CDRRW, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI | 269 UQ_MSC_FORCE_PROTO_ATAPI), 270 USB_QUIRK(MOTOROLA2, E398, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 271 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 272 UQ_MSC_NO_INQUIRY_EVPD, UQ_MSC_NO_GETMAXLUN), 273 USB_QUIRK_VP(USB_VENDOR_MPMAN, 0, UQ_MSC_NO_SYNC_CACHE, 274 UQ_MATCH_VENDOR_ONLY), 275 USB_QUIRK(MSYSTEMS, DISKONKEY, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 276 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE, UQ_MSC_NO_GETMAXLUN, 277 UQ_MSC_NO_RS_CLEAR_UA), 278 USB_QUIRK(MSYSTEMS, DISKONKEY2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 279 UQ_MSC_FORCE_PROTO_ATAPI), 280 USB_QUIRK(MYSON, HEDEN, 0x0000, 0xffff, UQ_MSC_IGNORE_RESIDUE, 281 UQ_MSC_NO_SYNC_CACHE), 282 USB_QUIRK(MYSON, HEDEN_8813, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 283 USB_QUIRK(MYSON, STARREADER, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 284 USB_QUIRK(NEODIO, ND3260, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 285 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ), 286 USB_QUIRK(NETAC, CF_CARD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 287 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 288 USB_QUIRK(NETAC, ONLYDISK, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 289 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 290 USB_QUIRK(NETCHIP, CLIK_40, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_ATAPI, 291 UQ_MSC_NO_INQUIRY), 292 USB_QUIRK(NIKON, D300, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 293 UQ_MSC_FORCE_PROTO_SCSI), 294 USB_QUIRK(OLYMPUS, C1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 295 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_WRONG_CSWSIG), 296 USB_QUIRK(OLYMPUS, C700, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN), 297 USB_QUIRK(ONSPEC, SDS_HOTFIND_D, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 298 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN, UQ_MSC_NO_SYNC_CACHE), 299 USB_QUIRK(ONSPEC, CFMS_RW, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 300 USB_QUIRK(ONSPEC, CFSM_COMBO, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 301 USB_QUIRK(ONSPEC, CFSM_READER, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 302 USB_QUIRK(ONSPEC, CFSM_READER2, 0x0000, 0xffff, 303 UQ_MSC_FORCE_PROTO_SCSI), 304 USB_QUIRK(ONSPEC, MDCFE_B_CF_READER, 0x0000, 0xffff, 305 UQ_MSC_FORCE_PROTO_SCSI), 306 USB_QUIRK(ONSPEC, MDSM_B_READER, 0x0000, 0xffff, 307 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 308 USB_QUIRK(ONSPEC, READER, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 309 USB_QUIRK(ONSPEC, UCF100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 310 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY | UQ_MSC_NO_GETMAXLUN), 311 USB_QUIRK(ONSPEC2, IMAGEMATE_SDDR55, 0x0000, 0xffff, 312 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 313 USB_QUIRK(PANASONIC, KXL840AN, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 314 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_GETMAXLUN), 315 USB_QUIRK(PANASONIC, KXLCB20AN, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 316 UQ_MSC_FORCE_PROTO_SCSI), 317 USB_QUIRK(PANASONIC, KXLCB35AN, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 318 UQ_MSC_FORCE_PROTO_SCSI), 319 USB_QUIRK(PANASONIC, LS120CAM, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_UFI), 320 USB_QUIRK(PHILIPS, SPE3030CC, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 321 USB_QUIRK(PLEXTOR, 40_12_40U, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 322 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_TEST_UNIT_READY), 323 USB_QUIRK(PNY, ATTACHE2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 324 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE, 325 UQ_MSC_NO_START_STOP), 326 USB_QUIRK(PROLIFIC, PL2506, 0x0000, 0xffff, 327 UQ_MSC_NO_SYNC_CACHE), 328 USB_QUIRK_VP(USB_VENDOR_SAMSUNG_TECHWIN, 329 USB_PRODUCT_SAMSUNG_TECHWIN_DIGIMAX_410, UQ_MSC_FORCE_WIRE_BBB, 330 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 331 USB_QUIRK(SAMSUNG, YP_U4, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 332 USB_QUIRK(SANDISK, SDDR05A, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 333 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1, 334 UQ_MSC_NO_GETMAXLUN), 335 USB_QUIRK(SANDISK, SDDR09, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI, 336 UQ_MSC_READ_CAP_OFFBY1, UQ_MSC_NO_GETMAXLUN), 337 USB_QUIRK(SANDISK, SDDR12, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 338 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1, 339 UQ_MSC_NO_GETMAXLUN), 340 USB_QUIRK(SANDISK, SDCZ2_256, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 341 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 342 USB_QUIRK(SANDISK, SDCZ4_128, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 343 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 344 USB_QUIRK(SANDISK, SDCZ4_256, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 345 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 346 USB_QUIRK(SANDISK, SDDR31, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 347 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1), 348 USB_QUIRK(SCANLOGIC, SL11R, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 349 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 350 USB_QUIRK(SHUTTLE, EUSB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 351 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_TEST_UNIT_READY, 352 UQ_MSC_NO_START_STOP, UQ_MSC_SHUTTLE_INIT), 353 USB_QUIRK(SHUTTLE, CDRW, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 354 UQ_MSC_FORCE_PROTO_ATAPI), 355 USB_QUIRK(SHUTTLE, CF, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 356 UQ_MSC_FORCE_PROTO_ATAPI), 357 USB_QUIRK(SHUTTLE, EUSBATAPI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 358 UQ_MSC_FORCE_PROTO_ATAPI), 359 USB_QUIRK(SHUTTLE, EUSBCFSM, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 360 USB_QUIRK(SHUTTLE, EUSCSI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 361 UQ_MSC_FORCE_PROTO_SCSI), 362 USB_QUIRK(SHUTTLE, HIFD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 363 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 364 USB_QUIRK(SHUTTLE, SDDR09, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI, 365 UQ_MSC_NO_GETMAXLUN), 366 USB_QUIRK(SHUTTLE, ZIOMMC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 367 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 368 USB_QUIRK(SIGMATEL, I_BEAD100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 369 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_SHUTTLE_INIT), 370 USB_QUIRK(SIIG, WINTERREADER, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 371 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 372 USB_QUIRK(SKANHEX, MD_7425, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 373 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 374 USB_QUIRK(SKANHEX, SX_520Z, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 375 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 376 USB_QUIRK(SONY, HANDYCAM, 0x0500, 0x0500, UQ_MSC_FORCE_WIRE_CBI, 377 UQ_MSC_FORCE_PROTO_RBC, UQ_MSC_RBC_PAD_TO_12), 378 USB_QUIRK(SONY, CLIE_40_MS, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 379 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 380 USB_QUIRK(SONY, DSC, 0x0500, 0x0500, UQ_MSC_FORCE_WIRE_CBI, 381 UQ_MSC_FORCE_PROTO_RBC, UQ_MSC_RBC_PAD_TO_12), 382 USB_QUIRK(SONY, DSC, 0x0600, 0x0600, UQ_MSC_FORCE_WIRE_CBI, 383 UQ_MSC_FORCE_PROTO_RBC, UQ_MSC_RBC_PAD_TO_12), 384 USB_QUIRK(SONY, DSC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 385 UQ_MSC_FORCE_PROTO_RBC), 386 USB_QUIRK(SONY, HANDYCAM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 387 UQ_MSC_FORCE_PROTO_RBC), 388 USB_QUIRK(SONY, MSC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 389 UQ_MSC_FORCE_PROTO_RBC), 390 USB_QUIRK(SONY, MS_MSC_U03, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 391 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_GETMAXLUN), 392 USB_QUIRK(SONY, MS_NW_MS7, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 393 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 394 USB_QUIRK(SONY, MS_PEG_N760C, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 395 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 396 USB_QUIRK(SONY, MSACUS1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 397 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 398 USB_QUIRK(SONY, PORTABLE_HDD_V2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 399 UQ_MSC_FORCE_PROTO_SCSI), 400 USB_QUIRK(SUPERTOP, IDE, 0x0000, 0xffff, UQ_MSC_IGNORE_RESIDUE, 401 UQ_MSC_NO_SYNC_CACHE), 402 USB_QUIRK(TAUGA, CAMERAMATE, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 403 USB_QUIRK(TEAC, FD05PUB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 404 UQ_MSC_FORCE_PROTO_UFI), 405 USB_QUIRK(TECLAST, TLC300, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY, 406 UQ_MSC_NO_SYNC_CACHE), 407 USB_QUIRK(TREK, MEMKEY, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 408 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 409 USB_QUIRK(TREK, THUMBDRIVE_8MB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 410 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_IGNORE_RESIDUE), 411 USB_QUIRK(TRUMPION, C3310, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 412 UQ_MSC_FORCE_PROTO_UFI), 413 USB_QUIRK(TRUMPION, MP3, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_RBC), 414 USB_QUIRK(TRUMPION, T33520, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 415 USB_QUIRK(TWINMOS, MDIV, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 416 UQ_MSC_FORCE_PROTO_SCSI), 417 USB_QUIRK(VIA, USB2IDEBRIDGE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 418 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_SYNC_CACHE), 419 USB_QUIRK(VIVITAR, 35XX, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 420 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 421 USB_QUIRK(WESTERN, COMBO, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 422 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 423 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 424 USB_QUIRK(WESTERN, EXTHDD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 425 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 426 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 427 USB_QUIRK(WESTERN, MYBOOK, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 428 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY_EVPD, 429 UQ_MSC_NO_SYNC_CACHE), 430 USB_QUIRK(WESTERN, MYPASSWORD, 0x0000, 0xffff, UQ_MSC_FORCE_SHORT_INQ), 431 USB_QUIRK(WINMAXGROUP, FLASH64MC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 432 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 433 USB_QUIRK(YANO, FW800HD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 434 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 435 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 436 USB_QUIRK(YANO, U640MO, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 437 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_FORCE_SHORT_INQ), 438 USB_QUIRK(YEDATA, FLASHBUSTERU, 0x0000, 0x007F, UQ_MSC_FORCE_WIRE_CBI, 439 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_FLOPPY_SPEED, 440 UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_GETMAXLUN), 441 USB_QUIRK(YEDATA, FLASHBUSTERU, 0x0080, 0x0080, UQ_MSC_FORCE_WIRE_CBI_I, 442 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_FLOPPY_SPEED, 443 UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_GETMAXLUN), 444 USB_QUIRK(YEDATA, FLASHBUSTERU, 0x0081, 0xFFFF, UQ_MSC_FORCE_WIRE_CBI_I, 445 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_FLOPPY_SPEED, 446 UQ_MSC_NO_GETMAXLUN), 447 USB_QUIRK(ZORAN, EX20DSC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 448 UQ_MSC_FORCE_PROTO_ATAPI), 449 USB_QUIRK(MEIZU, M6_SL, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 450 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY, UQ_MSC_NO_SYNC_CACHE), 451 USB_QUIRK(ACTIONS, MP4, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 452 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_SYNC_CACHE), 453 USB_QUIRK(ASUS, GMSC, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 454 USB_QUIRK(CHIPSBANK, USBMEMSTICK, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 455 USB_QUIRK(CHIPSBANK, USBMEMSTICK1, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 456 USB_QUIRK(NEWLINK, USB2IDEBRIDGE, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 457 458 /* Non-standard USB MIDI devices */ 459 USB_QUIRK(ROLAND, UM1, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 460 USB_QUIRK(ROLAND, SC8850, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 461 USB_QUIRK(ROLAND, SD90, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 462 USB_QUIRK(ROLAND, UM880N, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 463 USB_QUIRK(ROLAND, UA100, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 464 USB_QUIRK(ROLAND, UM4, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 465 USB_QUIRK(ROLAND, U8, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 466 USB_QUIRK(ROLAND, UM2, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 467 USB_QUIRK(ROLAND, SC8820, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 468 USB_QUIRK(ROLAND, PC300, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 469 USB_QUIRK(ROLAND, SK500, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 470 USB_QUIRK(ROLAND, SCD70, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 471 USB_QUIRK(ROLAND, UM550, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 472 USB_QUIRK(ROLAND, SD20, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 473 USB_QUIRK(ROLAND, SD80, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 474 USB_QUIRK(ROLAND, UA700, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 475 }; 476 #undef USB_QUIRK_VP 477 #undef USB_QUIRK 478 479 static const char *usb_quirk_str[USB_QUIRK_MAX] = { 480 [UQ_NONE] = "UQ_NONE", 481 [UQ_MATCH_VENDOR_ONLY] = "UQ_MATCH_VENDOR_ONLY", 482 [UQ_AUDIO_SWAP_LR] = "UQ_AUDIO_SWAP_LR", 483 [UQ_AU_INP_ASYNC] = "UQ_AU_INP_ASYNC", 484 [UQ_AU_NO_FRAC] = "UQ_AU_NO_FRAC", 485 [UQ_AU_NO_XU] = "UQ_AU_NO_XU", 486 [UQ_BAD_ADC] = "UQ_BAD_ADC", 487 [UQ_BAD_AUDIO] = "UQ_BAD_AUDIO", 488 [UQ_BROKEN_BIDIR] = "UQ_BROKEN_BIDIR", 489 [UQ_BUS_POWERED] = "UQ_BUS_POWERED", 490 [UQ_HID_IGNORE] = "UQ_HID_IGNORE", 491 [UQ_KBD_IGNORE] = "UQ_KBD_IGNORE", 492 [UQ_KBD_BOOTPROTO] = "UQ_KBD_BOOTPROTO", 493 [UQ_MS_BAD_CLASS] = "UQ_MS_BAD_CLASS", 494 [UQ_MS_LEADING_BYTE] = "UQ_MS_LEADING_BYTE", 495 [UQ_MS_REVZ] = "UQ_MS_REVZ", 496 [UQ_NO_STRINGS] = "UQ_NO_STRINGS", 497 [UQ_OPEN_CLEARSTALL] = "UQ_OPEN_CLEARSTALL", 498 [UQ_POWER_CLAIM] = "UQ_POWER_CLAIM", 499 [UQ_SPUR_BUT_UP] = "UQ_SPUR_BUT_UP", 500 [UQ_SWAP_UNICODE] = "UQ_SWAP_UNICODE", 501 [UQ_CFG_INDEX_1] = "UQ_CFG_INDEX_1", 502 [UQ_CFG_INDEX_2] = "UQ_CFG_INDEX_2", 503 [UQ_CFG_INDEX_3] = "UQ_CFG_INDEX_3", 504 [UQ_CFG_INDEX_4] = "UQ_CFG_INDEX_4", 505 [UQ_CFG_INDEX_0] = "UQ_CFG_INDEX_0", 506 [UQ_ASSUME_CM_OVER_DATA] = "UQ_ASSUME_CM_OVER_DATA", 507 [UQ_MSC_NO_TEST_UNIT_READY] = "UQ_MSC_NO_TEST_UNIT_READY", 508 [UQ_MSC_NO_RS_CLEAR_UA] = "UQ_MSC_NO_RS_CLEAR_UA", 509 [UQ_MSC_NO_START_STOP] = "UQ_MSC_NO_START_STOP", 510 [UQ_MSC_NO_GETMAXLUN] = "UQ_MSC_NO_GETMAXLUN", 511 [UQ_MSC_NO_INQUIRY] = "UQ_MSC_NO_INQUIRY", 512 [UQ_MSC_NO_INQUIRY_EVPD] = "UQ_MSC_NO_INQUIRY_EVPD", 513 [UQ_MSC_NO_SYNC_CACHE] = "UQ_MSC_NO_SYNC_CACHE", 514 [UQ_MSC_SHUTTLE_INIT] = "UQ_MSC_SHUTTLE_INIT", 515 [UQ_MSC_ALT_IFACE_1] = "UQ_MSC_ALT_IFACE_1", 516 [UQ_MSC_FLOPPY_SPEED] = "UQ_MSC_FLOPPY_SPEED", 517 [UQ_MSC_IGNORE_RESIDUE] = "UQ_MSC_IGNORE_RESIDUE", 518 [UQ_MSC_WRONG_CSWSIG] = "UQ_MSC_WRONG_CSWSIG", 519 [UQ_MSC_RBC_PAD_TO_12] = "UQ_MSC_RBC_PAD_TO_12", 520 [UQ_MSC_READ_CAP_OFFBY1] = "UQ_MSC_READ_CAP_OFFBY1", 521 [UQ_MSC_FORCE_SHORT_INQ] = "UQ_MSC_FORCE_SHORT_INQ", 522 [UQ_MSC_FORCE_WIRE_BBB] = "UQ_MSC_FORCE_WIRE_BBB", 523 [UQ_MSC_FORCE_WIRE_CBI] = "UQ_MSC_FORCE_WIRE_CBI", 524 [UQ_MSC_FORCE_WIRE_CBI_I] = "UQ_MSC_FORCE_WIRE_CBI_I", 525 [UQ_MSC_FORCE_PROTO_SCSI] = "UQ_MSC_FORCE_PROTO_SCSI", 526 [UQ_MSC_FORCE_PROTO_ATAPI] = "UQ_MSC_FORCE_PROTO_ATAPI", 527 [UQ_MSC_FORCE_PROTO_UFI] = "UQ_MSC_FORCE_PROTO_UFI", 528 [UQ_MSC_FORCE_PROTO_RBC] = "UQ_MSC_FORCE_PROTO_RBC", 529 [UQ_MSC_EJECT_HUAWEI] = "UQ_MSC_EJECT_HUAWEI", 530 [UQ_MSC_EJECT_SIERRA] = "UQ_MSC_EJECT_SIERRA", 531 [UQ_MSC_EJECT_SCSIEJECT] = "UQ_MSC_EJECT_SCSIEJECT", 532 [UQ_MSC_EJECT_REZERO] = "UQ_MSC_EJECT_REZERO", 533 [UQ_MSC_EJECT_ZTESTOR] = "UQ_MSC_EJECT_ZTESTOR", 534 [UQ_MSC_EJECT_CMOTECH] = "UQ_MSC_EJECT_CMOTECH", 535 [UQ_MSC_EJECT_WAIT] = "UQ_MSC_EJECT_WAIT", 536 [UQ_MSC_EJECT_SAEL_M460] = "UQ_MSC_EJECT_SAEL_M460", 537 [UQ_MSC_EJECT_HUAWEISCSI] = "UQ_MSC_EJECT_HUAWEISCSI", 538 [UQ_MSC_EJECT_TCT] = "UQ_MSC_EJECT_TCT", 539 [UQ_BAD_MIDI] = "UQ_BAD_MIDI", 540 [UQ_AU_VENDOR_CLASS] = "UQ_AU_VENDOR_CLASS", 541 }; 542 543 /*------------------------------------------------------------------------* 544 * usb_quirkstr 545 * 546 * This function converts an USB quirk code into a string. 547 *------------------------------------------------------------------------*/ 548 static const char * 549 usb_quirkstr(uint16_t quirk) 550 { 551 return ((quirk < USB_QUIRK_MAX) ? 552 usb_quirk_str[quirk] : "USB_QUIRK_UNKNOWN"); 553 } 554 555 /*------------------------------------------------------------------------* 556 * usb_test_quirk_by_info 557 * 558 * Returns: 559 * 0: Quirk not found 560 * Else: Quirk found 561 *------------------------------------------------------------------------*/ 562 static uint8_t 563 usb_test_quirk_by_info(const struct usbd_lookup_info *info, uint16_t quirk) 564 { 565 uint16_t x; 566 uint16_t y; 567 568 if (quirk == UQ_NONE) { 569 return (0); 570 } 571 mtx_lock(&usb_quirk_mtx); 572 573 for (x = 0; x != USB_DEV_QUIRKS_MAX; x++) { 574 /* see if quirk information does not match */ 575 if ((usb_quirks[x].vid != info->idVendor) || 576 (usb_quirks[x].lo_rev > info->bcdDevice) || 577 (usb_quirks[x].hi_rev < info->bcdDevice)) { 578 continue; 579 } 580 /* see if quirk only should match vendor ID */ 581 if (usb_quirks[x].pid != info->idProduct) { 582 if (usb_quirks[x].pid != 0) 583 continue; 584 585 for (y = 0; y != USB_SUB_QUIRKS_MAX; y++) { 586 if (usb_quirks[x].quirks[y] == UQ_MATCH_VENDOR_ONLY) 587 break; 588 } 589 if (y == USB_SUB_QUIRKS_MAX) 590 continue; 591 } 592 /* lookup quirk */ 593 for (y = 0; y != USB_SUB_QUIRKS_MAX; y++) { 594 if (usb_quirks[x].quirks[y] == quirk) { 595 mtx_unlock(&usb_quirk_mtx); 596 DPRINTF("Found quirk '%s'.\n", usb_quirkstr(quirk)); 597 return (1); 598 } 599 } 600 /* no quirk found */ 601 break; 602 } 603 mtx_unlock(&usb_quirk_mtx); 604 return (0); 605 } 606 607 static struct usb_quirk_entry * 608 usb_quirk_get_entry(uint16_t vid, uint16_t pid, 609 uint16_t lo_rev, uint16_t hi_rev, uint8_t do_alloc) 610 { 611 uint16_t x; 612 613 mtx_assert(&usb_quirk_mtx, MA_OWNED); 614 615 if ((vid | pid | lo_rev | hi_rev) == 0) { 616 /* all zero - special case */ 617 return (usb_quirks + USB_DEV_QUIRKS_MAX - 1); 618 } 619 /* search for an existing entry */ 620 for (x = 0; x != USB_DEV_QUIRKS_MAX; x++) { 621 /* see if quirk information does not match */ 622 if ((usb_quirks[x].vid != vid) || 623 (usb_quirks[x].pid != pid) || 624 (usb_quirks[x].lo_rev != lo_rev) || 625 (usb_quirks[x].hi_rev != hi_rev)) { 626 continue; 627 } 628 return (usb_quirks + x); 629 } 630 631 if (do_alloc == 0) { 632 /* no match */ 633 return (NULL); 634 } 635 /* search for a free entry */ 636 for (x = 0; x != USB_DEV_QUIRKS_MAX; x++) { 637 /* see if quirk information does not match */ 638 if ((usb_quirks[x].vid | 639 usb_quirks[x].pid | 640 usb_quirks[x].lo_rev | 641 usb_quirks[x].hi_rev) != 0) { 642 continue; 643 } 644 usb_quirks[x].vid = vid; 645 usb_quirks[x].pid = pid; 646 usb_quirks[x].lo_rev = lo_rev; 647 usb_quirks[x].hi_rev = hi_rev; 648 649 return (usb_quirks + x); 650 } 651 652 /* no entry found */ 653 return (NULL); 654 } 655 656 /*------------------------------------------------------------------------* 657 * usb_quirk_ioctl - handle quirk IOCTLs 658 * 659 * Returns: 660 * 0: Success 661 * Else: Failure 662 *------------------------------------------------------------------------*/ 663 static int 664 usb_quirk_ioctl(unsigned long cmd, caddr_t data, 665 int fflag, struct thread *td) 666 { 667 struct usb_gen_quirk *pgq; 668 struct usb_quirk_entry *pqe; 669 uint32_t x; 670 uint32_t y; 671 int err; 672 673 switch (cmd) { 674 case USB_DEV_QUIRK_GET: 675 pgq = (void *)data; 676 x = pgq->index % USB_SUB_QUIRKS_MAX; 677 y = pgq->index / USB_SUB_QUIRKS_MAX; 678 if (y >= USB_DEV_QUIRKS_MAX) { 679 return (EINVAL); 680 } 681 mtx_lock(&usb_quirk_mtx); 682 /* copy out data */ 683 pgq->vid = usb_quirks[y].vid; 684 pgq->pid = usb_quirks[y].pid; 685 pgq->bcdDeviceLow = usb_quirks[y].lo_rev; 686 pgq->bcdDeviceHigh = usb_quirks[y].hi_rev; 687 strlcpy(pgq->quirkname, 688 usb_quirkstr(usb_quirks[y].quirks[x]), 689 sizeof(pgq->quirkname)); 690 mtx_unlock(&usb_quirk_mtx); 691 return (0); /* success */ 692 693 case USB_QUIRK_NAME_GET: 694 pgq = (void *)data; 695 x = pgq->index; 696 if (x >= USB_QUIRK_MAX) { 697 return (EINVAL); 698 } 699 strlcpy(pgq->quirkname, 700 usb_quirkstr(x), sizeof(pgq->quirkname)); 701 return (0); /* success */ 702 703 case USB_DEV_QUIRK_ADD: 704 pgq = (void *)data; 705 706 /* check privileges */ 707 err = priv_check(curthread, PRIV_DRIVER); 708 if (err) { 709 return (err); 710 } 711 /* convert quirk string into numerical */ 712 for (y = 0; y != USB_DEV_QUIRKS_MAX; y++) { 713 if (strcmp(pgq->quirkname, usb_quirkstr(y)) == 0) { 714 break; 715 } 716 } 717 if (y == USB_DEV_QUIRKS_MAX) { 718 return (EINVAL); 719 } 720 if (y == UQ_NONE) { 721 return (EINVAL); 722 } 723 mtx_lock(&usb_quirk_mtx); 724 pqe = usb_quirk_get_entry(pgq->vid, pgq->pid, 725 pgq->bcdDeviceLow, pgq->bcdDeviceHigh, 1); 726 if (pqe == NULL) { 727 mtx_unlock(&usb_quirk_mtx); 728 return (EINVAL); 729 } 730 for (x = 0; x != USB_SUB_QUIRKS_MAX; x++) { 731 if (pqe->quirks[x] == UQ_NONE) { 732 pqe->quirks[x] = y; 733 break; 734 } 735 } 736 mtx_unlock(&usb_quirk_mtx); 737 if (x == USB_SUB_QUIRKS_MAX) { 738 return (ENOMEM); 739 } 740 return (0); /* success */ 741 742 case USB_DEV_QUIRK_REMOVE: 743 pgq = (void *)data; 744 /* check privileges */ 745 err = priv_check(curthread, PRIV_DRIVER); 746 if (err) { 747 return (err); 748 } 749 /* convert quirk string into numerical */ 750 for (y = 0; y != USB_DEV_QUIRKS_MAX; y++) { 751 if (strcmp(pgq->quirkname, usb_quirkstr(y)) == 0) { 752 break; 753 } 754 } 755 if (y == USB_DEV_QUIRKS_MAX) { 756 return (EINVAL); 757 } 758 if (y == UQ_NONE) { 759 return (EINVAL); 760 } 761 mtx_lock(&usb_quirk_mtx); 762 pqe = usb_quirk_get_entry(pgq->vid, pgq->pid, 763 pgq->bcdDeviceLow, pgq->bcdDeviceHigh, 0); 764 if (pqe == NULL) { 765 mtx_unlock(&usb_quirk_mtx); 766 return (EINVAL); 767 } 768 for (x = 0; x != USB_SUB_QUIRKS_MAX; x++) { 769 if (pqe->quirks[x] == y) { 770 pqe->quirks[x] = UQ_NONE; 771 break; 772 } 773 } 774 if (x == USB_SUB_QUIRKS_MAX) { 775 mtx_unlock(&usb_quirk_mtx); 776 return (ENOMEM); 777 } 778 for (x = 0; x != USB_SUB_QUIRKS_MAX; x++) { 779 if (pqe->quirks[x] != UQ_NONE) { 780 break; 781 } 782 } 783 if (x == USB_SUB_QUIRKS_MAX) { 784 /* all quirk entries are unused - release */ 785 memset(pqe, 0, sizeof(pqe)); 786 } 787 mtx_unlock(&usb_quirk_mtx); 788 return (0); /* success */ 789 790 default: 791 break; 792 } 793 return (ENOIOCTL); 794 } 795 796 static void 797 usb_quirk_init(void *arg) 798 { 799 /* initialize mutex */ 800 mtx_init(&usb_quirk_mtx, "USB quirk", NULL, MTX_DEF); 801 802 /* register our function */ 803 usb_test_quirk_p = &usb_test_quirk_by_info; 804 usb_quirk_ioctl_p = &usb_quirk_ioctl; 805 } 806 807 static void 808 usb_quirk_uninit(void *arg) 809 { 810 usb_quirk_unload(arg); 811 812 /* destroy mutex */ 813 mtx_destroy(&usb_quirk_mtx); 814 } 815 816 SYSINIT(usb_quirk_init, SI_SUB_LOCK, SI_ORDER_FIRST, usb_quirk_init, NULL); 817 SYSUNINIT(usb_quirk_uninit, SI_SUB_LOCK, SI_ORDER_ANY, usb_quirk_uninit, NULL); 818