1
From: Maxim Levitsky <maximlevitsky@gmail.com>
2
Date: Mon, 16 Nov 2009 22:12:22 -0800
3
Subject: [PATCH] Input: ALPS - add support for touchpads with 4-directional button
5
commit 71bb21b677e89a2b438b804231f92b779beda5d7 upstream.
7
The touchpad on Acer Aspire 5720, 5520 and some other Aspire models
8
(signature 0x73, 0x02, 0x50) has a button that can be rocked in 4
9
different directions. Make the driver to generate BTN_0..BTN_3 events
10
in response. The Synaptics driver by default maps BTN_0 and BTN_1 to
11
up and down, so there should be no visible changes with the old setup
12
that generated BTN_FORWARD and BTN_BACK (also mapped to up and down).
14
Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
15
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
17
drivers/input/mouse/alps.c | 100 ++++++++++++++++++++++++++++---------------
18
1 files changed, 65 insertions(+), 35 deletions(-)
20
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
21
index f361106..a3f492a 100644
22
--- a/drivers/input/mouse/alps.c
23
+++ b/drivers/input/mouse/alps.c
25
#define dbg(format, arg...) do {} while (0)
28
-#define ALPS_DUALPOINT 0x01
29
-#define ALPS_WHEEL 0x02
30
-#define ALPS_FW_BK_1 0x04
31
-#define ALPS_4BTN 0x08
32
-#define ALPS_OLDPROTO 0x10
33
-#define ALPS_PASS 0x20
34
-#define ALPS_FW_BK_2 0x40
36
+#define ALPS_OLDPROTO 0x01 /* old style input */
37
+#define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */
38
+#define ALPS_PASS 0x04 /* device has a pass-through port */
40
+#define ALPS_WHEEL 0x08 /* hardware wheel present */
41
+#define ALPS_FW_BK_1 0x10 /* front & back buttons present */
42
+#define ALPS_FW_BK_2 0x20 /* front & back buttons present */
43
+#define ALPS_FOUR_BUTTONS 0x40 /* 4 direction button present */
46
static const struct alps_model_info alps_model_data[] = {
47
{ { 0x32, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */
48
@@ -56,7 +59,7 @@ static const struct alps_model_info alps_model_data[] = {
49
{ { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT },
50
{ { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */
51
{ { 0x62, 0x02, 0x14 }, 0xcf, 0xcf, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude E6500 */
52
- { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 }, /* Dell Vostro 1400 */
53
+ { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */
57
@@ -83,6 +86,7 @@ static const struct alps_model_info alps_model_data[] = {
58
static void alps_process_packet(struct psmouse *psmouse)
60
struct alps_data *priv = psmouse->private;
61
+ const struct alps_model_info *model = priv->i;
62
unsigned char *packet = psmouse->packet;
63
struct input_dev *dev = psmouse->dev;
64
struct input_dev *dev2 = priv->dev2;
65
@@ -101,7 +105,7 @@ static void alps_process_packet(struct psmouse *psmouse)
69
- if (priv->i->flags & ALPS_OLDPROTO) {
70
+ if (model->flags & ALPS_OLDPROTO) {
71
left = packet[2] & 0x10;
72
right = packet[2] & 0x08;
74
@@ -117,12 +121,12 @@ static void alps_process_packet(struct psmouse *psmouse)
78
- if (priv->i->flags & ALPS_FW_BK_1) {
79
+ if (model->flags & ALPS_FW_BK_1) {
80
back = packet[0] & 0x10;
81
forward = packet[2] & 4;
84
- if (priv->i->flags & ALPS_FW_BK_2) {
85
+ if (model->flags & ALPS_FW_BK_2) {
87
forward = packet[2] & 4;
88
if ((middle = forward && back))
89
@@ -132,7 +136,7 @@ static void alps_process_packet(struct psmouse *psmouse)
93
- if ((priv->i->flags & ALPS_DUALPOINT) && z == 127) {
94
+ if ((model->flags & ALPS_DUALPOINT) && z == 127) {
95
input_report_rel(dev2, REL_X, (x > 383 ? (x - 768) : x));
96
input_report_rel(dev2, REL_Y, -(y > 255 ? (y - 512) : y));
98
@@ -150,7 +154,8 @@ static void alps_process_packet(struct psmouse *psmouse)
99
input_report_key(dev, BTN_MIDDLE, middle);
101
/* Convert hardware tap to a reasonable Z value */
102
- if (ges && !fin) z = 40;
107
* A "tap and drag" operation is reported by the hardware as a transition
108
@@ -166,8 +171,10 @@ static void alps_process_packet(struct psmouse *psmouse)
110
priv->prev_fin = fin;
112
- if (z > 30) input_report_key(dev, BTN_TOUCH, 1);
113
- if (z < 25) input_report_key(dev, BTN_TOUCH, 0);
115
+ input_report_key(dev, BTN_TOUCH, 1);
117
+ input_report_key(dev, BTN_TOUCH, 0);
120
input_report_abs(dev, ABS_X, x);
121
@@ -177,14 +184,21 @@ static void alps_process_packet(struct psmouse *psmouse)
122
input_report_abs(dev, ABS_PRESSURE, z);
123
input_report_key(dev, BTN_TOOL_FINGER, z > 0);
125
- if (priv->i->flags & ALPS_WHEEL)
126
+ if (model->flags & ALPS_WHEEL)
127
input_report_rel(dev, REL_WHEEL, ((packet[2] << 1) & 0x08) - ((packet[0] >> 4) & 0x07));
129
- if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) {
130
+ if (model->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) {
131
input_report_key(dev, BTN_FORWARD, forward);
132
input_report_key(dev, BTN_BACK, back);
135
+ if (model->flags & ALPS_FOUR_BUTTONS) {
136
+ input_report_key(dev, BTN_0, packet[2] & 4);
137
+ input_report_key(dev, BTN_1, packet[0] & 0x10);
138
+ input_report_key(dev, BTN_2, packet[3] & 4);
139
+ input_report_key(dev, BTN_3, packet[0] & 0x20);
145
@@ -393,15 +407,12 @@ static int alps_poll(struct psmouse *psmouse)
149
-static int alps_hw_init(struct psmouse *psmouse, int *version)
150
+static int alps_hw_init(struct psmouse *psmouse)
152
struct alps_data *priv = psmouse->private;
153
+ const struct alps_model_info *model = priv->i;
155
- priv->i = alps_get_model(psmouse, version);
159
- if ((priv->i->flags & ALPS_PASS) &&
160
+ if ((model->flags & ALPS_PASS) &&
161
alps_passthrough_mode(psmouse, true)) {
164
@@ -416,7 +427,7 @@ static int alps_hw_init(struct psmouse *psmouse, int *version)
168
- if ((priv->i->flags & ALPS_PASS) &&
169
+ if ((model->flags & ALPS_PASS) &&
170
alps_passthrough_mode(psmouse, false)) {
173
@@ -432,12 +443,15 @@ static int alps_hw_init(struct psmouse *psmouse, int *version)
175
static int alps_reconnect(struct psmouse *psmouse)
177
+ const struct alps_model_info *model;
179
psmouse_reset(psmouse);
181
- if (alps_hw_init(psmouse, NULL))
182
+ model = alps_get_model(psmouse, NULL);
187
+ return alps_hw_init(psmouse);
190
static void alps_disconnect(struct psmouse *psmouse)
191
@@ -452,6 +466,7 @@ static void alps_disconnect(struct psmouse *psmouse)
192
int alps_init(struct psmouse *psmouse)
194
struct alps_data *priv;
195
+ const struct alps_model_info *model;
196
struct input_dev *dev1 = psmouse->dev, *dev2;
199
@@ -463,33 +478,48 @@ int alps_init(struct psmouse *psmouse)
201
psmouse->private = priv;
203
- if (alps_hw_init(psmouse, &version))
204
+ model = alps_get_model(psmouse, &version);
210
+ if (alps_hw_init(psmouse))
213
dev1->evbit[BIT_WORD(EV_KEY)] |= BIT_MASK(EV_KEY);
214
dev1->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH);
215
dev1->keybit[BIT_WORD(BTN_TOOL_FINGER)] |= BIT_MASK(BTN_TOOL_FINGER);
216
- dev1->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) |
217
- BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
218
+ dev1->keybit[BIT_WORD(BTN_LEFT)] |=
219
+ BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT);
221
dev1->evbit[BIT_WORD(EV_ABS)] |= BIT_MASK(EV_ABS);
222
input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0);
223
input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0);
224
input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0);
226
- if (priv->i->flags & ALPS_WHEEL) {
227
+ if (model->flags & ALPS_WHEEL) {
228
dev1->evbit[BIT_WORD(EV_REL)] |= BIT_MASK(EV_REL);
229
dev1->relbit[BIT_WORD(REL_WHEEL)] |= BIT_MASK(REL_WHEEL);
232
- if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) {
233
+ if (model->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) {
234
dev1->keybit[BIT_WORD(BTN_FORWARD)] |= BIT_MASK(BTN_FORWARD);
235
dev1->keybit[BIT_WORD(BTN_BACK)] |= BIT_MASK(BTN_BACK);
238
+ if (model->flags & ALPS_FOUR_BUTTONS) {
239
+ dev1->keybit[BIT_WORD(BTN_0)] |= BIT_MASK(BTN_0);
240
+ dev1->keybit[BIT_WORD(BTN_1)] |= BIT_MASK(BTN_1);
241
+ dev1->keybit[BIT_WORD(BTN_2)] |= BIT_MASK(BTN_2);
242
+ dev1->keybit[BIT_WORD(BTN_3)] |= BIT_MASK(BTN_3);
244
+ dev1->keybit[BIT_WORD(BTN_MIDDLE)] |= BIT_MASK(BTN_MIDDLE);
247
snprintf(priv->phys, sizeof(priv->phys), "%s/input1", psmouse->ps2dev.serio->phys);
248
dev2->phys = priv->phys;
249
- dev2->name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse";
250
+ dev2->name = (model->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse";
251
dev2->id.bustype = BUS_I8042;
252
dev2->id.vendor = 0x0002;
253
dev2->id.product = PSMOUSE_ALPS;
254
@@ -497,9 +527,9 @@ int alps_init(struct psmouse *psmouse)
255
dev2->dev.parent = &psmouse->ps2dev.serio->dev;
257
dev2->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
258
- dev2->relbit[BIT_WORD(REL_X)] |= BIT_MASK(REL_X) | BIT_MASK(REL_Y);
259
- dev2->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) |
260
- BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
261
+ dev2->relbit[BIT_WORD(REL_X)] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
262
+ dev2->keybit[BIT_WORD(BTN_LEFT)] =
263
+ BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
265
if (input_register_device(priv->dev2))