USB_QUIRK(4)

✨ usb_quirk β€” the USB quirks module ✨

okay bestie, pull up a chair πŸŽ€ this is USB_QUIRK(4) from the Kernel Interfaces Manual, and it's literally the glow-up your janky USB hardware has been begging for πŸ’…


🌸 NAME 🌸

usb_quirk β€” the USB quirks module, aka the "your device is lying but we still love it" module 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

so to bake this module straight into the kernel, you drop this line into your kernel config file:

device usb

orrr, if you'd rather load it at boot time (very main character of you), you put this in loader.conf(5):

usb_quirk_load="YES"

πŸ’– DESCRIPTION πŸ’–

The usb_quirk module is the one that lets you dynamically add and remove quirks for USB devices, using usbconfig(8). no cap. it's giving fix-it energy ✨

πŸŽ€ General quirks πŸŽ€

  • UQ_AUDIO_SWAP_LR β€” swap left and right channels, because your ears deserve the correct sides
  • UQ_AU_INP_ASYNC β€” the input is async, despite what it claims about being adaptive
  • UQ_AU_NO_FRAC β€” do not adjust for fractional samples
  • UQ_AU_NO_XU β€” this audio device has a broken extension unit 😭
  • UQ_AU_VENDOR_CLASS β€” the audio device uses vendor class to identify itself (identity crisis, honestly)
  • UQ_AU_SET_SPDIF_CM6206 β€” this audio device needs special programming to enable S/PDIF audio output
  • UQ_BAD_ADC β€” bad audio spec version number
  • UQ_BAD_AUDIO β€” the device claims to be audio class, but it is NOT. liar behavior πŸ’€
  • UQ_BROKEN_BIDIR β€” printer has broken bidir mode
  • UQ_BUS_POWERED β€” the device is bus powered, despite its claims
  • UQ_HID_IGNORE β€” this device should be ignored by the hid class
  • UQ_KBD_IGNORE β€” this device should be ignored by the kbd class
  • UQ_KBD_BOOTPROTO β€” this device should set the boot protocol
  • UQ_UMS_IGNORE β€” this device should be ignored by the ums class
  • UQ_MS_BAD_CLASS β€” does not identify properly (we've all been there πŸ™ˆ)
  • UQ_MS_LEADING_BYTE β€” the mouse sends an unknown leading byte
  • UQ_MS_REVZ β€” the mouse has its Z-axis reversed
  • UQ_NO_STRINGS β€” string descriptors are broken
  • UQ_POWER_CLAIM β€” the hub lies about its power status
  • UQ_SPUR_BUT_UP β€” spurious mouse button up events (stop clicking at me!!)
  • UQ_SWAP_UNICODE β€” has some Unicode strings swapped
  • UQ_CFG_INDEX_1 β€” select configuration index 1 by default
  • UQ_CFG_INDEX_2 β€” select configuration index 2 by default
  • UQ_CFG_INDEX_3 β€” select configuration index 3 by default
  • UQ_CFG_INDEX_4 β€” select configuration index 4 by default
  • UQ_CFG_INDEX_0 β€” select configuration index 0 by default
  • UQ_ASSUME_CM_OVER_DATA β€” assume cm over data feature
  • UQ_WMT_IGNORE β€” this device should be ignored by the wmt driver

πŸ’… USB Mass Storage quirks πŸ’…

  • UQ_MSC_NO_TEST_UNIT_READY β€” send start/stop instead of TUR
  • UQ_MSC_NO_RS_CLEAR_UA β€” does not reset Unit Att.
  • UQ_MSC_NO_START_STOP β€” does not support start/stop
  • UQ_MSC_NO_GETMAXLUN β€” does not support get max LUN
  • UQ_MSC_NO_INQUIRY β€” fake generic inq response
  • UQ_MSC_NO_INQUIRY_EVPD β€” does not support inq EVPD
  • UQ_MSC_NO_SYNC_CACHE β€” does not support sync cache
  • UQ_MSC_SHUTTLE_INIT β€” requires Shuttle init sequence
  • UQ_MSC_ALT_IFACE_1 β€” switch to alternate interface 1
  • UQ_MSC_FLOPPY_SPEED β€” does floppy speeds (20kb/s) 🐌 iconic retro moment
  • UQ_MSC_IGNORE_RESIDUE β€” gets residue wrong
  • UQ_MSC_WRONG_CSWSIG β€” uses wrong CSW signature
  • UQ_MSC_RBC_PAD_TO_12 β€” pad RBC requests to 12 bytes
  • UQ_MSC_READ_CAP_OFFBY1 β€” reports sector count, not max sec.
  • UQ_MSC_FORCE_SHORT_INQ β€” does not support full inq.
  • UQ_MSC_FORCE_WIRE_BBB β€” force BBB wire protocol
  • UQ_MSC_FORCE_WIRE_CBI β€” force CBI wire protocol
  • UQ_MSC_FORCE_WIRE_CBI_I β€” force CBI with int. wire protocol
  • UQ_MSC_FORCE_PROTO_SCSI β€” force SCSI command protocol
  • UQ_MSC_FORCE_PROTO_ATAPI β€” force ATAPI command protocol
  • UQ_MSC_FORCE_PROTO_UFI β€” force UFI command protocol
  • UQ_MSC_FORCE_PROTO_RBC β€” force RBC command protocol

🌈 3G Datacard (u3g) quirks 🌈

  • UQ_MSC_EJECT_HUAWEI β€” ejects after Huawei USB command
  • UQ_MSC_EJECT_SIERRA β€” ejects after Sierra USB command
  • UQ_MSC_EJECT_SCSIEJECT β€” ejects after SCSI eject command 0x1b0000000200
  • UQ_MSC_EJECT_REZERO β€” ejects after SCSI rezero command 0x010000000000
  • UQ_MSC_EJECT_ZTESTOR β€” ejects after ZTE SCSI command 0x850101011801010101010000
  • UQ_MSC_EJECT_CMOTECH β€” ejects after C-motech SCSI command 0xff52444556434847
  • UQ_MSC_EJECT_WAIT β€” wait for the device to eject
  • UQ_MSC_EJECT_SAEL_M460 β€” ejects after Sael USB commands
  • UQ_MSC_EJECT_HUAWEISCSI β€” ejects after Huawei SCSI command 0x11060000000000000000000000000000
  • UQ_MSC_EJECT_TCT β€” ejects after TCT SCSI command 0x06f504025270
  • UQ_MSC_DYMO_EJECT β€” ejects after HID command 0x1b5a01
psst πŸ‘€ for the complete list of supported quirks, peek at /sys/dev/usb/quirk/usb_quirk.h or run usbconfig dump_quirk_names. slay.

πŸ”₯ LOADER TUNABLE πŸ”₯

you can set the following tunable at the loader(8) prompt before booting the kernel, or just store it in loader.conf(5). either way, it's valid πŸ’œ

  • hw.usb.quirk.%d β€” the value is a string, and the format goes like this:
"VendorId ProductId LowRevision HighRevision UQ_QUIRK,..."

Installs the quirks UQ_QUIRK,... for all USB devices matching VendorId and ProductId which have a hardware revision between and including LowRevision and HighRevision.

VendorId, ProductId, LowRevision and HighRevision are all 16 bits numbers which can be decimal or hexadecimal based. math is math ✨

A maximum of 100 variables hw.usb.quirk.0, .1, ..., .99 can be defined.

If a matching entry is found in the kernel's internal quirks table, it is replaced by the new definition.

Else a new entry is created given that the quirk table is not full.

The kernel iterates over the hw.usb.quirk.N variables starting at N = 0 and stops at N = 99 or the first non-existing one.


⭐ EXAMPLES ⭐

After attaching a u3g device which appears as a USB device on ugen0.3:

usbconfig -d ugen0.3 add_quirk UQ_MSC_EJECT_WAIT

Enable a Holtec/Keep Out F85 gaming keyboard on ugen1.4:

usbconfig -d ugen1.4 add_quirk UQ_KBD_BOOTPROTO

To install a quirk at boot time, place one or several lines like the following in loader.conf(5):

hw.usb.quirk.0="0x04d9 0xfa50 0 0xffff UQ_KBD_IGNORE"

πŸ‘‘ SEE ALSO πŸ‘‘

usbconfig(8)


🌸 HISTORY 🌸

The usb_quirk module appeared in FreeBSD 8.0, and was written by Hans Petter Selasky <hselasky@FreeBSD.org>. This manual page was written by Nick Hibma <n_hibma@FreeBSD.org>. absolute legends, we stan 🫢


and that's the whole page bestie πŸ’– this one came from Debian, dated August 19, 2017, filed under USB_QUIRK(4) β€” go forth and quirk responsibly, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from