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, NATURAL4000, 0x0000, 0xFFFF, UQ_KBD_BOOTPROTO), 127 USB_QUIRK(MICROSOFT, WLINTELLIMOUSE, 0x0000, 0xffff, UQ_MS_LEADING_BYTE), 128 /* Quirk for Corsair Vengeance K60 keyboard */ 129 USB_QUIRK(CORSAIR, K60, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), 130 /* umodem(4) device quirks */ 131 USB_QUIRK(METRICOM, RICOCHET_GS, 0x100, 0x100, UQ_ASSUME_CM_OVER_DATA), 132 USB_QUIRK(SANYO, SCP4900, 0x000, 0x000, UQ_ASSUME_CM_OVER_DATA), 133 USB_QUIRK(MOTOROLA2, T720C, 0x001, 0x001, UQ_ASSUME_CM_OVER_DATA), 134 USB_QUIRK(EICON, DIVA852, 0x100, 0x100, UQ_ASSUME_CM_OVER_DATA), 135 USB_QUIRK(SIEMENS2, ES75, 0x000, 0x000, UQ_ASSUME_CM_OVER_DATA), 136 USB_QUIRK(QUALCOMM, CDMA_MSM, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 137 USB_QUIRK(QUALCOMM2, CDMA_MSM, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 138 USB_QUIRK(CURITEL, UM150, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 139 USB_QUIRK(CURITEL, UM175, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 140 USB_QUIRK(VERTEX, VW110L, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 141 142 /* USB Mass Storage Class Quirks */ 143 USB_QUIRK_VP(USB_VENDOR_ASAHIOPTICAL, 0, UQ_MSC_NO_RS_CLEAR_UA, 144 UQ_MATCH_VENDOR_ONLY), 145 USB_QUIRK(ADDON, ATTACHE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 146 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 147 USB_QUIRK(ADDON, A256MB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 148 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 149 USB_QUIRK(ADDON, DISKPRO512, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 150 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 151 USB_QUIRK(ADDONICS2, CABLE_205, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 152 UQ_MSC_FORCE_PROTO_SCSI), 153 USB_QUIRK(AIPTEK, POCKETCAM3M, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 154 UQ_MSC_FORCE_PROTO_SCSI), 155 USB_QUIRK(ALCOR, UMCR_9361, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 156 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 157 USB_QUIRK(ALCOR, TRANSCEND, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 158 UQ_MSC_NO_SYNC_CACHE, UQ_MSC_NO_TEST_UNIT_READY), 159 USB_QUIRK(APACER, HT202, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY, 160 UQ_MSC_NO_SYNC_CACHE), 161 USB_QUIRK(ASAHIOPTICAL, OPTIO230, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 162 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 163 USB_QUIRK(ASAHIOPTICAL, OPTIO330, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 164 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 165 USB_QUIRK(BELKIN, USB2SCSI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 166 UQ_MSC_FORCE_PROTO_SCSI), 167 USB_QUIRK(CASIO, QV_DIGICAM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 168 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 169 USB_QUIRK(CCYU, ED1064, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 170 UQ_MSC_FORCE_PROTO_SCSI), 171 USB_QUIRK(CENTURY, EX35QUAT, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 172 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 173 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 174 USB_QUIRK(CYPRESS, XX6830XX, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 175 UQ_MSC_NO_SYNC_CACHE), 176 USB_QUIRK(DESKNOTE, UCR_61S2B, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 177 UQ_MSC_FORCE_PROTO_SCSI), 178 USB_QUIRK(DMI, CFSM_RW, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI, 179 UQ_MSC_NO_GETMAXLUN), 180 USB_QUIRK(EMTEC, RUF2PS, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 181 USB_QUIRK(EPSON, STYLUS_875DC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 182 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 183 USB_QUIRK(EPSON, STYLUS_895, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 184 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 185 USB_QUIRK(FEIYA, 5IN1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 186 UQ_MSC_FORCE_PROTO_SCSI), 187 USB_QUIRK(FEIYA, ELANGO, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 188 USB_QUIRK(FREECOM, DVD, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 189 USB_QUIRK(FUJIPHOTO, MASS0100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 190 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_NO_SYNC_CACHE), 191 USB_QUIRK(GENESYS, GL641USB2IDE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 192 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 193 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE, UQ_MSC_NO_SYNC_CACHE), 194 USB_QUIRK(GENESYS, GL641USB2IDE_2, 0x0000, 0xffff, 195 UQ_MSC_FORCE_WIRE_BBB, UQ_MSC_FORCE_PROTO_ATAPI, 196 UQ_MSC_FORCE_SHORT_INQ, UQ_MSC_NO_START_STOP, 197 UQ_MSC_IGNORE_RESIDUE), 198 USB_QUIRK(GENESYS, GL641USB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 199 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 200 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 201 USB_QUIRK(GENESYS, GL641USB_2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 202 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_WRONG_CSWSIG), 203 USB_QUIRK(HAGIWARA, FG, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 204 UQ_MSC_FORCE_PROTO_SCSI), 205 USB_QUIRK(HAGIWARA, FGSM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 206 UQ_MSC_FORCE_PROTO_SCSI), 207 USB_QUIRK(HITACHI, DVDCAM_DZ_MV100A, 0x0000, 0xffff, 208 UQ_MSC_FORCE_WIRE_CBI, UQ_MSC_FORCE_PROTO_SCSI, 209 UQ_MSC_NO_GETMAXLUN), 210 USB_QUIRK(HITACHI, DVDCAM_USB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 211 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 212 USB_QUIRK(HP, CDW4E, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_ATAPI), 213 USB_QUIRK(HP, CDW8200, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 214 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_TEST_UNIT_READY, 215 UQ_MSC_NO_START_STOP), 216 USB_QUIRK(IMAGINATION, DBX1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 217 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_WRONG_CSWSIG), 218 USB_QUIRK(INSYSTEM, USBCABLE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 219 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_TEST_UNIT_READY, 220 UQ_MSC_NO_START_STOP, UQ_MSC_ALT_IFACE_1), 221 USB_QUIRK(INSYSTEM, ATAPI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 222 UQ_MSC_FORCE_PROTO_RBC), 223 USB_QUIRK(INSYSTEM, STORAGE_V2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 224 UQ_MSC_FORCE_PROTO_RBC), 225 USB_QUIRK(IODATA, IU_CD2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 226 UQ_MSC_FORCE_PROTO_SCSI), 227 USB_QUIRK(IODATA, DVR_UEH8, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 228 UQ_MSC_FORCE_PROTO_SCSI), 229 USB_QUIRK(IOMEGA, ZIP100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 230 UQ_MSC_FORCE_PROTO_SCSI, 231 UQ_MSC_NO_TEST_UNIT_READY), /* XXX ZIP drives can also use ATAPI */ 232 USB_QUIRK(JMICRON, JM20337, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 233 UQ_MSC_FORCE_PROTO_SCSI, 234 UQ_MSC_NO_SYNC_CACHE), 235 USB_QUIRK(KYOCERA, FINECAM_L3, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 236 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 237 USB_QUIRK(KYOCERA, FINECAM_S3X, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 238 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 239 USB_QUIRK(KYOCERA, FINECAM_S4, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 240 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 241 USB_QUIRK(KYOCERA, FINECAM_S5, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 242 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 243 USB_QUIRK(LACIE, HD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 244 UQ_MSC_FORCE_PROTO_RBC), 245 USB_QUIRK(LEXAR, CF_READER, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 246 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 247 USB_QUIRK(LEXAR, JUMPSHOT, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 248 USB_QUIRK(LOGITEC, LDR_H443SU2, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 249 USB_QUIRK(LOGITEC, LDR_H443U2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 250 UQ_MSC_FORCE_PROTO_SCSI,), 251 USB_QUIRK(MELCO, DUBPXXG, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 252 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 253 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 254 USB_QUIRK(MICROTECH, DPCM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 255 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_TEST_UNIT_READY, 256 UQ_MSC_NO_START_STOP), 257 USB_QUIRK(MICRON, REALSSD, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 258 USB_QUIRK(MICROTECH, SCSIDB25, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 259 UQ_MSC_FORCE_PROTO_SCSI), 260 USB_QUIRK(MICROTECH, SCSIHD50, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 261 UQ_MSC_FORCE_PROTO_SCSI), 262 USB_QUIRK(MINOLTA, E223, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 263 USB_QUIRK(MINOLTA, F300, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 264 UQ_MSC_FORCE_PROTO_SCSI), 265 USB_QUIRK(MITSUMI, CDRRW, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI | 266 UQ_MSC_FORCE_PROTO_ATAPI), 267 USB_QUIRK(MOTOROLA2, E398, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 268 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 269 UQ_MSC_NO_INQUIRY_EVPD, UQ_MSC_NO_GETMAXLUN), 270 USB_QUIRK_VP(USB_VENDOR_MPMAN, 0, UQ_MSC_NO_SYNC_CACHE, 271 UQ_MATCH_VENDOR_ONLY), 272 USB_QUIRK(MSYSTEMS, DISKONKEY, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 273 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE, UQ_MSC_NO_GETMAXLUN, 274 UQ_MSC_NO_RS_CLEAR_UA), 275 USB_QUIRK(MSYSTEMS, DISKONKEY2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 276 UQ_MSC_FORCE_PROTO_ATAPI), 277 USB_QUIRK(MYSON, HEDEN, 0x0000, 0xffff, UQ_MSC_IGNORE_RESIDUE, 278 UQ_MSC_NO_SYNC_CACHE), 279 USB_QUIRK(NEODIO, ND3260, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 280 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ), 281 USB_QUIRK(NETAC, CF_CARD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 282 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 283 USB_QUIRK(NETAC, ONLYDISK, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 284 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 285 USB_QUIRK(NETCHIP, CLIK_40, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_ATAPI, 286 UQ_MSC_NO_INQUIRY), 287 USB_QUIRK(NIKON, D300, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 288 UQ_MSC_FORCE_PROTO_SCSI), 289 USB_QUIRK(OLYMPUS, C1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 290 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_WRONG_CSWSIG), 291 USB_QUIRK(OLYMPUS, C700, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN), 292 USB_QUIRK(ONSPEC, SDS_HOTFIND_D, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 293 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN, UQ_MSC_NO_SYNC_CACHE), 294 USB_QUIRK(ONSPEC, CFMS_RW, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 295 USB_QUIRK(ONSPEC, CFSM_COMBO, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 296 USB_QUIRK(ONSPEC, CFSM_READER, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 297 USB_QUIRK(ONSPEC, CFSM_READER2, 0x0000, 0xffff, 298 UQ_MSC_FORCE_PROTO_SCSI), 299 USB_QUIRK(ONSPEC, MDCFE_B_CF_READER, 0x0000, 0xffff, 300 UQ_MSC_FORCE_PROTO_SCSI), 301 USB_QUIRK(ONSPEC, MDSM_B_READER, 0x0000, 0xffff, 302 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 303 USB_QUIRK(ONSPEC, READER, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 304 USB_QUIRK(ONSPEC, UCF100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 305 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY | UQ_MSC_NO_GETMAXLUN), 306 USB_QUIRK(ONSPEC2, IMAGEMATE_SDDR55, 0x0000, 0xffff, 307 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 308 USB_QUIRK(PANASONIC, KXL840AN, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 309 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_GETMAXLUN), 310 USB_QUIRK(PANASONIC, KXLCB20AN, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 311 UQ_MSC_FORCE_PROTO_SCSI), 312 USB_QUIRK(PANASONIC, KXLCB35AN, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 313 UQ_MSC_FORCE_PROTO_SCSI), 314 USB_QUIRK(PANASONIC, LS120CAM, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_UFI), 315 USB_QUIRK(PLEXTOR, 40_12_40U, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 316 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_TEST_UNIT_READY), 317 USB_QUIRK(PNY, ATTACHE2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 318 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE, 319 UQ_MSC_NO_START_STOP), 320 USB_QUIRK(PROLIFIC, PL2506, 0x0000, 0xffff, 321 UQ_MSC_NO_SYNC_CACHE), 322 USB_QUIRK_VP(USB_VENDOR_SAMSUNG_TECHWIN, 323 USB_PRODUCT_SAMSUNG_TECHWIN_DIGIMAX_410, UQ_MSC_FORCE_WIRE_BBB, 324 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 325 USB_QUIRK(SANDISK, SDDR05A, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 326 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1, 327 UQ_MSC_NO_GETMAXLUN), 328 USB_QUIRK(SANDISK, SDDR09, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI, 329 UQ_MSC_READ_CAP_OFFBY1, UQ_MSC_NO_GETMAXLUN), 330 USB_QUIRK(SANDISK, SDDR12, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 331 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1, 332 UQ_MSC_NO_GETMAXLUN), 333 USB_QUIRK(SANDISK, SDCZ2_256, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 334 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 335 USB_QUIRK(SANDISK, SDCZ4_128, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 336 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 337 USB_QUIRK(SANDISK, SDCZ4_256, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 338 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 339 USB_QUIRK(SANDISK, SDDR31, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 340 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1), 341 USB_QUIRK(SCANLOGIC, SL11R, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 342 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 343 USB_QUIRK(SHUTTLE, EUSB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 344 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_TEST_UNIT_READY, 345 UQ_MSC_NO_START_STOP, UQ_MSC_SHUTTLE_INIT), 346 USB_QUIRK(SHUTTLE, CDRW, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 347 UQ_MSC_FORCE_PROTO_ATAPI), 348 USB_QUIRK(SHUTTLE, CF, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 349 UQ_MSC_FORCE_PROTO_ATAPI), 350 USB_QUIRK(SHUTTLE, EUSBATAPI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 351 UQ_MSC_FORCE_PROTO_ATAPI), 352 USB_QUIRK(SHUTTLE, EUSBCFSM, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 353 USB_QUIRK(SHUTTLE, EUSCSI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 354 UQ_MSC_FORCE_PROTO_SCSI), 355 USB_QUIRK(SHUTTLE, HIFD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 356 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 357 USB_QUIRK(SHUTTLE, SDDR09, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI, 358 UQ_MSC_NO_GETMAXLUN), 359 USB_QUIRK(SHUTTLE, ZIOMMC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 360 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 361 USB_QUIRK(SIGMATEL, I_BEAD100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 362 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_SHUTTLE_INIT), 363 USB_QUIRK(SIIG, WINTERREADER, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 364 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 365 USB_QUIRK(SKANHEX, MD_7425, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 366 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 367 USB_QUIRK(SKANHEX, SX_520Z, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 368 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 369 USB_QUIRK(SONY, HANDYCAM, 0x0500, 0x0500, UQ_MSC_FORCE_WIRE_CBI, 370 UQ_MSC_FORCE_PROTO_RBC, UQ_MSC_RBC_PAD_TO_12), 371 USB_QUIRK(SONY, CLIE_40_MS, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 372 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 373 USB_QUIRK(SONY, DSC, 0x0500, 0x0500, UQ_MSC_FORCE_WIRE_CBI, 374 UQ_MSC_FORCE_PROTO_RBC, UQ_MSC_RBC_PAD_TO_12), 375 USB_QUIRK(SONY, DSC, 0x0600, 0x0600, UQ_MSC_FORCE_WIRE_CBI, 376 UQ_MSC_FORCE_PROTO_RBC, UQ_MSC_RBC_PAD_TO_12), 377 USB_QUIRK(SONY, DSC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 378 UQ_MSC_FORCE_PROTO_RBC), 379 USB_QUIRK(SONY, HANDYCAM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 380 UQ_MSC_FORCE_PROTO_RBC), 381 USB_QUIRK(SONY, MSC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 382 UQ_MSC_FORCE_PROTO_RBC), 383 USB_QUIRK(SONY, MS_MSC_U03, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 384 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_GETMAXLUN), 385 USB_QUIRK(SONY, MS_NW_MS7, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 386 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 387 USB_QUIRK(SONY, MS_PEG_N760C, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 388 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 389 USB_QUIRK(SONY, MSACUS1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 390 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 391 USB_QUIRK(SONY, PORTABLE_HDD_V2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 392 UQ_MSC_FORCE_PROTO_SCSI), 393 USB_QUIRK(SUPERTOP, IDE, 0x0000, 0xffff, UQ_MSC_IGNORE_RESIDUE, 394 UQ_MSC_NO_SYNC_CACHE), 395 USB_QUIRK(SUPERTOP, FLASHDRIVE, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY, 396 UQ_MSC_NO_SYNC_CACHE), 397 USB_QUIRK(TAUGA, CAMERAMATE, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 398 USB_QUIRK(TEAC, FD05PUB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 399 UQ_MSC_FORCE_PROTO_UFI), 400 USB_QUIRK(TECLAST, TLC300, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY, 401 UQ_MSC_NO_SYNC_CACHE), 402 USB_QUIRK(TREK, MEMKEY, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 403 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 404 USB_QUIRK(TREK, THUMBDRIVE_8MB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 405 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_IGNORE_RESIDUE), 406 USB_QUIRK(TRUMPION, C3310, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 407 UQ_MSC_FORCE_PROTO_UFI), 408 USB_QUIRK(TRUMPION, MP3, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_RBC), 409 USB_QUIRK(TRUMPION, T33520, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 410 USB_QUIRK(TWINMOS, MDIV, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 411 UQ_MSC_FORCE_PROTO_SCSI), 412 USB_QUIRK(VIA, USB2IDEBRIDGE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 413 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_SYNC_CACHE), 414 USB_QUIRK(VIVITAR, 35XX, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 415 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 416 USB_QUIRK(WESTERN, COMBO, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 417 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 418 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 419 USB_QUIRK(WESTERN, EXTHDD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 420 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 421 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 422 USB_QUIRK(WESTERN, MYBOOK, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 423 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY_EVPD, 424 UQ_MSC_NO_SYNC_CACHE), 425 USB_QUIRK(WESTERN, MYPASSWORD, 0x0000, 0xffff, UQ_MSC_FORCE_SHORT_INQ), 426 USB_QUIRK(WINMAXGROUP, FLASH64MC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 427 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 428 USB_QUIRK(YANO, FW800HD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 429 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 430 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 431 USB_QUIRK(YANO, U640MO, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 432 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_FORCE_SHORT_INQ), 433 USB_QUIRK(YEDATA, FLASHBUSTERU, 0x0000, 0x007F, UQ_MSC_FORCE_WIRE_CBI, 434 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_FLOPPY_SPEED, 435 UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_GETMAXLUN), 436 USB_QUIRK(YEDATA, FLASHBUSTERU, 0x0080, 0x0080, UQ_MSC_FORCE_WIRE_CBI_I, 437 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_FLOPPY_SPEED, 438 UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_GETMAXLUN), 439 USB_QUIRK(YEDATA, FLASHBUSTERU, 0x0081, 0xFFFF, UQ_MSC_FORCE_WIRE_CBI_I, 440 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_FLOPPY_SPEED, 441 UQ_MSC_NO_GETMAXLUN), 442 USB_QUIRK(ZORAN, EX20DSC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 443 UQ_MSC_FORCE_PROTO_ATAPI), 444 USB_QUIRK(MEIZU, M6_SL, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 445 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY, UQ_MSC_NO_SYNC_CACHE), 446 447 USB_QUIRK(TOSHIBA, TRANSMEMORY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 448 USB_QUIRK(VIALABS, USB30SATABRIDGE, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 449 450 /* Non-standard USB MIDI devices */ 451 USB_QUIRK(ROLAND, UM1, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 452 USB_QUIRK(ROLAND, SC8850, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 453 USB_QUIRK(ROLAND, SD90, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 454 USB_QUIRK(ROLAND, UM880N, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 455 USB_QUIRK(ROLAND, UA100, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 456 USB_QUIRK(ROLAND, UM4, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 457 USB_QUIRK(ROLAND, U8, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 458 USB_QUIRK(ROLAND, UM2, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 459 USB_QUIRK(ROLAND, SC8820, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 460 USB_QUIRK(ROLAND, PC300, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 461 USB_QUIRK(ROLAND, SK500, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 462 USB_QUIRK(ROLAND, SCD70, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 463 USB_QUIRK(ROLAND, UM550, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 464 USB_QUIRK(ROLAND, SD20, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 465 USB_QUIRK(ROLAND, SD80, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 466 USB_QUIRK(ROLAND, UA700, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 467 USB_QUIRK(EGO, M4U, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 468 USB_QUIRK(LOGILINK, U2M, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 469 USB_QUIRK(MEDELI, DD305, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI, UQ_MATCH_VENDOR_ONLY), 470 USB_QUIRK(REDOCTANE, GHMIDI, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 471 USB_QUIRK(TEXTECH, U2M_1, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 472 USB_QUIRK(TEXTECH, U2M_2, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 473 USB_QUIRK(WCH2, U2M, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 474 475 /* Non-standard USB AUDIO devices */ 476 USB_QUIRK(MAUDIO, FASTTRACKULTRA, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 477 USB_QUIRK(MAUDIO, FASTTRACKULTRA8R, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 478 479 /* 480 * Quirks for manufacturers which USB devices does not respond 481 * after issuing non-supported commands: 482 */ 483 USB_QUIRK(ALCOR, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MSC_NO_TEST_UNIT_READY, UQ_MATCH_VENDOR_ONLY), 484 USB_QUIRK(FEIYA, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY), 485 USB_QUIRK(REALTEK, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY), 486 USB_QUIRK(INITIO, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY), 487 }; 488 #undef USB_QUIRK_VP 489 #undef USB_QUIRK 490 491 static const char *usb_quirk_str[USB_QUIRK_MAX] = { 492 [UQ_NONE] = "UQ_NONE", 493 [UQ_MATCH_VENDOR_ONLY] = "UQ_MATCH_VENDOR_ONLY", 494 [UQ_AUDIO_SWAP_LR] = "UQ_AUDIO_SWAP_LR", 495 [UQ_AU_INP_ASYNC] = "UQ_AU_INP_ASYNC", 496 [UQ_AU_NO_FRAC] = "UQ_AU_NO_FRAC", 497 [UQ_AU_NO_XU] = "UQ_AU_NO_XU", 498 [UQ_BAD_ADC] = "UQ_BAD_ADC", 499 [UQ_BAD_AUDIO] = "UQ_BAD_AUDIO", 500 [UQ_BROKEN_BIDIR] = "UQ_BROKEN_BIDIR", 501 [UQ_BUS_POWERED] = "UQ_BUS_POWERED", 502 [UQ_HID_IGNORE] = "UQ_HID_IGNORE", 503 [UQ_KBD_IGNORE] = "UQ_KBD_IGNORE", 504 [UQ_KBD_BOOTPROTO] = "UQ_KBD_BOOTPROTO", 505 [UQ_UMS_IGNORE] = "UQ_UMS_IGNORE", 506 [UQ_MS_BAD_CLASS] = "UQ_MS_BAD_CLASS", 507 [UQ_MS_LEADING_BYTE] = "UQ_MS_LEADING_BYTE", 508 [UQ_MS_REVZ] = "UQ_MS_REVZ", 509 [UQ_NO_STRINGS] = "UQ_NO_STRINGS", 510 [UQ_OPEN_CLEARSTALL] = "UQ_OPEN_CLEARSTALL", 511 [UQ_POWER_CLAIM] = "UQ_POWER_CLAIM", 512 [UQ_SPUR_BUT_UP] = "UQ_SPUR_BUT_UP", 513 [UQ_SWAP_UNICODE] = "UQ_SWAP_UNICODE", 514 [UQ_CFG_INDEX_1] = "UQ_CFG_INDEX_1", 515 [UQ_CFG_INDEX_2] = "UQ_CFG_INDEX_2", 516 [UQ_CFG_INDEX_3] = "UQ_CFG_INDEX_3", 517 [UQ_CFG_INDEX_4] = "UQ_CFG_INDEX_4", 518 [UQ_CFG_INDEX_0] = "UQ_CFG_INDEX_0", 519 [UQ_ASSUME_CM_OVER_DATA] = "UQ_ASSUME_CM_OVER_DATA", 520 [UQ_MSC_NO_TEST_UNIT_READY] = "UQ_MSC_NO_TEST_UNIT_READY", 521 [UQ_MSC_NO_RS_CLEAR_UA] = "UQ_MSC_NO_RS_CLEAR_UA", 522 [UQ_MSC_NO_START_STOP] = "UQ_MSC_NO_START_STOP", 523 [UQ_MSC_NO_GETMAXLUN] = "UQ_MSC_NO_GETMAXLUN", 524 [UQ_MSC_NO_INQUIRY] = "UQ_MSC_NO_INQUIRY", 525 [UQ_MSC_NO_INQUIRY_EVPD] = "UQ_MSC_NO_INQUIRY_EVPD", 526 [UQ_MSC_NO_SYNC_CACHE] = "UQ_MSC_NO_SYNC_CACHE", 527 [UQ_MSC_SHUTTLE_INIT] = "UQ_MSC_SHUTTLE_INIT", 528 [UQ_MSC_ALT_IFACE_1] = "UQ_MSC_ALT_IFACE_1", 529 [UQ_MSC_FLOPPY_SPEED] = "UQ_MSC_FLOPPY_SPEED", 530 [UQ_MSC_IGNORE_RESIDUE] = "UQ_MSC_IGNORE_RESIDUE", 531 [UQ_MSC_WRONG_CSWSIG] = "UQ_MSC_WRONG_CSWSIG", 532 [UQ_MSC_RBC_PAD_TO_12] = "UQ_MSC_RBC_PAD_TO_12", 533 [UQ_MSC_READ_CAP_OFFBY1] = "UQ_MSC_READ_CAP_OFFBY1", 534 [UQ_MSC_FORCE_SHORT_INQ] = "UQ_MSC_FORCE_SHORT_INQ", 535 [UQ_MSC_FORCE_WIRE_BBB] = "UQ_MSC_FORCE_WIRE_BBB", 536 [UQ_MSC_FORCE_WIRE_CBI] = "UQ_MSC_FORCE_WIRE_CBI", 537 [UQ_MSC_FORCE_WIRE_CBI_I] = "UQ_MSC_FORCE_WIRE_CBI_I", 538 [UQ_MSC_FORCE_PROTO_SCSI] = "UQ_MSC_FORCE_PROTO_SCSI", 539 [UQ_MSC_FORCE_PROTO_ATAPI] = "UQ_MSC_FORCE_PROTO_ATAPI", 540 [UQ_MSC_FORCE_PROTO_UFI] = "UQ_MSC_FORCE_PROTO_UFI", 541 [UQ_MSC_FORCE_PROTO_RBC] = "UQ_MSC_FORCE_PROTO_RBC", 542 [UQ_MSC_EJECT_HUAWEI] = "UQ_MSC_EJECT_HUAWEI", 543 [UQ_MSC_EJECT_SIERRA] = "UQ_MSC_EJECT_SIERRA", 544 [UQ_MSC_EJECT_SCSIEJECT] = "UQ_MSC_EJECT_SCSIEJECT", 545 [UQ_MSC_EJECT_REZERO] = "UQ_MSC_EJECT_REZERO", 546 [UQ_MSC_EJECT_ZTESTOR] = "UQ_MSC_EJECT_ZTESTOR", 547 [UQ_MSC_EJECT_CMOTECH] = "UQ_MSC_EJECT_CMOTECH", 548 [UQ_MSC_EJECT_WAIT] = "UQ_MSC_EJECT_WAIT", 549 [UQ_MSC_EJECT_SAEL_M460] = "UQ_MSC_EJECT_SAEL_M460", 550 [UQ_MSC_EJECT_HUAWEISCSI] = "UQ_MSC_EJECT_HUAWEISCSI", 551 [UQ_MSC_EJECT_TCT] = "UQ_MSC_EJECT_TCT", 552 [UQ_BAD_MIDI] = "UQ_BAD_MIDI", 553 [UQ_AU_VENDOR_CLASS] = "UQ_AU_VENDOR_CLASS", 554 [UQ_SINGLE_CMD_MIDI] = "UQ_SINGLE_CMD_MIDI", 555 }; 556 557 /*------------------------------------------------------------------------* 558 * usb_quirkstr 559 * 560 * This function converts an USB quirk code into a string. 561 *------------------------------------------------------------------------*/ 562 static const char * 563 usb_quirkstr(uint16_t quirk) 564 { 565 return ((quirk < USB_QUIRK_MAX) ? 566 usb_quirk_str[quirk] : "USB_QUIRK_UNKNOWN"); 567 } 568 569 /*------------------------------------------------------------------------* 570 * usb_test_quirk_by_info 571 * 572 * Returns: 573 * 0: Quirk not found 574 * Else: Quirk found 575 *------------------------------------------------------------------------*/ 576 static uint8_t 577 usb_test_quirk_by_info(const struct usbd_lookup_info *info, uint16_t quirk) 578 { 579 uint16_t x; 580 uint16_t y; 581 582 if (quirk == UQ_NONE) 583 goto done; 584 585 mtx_lock(&usb_quirk_mtx); 586 587 for (x = 0; x != USB_DEV_QUIRKS_MAX; x++) { 588 /* see if quirk information does not match */ 589 if ((usb_quirks[x].vid != info->idVendor) || 590 (usb_quirks[x].lo_rev > info->bcdDevice) || 591 (usb_quirks[x].hi_rev < info->bcdDevice)) { 592 continue; 593 } 594 /* see if quirk only should match vendor ID */ 595 if (usb_quirks[x].pid != info->idProduct) { 596 if (usb_quirks[x].pid != 0) 597 continue; 598 599 for (y = 0; y != USB_SUB_QUIRKS_MAX; y++) { 600 if (usb_quirks[x].quirks[y] == UQ_MATCH_VENDOR_ONLY) 601 break; 602 } 603 if (y == USB_SUB_QUIRKS_MAX) 604 continue; 605 } 606 /* lookup quirk */ 607 for (y = 0; y != USB_SUB_QUIRKS_MAX; y++) { 608 if (usb_quirks[x].quirks[y] == quirk) { 609 mtx_unlock(&usb_quirk_mtx); 610 DPRINTF("Found quirk '%s'.\n", usb_quirkstr(quirk)); 611 return (1); 612 } 613 } 614 /* no quirk found */ 615 break; 616 } 617 mtx_unlock(&usb_quirk_mtx); 618 done: 619 return (0); /* no quirk match */ 620 } 621 622 static struct usb_quirk_entry * 623 usb_quirk_get_entry(uint16_t vid, uint16_t pid, 624 uint16_t lo_rev, uint16_t hi_rev, uint8_t do_alloc) 625 { 626 uint16_t x; 627 628 mtx_assert(&usb_quirk_mtx, MA_OWNED); 629 630 if ((vid | pid | lo_rev | hi_rev) == 0) { 631 /* all zero - special case */ 632 return (usb_quirks + USB_DEV_QUIRKS_MAX - 1); 633 } 634 /* search for an existing entry */ 635 for (x = 0; x != USB_DEV_QUIRKS_MAX; x++) { 636 /* see if quirk information does not match */ 637 if ((usb_quirks[x].vid != vid) || 638 (usb_quirks[x].pid != pid) || 639 (usb_quirks[x].lo_rev != lo_rev) || 640 (usb_quirks[x].hi_rev != hi_rev)) { 641 continue; 642 } 643 return (usb_quirks + x); 644 } 645 646 if (do_alloc == 0) { 647 /* no match */ 648 return (NULL); 649 } 650 /* search for a free entry */ 651 for (x = 0; x != USB_DEV_QUIRKS_MAX; x++) { 652 /* see if quirk information does not match */ 653 if ((usb_quirks[x].vid | 654 usb_quirks[x].pid | 655 usb_quirks[x].lo_rev | 656 usb_quirks[x].hi_rev) != 0) { 657 continue; 658 } 659 usb_quirks[x].vid = vid; 660 usb_quirks[x].pid = pid; 661 usb_quirks[x].lo_rev = lo_rev; 662 usb_quirks[x].hi_rev = hi_rev; 663 664 return (usb_quirks + x); 665 } 666 667 /* no entry found */ 668 return (NULL); 669 } 670 671 /*------------------------------------------------------------------------* 672 * usb_quirk_ioctl - handle quirk IOCTLs 673 * 674 * Returns: 675 * 0: Success 676 * Else: Failure 677 *------------------------------------------------------------------------*/ 678 static int 679 usb_quirk_ioctl(unsigned long cmd, caddr_t data, 680 int fflag, struct thread *td) 681 { 682 struct usb_gen_quirk *pgq; 683 struct usb_quirk_entry *pqe; 684 uint32_t x; 685 uint32_t y; 686 int err; 687 688 switch (cmd) { 689 case USB_DEV_QUIRK_GET: 690 pgq = (void *)data; 691 x = pgq->index % USB_SUB_QUIRKS_MAX; 692 y = pgq->index / USB_SUB_QUIRKS_MAX; 693 if (y >= USB_DEV_QUIRKS_MAX) { 694 return (EINVAL); 695 } 696 mtx_lock(&usb_quirk_mtx); 697 /* copy out data */ 698 pgq->vid = usb_quirks[y].vid; 699 pgq->pid = usb_quirks[y].pid; 700 pgq->bcdDeviceLow = usb_quirks[y].lo_rev; 701 pgq->bcdDeviceHigh = usb_quirks[y].hi_rev; 702 strlcpy(pgq->quirkname, 703 usb_quirkstr(usb_quirks[y].quirks[x]), 704 sizeof(pgq->quirkname)); 705 mtx_unlock(&usb_quirk_mtx); 706 return (0); /* success */ 707 708 case USB_QUIRK_NAME_GET: 709 pgq = (void *)data; 710 x = pgq->index; 711 if (x >= USB_QUIRK_MAX) { 712 return (EINVAL); 713 } 714 strlcpy(pgq->quirkname, 715 usb_quirkstr(x), sizeof(pgq->quirkname)); 716 return (0); /* success */ 717 718 case USB_DEV_QUIRK_ADD: 719 pgq = (void *)data; 720 721 /* check privileges */ 722 err = priv_check(curthread, PRIV_DRIVER); 723 if (err) { 724 return (err); 725 } 726 /* convert quirk string into numerical */ 727 for (y = 0; y != USB_DEV_QUIRKS_MAX; y++) { 728 if (strcmp(pgq->quirkname, usb_quirkstr(y)) == 0) { 729 break; 730 } 731 } 732 if (y == USB_DEV_QUIRKS_MAX) { 733 return (EINVAL); 734 } 735 if (y == UQ_NONE) { 736 return (EINVAL); 737 } 738 mtx_lock(&usb_quirk_mtx); 739 pqe = usb_quirk_get_entry(pgq->vid, pgq->pid, 740 pgq->bcdDeviceLow, pgq->bcdDeviceHigh, 1); 741 if (pqe == NULL) { 742 mtx_unlock(&usb_quirk_mtx); 743 return (EINVAL); 744 } 745 for (x = 0; x != USB_SUB_QUIRKS_MAX; x++) { 746 if (pqe->quirks[x] == UQ_NONE) { 747 pqe->quirks[x] = y; 748 break; 749 } 750 } 751 mtx_unlock(&usb_quirk_mtx); 752 if (x == USB_SUB_QUIRKS_MAX) { 753 return (ENOMEM); 754 } 755 return (0); /* success */ 756 757 case USB_DEV_QUIRK_REMOVE: 758 pgq = (void *)data; 759 /* check privileges */ 760 err = priv_check(curthread, PRIV_DRIVER); 761 if (err) { 762 return (err); 763 } 764 /* convert quirk string into numerical */ 765 for (y = 0; y != USB_DEV_QUIRKS_MAX; y++) { 766 if (strcmp(pgq->quirkname, usb_quirkstr(y)) == 0) { 767 break; 768 } 769 } 770 if (y == USB_DEV_QUIRKS_MAX) { 771 return (EINVAL); 772 } 773 if (y == UQ_NONE) { 774 return (EINVAL); 775 } 776 mtx_lock(&usb_quirk_mtx); 777 pqe = usb_quirk_get_entry(pgq->vid, pgq->pid, 778 pgq->bcdDeviceLow, pgq->bcdDeviceHigh, 0); 779 if (pqe == NULL) { 780 mtx_unlock(&usb_quirk_mtx); 781 return (EINVAL); 782 } 783 for (x = 0; x != USB_SUB_QUIRKS_MAX; x++) { 784 if (pqe->quirks[x] == y) { 785 pqe->quirks[x] = UQ_NONE; 786 break; 787 } 788 } 789 if (x == USB_SUB_QUIRKS_MAX) { 790 mtx_unlock(&usb_quirk_mtx); 791 return (ENOMEM); 792 } 793 for (x = 0; x != USB_SUB_QUIRKS_MAX; x++) { 794 if (pqe->quirks[x] != UQ_NONE) { 795 break; 796 } 797 } 798 if (x == USB_SUB_QUIRKS_MAX) { 799 /* all quirk entries are unused - release */ 800 memset(pqe, 0, sizeof(pqe)); 801 } 802 mtx_unlock(&usb_quirk_mtx); 803 return (0); /* success */ 804 805 default: 806 break; 807 } 808 return (ENOIOCTL); 809 } 810 811 static void 812 usb_quirk_init(void *arg) 813 { 814 /* initialize mutex */ 815 mtx_init(&usb_quirk_mtx, "USB quirk", NULL, MTX_DEF); 816 817 /* register our function */ 818 usb_test_quirk_p = &usb_test_quirk_by_info; 819 usb_quirk_ioctl_p = &usb_quirk_ioctl; 820 } 821 822 static void 823 usb_quirk_uninit(void *arg) 824 { 825 usb_quirk_unload(arg); 826 827 /* destroy mutex */ 828 mtx_destroy(&usb_quirk_mtx); 829 } 830 831 SYSINIT(usb_quirk_init, SI_SUB_LOCK, SI_ORDER_FIRST, usb_quirk_init, NULL); 832 SYSUNINIT(usb_quirk_uninit, SI_SUB_LOCK, SI_ORDER_ANY, usb_quirk_uninit, NULL); 833