alps.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. /*
  2. * ALPS touchpad PS/2 mouse driver
  3. *
  4. * Copyright (c) 2003 Neil Brown <neilb@cse.unsw.edu.au>
  5. * Copyright (c) 2003-2005 Peter Osterlund <petero2@telia.com>
  6. * Copyright (c) 2004 Dmitry Torokhov <dtor@mail.ru>
  7. * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>
  8. *
  9. * ALPS detection, tap switching and status querying info is taken from
  10. * tpconfig utility (by C. Scott Ananian and Bruce Kall).
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License version 2 as published by
  14. * the Free Software Foundation.
  15. */
  16. #include <linux/input.h>
  17. #include <linux/serio.h>
  18. #include <linux/libps2.h>
  19. #include "psmouse.h"
  20. #include "alps.h"
  21. #undef DEBUG
  22. #ifdef DEBUG
  23. #define dbg(format, arg...) printk(KERN_INFO "alps.c: " format "\n", ## arg)
  24. #else
  25. #define dbg(format, arg...) do {} while (0)
  26. #endif
  27. #define ALPS_DUALPOINT 0x01
  28. #define ALPS_WHEEL 0x02
  29. #define ALPS_FW_BK_1 0x04
  30. #define ALPS_4BTN 0x08
  31. #define ALPS_OLDPROTO 0x10
  32. #define ALPS_PASS 0x20
  33. #define ALPS_FW_BK_2 0x40
  34. static const struct alps_model_info alps_model_data[] = {
  35. { { 0x32, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */
  36. { { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */
  37. { { 0x53, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
  38. { { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 },
  39. { { 0x60, 0x03, 0xc8 }, 0xf8, 0xf8, 0 }, /* HP ze1115 */
  40. { { 0x63, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
  41. { { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 },
  42. { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */
  43. { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */
  44. { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */
  45. { { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 },
  46. { { 0x63, 0x03, 0xc8 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D800 */
  47. { { 0x73, 0x00, 0x0a }, 0xf8, 0xf8, ALPS_DUALPOINT }, /* ThinkPad R61 8918-5QG */
  48. { { 0x73, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
  49. { { 0x73, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */
  50. { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */
  51. { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT },
  52. { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */
  53. { { 0x62, 0x02, 0x14 }, 0xcf, 0xcf, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude E6500 */
  54. { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FW_BK_1 }, /* Dell Vostro 1400 */
  55. };
  56. /*
  57. * XXX - this entry is suspicious. First byte has zero lower nibble,
  58. * which is what a normal mouse would report. Also, the value 0x0e
  59. * isn't valid per PS/2 spec.
  60. */
  61. /*
  62. * ALPS abolute Mode - new format
  63. *
  64. * byte 0: 1 ? ? ? 1 ? ? ?
  65. * byte 1: 0 x6 x5 x4 x3 x2 x1 x0
  66. * byte 2: 0 x10 x9 x8 x7 ? fin ges
  67. * byte 3: 0 y9 y8 y7 1 M R L
  68. * byte 4: 0 y6 y5 y4 y3 y2 y1 y0
  69. * byte 5: 0 z6 z5 z4 z3 z2 z1 z0
  70. *
  71. * ?'s can have different meanings on different models,
  72. * such as wheel rotation, extra buttons, stick buttons
  73. * on a dualpoint, etc.
  74. */
  75. static void alps_process_packet(struct psmouse *psmouse)
  76. {
  77. struct alps_data *priv = psmouse->private;
  78. unsigned char *packet = psmouse->packet;
  79. struct input_dev *dev = psmouse->dev;
  80. struct input_dev *dev2 = priv->dev2;
  81. int x, y, z, ges, fin, left, right, middle;
  82. int back = 0, forward = 0;
  83. if ((packet[0] & 0xc8) == 0x08) { /* 3-byte PS/2 packet */
  84. input_report_key(dev2, BTN_LEFT, packet[0] & 1);
  85. input_report_key(dev2, BTN_RIGHT, packet[0] & 2);
  86. input_report_key(dev2, BTN_MIDDLE, packet[0] & 4);
  87. input_report_rel(dev2, REL_X,
  88. packet[1] ? packet[1] - ((packet[0] << 4) & 0x100) : 0);
  89. input_report_rel(dev2, REL_Y,
  90. packet[2] ? ((packet[0] << 3) & 0x100) - packet[2] : 0);
  91. input_sync(dev2);
  92. return;
  93. }
  94. if (priv->i->flags & ALPS_OLDPROTO) {
  95. left = packet[2] & 0x10;
  96. right = packet[2] & 0x08;
  97. middle = 0;
  98. x = packet[1] | ((packet[0] & 0x07) << 7);
  99. y = packet[4] | ((packet[3] & 0x07) << 7);
  100. z = packet[5];
  101. } else {
  102. left = packet[3] & 1;
  103. right = packet[3] & 2;
  104. middle = packet[3] & 4;
  105. x = packet[1] | ((packet[2] & 0x78) << (7 - 3));
  106. y = packet[4] | ((packet[3] & 0x70) << (7 - 4));
  107. z = packet[5];
  108. }
  109. if (priv->i->flags & ALPS_FW_BK_1) {
  110. back = packet[0] & 0x10;
  111. forward = packet[2] & 4;
  112. }
  113. if (priv->i->flags & ALPS_FW_BK_2) {
  114. back = packet[3] & 4;
  115. forward = packet[2] & 4;
  116. if ((middle = forward && back))
  117. forward = back = 0;
  118. }
  119. ges = packet[2] & 1;
  120. fin = packet[2] & 2;
  121. if ((priv->i->flags & ALPS_DUALPOINT) && z == 127) {
  122. input_report_rel(dev2, REL_X, (x > 383 ? (x - 768) : x));
  123. input_report_rel(dev2, REL_Y, -(y > 255 ? (y - 512) : y));
  124. input_report_key(dev2, BTN_LEFT, left);
  125. input_report_key(dev2, BTN_RIGHT, right);
  126. input_report_key(dev2, BTN_MIDDLE, middle);
  127. input_sync(dev);
  128. input_sync(dev2);
  129. return;
  130. }
  131. input_report_key(dev, BTN_LEFT, left);
  132. input_report_key(dev, BTN_RIGHT, right);
  133. input_report_key(dev, BTN_MIDDLE, middle);
  134. /* Convert hardware tap to a reasonable Z value */
  135. if (ges && !fin) z = 40;
  136. /*
  137. * A "tap and drag" operation is reported by the hardware as a transition
  138. * from (!fin && ges) to (fin && ges). This should be translated to the
  139. * sequence Z>0, Z==0, Z>0, so the Z==0 event has to be generated manually.
  140. */
  141. if (ges && fin && !priv->prev_fin) {
  142. input_report_abs(dev, ABS_X, x);
  143. input_report_abs(dev, ABS_Y, y);
  144. input_report_abs(dev, ABS_PRESSURE, 0);
  145. input_report_key(dev, BTN_TOOL_FINGER, 0);
  146. input_sync(dev);
  147. }
  148. priv->prev_fin = fin;
  149. if (z > 30) input_report_key(dev, BTN_TOUCH, 1);
  150. if (z < 25) input_report_key(dev, BTN_TOUCH, 0);
  151. if (z > 0) {
  152. input_report_abs(dev, ABS_X, x);
  153. input_report_abs(dev, ABS_Y, y);
  154. }
  155. input_report_abs(dev, ABS_PRESSURE, z);
  156. input_report_key(dev, BTN_TOOL_FINGER, z > 0);
  157. if (priv->i->flags & ALPS_WHEEL)
  158. input_report_rel(dev, REL_WHEEL, ((packet[2] << 1) & 0x08) - ((packet[0] >> 4) & 0x07));
  159. if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) {
  160. input_report_key(dev, BTN_FORWARD, forward);
  161. input_report_key(dev, BTN_BACK, back);
  162. }
  163. input_sync(dev);
  164. }
  165. static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
  166. {
  167. struct alps_data *priv = psmouse->private;
  168. if ((psmouse->packet[0] & 0xc8) == 0x08) { /* PS/2 packet */
  169. if (psmouse->pktcnt == 3) {
  170. alps_process_packet(psmouse);
  171. return PSMOUSE_FULL_PACKET;
  172. }
  173. return PSMOUSE_GOOD_DATA;
  174. }
  175. if ((psmouse->packet[0] & priv->i->mask0) != priv->i->byte0)
  176. return PSMOUSE_BAD_DATA;
  177. /* Bytes 2 - 6 should have 0 in the highest bit */
  178. if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 6 &&
  179. (psmouse->packet[psmouse->pktcnt - 1] & 0x80))
  180. return PSMOUSE_BAD_DATA;
  181. if (psmouse->pktcnt == 6) {
  182. alps_process_packet(psmouse);
  183. return PSMOUSE_FULL_PACKET;
  184. }
  185. return PSMOUSE_GOOD_DATA;
  186. }
  187. static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version)
  188. {
  189. struct ps2dev *ps2dev = &psmouse->ps2dev;
  190. static const unsigned char rates[] = { 0, 10, 20, 40, 60, 80, 100, 200 };
  191. unsigned char param[4];
  192. int i;
  193. /*
  194. * First try "E6 report".
  195. * ALPS should return 0,0,10 or 0,0,100
  196. */
  197. param[0] = 0;
  198. if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES) ||
  199. ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
  200. ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
  201. ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11))
  202. return NULL;
  203. param[0] = param[1] = param[2] = 0xff;
  204. if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
  205. return NULL;
  206. dbg("E6 report: %2.2x %2.2x %2.2x", param[0], param[1], param[2]);
  207. if (param[0] != 0 || param[1] != 0 || (param[2] != 10 && param[2] != 100))
  208. return NULL;
  209. /*
  210. * Now try "E7 report". Allowed responses are in
  211. * alps_model_data[].signature
  212. */
  213. param[0] = 0;
  214. if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES) ||
  215. ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
  216. ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
  217. ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21))
  218. return NULL;
  219. param[0] = param[1] = param[2] = 0xff;
  220. if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
  221. return NULL;
  222. dbg("E7 report: %2.2x %2.2x %2.2x", param[0], param[1], param[2]);
  223. if (version) {
  224. for (i = 0; i < ARRAY_SIZE(rates) && param[2] != rates[i]; i++)
  225. /* empty */;
  226. *version = (param[0] << 8) | (param[1] << 4) | i;
  227. }
  228. for (i = 0; i < ARRAY_SIZE(alps_model_data); i++)
  229. if (!memcmp(param, alps_model_data[i].signature,
  230. sizeof(alps_model_data[i].signature)))
  231. return alps_model_data + i;
  232. return NULL;
  233. }
  234. /*
  235. * For DualPoint devices select the device that should respond to
  236. * subsequent commands. It looks like glidepad is behind stickpointer,
  237. * I'd thought it would be other way around...
  238. */
  239. static int alps_passthrough_mode(struct psmouse *psmouse, int enable)
  240. {
  241. struct ps2dev *ps2dev = &psmouse->ps2dev;
  242. int cmd = enable ? PSMOUSE_CMD_SETSCALE21 : PSMOUSE_CMD_SETSCALE11;
  243. if (ps2_command(ps2dev, NULL, cmd) ||
  244. ps2_command(ps2dev, NULL, cmd) ||
  245. ps2_command(ps2dev, NULL, cmd) ||
  246. ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE))
  247. return -1;
  248. /* we may get 3 more bytes, just ignore them */
  249. ps2_drain(ps2dev, 3, 100);
  250. return 0;
  251. }
  252. static int alps_absolute_mode(struct psmouse *psmouse)
  253. {
  254. struct ps2dev *ps2dev = &psmouse->ps2dev;
  255. /* Try ALPS magic knock - 4 disable before enable */
  256. if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
  257. ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
  258. ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
  259. ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
  260. ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE))
  261. return -1;
  262. /*
  263. * Switch mouse to poll (remote) mode so motion data will not
  264. * get in our way
  265. */
  266. return ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETPOLL);
  267. }
  268. static int alps_get_status(struct psmouse *psmouse, char *param)
  269. {
  270. struct ps2dev *ps2dev = &psmouse->ps2dev;
  271. /* Get status: 0xF5 0xF5 0xF5 0xE9 */
  272. if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
  273. ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
  274. ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
  275. ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
  276. return -1;
  277. dbg("Status: %2.2x %2.2x %2.2x", param[0], param[1], param[2]);
  278. return 0;
  279. }
  280. /*
  281. * Turn touchpad tapping on or off. The sequences are:
  282. * 0xE9 0xF5 0xF5 0xF3 0x0A to enable,
  283. * 0xE9 0xF5 0xF5 0xE8 0x00 to disable.
  284. * My guess that 0xE9 (GetInfo) is here as a sync point.
  285. * For models that also have stickpointer (DualPoints) its tapping
  286. * is controlled separately (0xE6 0xE6 0xE6 0xF3 0x14|0x0A) but
  287. * we don't fiddle with it.
  288. */
  289. static int alps_tap_mode(struct psmouse *psmouse, int enable)
  290. {
  291. struct ps2dev *ps2dev = &psmouse->ps2dev;
  292. int cmd = enable ? PSMOUSE_CMD_SETRATE : PSMOUSE_CMD_SETRES;
  293. unsigned char tap_arg = enable ? 0x0A : 0x00;
  294. unsigned char param[4];
  295. if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO) ||
  296. ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
  297. ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
  298. ps2_command(ps2dev, &tap_arg, cmd))
  299. return -1;
  300. if (alps_get_status(psmouse, param))
  301. return -1;
  302. return 0;
  303. }
  304. /*
  305. * alps_poll() - poll the touchpad for current motion packet.
  306. * Used in resync.
  307. */
  308. static int alps_poll(struct psmouse *psmouse)
  309. {
  310. struct alps_data *priv = psmouse->private;
  311. unsigned char buf[6];
  312. int poll_failed;
  313. if (priv->i->flags & ALPS_PASS)
  314. alps_passthrough_mode(psmouse, 1);
  315. poll_failed = ps2_command(&psmouse->ps2dev, buf,
  316. PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)) < 0;
  317. if (priv->i->flags & ALPS_PASS)
  318. alps_passthrough_mode(psmouse, 0);
  319. if (poll_failed || (buf[0] & priv->i->mask0) != priv->i->byte0)
  320. return -1;
  321. if ((psmouse->badbyte & 0xc8) == 0x08) {
  322. /*
  323. * Poll the track stick ...
  324. */
  325. if (ps2_command(&psmouse->ps2dev, buf, PSMOUSE_CMD_POLL | (3 << 8)))
  326. return -1;
  327. }
  328. memcpy(psmouse->packet, buf, sizeof(buf));
  329. return 0;
  330. }
  331. static int alps_hw_init(struct psmouse *psmouse, int *version)
  332. {
  333. struct alps_data *priv = psmouse->private;
  334. priv->i = alps_get_model(psmouse, version);
  335. if (!priv->i)
  336. return -1;
  337. if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 1))
  338. return -1;
  339. if (alps_tap_mode(psmouse, 1)) {
  340. printk(KERN_WARNING "alps.c: Failed to enable hardware tapping\n");
  341. return -1;
  342. }
  343. if (alps_absolute_mode(psmouse)) {
  344. printk(KERN_ERR "alps.c: Failed to enable absolute mode\n");
  345. return -1;
  346. }
  347. if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0))
  348. return -1;
  349. /* ALPS needs stream mode, otherwise it won't report any data */
  350. if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSTREAM)) {
  351. printk(KERN_ERR "alps.c: Failed to enable stream mode\n");
  352. return -1;
  353. }
  354. return 0;
  355. }
  356. static int alps_reconnect(struct psmouse *psmouse)
  357. {
  358. psmouse_reset(psmouse);
  359. if (alps_hw_init(psmouse, NULL))
  360. return -1;
  361. return 0;
  362. }
  363. static void alps_disconnect(struct psmouse *psmouse)
  364. {
  365. struct alps_data *priv = psmouse->private;
  366. psmouse_reset(psmouse);
  367. input_unregister_device(priv->dev2);
  368. kfree(priv);
  369. }
  370. int alps_init(struct psmouse *psmouse)
  371. {
  372. struct alps_data *priv;
  373. struct input_dev *dev1 = psmouse->dev, *dev2;
  374. int version;
  375. priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL);
  376. dev2 = input_allocate_device();
  377. if (!priv || !dev2)
  378. goto init_fail;
  379. priv->dev2 = dev2;
  380. psmouse->private = priv;
  381. if (alps_hw_init(psmouse, &version))
  382. goto init_fail;
  383. dev1->evbit[BIT_WORD(EV_KEY)] |= BIT_MASK(EV_KEY);
  384. dev1->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH);
  385. dev1->keybit[BIT_WORD(BTN_TOOL_FINGER)] |= BIT_MASK(BTN_TOOL_FINGER);
  386. dev1->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) |
  387. BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
  388. dev1->evbit[BIT_WORD(EV_ABS)] |= BIT_MASK(EV_ABS);
  389. input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0);
  390. input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0);
  391. input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0);
  392. if (priv->i->flags & ALPS_WHEEL) {
  393. dev1->evbit[BIT_WORD(EV_REL)] |= BIT_MASK(EV_REL);
  394. dev1->relbit[BIT_WORD(REL_WHEEL)] |= BIT_MASK(REL_WHEEL);
  395. }
  396. if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) {
  397. dev1->keybit[BIT_WORD(BTN_FORWARD)] |= BIT_MASK(BTN_FORWARD);
  398. dev1->keybit[BIT_WORD(BTN_BACK)] |= BIT_MASK(BTN_BACK);
  399. }
  400. snprintf(priv->phys, sizeof(priv->phys), "%s/input1", psmouse->ps2dev.serio->phys);
  401. dev2->phys = priv->phys;
  402. dev2->name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse";
  403. dev2->id.bustype = BUS_I8042;
  404. dev2->id.vendor = 0x0002;
  405. dev2->id.product = PSMOUSE_ALPS;
  406. dev2->id.version = 0x0000;
  407. dev2->dev.parent = &psmouse->ps2dev.serio->dev;
  408. dev2->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
  409. dev2->relbit[BIT_WORD(REL_X)] |= BIT_MASK(REL_X) | BIT_MASK(REL_Y);
  410. dev2->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) |
  411. BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT);
  412. if (input_register_device(priv->dev2))
  413. goto init_fail;
  414. psmouse->protocol_handler = alps_process_byte;
  415. psmouse->poll = alps_poll;
  416. psmouse->disconnect = alps_disconnect;
  417. psmouse->reconnect = alps_reconnect;
  418. psmouse->pktsize = 6;
  419. /* We are having trouble resyncing ALPS touchpads so disable it for now */
  420. psmouse->resync_time = 0;
  421. return 0;
  422. init_fail:
  423. psmouse_reset(psmouse);
  424. input_free_device(dev2);
  425. kfree(priv);
  426. psmouse->private = NULL;
  427. return -1;
  428. }
  429. int alps_detect(struct psmouse *psmouse, int set_properties)
  430. {
  431. int version;
  432. const struct alps_model_info *model;
  433. model = alps_get_model(psmouse, &version);
  434. if (!model)
  435. return -1;
  436. if (set_properties) {
  437. psmouse->vendor = "ALPS";
  438. psmouse->name = model->flags & ALPS_DUALPOINT ?
  439. "DualPoint TouchPad" : "GlidePoint";
  440. psmouse->model = version;
  441. }
  442. return 0;
  443. }