1 From 5f57d67da87332a9a1ba8fa7a33bf0680e1c76e7 Mon Sep 17 00:00:00 2001
2 From: Takashi Iwai <tiwai@suse.de>
3 Date: Mon, 19 Apr 2010 10:37:21 -0700
4 Subject: [PATCH 1/2] Input: Add support of Synaptics Clickpad device
6 Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git
7 Git-commit: 5f57d67da87332a9a1ba8fa7a33bf0680e1c76e7
10 The new type of touchpads can be detected via a new query command
11 0x0c. The clickpad flags are in cap[0]:4 and cap[1]:0 bits.
13 When the device is detected, the driver now reports only the left
14 button as the supported buttons so that X11 driver can detect that
15 the device is Clickpad. A Clickpad device gives the button events
16 only as the middle button. The kernel driver morphs to the left
17 button. The real handling of Clickpad is done rather in X driver
20 Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
22 Acked-by: Jian-feng Ding <jian-feng.ding@intel.com>
24 drivers/input/mouse/synaptics.c | 35 ++++++++++++++++++++++++++++++-----
25 drivers/input/mouse/synaptics.h | 4 ++++
26 2 files changed, 34 insertions(+), 5 deletions(-)
28 diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
29 index d3f5243..9ab9ff0 100644
30 --- a/drivers/input/mouse/synaptics.c
31 +++ b/drivers/input/mouse/synaptics.c
32 @@ -136,7 +136,8 @@ static int synaptics_capability(struct psmouse *psmouse)
33 if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap))
35 priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2];
37 + priv->ext_cap = priv->ext_cap_0c = 0;
39 if (!SYN_CAP_VALID(priv->capabilities))
42 @@ -149,7 +150,7 @@ static int synaptics_capability(struct psmouse *psmouse)
43 if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 1) {
44 if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) {
45 printk(KERN_ERR "Synaptics claims to have extended capabilities,"
46 - " but I'm not able to read them.");
47 + " but I'm not able to read them.\n");
49 priv->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2];
51 @@ -161,6 +162,16 @@ static int synaptics_capability(struct psmouse *psmouse)
52 priv->ext_cap &= 0xff0fff;
56 + if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 4) {
57 + if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB_0C, cap)) {
58 + printk(KERN_ERR "Synaptics claims to have extended capability 0x0c,"
59 + " but I'm not able to read it.\n");
61 + priv->ext_cap_0c = (cap[0] << 16) | (cap[1] << 8) | cap[2];
68 @@ -347,7 +358,15 @@ static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data
69 hw->left = (buf[0] & 0x01) ? 1 : 0;
70 hw->right = (buf[0] & 0x02) ? 1 : 0;
72 - if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) {
73 + if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
75 + * Clickpad's button is transmitted as middle button,
76 + * however, since it is primary button, we will report
79 + hw->left = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
81 + } else if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) {
82 hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
84 hw->scroll = (signed char)(buf[1]);
85 @@ -592,6 +611,12 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
87 dev->absres[ABS_X] = priv->x_res;
88 dev->absres[ABS_Y] = priv->y_res;
90 + if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
91 + /* Clickpads report only left button */
92 + __clear_bit(BTN_RIGHT, dev->keybit);
93 + __clear_bit(BTN_MIDDLE, dev->keybit);
97 static void synaptics_disconnect(struct psmouse *psmouse)
98 @@ -696,10 +721,10 @@ int synaptics_init(struct psmouse *psmouse)
100 priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;
102 - printk(KERN_INFO "Synaptics Touchpad, model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx\n",
103 + printk(KERN_INFO "Synaptics Touchpad, model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx\n",
104 SYN_ID_MODEL(priv->identity),
105 SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity),
106 - priv->model_id, priv->capabilities, priv->ext_cap);
107 + priv->model_id, priv->capabilities, priv->ext_cap, priv->ext_cap_0c);
109 set_input_params(psmouse->dev, priv);
111 diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
112 index f0f40a3..ae37c5d 100644
113 --- a/drivers/input/mouse/synaptics.h
114 +++ b/drivers/input/mouse/synaptics.h
116 #define SYN_QUE_SERIAL_NUMBER_SUFFIX 0x07
117 #define SYN_QUE_RESOLUTION 0x08
118 #define SYN_QUE_EXT_CAPAB 0x09
119 +#define SYN_QUE_EXT_CAPAB_0C 0x0c
122 #define SYN_BIT_ABSOLUTE_MODE (1 << 7)
124 #define SYN_CAP_VALID(c) ((((c) & 0x00ff00) >> 8) == 0x47)
125 #define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20)
126 #define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12)
127 +#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16)
128 +#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100)
130 /* synaptics modes query bits */
131 #define SYN_MODE_ABSOLUTE(m) ((m) & (1 << 7))
132 @@ -96,6 +99,7 @@ struct synaptics_data {
133 unsigned long int model_id; /* Model-ID */
134 unsigned long int capabilities; /* Capabilities */
135 unsigned long int ext_cap; /* Extended Capabilities */
136 + unsigned long int ext_cap_0c; /* Ext Caps from 0x0c query */
137 unsigned long int identity; /* Identification */
138 int x_res; /* X resolution in units/mm */
139 int y_res; /* Y resolution in units/mm */