USB_QUIRK(4)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’– USB_QUIRK(4) β€” the usb_quirk module, bestie edition πŸ’–

okay so this is a page from the Kernel Interfaces Manual and it's all about usb_quirk, the USB quirks module. It's giving "fix the weird USB devices" energy and honestly? iconic. Let's get into it 🫢


✨ NAME ✨

usb_quirk β€” the USB quirks module πŸ’…


🌸 SYNOPSIS 🌸

So there's two ways to get this module living its best life. To compile it into the kernel, drop this line into your kernel configuration file:

device usb

Or, if you'd rather load it at boot time, put this in loader.conf(5):

usb_quirk_load="YES"

no cap, that's it ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

The usb_quirk module is the main character that lets you dynamically add and remove quirks for USB devices using usbconfig(8). literally so useful, fr fr πŸ’–

🌈 General quirks

  • UQ_AUDIO_SWAP_LR β€” swap left and right channels πŸ”„
  • UQ_AU_INP_ASYNC β€” input is async despite claim of adaptive
  • UQ_AU_NO_FRAC β€” do not adjust for fractional samples
  • UQ_AU_NO_XU β€” audio device has broken extension unit 😭
  • UQ_AU_VENDOR_CLASS β€” audio device uses vendor class to identify itself
  • UQ_AU_SET_SPDIF_CM6206 β€” audio device needs special programming to enable S/PDIF audio output
  • UQ_BAD_ADC β€” bad audio spec version number
  • UQ_BAD_AUDIO β€” device claims audio class, but is not πŸ’€
  • UQ_BROKEN_BIDIR β€” printer has broken bidir mode
  • UQ_BUS_POWERED β€” device is bus powered, despite claim
  • UQ_HID_IGNORE β€” device should be ignored by hid class
  • UQ_KBD_IGNORE β€” device should be ignored by kbd class
  • UQ_KBD_BOOTPROTO β€” device should set the boot protocol
  • UQ_UMS_IGNORE β€” device should be ignored by ums class
  • UQ_MS_BAD_CLASS β€” does not identify properly
  • UQ_MS_LEADING_BYTE β€” mouse sends an unknown leading byte
  • UQ_MS_REVZ β€” mouse has Z-axis reversed
  • UQ_MS_VENDOR_BTN β€” mouse has buttons in vendor usage page
  • UQ_NO_STRINGS β€” string descriptors are broken
  • UQ_POWER_CLAIM β€” hub lies about power status πŸ™ˆ
  • UQ_SPUR_BUT_UP β€” spurious mouse button up events
  • 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_IGNORE_CDC_CM β€” ignore cm descriptor
  • UQ_WMT_IGNORE β€” device should be ignored by 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) 🐌
  • 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
bestie, for the complete list of supported quirks, look at /sys/dev/usb/quirk/usb_quirk.h or run usbconfig dump_quirk_names πŸ‘‘

πŸ‘‘ LOADER TUNABLE πŸ‘‘

There's one tunable here, and you can set it at the loader(8) prompt before booting the kernel, or just store it in loader.conf(5). easy ✨

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

This 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, no cap.

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. periodt.


πŸ”₯ EXAMPLES πŸ”₯

So 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

And 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"

slay. that's the whole vibe check πŸ’–


🌟 SEE ALSO 🌟


πŸŽ€ 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>. iconic authors, honestly πŸ‘‘βœ¨


so yeah, that's the whole page! this version is from Debian, dated August 19, 2017 β€” catch you in the group chat, bestie πŸ’œπŸ¦‹

πŸ“¦ where this page comes from