~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to debian/patches/features/all/input-alps-add-support-for-touchpads-with-4-directional-button.patch

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
4
 
 
5
 
commit 71bb21b677e89a2b438b804231f92b779beda5d7 upstream.
6
 
 
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).
13
 
 
14
 
Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
15
 
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
16
 
---
17
 
 drivers/input/mouse/alps.c |  100 ++++++++++++++++++++++++++++---------------
18
 
 1 files changed, 65 insertions(+), 35 deletions(-)
19
 
 
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
24
 
@@ -28,13 +28,16 @@
25
 
 #define dbg(format, arg...) do {} while (0)
26
 
 #endif
27
 
 
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
35
 
+
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 */
39
 
+
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 */
44
 
+
45
 
 
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 */
54
 
 };
55
 
 
56
 
 /*
57
 
@@ -83,6 +86,7 @@ static const struct alps_model_info alps_model_data[] = {
58
 
 static void alps_process_packet(struct psmouse *psmouse)
59
 
 {
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)
66
 
                return;
67
 
        }
68
 
 
69
 
-       if (priv->i->flags & ALPS_OLDPROTO) {
70
 
+       if (model->flags & ALPS_OLDPROTO) {
71
 
                left = packet[2] & 0x10;
72
 
                right = packet[2] & 0x08;
73
 
                middle = 0;
74
 
@@ -117,12 +121,12 @@ static void alps_process_packet(struct psmouse *psmouse)
75
 
                z = packet[5];
76
 
        }
77
 
 
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;
82
 
        }
83
 
 
84
 
-       if (priv->i->flags & ALPS_FW_BK_2) {
85
 
+       if (model->flags & ALPS_FW_BK_2) {
86
 
                back = packet[3] & 4;
87
 
                forward = packet[2] & 4;
88
 
                if ((middle = forward && back))
89
 
@@ -132,7 +136,7 @@ static void alps_process_packet(struct psmouse *psmouse)
90
 
        ges = packet[2] & 1;
91
 
        fin = packet[2] & 2;
92
 
 
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));
97
 
 
98
 
@@ -150,7 +154,8 @@ static void alps_process_packet(struct psmouse *psmouse)
99
 
        input_report_key(dev, BTN_MIDDLE, middle);
100
 
 
101
 
        /* Convert hardware tap to a reasonable Z value */
102
 
-       if (ges && !fin) z = 40;
103
 
+       if (ges && !fin)
104
 
+               z = 40;
105
 
 
106
 
        /*
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)
109
 
        }
110
 
        priv->prev_fin = fin;
111
 
 
112
 
-       if (z > 30) input_report_key(dev, BTN_TOUCH, 1);
113
 
-       if (z < 25) input_report_key(dev, BTN_TOUCH, 0);
114
 
+       if (z > 30)
115
 
+               input_report_key(dev, BTN_TOUCH, 1);
116
 
+       if (z < 25)
117
 
+               input_report_key(dev, BTN_TOUCH, 0);
118
 
 
119
 
        if (z > 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);
124
 
 
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));
128
 
 
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);
133
 
        }
134
 
 
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);
140
 
+       }
141
 
+
142
 
        input_sync(dev);
143
 
 }
144
 
 
145
 
@@ -393,15 +407,12 @@ static int alps_poll(struct psmouse *psmouse)
146
 
        return 0;
147
 
 }
148
 
 
149
 
-static int alps_hw_init(struct psmouse *psmouse, int *version)
150
 
+static int alps_hw_init(struct psmouse *psmouse)
151
 
 {
152
 
        struct alps_data *priv = psmouse->private;
153
 
+       const struct alps_model_info *model = priv->i;
154
 
 
155
 
-       priv->i = alps_get_model(psmouse, version);
156
 
-       if (!priv->i)
157
 
-               return -1;
158
 
-
159
 
-       if ((priv->i->flags & ALPS_PASS) &&
160
 
+       if ((model->flags & ALPS_PASS) &&
161
 
            alps_passthrough_mode(psmouse, true)) {
162
 
                return -1;
163
 
        }
164
 
@@ -416,7 +427,7 @@ static int alps_hw_init(struct psmouse *psmouse, int *version)
165
 
                return -1;
166
 
        }
167
 
 
168
 
-       if ((priv->i->flags & ALPS_PASS) &&
169
 
+       if ((model->flags & ALPS_PASS) &&
170
 
            alps_passthrough_mode(psmouse, false)) {
171
 
                return -1;
172
 
        }
173
 
@@ -432,12 +443,15 @@ static int alps_hw_init(struct psmouse *psmouse, int *version)
174
 
 
175
 
 static int alps_reconnect(struct psmouse *psmouse)
176
 
 {
177
 
+       const struct alps_model_info *model;
178
 
+
179
 
        psmouse_reset(psmouse);
180
 
 
181
 
-       if (alps_hw_init(psmouse, NULL))
182
 
+       model = alps_get_model(psmouse, NULL);
183
 
+       if (!model)
184
 
                return -1;
185
 
 
186
 
-       return 0;
187
 
+       return alps_hw_init(psmouse);
188
 
 }
189
 
 
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)
193
 
 {
194
 
        struct alps_data *priv;
195
 
+       const struct alps_model_info *model;
196
 
        struct input_dev *dev1 = psmouse->dev, *dev2;
197
 
        int version;
198
 
 
199
 
@@ -463,33 +478,48 @@ int alps_init(struct psmouse *psmouse)
200
 
        priv->dev2 = dev2;
201
 
        psmouse->private = priv;
202
 
 
203
 
-       if (alps_hw_init(psmouse, &version))
204
 
+       model = alps_get_model(psmouse, &version);
205
 
+       if (!model)
206
 
+               goto init_fail;
207
 
+
208
 
+       priv->i = model;
209
 
+
210
 
+       if (alps_hw_init(psmouse))
211
 
                goto init_fail;
212
 
 
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);
220
 
 
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);
225
 
 
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);
230
 
        }
231
 
 
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);
236
 
        }
237
 
 
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);
243
 
+       } else {
244
 
+               dev1->keybit[BIT_WORD(BTN_MIDDLE)] |= BIT_MASK(BTN_MIDDLE);
245
 
+       }
246
 
+
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;
256
 
 
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);
264
 
 
265
 
        if (input_register_device(priv->dev2))
266
 
                goto init_fail;
267
 
1.7.1
268