2 * HID driver for some sony "special" devices
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
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)
19 #include <linux/device.h>
20 #include <linux/hid.h>
21 #include <linux/module.h>
22 #include <linux/usb.h>
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
31 static int sony_set_operational(struct hid_device
*hdev
)
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
;
37 char *buf
= kmalloc(18, GFP_KERNEL
);
42 ret
= usb_control_msg(dev
, usb_rcvctrlpipe(dev
, 0),
44 USB_DIR_IN
| USB_TYPE_CLASS
|
46 (3 << 8) | 0xf2, ifnum
, buf
, 17,
47 USB_CTRL_GET_TIMEOUT
);
49 dev_err(&hdev
->dev
, "can't set operational mode\n");
56 static int sony_probe(struct hid_device
*hdev
, const struct hid_device_id
*id
)
60 ret
= hid_parse(hdev
);
62 dev_err(&hdev
->dev
, "parse failed\n");
66 ret
= hid_hw_start(hdev
, HID_CONNECT_DEFAULT
|
67 HID_CONNECT_HIDDEV_FORCE
);
69 dev_err(&hdev
->dev
, "hw start failed\n");
73 ret
= sony_set_operational(hdev
);
84 static const struct hid_device_id sony_devices
[] = {
85 { HID_USB_DEVICE(USB_VENDOR_ID_SONY
, USB_DEVICE_ID_SONY_PS3_CONTROLLER
) },
88 MODULE_DEVICE_TABLE(hid
, sony_devices
);
90 static struct hid_driver sony_driver
= {
92 .id_table
= sony_devices
,
96 static int sony_init(void)
98 return hid_register_driver(&sony_driver
);
101 static void sony_exit(void)
103 hid_unregister_driver(&sony_driver
);
106 module_init(sony_init
);
107 module_exit(sony_exit
);
108 MODULE_LICENSE("GPL");
110 HID_COMPAT_LOAD_DRIVER(sony
);