#include <linux/device.h>
#include <linux/hid.h>
#include <linux/module.h>
#include <linux/usb.h>
#include "hid-ids.h"
static const __u8 huawei_cd30_kbd_rdesc_fixed[] = {
0x05, 0x01,
0x09, 0x80,
0xa1, 0x01,
0x85, 0x01,
0x19, 0x81,
0x29, 0x83,
0x15, 0x00,
0x25, 0x01,
0x75, 0x01,
0x95, 0x03,
0x81, 0x02,
0x95, 0x05,
0x81, 0x01,
0xc0,
0x05, 0x0c,
0x09, 0x01,
0xa1, 0x01,
0x85, 0x02,
0x19, 0x00,
0x2a, 0x3c, 0x02,
0x15, 0x00,
0x26, 0x3c, 0x02,
0x95, 0x01,
0x75, 0x10,
0x81, 0x00,
0xc0
};
static const __u8 *huawei_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
struct usb_interface *intf = hid_is_usb(hdev) ?
to_usb_interface(hdev->dev.parent) : NULL;
switch (hdev->product) {
case USB_DEVICE_ID_HUAWEI_CD30KBD:
if (!intf || intf->cur_altsetting->desc.bInterfaceNumber == 1) {
if (*rsize != sizeof(huawei_cd30_kbd_rdesc_fixed) ||
memcmp(huawei_cd30_kbd_rdesc_fixed, rdesc,
sizeof(huawei_cd30_kbd_rdesc_fixed)) != 0) {
hid_info(hdev, "Replacing Huawei cd30 keyboard report descriptor.\n");
*rsize = sizeof(huawei_cd30_kbd_rdesc_fixed);
return huawei_cd30_kbd_rdesc_fixed;
}
}
break;
}
return rdesc;
}
static const struct hid_device_id huawei_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_HUAWEI, USB_DEVICE_ID_HUAWEI_CD30KBD)},
{ }
};
MODULE_DEVICE_TABLE(hid, huawei_devices);
static struct hid_driver huawei_driver = {
.name = "huawei",
.id_table = huawei_devices,
.report_fixup = huawei_report_fixup,
};
module_hid_driver(huawei_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Miao Li <limiao@kylinos.cn>");
MODULE_DESCRIPTION("HID driver for some huawei \"special\" devices"