Skip to content

Commit 5f57d67

Browse files
tiwaidtor
authored andcommitted
Input: Add support of Synaptics Clickpad device
The new type of touchpads can be detected via a new query command 0x0c. The clickpad flags are in cap[0]:4 and cap[1]:0 bits. When the device is detected, the driver now reports only the left button as the supported buttons so that X11 driver can detect that the device is Clickpad. A Clickpad device gives the button events only as the middle button. The kernel driver morphs to the left button. The real handling of Clickpad is done rather in X driver side. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
1 parent 6d327cb commit 5f57d67

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

‎drivers/input/mouse/synaptics.c‎

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ static int synaptics_capability(struct psmouse *psmouse)
136136
if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap))
137137
return -1;
138138
priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2];
139-
priv->ext_cap = 0;
139+
priv->ext_cap = priv->ext_cap_0c = 0;
140+
140141
if (!SYN_CAP_VALID(priv->capabilities))
141142
return -1;
142143

@@ -149,7 +150,7 @@ static int synaptics_capability(struct psmouse *psmouse)
149150
if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 1) {
150151
if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) {
151152
printk(KERN_ERR "Synaptics claims to have extended capabilities,"
152-
" but I'm not able to read them.");
153+
" but I'm not able to read them.\n");
153154
} else {
154155
priv->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2];
155156

@@ -161,6 +162,16 @@ static int synaptics_capability(struct psmouse *psmouse)
161162
priv->ext_cap &= 0xff0fff;
162163
}
163164
}
165+
166+
if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 4) {
167+
if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB_0C, cap)) {
168+
printk(KERN_ERR "Synaptics claims to have extended capability 0x0c,"
169+
" but I'm not able to read it.\n");
170+
} else {
171+
priv->ext_cap_0c = (cap[0] << 16) | (cap[1] << 8) | cap[2];
172+
}
173+
}
174+
164175
return 0;
165176
}
166177

@@ -347,7 +358,15 @@ static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data
347358
hw->left = (buf[0] & 0x01) ? 1 : 0;
348359
hw->right = (buf[0] & 0x02) ? 1 : 0;
349360

350-
if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) {
361+
if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
362+
/*
363+
* Clickpad's button is transmitted as middle button,
364+
* however, since it is primary button, we will report
365+
* it as BTN_LEFT.
366+
*/
367+
hw->left = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
368+
369+
} else if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) {
351370
hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
352371
if (hw->w == 2)
353372
hw->scroll = (signed char)(buf[1]);
@@ -592,6 +611,12 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
592611

593612
dev->absres[ABS_X] = priv->x_res;
594613
dev->absres[ABS_Y] = priv->y_res;
614+
615+
if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
616+
/* Clickpads report only left button */
617+
__clear_bit(BTN_RIGHT, dev->keybit);
618+
__clear_bit(BTN_MIDDLE, dev->keybit);
619+
}
595620
}
596621

597622
static void synaptics_disconnect(struct psmouse *psmouse)
@@ -696,10 +721,10 @@ int synaptics_init(struct psmouse *psmouse)
696721

697722
priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;
698723

699-
printk(KERN_INFO "Synaptics Touchpad, model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx\n",
724+
printk(KERN_INFO "Synaptics Touchpad, model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx\n",
700725
SYN_ID_MODEL(priv->identity),
701726
SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity),
702-
priv->model_id, priv->capabilities, priv->ext_cap);
727+
priv->model_id, priv->capabilities, priv->ext_cap, priv->ext_cap_0c);
703728

704729
set_input_params(psmouse->dev, priv);
705730

‎drivers/input/mouse/synaptics.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define SYN_QUE_SERIAL_NUMBER_SUFFIX 0x07
1919
#define SYN_QUE_RESOLUTION 0x08
2020
#define SYN_QUE_EXT_CAPAB 0x09
21+
#define SYN_QUE_EXT_CAPAB_0C 0x0c
2122

2223
/* synatics modes */
2324
#define SYN_BIT_ABSOLUTE_MODE (1 << 7)
@@ -48,6 +49,8 @@
4849
#define SYN_CAP_VALID(c) ((((c) & 0x00ff00) >> 8) == 0x47)
4950
#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20)
5051
#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12)
52+
#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16)
53+
#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100)
5154

5255
/* synaptics modes query bits */
5356
#define SYN_MODE_ABSOLUTE(m) ((m) & (1 << 7))
@@ -96,6 +99,7 @@ struct synaptics_data {
9699
unsigned long int model_id; /* Model-ID */
97100
unsigned long int capabilities; /* Capabilities */
98101
unsigned long int ext_cap; /* Extended Capabilities */
102+
unsigned long int ext_cap_0c; /* Ext Caps from 0x0c query */
99103
unsigned long int identity; /* Identification */
100104
int x_res; /* X resolution in units/mm */
101105
int y_res; /* Y resolution in units/mm */

0 commit comments

Comments
 (0)