]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
HID: move cherry quirks
authorJiri Slaby <jirislaby@gmail.com>
Tue, 24 Jun 2008 18:42:25 +0000 (20:42 +0200)
committerJiri Kosina <jkosina@suse.cz>
Tue, 14 Oct 2008 21:50:52 +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-cherry.c [new file with mode: 0644]
drivers/hid/hid-core.c
drivers/hid/hid-dummy.c
drivers/hid/hid-input-quirks.c
drivers/hid/usbhid/hid-quirks.c
include/linux/hid.h

index 01456b1d38332c6003715053b70140f29c6b1592..85aabb5d971240998fa7927ed58c9a36ddb4b442 100644 (file)
@@ -103,6 +103,13 @@ config HID_APPLE
 
        If unsure, say M.
 
+config HID_CHERRY
+       tristate "Cherry"
+       default m
+       depends on USB_HID
+       ---help---
+       Support for Cherry Cymotion.
+
 config HID_CYPRESS
        tristate "Cypress"
        default m
index ceede11eed7cf2633b54f6c76f288737dd745742..cd6bd024767c5913f62e13ef1acd6130275335f6 100644 (file)
@@ -14,6 +14,7 @@ endif
 
 obj-$(CONFIG_HID_A4TECH)       += hid-a4tech.o
 obj-$(CONFIG_HID_APPLE)                += hid-apple.o
+obj-$(CONFIG_HID_CHERRY)       += hid-cherry.o
 obj-$(CONFIG_HID_CYPRESS)      += hid-cypress.o
 obj-$(CONFIG_HID_LOGITECH)     += hid-logitech.o
 obj-$(CONFIG_HID_MICROSOFT)    += hid-microsoft.o
diff --git a/drivers/hid/hid-cherry.c b/drivers/hid/hid-cherry.c
new file mode 100644 (file)
index 0000000..b833b97
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ *  HID driver for some cherry "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"
+
+/*
+ * Cherry Cymotion keyboard have an invalid HID report descriptor,
+ * that needs fixing before we can parse it.
+ */
+static void ch_report_fixup(struct hid_device *hdev, __u8 *rdesc,
+               unsigned int rsize)
+{
+       if (rsize >= 17 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
+               dev_info(&hdev->dev, "fixing up Cherry Cymotion report "
+                               "descriptor\n");
+               rdesc[11] = rdesc[16] = 0xff;
+               rdesc[12] = rdesc[17] = 0x03;
+       }
+}
+
+#define ch_map_key_clear(c)    hid_map_usage_clear(hi, usage, bit, max, \
+                                       EV_KEY, (c))
+static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
+               struct hid_field *field, struct hid_usage *usage,
+               unsigned long **bit, int *max)
+{
+       if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
+               return 0;
+
+       switch (usage->hid & HID_USAGE) {
+       case 0x301: ch_map_key_clear(KEY_PROG1);        break;
+       case 0x302: ch_map_key_clear(KEY_PROG2);        break;
+       case 0x303: ch_map_key_clear(KEY_PROG3);        break;
+       default:
+               return 0;
+       }
+
+       return 1;
+}
+
+static const struct hid_device_id ch_devices[] = {
+       { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
+       { }
+};
+MODULE_DEVICE_TABLE(hid, ch_devices);
+
+static struct hid_driver ch_driver = {
+       .name = "cherry",
+       .id_table = ch_devices,
+       .report_fixup = ch_report_fixup,
+       .input_mapping = ch_input_mapping,
+};
+
+static int ch_init(void)
+{
+       return hid_register_driver(&ch_driver);
+}
+
+static void ch_exit(void)
+{
+       hid_unregister_driver(&ch_driver);
+}
+
+module_init(ch_init);
+module_exit(ch_exit);
+MODULE_LICENSE("GPL");
+
+HID_COMPAT_LOAD_DRIVER(cherry);
index be582976db2c51fb67d2a8dd7477233283b63500..5acdc3742851182a070a2ea6306da9445b1b3fe8 100644 (file)
@@ -1164,6 +1164,7 @@ 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_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
        { 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) },
index 123f1c71cdf2d71a4aaf6624a22111c17d9bf83f..178344ea651bf067da2ee3c283f90282fbe62682 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_CHERRY_MODULE
+       HID_COMPAT_CALL_DRIVER(cherry);
+#endif
 #ifdef CONFIG_HID_CYPRESS_MODULE
        HID_COMPAT_CALL_DRIVER(cypress);
 #endif
