From aa202d12144eeceab15a981c5567a08d67dd7c9c Mon Sep 17 00:00:00 2001 From: Berk Cem Goksel Date: Tue, 24 Feb 2026 14:28:20 +0300 Subject: sys/linux: simplify generateAudioDeviceDescriptor --- sys/linux/init_vusb.go | 263 +++++++++++++++++++++++++------------------------ 1 file changed, 132 insertions(+), 131 deletions(-) (limited to 'sys/linux') diff --git a/sys/linux/init_vusb.go b/sys/linux/init_vusb.go index e26a30aad..18bbd7e0d 100644 --- a/sys/linux/init_vusb.go +++ b/sys/linux/init_vusb.go @@ -112,6 +112,135 @@ func (arch *arch) generateUsbPrinterDeviceDescriptor(g *prog.Gen, typ0 prog.Type return } +// audioQuirksIDs contains quirk IDs that are hardcoded in the USB audio class drivers +// (and thus are not auto-extractable) to allow exercising driver quirks. +var audioQuirksIDs = [][2]uint16{ + // sound/usb/quirks.c + {0x10f5, 0x0200}, + {0x0d8c, 0x0102}, + {0x0ccd, 0x00b1}, + {0x1235, 0x0010}, + {0x1235, 0x0018}, + {0x0763, 0x2012}, + {0x047f, 0xc010}, + {0x2466, 0x8010}, + // sound/usb/stream.c + {0x04fa, 0x4201}, + {0x0763, 0x2003}, + // sound/usb/midi.c + {0x0a67, 0x5011}, + {0x0a92, 0x1020}, + {0x1430, 0x474b}, + {0x15ca, 0x0101}, + {0x15ca, 0x1806}, + {0x1a86, 0x752d}, + {0xfc08, 0x0101}, + {0x0644, 0x800e}, + {0x0644, 0x800f}, + {0x0763, 0x0150}, + {0x0499, 0x105c}, + {0x0582, 0x0000}, + {0x0582, 0x0003}, + {0x0582, 0x0004}, + {0x0582, 0x0007}, + {0x0582, 0x000b}, + {0x0582, 0x000c}, + {0x0582, 0x0014}, + {0x0582, 0x0016}, + {0x0582, 0x0023}, + {0x0582, 0x0027}, + {0x0582, 0x0029}, + {0x0582, 0x002b}, + {0x0582, 0x002f}, + {0x0582, 0x0033}, + {0x0582, 0x003b}, + {0x0582, 0x0048}, + {0x0582, 0x004d}, + {0x0582, 0x0089}, + {0x0582, 0x009a}, + {0x0582, 0x00b2}, + {0x0582, 0x00eb}, + {0x0582, 0x0102}, + {0x0582, 0x010f}, + {0x0582, 0x0114}, + {0x0582, 0x0120}, + {0x0582, 0x0121}, + {0x0582, 0x0145}, + {0x0582, 0x0156}, + {0x0582, 0x015b}, + {0x0763, 0x1031}, + {0x0763, 0x1033}, + {0x07fd, 0x0001}, + {0x086a, 0x0001}, + {0x086a, 0x0002}, + {0x086a, 0x0003}, + {0x09e8, 0x0062}, + {0x133e, 0x0815}, + // sound/usb/card.c + {0x18d1, 0x2d04}, + {0x18d1, 0x2d05}, + // sound/usb/format.c + {0x0582, 0x0016}, + {0x0582, 0x000c}, + {0x0d8c, 0x0201}, + {0x0d8c, 0x0078}, + {0x041e, 0x4064}, + {0x041e, 0x4068}, + {0x0e41, 0x4241}, + {0x0e41, 0x4242}, + {0x0e41, 0x4244}, + {0x0e41, 0x4246}, + {0x0e41, 0x4247}, + {0x0e41, 0x4248}, + {0x0e41, 0x4249}, + {0x0e41, 0x424a}, + {0x19f7, 0x0011}, + {0x0e41, 0x3000}, + {0x0e41, 0x3020}, + {0x0e41, 0x3061}, + // sound/usb/mixer_quirks.c + {0x041e, 0x3000}, + {0x041e, 0x3020}, + {0x041e, 0x3040}, + {0x041e, 0x3042}, + {0x041e, 0x3048}, + {0x041e, 0x30df}, + {0x041e, 0x3237}, + {0x041e, 0x323b}, + {0x041e, 0x3263}, + {0x0644, 0x8047}, + {0x0b05, 0x1739}, + {0x0b05, 0x1743}, + {0x0b05, 0x17a0}, + {0x0bda, 0x4014}, + {0x0d8c, 0x000c}, + {0x0d8c, 0x0014}, + {0x0d8c, 0x0103}, + {0x1235, 0x8002}, + {0x1235, 0x8004}, + {0x1235, 0x800c}, + {0x1235, 0x8012}, + {0x1235, 0x8014}, + {0x1235, 0x8201}, + {0x1235, 0x8203}, + {0x1235, 0x8204}, + {0x1235, 0x8210}, + {0x1235, 0x8211}, + {0x1235, 0x8212}, + {0x1235, 0x8213}, + {0x1235, 0x8214}, + {0x1235, 0x8215}, + {0x17cc, 0x1011}, + {0x17cc, 0x1021}, + {0x194f, 0x010c}, + {0x200c, 0x1018}, + {0x21b4, 0x0081}, + {0x2a39, 0x3fb0}, + {0x2a39, 0x3fd2}, + {0x2a39, 0x3fd3}, + {0x2a39, 0x3fd4}, +} + func (arch *arch) generateAudioDeviceDescriptor(g *prog.Gen, typ0 prog.Type, dir prog.Dir, old prog.Arg) ( arg prog.Arg, calls []*prog.Call) { if old == nil { @@ -131,137 +260,9 @@ func (arch *arch) generateAudioDeviceDescriptor(g *prog.Gen, typ0 prog.Type, dir case g.Rand().Intn(2) == 0: // Patch in quirk IDs that are hardcoded in the USB audio class drivers // (and thus are not auto-extractable) to allow exercising driver quirks. - var idVendor uint16 - var idProduct uint16 - quirksIDs := [][2]uint16{ - // sound/usb/quirks.c - {0x10f5, 0x0200}, - {0x0d8c, 0x0102}, - {0x0ccd, 0x00b1}, - {0x1235, 0x0010}, - {0x1235, 0x0018}, - {0x0763, 0x2012}, - {0x047f, 0xc010}, - {0x2466, 0x8010}, - // sound/usb/stream.c - {0x04fa, 0x4201}, - {0x0763, 0x2003}, - // sound/usb/midi.c - {0x0a67, 0x5011}, - {0x0a92, 0x1020}, - {0x1430, 0x474b}, - {0x15ca, 0x0101}, - {0x15ca, 0x1806}, - {0x1a86, 0x752d}, - {0xfc08, 0x0101}, - {0x0644, 0x800e}, - {0x0644, 0x800f}, - {0x0763, 0x0150}, - {0x0499, 0x105c}, - {0x0582, 0x0000}, - {0x0582, 0x0003}, - {0x0582, 0x0004}, - {0x0582, 0x0007}, - {0x0582, 0x000b}, - {0x0582, 0x000c}, - {0x0582, 0x0014}, - {0x0582, 0x0016}, - {0x0582, 0x0023}, - {0x0582, 0x0027}, - {0x0582, 0x0029}, - {0x0582, 0x002b}, - {0x0582, 0x002f}, - {0x0582, 0x0033}, - {0x0582, 0x003b}, - {0x0582, 0x0048}, - {0x0582, 0x004d}, - {0x0582, 0x0089}, - {0x0582, 0x009a}, - {0x0582, 0x00b2}, - {0x0582, 0x00eb}, - {0x0582, 0x0102}, - {0x0582, 0x010f}, - {0x0582, 0x0114}, - {0x0582, 0x0120}, - {0x0582, 0x0121}, - {0x0582, 0x0145}, - {0x0582, 0x0156}, - {0x0582, 0x015b}, - {0x0763, 0x1031}, - {0x0763, 0x1033}, - {0x07fd, 0x0001}, - {0x086a, 0x0001}, - {0x086a, 0x0002}, - {0x086a, 0x0003}, - {0x09e8, 0x0062}, - {0x133e, 0x0815}, - // sound/usb/card.c - {0x18d1, 0x2d04}, - {0x18d1, 0x2d05}, - // sound/usb/format.c - {0x0582, 0x0016}, - {0x0582, 0x000c}, - {0x0d8c, 0x0201}, - {0x0d8c, 0x0078}, - {0x041e, 0x4064}, - {0x041e, 0x4068}, - {0x0e41, 0x4241}, - {0x0e41, 0x4242}, - {0x0e41, 0x4244}, - {0x0e41, 0x4246}, - {0x0e41, 0x4247}, - {0x0e41, 0x4248}, - {0x0e41, 0x4249}, - {0x0e41, 0x424a}, - {0x19f7, 0x0011}, - {0x0e41, 0x3000}, - {0x0e41, 0x3020}, - {0x0e41, 0x3061}, - // sound/usb/mixer_quirks.c - {0x041e, 0x3000}, - {0x041e, 0x3020}, - {0x041e, 0x3040}, - {0x041e, 0x3042}, - {0x041e, 0x3048}, - {0x041e, 0x30df}, - {0x041e, 0x3237}, - {0x041e, 0x323b}, - {0x041e, 0x3263}, - {0x0644, 0x8047}, - {0x0b05, 0x1739}, - {0x0b05, 0x1743}, - {0x0b05, 0x17a0}, - {0x0bda, 0x4014}, - {0x0d8c, 0x000c}, - {0x0d8c, 0x0014}, - {0x0d8c, 0x0103}, - {0x1235, 0x8002}, - {0x1235, 0x8004}, - {0x1235, 0x800c}, - {0x1235, 0x8012}, - {0x1235, 0x8014}, - {0x1235, 0x8201}, - {0x1235, 0x8203}, - {0x1235, 0x8204}, - {0x1235, 0x8210}, - {0x1235, 0x8211}, - {0x1235, 0x8212}, - {0x1235, 0x8213}, - {0x1235, 0x8214}, - {0x1235, 0x8215}, - {0x17cc, 0x1011}, - {0x17cc, 0x1021}, - {0x194f, 0x010c}, - {0x200c, 0x1018}, - {0x21b4, 0x0081}, - {0x2a39, 0x3fb0}, - {0x2a39, 0x3fd2}, - {0x2a39, 0x3fd3}, - {0x2a39, 0x3fd4}, - } - idx := g.Rand().Intn(len(quirksIDs)) - idVendor = quirksIDs[idx][0] - idProduct = quirksIDs[idx][1] + idx := g.Rand().Intn(len(audioQuirksIDs)) + idVendor := audioQuirksIDs[idx][0] + idProduct := audioQuirksIDs[idx][1] devArg := arg.(*prog.GroupArg).Inner[0] patchGroupArg(devArg, 7, "idVendor", uint64(idVendor)) patchGroupArg(devArg, 8, "idProduct", uint64(idProduct)) -- cgit mrf-deployment