hid: jarvis: WAR for cypress controller reset
Ankita Garg [Wed, 23 Mar 2016 08:36:12 +0000 (01:36 -0700)]
Whenever cypress controller gets reset and
enters bootloader (version mis-match on jarvis
startup or OTA), it pulls all the buttons low,
causing spurious input events. This WAR disables
inputs when all three buttons are either pressed
or released.

Bug 200174400

Change-Id: If916a8f11004fc2e25a6c5131d32f621e2729ea2
Signed-off-by: Ankita Garg <ankitag@nvidia.com>
Reviewed-on: http://git-master/r/1114574
Reviewed-by: Siddardha Naraharisetti <siddardhan@nvidia.com>
Reviewed-by: Spencer Sutterlin <ssutterlin@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinayak Pane <vpane@nvidia.com>

drivers/hid/hid-atv-jarvis.c

index 4369d31..1562f9e 100644 (file)
@@ -1299,6 +1299,18 @@ __nodev:
 #define JAR_AUDIO_REPORT_SIZE  233
 #define JAR_AUDIO_FRAME_SIZE   0x3A
 
+/* WAR for cypress controller pulling all buttons (HOME/BACK/SEARCH) low
+ * when in bootloader. If all buttons are found to be pressed simulatneously,
+ * ignore the hid report
+ */
+static bool atvr_jarvis_is_cypress_reset(u8 rdata)
+{
+       if (rdata == 0xe0)
+               return true;
+
+       return false;
+}
+
 static int atvr_jarvis_break_events(struct hid_device *hdev,
                                    struct hid_report *report,
                                    u8 *data, int size)
@@ -1322,8 +1334,13 @@ static int atvr_jarvis_break_events(struct hid_device *hdev,
                if ((data[0] == JAR_BUTTON_REPORT_ID) &&
                    (size >= JAR_BUTTON_REPORT_SIZE)) {
                        amount = JAR_BUTTON_REPORT_SIZE;
-                       hid_report_raw_event(hdev, 0, data,
+                       if (atvr_jarvis_is_cypress_reset(data[1])) {
+                               pr_err("Cypress controller reset, disabling"
+                                      "spurious key inputs \n");
+                       } else {
+                               hid_report_raw_event(hdev, 0, data,
                                             sizeof(amount), 0);
+                       }
                } else if ((data[0] == JAR_AUDIO_REPORT_ID) &&
                           (size >= JAR_AUDIO_REPORT_SIZE)) {
                        u8 *frame = &data[1];