HID: move belkin quirks
authorJiri Slaby <jirislaby@gmail.com>
Tue, 24 Jun 2008 21:24:57 +0000 (23:24 +0200)
committerJiri Kosina <jkosina@suse.cz>
Tue, 14 Oct 2008 21:50:53 +0000 (23:50 +0200)
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/Kconfig
drivers/hid/Makefile
drivers/hid/hid-belkin.c [new file with mode: 0644]
drivers/hid/hid-core.c
drivers/hid/hid-dummy.c
drivers/hid/hid-ids.h
drivers/hid/hid-input-quirks.c
drivers/hid/usbhid/hid-quirks.c

index 1e6a5a04459197fb6345d15718e38f695595e290..b093f3c83e3615ad9892d26759e98423a62f4d7e 100644 (file)
@@ -103,6 +103,13 @@ config HID_APPLE
 
        If unsure, say M.
 
+config HID_BELKIN
+       tristate "Belkin"
+       default m
+       depends on USB_HID
+       ---help---
+       Support for Belkin Flip KVM and Wireless keyboard.
+
 config HID_CHERRY
        tristate "Cherry"
        default m
index a5eaa3e078be945a8921d6850b580a9471df96cf..ffb58f8001b713e0184e2096d060983c0e66acb2 100644 (file)
@@ -14,6 +14,7 @@ endif
 
 obj-$(CONFIG_HID_A4TECH)       += hid-a4tech.o
 obj-$(CONFIG_HID_APPLE)                += hid-apple.o
+obj-$(CONFIG_HID_BELKIN)       += hid-belkin.o
 obj-$(CONFIG_HID_CHERRY)       += hid-cherry.o
 obj-$(CONFIG_HID_CHICONY)      += hid-chicony.o
 obj-$(CONFIG_HID_CYPRESS)      += hid-cypress.o
diff --git a/drivers/hid/hid-belkin.c b/drivers/hid/hid-belkin.c
new file mode 100644 (file)
index 0000000..050b989
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ *  HID driver for some belkin "special" devices
+ *
+ *  Copyright (c) 1999 Andreas Gal
+ *  Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
+ *  Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
+ *  Copyright (c) 2006-2007 Jiri Kosina
+ *  Copyright (c) 2007 Paul Walmsley
+ *  Copyright (c) 2008 Jiri Slaby
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include <linux/device.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+
+#include "hid-ids.h"
+
+#define BELKIN_HIDDEV  0x01
+#define BELKIN_WKBD    0x02
+
+#define belkin_map_key_clear(c)        hid_map_usage_clear(hi, usage, bit, max, \
+                                       EV_KEY, (c))
+static int belkin_input_mapping(struct hid_device *hdev, struct hid_input *hi,
+               struct hid_field *field, struct hid_usage *usage,
+               unsigned long **bit, int *max)
+{
+       unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
+
+       if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER ||
+                       !(quirks & BELKIN_WKBD))
+               return 0;
+
+       switch (usage->hid & HID_USAGE) {
+       case 0x03a: belkin_map_key_clear(KEY_SOUND);            break;
+       case 0x03b: belkin_map_key_clear(KEY_CAMERA);           break;
+       case 0x03c: belkin_map_key_clear(KEY_DOCUMENTS);        break;
+       default:
+               return 0;
+       }
+       return 1;
+}
+
+static int belkin_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+       unsigned long quirks = id->driver_data;
+       int ret;
+
+       hid_set_drvdata(hdev, (void *)quirks);
+
+       if (quirks & BELKIN_HIDDEV)
+               hdev->quirks |= HID_QUIRK_HIDDEV;
+
+       ret = hid_parse(hdev);
+       if (ret) {
+               dev_err(&hdev->dev, "parse failed\n");
+               goto err_free;
+       }
+
+       ret = hid_hw_start(hdev);
+       if (ret) {
+               dev_err(&hdev->dev, "hw start failed\n");
+               goto err_free;
+       }
+
+       return 0;
+err_free:
+       return ret;
+}
+
+static const struct hid_device_id belkin_devices[] = {
+       { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM),
+               .driver_data = BELKIN_HIDDEV },
+       { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD),
+               .driver_data = BELKIN_WKBD },
+       { }
+};
+MODULE_DEVICE_TABLE(hid, belkin_devices);
+
+static struct hid_driver belkin_driver = {
+       .name = "belkin",
+       .id_table = belkin_devices,
+       .input_mapping = belkin_input_mapping,
+       .probe = belkin_probe,
+};
+
+static int belkin_init(void)
+{
+       return hid_register_driver(&belkin_driver);
+}
+
+static void belkin_exit(void)
+{
+       hid_unregister_driver(&belkin_driver);
+}
+
+module_init(belkin_init);
+module_exit(belkin_exit);
+MODULE_LICENSE("GPL");
+
+HID_COMPAT_LOAD_DRIVER(belkin);
index 0c4e7882800571967cc412d0eb51148260a09434..81e7d70260a49558fb019080985d49f930c25e11 100644 (file)
@@ -1164,12 +1164,14 @@ static const struct hid_device_id hid_blacklist[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
        { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) },
