]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
HID: move sony quirks
authorJiri Slaby <jirislaby@gmail.com>
Wed, 25 Jun 2008 21:47:04 +0000 (23:47 +0200)
committerJiri Kosina <jkosina@suse.cz>
Tue, 14 Oct 2008 21:50:55 +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-sony.c [new file with mode: 0644]
drivers/hid/usbhid/hid-core.c
drivers/hid/usbhid/hid-quirks.c
include/linux/hid.h

index 52b617bf2b93c182e4b32a7dcb9932ecdb10f781..7ced6476026af595318951fea37eae309fd0c447 100644 (file)
@@ -182,6 +182,13 @@ config HID_SAMSUNG
        ---help---
        Support for Samsung IR remote.
 
+config HID_SONY
+       tristate "Sony"
+       default m
+       depends on USB_HID
+       ---help---
+       Support for Sony PS3 controller.
+
 config HID_SUNPLUS
        tristate "Sunplus"
        default m
index 0141ff88008eff6a3c092c2a28cac30da76911bb..4f39b9431ebe86d447cc6702e642cee30818d7e6 100644 (file)
@@ -25,6 +25,7 @@ obj-$(CONFIG_HID_MICROSOFT)   += hid-microsoft.o
 obj-$(CONFIG_HID_MONTEREY)     += hid-monterey.o
 obj-$(CONFIG_HID_PETALYNX)     += hid-petalynx.o
 obj-$(CONFIG_HID_SAMSUNG)      += hid-samsung.o
+obj-$(CONFIG_HID_SONY)         += hid-sony.o
 obj-$(CONFIG_HID_SUNPLUS)      += hid-sunplus.o
 
 obj-$(CONFIG_USB_HID)          += usbhid/
index 1b43af072ce05d260ae18f92e00bcef76aaefe88..f527e332b596fddd80f0ebf4276f217ec2ced38b 100644 (file)
@@ -1195,6 +1195,7 @@ static const struct hid_device_id hid_blacklist[] = {
        { 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_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
        { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
 
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) },
index cd21dcc418165be2b01db8a95bd66cf4148b6c25..1ef3111f7fe71859831d811f3cdb11120cfd2f35 100644 (file)
@@ -43,6 +43,9 @@ static int __init hid_dummy_init(void)
 #ifdef CONFIG_HID_SAMSUNG_MODULE
        HID_COMPAT_CALL_DRIVER(samsung);
 #endif
+#ifdef CONFIG_HID_SONY_MODULE
+       HID_COMPAT_CALL_DRIVER(sony);
+#endif
 #ifdef CONFIG_HID_SUNPLUS_MODULE
        HID_COMPAT_CALL_DRIVER(sunplus);
 #endif
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
new file mode 100644 (file)
index 0000000..97668c6
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ *  HID driver for some sony "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 <linux/usb.h>
+
+#include "hid-ids.h"
+
+/*
+ * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
+ * to "operational".  Without this, the ps3 controller will not report any
+ * events.
+ */
+static int sony_set_operational(struct hid_device *hdev)
+{
+       struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
+       struct usb_device *dev = interface_to_usbdev(intf);
+       __u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
+       int ret;
+       char *buf = kmalloc(18, GFP_KERNEL);
+
+       if (!buf)
+               return -ENOMEM;
+
+       ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+                                HID_REQ_GET_REPORT,
+                                USB_DIR_IN | USB_TYPE_CLASS |
+                                USB_RECIP_INTERFACE,
+                                (3 << 8) | 0xf2, ifnum, buf, 17,
+                                USB_CTRL_GET_TIMEOUT);
+       if (ret < 0)
+               dev_err(&hdev->dev, "can't set operational mode\n");
+
+       kfree(buf);
+
+       return ret;
+}
+
+static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+       int ret;
+
+       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;
+       }
+
+       ret = sony_set_operational(hdev);
+       if (ret)
+               goto err_stop;
+
+       return 0;
+err_stop:
+       hid_hw_stop(hdev);
+err_free:
+       return ret;
+}
+
+static const struct hid_device_id sony_devices[] = {
+       { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
+       { }
+};
+MODULE_DEVICE_TABLE(hid, sony_devices);
+
+static struct hid_driver sony_driver = {
+       .name = "sony",
+       .id_table = sony_devices,
+       .probe = sony_probe,
+};
+
+static int sony_init(void)
+{
+       return hid_register_driver(&sony_driver);
+}
+
+static void sony_exit(void)
+{
+       hid_unregister_driver(&sony_driver);
+}
+
+module_init(sony_init);
+module_exit(sony_exit);
+MODULE_LICENSE("GPL");
+
+HID_COMPAT_LOAD_DRIVER(sony);
index e900d597bc2d6e82802732c1ef663d7da3b69135..b41d0110a75eff1349e58769824e0e35a4d99b4c 100644 (file)
@@ -670,32 +670,6 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
        usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma);
 }
 
-/*
- * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
- * to "operational".  Without this, the ps3 controller will not report any
- * events.
- */
-static void hid_fixup_sony_ps3_controller(struct usb_device *dev, int ifnum)
-{
-       int result;
-       char *buf = kmalloc(18, GFP_KERNEL);
-
-       if (!buf)
-               return;
-
-       result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-                                HID_REQ_GET_REPORT,
-                                USB_DIR_IN | USB_TYPE_CLASS |
-                                USB_RECIP_INTERFACE,
-                                (3 << 8) | 0xf2, ifnum, buf, 17,
-                                USB_CTRL_GET_TIMEOUT);
-
-       if (result < 0)
-               err_hid("%s failed: %d\n", __func__, result);
-
-       kfree(buf);
-}
-
 static int usbhid_start_finish(struct hid_device *hid)
 {
        struct usb_interface *intf = to_usb_interface(hid->dev.parent);
@@ -723,10 +697,6 @@ static int usbhid_start_finish(struct hid_device *hid)
        if ((hid->claimed & HID_CLAIMED_INPUT))
                hid_ff_init(hid);
 
-       if (hid->quirks & HID_QUIRK_SONY_PS3_CONTROLLER)
-               hid_fixup_sony_ps3_controller(interface_to_usbdev(intf),
-                       intf->cur_altsetting->desc.bInterfaceNumber);
-
        printk(KERN_INFO);
 
        if (hid->claimed & HID_CLAIMED_INPUT)
index f66d2e43b5d56e53d3af10e08dfdc8609b8bc08d..a154a7dc1e635431fbfe1c18cb04cc35822686b2 100644 (file)
@@ -46,8 +46,6 @@ static const struct hid_blacklist {
        { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
        { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT },
 
-       { USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER, HID_QUIRK_SONY_PS3_CONTROLLER | HID_QUIRK_HIDDEV },
-
        { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET },
index 9eac330a1dfa4e1c35595c65c14bcec5099c0fec..43aa51a7fa95e68e5b303840f4b2aead01570e06 100644 (file)
@@ -262,7 +262,6 @@ struct hid_item {
 #define HID_QUIRK_BADPAD                       0x00000020
 #define HID_QUIRK_MULTI_INPUT                  0x00000040
 #define HID_QUIRK_SKIP_OUTPUT_REPORTS          0x00010000
-#define HID_QUIRK_SONY_PS3_CONTROLLER          0x00040000
 #define HID_QUIRK_RESET_LEDS                   0x00100000
 #define HID_QUIRK_HIDINPUT                     0x00200000
 #define HID_QUIRK_IGNORE_HIDINPUT              0x01000000