HID: quirk for MS Wireless Desktop Receiver (model 1028)
authorJim Duchek <jim.duchek@gmail.com>
Fri, 14 Mar 2008 14:53:49 +0000 (15:53 +0100)
committerJiri Kosina <jkosina@suse.cz>
Tue, 22 Apr 2008 09:34:57 +0000 (11:34 +0200)
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>
drivers/hid/usbhid/hid-quirks.c
include/linux/hid.h

index 54b8f8311f94627963d496800c73ccecdd2fc84f..81dc5e353dd8a8210e37d4424822a489e9bb3c11 100644 (file)
 #define USB_VENDOR_ID_MICROSOFT                0x045e
 #define USB_DEVICE_ID_SIDEWINDER_GV    0x003b
 #define USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0 0x009d
+#define USB_DEVICE_ID_DESKTOP_RECV_1028 0x00f9
 #define USB_DEVICE_ID_MS_NE4K          0x00db
 #define USB_DEVICE_ID_MS_LK6K          0x00f9
 
@@ -724,6 +725,7 @@ static const struct hid_rdesc_blacklist {
        { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER, HID_QUIRK_RDESC_LOGITECH },
        { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER, HID_QUIRK_RDESC_LOGITECH },
        { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2, HID_QUIRK_RDESC_LOGITECH },
+       { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_DESKTOP_RECV_1028, HID_QUIRK_RDESC_MICROSOFT_RECV_1028 },
 
        { USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E, HID_QUIRK_RDESC_BUTTON_CONSUMER },
 
@@ -1094,6 +1096,28 @@ static void usbhid_fixup_button_consumer_descriptor(unsigned char *rdesc, int rs
        }
 }
 
+/*
+ * Microsoft Wireless Desktop Receiver (Model 1028) has several
+ * 'Usage Min/Max' where it ought to have 'Physical Min/Max'
+ */
+static void usbhid_fixup_microsoft_descriptor(unsigned char *rdesc, int rsize)
+{
+       if (rsize == 571 && rdesc[284] == 0x19
+                        && rdesc[286] == 0x2a
+                        && rdesc[304] == 0x19
+                        && rdesc[306] == 0x29
+                        && rdesc[352] == 0x1a
+                        && rdesc[355] == 0x2a
+                        && rdesc[557] == 0x19
+                        && rdesc[559] == 0x29) {
+               printk(KERN_INFO "Fixing up Microsoft Wireless Receiver Model 1028 report descriptor\n");
+               rdesc[284] = rdesc[304] = rdesc[558] = 0x35;
+               rdesc[352] = 0x36;
+               rdesc[286] = rdesc[355] = 0x46;
+               rdesc[306] = rdesc[559] = 0x45;
+       }
+}
+
 static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned rsize)
 {
        if ((quirks & HID_QUIRK_RDESC_CYMOTION))
@@ -1117,6 +1141,8 @@ static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned
        if (quirks & HID_QUIRK_RDESC_SAMSUNG_REMOTE)
                usbhid_fixup_samsung_irda_descriptor(rdesc, rsize);
 
+       if (quirks & HID_QUIRK_RDESC_MICROSOFT_RECV_1028)
+               usbhid_fixup_microsoft_descriptor(rdesc, rsize);
 }
 
 /**
index af1f7e57a12dc07c696b1d94f1fb4023a4e3da92..e9701f22d4235913b6bef4ed70dee1a76ae2eec5 100644 (file)
@@ -297,6 +297,7 @@ struct hid_item {
 #define HID_QUIRK_RDESC_MACBOOK_JIS            0x00000010
 #define HID_QUIRK_RDESC_BUTTON_CONSUMER                0x00000020
 #define HID_QUIRK_RDESC_SAMSUNG_REMOTE         0x00000040
+#define HID_QUIRK_RDESC_MICROSOFT_RECV_1028    0x00000080
 
 /*
  * This is the global environment of the parser. This information is