aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-sony.c
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2008-06-25 17:47:04 -0400
committerJiri Kosina <jkosina@suse.cz>2008-10-14 17:50:55 -0400
commitbd28ce008bdc68ef5902f68d2d62cbb7fa78c415 (patch)
tree188317a52208632b330c3e4b0e1cc4576dcb9178 /drivers/hid/hid-sony.c
parent2b88b803018dbc2e9c68cbcd1739186e0715911a (diff)
HID: move sony quirks
Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-sony.c')
-rw-r--r--drivers/hid/hid-sony.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
new file mode 100644
index 000000000000..97668c68f0a6
--- /dev/null
+++ b/drivers/hid/hid-sony.c
@@ -0,0 +1,111 @@
1/*
2 * HID driver for some sony "special" devices
3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby
10 */
11
12/*
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the Free
15 * Software Foundation; either version 2 of the License, or (at your option)
16 * any later version.
17 */
18
19#include <linux/device.h>
20#include <linux/hid.h>
21#include <linux/module.h>
22#include <linux/usb.h>
23
24#include "hid-ids.h"
25
26/*
27 * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
28 * to "operational". Without this, the ps3 controller will not report any
29 * events.
30 */
31static int sony_set_operational(struct hid_device *hdev)
32{
33 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
34 struct usb_device *dev = interface_to_usbdev(intf);
35 __u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
36 int ret;
37 char *buf = kmalloc(18, GFP_KERNEL);
38
39 if (!buf)
40 return -ENOMEM;
41
42 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
43 HID_REQ_GET_REPORT,
44 USB_DIR_IN | USB_TYPE_CLASS |
45 USB_RECIP_INTERFACE,
46 (3 << 8) | 0xf2, ifnum, buf, 17,
47 USB_CTRL_GET_TIMEOUT);
48 if (ret < 0)
49 dev_err(&hdev->dev, "can't set operational mode\n");
50
51 kfree(buf);
52
53 return ret;
54}
55
56static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
57{
58 int ret;
59
60 hdev->quirks |= HID_QUIRK_HIDDEV;
61
62 ret = hid_parse(hdev);
63 if (ret) {
64 dev_err(&hdev->dev, "parse failed\n");
65 goto err_free;
66 }
67
68 ret = hid_hw_start(hdev);
69 if (ret) {
70 dev_err(&hdev->dev, "hw start failed\n");
71 goto err_free;
72 }
73
74 ret = sony_set_operational(hdev);
75 if (ret)
76 goto err_stop;
77
78 return 0;
79err_stop:
80 hid_hw_stop(hdev);
81err_free:
82 return ret;
83}
84
85static const struct hid_device_id sony_devices[] = {
86 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
87 { }
88};
89MODULE_DEVICE_TABLE(hid, sony_devices);
90
91static struct hid_driver sony_driver = {
92 .name = "sony",
93 .id_table = sony_devices,
94 .probe = sony_probe,
95};
96
97static int sony_init(void)
98{
99 return hid_register_driver(&sony_driver);
100}
101
102static void sony_exit(void)
103{
104 hid_unregister_driver(&sony_driver);
105}
106
107module_init(sony_init);
108module_exit(sony_exit);
109MODULE_LICENSE("GPL");
110
111HID_COMPAT_LOAD_DRIVER(sony);