a1ef73d
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
a1ef73d
Date: Sun, 8 Mar 2015 22:34:03 -0700
a1ef73d
Subject: [PATCH] Input: synaptics - retrieve the extended capabilities in
a1ef73d
 query $10
a1ef73d
a1ef73d
Newer Synaptics touchpads need to get information from the query $10.
a1ef73d
Retrieve it if available.
a1ef73d
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 | 23 ++++++++++++++++++++---
a1ef73d
 drivers/input/mouse/synaptics.h | 23 +++++++++++++++++++++++
a1ef73d
 2 files changed, 43 insertions(+), 3 deletions(-)
a1ef73d
a1ef73d
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
a1ef73d
index 2176874a41b1..8f6a153677b9 100644
a1ef73d
--- a/drivers/input/mouse/synaptics.c
a1ef73d
+++ b/drivers/input/mouse/synaptics.c
a1ef73d
@@ -241,11 +241,24 @@ static int synaptics_model_id(struct psmouse *psmouse)
a1ef73d
 	return 0;
a1ef73d
 }
a1ef73d
 
a1ef73d
+static int synaptics_more_extended_queries(struct psmouse *psmouse)
a1ef73d
+{
a1ef73d
+	struct synaptics_data *priv = psmouse->private;
a1ef73d
+	unsigned char buf[3];
a1ef73d
+
a1ef73d
+	if (synaptics_send_cmd(psmouse, SYN_QUE_MEXT_CAPAB_10, buf))
a1ef73d
+		return -1;
a1ef73d
+
a1ef73d
+	priv->ext_cap_10 = (buf[0]<<16) | (buf[1]<<8) | buf[2];
a1ef73d
+
a1ef73d
+	return 0;
a1ef73d
+}
a1ef73d
+
a1ef73d
 /*
a1ef73d
- * Read the board id from the touchpad
a1ef73d
+ * Read the board id and the "More Extended Queries" from the touchpad
a1ef73d
  * The board id is encoded in the "QUERY MODES" response
a1ef73d
  */
a1ef73d
-static int synaptics_board_id(struct psmouse *psmouse)
a1ef73d
+static int synaptics_query_modes(struct psmouse *psmouse)
a1ef73d
 {
a1ef73d
 	struct synaptics_data *priv = psmouse->private;
a1ef73d
 	unsigned char bid[3];
a1ef73d
@@ -257,6 +270,10 @@ static int synaptics_board_id(struct psmouse *psmouse)
a1ef73d
 	if (synaptics_send_cmd(psmouse, SYN_QUE_MODES, bid))
a1ef73d
 		return -1;
a1ef73d
 	priv->board_id = ((bid[0] & 0xfc) << 6) | bid[1];
a1ef73d
+
a1ef73d
+	if (SYN_MEXT_CAP_BIT(bid[0]))
a1ef73d
+		return synaptics_more_extended_queries(psmouse);
a1ef73d
+
a1ef73d
 	return 0;
a1ef73d
 }
a1ef73d
 
a1ef73d
@@ -446,7 +463,7 @@ static int synaptics_query_hardware(struct psmouse *psmouse)
a1ef73d
 		return -1;
a1ef73d
 	if (synaptics_firmware_id(psmouse))
a1ef73d
 		return -1;
a1ef73d
-	if (synaptics_board_id(psmouse))
a1ef73d
+	if (synaptics_query_modes(psmouse))
a1ef73d
 		return -1;
a1ef73d
 	if (synaptics_capability(psmouse))
a1ef73d
 		return -1;
a1ef73d
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
a1ef73d
index 1bd01f21783b..8d3761ce8f54 100644
a1ef73d
--- a/drivers/input/mouse/synaptics.h
a1ef73d
+++ b/drivers/input/mouse/synaptics.h
a1ef73d
@@ -22,6 +22,7 @@
a1ef73d
 #define SYN_QUE_EXT_CAPAB_0C		0x0c
a1ef73d
 #define SYN_QUE_EXT_MAX_COORDS		0x0d
a1ef73d
 #define SYN_QUE_EXT_MIN_COORDS		0x0f
a1ef73d
+#define SYN_QUE_MEXT_CAPAB_10		0x10
a1ef73d
 
a1ef73d
 /* synatics modes */
a1ef73d
 #define SYN_BIT_ABSOLUTE_MODE		(1 << 7)
a1ef73d
@@ -53,6 +54,7 @@
a1ef73d
 #define SYN_EXT_CAP_REQUESTS(c)		(((c) & 0x700000) >> 20)
a1ef73d
 #define SYN_CAP_MULTI_BUTTON_NO(ec)	(((ec) & 0x00f000) >> 12)
a1ef73d
 #define SYN_CAP_PRODUCT_ID(ec)		(((ec) & 0xff0000) >> 16)
a1ef73d
+#define SYN_MEXT_CAP_BIT(m)		((m) & (1 << 1))
a1ef73d
 
a1ef73d
 /*
a1ef73d
  * The following describes response for the 0x0c query.
a1ef73d
@@ -89,6 +91,26 @@
a1ef73d
 #define SYN_CAP_REDUCED_FILTERING(ex0c)	((ex0c) & 0x000400)
a1ef73d
 #define SYN_CAP_IMAGE_SENSOR(ex0c)	((ex0c) & 0x000800)
a1ef73d
 
a1ef73d
+/*
a1ef73d
+ * The following descibes response for the 0x10 query.
a1ef73d
+ *
a1ef73d
+ * byte	mask	name			meaning
a1ef73d
+ * ----	----	-------			------------
a1ef73d
+ * 1	0x01	ext buttons are stick	buttons exported in the extended
a1ef73d
+ *					capability are actually meant to be used
a1ef73d
+ *					by the tracktick (pass-through).
a1ef73d
+ * 1	0x02	SecurePad		the touchpad is a SecurePad, so it
a1ef73d
+ *					contains a built-in fingerprint reader.
a1ef73d
+ * 1	0xe0	more ext count		how many more extented queries are
a1ef73d
+ *					available after this one.
a1ef73d
+ * 2	0xff	SecurePad width		the width of the SecurePad fingerprint
a1ef73d
+ *					reader.
a1ef73d
+ * 3	0xff	SecurePad height	the height of the SecurePad fingerprint
a1ef73d
+ *					reader.
a1ef73d
+ */
a1ef73d
+#define SYN_CAP_EXT_BUTTONS_STICK(ex10)	((ex10) & 0x010000)
a1ef73d
+#define SYN_CAP_SECUREPAD(ex10)		((ex10) & 0x020000)
a1ef73d
+
a1ef73d
 /* synaptics modes query bits */
a1ef73d
 #define SYN_MODE_ABSOLUTE(m)		((m) & (1 << 7))
a1ef73d
 #define SYN_MODE_RATE(m)		((m) & (1 << 6))
a1ef73d
@@ -156,6 +178,7 @@ struct synaptics_data {
a1ef73d
 	unsigned long int capabilities;		/* Capabilities */
a1ef73d
 	unsigned long int ext_cap;		/* Extended Capabilities */
a1ef73d
 	unsigned long int ext_cap_0c;		/* Ext Caps from 0x0c query */
a1ef73d
+	unsigned long int ext_cap_10;		/* Ext Caps from 0x10 query */
a1ef73d
 	unsigned long int identity;		/* Identification */
a1ef73d
 	unsigned int x_res, y_res;		/* X/Y resolution in units/mm */
a1ef73d
 	unsigned int x_max, y_max;		/* Max coordinates (from FW) */
a1ef73d
-- 
a1ef73d
2.1.0
a1ef73d