index 0b683af41b241ae9ceda2e1711a22c028e9e296d..b95476c4744981db48df6dc540dbd9a8cd7e166c 100644 (file)
@@ -10,6 +10,9 @@ static int __init hid_dummy_init(void)
 #ifdef CONFIG_HID_APPLE_MODULE
        HID_COMPAT_CALL_DRIVER(apple);
 #endif
+#ifdef CONFIG_HID_BELKIN_MODULE
+       HID_COMPAT_CALL_DRIVER(belkin);
+#endif
 #ifdef CONFIG_HID_CHERRY_MODULE
        HID_COMPAT_CALL_DRIVER(cherry);
 #endif
index 11472d96e2ad96a8817f3ea6659380c2b369c84d..ebe665206a72f4500ecdb6e93242f6f1f938c089 100644 (file)
 #define USB_VENDOR_ID_KBGEAR           0x084e
 #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001
 
+#define USB_VENDOR_ID_LABTEC           0x1020
+#define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006
+
 #define USB_VENDOR_ID_LD               0x0f11
 #define USB_DEVICE_ID_LD_CASSY         0x1000
 #define USB_DEVICE_ID_LD_POCKETCASSY   0x1010
index 5f84568b9bd0ed9c7d84ffd049642c58141f2b36..d10f477655539e540c41869f99bc964ef4edc564 100644 (file)
 #define map_key_clear(c)       hid_map_usage_clear(hidinput, usage, bit, \
                max, EV_KEY, (c))
 
-static int quirk_belkin_wkbd(struct hid_usage *usage,
-               struct hid_input *hidinput, unsigned long **bit, int *max)
-{
-       if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
-               return 0;
-
-       switch (usage->hid & HID_USAGE) {
-               case 0x03a: map_key_clear(KEY_SOUND);           break;
-               case 0x03b: map_key_clear(KEY_CAMERA);          break;
-               case 0x03c: map_key_clear(KEY_DOCUMENTS);       break;
-               default:
-                       return 0;
-       }
-       return 1;
-}
-
 static int quirk_gyration_remote(struct hid_usage *usage,
                struct hid_input *hidinput, unsigned long **bit, int *max)
 {
@@ -104,9 +88,6 @@ static int quirk_cherry_genius_29e(struct hid_usage *usage,
        return 1;
 }
 
-#define VENDOR_ID_BELKIN                       0x1020
-#define DEVICE_ID_BELKIN_WIRELESS_KEYBOARD     0x0006
-
 #define VENDOR_ID_GYRATION                     0x0c16
 #define DEVICE_ID_GYRATION_REMOTE              0x0002
 
@@ -122,8 +103,6 @@ static const struct hid_input_blacklist {
        int (*quirk)(struct hid_usage *, struct hid_input *, unsigned long **,
                        int *);
 } hid_input_blacklist[] = {
-       { VENDOR_ID_BELKIN, DEVICE_ID_BELKIN_WIRELESS_KEYBOARD, quirk_belkin_wkbd },
-
        { VENDOR_ID_GYRATION, DEVICE_ID_GYRATION_REMOTE, quirk_gyration_remote },
 
        { VENDOR_ID_MONTEREY, DEVICE_ID_GENIUS_KB29E, quirk_cherry_genius_29e },
index ddc16ea159a3435516c913a45bbd906e393953ad..c344ec2fad5db0cec643faeda1eba27311ae3fe6 100644 (file)
@@ -43,7 +43,6 @@ static const struct hid_blacklist {
 
        { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL },
 
-       { USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM, HID_QUIRK_HIDDEV },
        { USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE, HID_QUIRK_HIDDEV | HID_QUIRK_IGNORE_HIDINPUT },
 
        { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },