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
Signed-off-by: Jiri Slaby <redacted>
---
drivers/hid/hid-microsoft.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
@@ -28,22 +28,30 @@#define MS_RDESC 0x08#define MS_NOGET 0x10#define MS_DUPLICATE_USAGES 0x20+#define MS_RDESC_3K 0x40-/*-*MicrosoftWirelessDesktopReceiver(Model1028)has-*'UsageMin/Max'whereitoughttohave'PhysicalMin/Max'-*/static__u8*ms_report_fixup(structhid_device*hdev,__u8*rdesc,unsignedint*rsize){unsignedlongquirks=(unsignedlong)hid_get_drvdata(hdev);+/*+*MicrosoftWirelessDesktopReceiver(Model1028)has+*'UsageMin/Max'whereitoughttohave'PhysicalMin/Max'+*/if((quirks&MS_RDESC)&&*rsize==571&&rdesc[557]==0x19&&rdesc[559]==0x29){hid_info(hdev,"fixing up Microsoft Wireless Receiver Model 1028 report descriptor\n");rdesc[557]=0x35;rdesc[559]=0x45;}+/* the same as above (s/usage/physical/) */+if((quirks&MS_RDESC_3K)&&*rsize==106&&+!memcmp((char[]){0x19,0x00,0x29,0xff},+&rdesc[94],4)){+rdesc[94]=0x35;+rdesc[96]=0x45;+}returnrdesc;}
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
Signed-off-by: Jiri Slaby <redacted>
Added CC to stable and applied, thanks.
--
Jiri Kosina
SUSE Labs
Which version of gcc are you using?
I'm getting (m68k-linux-gnu-gcc 4.1.2):
drivers/hid/hid-microsoft.c:51:18: error: macro "memcmp" passed 6
arguments, but takes just 3
drivers/hid/hid-microsoft.c: In function ‘ms_report_fixup’:
drivers/hid/hid-microsoft.c:50: error: ‘memcmp’ undeclared (first use
in this function)
drivers/hid/hid-microsoft.c:50: error: (Each undeclared identifier is
reported only once
/drivers/hid/hid-microsoft.c:50: error: for each function it appears in.)
Extracted into this test case:
---snip---
#include <string.h>
#define memcmp(a, b, c) memcmp((a), (b), (c))
int f(unsigned char *rdesc)
{
return memcmp((char []){ 0x19, 0x00, 0x29, 0xff }, &rdesc[94], 4);
}
---snip---
it also fails with gcc-3.4/4.1/4.2/4.3/4.4 of Ubuntu 10.04 on amd64.
Interestingly, it doesn't fail if I remove the #define for memcmp. So it seems
to work if memcmp() is a real function, not a #define.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
4.7.1. But that indeed fails too if memcmp is a macro. This is of course
not the case for x86, so that I didn't hit that. I will post a patch to
change this to standard array accesses. (This looked prettier though.)
@Greg: please drop that patch from the stable queues for now.
thanks,
--
js
suse labs
4.7.1. But that indeed fails too if memcmp is a macro. This is of course
not the case for x86, so that I didn't hit that. I will post a patch to
change this to standard array accesses. (This looked prettier though.)
On x86/32 it's also a macro, but a different one, which doesn't process the
parameters:
arch/m68k/include/asm/string.h:#define memcmp(d, s, n) __builtin_memcmp(d, s, n)
arch/x86/include/asm/string_32.h:#define memcmp __builtin_memcmp
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
4.7.1. But that indeed fails too if memcmp is a macro. This is of course
not the case for x86, so that I didn't hit that. I will post a patch to
change this to standard array accesses. (This looked prettier though.)
BTW, you also have to add
#include <linux/string.h>
as on some configs, I get
drivers/hid/hid-microsoft.c:50: error: ‘memcmp’ undeclared (first use
in this function)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html