Skip to content

Commit 3ccc60f

Browse files
Jiri SlabyJiri Kosina
authored andcommitted
HID: microsoft: fix invalid rdesc for 3k kbd
Microsoft Digital Media Keyboard 3000 has two interfaces, and the second one has a report descriptor with a bug. The second collection says: 05 01 -- global; usage page -- 01 -- Generic Desktop Controls 09 80 -- local; usage -- 80 -- System Control a1 01 -- main; collection -- 01 -- application 85 03 -- global; report ID -- 03 19 00 -- local; Usage Minimum -- 00 29 ff -- local; Usage Maximum -- ff 15 00 -- global; Logical Minimum -- 0 26 ff 00 -- global; Logical Maximum -- ff 81 00 -- main; input c0 -- main; End Collection I.e. it makes us think that there are all kinds of usages of system control. That the keyboard is a not only a keyboard, but also a joystick, mouse, gamepad, keypad, etc. The same as for the Wireless Desktop Receiver, this should be Physical Min/Max. So fix that appropriately. References: https://bugzilla.novell.com/show_bug.cgi?id=776834 Cc: <[email protected]> Signed-off-by: Jiri Slaby <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent def7cb8 commit 3ccc60f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

drivers/hid/hid-microsoft.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,30 @@
2828
#define MS_RDESC 0x08
2929
#define MS_NOGET 0x10
3030
#define MS_DUPLICATE_USAGES 0x20
31+
#define MS_RDESC_3K 0x40
3132

32-
/*
33-
* Microsoft Wireless Desktop Receiver (Model 1028) has
34-
* 'Usage Min/Max' where it ought to have 'Physical Min/Max'
35-
*/
3633
static __u8 *ms_report_fixup(struct hid_device *hdev, __u8 *rdesc,
3734
unsigned int *rsize)
3835
{
3936
unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
4037

38+
/*
39+
* Microsoft Wireless Desktop Receiver (Model 1028) has
40+
* 'Usage Min/Max' where it ought to have 'Physical Min/Max'
41+
*/
4142
if ((quirks & MS_RDESC) && *rsize == 571 && rdesc[557] == 0x19 &&
4243
rdesc[559] == 0x29) {
4344
hid_info(hdev, "fixing up Microsoft Wireless Receiver Model 1028 report descriptor\n");
4445
rdesc[557] = 0x35;
4546
rdesc[559] = 0x45;
4647
}
48+
/* the same as above (s/usage/physical/) */
49+
if ((quirks & MS_RDESC_3K) && *rsize == 106 &&
50+
!memcmp((char []){ 0x19, 0x00, 0x29, 0xff },
51+
&rdesc[94], 4)) {
52+
rdesc[94] = 0x35;
53+
rdesc[96] = 0x45;
54+
}
4755
return rdesc;
4856
}
4957

@@ -192,7 +200,7 @@ static const struct hid_device_id ms_devices[] = {
192200
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB),
193201
.driver_data = MS_PRESENTER },
194202
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K),
195-
.driver_data = MS_ERGONOMY },
203+
.driver_data = MS_ERGONOMY | MS_RDESC_3K },
196204
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0),
197205
.driver_data = MS_NOGET },
198206
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500),

0 commit comments

Comments
 (0)