1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * HID driver for some belkin "special" devices
5 * Copyright (c) 1999 Andreas Gal
6 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
7 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
8 * Copyright (c) 2006-2007 Jiri Kosina
9 * Copyright (c) 2008 Jiri Slaby
15 #include <linux/device.h>
16 #include <linux/hid.h>
17 #include <linux/module.h>
21 #define BELKIN_HIDDEV 0x01
22 #define BELKIN_WKBD 0x02
24 #define belkin_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
26 static int belkin_input_mapping(struct hid_device *hdev, struct hid_input *hi,
27 struct hid_field *field, struct hid_usage *usage,
28 unsigned long **bit, int *max)
30 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
32 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER ||
33 !(quirks & BELKIN_WKBD))
36 switch (usage->hid & HID_USAGE) {
37 case 0x03a: belkin_map_key_clear(KEY_SOUND); break;
38 case 0x03b: belkin_map_key_clear(KEY_CAMERA); break;
39 case 0x03c: belkin_map_key_clear(KEY_DOCUMENTS); break;
46 static int belkin_probe(struct hid_device *hdev, const struct hid_device_id *id)
48 unsigned long quirks = id->driver_data;
51 hid_set_drvdata(hdev, (void *)quirks);
53 ret = hid_parse(hdev);
55 hid_err(hdev, "parse failed\n");
59 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT |
60 ((quirks & BELKIN_HIDDEV) ? HID_CONNECT_HIDDEV_FORCE : 0));
62 hid_err(hdev, "hw start failed\n");
71 static const struct hid_device_id belkin_devices[] = {
72 { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM),
73 .driver_data = BELKIN_HIDDEV },
74 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD),
75 .driver_data = BELKIN_WKBD },
78 MODULE_DEVICE_TABLE(hid, belkin_devices);
80 static struct hid_driver belkin_driver = {
82 .id_table = belkin_devices,
83 .input_mapping = belkin_input_mapping,
84 .probe = belkin_probe,
86 module_hid_driver(belkin_driver);
88 MODULE_LICENSE("GPL");