1 /* $FreeBSD$ */ 2 /*- 3 * SPDX-License-Identifier: BSD-2-Clause-NetBSD 4 * 5 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 6 * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 7 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31 #include <sys/stdint.h> 32 #include <sys/stddef.h> 33 #include <sys/param.h> 34 #include <sys/queue.h> 35 #include <sys/types.h> 36 #include <sys/systm.h> 37 #include <sys/kernel.h> 38 #include <sys/bus.h> 39 #include <sys/module.h> 40 #include <sys/lock.h> 41 #include <sys/mutex.h> 42 #include <sys/condvar.h> 43 #include <sys/sysctl.h> 44 #include <sys/sx.h> 45 #include <sys/unistd.h> 46 #include <sys/callout.h> 47 #include <sys/malloc.h> 48 #include <sys/priv.h> 49 50 #include <dev/usb/usb.h> 51 #include <dev/usb/usb_ioctl.h> 52 #include <dev/usb/usbdi.h> 53 #include "usbdevs.h" 54 55 #define USB_DEBUG_VAR usb_debug 56 #include <dev/usb/usb_debug.h> 57 #include <dev/usb/usb_dynamic.h> 58 59 #include <dev/usb/quirk/usb_quirk.h> 60 61 MODULE_DEPEND(usb_quirk, usb, 1, 1, 1); 62 MODULE_VERSION(usb_quirk, 1); 63 64 #define USB_DEV_QUIRKS_MAX 384 65 #define USB_SUB_QUIRKS_MAX 8 66 #define USB_QUIRK_ENVROOT "hw.usb.quirk." 67 68 struct usb_quirk_entry { 69 uint16_t vid; 70 uint16_t pid; 71 uint16_t lo_rev; 72 uint16_t hi_rev; 73 uint16_t quirks[USB_SUB_QUIRKS_MAX]; 74 }; 75 76 static struct mtx usb_quirk_mtx; 77 78 #define USB_QUIRK_VP(v,p,l,h,...) \ 79 { .vid = (v), .pid = (p), .lo_rev = (l), .hi_rev = (h), \ 80 .quirks = { __VA_ARGS__ } } 81 #define USB_QUIRK(v,p,l,h,...) \ 82 USB_QUIRK_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, l, h, __VA_ARGS__) 83 84 static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRKS_MAX] = { 85 USB_QUIRK(ASUS, LCM, 0x0000, 0xffff, UQ_HID_IGNORE), 86 USB_QUIRK(INSIDEOUT, EDGEPORT4, 0x094, 0x094, UQ_SWAP_UNICODE), 87 USB_QUIRK(DALLAS, J6502, 0x0a2, 0x0a2, UQ_BAD_ADC), 88 USB_QUIRK(DALLAS, J6502, 0x0a2, 0x0a2, UQ_AU_NO_XU), 89 USB_QUIRK(ALTEC, ADA70, 0x103, 0x103, UQ_BAD_ADC), 90 USB_QUIRK(ALTEC, ASC495, 0x000, 0x000, UQ_BAD_AUDIO), 91 USB_QUIRK(QTRONIX, 980N, 0x110, 0x110, UQ_SPUR_BUT_UP), 92 USB_QUIRK(ALCOR2, KBD_HUB, 0x001, 0x001, UQ_SPUR_BUT_UP), 93 USB_QUIRK(MCT, HUB0100, 0x102, 0x102, UQ_BUS_POWERED), 94 USB_QUIRK(MCT, USB232, 0x102, 0x102, UQ_BUS_POWERED), 95 USB_QUIRK(TI, UTUSB41, 0x110, 0x110, UQ_POWER_CLAIM), 96 USB_QUIRK(TELEX, MIC1, 0x009, 0x009, UQ_AU_NO_FRAC), 97 USB_QUIRK(SILICONPORTALS, YAPPHONE, 0x100, 0x100, UQ_AU_INP_ASYNC), 98 USB_QUIRK(LOGITECH, UN53B, 0x0000, 0xffff, UQ_NO_STRINGS), 99 USB_QUIRK(LOGITECH, G510S, 0x0000, 0xFFFF, UQ_KBD_BOOTPROTO), 100 USB_QUIRK(REALTEK, RTL8196EU, 0x0000, 0xffff, UQ_CFG_INDEX_1), 101 USB_QUIRK(ELSA, MODEM1, 0x0000, 0xffff, UQ_CFG_INDEX_1), 102 USB_QUIRK(PLANEX2, MZKUE150N, 0x0000, 0xffff, UQ_CFG_INDEX_1), 103 USB_QUIRK(CISCOLINKSYS, USB3GIGV1, 0x0000, 0xffff, UQ_CFG_INDEX_1), 104 USB_QUIRK(REALTEK, RTL8156, 0x0000, 0xffff, UQ_CFG_INDEX_2), 105 /* Quirks for printer devices */ 106 USB_QUIRK(HP, 895C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 107 USB_QUIRK(HP, 880C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 108 USB_QUIRK(HP, 815C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 109 USB_QUIRK(HP, 810C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 110 USB_QUIRK(HP, 830C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 111 USB_QUIRK(HP, 1220C, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 112 USB_QUIRK(XEROX, WCM15, 0x0000, 0xffff, UQ_BROKEN_BIDIR), 113 /* Devices which should be ignored by uhid */ 114 USB_QUIRK(APC, UPS, 0x0000, 0xffff, UQ_HID_IGNORE), 115 USB_QUIRK(BELKIN, F6H375USB, 0x0000, 0xffff, UQ_HID_IGNORE), 116 USB_QUIRK(BELKIN, F6C550AVR, 0x0000, 0xffff, UQ_HID_IGNORE), 117 USB_QUIRK(BELKIN, F6C1250TWRK, 0x0000, 0xffff, UQ_HID_IGNORE), 118 USB_QUIRK(BELKIN, F6C1500TWRK, 0x0000, 0xffff, UQ_HID_IGNORE), 119 USB_QUIRK(BELKIN, F6C900UNV, 0x0000, 0xffff, UQ_HID_IGNORE), 120 USB_QUIRK(BELKIN, F6C100UNV, 0x0000, 0xffff, UQ_HID_IGNORE), 121 USB_QUIRK(BELKIN, F6C120UNV, 0x0000, 0xffff, UQ_HID_IGNORE), 122 USB_QUIRK(BELKIN, F6C800UNV, 0x0000, 0xffff, UQ_HID_IGNORE), 123 USB_QUIRK(BELKIN, F6C1100UNV, 0x0000, 0xffff, UQ_HID_IGNORE), 124 USB_QUIRK(CYBERPOWER, BC900D, 0x0000, 0xffff, UQ_HID_IGNORE), 125 USB_QUIRK(CYBERPOWER, 1500CAVRLCD, 0x0000, 0xffff, UQ_HID_IGNORE), 126 USB_QUIRK(CYBERPOWER, OR2200LCDRM2U, 0x0000, 0xffff, UQ_HID_IGNORE), 127 USB_QUIRK(DELL2, VARIOUS_UPS, 0x0000, 0xffff, UQ_HID_IGNORE), 128 USB_QUIRK(CYPRESS, SILVERSHIELD, 0x0000, 0xffff, UQ_HID_IGNORE), 129 USB_QUIRK(DELORME, EARTHMATE, 0x0000, 0xffff, UQ_HID_IGNORE), 130 USB_QUIRK(DREAMLINK, DL100B, 0x0000, 0xffff, UQ_HID_IGNORE), 131 USB_QUIRK(MICROCHIP, PICOLCD20X2, 0x0000, 0xffff, UQ_HID_IGNORE), 132 USB_QUIRK(MICROCHIP, PICOLCD4X20, 0x0000, 0xffff, UQ_HID_IGNORE), 133 USB_QUIRK(LIEBERT, POWERSURE_PXT, 0x0000, 0xffff, UQ_HID_IGNORE), 134 USB_QUIRK(LIEBERT2, PSI1000, 0x0000, 0xffff, UQ_HID_IGNORE), 135 USB_QUIRK(LIEBERT2, POWERSURE_PSA, 0x0000, 0xffff, UQ_HID_IGNORE), 136 USB_QUIRK(MGE, UPS1, 0x0000, 0xffff, UQ_HID_IGNORE), 137 USB_QUIRK(MGE, UPS2, 0x0000, 0xffff, UQ_HID_IGNORE), 138 USB_QUIRK(POWERCOM, IMPERIAL_SERIES, 0x0000, 0xffff, UQ_HID_IGNORE), 139 USB_QUIRK(POWERCOM, SMART_KING_PRO, 0x0000, 0xffff, UQ_HID_IGNORE), 140 USB_QUIRK(POWERCOM, WOW, 0x0000, 0xffff, UQ_HID_IGNORE), 141 USB_QUIRK(POWERCOM, VANGUARD, 0x0000, 0xffff, UQ_HID_IGNORE), 142 USB_QUIRK(POWERCOM, BLACK_KNIGHT_PRO, 0x0000, 0xffff, UQ_HID_IGNORE), 143 USB_QUIRK(TRIPPLITE2, AVR550U, 0x0000, 0xffff, UQ_HID_IGNORE), 144 USB_QUIRK(TRIPPLITE2, AVR750U, 0x0000, 0xffff, UQ_HID_IGNORE), 145 USB_QUIRK(TRIPPLITE2, ECO550UPS, 0x0000, 0xffff, UQ_HID_IGNORE), 146 USB_QUIRK(TRIPPLITE2, T750_INTL, 0x0000, 0xffff, UQ_HID_IGNORE), 147 USB_QUIRK(TRIPPLITE2, RT_2200_INTL, 0x0000, 0xffff, UQ_HID_IGNORE), 148 USB_QUIRK(TRIPPLITE2, OMNI1000LCD, 0x0000, 0xffff, UQ_HID_IGNORE), 149 USB_QUIRK(TRIPPLITE2, OMNI900LCD, 0x0000, 0xffff, UQ_HID_IGNORE), 150 USB_QUIRK(TRIPPLITE2, SMART_2200RMXL2U, 0x0000, 0xffff, UQ_HID_IGNORE), 151 USB_QUIRK(TRIPPLITE2, UPS_3014, 0x0000, 0xffff, UQ_HID_IGNORE), 152 USB_QUIRK(TRIPPLITE2, SU1500RTXL2UA, 0x0000, 0xffff, UQ_HID_IGNORE), 153 USB_QUIRK(TRIPPLITE2, SU6000RT4U, 0x0000, 0xffff, UQ_HID_IGNORE), 154 USB_QUIRK(TRIPPLITE2, SU1500RTXL2UA_2, 0x0000, 0xffff, UQ_HID_IGNORE), 155 USB_QUIRK(APPLE, IPHONE, 0x0000, 0xffff, UQ_HID_IGNORE), 156 USB_QUIRK(APPLE, IPHONE_3G, 0x0000, 0xffff, UQ_HID_IGNORE), 157 USB_QUIRK(MEGATEC, UPS, 0x0000, 0xffff, UQ_HID_IGNORE), 158 /* Devices which should be ignored by both ukbd and uhid */ 159 USB_QUIRK(CYPRESS, WISPY1A, 0x0000, 0xffff, UQ_KBD_IGNORE, UQ_HID_IGNORE), 160 USB_QUIRK(METAGEEK, WISPY1B, 0x0000, 0xffff, UQ_KBD_IGNORE, UQ_HID_IGNORE), 161 USB_QUIRK(METAGEEK, WISPY24X, 0x0000, 0xffff, UQ_KBD_IGNORE, UQ_HID_IGNORE), 162 USB_QUIRK(METAGEEK2, WISPYDBX, 0x0000, 0xffff, UQ_KBD_IGNORE, UQ_HID_IGNORE), 163 USB_QUIRK(TENX, UAUDIO0, 0x0101, 0x0101, UQ_AUDIO_SWAP_LR), 164 /* MS keyboards do weird things */ 165 USB_QUIRK(MICROSOFT, NATURAL4000, 0x0000, 0xFFFF, UQ_KBD_BOOTPROTO), 166 USB_QUIRK(MICROSOFT, WLINTELLIMOUSE, 0x0000, 0xffff, UQ_MS_LEADING_BYTE), 167 /* Quirk for Corsair Vengeance K60 keyboard */ 168 USB_QUIRK(CORSAIR, K60, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), 169 /* Quirk for Corsair Gaming K68 keyboard */ 170 USB_QUIRK(CORSAIR, K68, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), 171 /* Quirk for Corsair Vengeance K70 keyboard */ 172 USB_QUIRK(CORSAIR, K70, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), 173 /* Quirk for Corsair K70 RGB keyboard */ 174 USB_QUIRK(CORSAIR, K70_RGB, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), 175 /* Quirk for Corsair STRAFE Gaming keyboard */ 176 USB_QUIRK(CORSAIR, STRAFE, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), 177 USB_QUIRK(CORSAIR, STRAFE2, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), 178 /* Quirk for Kensington Slimblade Trackball */ 179 USB_QUIRK(KENSINGTON, SLIMBLADE, 0x0000, 0xffff, UQ_MS_VENDOR_BTN), 180 /* umodem(4) device quirks */ 181 USB_QUIRK(METRICOM, RICOCHET_GS, 0x100, 0x100, UQ_ASSUME_CM_OVER_DATA), 182 USB_QUIRK(SANYO, SCP4900, 0x000, 0x000, UQ_ASSUME_CM_OVER_DATA), 183 USB_QUIRK(MOTOROLA2, T720C, 0x001, 0x001, UQ_ASSUME_CM_OVER_DATA), 184 USB_QUIRK(EICON, DIVA852, 0x100, 0x100, UQ_ASSUME_CM_OVER_DATA), 185 USB_QUIRK(SIEMENS2, ES75, 0x000, 0x000, UQ_ASSUME_CM_OVER_DATA), 186 USB_QUIRK(QUALCOMM, CDMA_MSM, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 187 USB_QUIRK(QUALCOMM2, CDMA_MSM, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 188 USB_QUIRK(CURITEL, UM150, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 189 USB_QUIRK(CURITEL, UM175, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 190 USB_QUIRK(VERTEX, VW110L, 0x0000, 0xffff, UQ_ASSUME_CM_OVER_DATA), 191 192 /* USB Mass Storage Class Quirks */ 193 USB_QUIRK_VP(USB_VENDOR_ASAHIOPTICAL, 0, UQ_MSC_NO_RS_CLEAR_UA, 194 UQ_MATCH_VENDOR_ONLY), 195 USB_QUIRK(ADDON, ATTACHE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 196 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 197 USB_QUIRK(ADDON, A256MB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 198 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 199 USB_QUIRK(ADDON, DISKPRO512, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 200 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 201 USB_QUIRK(ADDONICS2, CABLE_205, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 202 UQ_MSC_FORCE_PROTO_SCSI), 203 USB_QUIRK(AIPTEK, POCKETCAM3M, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 204 UQ_MSC_FORCE_PROTO_SCSI), 205 USB_QUIRK(ALCOR, UMCR_9361, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 206 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 207 USB_QUIRK(ALCOR, TRANSCEND, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 208 UQ_MSC_NO_SYNC_CACHE, UQ_MSC_NO_TEST_UNIT_READY), 209 USB_QUIRK(APACER, HT202, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY, 210 UQ_MSC_NO_SYNC_CACHE), 211 USB_QUIRK(ASAHIOPTICAL, OPTIO230, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 212 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 213 USB_QUIRK(ASAHIOPTICAL, OPTIO330, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 214 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 215 USB_QUIRK(ATP, EUSB, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 216 USB_QUIRK(BELKIN, USB2SCSI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 217 UQ_MSC_FORCE_PROTO_SCSI), 218 USB_QUIRK(CASIO, QV_DIGICAM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 219 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 220 USB_QUIRK(CCYU, ED1064, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 221 UQ_MSC_FORCE_PROTO_SCSI), 222 USB_QUIRK(CENTURY, EX35QUAT, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 223 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 224 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 225 USB_QUIRK(CREATIVE, NOMAD, 0x0001, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 226 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1), 227 USB_QUIRK(CYPRESS, XX6830XX, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 228 UQ_MSC_NO_SYNC_CACHE), 229 USB_QUIRK(EMTEC, DANEELEC4GB, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 230 USB_QUIRK(DESKNOTE, UCR_61S2B, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 231 UQ_MSC_FORCE_PROTO_SCSI), 232 USB_QUIRK(DMI, CFSM_RW, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI, 233 UQ_MSC_NO_GETMAXLUN), 234 USB_QUIRK(EMTEC, RUF2PS, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 235 USB_QUIRK(EPSON, STYLUS_875DC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 236 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 237 USB_QUIRK(EPSON, STYLUS_895, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 238 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 239 USB_QUIRK(FEIYA, 5IN1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 240 UQ_MSC_FORCE_PROTO_SCSI), 241 USB_QUIRK(FEIYA, ELANGO, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 242 USB_QUIRK(FREECOM, DVD, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 243 USB_QUIRK(FUJIPHOTO, MASS0100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 244 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_NO_SYNC_CACHE), 245 USB_QUIRK(GARMIN, DAKOTA20, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), 246 USB_QUIRK(GARMIN, FORERUNNER230, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), 247 USB_QUIRK(GARMIN, GPSMAP62S, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), 248 USB_QUIRK(GARMIN, EDGETOURINGPLUS, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), 249 USB_QUIRK(GARMIN, INSTINCTSOLAR, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), 250 USB_QUIRK(GENESYS, GL641USB2IDE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 251 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 252 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE, UQ_MSC_NO_SYNC_CACHE), 253 USB_QUIRK(GENESYS, GL641USB2IDE_2, 0x0000, 0xffff, 254 UQ_MSC_FORCE_WIRE_BBB, UQ_MSC_FORCE_PROTO_ATAPI, 255 UQ_MSC_FORCE_SHORT_INQ, UQ_MSC_NO_START_STOP, 256 UQ_MSC_IGNORE_RESIDUE), 257 USB_QUIRK(GENESYS, GL641USB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 258 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 259 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 260 USB_QUIRK(GENESYS, GL641USB_2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 261 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_WRONG_CSWSIG), 262 USB_QUIRK(HAGIWARA, FG, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 263 UQ_MSC_FORCE_PROTO_SCSI), 264 USB_QUIRK(HAGIWARA, FGSM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 265 UQ_MSC_FORCE_PROTO_SCSI), 266 USB_QUIRK(HITACHI, DVDCAM_DZ_MV100A, 0x0000, 0xffff, 267 UQ_MSC_FORCE_WIRE_CBI, UQ_MSC_FORCE_PROTO_SCSI, 268 UQ_MSC_NO_GETMAXLUN), 269 USB_QUIRK(HITACHI, DVDCAM_USB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 270 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 271 USB_QUIRK(HP, CDW4E, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_ATAPI), 272 USB_QUIRK(HP, CDW8200, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 273 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_TEST_UNIT_READY, 274 UQ_MSC_NO_START_STOP), 275 USB_QUIRK(HUAWEI, E3372_INIT, 0, 0xffff, UQ_MSC_NO_INQUIRY, 276 UQ_MSC_NO_GETMAXLUN), 277 USB_QUIRK(IMAGINATION, DBX1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 278 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_WRONG_CSWSIG), 279 USB_QUIRK(INSYSTEM, USBCABLE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 280 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_TEST_UNIT_READY, 281 UQ_MSC_NO_START_STOP, UQ_MSC_ALT_IFACE_1), 282 USB_QUIRK(INSYSTEM, ATAPI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 283 UQ_MSC_FORCE_PROTO_RBC), 284 USB_QUIRK(INSYSTEM, STORAGE_V2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 285 UQ_MSC_FORCE_PROTO_RBC), 286 USB_QUIRK(VIALABS, VL701, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), 287 USB_QUIRK(IODATA, IU_CD2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 288 UQ_MSC_FORCE_PROTO_SCSI), 289 USB_QUIRK(IODATA, DVR_UEH8, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 290 UQ_MSC_FORCE_PROTO_SCSI), 291 USB_QUIRK(IOMEGA, ZIP100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 292 UQ_MSC_FORCE_PROTO_SCSI, 293 UQ_MSC_NO_TEST_UNIT_READY), /* XXX ZIP drives can also use ATAPI */ 294 USB_QUIRK(JMICRON, JMS566, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN), 295 USB_QUIRK(JMICRON, JMS567, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN), 296 USB_QUIRK(JMICRON, JM20337, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 297 UQ_MSC_FORCE_PROTO_SCSI, 298 UQ_MSC_NO_SYNC_CACHE), 299 USB_QUIRK(KINGSTON, HYPERX3_0, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), 300 USB_QUIRK(KINGSTON, DATATRAVELER3_0, 0x0000, 0xffff, UQ_MSC_NO_PREVENT_ALLOW, UQ_MSC_NO_SYNC_CACHE), 301 USB_QUIRK(KYOCERA, FINECAM_L3, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 302 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 303 USB_QUIRK(KYOCERA, FINECAM_S3X, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 304 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 305 USB_QUIRK(KYOCERA, FINECAM_S4, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 306 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 307 USB_QUIRK(KYOCERA, FINECAM_S5, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 308 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 309 USB_QUIRK(LACIE, HD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 310 UQ_MSC_FORCE_PROTO_RBC), 311 USB_QUIRK(LEXAR, CF_READER, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 312 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 313 USB_QUIRK(LEXAR, JUMPSHOT, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 314 USB_QUIRK(LEXAR, JUMPDRIVE, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), 315 USB_QUIRK(LOGITEC, LDR_H443SU2, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 316 USB_QUIRK(LOGITEC, LDR_H443U2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 317 UQ_MSC_FORCE_PROTO_SCSI,), 318 USB_QUIRK(MELCO, DUBPXXG, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 319 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 320 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 321 USB_QUIRK(MICROTECH, DPCM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 322 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_TEST_UNIT_READY, 323 UQ_MSC_NO_START_STOP), 324 USB_QUIRK(MICRON, REALSSD, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 325 USB_QUIRK(MICROTECH, SCSIDB25, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 326 UQ_MSC_FORCE_PROTO_SCSI), 327 USB_QUIRK(MICROTECH, SCSIHD50, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 328 UQ_MSC_FORCE_PROTO_SCSI), 329 USB_QUIRK(MINOLTA, E223, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 330 USB_QUIRK(MINOLTA, F300, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 331 UQ_MSC_FORCE_PROTO_SCSI), 332 USB_QUIRK(MITSUMI, CDRRW, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI | 333 UQ_MSC_FORCE_PROTO_ATAPI), 334 USB_QUIRK(MOTOROLA2, E398, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 335 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 336 UQ_MSC_NO_INQUIRY_EVPD, UQ_MSC_NO_GETMAXLUN), 337 USB_QUIRK_VP(USB_VENDOR_MPMAN, 0, UQ_MSC_NO_SYNC_CACHE, 338 UQ_MATCH_VENDOR_ONLY), 339 USB_QUIRK(MSYSTEMS, DISKONKEY, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 340 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE, UQ_MSC_NO_GETMAXLUN, 341 UQ_MSC_NO_RS_CLEAR_UA), 342 USB_QUIRK(MSYSTEMS, DISKONKEY2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 343 UQ_MSC_FORCE_PROTO_ATAPI), 344 USB_QUIRK(MYSON, HEDEN, 0x0000, 0xffff, UQ_MSC_IGNORE_RESIDUE, 345 UQ_MSC_NO_SYNC_CACHE), 346 USB_QUIRK(NEODIO, ND3260, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 347 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ), 348 USB_QUIRK(NETAC, CF_CARD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 349 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 350 USB_QUIRK(NETAC, ONLYDISK, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 351 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 352 USB_QUIRK(NETCHIP, CLIK_40, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_ATAPI, 353 UQ_MSC_NO_INQUIRY), 354 USB_QUIRK(NETCHIP, POCKETBOOK, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 355 USB_QUIRK(NIKON, D300, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 356 UQ_MSC_FORCE_PROTO_SCSI), 357 USB_QUIRK(OLYMPUS, C1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 358 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_WRONG_CSWSIG), 359 USB_QUIRK(OLYMPUS, C700, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN), 360 /* Selected Olympus DSLR and EVIL models. See ../usbdevs for more 361 * details. 362 * 363 * Not all quirks apply to all models. The commented-out entries are 364 * correct for that model. 365 */ 366 USB_QUIRK(OLYMPUS, E_1, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 367 UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_PREVENT_ALLOW, 368 UQ_MSC_NO_SYNC_CACHE), 369 /* 370 * Product code 0x118. 371 * USB_QUIRK(OLYMPUS, E_300, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 372 * UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_PREVENT_ALLOW, 373 * UQ_MSC_NO_SYNC_CACHE), 374 * USB_QUIRK(OLYMPUS, E_30, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 375 * UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_PREVENT_ALLOW, 376 * UQ_MSC_NO_SYNC_CACHE), */ 377 USB_QUIRK(OLYMPUS, E_330, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 378 UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_PREVENT_ALLOW, 379 UQ_MSC_NO_SYNC_CACHE, UQ_MSC_NO_START_STOP), 380 USB_QUIRK(OLYMPUS, E_PM1, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 381 UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_PREVENT_ALLOW, 382 UQ_MSC_NO_SYNC_CACHE, UQ_MSC_NO_START_STOP), 383 /* Product code 0x12e. 384 * USB_QUIRK(OLYMPUS, E_PM2, 0x0000, 0xffff, 0), 385 * USB_QUIRK(OLYMPUS, E_M1MarkII, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 386 * UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_PREVENT_ALLOW, 387 * UQ_MSC_NO_SYNC_CACHE), 388 * USB_QUIRK(OLYMPUS, E_M5MarkIII, 0x0000, 0xffff, 0), 389 */ 390 USB_QUIRK(OLYMPUS, E_M1, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 391 UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_PREVENT_ALLOW, 392 UQ_MSC_NO_SYNC_CACHE, UQ_MSC_NO_START_STOP), 393 USB_QUIRK(ONSPEC, SDS_HOTFIND_D, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 394 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN, UQ_MSC_NO_SYNC_CACHE), 395 USB_QUIRK(ONSPEC, CFMS_RW, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 396 USB_QUIRK(ONSPEC, CFSM_COMBO, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 397 USB_QUIRK(ONSPEC, CFSM_READER, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 398 USB_QUIRK(ONSPEC, CFSM_READER2, 0x0000, 0xffff, 399 UQ_MSC_FORCE_PROTO_SCSI), 400 USB_QUIRK(ONSPEC, MDCFE_B_CF_READER, 0x0000, 0xffff, 401 UQ_MSC_FORCE_PROTO_SCSI), 402 USB_QUIRK(ONSPEC, MDSM_B_READER, 0x0000, 0xffff, 403 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 404 USB_QUIRK(ONSPEC, READER, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 405 USB_QUIRK(ONSPEC, UCF100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 406 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY, UQ_MSC_NO_GETMAXLUN), 407 USB_QUIRK(ONSPEC2, IMAGEMATE_SDDR55, 0x0000, 0xffff, 408 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 409 USB_QUIRK(PANASONIC, KXL840AN, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 410 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_GETMAXLUN), 411 USB_QUIRK(PANASONIC, KXLCB20AN, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 412 UQ_MSC_FORCE_PROTO_SCSI), 413 USB_QUIRK(PANASONIC, KXLCB35AN, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 414 UQ_MSC_FORCE_PROTO_SCSI), 415 USB_QUIRK(PANASONIC, LS120CAM, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_UFI), 416 USB_QUIRK(PLEXTOR, 40_12_40U, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 417 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_TEST_UNIT_READY), 418 USB_QUIRK(PNY, ATTACHE2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 419 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE, 420 UQ_MSC_NO_START_STOP), 421 USB_QUIRK(PROLIFIC, PL2506, 0x0000, 0xffff, 422 UQ_MSC_NO_SYNC_CACHE, UQ_MSC_NO_PREVENT_ALLOW), 423 USB_QUIRK_VP(USB_VENDOR_SAMSUNG_TECHWIN, 424 USB_PRODUCT_SAMSUNG_TECHWIN_DIGIMAX_410, UQ_MSC_FORCE_WIRE_BBB, 425 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 426 USB_QUIRK(SANDISK, SDDR05A, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 427 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1, 428 UQ_MSC_NO_GETMAXLUN), 429 USB_QUIRK(SANDISK, SDDR09, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI, 430 UQ_MSC_READ_CAP_OFFBY1, UQ_MSC_NO_GETMAXLUN), 431 USB_QUIRK(SANDISK, SDDR12, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 432 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1, 433 UQ_MSC_NO_GETMAXLUN), 434 USB_QUIRK(SANDISK, SDCZ2_128, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 435 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE, 436 UQ_MSC_NO_SYNC_CACHE), 437 USB_QUIRK(SANDISK, SDCZ2_256, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 438 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 439 USB_QUIRK(SANDISK, SDCZ4_128, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 440 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 441 USB_QUIRK(SANDISK, SDCZ4_256, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 442 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 443 USB_QUIRK(SANDISK, SDCZ48_32, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, 444 UQ_MSC_NO_TEST_UNIT_READY), 445 USB_QUIRK(SANDISK, SDDR31, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 446 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1), 447 USB_QUIRK(SANDISK, IMAGEMATE_SDDR289, 0x0000, 0xffff, 448 UQ_MSC_NO_SYNC_CACHE, UQ_MSC_NO_GETMAXLUN), 449 USB_QUIRK(SCANLOGIC, SL11R, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 450 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_INQUIRY), 451 USB_QUIRK(SHUTTLE, EUSB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 452 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_TEST_UNIT_READY, 453 UQ_MSC_NO_START_STOP, UQ_MSC_SHUTTLE_INIT), 454 USB_QUIRK(SHUTTLE, CDRW, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 455 UQ_MSC_FORCE_PROTO_ATAPI), 456 USB_QUIRK(SHUTTLE, CF, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 457 UQ_MSC_FORCE_PROTO_ATAPI), 458 USB_QUIRK(SHUTTLE, EUSBATAPI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 459 UQ_MSC_FORCE_PROTO_ATAPI), 460 USB_QUIRK(SHUTTLE, EUSBCFSM, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 461 USB_QUIRK(SHUTTLE, EUSCSI, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 462 UQ_MSC_FORCE_PROTO_SCSI), 463 USB_QUIRK(SHUTTLE, HIFD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 464 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 465 USB_QUIRK(SHUTTLE, SDDR09, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI, 466 UQ_MSC_NO_GETMAXLUN), 467 USB_QUIRK(SHUTTLE, ZIOMMC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 468 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 469 USB_QUIRK(SIGMATEL, I_BEAD100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 470 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_SHUTTLE_INIT), 471 USB_QUIRK(SIIG, WINTERREADER, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 472 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_IGNORE_RESIDUE), 473 USB_QUIRK(SKANHEX, MD_7425, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 474 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 475 USB_QUIRK(SKANHEX, SX_520Z, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 476 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 477 USB_QUIRK(SONY, HANDYCAM, 0x0500, 0x0500, UQ_MSC_FORCE_WIRE_CBI, 478 UQ_MSC_FORCE_PROTO_RBC, UQ_MSC_RBC_PAD_TO_12), 479 USB_QUIRK(SONY, CLIE_40_MS, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 480 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 481 USB_QUIRK(SONY, DSC, 0x0500, 0x0500, UQ_MSC_FORCE_WIRE_CBI, 482 UQ_MSC_FORCE_PROTO_RBC, UQ_MSC_RBC_PAD_TO_12), 483 USB_QUIRK(SONY, DSC, 0x0600, 0x0600, UQ_MSC_FORCE_WIRE_CBI, 484 UQ_MSC_FORCE_PROTO_RBC, UQ_MSC_RBC_PAD_TO_12), 485 USB_QUIRK(SONY, DSC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 486 UQ_MSC_FORCE_PROTO_RBC), 487 USB_QUIRK(SONY, HANDYCAM, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 488 UQ_MSC_FORCE_PROTO_RBC), 489 USB_QUIRK(SONY, MSC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 490 UQ_MSC_FORCE_PROTO_RBC), 491 USB_QUIRK(SONY, MS_MSC_U03, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 492 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_GETMAXLUN), 493 USB_QUIRK(SONY, MS_NW_MS7, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 494 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 495 USB_QUIRK(SONY, MS_PEG_N760C, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 496 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 497 USB_QUIRK(SONY, MSACUS1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 498 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN), 499 USB_QUIRK(SONY, PORTABLE_HDD_V2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 500 UQ_MSC_FORCE_PROTO_SCSI), 501 USB_QUIRK(STMICRO, ST72682, 0x0000, 0xffff, UQ_MSC_NO_PREVENT_ALLOW), 502 USB_QUIRK(SUPERTOP, IDE, 0x0000, 0xffff, UQ_MSC_IGNORE_RESIDUE, 503 UQ_MSC_NO_SYNC_CACHE), 504 USB_QUIRK(SUPERTOP, FLASHDRIVE, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY, 505 UQ_MSC_NO_SYNC_CACHE), 506 USB_QUIRK(TAUGA, CAMERAMATE, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 507 USB_QUIRK(TEAC, FD05PUB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 508 UQ_MSC_FORCE_PROTO_UFI), 509 USB_QUIRK(TECLAST, TLC300, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY, 510 UQ_MSC_NO_SYNC_CACHE), 511 USB_QUIRK(TREK, MEMKEY, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 512 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 513 USB_QUIRK(TREK, THUMBDRIVE_8MB, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 514 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_IGNORE_RESIDUE), 515 USB_QUIRK(TRUMPION, C3310, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 516 UQ_MSC_FORCE_PROTO_UFI), 517 USB_QUIRK(TRUMPION, MP3, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_RBC), 518 USB_QUIRK(TRUMPION, T33520, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI), 519 USB_QUIRK(TWINMOS, MDIV, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 520 UQ_MSC_FORCE_PROTO_SCSI), 521 USB_QUIRK(VIA, USB2IDEBRIDGE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 522 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_SYNC_CACHE), 523 USB_QUIRK(VIVITAR, 35XX, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 524 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 525 USB_QUIRK(WESTERN, COMBO, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 526 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 527 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 528 USB_QUIRK(WESTERN, EXTHDD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 529 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 530 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 531 USB_QUIRK(WESTERN, MYBOOK, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 532 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY_EVPD, 533 UQ_MSC_NO_SYNC_CACHE), 534 USB_QUIRK(WESTERN, MYPASSPORT_00, 0x0000, 0xffff, UQ_MSC_FORCE_SHORT_INQ), 535 USB_QUIRK(WESTERN, MYPASSPORT_01, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 536 USB_QUIRK(WESTERN, MYPASSPORT_02, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 537 USB_QUIRK(WESTERN, MYPASSPORT_03, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 538 USB_QUIRK(WESTERN, MYPASSPORT_04, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 539 USB_QUIRK(WESTERN, MYPASSPORT_05, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 540 USB_QUIRK(WESTERN, MYPASSPORT_06, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 541 USB_QUIRK(WESTERN, MYPASSPORT_07, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 542 USB_QUIRK(WESTERN, MYPASSPORT_08, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 543 USB_QUIRK(WESTERN, MYPASSPORT_09, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 544 USB_QUIRK(WESTERN, MYPASSPORT_10, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 545 USB_QUIRK(WESTERN, MYPASSPORT_11, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 546 USB_QUIRK(WESTERN, MYPASSPORTES_00, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 547 USB_QUIRK(WESTERN, MYPASSPORTES_01, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 548 USB_QUIRK(WESTERN, MYPASSPORTES_02, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 549 USB_QUIRK(WESTERN, MYPASSPORTES_03, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 550 USB_QUIRK(WESTERN, MYPASSPORTES_04, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 551 USB_QUIRK(WESTERN, MYPASSPORTES_05, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 552 USB_QUIRK(WESTERN, MYPASSPORTES_06, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 553 USB_QUIRK(WESTERN, MYPASSPORTES_07, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 554 USB_QUIRK(WESTERN, MYPASSPORTES_08, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 555 USB_QUIRK(WESTERN, MYPASSPORTES_09, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 556 USB_QUIRK(WINMAXGROUP, FLASH64MC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 557 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY), 558 USB_QUIRK(YANO, FW800HD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 559 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ, 560 UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE), 561 USB_QUIRK(YANO, U640MO, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I, 562 UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_FORCE_SHORT_INQ), 563 USB_QUIRK(YEDATA, FLASHBUSTERU, 0x0000, 0x007F, UQ_MSC_FORCE_WIRE_CBI, 564 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_FLOPPY_SPEED, 565 UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_GETMAXLUN), 566 USB_QUIRK(YEDATA, FLASHBUSTERU, 0x0080, 0x0080, UQ_MSC_FORCE_WIRE_CBI_I, 567 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_FLOPPY_SPEED, 568 UQ_MSC_NO_TEST_UNIT_READY, UQ_MSC_NO_GETMAXLUN), 569 USB_QUIRK(YEDATA, FLASHBUSTERU, 0x0081, 0xFFFF, UQ_MSC_FORCE_WIRE_CBI_I, 570 UQ_MSC_FORCE_PROTO_UFI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_FLOPPY_SPEED, 571 UQ_MSC_NO_GETMAXLUN), 572 USB_QUIRK(ZORAN, EX20DSC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI, 573 UQ_MSC_FORCE_PROTO_ATAPI), 574 USB_QUIRK(MEIZU, M6_SL, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB, 575 UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY, UQ_MSC_NO_SYNC_CACHE), 576 USB_QUIRK(TOSHIBA, TRANSMEMORY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, 577 UQ_MSC_NO_PREVENT_ALLOW), 578 USB_QUIRK(VIALABS, USB30SATABRIDGE, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE), 579 USB_QUIRK(QUALCOMMINC, ZTE_MF730M, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN, 580 UQ_MSC_NO_INQUIRY, UQ_CFG_INDEX_0), 581 USB_QUIRK(SMART2, G2MEMKEY, 0x0000, 0xffff, UQ_MSC_NO_INQUIRY), 582 USB_QUIRK(RALINK, RT_STOR, 0x0001, 0x0001, UQ_MSC_IGNORE), 583 USB_QUIRK(REALTEK, RTW8821CU_CD, 0x0001, 0x0001, UQ_MSC_IGNORE), 584 /* Non-standard USB MIDI devices */ 585 USB_QUIRK(ROLAND, UM1, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 586 USB_QUIRK(ROLAND, SC8850, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 587 USB_QUIRK(ROLAND, SD90, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 588 USB_QUIRK(ROLAND, UM880N, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 589 USB_QUIRK(ROLAND, UA100, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 590 USB_QUIRK(ROLAND, UM4, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 591 USB_QUIRK(ROLAND, U8, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 592 USB_QUIRK(ROLAND, UM2, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 593 USB_QUIRK(ROLAND, SC8820, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 594 USB_QUIRK(ROLAND, PC300, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 595 USB_QUIRK(ROLAND, SK500, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 596 USB_QUIRK(ROLAND, SCD70, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 597 USB_QUIRK(ROLAND, UM550, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 598 USB_QUIRK(ROLAND, SD20, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 599 USB_QUIRK(ROLAND, SD80, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 600 USB_QUIRK(ROLAND, UA700, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 601 USB_QUIRK(ROLAND, PCR300, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 602 USB_QUIRK(EGO, M4U, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 603 USB_QUIRK(LOGILINK, U2M, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 604 USB_QUIRK(MEDELI, DD305, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI, UQ_MATCH_VENDOR_ONLY), 605 USB_QUIRK(REDOCTANE, GHMIDI, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 606 USB_QUIRK(TEXTECH, U2M_1, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 607 USB_QUIRK(TEXTECH, U2M_2, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 608 USB_QUIRK(WCH2, U2M, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI), 609 610 /* Non-standard USB AUDIO devices */ 611 USB_QUIRK(MAUDIO, FASTTRACKULTRA, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 612 USB_QUIRK(MAUDIO, FASTTRACKULTRA8R, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 613 USB_QUIRK(CMEDIA, CM6206, 0x0000, 0xffff, UQ_AU_SET_SPDIF_CM6206), 614 USB_QUIRK(PLOYTEC, SPL_CRIMSON_1, 0x0000, 0xffff, UQ_CFG_INDEX_1), 615 USB_QUIRK(ROLAND, UA25EX_AD, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), 616 617 /* 618 * Quirks for manufacturers which USB devices does not respond 619 * after issuing non-supported commands: 620 */ 621 USB_QUIRK(ALCOR, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MSC_NO_TEST_UNIT_READY, UQ_MATCH_VENDOR_ONLY), 622 USB_QUIRK(APPLE, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY), 623 USB_QUIRK(FEIYA, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY), 624 USB_QUIRK(REALTEK, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY), 625 USB_QUIRK(INITIO, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY), 626 627 /* DYMO LabelManager Pnp */ 628 USB_QUIRK(DYMO, LABELMANAGERPNP, 0x0000, 0xffff, UQ_MSC_DYMO_EJECT), 629 630 /* Holtek USB gaming keyboard */ 631 USB_QUIRK(HOLTEK, F85, 0x0000, 0xffff, UQ_KBD_BOOTPROTO), 632 }; 633 #undef USB_QUIRK_VP 634 #undef USB_QUIRK 635 636 static const char *usb_quirk_str[USB_QUIRK_MAX] = { 637 [UQ_NONE] = "UQ_NONE", 638 [UQ_MATCH_VENDOR_ONLY] = "UQ_MATCH_VENDOR_ONLY", 639 [UQ_AUDIO_SWAP_LR] = "UQ_AUDIO_SWAP_LR", 640 [UQ_AU_INP_ASYNC] = "UQ_AU_INP_ASYNC", 641 [UQ_AU_NO_FRAC] = "UQ_AU_NO_FRAC", 642 [UQ_AU_NO_XU] = "UQ_AU_NO_XU", 643 [UQ_BAD_ADC] = "UQ_BAD_ADC", 644 [UQ_BAD_AUDIO] = "UQ_BAD_AUDIO", 645 [UQ_BROKEN_BIDIR] = "UQ_BROKEN_BIDIR", 646 [UQ_BUS_POWERED] = "UQ_BUS_POWERED", 647 [UQ_HID_IGNORE] = "UQ_HID_IGNORE", 648 [UQ_KBD_IGNORE] = "UQ_KBD_IGNORE", 649 [UQ_KBD_BOOTPROTO] = "UQ_KBD_BOOTPROTO", 650 [UQ_UMS_IGNORE] = "UQ_UMS_IGNORE", 651 [UQ_MS_BAD_CLASS] = "UQ_MS_BAD_CLASS", 652 [UQ_MS_LEADING_BYTE] = "UQ_MS_LEADING_BYTE", 653 [UQ_MS_REVZ] = "UQ_MS_REVZ", 654 [UQ_MS_VENDOR_BTN] = "UQ_MS_VENDOR_BTN", 655 [UQ_NO_STRINGS] = "UQ_NO_STRINGS", 656 [UQ_POWER_CLAIM] = "UQ_POWER_CLAIM", 657 [UQ_SPUR_BUT_UP] = "UQ_SPUR_BUT_UP", 658 [UQ_SWAP_UNICODE] = "UQ_SWAP_UNICODE", 659 [UQ_CFG_INDEX_1] = "UQ_CFG_INDEX_1", 660 [UQ_CFG_INDEX_2] = "UQ_CFG_INDEX_2", 661 [UQ_CFG_INDEX_3] = "UQ_CFG_INDEX_3", 662 [UQ_CFG_INDEX_4] = "UQ_CFG_INDEX_4", 663 [UQ_CFG_INDEX_0] = "UQ_CFG_INDEX_0", 664 [UQ_ASSUME_CM_OVER_DATA] = "UQ_ASSUME_CM_OVER_DATA", 665 [UQ_MSC_NO_TEST_UNIT_READY] = "UQ_MSC_NO_TEST_UNIT_READY", 666 [UQ_MSC_NO_RS_CLEAR_UA] = "UQ_MSC_NO_RS_CLEAR_UA", 667 [UQ_MSC_NO_START_STOP] = "UQ_MSC_NO_START_STOP", 668 [UQ_MSC_NO_GETMAXLUN] = "UQ_MSC_NO_GETMAXLUN", 669 [UQ_MSC_NO_INQUIRY] = "UQ_MSC_NO_INQUIRY", 670 [UQ_MSC_NO_INQUIRY_EVPD] = "UQ_MSC_NO_INQUIRY_EVPD", 671 [UQ_MSC_NO_PREVENT_ALLOW] = "UQ_MSC_NO_PREVENT_ALLOW", 672 [UQ_MSC_NO_SYNC_CACHE] = "UQ_MSC_NO_SYNC_CACHE", 673 [UQ_MSC_SHUTTLE_INIT] = "UQ_MSC_SHUTTLE_INIT", 674 [UQ_MSC_ALT_IFACE_1] = "UQ_MSC_ALT_IFACE_1", 675 [UQ_MSC_FLOPPY_SPEED] = "UQ_MSC_FLOPPY_SPEED", 676 [UQ_MSC_IGNORE_RESIDUE] = "UQ_MSC_IGNORE_RESIDUE", 677 [UQ_MSC_WRONG_CSWSIG] = "UQ_MSC_WRONG_CSWSIG", 678 [UQ_MSC_RBC_PAD_TO_12] = "UQ_MSC_RBC_PAD_TO_12", 679 [UQ_MSC_READ_CAP_OFFBY1] = "UQ_MSC_READ_CAP_OFFBY1", 680 [UQ_MSC_FORCE_SHORT_INQ] = "UQ_MSC_FORCE_SHORT_INQ", 681 [UQ_MSC_FORCE_WIRE_BBB] = "UQ_MSC_FORCE_WIRE_BBB", 682 [UQ_MSC_FORCE_WIRE_CBI] = "UQ_MSC_FORCE_WIRE_CBI", 683 [UQ_MSC_FORCE_WIRE_CBI_I] = "UQ_MSC_FORCE_WIRE_CBI_I", 684 [UQ_MSC_FORCE_PROTO_SCSI] = "UQ_MSC_FORCE_PROTO_SCSI", 685 [UQ_MSC_FORCE_PROTO_ATAPI] = "UQ_MSC_FORCE_PROTO_ATAPI", 686 [UQ_MSC_FORCE_PROTO_UFI] = "UQ_MSC_FORCE_PROTO_UFI", 687 [UQ_MSC_FORCE_PROTO_RBC] = "UQ_MSC_FORCE_PROTO_RBC", 688 [UQ_MSC_IGNORE] = "UQ_MSC_IGNORE", 689 [UQ_MSC_EJECT_HUAWEI] = "UQ_MSC_EJECT_HUAWEI", 690 [UQ_MSC_EJECT_SIERRA] = "UQ_MSC_EJECT_SIERRA", 691 [UQ_MSC_EJECT_SCSIEJECT] = "UQ_MSC_EJECT_SCSIEJECT", 692 [UQ_MSC_EJECT_REZERO] = "UQ_MSC_EJECT_REZERO", 693 [UQ_MSC_EJECT_ZTESTOR] = "UQ_MSC_EJECT_ZTESTOR", 694 [UQ_MSC_EJECT_CMOTECH] = "UQ_MSC_EJECT_CMOTECH", 695 [UQ_MSC_EJECT_WAIT] = "UQ_MSC_EJECT_WAIT", 696 [UQ_MSC_EJECT_SAEL_M460] = "UQ_MSC_EJECT_SAEL_M460", 697 [UQ_MSC_EJECT_HUAWEISCSI] = "UQ_MSC_EJECT_HUAWEISCSI", 698 [UQ_MSC_EJECT_HUAWEISCSI2] = "UQ_MSC_EJECT_HUAWEISCSI2", 699 [UQ_MSC_EJECT_TCT] = "UQ_MSC_EJECT_TCT", 700 [UQ_BAD_MIDI] = "UQ_BAD_MIDI", 701 [UQ_AU_VENDOR_CLASS] = "UQ_AU_VENDOR_CLASS", 702 [UQ_SINGLE_CMD_MIDI] = "UQ_SINGLE_CMD_MIDI", 703 [UQ_MSC_DYMO_EJECT] = "UQ_MSC_DYMO_EJECT", 704 [UQ_AU_SET_SPDIF_CM6206] = "UQ_AU_SET_SPDIF_CM6206", 705 [UQ_WMT_IGNORE] = "UQ_WMT_IGNORE", 706 }; 707 708 /*------------------------------------------------------------------------* 709 * usb_quirkstr 710 * 711 * This function converts an USB quirk code into a string. 712 *------------------------------------------------------------------------*/ 713 static const char * 714 usb_quirkstr(uint16_t quirk) 715 { 716 return ((quirk < USB_QUIRK_MAX && usb_quirk_str[quirk] != NULL) ? 717 usb_quirk_str[quirk] : "UQ_UNKNOWN"); 718 } 719 720 /*------------------------------------------------------------------------* 721 * usb_strquirk 722 * 723 * This function converts a string into a USB quirk code. 724 * 725 * Returns: 726 * Less than USB_QUIRK_MAX: Quirk code 727 * Else: Quirk code not found 728 *------------------------------------------------------------------------*/ 729 static uint16_t 730 usb_strquirk(const char *str, size_t len) 731 { 732 const char *quirk; 733 uint16_t x; 734 735 for (x = 0; x != USB_QUIRK_MAX; x++) { 736 quirk = usb_quirkstr(x); 737 if (strncmp(str, quirk, len) == 0 && 738 quirk[len] == 0) 739 break; 740 } 741 return (x); 742 } 743 744 /*------------------------------------------------------------------------* 745 * usb_test_quirk_by_info 746 * 747 * Returns: 748 * 0: Quirk not found 749 * Else: Quirk found 750 *------------------------------------------------------------------------*/ 751 static uint8_t 752 usb_test_quirk_by_info(const struct usbd_lookup_info *info, uint16_t quirk) 753 { 754 uint16_t x; 755 uint16_t y; 756 757 if (quirk == UQ_NONE) 758 goto done; 759 760 USB_MTX_LOCK(&usb_quirk_mtx); 761 762 for (x = 0; x != USB_DEV_QUIRKS_MAX; x++) { 763 /* see if quirk information does not match */ 764 if ((usb_quirks[x].vid != info->idVendor) || 765 (usb_quirks[x].lo_rev > info->bcdDevice) || 766 (usb_quirks[x].hi_rev < info->bcdDevice)) { 767 continue; 768 } 769 /* see if quirk only should match vendor ID */ 770 if (usb_quirks[x].pid != info->idProduct) { 771 if (usb_quirks[x].pid != 0) 772 continue; 773 774 for (y = 0; y != USB_SUB_QUIRKS_MAX; y++) { 775 if (usb_quirks[x].quirks[y] == UQ_MATCH_VENDOR_ONLY) 776 break; 777 } 778 if (y == USB_SUB_QUIRKS_MAX) 779 continue; 780 } 781 /* lookup quirk */ 782 for (y = 0; y != USB_SUB_QUIRKS_MAX; y++) { 783 if (usb_quirks[x].quirks[y] == quirk) { 784 USB_MTX_UNLOCK(&usb_quirk_mtx); 785 DPRINTF("Found quirk '%s'.\n", usb_quirkstr(quirk)); 786 return (1); 787 } 788 } 789 } 790 USB_MTX_UNLOCK(&usb_quirk_mtx); 791 done: 792 return (0); /* no quirk match */ 793 } 794 795 static struct usb_quirk_entry * 796 usb_quirk_get_entry(uint16_t vid, uint16_t pid, 797 uint16_t lo_rev, uint16_t hi_rev, uint8_t do_alloc) 798 { 799 uint16_t x; 800 801 USB_MTX_ASSERT(&usb_quirk_mtx, MA_OWNED); 802 803 if ((vid | pid | lo_rev | hi_rev) == 0) { 804 /* all zero - special case */ 805 return (usb_quirks + USB_DEV_QUIRKS_MAX - 1); 806 } 807 /* search for an existing entry */ 808 for (x = 0; x != USB_DEV_QUIRKS_MAX; x++) { 809 /* see if quirk information does not match */ 810 if ((usb_quirks[x].vid != vid) || 811 (usb_quirks[x].pid != pid) || 812 (usb_quirks[x].lo_rev != lo_rev) || 813 (usb_quirks[x].hi_rev != hi_rev)) { 814 continue; 815 } 816 return (usb_quirks + x); 817 } 818 819 if (do_alloc == 0) { 820 /* no match */ 821 return (NULL); 822 } 823 /* search for a free entry */ 824 for (x = 0; x != USB_DEV_QUIRKS_MAX; x++) { 825 /* see if quirk information does not match */ 826 if ((usb_quirks[x].vid | 827 usb_quirks[x].pid | 828 usb_quirks[x].lo_rev | 829 usb_quirks[x].hi_rev) != 0) { 830 continue; 831 } 832 usb_quirks[x].vid = vid; 833 usb_quirks[x].pid = pid; 834 usb_quirks[x].lo_rev = lo_rev; 835 usb_quirks[x].hi_rev = hi_rev; 836 837 return (usb_quirks + x); 838 } 839 840 /* no entry found */ 841 return (NULL); 842 } 843 844 /*------------------------------------------------------------------------* 845 * usb_quirk_ioctl - handle quirk IOCTLs 846 * 847 * Returns: 848 * 0: Success 849 * Else: Failure 850 *------------------------------------------------------------------------*/ 851 static int 852 usb_quirk_ioctl(unsigned long cmd, caddr_t data, 853 int fflag, struct thread *td) 854 { 855 struct usb_gen_quirk *pgq; 856 struct usb_quirk_entry *pqe; 857 uint32_t x; 858 uint32_t y; 859 int err; 860 861 switch (cmd) { 862 case USB_DEV_QUIRK_GET: 863 pgq = (void *)data; 864 x = pgq->index % USB_SUB_QUIRKS_MAX; 865 y = pgq->index / USB_SUB_QUIRKS_MAX; 866 if (y >= USB_DEV_QUIRKS_MAX) { 867 return (EINVAL); 868 } 869 USB_MTX_LOCK(&usb_quirk_mtx); 870 /* copy out data */ 871 pgq->vid = usb_quirks[y].vid; 872 pgq->pid = usb_quirks[y].pid; 873 pgq->bcdDeviceLow = usb_quirks[y].lo_rev; 874 pgq->bcdDeviceHigh = usb_quirks[y].hi_rev; 875 strlcpy(pgq->quirkname, 876 usb_quirkstr(usb_quirks[y].quirks[x]), 877 sizeof(pgq->quirkname)); 878 USB_MTX_UNLOCK(&usb_quirk_mtx); 879 return (0); /* success */ 880 881 case USB_QUIRK_NAME_GET: 882 pgq = (void *)data; 883 x = pgq->index; 884 if (x >= USB_QUIRK_MAX) { 885 return (EINVAL); 886 } 887 strlcpy(pgq->quirkname, 888 usb_quirkstr(x), sizeof(pgq->quirkname)); 889 return (0); /* success */ 890 891 case USB_DEV_QUIRK_ADD: 892 pgq = (void *)data; 893 894 /* check privileges */ 895 err = priv_check(curthread, PRIV_DRIVER); 896 if (err) { 897 return (err); 898 } 899 /* convert quirk string into numerical */ 900 for (y = 0; y != USB_DEV_QUIRKS_MAX; y++) { 901 if (strcmp(pgq->quirkname, usb_quirkstr(y)) == 0) { 902 break; 903 } 904 } 905 if (y == USB_DEV_QUIRKS_MAX) { 906 return (EINVAL); 907 } 908 if (y == UQ_NONE) { 909 return (EINVAL); 910 } 911 USB_MTX_LOCK(&usb_quirk_mtx); 912 pqe = usb_quirk_get_entry(pgq->vid, pgq->pid, 913 pgq->bcdDeviceLow, pgq->bcdDeviceHigh, 1); 914 if (pqe == NULL) { 915 USB_MTX_UNLOCK(&usb_quirk_mtx); 916 return (EINVAL); 917 } 918 for (x = 0; x != USB_SUB_QUIRKS_MAX; x++) { 919 if (pqe->quirks[x] == UQ_NONE) { 920 pqe->quirks[x] = y; 921 break; 922 } 923 } 924 USB_MTX_UNLOCK(&usb_quirk_mtx); 925 if (x == USB_SUB_QUIRKS_MAX) { 926 return (ENOMEM); 927 } 928 return (0); /* success */ 929 930 case USB_DEV_QUIRK_REMOVE: 931 pgq = (void *)data; 932 /* check privileges */ 933 err = priv_check(curthread, PRIV_DRIVER); 934 if (err) { 935 return (err); 936 } 937 /* convert quirk string into numerical */ 938 for (y = 0; y != USB_DEV_QUIRKS_MAX; y++) { 939 if (strcmp(pgq->quirkname, usb_quirkstr(y)) == 0) { 940 break; 941 } 942 } 943 if (y == USB_DEV_QUIRKS_MAX) { 944 return (EINVAL); 945 } 946 if (y == UQ_NONE) { 947 return (EINVAL); 948 } 949 USB_MTX_LOCK(&usb_quirk_mtx); 950 pqe = usb_quirk_get_entry(pgq->vid, pgq->pid, 951 pgq->bcdDeviceLow, pgq->bcdDeviceHigh, 0); 952 if (pqe == NULL) { 953 USB_MTX_UNLOCK(&usb_quirk_mtx); 954 return (EINVAL); 955 } 956 for (x = 0; x != USB_SUB_QUIRKS_MAX; x++) { 957 if (pqe->quirks[x] == y) { 958 pqe->quirks[x] = UQ_NONE; 959 break; 960 } 961 } 962 if (x == USB_SUB_QUIRKS_MAX) { 963 USB_MTX_UNLOCK(&usb_quirk_mtx); 964 return (ENOMEM); 965 } 966 for (x = 0; x != USB_SUB_QUIRKS_MAX; x++) { 967 if (pqe->quirks[x] != UQ_NONE) { 968 break; 969 } 970 } 971 if (x == USB_SUB_QUIRKS_MAX) { 972 /* all quirk entries are unused - release */ 973 memset(pqe, 0, sizeof(*pqe)); 974 } 975 USB_MTX_UNLOCK(&usb_quirk_mtx); 976 return (0); /* success */ 977 978 default: 979 break; 980 } 981 return (ENOIOCTL); 982 } 983 984 /*------------------------------------------------------------------------* 985 * usb_quirk_strtou16 986 * 987 * Helper function to scan a 16-bit integer. 988 *------------------------------------------------------------------------*/ 989 static uint16_t 990 usb_quirk_strtou16(const char **pptr, const char *name, const char *what) 991 { 992 unsigned long value; 993 char *end; 994 995 value = strtoul(*pptr, &end, 0); 996 if (value > 65535 || *pptr == end || (*end != ' ' && *end != '\t')) { 997 printf("%s: %s 16-bit %s value set to zero\n", 998 name, what, *end == 0 ? "incomplete" : "invalid"); 999 return (0); 1000 } 1001 *pptr = end + 1; 1002 return ((uint16_t)value); 1003 } 1004 1005 /*------------------------------------------------------------------------* 1006 * usb_quirk_add_entry_from_str 1007 * 1008 * Add a USB quirk entry from string. 1009 * "VENDOR PRODUCT LO_REV HI_REV QUIRK[,QUIRK[,...]]" 1010 *------------------------------------------------------------------------*/ 1011 static void 1012 usb_quirk_add_entry_from_str(const char *name, const char *env) 1013 { 1014 struct usb_quirk_entry entry = { }; 1015 struct usb_quirk_entry *new; 1016 uint16_t quirk_idx; 1017 uint16_t quirk; 1018 const char *end; 1019 1020 /* check for invalid environment variable */ 1021 if (name == NULL || env == NULL) 1022 return; 1023 1024 if (bootverbose) 1025 printf("Adding USB QUIRK '%s' = '%s'\n", name, env); 1026 1027 /* parse device information */ 1028 entry.vid = usb_quirk_strtou16(&env, name, "Vendor ID"); 1029 entry.pid = usb_quirk_strtou16(&env, name, "Product ID"); 1030 entry.lo_rev = usb_quirk_strtou16(&env, name, "Low revision"); 1031 entry.hi_rev = usb_quirk_strtou16(&env, name, "High revision"); 1032 1033 /* parse quirk information */ 1034 quirk_idx = 0; 1035 while (*env != 0 && quirk_idx != USB_SUB_QUIRKS_MAX) { 1036 /* skip whitespace before quirks */ 1037 while (*env == ' ' || *env == '\t') 1038 env++; 1039 1040 /* look for quirk separation character */ 1041 end = strchr(env, ','); 1042 if (end == NULL) 1043 end = env + strlen(env); 1044 1045 /* lookup quirk in string table */ 1046 quirk = usb_strquirk(env, end - env); 1047 if (quirk < USB_QUIRK_MAX) { 1048 entry.quirks[quirk_idx++] = quirk; 1049 } else { 1050 printf("%s: unknown USB quirk '%.*s' (skipped)\n", 1051 name, (int)(end - env), env); 1052 } 1053 env = end; 1054 1055 /* skip quirk delimiter, if any */ 1056 if (*env != 0) 1057 env++; 1058 } 1059 1060 /* register quirk */ 1061 if (quirk_idx != 0) { 1062 if (*env != 0) { 1063 printf("%s: Too many USB quirks, only %d allowed!\n", 1064 name, USB_SUB_QUIRKS_MAX); 1065 } 1066 USB_MTX_LOCK(&usb_quirk_mtx); 1067 new = usb_quirk_get_entry(entry.vid, entry.pid, 1068 entry.lo_rev, entry.hi_rev, 1); 1069 if (new == NULL) 1070 printf("%s: USB quirks table is full!\n", name); 1071 else 1072 memcpy(new->quirks, entry.quirks, sizeof(entry.quirks)); 1073 USB_MTX_UNLOCK(&usb_quirk_mtx); 1074 } else { 1075 printf("%s: No USB quirks found!\n", name); 1076 } 1077 } 1078 1079 static void 1080 usb_quirk_init(void *arg) 1081 { 1082 char envkey[sizeof(USB_QUIRK_ENVROOT) + 2]; /* 2 digits max, 0 to 99 */ 1083 int i; 1084 1085 /* initialize mutex */ 1086 mtx_init(&usb_quirk_mtx, "USB quirk", NULL, MTX_DEF); 1087 1088 /* look for quirks defined by the environment variable */ 1089 for (i = 0; i != 100; i++) { 1090 snprintf(envkey, sizeof(envkey), USB_QUIRK_ENVROOT "%d", i); 1091 1092 /* Stop at first undefined var */ 1093 if (!testenv(envkey)) 1094 break; 1095 1096 /* parse environment variable */ 1097 usb_quirk_add_entry_from_str(envkey, kern_getenv(envkey)); 1098 } 1099 1100 /* register our function */ 1101 usb_test_quirk_p = &usb_test_quirk_by_info; 1102 usb_quirk_ioctl_p = &usb_quirk_ioctl; 1103 } 1104 1105 static void 1106 usb_quirk_uninit(void *arg) 1107 { 1108 usb_quirk_unload(arg); 1109 1110 /* destroy mutex */ 1111 mtx_destroy(&usb_quirk_mtx); 1112 } 1113 1114 SYSINIT(usb_quirk_init, SI_SUB_LOCK, SI_ORDER_FIRST, usb_quirk_init, NULL); 1115 SYSUNINIT(usb_quirk_uninit, SI_SUB_LOCK, SI_ORDER_ANY, usb_quirk_uninit, NULL); 1116