Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux/fpc-iii.git] / drivers / hid / hid-redragon.c
blob73c9d4c4fa34dbcb9f073c3f34cbe37b148688b9
1 /*
2 * HID driver for Redragon keyboards
4 * Copyright (c) 2017 Robert Munteanu
5 * SPDX-License-Identifier: GPL-2.0+
6 */
8 /*
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
15 #include <linux/device.h>
16 #include <linux/hid.h>
17 #include <linux/module.h>
19 #include "hid-ids.h"
23 * The Redragon Asura keyboard sends an incorrect HID descriptor.
24 * At byte 100 it contains
26 * 0x81, 0x00
28 * which is Input (Data, Arr, Abs), but it should be
30 * 0x81, 0x02
32 * which is Input (Data, Var, Abs), which is consistent with the way
33 * key codes are generated.
36 static __u8 *redragon_report_fixup(struct hid_device *hdev, __u8 *rdesc,
37 unsigned int *rsize)
39 if (*rsize >= 102 && rdesc[100] == 0x81 && rdesc[101] == 0x00) {
40 dev_info(&hdev->dev, "Fixing Redragon ASURA report descriptor.\n");
41 rdesc[101] = 0x02;
44 return rdesc;
47 static const struct hid_device_id redragon_devices[] = {
48 {HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_REDRAGON_ASURA)},
52 MODULE_DEVICE_TABLE(hid, redragon_devices);
54 static struct hid_driver redragon_driver = {
55 .name = "redragon",
56 .id_table = redragon_devices,
57 .report_fixup = redragon_report_fixup
60 module_hid_driver(redragon_driver);
62 MODULE_LICENSE("GPL");