Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: quirk for MS Wireless Desktop Receiver (model 1028)

Microsoft's wireless desktop receiver (Model 1028) has a bug in the report
descriptor -- namely, in four seperate places it uses USAGE_MIN and _MAX when
it quite obviously doesn't intend to.

In other words, it reports that it has pretty much _everything_ in 'consumer'
and 'generic desktop'. And then the X evdev driver believes I have a mouse
with 36 absolute axes and a huge pile of keys and buttons, when I in fact,
should have zero. 255/256 in three of the cases, and 0-1024 in another.

This patch fixes the report descriptor of this device before it enters the HID
parser.

Signed-off-by: Jim Duchek <jim.duchek@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Jim Duchek and committed by
Jiri Kosina
974faac4 f345c37c

+27
+26
drivers/hid/usbhid/hid-quirks.c
··· 335 335 #define USB_VENDOR_ID_MICROSOFT 0x045e 336 336 #define USB_DEVICE_ID_SIDEWINDER_GV 0x003b 337 337 #define USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0 0x009d 338 + #define USB_DEVICE_ID_DESKTOP_RECV_1028 0x00f9 338 339 #define USB_DEVICE_ID_MS_NE4K 0x00db 339 340 #define USB_DEVICE_ID_MS_LK6K 0x00f9 340 341 ··· 725 724 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER, HID_QUIRK_RDESC_LOGITECH }, 726 725 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER, HID_QUIRK_RDESC_LOGITECH }, 727 726 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2, HID_QUIRK_RDESC_LOGITECH }, 727 + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_DESKTOP_RECV_1028, HID_QUIRK_RDESC_MICROSOFT_RECV_1028 }, 728 728 729 729 { USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E, HID_QUIRK_RDESC_BUTTON_CONSUMER }, 730 730 ··· 1096 1094 } 1097 1095 } 1098 1096 1097 + /* 1098 + * Microsoft Wireless Desktop Receiver (Model 1028) has several 1099 + * 'Usage Min/Max' where it ought to have 'Physical Min/Max' 1100 + */ 1101 + static void usbhid_fixup_microsoft_descriptor(unsigned char *rdesc, int rsize) 1102 + { 1103 + if (rsize == 571 && rdesc[284] == 0x19 1104 + && rdesc[286] == 0x2a 1105 + && rdesc[304] == 0x19 1106 + && rdesc[306] == 0x29 1107 + && rdesc[352] == 0x1a 1108 + && rdesc[355] == 0x2a 1109 + && rdesc[557] == 0x19 1110 + && rdesc[559] == 0x29) { 1111 + printk(KERN_INFO "Fixing up Microsoft Wireless Receiver Model 1028 report descriptor\n"); 1112 + rdesc[284] = rdesc[304] = rdesc[558] = 0x35; 1113 + rdesc[352] = 0x36; 1114 + rdesc[286] = rdesc[355] = 0x46; 1115 + rdesc[306] = rdesc[559] = 0x45; 1116 + } 1117 + } 1118 + 1099 1119 static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned rsize) 1100 1120 { 1101 1121 if ((quirks & HID_QUIRK_RDESC_CYMOTION)) ··· 1141 1117 if (quirks & HID_QUIRK_RDESC_SAMSUNG_REMOTE) 1142 1118 usbhid_fixup_samsung_irda_descriptor(rdesc, rsize); 1143 1119 1120 + if (quirks & HID_QUIRK_RDESC_MICROSOFT_RECV_1028) 1121 + usbhid_fixup_microsoft_descriptor(rdesc, rsize); 1144 1122 } 1145 1123 1146 1124 /**
+1
include/linux/hid.h
··· 297 297 #define HID_QUIRK_RDESC_MACBOOK_JIS 0x00000010 298 298 #define HID_QUIRK_RDESC_BUTTON_CONSUMER 0x00000020 299 299 #define HID_QUIRK_RDESC_SAMSUNG_REMOTE 0x00000040 300 + #define HID_QUIRK_RDESC_MICROSOFT_RECV_1028 0x00000080 300 301 301 302 /* 302 303 * This is the global environment of the parser. This information is