index 5bacf181a8caea29063ec4f427a2f686f494e08e..97ee75064a0e70d246c7064a50f7c6ccb79f3924 100644 (file)
@@ -38,22 +38,6 @@ static int quirk_belkin_wkbd(struct hid_usage *usage,
        return 1;
 }
 
-static int quirk_cherry_cymotion(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 0x301: map_key_clear(KEY_PROG1);           break;
-               case 0x302: map_key_clear(KEY_PROG2);           break;
-               case 0x303: map_key_clear(KEY_PROG3);           break;
-               default:
-                       return 0;
-       }
-       return 1;
-}
-
 static int quirk_gyration_remote(struct hid_usage *usage,
                struct hid_input *hidinput, unsigned long **bit, int *max)
 {
@@ -173,9 +157,6 @@ static int quirk_btc_8193(struct hid_usage *usage, struct hid_input *hidinput,
 #define VENDOR_ID_BELKIN                       0x1020
 #define DEVICE_ID_BELKIN_WIRELESS_KEYBOARD     0x0006
 
-#define VENDOR_ID_CHERRY                       0x046a
-#define DEVICE_ID_CHERRY_CYMOTION              0x0023
-
 #define VENDOR_ID_CHICONY                      0x04f2
 #define DEVICE_ID_CHICONY_TACTICAL_PAD         0x0418
 
@@ -199,8 +180,6 @@ static const struct hid_input_blacklist {
 } hid_input_blacklist[] = {
        { VENDOR_ID_BELKIN, DEVICE_ID_BELKIN_WIRELESS_KEYBOARD, quirk_belkin_wkbd },
 
-       { VENDOR_ID_CHERRY, DEVICE_ID_CHERRY_CYMOTION, quirk_cherry_cymotion },
-
        { VENDOR_ID_CHICONY, DEVICE_ID_CHICONY_TACTICAL_PAD, quirk_chicony_tactical_pad },
 
        { VENDOR_ID_EZKEY, DEVICE_ID_BTC_8193, quirk_btc_8193 },
index 1d12fb24829c9e901b20cb808fd389ff6cff1dca..0cc6e4223cd107b106afa1ff4b8c0850beecbaf4 100644 (file)
@@ -79,9 +79,6 @@ static const struct hid_rdesc_blacklist {
        __u16 idProduct;
        __u32 quirks;
 } hid_rdesc_blacklist[] = {
-
-       { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_RDESC_CYMOTION },
-
        { USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E, HID_QUIRK_RDESC_BUTTON_CONSUMER },
 
        { USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE, HID_QUIRK_RDESC_PETALYNX },
@@ -319,19 +316,6 @@ u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct)
 
 EXPORT_SYMBOL_GPL(usbhid_lookup_quirk);
 
-/*
- * Cherry Cymotion keyboard have an invalid HID report descriptor,
- * that needs fixing before we can parse it.
- */
-static void usbhid_fixup_cymotion_descriptor(char *rdesc, int rsize)
-{
-       if (rsize >= 17 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
-               printk(KERN_INFO "Fixing up Cherry Cymotion report descriptor\n");
-               rdesc[11] = rdesc[16] = 0xff;
-               rdesc[12] = rdesc[17] = 0x03;
-       }
-}
-
 /*
  * Samsung IrDA remote controller (reports as Cypress USB Mouse).
  *
@@ -385,9 +369,6 @@ static void usbhid_fixup_button_consumer_descriptor(unsigned char *rdesc, int rs
 
 static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned rsize)
 {
-       if ((quirks & HID_QUIRK_RDESC_CYMOTION))
-               usbhid_fixup_cymotion_descriptor(rdesc, rsize);
-
        if (quirks & HID_QUIRK_RDESC_PETALYNX)
                usbhid_fixup_petalynx_descriptor(rdesc, rsize);
 
index a7cc4af2e4671d9eb514bfb400280029fed32233..d9ab4a3af431f0dc1c9ad5909cade7a42eb96094 100644 (file)
@@ -273,7 +273,6 @@ struct hid_item {
  * Separate quirks for runtime report descriptor fixup
  */
 
-#define HID_QUIRK_RDESC_CYMOTION               0x00000001
 #define HID_QUIRK_RDESC_PETALYNX               0x00000008
 #define HID_QUIRK_RDESC_BUTTON_CONSUMER                0x00000020
 #define HID_QUIRK_RDESC_SAMSUNG_REMOTE         0x00000040