a1ef73d
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
a1ef73d
Date: Sun, 8 Mar 2015 22:32:43 -0700
a1ef73d
Subject: [PATCH] Input: synaptics - handle spurious release of trackstick
a1ef73d
 buttons
a1ef73d
a1ef73d
The Fimware 8.1 has a bug in which the extra buttons are only sent when the
a1ef73d
ExtBit is 1.  This should be fixed in a future FW update which should have
a1ef73d
a bump of the minor version.
a1ef73d
a1ef73d
Cc: stable@vger.kernel.org
a1ef73d
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
a1ef73d
Acked-by: Hans de Goede <hdegoede@redhat.com>
a1ef73d
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
a1ef73d
---
a1ef73d
 drivers/input/mouse/synaptics.c | 33 +++++++++++++++++++++++++--------
a1ef73d
 1 file changed, 25 insertions(+), 8 deletions(-)
a1ef73d
a1ef73d
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
a1ef73d
index e78cc5578527..2f42a712f3e0 100644
a1ef73d
--- a/drivers/input/mouse/synaptics.c
a1ef73d
+++ b/drivers/input/mouse/synaptics.c
a1ef73d
@@ -820,14 +820,36 @@ static void synaptics_report_semi_mt_data(struct input_dev *dev,
a1ef73d
 	}
a1ef73d
 }
a1ef73d
 
a1ef73d
-static void synaptics_report_buttons(struct psmouse *psmouse,
a1ef73d
-				     const struct synaptics_hw_state *hw)
a1ef73d
+static void synaptics_report_ext_buttons(struct psmouse *psmouse,
a1ef73d
+					 const struct synaptics_hw_state *hw)
a1ef73d
 {
a1ef73d
 	struct input_dev *dev = psmouse->dev;
a1ef73d
 	struct synaptics_data *priv = psmouse->private;
a1ef73d
 	int ext_bits = (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) + 1) >> 1;
a1ef73d
 	int i;
a1ef73d
 
a1ef73d
+	if (!SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap))
a1ef73d
+		return;
a1ef73d
+
a1ef73d
+	/* Bug in FW 8.1, buttons are reported only when ExtBit is 1 */
a1ef73d
+	if (SYN_ID_FULL(priv->identity) == 0x801 &&
a1ef73d
+	    !((psmouse->packet[0] ^ psmouse->packet[3]) & 0x02))
a1ef73d
+		return;
a1ef73d
+
a1ef73d
+	for (i = 0; i < ext_bits; i++) {
a1ef73d
+		input_report_key(dev, BTN_0 + 2 * i,
a1ef73d
+			hw->ext_buttons & (1 << i));
a1ef73d
+		input_report_key(dev, BTN_1 + 2 * i,
a1ef73d
+			hw->ext_buttons & (1 << (i + ext_bits)));
a1ef73d
+	}
a1ef73d
+}
a1ef73d
+
a1ef73d
+static void synaptics_report_buttons(struct psmouse *psmouse,
a1ef73d
+				     const struct synaptics_hw_state *hw)
a1ef73d
+{
a1ef73d
+	struct input_dev *dev = psmouse->dev;
a1ef73d
+	struct synaptics_data *priv = psmouse->private;
a1ef73d
+
a1ef73d
 	input_report_key(dev, BTN_LEFT, hw->left);
a1ef73d
 	input_report_key(dev, BTN_RIGHT, hw->right);
a1ef73d
 
a1ef73d
@@ -839,12 +861,7 @@ static void synaptics_report_buttons(struct psmouse *psmouse,
a1ef73d
 		input_report_key(dev, BTN_BACK, hw->down);
a1ef73d
 	}
a1ef73d
 
a1ef73d
-	for (i = 0; i < ext_bits; i++) {
a1ef73d
-		input_report_key(dev, BTN_0 + 2 * i,
a1ef73d
-				 hw->ext_buttons & (1 << i));
a1ef73d
-		input_report_key(dev, BTN_1 + 2 * i,
a1ef73d
-				 hw->ext_buttons & (1 << (i + ext_bits)));
a1ef73d
-	}
a1ef73d
+	synaptics_report_ext_buttons(psmouse, hw);
a1ef73d
 }
a1ef73d
 
a1ef73d
 static void synaptics_report_slot(struct input_dev *dev, int slot,
a1ef73d
-- 
a1ef73d
2.1.0
a1ef73d