2 * HID driver for Sony / PS2 / PS3 BD 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) 2008 Jiri Slaby
8 * Copyright (c) 2012 David Dillow <dave@thedillows.org>
9 * Copyright (c) 2006-2013 Jiri Kosina
10 * Copyright (c) 2013 Colin Leitner <colin.leitner@gmail.com>
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at your option)
20 /* NOTE: in order for the Sony PS3 BD Remote Control to be found by
21 * a Bluetooth host, the key combination Start+Enter has to be kept pressed
22 * for about 7 seconds with the Bluetooth Host Controller in discovering mode.
24 * There will be no PIN request from the device.
27 #include <linux/device.h>
28 #include <linux/hid.h>
29 #include <linux/module.h>
30 #include <linux/slab.h>
31 #include <linux/usb.h>
32 #include <linux/leds.h>
36 #define VAIO_RDESC_CONSTANT (1 << 0)
37 #define SIXAXIS_CONTROLLER_USB (1 << 1)
38 #define SIXAXIS_CONTROLLER_BT (1 << 2)
39 #define BUZZ_CONTROLLER (1 << 3)
40 #define PS3REMOTE (1 << 4)
42 static const u8 sixaxis_rdesc_fixup[] = {
43 0x95, 0x13, 0x09, 0x01, 0x81, 0x02, 0x95, 0x0C,
44 0x81, 0x01, 0x75, 0x10, 0x95, 0x04, 0x26, 0xFF,
45 0x03, 0x46, 0xFF, 0x03, 0x09, 0x01, 0x81, 0x02
48 static const u8 sixaxis_rdesc_fixup2[] = {
49 0x05, 0x01, 0x09, 0x04, 0xa1, 0x01, 0xa1, 0x02,
50 0x85, 0x01, 0x75, 0x08, 0x95, 0x01, 0x15, 0x00,
51 0x26, 0xff, 0x00, 0x81, 0x03, 0x75, 0x01, 0x95,
52 0x13, 0x15, 0x00, 0x25, 0x01, 0x35, 0x00, 0x45,
53 0x01, 0x05, 0x09, 0x19, 0x01, 0x29, 0x13, 0x81,
54 0x02, 0x75, 0x01, 0x95, 0x0d, 0x06, 0x00, 0xff,
55 0x81, 0x03, 0x15, 0x00, 0x26, 0xff, 0x00, 0x05,
56 0x01, 0x09, 0x01, 0xa1, 0x00, 0x75, 0x08, 0x95,
57 0x04, 0x35, 0x00, 0x46, 0xff, 0x00, 0x09, 0x30,
58 0x09, 0x31, 0x09, 0x32, 0x09, 0x35, 0x81, 0x02,
59 0xc0, 0x05, 0x01, 0x95, 0x13, 0x09, 0x01, 0x81,
60 0x02, 0x95, 0x0c, 0x81, 0x01, 0x75, 0x10, 0x95,
61 0x04, 0x26, 0xff, 0x03, 0x46, 0xff, 0x03, 0x09,
62 0x01, 0x81, 0x02, 0xc0, 0xa1, 0x02, 0x85, 0x02,
63 0x75, 0x08, 0x95, 0x30, 0x09, 0x01, 0xb1, 0x02,
64 0xc0, 0xa1, 0x02, 0x85, 0xee, 0x75, 0x08, 0x95,
65 0x30, 0x09, 0x01, 0xb1, 0x02, 0xc0, 0xa1, 0x02,
66 0x85, 0xef, 0x75, 0x08, 0x95, 0x30, 0x09, 0x01,
67 0xb1, 0x02, 0xc0, 0xc0,
70 static __u8 ps3remote_rdesc[] = {
71 0x05, 0x01, /* GUsagePage Generic Desktop */
72 0x09, 0x05, /* LUsage 0x05 [Game Pad] */
73 0xA1, 0x01, /* MCollection Application (mouse, keyboard) */
75 /* Use collection 1 for joypad buttons */
76 0xA1, 0x02, /* MCollection Logical (interrelated data) */
78 /* Ignore the 1st byte, maybe it is used for a controller
79 * number but it's not needed for correct operation */
80 0x75, 0x08, /* GReportSize 0x08 [8] */
81 0x95, 0x01, /* GReportCount 0x01 [1] */
82 0x81, 0x01, /* MInput 0x01 (Const[0] Arr[1] Abs[2]) */
84 /* Bytes from 2nd to 4th are a bitmap for joypad buttons, for these
85 * buttons multiple keypresses are allowed */
86 0x05, 0x09, /* GUsagePage Button */
87 0x19, 0x01, /* LUsageMinimum 0x01 [Button 1 (primary/trigger)] */
88 0x29, 0x18, /* LUsageMaximum 0x18 [Button 24] */
89 0x14, /* GLogicalMinimum [0] */
90 0x25, 0x01, /* GLogicalMaximum 0x01 [1] */
91 0x75, 0x01, /* GReportSize 0x01 [1] */
92 0x95, 0x18, /* GReportCount 0x18 [24] */
93 0x81, 0x02, /* MInput 0x02 (Data[0] Var[1] Abs[2]) */
95 0xC0, /* MEndCollection */
97 /* Use collection 2 for remote control buttons */
98 0xA1, 0x02, /* MCollection Logical (interrelated data) */
100 /* 5th byte is used for remote control buttons */
101 0x05, 0x09, /* GUsagePage Button */
102 0x18, /* LUsageMinimum [No button pressed] */
103 0x29, 0xFE, /* LUsageMaximum 0xFE [Button 254] */
104 0x14, /* GLogicalMinimum [0] */
105 0x26, 0xFE, 0x00, /* GLogicalMaximum 0x00FE [254] */
106 0x75, 0x08, /* GReportSize 0x08 [8] */
107 0x95, 0x01, /* GReportCount 0x01 [1] */
110 /* Ignore bytes from 6th to 11th, 6th to 10th are always constant at
111 * 0xff and 11th is for press indication */
112 0x75, 0x08, /* GReportSize 0x08 [8] */
113 0x95, 0x06, /* GReportCount 0x06 [6] */
114 0x81, 0x01, /* MInput 0x01 (Const[0] Arr[1] Abs[2]) */
116 /* 12th byte is for battery strength */
117 0x05, 0x06, /* GUsagePage Generic Device Controls */
118 0x09, 0x20, /* LUsage 0x20 [Battery Strength] */
119 0x14, /* GLogicalMinimum [0] */
120 0x25, 0x05, /* GLogicalMaximum 0x05 [5] */
121 0x75, 0x08, /* GReportSize 0x08 [8] */
122 0x95, 0x01, /* GReportCount 0x01 [1] */
123 0x81, 0x02, /* MInput 0x02 (Data[0] Var[1] Abs[2]) */
125 0xC0, /* MEndCollection */
127 0xC0 /* MEndCollection [Game Pad] */
130 static const unsigned int ps3remote_keymap_joypad_buttons[] = {
132 [0x02] = BTN_THUMBL, /* L3 */
133 [0x03] = BTN_THUMBR, /* R3 */
139 [0x09] = BTN_TL2, /* L2 */
140 [0x0a] = BTN_TR2, /* R2 */
141 [0x0b] = BTN_TL, /* L1 */
142 [0x0c] = BTN_TR, /* R1 */
143 [0x0d] = KEY_OPTION, /* options/triangle */
144 [0x0e] = KEY_BACK, /* back/circle */
145 [0x0f] = BTN_0, /* cross */
146 [0x10] = KEY_SCREEN, /* view/square */
147 [0x11] = KEY_HOMEPAGE, /* PS button */
150 static const unsigned int ps3remote_keymap_remote_buttons[] = {
161 [0x0e] = KEY_ESC, /* return */
163 [0x16] = KEY_EJECTCD,
164 [0x1a] = KEY_MENU, /* top menu */
166 [0x30] = KEY_PREVIOUS,
169 [0x33] = KEY_REWIND, /* scan back */
170 [0x34] = KEY_FORWARD, /* scan forward */
173 [0x40] = KEY_CONTEXT_MENU, /* pop up/menu */
174 [0x60] = KEY_FRAMEBACK, /* slow/step back */
175 [0x61] = KEY_FRAMEFORWARD, /* slow/step forward */
176 [0x63] = KEY_SUBTITLE,
179 [0x70] = KEY_INFO, /* display */
186 static const unsigned int buzz_keymap[] = {
187 /* The controller has 4 remote buzzers, each with one LED and 5
190 * We use the mapping chosen by the controller, which is:
193 * -------------------
200 * So, for example, the orange button on the third buzzer is mapped to
201 * BTN_TRIGGER_HAPPY14
203 [ 1] = BTN_TRIGGER_HAPPY1,
204 [ 2] = BTN_TRIGGER_HAPPY2,
205 [ 3] = BTN_TRIGGER_HAPPY3,
206 [ 4] = BTN_TRIGGER_HAPPY4,
207 [ 5] = BTN_TRIGGER_HAPPY5,
208 [ 6] = BTN_TRIGGER_HAPPY6,
209 [ 7] = BTN_TRIGGER_HAPPY7,
210 [ 8] = BTN_TRIGGER_HAPPY8,
211 [ 9] = BTN_TRIGGER_HAPPY9,
212 [10] = BTN_TRIGGER_HAPPY10,
213 [11] = BTN_TRIGGER_HAPPY11,
214 [12] = BTN_TRIGGER_HAPPY12,
215 [13] = BTN_TRIGGER_HAPPY13,
216 [14] = BTN_TRIGGER_HAPPY14,
217 [15] = BTN_TRIGGER_HAPPY15,
218 [16] = BTN_TRIGGER_HAPPY16,
219 [17] = BTN_TRIGGER_HAPPY17,
220 [18] = BTN_TRIGGER_HAPPY18,
221 [19] = BTN_TRIGGER_HAPPY19,
222 [20] = BTN_TRIGGER_HAPPY20,
226 unsigned long quirks;
228 #ifdef CONFIG_SONY_FF
229 struct work_struct rumble_worker;
230 struct hid_device *hdev;
240 struct led_classdev *leds[4];
243 static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc,
246 *rsize = sizeof(ps3remote_rdesc);
247 return ps3remote_rdesc;
250 static int ps3remote_mapping(struct hid_device *hdev, struct hid_input *hi,
251 struct hid_field *field, struct hid_usage *usage,
252 unsigned long **bit, int *max)
254 unsigned int key = usage->hid & HID_USAGE;
256 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON)
259 switch (usage->collection_index) {
261 if (key >= ARRAY_SIZE(ps3remote_keymap_joypad_buttons))
264 key = ps3remote_keymap_joypad_buttons[key];
269 if (key >= ARRAY_SIZE(ps3remote_keymap_remote_buttons))
272 key = ps3remote_keymap_remote_buttons[key];
280 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, key);
285 /* Sony Vaio VGX has wrongly mouse pointer declared as constant */
286 static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
289 struct sony_sc *sc = hid_get_drvdata(hdev);
292 * Some Sony RF receivers wrongly declare the mouse pointer as a
293 * a constant non-data variable.
295 if ((sc->quirks & VAIO_RDESC_CONSTANT) && *rsize >= 56 &&
296 /* usage page: generic desktop controls */
297 /* rdesc[0] == 0x05 && rdesc[1] == 0x01 && */
299 rdesc[2] == 0x09 && rdesc[3] == 0x02 &&
300 /* input (usage page for x,y axes): constant, variable, relative */
301 rdesc[54] == 0x81 && rdesc[55] == 0x07) {
302 hid_info(hdev, "Fixing up Sony RF Receiver report descriptor\n");
303 /* input: data, variable, relative */
307 /* The HID descriptor exposed over BT has a trailing zero byte */
308 if ((((sc->quirks & SIXAXIS_CONTROLLER_USB) && *rsize == 148) ||
309 ((sc->quirks & SIXAXIS_CONTROLLER_BT) && *rsize == 149)) &&
311 hid_info(hdev, "Fixing up Sony Sixaxis report descriptor\n");
312 memcpy((void *)&rdesc[83], (void *)&sixaxis_rdesc_fixup,
313 sizeof(sixaxis_rdesc_fixup));
314 } else if (sc->quirks & SIXAXIS_CONTROLLER_USB &&
315 *rsize > sizeof(sixaxis_rdesc_fixup2)) {
316 hid_info(hdev, "Sony Sixaxis clone detected. Using original report descriptor (size: %d clone; %d new)\n",
317 *rsize, (int)sizeof(sixaxis_rdesc_fixup2));
318 *rsize = sizeof(sixaxis_rdesc_fixup2);
319 memcpy(rdesc, &sixaxis_rdesc_fixup2, *rsize);
322 if (sc->quirks & PS3REMOTE)
323 return ps3remote_fixup(hdev, rdesc, rsize);
328 static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
331 struct sony_sc *sc = hid_get_drvdata(hdev);
333 /* Sixaxis HID report has acclerometers/gyro with MSByte first, this
334 * has to be BYTE_SWAPPED before passing up to joystick interface
336 if ((sc->quirks & (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT)) &&
337 rd[0] == 0x01 && size == 49) {
338 swap(rd[41], rd[42]);
339 swap(rd[43], rd[44]);
340 swap(rd[45], rd[46]);
341 swap(rd[47], rd[48]);
347 static int sony_mapping(struct hid_device *hdev, struct hid_input *hi,
348 struct hid_field *field, struct hid_usage *usage,
349 unsigned long **bit, int *max)
351 struct sony_sc *sc = hid_get_drvdata(hdev);
353 if (sc->quirks & BUZZ_CONTROLLER) {
354 unsigned int key = usage->hid & HID_USAGE;
356 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON)
359 switch (usage->collection_index) {
361 if (key >= ARRAY_SIZE(buzz_keymap))
364 key = buzz_keymap[key];
372 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, key);
376 if (sc->quirks & PS3REMOTE)
377 return ps3remote_mapping(hdev, hi, field, usage, bit, max);
379 /* Let hid-core decide for the others */
384 * The Sony Sixaxis does not handle HID Output Reports on the Interrupt EP
385 * like it should according to usbhid/hid-core.c::usbhid_output_raw_report()
386 * so we need to override that forcing HID Output Reports on the Control EP.
388 * There is also another issue about HID Output Reports via USB, the Sixaxis
389 * does not want the report_id as part of the data packet, so we have to
390 * discard buf[0] when sending the actual control message, even for numbered
393 static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf,
394 size_t count, unsigned char report_type)
396 struct usb_interface *intf = to_usb_interface(hid->dev.parent);
397 struct usb_device *dev = interface_to_usbdev(intf);
398 struct usb_host_interface *interface = intf->cur_altsetting;
399 int report_id = buf[0];
402 if (report_type == HID_OUTPUT_REPORT) {
403 /* Don't send the Report ID */
408 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
410 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
411 ((report_type + 1) << 8) | report_id,
412 interface->desc.bInterfaceNumber, buf, count,
413 USB_CTRL_SET_TIMEOUT);
415 /* Count also the Report ID, in case of an Output report. */
416 if (ret > 0 && report_type == HID_OUTPUT_REPORT)
423 * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
424 * to "operational". Without this, the ps3 controller will not report any
427 static int sixaxis_set_operational_usb(struct hid_device *hdev)
430 char *buf = kmalloc(18, GFP_KERNEL);
435 ret = hdev->hid_get_raw_report(hdev, 0xf2, buf, 17, HID_FEATURE_REPORT);
438 hid_err(hdev, "can't set operational mode\n");
445 static int sixaxis_set_operational_bt(struct hid_device *hdev)
447 unsigned char buf[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 };
448 return hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
451 static void buzz_set_leds(struct hid_device *hdev, int leds)
453 struct list_head *report_list =
454 &hdev->report_enum[HID_OUTPUT_REPORT].report_list;
455 struct hid_report *report = list_entry(report_list->next,
456 struct hid_report, list);
457 __s32 *value = report->field[0]->value;
460 value[1] = (leds & 1) ? 0xff : 0x00;
461 value[2] = (leds & 2) ? 0xff : 0x00;
462 value[3] = (leds & 4) ? 0xff : 0x00;
463 value[4] = (leds & 8) ? 0xff : 0x00;
466 hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
469 static void buzz_led_set_brightness(struct led_classdev *led,
470 enum led_brightness value)
472 struct device *dev = led->dev->parent;
473 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
474 struct sony_sc *drv_data;
475 struct buzz_extra *buzz;
479 drv_data = hid_get_drvdata(hdev);
480 if (!drv_data || !drv_data->extra) {
481 hid_err(hdev, "No device data\n");
484 buzz = drv_data->extra;
486 for (n = 0; n < 4; n++) {
487 if (led == buzz->leds[n]) {
488 int on = !! (buzz->led_state & (1 << n));
489 if (value == LED_OFF && on) {
490 buzz->led_state &= ~(1 << n);
491 buzz_set_leds(hdev, buzz->led_state);
492 } else if (value != LED_OFF && !on) {
493 buzz->led_state |= (1 << n);
494 buzz_set_leds(hdev, buzz->led_state);
501 static enum led_brightness buzz_led_get_brightness(struct led_classdev *led)
503 struct device *dev = led->dev->parent;
504 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
505 struct sony_sc *drv_data;
506 struct buzz_extra *buzz;
511 drv_data = hid_get_drvdata(hdev);
512 if (!drv_data || !drv_data->extra) {
513 hid_err(hdev, "No device data\n");
516 buzz = drv_data->extra;
518 for (n = 0; n < 4; n++) {
519 if (led == buzz->leds[n]) {
520 on = !! (buzz->led_state & (1 << n));
525 return on ? LED_FULL : LED_OFF;
528 static int buzz_init(struct hid_device *hdev)
530 struct sony_sc *drv_data;
531 struct buzz_extra *buzz;
533 struct led_classdev *led;
537 drv_data = hid_get_drvdata(hdev);
538 BUG_ON(!(drv_data->quirks & BUZZ_CONTROLLER));
540 /* Validate expected report characteristics. */
541 if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7))
544 buzz = kzalloc(sizeof(*buzz), GFP_KERNEL);
546 hid_err(hdev, "Insufficient memory, cannot allocate driver data\n");
549 drv_data->extra = buzz;
551 /* Clear LEDs as we have no way of reading their initial state. This is
552 * only relevant if the driver is loaded after somebody actively set the
554 buzz_set_leds(hdev, 0x00);
556 name_sz = strlen(dev_name(&hdev->dev)) + strlen("::buzz#") + 1;
558 for (n = 0; n < 4; n++) {
559 led = kzalloc(sizeof(struct led_classdev) + name_sz, GFP_KERNEL);
561 hid_err(hdev, "Couldn't allocate memory for LED %d\n", n);
565 name = (void *)(&led[1]);
566 snprintf(name, name_sz, "%s::buzz%d", dev_name(&hdev->dev), n + 1);
569 led->max_brightness = 1;
570 led->brightness_get = buzz_led_get_brightness;
571 led->brightness_set = buzz_led_set_brightness;
573 if (led_classdev_register(&hdev->dev, led)) {
574 hid_err(hdev, "Failed to register LED %d\n", n);
585 for (n = 0; n < 4; n++) {
587 buzz->leds[n] = NULL;
590 led_classdev_unregister(led);
594 kfree(drv_data->extra);
595 drv_data->extra = NULL;
599 static void buzz_remove(struct hid_device *hdev)
601 struct sony_sc *drv_data;
602 struct buzz_extra *buzz;
603 struct led_classdev *led;
606 drv_data = hid_get_drvdata(hdev);
607 BUG_ON(!(drv_data->quirks & BUZZ_CONTROLLER));
609 buzz = drv_data->extra;
611 for (n = 0; n < 4; n++) {
613 buzz->leds[n] = NULL;
616 led_classdev_unregister(led);
620 kfree(drv_data->extra);
621 drv_data->extra = NULL;
624 #ifdef CONFIG_SONY_FF
625 static void sony_rumble_worker(struct work_struct *work)
627 struct sony_sc *sc = container_of(work, struct sony_sc, rumble_worker);
628 unsigned char buf[] = {
630 0x00, 0xff, 0x00, 0xff, 0x00,
631 0x00, 0x00, 0x00, 0x00, 0x03,
632 0xff, 0x27, 0x10, 0x00, 0x32,
633 0xff, 0x27, 0x10, 0x00, 0x32,
634 0xff, 0x27, 0x10, 0x00, 0x32,
635 0xff, 0x27, 0x10, 0x00, 0x32,
636 0x00, 0x00, 0x00, 0x00, 0x00
642 sc->hdev->hid_output_raw_report(sc->hdev, buf, sizeof(buf),
646 static int sony_play_effect(struct input_dev *dev, void *data,
647 struct ff_effect *effect)
649 struct hid_device *hid = input_get_drvdata(dev);
650 struct sony_sc *sc = hid_get_drvdata(hid);
652 if (effect->type != FF_RUMBLE)
655 sc->left = effect->u.rumble.strong_magnitude / 256;
656 sc->right = effect->u.rumble.weak_magnitude ? 1 : 0;
658 schedule_work(&sc->rumble_worker);
662 static int sony_init_ff(struct hid_device *hdev)
664 struct hid_input *hidinput = list_entry(hdev->inputs.next,
665 struct hid_input, list);
666 struct input_dev *input_dev = hidinput->input;
667 struct sony_sc *sc = hid_get_drvdata(hdev);
670 INIT_WORK(&sc->rumble_worker, sony_rumble_worker);
672 input_set_capability(input_dev, EV_FF, FF_RUMBLE);
673 return input_ff_create_memless(input_dev, NULL, sony_play_effect);
676 static void sony_destroy_ff(struct hid_device *hdev)
678 struct sony_sc *sc = hid_get_drvdata(hdev);
680 cancel_work_sync(&sc->rumble_worker);
684 static int sony_init_ff(struct hid_device *hdev)
689 static void sony_destroy_ff(struct hid_device *hdev)
694 static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
697 unsigned long quirks = id->driver_data;
699 unsigned int connect_mask = HID_CONNECT_DEFAULT;
701 sc = devm_kzalloc(&hdev->dev, sizeof(*sc), GFP_KERNEL);
703 hid_err(hdev, "can't alloc sony descriptor\n");
708 hid_set_drvdata(hdev, sc);
710 ret = hid_parse(hdev);
712 hid_err(hdev, "parse failed\n");
716 if (sc->quirks & VAIO_RDESC_CONSTANT)
717 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
718 else if (sc->quirks & SIXAXIS_CONTROLLER_USB)
719 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
720 else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
721 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
723 ret = hid_hw_start(hdev, connect_mask);
725 hid_err(hdev, "hw start failed\n");
729 if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
730 hdev->hid_output_raw_report = sixaxis_usb_output_raw_report;
731 ret = sixaxis_set_operational_usb(hdev);
733 else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
734 ret = sixaxis_set_operational_bt(hdev);
735 else if (sc->quirks & BUZZ_CONTROLLER)
736 ret = buzz_init(hdev);
743 ret = sony_init_ff(hdev);
753 static void sony_remove(struct hid_device *hdev)
755 struct sony_sc *sc = hid_get_drvdata(hdev);
757 if (sc->quirks & BUZZ_CONTROLLER)
760 sony_destroy_ff(hdev);
765 static const struct hid_device_id sony_devices[] = {
766 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
767 .driver_data = SIXAXIS_CONTROLLER_USB },
768 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER),
769 .driver_data = SIXAXIS_CONTROLLER_USB },
770 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
771 .driver_data = SIXAXIS_CONTROLLER_BT },
772 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),
773 .driver_data = VAIO_RDESC_CONSTANT },
774 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE),
775 .driver_data = VAIO_RDESC_CONSTANT },
776 /* Wired Buzz Controller. Reported as Sony Hub from its USB ID and as
777 * Logitech joystick from the device descriptor. */
778 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER),
779 .driver_data = BUZZ_CONTROLLER },
780 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER),
781 .driver_data = BUZZ_CONTROLLER },
782 /* PS3 BD Remote Control */
783 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE),
784 .driver_data = PS3REMOTE },
785 /* Logitech Harmony Adapter for PS3 */
786 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3),
787 .driver_data = PS3REMOTE },
790 MODULE_DEVICE_TABLE(hid, sony_devices);
792 static struct hid_driver sony_driver = {
794 .id_table = sony_devices,
795 .input_mapping = sony_mapping,
797 .remove = sony_remove,
798 .report_fixup = sony_report_fixup,
799 .raw_event = sony_raw_event
801 module_hid_driver(sony_driver);
803 MODULE_LICENSE("GPL");