Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ALPS touchpad PS/2 mouse driver |
| 3 | * |
| 4 | * Copyright (c) 2003 Neil Brown <neilb@cse.unsw.edu.au> |
Peter Osterlund | 963f626 | 2005-07-11 01:08:04 -0500 | [diff] [blame] | 5 | * Copyright (c) 2003-2005 Peter Osterlund <petero2@telia.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Copyright (c) 2004 Dmitry Torokhov <dtor@mail.ru> |
| 7 | * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz> |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 8 | * Copyright (c) 2009 Sebastian Kapfer <sebastian_kapfer@gmx.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
| 10 | * ALPS detection, tap switching and status querying info is taken from |
| 11 | * tpconfig utility (by C. Scott Ananian and Bruce Kall). |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify it |
| 14 | * under the terms of the GNU General Public License version 2 as published by |
| 15 | * the Free Software Foundation. |
| 16 | */ |
| 17 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 18 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/input.h> |
| 20 | #include <linux/serio.h> |
| 21 | #include <linux/libps2.h> |
| 22 | |
| 23 | #include "psmouse.h" |
| 24 | #include "alps.h" |
| 25 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 26 | /* |
| 27 | * Definitions for ALPS version 3 and 4 command mode protocol |
| 28 | */ |
| 29 | #define ALPS_CMD_NIBBLE_10 0x01f2 |
| 30 | |
| 31 | static const struct alps_nibble_commands alps_v3_nibble_commands[] = { |
| 32 | { PSMOUSE_CMD_SETPOLL, 0x00 }, /* 0 */ |
| 33 | { PSMOUSE_CMD_RESET_DIS, 0x00 }, /* 1 */ |
| 34 | { PSMOUSE_CMD_SETSCALE21, 0x00 }, /* 2 */ |
| 35 | { PSMOUSE_CMD_SETRATE, 0x0a }, /* 3 */ |
| 36 | { PSMOUSE_CMD_SETRATE, 0x14 }, /* 4 */ |
| 37 | { PSMOUSE_CMD_SETRATE, 0x28 }, /* 5 */ |
| 38 | { PSMOUSE_CMD_SETRATE, 0x3c }, /* 6 */ |
| 39 | { PSMOUSE_CMD_SETRATE, 0x50 }, /* 7 */ |
| 40 | { PSMOUSE_CMD_SETRATE, 0x64 }, /* 8 */ |
| 41 | { PSMOUSE_CMD_SETRATE, 0xc8 }, /* 9 */ |
| 42 | { ALPS_CMD_NIBBLE_10, 0x00 }, /* a */ |
| 43 | { PSMOUSE_CMD_SETRES, 0x00 }, /* b */ |
| 44 | { PSMOUSE_CMD_SETRES, 0x01 }, /* c */ |
| 45 | { PSMOUSE_CMD_SETRES, 0x02 }, /* d */ |
| 46 | { PSMOUSE_CMD_SETRES, 0x03 }, /* e */ |
| 47 | { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */ |
| 48 | }; |
| 49 | |
| 50 | static const struct alps_nibble_commands alps_v4_nibble_commands[] = { |
| 51 | { PSMOUSE_CMD_ENABLE, 0x00 }, /* 0 */ |
| 52 | { PSMOUSE_CMD_RESET_DIS, 0x00 }, /* 1 */ |
| 53 | { PSMOUSE_CMD_SETSCALE21, 0x00 }, /* 2 */ |
| 54 | { PSMOUSE_CMD_SETRATE, 0x0a }, /* 3 */ |
| 55 | { PSMOUSE_CMD_SETRATE, 0x14 }, /* 4 */ |
| 56 | { PSMOUSE_CMD_SETRATE, 0x28 }, /* 5 */ |
| 57 | { PSMOUSE_CMD_SETRATE, 0x3c }, /* 6 */ |
| 58 | { PSMOUSE_CMD_SETRATE, 0x50 }, /* 7 */ |
| 59 | { PSMOUSE_CMD_SETRATE, 0x64 }, /* 8 */ |
| 60 | { PSMOUSE_CMD_SETRATE, 0xc8 }, /* 9 */ |
| 61 | { ALPS_CMD_NIBBLE_10, 0x00 }, /* a */ |
| 62 | { PSMOUSE_CMD_SETRES, 0x00 }, /* b */ |
| 63 | { PSMOUSE_CMD_SETRES, 0x01 }, /* c */ |
| 64 | { PSMOUSE_CMD_SETRES, 0x02 }, /* d */ |
| 65 | { PSMOUSE_CMD_SETRES, 0x03 }, /* e */ |
| 66 | { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */ |
| 67 | }; |
| 68 | |
| 69 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 70 | #define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */ |
| 71 | #define ALPS_PASS 0x04 /* device has a pass-through port */ |
| 72 | |
| 73 | #define ALPS_WHEEL 0x08 /* hardware wheel present */ |
| 74 | #define ALPS_FW_BK_1 0x10 /* front & back buttons present */ |
| 75 | #define ALPS_FW_BK_2 0x20 /* front & back buttons present */ |
| 76 | #define ALPS_FOUR_BUTTONS 0x40 /* 4 direction button present */ |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 77 | #define ALPS_PS2_INTERLEAVED 0x80 /* 3-byte PS/2 packet interleaved with |
| 78 | 6-byte ALPS packet */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Helge Deller | e38de67 | 2006-09-10 21:54:39 -0400 | [diff] [blame] | 80 | static const struct alps_model_info alps_model_data[] = { |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 81 | { { 0x32, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */ |
| 82 | { { 0x33, 0x02, 0x0a }, 0x00, ALPS_PROTO_V1, 0x88, 0xf8, 0 }, /* UMAX-530T */ |
| 83 | { { 0x53, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
| 84 | { { 0x53, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
| 85 | { { 0x60, 0x03, 0xc8 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, /* HP ze1115 */ |
| 86 | { { 0x63, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
| 87 | { { 0x63, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
| 88 | { { 0x63, 0x02, 0x28 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */ |
| 89 | { { 0x63, 0x02, 0x3c }, 0x00, ALPS_PROTO_V2, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */ |
| 90 | { { 0x63, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */ |
| 91 | { { 0x63, 0x02, 0x64 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
| 92 | { { 0x63, 0x03, 0xc8 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D800 */ |
| 93 | { { 0x73, 0x00, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_DUALPOINT }, /* ThinkPad R61 8918-5QG */ |
| 94 | { { 0x73, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, |
| 95 | { { 0x73, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */ |
| 96 | { { 0x20, 0x02, 0x0e }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ |
| 97 | { { 0x22, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, |
| 98 | { { 0x22, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 99 | /* Dell Latitude E5500, E6400, E6500, Precision M4400 */ |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 100 | { { 0x62, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 101 | ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 102 | { { 0x73, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */ |
| 103 | { { 0x52, 0x01, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, |
| 104 | ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */ |
| 105 | { { 0x73, 0x02, 0x64 }, 0x9b, ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT }, |
| 106 | { { 0x73, 0x02, 0x64 }, 0x9d, ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT }, |
| 107 | { { 0x73, 0x02, 0x64 }, 0x8a, ALPS_PROTO_V4, 0x8f, 0x8f, 0 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | /* |
| 111 | * XXX - this entry is suspicious. First byte has zero lower nibble, |
| 112 | * which is what a normal mouse would report. Also, the value 0x0e |
| 113 | * isn't valid per PS/2 spec. |
| 114 | */ |
| 115 | |
Seth Forshee | d4b347b | 2011-11-07 19:53:15 -0800 | [diff] [blame] | 116 | /* Packet formats are described in Documentation/input/alps.txt */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 118 | static bool alps_is_valid_first_byte(const struct alps_model_info *model, |
| 119 | unsigned char data) |
| 120 | { |
| 121 | return (data & model->mask0) == model->byte0; |
| 122 | } |
| 123 | |
| 124 | static void alps_report_buttons(struct psmouse *psmouse, |
| 125 | struct input_dev *dev1, struct input_dev *dev2, |
| 126 | int left, int right, int middle) |
| 127 | { |
Martin Buck | c91ed05 | 2010-03-13 22:23:58 -0800 | [diff] [blame] | 128 | struct input_dev *dev; |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 129 | |
Martin Buck | c91ed05 | 2010-03-13 22:23:58 -0800 | [diff] [blame] | 130 | /* |
| 131 | * If shared button has already been reported on the |
| 132 | * other device (dev2) then this event should be also |
| 133 | * sent through that device. |
| 134 | */ |
| 135 | dev = test_bit(BTN_LEFT, dev2->key) ? dev2 : dev1; |
| 136 | input_report_key(dev, BTN_LEFT, left); |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 137 | |
Martin Buck | c91ed05 | 2010-03-13 22:23:58 -0800 | [diff] [blame] | 138 | dev = test_bit(BTN_RIGHT, dev2->key) ? dev2 : dev1; |
| 139 | input_report_key(dev, BTN_RIGHT, right); |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 140 | |
Martin Buck | c91ed05 | 2010-03-13 22:23:58 -0800 | [diff] [blame] | 141 | dev = test_bit(BTN_MIDDLE, dev2->key) ? dev2 : dev1; |
| 142 | input_report_key(dev, BTN_MIDDLE, middle); |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 143 | |
Martin Buck | c91ed05 | 2010-03-13 22:23:58 -0800 | [diff] [blame] | 144 | /* |
| 145 | * Sync the _other_ device now, we'll do the first |
| 146 | * device later once we report the rest of the events. |
| 147 | */ |
| 148 | input_sync(dev2); |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 149 | } |
| 150 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 151 | static void alps_process_packet_v1_v2(struct psmouse *psmouse) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | { |
| 153 | struct alps_data *priv = psmouse->private; |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 154 | const struct alps_model_info *model = priv->i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | unsigned char *packet = psmouse->packet; |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 156 | struct input_dev *dev = psmouse->dev; |
| 157 | struct input_dev *dev2 = priv->dev2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | int x, y, z, ges, fin, left, right, middle; |
Ivan Casado Ruiz | c30b4c1 | 2005-06-01 02:39:18 -0500 | [diff] [blame] | 159 | int back = 0, forward = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
Seth Forshee | fa629ef | 2011-11-07 19:53:24 -0800 | [diff] [blame] | 161 | if (model->proto_version == ALPS_PROTO_V1) { |
Yotam Medini | d2f4012 | 2006-05-29 23:30:36 -0400 | [diff] [blame] | 162 | left = packet[2] & 0x10; |
| 163 | right = packet[2] & 0x08; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | middle = 0; |
| 165 | x = packet[1] | ((packet[0] & 0x07) << 7); |
| 166 | y = packet[4] | ((packet[3] & 0x07) << 7); |
| 167 | z = packet[5]; |
| 168 | } else { |
| 169 | left = packet[3] & 1; |
| 170 | right = packet[3] & 2; |
| 171 | middle = packet[3] & 4; |
| 172 | x = packet[1] | ((packet[2] & 0x78) << (7 - 3)); |
| 173 | y = packet[4] | ((packet[3] & 0x70) << (7 - 4)); |
| 174 | z = packet[5]; |
| 175 | } |
| 176 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 177 | if (model->flags & ALPS_FW_BK_1) { |
Laszlo Kajan | 3c00bb9 | 2008-03-18 00:39:55 -0400 | [diff] [blame] | 178 | back = packet[0] & 0x10; |
| 179 | forward = packet[2] & 4; |
Ivan Casado Ruiz | c30b4c1 | 2005-06-01 02:39:18 -0500 | [diff] [blame] | 180 | } |
| 181 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 182 | if (model->flags & ALPS_FW_BK_2) { |
Ivan Casado Ruiz | c30b4c1 | 2005-06-01 02:39:18 -0500 | [diff] [blame] | 183 | back = packet[3] & 4; |
| 184 | forward = packet[2] & 4; |
| 185 | if ((middle = forward && back)) |
| 186 | forward = back = 0; |
| 187 | } |
| 188 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | ges = packet[2] & 1; |
| 190 | fin = packet[2] & 2; |
| 191 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 192 | if ((model->flags & ALPS_DUALPOINT) && z == 127) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | input_report_rel(dev2, REL_X, (x > 383 ? (x - 768) : x)); |
| 194 | input_report_rel(dev2, REL_Y, -(y > 255 ? (y - 512) : y)); |
Ulrich Dangel | d7ed5d8 | 2009-06-11 00:15:09 -0700 | [diff] [blame] | 195 | |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 196 | alps_report_buttons(psmouse, dev2, dev, left, right, middle); |
Ulrich Dangel | d7ed5d8 | 2009-06-11 00:15:09 -0700 | [diff] [blame] | 197 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | input_sync(dev2); |
| 199 | return; |
| 200 | } |
| 201 | |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 202 | alps_report_buttons(psmouse, dev, dev2, left, right, middle); |
Ulrich Dangel | d7ed5d8 | 2009-06-11 00:15:09 -0700 | [diff] [blame] | 203 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | /* Convert hardware tap to a reasonable Z value */ |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 205 | if (ges && !fin) |
| 206 | z = 40; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | |
| 208 | /* |
| 209 | * A "tap and drag" operation is reported by the hardware as a transition |
| 210 | * from (!fin && ges) to (fin && ges). This should be translated to the |
| 211 | * sequence Z>0, Z==0, Z>0, so the Z==0 event has to be generated manually. |
| 212 | */ |
| 213 | if (ges && fin && !priv->prev_fin) { |
| 214 | input_report_abs(dev, ABS_X, x); |
| 215 | input_report_abs(dev, ABS_Y, y); |
| 216 | input_report_abs(dev, ABS_PRESSURE, 0); |
| 217 | input_report_key(dev, BTN_TOOL_FINGER, 0); |
| 218 | input_sync(dev); |
| 219 | } |
| 220 | priv->prev_fin = fin; |
| 221 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 222 | if (z > 30) |
| 223 | input_report_key(dev, BTN_TOUCH, 1); |
| 224 | if (z < 25) |
| 225 | input_report_key(dev, BTN_TOUCH, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | |
| 227 | if (z > 0) { |
| 228 | input_report_abs(dev, ABS_X, x); |
| 229 | input_report_abs(dev, ABS_Y, y); |
| 230 | } |
| 231 | |
| 232 | input_report_abs(dev, ABS_PRESSURE, z); |
| 233 | input_report_key(dev, BTN_TOOL_FINGER, z > 0); |
| 234 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 235 | if (model->flags & ALPS_WHEEL) |
Vojtech Pavlik | e6c047b | 2005-09-04 01:40:43 -0500 | [diff] [blame] | 236 | input_report_rel(dev, REL_WHEEL, ((packet[2] << 1) & 0x08) - ((packet[0] >> 4) & 0x07)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 238 | if (model->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { |
Ivan Casado Ruiz | c30b4c1 | 2005-06-01 02:39:18 -0500 | [diff] [blame] | 239 | input_report_key(dev, BTN_FORWARD, forward); |
| 240 | input_report_key(dev, BTN_BACK, back); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | } |
| 242 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 243 | if (model->flags & ALPS_FOUR_BUTTONS) { |
| 244 | input_report_key(dev, BTN_0, packet[2] & 4); |
| 245 | input_report_key(dev, BTN_1, packet[0] & 0x10); |
| 246 | input_report_key(dev, BTN_2, packet[3] & 4); |
| 247 | input_report_key(dev, BTN_3, packet[0] & 0x20); |
| 248 | } |
| 249 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | input_sync(dev); |
| 251 | } |
| 252 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 253 | static void alps_process_trackstick_packet_v3(struct psmouse *psmouse) |
| 254 | { |
| 255 | struct alps_data *priv = psmouse->private; |
| 256 | unsigned char *packet = psmouse->packet; |
| 257 | struct input_dev *dev = priv->dev2; |
| 258 | int x, y, z, left, right, middle; |
| 259 | |
| 260 | /* Sanity check packet */ |
| 261 | if (!(packet[0] & 0x40)) { |
| 262 | psmouse_dbg(psmouse, "Bad trackstick packet, discarding\n"); |
| 263 | return; |
| 264 | } |
| 265 | |
| 266 | /* |
| 267 | * There's a special packet that seems to indicate the end |
| 268 | * of a stream of trackstick data. Filter these out. |
| 269 | */ |
| 270 | if (packet[1] == 0x7f && packet[2] == 0x7f && packet[4] == 0x7f) |
| 271 | return; |
| 272 | |
| 273 | x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f)); |
| 274 | y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f)); |
| 275 | z = (packet[4] & 0x7c) >> 2; |
| 276 | |
| 277 | /* |
| 278 | * The x and y values tend to be quite large, and when used |
| 279 | * alone the trackstick is difficult to use. Scale them down |
| 280 | * to compensate. |
| 281 | */ |
| 282 | x /= 8; |
| 283 | y /= 8; |
| 284 | |
| 285 | input_report_rel(dev, REL_X, x); |
| 286 | input_report_rel(dev, REL_Y, -y); |
| 287 | |
| 288 | /* |
| 289 | * Most ALPS models report the trackstick buttons in the touchpad |
| 290 | * packets, but a few report them here. No reliable way has been |
| 291 | * found to differentiate between the models upfront, so we enable |
| 292 | * the quirk in response to seeing a button press in the trackstick |
| 293 | * packet. |
| 294 | */ |
| 295 | left = packet[3] & 0x01; |
| 296 | right = packet[3] & 0x02; |
| 297 | middle = packet[3] & 0x04; |
| 298 | |
| 299 | if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) && |
| 300 | (left || right || middle)) |
| 301 | priv->quirks |= ALPS_QUIRK_TRACKSTICK_BUTTONS; |
| 302 | |
| 303 | if (priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) { |
| 304 | input_report_key(dev, BTN_LEFT, left); |
| 305 | input_report_key(dev, BTN_RIGHT, right); |
| 306 | input_report_key(dev, BTN_MIDDLE, middle); |
| 307 | } |
| 308 | |
| 309 | input_sync(dev); |
| 310 | return; |
| 311 | } |
| 312 | |
| 313 | static void alps_process_touchpad_packet_v3(struct psmouse *psmouse) |
| 314 | { |
| 315 | struct alps_data *priv = psmouse->private; |
| 316 | unsigned char *packet = psmouse->packet; |
| 317 | struct input_dev *dev = psmouse->dev; |
| 318 | struct input_dev *dev2 = priv->dev2; |
| 319 | int x, y, z; |
| 320 | int left, right, middle; |
| 321 | |
| 322 | /* |
| 323 | * There's no single feature of touchpad position and bitmap |
| 324 | * packets that can be used to distinguish between them. We |
| 325 | * rely on the fact that a bitmap packet should always follow |
| 326 | * a position packet with bit 6 of packet[4] set. |
| 327 | */ |
| 328 | if (priv->multi_packet) { |
| 329 | priv->multi_packet = 0; |
| 330 | |
| 331 | /* |
| 332 | * Sometimes a position packet will indicate a multi-packet |
| 333 | * sequence, but then what follows is another position |
| 334 | * packet. Check for this, and when it happens process the |
| 335 | * position packet as usual. |
| 336 | */ |
| 337 | if (packet[0] & 0x40) { |
| 338 | /* |
| 339 | * Bitmap packets are not yet supported, so for now |
| 340 | * just ignore them. |
| 341 | */ |
| 342 | return; |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | if (!priv->multi_packet && (packet[4] & 0x40)) |
| 347 | priv->multi_packet = 1; |
| 348 | else |
| 349 | priv->multi_packet = 0; |
| 350 | |
| 351 | left = packet[3] & 0x01; |
| 352 | right = packet[3] & 0x02; |
| 353 | middle = packet[3] & 0x04; |
| 354 | |
| 355 | x = ((packet[1] & 0x7f) << 4) | ((packet[4] & 0x30) >> 2) | |
| 356 | ((packet[0] & 0x30) >> 4); |
| 357 | y = ((packet[2] & 0x7f) << 4) | (packet[4] & 0x0f); |
| 358 | z = packet[5] & 0x7f; |
| 359 | |
| 360 | /* |
| 361 | * Sometimes the hardware sends a single packet with z = 0 |
| 362 | * in the middle of a stream. Real releases generate packets |
| 363 | * with x, y, and z all zero, so these seem to be flukes. |
| 364 | * Ignore them. |
| 365 | */ |
| 366 | if (x && y && !z) |
| 367 | return; |
| 368 | |
| 369 | if (z >= 64) |
| 370 | input_report_key(dev, BTN_TOUCH, 1); |
| 371 | else |
| 372 | input_report_key(dev, BTN_TOUCH, 0); |
| 373 | |
| 374 | if (z > 0) { |
| 375 | input_report_abs(dev, ABS_X, x); |
| 376 | input_report_abs(dev, ABS_Y, y); |
| 377 | } |
| 378 | input_report_abs(dev, ABS_PRESSURE, z); |
| 379 | |
| 380 | input_report_key(dev, BTN_TOOL_FINGER, z > 0); |
| 381 | input_report_key(dev, BTN_LEFT, left); |
| 382 | input_report_key(dev, BTN_RIGHT, right); |
| 383 | input_report_key(dev, BTN_MIDDLE, middle); |
| 384 | |
| 385 | input_sync(dev); |
| 386 | |
| 387 | if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) { |
| 388 | left = packet[3] & 0x10; |
| 389 | right = packet[3] & 0x20; |
| 390 | middle = packet[3] & 0x40; |
| 391 | |
| 392 | input_report_key(dev2, BTN_LEFT, left); |
| 393 | input_report_key(dev2, BTN_RIGHT, right); |
| 394 | input_report_key(dev2, BTN_MIDDLE, middle); |
| 395 | input_sync(dev2); |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | static void alps_process_packet_v3(struct psmouse *psmouse) |
| 400 | { |
| 401 | unsigned char *packet = psmouse->packet; |
| 402 | |
| 403 | /* |
| 404 | * v3 protocol packets come in three types, two representing |
| 405 | * touchpad data and one representing trackstick data. |
| 406 | * Trackstick packets seem to be distinguished by always |
| 407 | * having 0x3f in the last byte. This value has never been |
| 408 | * observed in the last byte of either of the other types |
| 409 | * of packets. |
| 410 | */ |
| 411 | if (packet[5] == 0x3f) { |
| 412 | alps_process_trackstick_packet_v3(psmouse); |
| 413 | return; |
| 414 | } |
| 415 | |
| 416 | alps_process_touchpad_packet_v3(psmouse); |
| 417 | } |
| 418 | |
| 419 | static void alps_process_packet_v4(struct psmouse *psmouse) |
| 420 | { |
| 421 | unsigned char *packet = psmouse->packet; |
| 422 | struct input_dev *dev = psmouse->dev; |
| 423 | int x, y, z; |
| 424 | int left, right; |
| 425 | |
| 426 | left = packet[4] & 0x01; |
| 427 | right = packet[4] & 0x02; |
| 428 | |
| 429 | x = ((packet[1] & 0x7f) << 4) | ((packet[3] & 0x30) >> 2) | |
| 430 | ((packet[0] & 0x30) >> 4); |
| 431 | y = ((packet[2] & 0x7f) << 4) | (packet[3] & 0x0f); |
| 432 | z = packet[5] & 0x7f; |
| 433 | |
| 434 | if (z >= 64) |
| 435 | input_report_key(dev, BTN_TOUCH, 1); |
| 436 | else |
| 437 | input_report_key(dev, BTN_TOUCH, 0); |
| 438 | |
| 439 | if (z > 0) { |
| 440 | input_report_abs(dev, ABS_X, x); |
| 441 | input_report_abs(dev, ABS_Y, y); |
| 442 | } |
| 443 | input_report_abs(dev, ABS_PRESSURE, z); |
| 444 | |
| 445 | input_report_key(dev, BTN_TOOL_FINGER, z > 0); |
| 446 | input_report_key(dev, BTN_LEFT, left); |
| 447 | input_report_key(dev, BTN_RIGHT, right); |
| 448 | |
| 449 | input_sync(dev); |
| 450 | } |
| 451 | |
| 452 | static void alps_process_packet(struct psmouse *psmouse) |
| 453 | { |
| 454 | struct alps_data *priv = psmouse->private; |
| 455 | const struct alps_model_info *model = priv->i; |
| 456 | |
| 457 | switch (model->proto_version) { |
| 458 | case ALPS_PROTO_V1: |
| 459 | case ALPS_PROTO_V2: |
| 460 | alps_process_packet_v1_v2(psmouse); |
| 461 | break; |
| 462 | case ALPS_PROTO_V3: |
| 463 | alps_process_packet_v3(psmouse); |
| 464 | break; |
| 465 | case ALPS_PROTO_V4: |
| 466 | alps_process_packet_v4(psmouse); |
| 467 | break; |
| 468 | } |
| 469 | } |
| 470 | |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 471 | static void alps_report_bare_ps2_packet(struct psmouse *psmouse, |
| 472 | unsigned char packet[], |
| 473 | bool report_buttons) |
| 474 | { |
| 475 | struct alps_data *priv = psmouse->private; |
| 476 | struct input_dev *dev2 = priv->dev2; |
| 477 | |
| 478 | if (report_buttons) |
| 479 | alps_report_buttons(psmouse, dev2, psmouse->dev, |
| 480 | packet[0] & 1, packet[0] & 2, packet[0] & 4); |
| 481 | |
| 482 | input_report_rel(dev2, REL_X, |
| 483 | packet[1] ? packet[1] - ((packet[0] << 4) & 0x100) : 0); |
| 484 | input_report_rel(dev2, REL_Y, |
| 485 | packet[2] ? ((packet[0] << 3) & 0x100) - packet[2] : 0); |
| 486 | |
| 487 | input_sync(dev2); |
| 488 | } |
| 489 | |
| 490 | static psmouse_ret_t alps_handle_interleaved_ps2(struct psmouse *psmouse) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | { |
| 492 | struct alps_data *priv = psmouse->private; |
| 493 | |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 494 | if (psmouse->pktcnt < 6) |
| 495 | return PSMOUSE_GOOD_DATA; |
| 496 | |
| 497 | if (psmouse->pktcnt == 6) { |
| 498 | /* |
| 499 | * Start a timer to flush the packet if it ends up last |
| 500 | * 6-byte packet in the stream. Timer needs to fire |
| 501 | * psmouse core times out itself. 20 ms should be enough |
| 502 | * to decide if we are getting more data or not. |
| 503 | */ |
| 504 | mod_timer(&priv->timer, jiffies + msecs_to_jiffies(20)); |
| 505 | return PSMOUSE_GOOD_DATA; |
| 506 | } |
| 507 | |
| 508 | del_timer(&priv->timer); |
| 509 | |
| 510 | if (psmouse->packet[6] & 0x80) { |
| 511 | |
| 512 | /* |
| 513 | * Highest bit is set - that means we either had |
| 514 | * complete ALPS packet and this is start of the |
| 515 | * next packet or we got garbage. |
| 516 | */ |
| 517 | |
| 518 | if (((psmouse->packet[3] | |
| 519 | psmouse->packet[4] | |
| 520 | psmouse->packet[5]) & 0x80) || |
| 521 | (!alps_is_valid_first_byte(priv->i, psmouse->packet[6]))) { |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 522 | psmouse_dbg(psmouse, |
| 523 | "refusing packet %x %x %x %x (suspected interleaved ps/2)\n", |
| 524 | psmouse->packet[3], psmouse->packet[4], |
| 525 | psmouse->packet[5], psmouse->packet[6]); |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 526 | return PSMOUSE_BAD_DATA; |
| 527 | } |
| 528 | |
| 529 | alps_process_packet(psmouse); |
| 530 | |
| 531 | /* Continue with the next packet */ |
| 532 | psmouse->packet[0] = psmouse->packet[6]; |
| 533 | psmouse->pktcnt = 1; |
| 534 | |
| 535 | } else { |
| 536 | |
| 537 | /* |
| 538 | * High bit is 0 - that means that we indeed got a PS/2 |
| 539 | * packet in the middle of ALPS packet. |
| 540 | * |
| 541 | * There is also possibility that we got 6-byte ALPS |
| 542 | * packet followed by 3-byte packet from trackpoint. We |
| 543 | * can not distinguish between these 2 scenarios but |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 544 | * because the latter is unlikely to happen in course of |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 545 | * normal operation (user would need to press all |
| 546 | * buttons on the pad and start moving trackpoint |
| 547 | * without touching the pad surface) we assume former. |
| 548 | * Even if we are wrong the wost thing that would happen |
| 549 | * the cursor would jump but we should not get protocol |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 550 | * de-synchronization. |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 551 | */ |
| 552 | |
| 553 | alps_report_bare_ps2_packet(psmouse, &psmouse->packet[3], |
| 554 | false); |
| 555 | |
| 556 | /* |
| 557 | * Continue with the standard ALPS protocol handling, |
| 558 | * but make sure we won't process it as an interleaved |
| 559 | * packet again, which may happen if all buttons are |
| 560 | * pressed. To avoid this let's reset the 4th bit which |
| 561 | * is normally 1. |
| 562 | */ |
| 563 | psmouse->packet[3] = psmouse->packet[6] & 0xf7; |
| 564 | psmouse->pktcnt = 4; |
| 565 | } |
| 566 | |
| 567 | return PSMOUSE_GOOD_DATA; |
| 568 | } |
| 569 | |
| 570 | static void alps_flush_packet(unsigned long data) |
| 571 | { |
| 572 | struct psmouse *psmouse = (struct psmouse *)data; |
| 573 | |
| 574 | serio_pause_rx(psmouse->ps2dev.serio); |
| 575 | |
Seth Forshee | b46615f | 2011-11-07 19:53:30 -0800 | [diff] [blame] | 576 | if (psmouse->pktcnt == psmouse->pktsize) { |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 577 | |
| 578 | /* |
| 579 | * We did not any more data in reasonable amount of time. |
| 580 | * Validate the last 3 bytes and process as a standard |
| 581 | * ALPS packet. |
| 582 | */ |
| 583 | if ((psmouse->packet[3] | |
| 584 | psmouse->packet[4] | |
| 585 | psmouse->packet[5]) & 0x80) { |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 586 | psmouse_dbg(psmouse, |
| 587 | "refusing packet %x %x %x (suspected interleaved ps/2)\n", |
| 588 | psmouse->packet[3], psmouse->packet[4], |
| 589 | psmouse->packet[5]); |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 590 | } else { |
| 591 | alps_process_packet(psmouse); |
| 592 | } |
| 593 | psmouse->pktcnt = 0; |
| 594 | } |
| 595 | |
| 596 | serio_continue_rx(psmouse->ps2dev.serio); |
| 597 | } |
| 598 | |
| 599 | static psmouse_ret_t alps_process_byte(struct psmouse *psmouse) |
| 600 | { |
| 601 | struct alps_data *priv = psmouse->private; |
| 602 | const struct alps_model_info *model = priv->i; |
| 603 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | if ((psmouse->packet[0] & 0xc8) == 0x08) { /* PS/2 packet */ |
| 605 | if (psmouse->pktcnt == 3) { |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 606 | alps_report_bare_ps2_packet(psmouse, psmouse->packet, |
| 607 | true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | return PSMOUSE_FULL_PACKET; |
| 609 | } |
| 610 | return PSMOUSE_GOOD_DATA; |
| 611 | } |
| 612 | |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 613 | /* Check for PS/2 packet stuffed in the middle of ALPS packet. */ |
| 614 | |
| 615 | if ((model->flags & ALPS_PS2_INTERLEAVED) && |
| 616 | psmouse->pktcnt >= 4 && (psmouse->packet[3] & 0x0f) == 0x0f) { |
| 617 | return alps_handle_interleaved_ps2(psmouse); |
| 618 | } |
| 619 | |
| 620 | if (!alps_is_valid_first_byte(model, psmouse->packet[0])) { |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 621 | psmouse_dbg(psmouse, |
| 622 | "refusing packet[0] = %x (mask0 = %x, byte0 = %x)\n", |
| 623 | psmouse->packet[0], model->mask0, model->byte0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | return PSMOUSE_BAD_DATA; |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 625 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | |
Seth Forshee | b46615f | 2011-11-07 19:53:30 -0800 | [diff] [blame] | 627 | /* Bytes 2 - pktsize should have 0 in the highest bit */ |
| 628 | if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize && |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 629 | (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) { |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 630 | psmouse_dbg(psmouse, "refusing packet[%i] = %x\n", |
| 631 | psmouse->pktcnt - 1, |
| 632 | psmouse->packet[psmouse->pktcnt - 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | return PSMOUSE_BAD_DATA; |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 634 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | |
Seth Forshee | b46615f | 2011-11-07 19:53:30 -0800 | [diff] [blame] | 636 | if (psmouse->pktcnt == psmouse->pktsize) { |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 637 | alps_process_packet(psmouse); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | return PSMOUSE_FULL_PACKET; |
| 639 | } |
| 640 | |
| 641 | return PSMOUSE_GOOD_DATA; |
| 642 | } |
| 643 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 644 | static int alps_command_mode_send_nibble(struct psmouse *psmouse, int nibble) |
| 645 | { |
| 646 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 647 | struct alps_data *priv = psmouse->private; |
| 648 | int command; |
| 649 | unsigned char *param; |
| 650 | unsigned char dummy[4]; |
| 651 | |
| 652 | BUG_ON(nibble > 0xf); |
| 653 | |
| 654 | command = priv->nibble_commands[nibble].command; |
| 655 | param = (command & 0x0f00) ? |
| 656 | dummy : (unsigned char *)&priv->nibble_commands[nibble].data; |
| 657 | |
| 658 | if (ps2_command(ps2dev, param, command)) |
| 659 | return -1; |
| 660 | |
| 661 | return 0; |
| 662 | } |
| 663 | |
| 664 | static int alps_command_mode_set_addr(struct psmouse *psmouse, int addr) |
| 665 | { |
| 666 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 667 | struct alps_data *priv = psmouse->private; |
| 668 | int i, nibble; |
| 669 | |
| 670 | if (ps2_command(ps2dev, NULL, priv->addr_command)) |
| 671 | return -1; |
| 672 | |
| 673 | for (i = 12; i >= 0; i -= 4) { |
| 674 | nibble = (addr >> i) & 0xf; |
| 675 | if (alps_command_mode_send_nibble(psmouse, nibble)) |
| 676 | return -1; |
| 677 | } |
| 678 | |
| 679 | return 0; |
| 680 | } |
| 681 | |
| 682 | static int __alps_command_mode_read_reg(struct psmouse *psmouse, int addr) |
| 683 | { |
| 684 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 685 | unsigned char param[4]; |
| 686 | |
| 687 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) |
| 688 | return -1; |
| 689 | |
| 690 | /* |
| 691 | * The address being read is returned in the first two bytes |
| 692 | * of the result. Check that this address matches the expected |
| 693 | * address. |
| 694 | */ |
| 695 | if (addr != ((param[0] << 8) | param[1])) |
| 696 | return -1; |
| 697 | |
| 698 | return param[2]; |
| 699 | } |
| 700 | |
| 701 | static int alps_command_mode_read_reg(struct psmouse *psmouse, int addr) |
| 702 | { |
| 703 | if (alps_command_mode_set_addr(psmouse, addr)) |
| 704 | return -1; |
| 705 | return __alps_command_mode_read_reg(psmouse, addr); |
| 706 | } |
| 707 | |
| 708 | static int __alps_command_mode_write_reg(struct psmouse *psmouse, u8 value) |
| 709 | { |
| 710 | if (alps_command_mode_send_nibble(psmouse, (value >> 4) & 0xf)) |
| 711 | return -1; |
| 712 | if (alps_command_mode_send_nibble(psmouse, value & 0xf)) |
| 713 | return -1; |
| 714 | return 0; |
| 715 | } |
| 716 | |
| 717 | static int alps_command_mode_write_reg(struct psmouse *psmouse, int addr, |
| 718 | u8 value) |
| 719 | { |
| 720 | if (alps_command_mode_set_addr(psmouse, addr)) |
| 721 | return -1; |
| 722 | return __alps_command_mode_write_reg(psmouse, value); |
| 723 | } |
| 724 | |
| 725 | static int alps_enter_command_mode(struct psmouse *psmouse, |
| 726 | unsigned char *resp) |
| 727 | { |
| 728 | unsigned char param[4]; |
| 729 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 730 | |
| 731 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) || |
| 732 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) || |
| 733 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) || |
| 734 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { |
| 735 | psmouse_err(psmouse, "failed to enter command mode\n"); |
| 736 | return -1; |
| 737 | } |
| 738 | |
| 739 | if (param[0] != 0x88 && param[1] != 0x07) { |
| 740 | psmouse_dbg(psmouse, |
| 741 | "unknown response while entering command mode: %2.2x %2.2x %2.2x\n", |
| 742 | param[0], param[1], param[2]); |
| 743 | return -1; |
| 744 | } |
| 745 | |
| 746 | if (resp) |
| 747 | *resp = param[2]; |
| 748 | return 0; |
| 749 | } |
| 750 | |
| 751 | static inline int alps_exit_command_mode(struct psmouse *psmouse) |
| 752 | { |
| 753 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 754 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSTREAM)) |
| 755 | return -1; |
| 756 | return 0; |
| 757 | } |
| 758 | |
Helge Deller | e38de67 | 2006-09-10 21:54:39 -0400 | [diff] [blame] | 759 | static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | { |
| 761 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
Helge Deller | e38de67 | 2006-09-10 21:54:39 -0400 | [diff] [blame] | 762 | static const unsigned char rates[] = { 0, 10, 20, 40, 60, 80, 100, 200 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | unsigned char param[4]; |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 764 | const struct alps_model_info *model = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | int i; |
| 766 | |
| 767 | /* |
| 768 | * First try "E6 report". |
| 769 | * ALPS should return 0,0,10 or 0,0,100 |
| 770 | */ |
| 771 | param[0] = 0; |
| 772 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES) || |
| 773 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || |
| 774 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || |
| 775 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11)) |
| 776 | return NULL; |
| 777 | |
| 778 | param[0] = param[1] = param[2] = 0xff; |
| 779 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) |
| 780 | return NULL; |
| 781 | |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 782 | psmouse_dbg(psmouse, "E6 report: %2.2x %2.2x %2.2x", |
| 783 | param[0], param[1], param[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | |
| 785 | if (param[0] != 0 || param[1] != 0 || (param[2] != 10 && param[2] != 100)) |
| 786 | return NULL; |
| 787 | |
| 788 | /* |
| 789 | * Now try "E7 report". Allowed responses are in |
| 790 | * alps_model_data[].signature |
| 791 | */ |
| 792 | param[0] = 0; |
| 793 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES) || |
| 794 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || |
| 795 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || |
| 796 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21)) |
| 797 | return NULL; |
| 798 | |
| 799 | param[0] = param[1] = param[2] = 0xff; |
| 800 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) |
| 801 | return NULL; |
| 802 | |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 803 | psmouse_dbg(psmouse, "E7 report: %2.2x %2.2x %2.2x", |
| 804 | param[0], param[1], param[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | |
Dmitry Torokhov | 1e0c5b1 | 2007-05-14 23:51:54 -0400 | [diff] [blame] | 806 | if (version) { |
| 807 | for (i = 0; i < ARRAY_SIZE(rates) && param[2] != rates[i]; i++) |
| 808 | /* empty */; |
| 809 | *version = (param[0] << 8) | (param[1] << 4) | i; |
| 810 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 812 | for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) { |
Dmitry Torokhov | 1e0c5b1 | 2007-05-14 23:51:54 -0400 | [diff] [blame] | 813 | if (!memcmp(param, alps_model_data[i].signature, |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 814 | sizeof(alps_model_data[i].signature))) { |
| 815 | model = alps_model_data + i; |
| 816 | break; |
| 817 | } |
| 818 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 820 | if (model && model->proto_version > ALPS_PROTO_V2) { |
| 821 | /* |
| 822 | * Need to check command mode response to identify |
| 823 | * model |
| 824 | */ |
| 825 | model = NULL; |
| 826 | if (alps_enter_command_mode(psmouse, param)) { |
| 827 | psmouse_warn(psmouse, |
| 828 | "touchpad failed to enter command mode\n"); |
| 829 | } else { |
| 830 | for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) { |
| 831 | if (alps_model_data[i].proto_version > ALPS_PROTO_V2 && |
| 832 | alps_model_data[i].command_mode_resp == param[0]) { |
| 833 | model = alps_model_data + i; |
| 834 | break; |
| 835 | } |
| 836 | } |
| 837 | alps_exit_command_mode(psmouse); |
| 838 | |
| 839 | if (!model) |
| 840 | psmouse_dbg(psmouse, |
| 841 | "Unknown command mode response %2.2x\n", |
| 842 | param[0]); |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | return model; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | /* |
| 850 | * For DualPoint devices select the device that should respond to |
| 851 | * subsequent commands. It looks like glidepad is behind stickpointer, |
| 852 | * I'd thought it would be other way around... |
| 853 | */ |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 854 | static int alps_passthrough_mode_v2(struct psmouse *psmouse, bool enable) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | { |
| 856 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | int cmd = enable ? PSMOUSE_CMD_SETSCALE21 : PSMOUSE_CMD_SETSCALE11; |
| 858 | |
| 859 | if (ps2_command(ps2dev, NULL, cmd) || |
| 860 | ps2_command(ps2dev, NULL, cmd) || |
| 861 | ps2_command(ps2dev, NULL, cmd) || |
| 862 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE)) |
| 863 | return -1; |
| 864 | |
| 865 | /* we may get 3 more bytes, just ignore them */ |
Dmitry Torokhov | c611763 | 2005-06-01 02:39:51 -0500 | [diff] [blame] | 866 | ps2_drain(ps2dev, 3, 100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | |
| 868 | return 0; |
| 869 | } |
| 870 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 871 | static int alps_absolute_mode_v1_v2(struct psmouse *psmouse) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | { |
| 873 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 874 | |
| 875 | /* Try ALPS magic knock - 4 disable before enable */ |
| 876 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || |
| 877 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || |
| 878 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || |
| 879 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || |
| 880 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) |
| 881 | return -1; |
| 882 | |
| 883 | /* |
| 884 | * Switch mouse to poll (remote) mode so motion data will not |
| 885 | * get in our way |
| 886 | */ |
| 887 | return ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETPOLL); |
| 888 | } |
| 889 | |
| 890 | static int alps_get_status(struct psmouse *psmouse, char *param) |
| 891 | { |
| 892 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 893 | |
| 894 | /* Get status: 0xF5 0xF5 0xF5 0xE9 */ |
| 895 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || |
| 896 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || |
| 897 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || |
| 898 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) |
| 899 | return -1; |
| 900 | |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 901 | psmouse_dbg(psmouse, "Status: %2.2x %2.2x %2.2x", |
| 902 | param[0], param[1], param[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | |
| 904 | return 0; |
| 905 | } |
| 906 | |
| 907 | /* |
| 908 | * Turn touchpad tapping on or off. The sequences are: |
| 909 | * 0xE9 0xF5 0xF5 0xF3 0x0A to enable, |
| 910 | * 0xE9 0xF5 0xF5 0xE8 0x00 to disable. |
| 911 | * My guess that 0xE9 (GetInfo) is here as a sync point. |
| 912 | * For models that also have stickpointer (DualPoints) its tapping |
| 913 | * is controlled separately (0xE6 0xE6 0xE6 0xF3 0x14|0x0A) but |
| 914 | * we don't fiddle with it. |
| 915 | */ |
| 916 | static int alps_tap_mode(struct psmouse *psmouse, int enable) |
| 917 | { |
| 918 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 919 | int cmd = enable ? PSMOUSE_CMD_SETRATE : PSMOUSE_CMD_SETRES; |
| 920 | unsigned char tap_arg = enable ? 0x0A : 0x00; |
| 921 | unsigned char param[4]; |
| 922 | |
| 923 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO) || |
| 924 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || |
| 925 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || |
| 926 | ps2_command(ps2dev, &tap_arg, cmd)) |
| 927 | return -1; |
| 928 | |
| 929 | if (alps_get_status(psmouse, param)) |
| 930 | return -1; |
| 931 | |
| 932 | return 0; |
| 933 | } |
| 934 | |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 935 | /* |
| 936 | * alps_poll() - poll the touchpad for current motion packet. |
| 937 | * Used in resync. |
| 938 | */ |
| 939 | static int alps_poll(struct psmouse *psmouse) |
| 940 | { |
| 941 | struct alps_data *priv = psmouse->private; |
Seth Forshee | b46615f | 2011-11-07 19:53:30 -0800 | [diff] [blame] | 942 | unsigned char buf[sizeof(psmouse->packet)]; |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 943 | bool poll_failed; |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 944 | |
| 945 | if (priv->i->flags & ALPS_PASS) |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 946 | alps_passthrough_mode_v2(psmouse, true); |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 947 | |
| 948 | poll_failed = ps2_command(&psmouse->ps2dev, buf, |
| 949 | PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)) < 0; |
| 950 | |
| 951 | if (priv->i->flags & ALPS_PASS) |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 952 | alps_passthrough_mode_v2(psmouse, false); |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 953 | |
| 954 | if (poll_failed || (buf[0] & priv->i->mask0) != priv->i->byte0) |
| 955 | return -1; |
| 956 | |
| 957 | if ((psmouse->badbyte & 0xc8) == 0x08) { |
| 958 | /* |
| 959 | * Poll the track stick ... |
| 960 | */ |
| 961 | if (ps2_command(&psmouse->ps2dev, buf, PSMOUSE_CMD_POLL | (3 << 8))) |
| 962 | return -1; |
| 963 | } |
| 964 | |
| 965 | memcpy(psmouse->packet, buf, sizeof(buf)); |
| 966 | return 0; |
| 967 | } |
| 968 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 969 | static int alps_hw_init_v1_v2(struct psmouse *psmouse) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 970 | { |
| 971 | struct alps_data *priv = psmouse->private; |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 972 | const struct alps_model_info *model = priv->i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 973 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 974 | if ((model->flags & ALPS_PASS) && |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 975 | alps_passthrough_mode_v2(psmouse, true)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | return -1; |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 977 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 978 | |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 979 | if (alps_tap_mode(psmouse, true)) { |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 980 | psmouse_warn(psmouse, "Failed to enable hardware tapping\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 981 | return -1; |
Peter Osterlund | 963f626 | 2005-07-11 01:08:04 -0500 | [diff] [blame] | 982 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 984 | if (alps_absolute_mode_v1_v2(psmouse)) { |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 985 | psmouse_err(psmouse, "Failed to enable absolute mode\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | return -1; |
| 987 | } |
| 988 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 989 | if ((model->flags & ALPS_PASS) && |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 990 | alps_passthrough_mode_v2(psmouse, false)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 991 | return -1; |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 992 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | |
Dmitry Torokhov | 1e0c5b1 | 2007-05-14 23:51:54 -0400 | [diff] [blame] | 994 | /* ALPS needs stream mode, otherwise it won't report any data */ |
| 995 | if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSTREAM)) { |
Dmitry Torokhov | b5d2170 | 2011-10-10 18:27:03 -0700 | [diff] [blame] | 996 | psmouse_err(psmouse, "Failed to enable stream mode\n"); |
Dmitry Torokhov | 1e0c5b1 | 2007-05-14 23:51:54 -0400 | [diff] [blame] | 997 | return -1; |
| 998 | } |
| 999 | |
| 1000 | return 0; |
| 1001 | } |
| 1002 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 1003 | /* |
| 1004 | * Enable or disable passthrough mode to the trackstick. Must be in |
| 1005 | * command mode when calling this function. |
| 1006 | */ |
| 1007 | static int alps_passthrough_mode_v3(struct psmouse *psmouse, bool enable) |
| 1008 | { |
| 1009 | int reg_val; |
| 1010 | |
| 1011 | reg_val = alps_command_mode_read_reg(psmouse, 0x0008); |
| 1012 | if (reg_val == -1) |
| 1013 | return -1; |
| 1014 | |
| 1015 | if (enable) |
| 1016 | reg_val |= 0x01; |
| 1017 | else |
| 1018 | reg_val &= ~0x01; |
| 1019 | |
| 1020 | if (__alps_command_mode_write_reg(psmouse, reg_val)) |
| 1021 | return -1; |
| 1022 | |
| 1023 | return 0; |
| 1024 | } |
| 1025 | |
| 1026 | /* Must be in command mode when calling this function */ |
| 1027 | static int alps_absolute_mode_v3(struct psmouse *psmouse) |
| 1028 | { |
| 1029 | int reg_val; |
| 1030 | |
| 1031 | reg_val = alps_command_mode_read_reg(psmouse, 0x0004); |
| 1032 | if (reg_val == -1) |
| 1033 | return -1; |
| 1034 | |
| 1035 | reg_val |= 0x06; |
| 1036 | if (__alps_command_mode_write_reg(psmouse, reg_val)) |
| 1037 | return -1; |
| 1038 | |
| 1039 | return 0; |
| 1040 | } |
| 1041 | |
| 1042 | static int alps_hw_init_v3(struct psmouse *psmouse) |
| 1043 | { |
| 1044 | struct alps_data *priv = psmouse->private; |
| 1045 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 1046 | int reg_val; |
| 1047 | unsigned char param[4]; |
| 1048 | |
| 1049 | priv->nibble_commands = alps_v3_nibble_commands; |
| 1050 | priv->addr_command = PSMOUSE_CMD_RESET_WRAP; |
| 1051 | |
| 1052 | if (alps_enter_command_mode(psmouse, NULL)) |
| 1053 | goto error; |
| 1054 | |
| 1055 | /* Check for trackstick */ |
| 1056 | reg_val = alps_command_mode_read_reg(psmouse, 0x0008); |
| 1057 | if (reg_val == -1) |
| 1058 | goto error; |
| 1059 | if (reg_val & 0x80) { |
| 1060 | if (alps_passthrough_mode_v3(psmouse, true)) |
| 1061 | goto error; |
| 1062 | if (alps_exit_command_mode(psmouse)) |
| 1063 | goto error; |
| 1064 | |
| 1065 | /* |
| 1066 | * E7 report for the trackstick |
| 1067 | * |
| 1068 | * There have been reports of failures to seem to trace back |
| 1069 | * to the above trackstick check failing. When these occur |
| 1070 | * this E7 report fails, so when that happens we continue |
| 1071 | * with the assumption that there isn't a trackstick after |
| 1072 | * all. |
| 1073 | */ |
| 1074 | param[0] = 0x64; |
| 1075 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || |
| 1076 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || |
| 1077 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || |
| 1078 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { |
| 1079 | psmouse_warn(psmouse, "trackstick E7 report failed\n"); |
| 1080 | } else { |
| 1081 | psmouse_dbg(psmouse, |
| 1082 | "trackstick E7 report: %2.2x %2.2x %2.2x\n", |
| 1083 | param[0], param[1], param[2]); |
| 1084 | |
| 1085 | /* |
| 1086 | * Not sure what this does, but it is absolutely |
| 1087 | * essential. Without it, the touchpad does not |
| 1088 | * work at all and the trackstick just emits normal |
| 1089 | * PS/2 packets. |
| 1090 | */ |
| 1091 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || |
| 1092 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || |
| 1093 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || |
| 1094 | alps_command_mode_send_nibble(psmouse, 0x9) || |
| 1095 | alps_command_mode_send_nibble(psmouse, 0x4)) { |
| 1096 | psmouse_err(psmouse, |
| 1097 | "Error sending magic E6 sequence\n"); |
| 1098 | goto error_passthrough; |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | if (alps_enter_command_mode(psmouse, NULL)) |
| 1103 | goto error_passthrough; |
| 1104 | if (alps_passthrough_mode_v3(psmouse, false)) |
| 1105 | goto error; |
| 1106 | } |
| 1107 | |
| 1108 | if (alps_absolute_mode_v3(psmouse)) { |
| 1109 | psmouse_err(psmouse, "Failed to enter absolute mode\n"); |
| 1110 | goto error; |
| 1111 | } |
| 1112 | |
| 1113 | reg_val = alps_command_mode_read_reg(psmouse, 0x0006); |
| 1114 | if (reg_val == -1) |
| 1115 | goto error; |
| 1116 | if (__alps_command_mode_write_reg(psmouse, reg_val | 0x01)) |
| 1117 | goto error; |
| 1118 | |
| 1119 | reg_val = alps_command_mode_read_reg(psmouse, 0x0007); |
| 1120 | if (reg_val == -1) |
| 1121 | goto error; |
| 1122 | if (__alps_command_mode_write_reg(psmouse, reg_val | 0x01)) |
| 1123 | goto error; |
| 1124 | |
| 1125 | if (alps_command_mode_read_reg(psmouse, 0x0144) == -1) |
| 1126 | goto error; |
| 1127 | if (__alps_command_mode_write_reg(psmouse, 0x04)) |
| 1128 | goto error; |
| 1129 | |
| 1130 | if (alps_command_mode_read_reg(psmouse, 0x0159) == -1) |
| 1131 | goto error; |
| 1132 | if (__alps_command_mode_write_reg(psmouse, 0x03)) |
| 1133 | goto error; |
| 1134 | |
| 1135 | if (alps_command_mode_read_reg(psmouse, 0x0163) == -1) |
| 1136 | goto error; |
| 1137 | if (alps_command_mode_write_reg(psmouse, 0x0163, 0x03)) |
| 1138 | goto error; |
| 1139 | |
| 1140 | if (alps_command_mode_read_reg(psmouse, 0x0162) == -1) |
| 1141 | goto error; |
| 1142 | if (alps_command_mode_write_reg(psmouse, 0x0162, 0x04)) |
| 1143 | goto error; |
| 1144 | |
| 1145 | /* |
| 1146 | * This ensures the trackstick packets are in the format |
| 1147 | * supported by this driver. If bit 1 isn't set the packet |
| 1148 | * format is different. |
| 1149 | */ |
| 1150 | if (alps_command_mode_write_reg(psmouse, 0x0008, 0x82)) |
| 1151 | goto error; |
| 1152 | |
| 1153 | alps_exit_command_mode(psmouse); |
| 1154 | |
| 1155 | /* Set rate and enable data reporting */ |
| 1156 | param[0] = 0x64; |
| 1157 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE) || |
| 1158 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) { |
| 1159 | psmouse_err(psmouse, "Failed to enable data reporting\n"); |
| 1160 | return -1; |
| 1161 | } |
| 1162 | |
| 1163 | return 0; |
| 1164 | |
| 1165 | error_passthrough: |
| 1166 | /* Something failed while in passthrough mode, so try to get out */ |
| 1167 | if (!alps_enter_command_mode(psmouse, NULL)) |
| 1168 | alps_passthrough_mode_v3(psmouse, false); |
| 1169 | error: |
| 1170 | /* |
| 1171 | * Leaving the touchpad in command mode will essentially render |
| 1172 | * it unusable until the machine reboots, so exit it here just |
| 1173 | * to be safe |
| 1174 | */ |
| 1175 | alps_exit_command_mode(psmouse); |
| 1176 | return -1; |
| 1177 | } |
| 1178 | |
| 1179 | /* Must be in command mode when calling this function */ |
| 1180 | static int alps_absolute_mode_v4(struct psmouse *psmouse) |
| 1181 | { |
| 1182 | int reg_val; |
| 1183 | |
| 1184 | reg_val = alps_command_mode_read_reg(psmouse, 0x0004); |
| 1185 | if (reg_val == -1) |
| 1186 | return -1; |
| 1187 | |
| 1188 | reg_val |= 0x02; |
| 1189 | if (__alps_command_mode_write_reg(psmouse, reg_val)) |
| 1190 | return -1; |
| 1191 | |
| 1192 | return 0; |
| 1193 | } |
| 1194 | |
| 1195 | static int alps_hw_init_v4(struct psmouse *psmouse) |
| 1196 | { |
| 1197 | struct alps_data *priv = psmouse->private; |
| 1198 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
| 1199 | unsigned char param[4]; |
| 1200 | |
| 1201 | priv->nibble_commands = alps_v4_nibble_commands; |
| 1202 | priv->addr_command = PSMOUSE_CMD_DISABLE; |
| 1203 | |
| 1204 | if (alps_enter_command_mode(psmouse, NULL)) |
| 1205 | goto error; |
| 1206 | |
| 1207 | if (alps_absolute_mode_v4(psmouse)) { |
| 1208 | psmouse_err(psmouse, "Failed to enter absolute mode\n"); |
| 1209 | goto error; |
| 1210 | } |
| 1211 | |
| 1212 | if (alps_command_mode_write_reg(psmouse, 0x0007, 0x8c)) |
| 1213 | goto error; |
| 1214 | |
| 1215 | if (alps_command_mode_write_reg(psmouse, 0x0149, 0x03)) |
| 1216 | goto error; |
| 1217 | |
| 1218 | if (alps_command_mode_write_reg(psmouse, 0x0160, 0x03)) |
| 1219 | goto error; |
| 1220 | |
| 1221 | if (alps_command_mode_write_reg(psmouse, 0x017f, 0x15)) |
| 1222 | goto error; |
| 1223 | |
| 1224 | if (alps_command_mode_write_reg(psmouse, 0x0151, 0x01)) |
| 1225 | goto error; |
| 1226 | |
| 1227 | if (alps_command_mode_write_reg(psmouse, 0x0168, 0x03)) |
| 1228 | goto error; |
| 1229 | |
| 1230 | if (alps_command_mode_write_reg(psmouse, 0x014a, 0x03)) |
| 1231 | goto error; |
| 1232 | |
| 1233 | if (alps_command_mode_write_reg(psmouse, 0x0161, 0x03)) |
| 1234 | goto error; |
| 1235 | |
| 1236 | alps_exit_command_mode(psmouse); |
| 1237 | |
| 1238 | /* |
| 1239 | * This sequence changes the output from a 9-byte to an |
| 1240 | * 8-byte format. All the same data seems to be present, |
| 1241 | * just in a more compact format. |
| 1242 | */ |
| 1243 | param[0] = 0xc8; |
| 1244 | param[1] = 0x64; |
| 1245 | param[2] = 0x50; |
| 1246 | if (ps2_command(ps2dev, ¶m[0], PSMOUSE_CMD_SETRATE) || |
| 1247 | ps2_command(ps2dev, ¶m[1], PSMOUSE_CMD_SETRATE) || |
| 1248 | ps2_command(ps2dev, ¶m[2], PSMOUSE_CMD_SETRATE) || |
| 1249 | ps2_command(ps2dev, param, PSMOUSE_CMD_GETID)) |
| 1250 | return -1; |
| 1251 | |
| 1252 | /* Set rate and enable data reporting */ |
| 1253 | param[0] = 0x64; |
| 1254 | if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE) || |
| 1255 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) { |
| 1256 | psmouse_err(psmouse, "Failed to enable data reporting\n"); |
| 1257 | return -1; |
| 1258 | } |
| 1259 | |
| 1260 | return 0; |
| 1261 | |
| 1262 | error: |
| 1263 | /* |
| 1264 | * Leaving the touchpad in command mode will essentially render |
| 1265 | * it unusable until the machine reboots, so exit it here just |
| 1266 | * to be safe |
| 1267 | */ |
| 1268 | alps_exit_command_mode(psmouse); |
| 1269 | return -1; |
| 1270 | } |
| 1271 | |
| 1272 | static int alps_hw_init(struct psmouse *psmouse) |
| 1273 | { |
| 1274 | struct alps_data *priv = psmouse->private; |
| 1275 | const struct alps_model_info *model = priv->i; |
| 1276 | int ret = -1; |
| 1277 | |
| 1278 | switch (model->proto_version) { |
| 1279 | case ALPS_PROTO_V1: |
| 1280 | case ALPS_PROTO_V2: |
| 1281 | ret = alps_hw_init_v1_v2(psmouse); |
| 1282 | break; |
| 1283 | case ALPS_PROTO_V3: |
| 1284 | ret = alps_hw_init_v3(psmouse); |
| 1285 | break; |
| 1286 | case ALPS_PROTO_V4: |
| 1287 | ret = alps_hw_init_v4(psmouse); |
| 1288 | break; |
| 1289 | } |
| 1290 | |
| 1291 | return ret; |
| 1292 | } |
| 1293 | |
Dmitry Torokhov | 1e0c5b1 | 2007-05-14 23:51:54 -0400 | [diff] [blame] | 1294 | static int alps_reconnect(struct psmouse *psmouse) |
| 1295 | { |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 1296 | const struct alps_model_info *model; |
| 1297 | |
Dmitry Torokhov | 1e0c5b1 | 2007-05-14 23:51:54 -0400 | [diff] [blame] | 1298 | psmouse_reset(psmouse); |
| 1299 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 1300 | model = alps_get_model(psmouse, NULL); |
| 1301 | if (!model) |
Dmitry Torokhov | 1e0c5b1 | 2007-05-14 23:51:54 -0400 | [diff] [blame] | 1302 | return -1; |
| 1303 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 1304 | return alps_hw_init(psmouse); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1305 | } |
| 1306 | |
| 1307 | static void alps_disconnect(struct psmouse *psmouse) |
| 1308 | { |
| 1309 | struct alps_data *priv = psmouse->private; |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 1310 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1311 | psmouse_reset(psmouse); |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 1312 | del_timer_sync(&priv->timer); |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 1313 | input_unregister_device(priv->dev2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | kfree(priv); |
| 1315 | } |
| 1316 | |
| 1317 | int alps_init(struct psmouse *psmouse) |
| 1318 | { |
| 1319 | struct alps_data *priv; |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 1320 | const struct alps_model_info *model; |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 1321 | struct input_dev *dev1 = psmouse->dev, *dev2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | int version; |
| 1323 | |
Dmitry Torokhov | f42649e | 2007-04-12 01:31:13 -0400 | [diff] [blame] | 1324 | priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL); |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 1325 | dev2 = input_allocate_device(); |
| 1326 | if (!priv || !dev2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | goto init_fail; |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 1328 | |
| 1329 | priv->dev2 = dev2; |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 1330 | setup_timer(&priv->timer, alps_flush_packet, (unsigned long)psmouse); |
| 1331 | |
Dmitry Torokhov | 1e0c5b1 | 2007-05-14 23:51:54 -0400 | [diff] [blame] | 1332 | psmouse->private = priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1333 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 1334 | psmouse_reset(psmouse); |
| 1335 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 1336 | model = alps_get_model(psmouse, &version); |
| 1337 | if (!model) |
| 1338 | goto init_fail; |
| 1339 | |
| 1340 | priv->i = model; |
| 1341 | |
| 1342 | if (alps_hw_init(psmouse)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1343 | goto init_fail; |
| 1344 | |
Dmitry Torokhov | 7105d2e | 2009-12-11 23:54:54 -0800 | [diff] [blame] | 1345 | /* |
| 1346 | * Undo part of setup done for us by psmouse core since touchpad |
| 1347 | * is not a relative device. |
| 1348 | */ |
| 1349 | __clear_bit(EV_REL, dev1->evbit); |
| 1350 | __clear_bit(REL_X, dev1->relbit); |
| 1351 | __clear_bit(REL_Y, dev1->relbit); |
| 1352 | |
| 1353 | /* |
| 1354 | * Now set up our capabilities. |
| 1355 | */ |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 1356 | dev1->evbit[BIT_WORD(EV_KEY)] |= BIT_MASK(EV_KEY); |
| 1357 | dev1->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH); |
| 1358 | dev1->keybit[BIT_WORD(BTN_TOOL_FINGER)] |= BIT_MASK(BTN_TOOL_FINGER); |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 1359 | dev1->keybit[BIT_WORD(BTN_LEFT)] |= |
| 1360 | BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 1362 | dev1->evbit[BIT_WORD(EV_ABS)] |= BIT_MASK(EV_ABS); |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 1363 | |
| 1364 | switch (model->proto_version) { |
| 1365 | case ALPS_PROTO_V1: |
| 1366 | case ALPS_PROTO_V2: |
| 1367 | input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0); |
| 1368 | input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0); |
| 1369 | break; |
| 1370 | case ALPS_PROTO_V3: |
| 1371 | case ALPS_PROTO_V4: |
| 1372 | input_set_abs_params(dev1, ABS_X, 0, 2000, 0, 0); |
| 1373 | input_set_abs_params(dev1, ABS_Y, 0, 1400, 0, 0); |
| 1374 | break; |
| 1375 | } |
| 1376 | |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 1377 | input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1378 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 1379 | if (model->flags & ALPS_WHEEL) { |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 1380 | dev1->evbit[BIT_WORD(EV_REL)] |= BIT_MASK(EV_REL); |
| 1381 | dev1->relbit[BIT_WORD(REL_WHEEL)] |= BIT_MASK(REL_WHEEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1382 | } |
| 1383 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 1384 | if (model->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 1385 | dev1->keybit[BIT_WORD(BTN_FORWARD)] |= BIT_MASK(BTN_FORWARD); |
| 1386 | dev1->keybit[BIT_WORD(BTN_BACK)] |= BIT_MASK(BTN_BACK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1387 | } |
| 1388 | |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 1389 | if (model->flags & ALPS_FOUR_BUTTONS) { |
| 1390 | dev1->keybit[BIT_WORD(BTN_0)] |= BIT_MASK(BTN_0); |
| 1391 | dev1->keybit[BIT_WORD(BTN_1)] |= BIT_MASK(BTN_1); |
| 1392 | dev1->keybit[BIT_WORD(BTN_2)] |= BIT_MASK(BTN_2); |
| 1393 | dev1->keybit[BIT_WORD(BTN_3)] |= BIT_MASK(BTN_3); |
| 1394 | } else { |
| 1395 | dev1->keybit[BIT_WORD(BTN_MIDDLE)] |= BIT_MASK(BTN_MIDDLE); |
| 1396 | } |
| 1397 | |
Dmitry Torokhov | 08ffce4 | 2006-06-26 01:45:10 -0400 | [diff] [blame] | 1398 | snprintf(priv->phys, sizeof(priv->phys), "%s/input1", psmouse->ps2dev.serio->phys); |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 1399 | dev2->phys = priv->phys; |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 1400 | dev2->name = (model->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse"; |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 1401 | dev2->id.bustype = BUS_I8042; |
| 1402 | dev2->id.vendor = 0x0002; |
| 1403 | dev2->id.product = PSMOUSE_ALPS; |
| 1404 | dev2->id.version = 0x0000; |
Dmitry Torokhov | 1db3a34 | 2008-03-18 00:29:18 -0400 | [diff] [blame] | 1405 | dev2->dev.parent = &psmouse->ps2dev.serio->dev; |
Dmitry Torokhov | 968ac84 | 2005-05-29 02:28:29 -0500 | [diff] [blame] | 1406 | |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 1407 | dev2->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); |
Maxim Levitsky | 71bb21b | 2009-11-16 22:12:22 -0800 | [diff] [blame] | 1408 | dev2->relbit[BIT_WORD(REL_X)] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); |
| 1409 | dev2->keybit[BIT_WORD(BTN_LEFT)] = |
| 1410 | BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | |
Dmitry Torokhov | f42649e | 2007-04-12 01:31:13 -0400 | [diff] [blame] | 1412 | if (input_register_device(priv->dev2)) |
| 1413 | goto init_fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1414 | |
| 1415 | psmouse->protocol_handler = alps_process_byte; |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 1416 | psmouse->poll = alps_poll; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1417 | psmouse->disconnect = alps_disconnect; |
| 1418 | psmouse->reconnect = alps_reconnect; |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame^] | 1419 | psmouse->pktsize = model->proto_version == ALPS_PROTO_V4 ? 8 : 6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 1421 | /* We are having trouble resyncing ALPS touchpads so disable it for now */ |
| 1422 | psmouse->resync_time = 0; |
| 1423 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1424 | return 0; |
| 1425 | |
| 1426 | init_fail: |
Dmitry Torokhov | f42649e | 2007-04-12 01:31:13 -0400 | [diff] [blame] | 1427 | psmouse_reset(psmouse); |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 1428 | input_free_device(dev2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1429 | kfree(priv); |
Dmitry Torokhov | 1e0c5b1 | 2007-05-14 23:51:54 -0400 | [diff] [blame] | 1430 | psmouse->private = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | return -1; |
| 1432 | } |
| 1433 | |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 1434 | int alps_detect(struct psmouse *psmouse, bool set_properties) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | { |
| 1436 | int version; |
Helge Deller | e38de67 | 2006-09-10 21:54:39 -0400 | [diff] [blame] | 1437 | const struct alps_model_info *model; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1438 | |
Dmitry Torokhov | f42649e | 2007-04-12 01:31:13 -0400 | [diff] [blame] | 1439 | model = alps_get_model(psmouse, &version); |
| 1440 | if (!model) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1441 | return -1; |
| 1442 | |
| 1443 | if (set_properties) { |
| 1444 | psmouse->vendor = "ALPS"; |
Dmitry Torokhov | 968ac84 | 2005-05-29 02:28:29 -0500 | [diff] [blame] | 1445 | psmouse->name = model->flags & ALPS_DUALPOINT ? |
| 1446 | "DualPoint TouchPad" : "GlidePoint"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1447 | psmouse->model = version; |
| 1448 | } |
| 1449 | return 0; |
| 1450 | } |
| 1451 | |