CHROMEOS: HID: Support for Logitech T651 Touchpad
[cascardo/linux.git] / drivers / hid / hid-logitech-hidpp.c
index cbab03e..586f0f1 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/sched.h>
+#include "hid-ids.h"
 #include "hid-logitech-hidpp.h"
 
 MODULE_LICENSE("GPL");
@@ -74,7 +75,9 @@ static int __hidpp_send_report(struct hid_device *hdev,
                                                 sizeof(struct hidpp_report),
                                                 HID_OUTPUT_REPORT);
 
-       return (sent_bytes < 0) ? sent_bytes : 0;
+       /* It seems that sending via bluetooth can return -EIO even
+        * when the message is delivered, so we have this hack: */
+       return (sent_bytes < 0 && sent_bytes != -EIO) ? sent_bytes : 0;
 }
 
 static int hidpp_send_message_sync(struct hidpp_device *hidpp_dev,
@@ -154,6 +157,9 @@ int hidpp_send_rap_command_sync(struct hidpp_device *hidpp_dev,
 
        memset(&message, 0, sizeof(message));
        message.report_id = report_id;
+       /* If sending to a non-DJ device, device expects 0xff. If sending to
+        * a DJ device, this device_index will be overwritten by the DJ code: */
+       message.device_index = 0xff;
        message.rap.sub_id = sub_id;
        message.rap.reg_address = reg_address;
        memcpy(&message.rap.params, params, param_count);
@@ -174,7 +180,7 @@ int hidpp_get_hidpp2_feature_index(struct hidpp_device *hidpp_dev,
        params[0] = feature_id >> 8;
        params[1] = feature_id & 0xff;
        ret = hidpp_send_hidpp2_sync(hidpp_dev,
-                                       REPORT_ID_HIDPP_SHORT,
+                                       REPORT_ID_HIDPP_LONG,
                                        0,
                                        0,
                                        software_id,
@@ -334,8 +340,10 @@ int hidpp_raw_event(struct hid_device *hdev, struct hid_report *hid_report,
 
        hidpp_print_raw_event("hidpp_raw_event", data, size);
 
-       if ((report->report_id != REPORT_ID_HIDPP_LONG) &&
-           (report->report_id != REPORT_ID_HIDPP_SHORT)) {
+       if (!(report->report_id == REPORT_ID_HIDPP_LONG ||
+             report->report_id == REPORT_ID_HIDPP_SHORT ||
+             (report->report_id == T651_REPORT_TYPE_MOUSE &&
+              hdev->product == USB_DEVICE_ID_WIRELESS_TOUCHPAD_T651))) {
                dbg_hid("hid-logitech-hidpp.c:%s: ignore report_id:%d\n",
                        __func__, report->report_id);
                return 0;