HID: move monterey quirks
authorJiri Slaby <jirislaby@gmail.com>
Tue, 24 Jun 2008 22:07:50 +0000 (00:07 +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-core.c
drivers/hid/hid-dummy.c
drivers/hid/hid-input-quirks.c
drivers/hid/hid-monterey.c [new file with mode: 0644]
drivers/hid/usbhid/hid-quirks.c
include/linux/hid.h

index 04f646a90d32d86b13f3029675890101a3047dbb..d71507a5cccb5214f0600d84beb15d2bb99e58d7 100644 (file)
@@ -154,6 +154,13 @@ config HID_MICROSOFT
        Support for some Microsoft devices which breaks less or more
        HID specification.
 
+config HID_MONTEREY
+       tristate "Monterey"
+       default m
+       depends on USB_HID
+       ---help---
+       Support for Monterey Genius KB29E.
+
 config HID_PETALYNX
        tristate "Petalynx"
        default m
index 359a5bae4082cf07b68ce0b46d73d9bb4ec4242b..48b5fb25d16abb8f1ca6df85a7ee3711f2eb4329 100644 (file)
@@ -21,6 +21,7 @@ obj-$(CONFIG_HID_CYPRESS)     += hid-cypress.o
 obj-$(CONFIG_HID_EZKEY)                += hid-ezkey.o
 obj-$(CONFIG_HID_LOGITECH)     += hid-logitech.o
 obj-$(CONFIG_HID_MICROSOFT)    += hid-microsoft.o
+obj-$(CONFIG_HID_MONTEREY)     += hid-monterey.o
 obj-$(CONFIG_HID_PETALYNX)     += hid-petalynx.o
 obj-$(CONFIG_HID_SUNPLUS)      += hid-sunplus.o
 
index 2b7a08fe171842923d9a167befef247b969a3f5e..fa27231004503e49c166766e71cfe1ca434055c6 100644 (file)
@@ -1191,6 +1191,7 @@ static const struct hid_device_id hid_blacklist[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
        { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) },
        { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
        { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
        { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
 
index c28422c9d2b5487850cb58abde66ed6eb55be01e..1dbb454c8112762eb47846cd72c8865d9ceee15c 100644 (file)
@@ -31,6 +31,9 @@ static int __init hid_dummy_init(void)
 #ifdef CONFIG_HID_MICROSOFT_MODULE
        HID_COMPAT_CALL_DRIVER(microsoft);
 #endif
+#ifdef CONFIG_HID_MONTEREY_MODULE
+       HID_COMPAT_CALL_DRIVER(monterey);
+#endif
 #ifdef CONFIG_HID_PETALYNX_MODULE
        HID_COMPAT_CALL_DRIVER(petalynx);
 #endif
index 903162a63c4f03288b0ba88cf359f1e2588d30d2..1a4ba0313030b482f4d62f5f8af91ee20730deaf 100644 (file)
@@ -42,30 +42,9 @@ static int quirk_gyration_remote(struct hid_usage *usage,
        return 1;
 }
 
-static int quirk_cherry_genius_29e(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 0x156: map_key_clear(KEY_WORDPROCESSOR);   break;
-               case 0x157: map_key_clear(KEY_SPREADSHEET);     break;
-               case 0x158: map_key_clear(KEY_PRESENTATION);    break;
-               case 0x15c: map_key_clear(KEY_STOP);            break;
-
-               default:
-                       return 0;
-       }
-       return 1;
-}
-
 #define VENDOR_ID_GYRATION                     0x0c16
 #define DEVICE_ID_GYRATION_REMOTE              0x0002
 
-#define VENDOR_ID_MONTEREY                     0x0566
-#define DEVICE_ID_GENIUS_KB29E                 0x3004
-
 static const struct hid_input_blacklist {
        __u16 idVendor;
        __u16 idProduct;
@@ -74,8 +53,6 @@ static const struct hid_input_blacklist {
 } hid_input_blacklist[] = {
        { VENDOR_ID_GYRATION, DEVICE_ID_GYRATION_REMOTE, quirk_gyration_remote },
 
-       { VENDOR_ID_MONTEREY, DEVICE_ID_GENIUS_KB29E, quirk_cherry_genius_29e },
-
        { 0, 0, NULL }
 };
 
diff --git a/drivers/hid/hid-monterey.c b/drivers/hid/hid-monterey.c
new file mode 100644 (file)
index 0000000..f3a85a0
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ *  HID driver for some monterey "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"
+
+static void mr_report_fixup(struct hid_device *hdev, __u8 *rdesc,
+               unsigned int rsize)
+{
+       if (rsize >= 30 && rdesc[29] == 0x05 && rdesc[30] == 0x09) {
+               dev_info(&hdev->dev, "fixing up button/consumer in HID report "
+                               "descriptor\n");
+               rdesc[30] = 0x0c;
+       }
+}
+
+#define mr_map_key_clear(c)    hid_map_usage_clear(hi, usage, bit, max, \
+                                       EV_KEY, (c))
+static int mr_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 0x156: mr_map_key_clear(KEY_WORDPROCESSOR);        break;
+       case 0x157: mr_map_key_clear(KEY_SPREADSHEET);          break;
+       case 0x158: mr_map_key_clear(KEY_PRESENTATION);         break;
+       case 0x15c: mr_map_key_clear(KEY_STOP);                 break;
+       default:
+               return 0;
+       }
+       return 1;
+}
+
+static const struct hid_device_id mr_devices[] = {
+       { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
+       { }
+};
+MODULE_DEVICE_TABLE(hid, mr_devices);
+
+static struct hid_driver mr_driver = {
+       .name = "monterey",
+       .id_table = mr_devices,
+       .report_fixup = mr_report_fixup,
+       .input_mapping = mr_input_mapping,
+};
+
+static int mr_init(void)
+{
+       return hid_register_driver(&mr_driver);
+}
+
+static void mr_exit(void)
+{
+       hid_unregister_driver(&mr_driver);
+}
+
+module_init(mr_init);
+module_exit(mr_exit);
+MODULE_LICENSE("GPL");
+
+HID_COMPAT_LOAD_DRIVER(monterey);
index 3f977abb62b10cc053ab165ef5fd0df95047f72e..cc1927b1b88a102c07814450150a816cbd2781ea 100644 (file)
@@ -75,8 +75,6 @@ static const struct hid_rdesc_blacklist {
        __u16 idProduct;
        __u32 quirks;
 } hid_rdesc_blacklist[] = {
-       { USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E, HID_QUIRK_RDESC_BUTTON_CONSUMER },
-
        { USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE, HID_QUIRK_RDESC_SAMSUNG_REMOTE },
 
        { 0, 0 }
@@ -337,20 +335,8 @@ static void usbhid_fixup_samsung_irda_descriptor(unsigned char *rdesc,
        }
 }
 
-static void usbhid_fixup_button_consumer_descriptor(unsigned char *rdesc, int rsize)
-{
-       if (rsize >= 30 && rdesc[29] == 0x05
-                       && rdesc[30] == 0x09) {
-               printk(KERN_INFO "Fixing up button/consumer in HID report descriptor\n");
-               rdesc[30] = 0x0c;
-       }
-}
-
 static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned rsize)
 {
-       if (quirks & HID_QUIRK_RDESC_BUTTON_CONSUMER)
-               usbhid_fixup_button_consumer_descriptor(rdesc, rsize);
-
        if (quirks & HID_QUIRK_RDESC_SAMSUNG_REMOTE)
                usbhid_fixup_samsung_irda_descriptor(rdesc, rsize);
 }
index 7f4c94ffa6179d366673d74db925f90858afe32d..3a639bff4ab252b1884bfac74b1478e5988f19e0 100644 (file)
@@ -272,7 +272,6 @@ struct hid_item {
  * Separate quirks for runtime report descriptor fixup
  */
 
-#define HID_QUIRK_RDESC_BUTTON_CONSUMER                0x00000020
 #define HID_QUIRK_RDESC_SAMSUNG_REMOTE         0x00000040
 
 /*