Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 0adb9c2

Browse files
bentissJiri Kosina
authored andcommitted
HID: kye: Add report fixup for Genius Gx Imperator Keyboard
Genius Gx Imperator Keyboard presents the same problem in its report descriptors than Genius Gila Gaming Mouse. Use the same fixup for both. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=928561 Reported-and-tested-by: Honza Brazdil <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 38ead6e commit 0adb9c2

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

drivers/hid/hid-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
15941594
{ HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) },
15951595
{ HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) },
15961596
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) },
1597+
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_GENIUS_GX_IMPERATOR) },
15971598
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) },
15981599
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) },
15991600
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) },

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@
479479
#define USB_VENDOR_ID_KYE 0x0458
480480
#define USB_DEVICE_ID_KYE_ERGO_525V 0x0087
481481
#define USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE 0x0138
482+
#define USB_DEVICE_ID_GENIUS_GX_IMPERATOR 0x4018
482483
#define USB_DEVICE_ID_KYE_GPEN_560 0x5003
483484
#define USB_DEVICE_ID_KYE_EASYPEN_I405X 0x5010
484485
#define USB_DEVICE_ID_KYE_MOUSEPEN_I608X 0x5011

drivers/hid/hid-kye.c

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,26 @@ static __u8 easypen_m610x_rdesc_fixed[] = {
268268
0xC0 /* End Collection */
269269
};
270270

271+
static __u8 *kye_consumer_control_fixup(struct hid_device *hdev, __u8 *rdesc,
272+
unsigned int *rsize, int offset, const char *device_name) {
273+
/*
274+
* the fixup that need to be done:
275+
* - change Usage Maximum in the Comsumer Control
276+
* (report ID 3) to a reasonable value
277+
*/
278+
if (*rsize >= offset + 31 &&
279+
/* Usage Page (Consumer Devices) */
280+
rdesc[offset] == 0x05 && rdesc[offset + 1] == 0x0c &&
281+
/* Usage (Consumer Control) */
282+
rdesc[offset + 2] == 0x09 && rdesc[offset + 3] == 0x01 &&
283+
/* Usage Maximum > 12287 */
284+
rdesc[offset + 10] == 0x2a && rdesc[offset + 12] > 0x2f) {
285+
hid_info(hdev, "fixing up %s report descriptor\n", device_name);
286+
rdesc[offset + 12] = 0x2f;
287+
}
288+
return rdesc;
289+
}
290+
271291
static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
272292
unsigned int *rsize)
273293
{
@@ -315,23 +335,12 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
315335
}
316336
break;
317337
case USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE:
318-
/*
319-
* the fixup that need to be done:
320-
* - change Usage Maximum in the Comsumer Control
321-
* (report ID 3) to a reasonable value
322-
*/
323-
if (*rsize >= 135 &&
324-
/* Usage Page (Consumer Devices) */
325-
rdesc[104] == 0x05 && rdesc[105] == 0x0c &&
326-
/* Usage (Consumer Control) */
327-
rdesc[106] == 0x09 && rdesc[107] == 0x01 &&
328-
/* Usage Maximum > 12287 */
329-
rdesc[114] == 0x2a && rdesc[116] > 0x2f) {
330-
hid_info(hdev,
331-
"fixing up Genius Gila Gaming Mouse "
332-
"report descriptor\n");
333-
rdesc[116] = 0x2f;
334-
}
338+
rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104,
339+
"Genius Gila Gaming Mouse");
340+
break;
341+
case USB_DEVICE_ID_GENIUS_GX_IMPERATOR:
342+
rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 83,
343+
"Genius Gx Imperator Keyboard");
335344
break;
336345
}
337346
return rdesc;
@@ -428,6 +437,8 @@ static const struct hid_device_id kye_devices[] = {
428437
USB_DEVICE_ID_KYE_EASYPEN_M610X) },
429438
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
430439
USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) },
440+
{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
441+
USB_DEVICE_ID_GENIUS_GX_IMPERATOR) },
431442
{ }
432443
};
433444
MODULE_DEVICE_TABLE(hid, kye_devices);

0 commit comments

Comments
 (0)