2 * Elantech Touchpad driver (v6)
4 * Copyright (C) 2007-2009 Arjan Opmeer <arjan@opmeer.net>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
10 * Trademarks are the property of their respective owners.
13 #define pr_fmt(fmt) KBUILD_BASENAME ": " fmt
15 #include <linux/delay.h>
16 #include <linux/slab.h>
17 #include <linux/module.h>
18 #include <linux/input.h>
19 #include <linux/input/mt.h>
20 #include <linux/serio.h>
21 #include <linux/libps2.h>
25 #define elantech_debug(fmt, ...) \
28 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
31 static bool force_elantech;
32 module_param_named(force_elantech, force_elantech, bool, 0644);
33 MODULE_PARM_DESC(force_elantech, "Force the Elantech PS/2 protocol extension to be used, 1 = enabled, 0 = disabled (default).");
36 * Send a Synaptics style sliced query command
38 static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c,
41 if (psmouse_sliced_command(psmouse, c) ||
42 ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) {
43 pr_err("synaptics_send_cmd query 0x%02x failed.\n", c);
51 * A retrying version of ps2_command
53 static int elantech_ps2_command(struct psmouse *psmouse,
54 unsigned char *param, int command)
56 struct ps2dev *ps2dev = &psmouse->ps2dev;
57 struct elantech_data *etd = psmouse->private;
59 int tries = ETP_PS2_COMMAND_TRIES;
62 rc = ps2_command(ps2dev, param, command);
66 elantech_debug("retrying ps2 command 0x%02x (%d).\n",
68 msleep(ETP_PS2_COMMAND_DELAY);
72 pr_err("ps2 command 0x%02x failed.\n", command);
78 * Send an Elantech style special command to read a value from a register
80 static int elantech_read_reg(struct psmouse *psmouse, unsigned char reg,
83 struct elantech_data *etd = psmouse->private;
84 unsigned char param[3];
87 if (reg < 0x10 || reg > 0x26)
90 if (reg > 0x11 && reg < 0x20)
93 switch (etd->hw_version) {
95 if (psmouse_sliced_command(psmouse, ETP_REGISTER_READ) ||
96 psmouse_sliced_command(psmouse, reg) ||
97 ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) {
103 if (elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) ||
104 elantech_ps2_command(psmouse, NULL, ETP_REGISTER_READ) ||
105 elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) ||
106 elantech_ps2_command(psmouse, NULL, reg) ||
107 elantech_ps2_command(psmouse, param, PSMOUSE_CMD_GETINFO)) {
114 pr_err("failed to read register 0x%02x.\n", reg);
122 * Send an Elantech style special command to write a register with a value
124 static int elantech_write_reg(struct psmouse *psmouse, unsigned char reg,
127 struct elantech_data *etd = psmouse->private;
130 if (reg < 0x10 || reg > 0x26)
133 if (reg > 0x11 && reg < 0x20)
136 switch (etd->hw_version) {
138 if (psmouse_sliced_command(psmouse, ETP_REGISTER_WRITE) ||
139 psmouse_sliced_command(psmouse, reg) ||
140 psmouse_sliced_command(psmouse, val) ||
141 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11)) {
147 if (elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) ||
148 elantech_ps2_command(psmouse, NULL, ETP_REGISTER_WRITE) ||
149 elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) ||
150 elantech_ps2_command(psmouse, NULL, reg) ||
151 elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) ||
152 elantech_ps2_command(psmouse, NULL, val) ||
153 elantech_ps2_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11)) {
160 pr_err("failed to write register 0x%02x with value 0x%02x.\n",
167 * Dump a complete mouse movement packet to the syslog
169 static void elantech_packet_dump(unsigned char *packet, int size)
173 printk(KERN_DEBUG pr_fmt("PS/2 packet ["));
174 for (i = 0; i < size; i++)
175 printk("%s0x%02x ", (i) ? ", " : " ", packet[i]);
180 * Interpret complete data packets and report absolute mode input events for
181 * hardware version 1. (4 byte packets)
183 static void elantech_report_absolute_v1(struct psmouse *psmouse)
185 struct input_dev *dev = psmouse->dev;
186 struct elantech_data *etd = psmouse->private;
187 unsigned char *packet = psmouse->packet;
190 if (etd->fw_version < 0x020000) {
192 * byte 0: D U p1 p2 1 p3 R L
193 * byte 1: f 0 th tw x9 x8 y9 y8
195 fingers = ((packet[1] & 0x80) >> 7) +
196 ((packet[1] & 0x30) >> 4);
199 * byte 0: n1 n0 p2 p1 1 p3 R L
200 * byte 1: 0 0 0 0 x9 x8 y9 y8
202 fingers = (packet[0] & 0xc0) >> 6;
205 if (etd->jumpy_cursor) {
207 etd->single_finger_reports = 0;
208 } else if (etd->single_finger_reports < 2) {
209 /* Discard first 2 reports of one finger, bogus */
210 etd->single_finger_reports++;
211 elantech_debug("discarding packet\n");
216 input_report_key(dev, BTN_TOUCH, fingers != 0);
219 * byte 2: x7 x6 x5 x4 x3 x2 x1 x0
220 * byte 3: y7 y6 y5 y4 y3 y2 y1 y0
223 input_report_abs(dev, ABS_X,
224 ((packet[1] & 0x0c) << 6) | packet[2]);
225 input_report_abs(dev, ABS_Y,
226 ETP_YMAX_V1 - (((packet[1] & 0x03) << 8) | packet[3]));
229 input_report_key(dev, BTN_TOOL_FINGER, fingers == 1);
230 input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2);
231 input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3);
232 input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
233 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
235 if (etd->fw_version < 0x020000 &&
236 (etd->capabilities & ETP_CAP_HAS_ROCKER)) {
238 input_report_key(dev, BTN_FORWARD, packet[0] & 0x40);
240 input_report_key(dev, BTN_BACK, packet[0] & 0x80);
246 static void elantech_set_slot(struct input_dev *dev, int slot, bool active,
247 unsigned int x, unsigned int y)
249 input_mt_slot(dev, slot);
250 input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
252 input_report_abs(dev, ABS_MT_POSITION_X, x);
253 input_report_abs(dev, ABS_MT_POSITION_Y, y);
257 /* x1 < x2 and y1 < y2 when two fingers, x = y = 0 when not pressed */
258 static void elantech_report_semi_mt_data(struct input_dev *dev,
259 unsigned int num_fingers,
260 unsigned int x1, unsigned int y1,
261 unsigned int x2, unsigned int y2)
263 elantech_set_slot(dev, 0, num_fingers != 0, x1, y1);
264 elantech_set_slot(dev, 1, num_fingers == 2, x2, y2);
268 * Interpret complete data packets and report absolute mode input events for
269 * hardware version 2. (6 byte packets)
271 static void elantech_report_absolute_v2(struct psmouse *psmouse)
273 struct elantech_data *etd = psmouse->private;
274 struct input_dev *dev = psmouse->dev;
275 unsigned char *packet = psmouse->packet;
276 unsigned int fingers, x1 = 0, y1 = 0, x2 = 0, y2 = 0, width = 0, pres = 0;
278 /* byte 0: n1 n0 . . . . R L */
279 fingers = (packet[0] & 0xc0) >> 6;
280 input_report_key(dev, BTN_TOUCH, fingers != 0);
285 * Same as one finger, except report of more than 3 fingers:
286 * byte 3: n4 . w1 w0 . . . .
288 if (packet[3] & 0x80)
290 /* pass through... */
293 * byte 1: . . . . . x10 x9 x8
294 * byte 2: x7 x6 x5 x4 x4 x2 x1 x0
296 x1 = ((packet[1] & 0x07) << 8) | packet[2];
298 * byte 4: . . . . . . y9 y8
299 * byte 5: y7 y6 y5 y4 y3 y2 y1 y0
301 y1 = ETP_YMAX_V2 - (((packet[4] & 0x03) << 8) | packet[5]);
303 input_report_abs(dev, ABS_X, x1);
304 input_report_abs(dev, ABS_Y, y1);
306 pres = (packet[1] & 0xf0) | ((packet[4] & 0xf0) >> 4);
307 width = ((packet[0] & 0x30) >> 2) | ((packet[3] & 0x30) >> 4);
312 * The coordinate of each finger is reported separately
313 * with a lower resolution for two finger touches:
314 * byte 0: . . ay8 ax8 . . . .
315 * byte 1: ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0
317 x1 = ((packet[0] & 0x10) << 4) | packet[1];
318 /* byte 2: ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0 */
319 y1 = ETP_2FT_YMAX - (((packet[0] & 0x20) << 3) | packet[2]);
321 * byte 3: . . by8 bx8 . . . .
322 * byte 4: bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0
324 x2 = ((packet[3] & 0x10) << 4) | packet[4];
325 /* byte 5: by7 by8 by5 by4 by3 by2 by1 by0 */
326 y2 = ETP_2FT_YMAX - (((packet[3] & 0x20) << 3) | packet[5]);
328 * For compatibility with the X Synaptics driver scale up
329 * one coordinate and report as ordinary mouse movent
331 input_report_abs(dev, ABS_X, x1 << 2);
332 input_report_abs(dev, ABS_Y, y1 << 2);
334 * For compatibility with the proprietary X Elantech driver
335 * report both coordinates as hat coordinates
337 input_report_abs(dev, ABS_HAT0X, x1);
338 input_report_abs(dev, ABS_HAT0Y, y1);
339 input_report_abs(dev, ABS_HAT1X, x2);
340 input_report_abs(dev, ABS_HAT1Y, y2);
342 /* Unknown so just report sensible values */
348 elantech_report_semi_mt_data(dev, fingers, x1, y1, x2, y2);
349 input_report_key(dev, BTN_TOOL_FINGER, fingers == 1);
350 input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2);
351 input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3);
352 input_report_key(dev, BTN_TOOL_QUADTAP, fingers == 4);
353 input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
354 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
355 if (etd->reports_pressure) {
356 input_report_abs(dev, ABS_PRESSURE, pres);
357 input_report_abs(dev, ABS_TOOL_WIDTH, width);
363 static int elantech_check_parity_v1(struct psmouse *psmouse)
365 struct elantech_data *etd = psmouse->private;
366 unsigned char *packet = psmouse->packet;
367 unsigned char p1, p2, p3;
369 /* Parity bits are placed differently */
370 if (etd->fw_version < 0x020000) {
371 /* byte 0: D U p1 p2 1 p3 R L */
372 p1 = (packet[0] & 0x20) >> 5;
373 p2 = (packet[0] & 0x10) >> 4;
375 /* byte 0: n1 n0 p2 p1 1 p3 R L */
376 p1 = (packet[0] & 0x10) >> 4;
377 p2 = (packet[0] & 0x20) >> 5;
380 p3 = (packet[0] & 0x04) >> 2;
382 return etd->parity[packet[1]] == p1 &&
383 etd->parity[packet[2]] == p2 &&
384 etd->parity[packet[3]] == p3;
388 * Process byte stream from mouse and handle complete packets
390 static psmouse_ret_t elantech_process_byte(struct psmouse *psmouse)
392 struct elantech_data *etd = psmouse->private;
394 if (psmouse->pktcnt < psmouse->pktsize)
395 return PSMOUSE_GOOD_DATA;
398 elantech_packet_dump(psmouse->packet, psmouse->pktsize);
400 switch (etd->hw_version) {
402 if (etd->paritycheck && !elantech_check_parity_v1(psmouse))
403 return PSMOUSE_BAD_DATA;
405 elantech_report_absolute_v1(psmouse);
409 /* We don't know how to check parity in protocol v2 */
410 elantech_report_absolute_v2(psmouse);
414 return PSMOUSE_FULL_PACKET;
418 * Put the touchpad into absolute mode
420 static int elantech_set_absolute_mode(struct psmouse *psmouse)
422 struct elantech_data *etd = psmouse->private;
424 int tries = ETP_READ_BACK_TRIES;
427 switch (etd->hw_version) {
431 if (elantech_write_reg(psmouse, 0x10, etd->reg_10) ||
432 elantech_write_reg(psmouse, 0x11, etd->reg_11)) {
438 /* Windows driver values */
440 etd->reg_11 = 0x88; /* 0x8a */
441 etd->reg_21 = 0x60; /* 0x00 */
442 if (elantech_write_reg(psmouse, 0x10, etd->reg_10) ||
443 elantech_write_reg(psmouse, 0x11, etd->reg_11) ||
444 elantech_write_reg(psmouse, 0x21, etd->reg_21)) {
452 * Read back reg 0x10. For hardware version 1 we must make
453 * sure the absolute mode bit is set. For hardware version 2
454 * the touchpad is probably initalising and not ready until
455 * we read back the value we just wrote.
458 rc = elantech_read_reg(psmouse, 0x10, &val);
462 elantech_debug("retrying read (%d).\n", tries);
463 msleep(ETP_READ_BACK_DELAY);
467 pr_err("failed to read back register 0x10.\n");
468 } else if (etd->hw_version == 1 &&
469 !(val & ETP_R10_ABSOLUTE_MODE)) {
470 pr_err("touchpad refuses to switch to absolute mode.\n");
476 pr_err("failed to initialise registers.\n");
482 * Set the appropriate event bits for the input subsystem
484 static void elantech_set_input_params(struct psmouse *psmouse)
486 struct input_dev *dev = psmouse->dev;
487 struct elantech_data *etd = psmouse->private;
489 __set_bit(EV_KEY, dev->evbit);
490 __set_bit(EV_ABS, dev->evbit);
491 __clear_bit(EV_REL, dev->evbit);
493 __set_bit(BTN_LEFT, dev->keybit);
494 __set_bit(BTN_RIGHT, dev->keybit);
496 __set_bit(BTN_TOUCH, dev->keybit);
497 __set_bit(BTN_TOOL_FINGER, dev->keybit);
498 __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
499 __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit);
501 switch (etd->hw_version) {
504 if (etd->fw_version < 0x020000 &&
505 (etd->capabilities & ETP_CAP_HAS_ROCKER)) {
506 __set_bit(BTN_FORWARD, dev->keybit);
507 __set_bit(BTN_BACK, dev->keybit);
509 input_set_abs_params(dev, ABS_X, ETP_XMIN_V1, ETP_XMAX_V1, 0, 0);
510 input_set_abs_params(dev, ABS_Y, ETP_YMIN_V1, ETP_YMAX_V1, 0, 0);
514 __set_bit(BTN_TOOL_QUADTAP, dev->keybit);
515 input_set_abs_params(dev, ABS_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0);
516 input_set_abs_params(dev, ABS_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0);
517 if (etd->reports_pressure) {
518 input_set_abs_params(dev, ABS_PRESSURE, ETP_PMIN_V2,
520 input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2,
523 __set_bit(INPUT_PROP_SEMI_MT, dev->propbit);
524 input_mt_init_slots(dev, 2);
525 input_set_abs_params(dev, ABS_MT_POSITION_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0);
526 input_set_abs_params(dev, ABS_MT_POSITION_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0);
527 input_set_abs_params(dev, ABS_HAT0X, ETP_2FT_XMIN, ETP_2FT_XMAX, 0, 0);
528 input_set_abs_params(dev, ABS_HAT0Y, ETP_2FT_YMIN, ETP_2FT_YMAX, 0, 0);
529 input_set_abs_params(dev, ABS_HAT1X, ETP_2FT_XMIN, ETP_2FT_XMAX, 0, 0);
530 input_set_abs_params(dev, ABS_HAT1Y, ETP_2FT_YMIN, ETP_2FT_YMAX, 0, 0);
535 struct elantech_attr_data {
541 * Display a register value by reading a sysfs entry
543 static ssize_t elantech_show_int_attr(struct psmouse *psmouse, void *data,
546 struct elantech_data *etd = psmouse->private;
547 struct elantech_attr_data *attr = data;
548 unsigned char *reg = (unsigned char *) etd + attr->field_offset;
552 rc = elantech_read_reg(psmouse, attr->reg, reg);
554 return sprintf(buf, "0x%02x\n", (attr->reg && rc) ? -1 : *reg);
558 * Write a register value by writing a sysfs entry
560 static ssize_t elantech_set_int_attr(struct psmouse *psmouse,
561 void *data, const char *buf, size_t count)
563 struct elantech_data *etd = psmouse->private;
564 struct elantech_attr_data *attr = data;
565 unsigned char *reg = (unsigned char *) etd + attr->field_offset;
569 err = strict_strtoul(buf, 16, &value);
576 /* Do we need to preserve some bits for version 2 hardware too? */
577 if (etd->hw_version == 1) {
578 if (attr->reg == 0x10)
579 /* Force absolute mode always on */
580 value |= ETP_R10_ABSOLUTE_MODE;
581 else if (attr->reg == 0x11)
582 /* Force 4 byte mode always on */
583 value |= ETP_R11_4_BYTE_MODE;
586 if (!attr->reg || elantech_write_reg(psmouse, attr->reg, value) == 0)
592 #define ELANTECH_INT_ATTR(_name, _register) \
593 static struct elantech_attr_data elantech_attr_##_name = { \
594 .field_offset = offsetof(struct elantech_data, _name), \
597 PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \
598 &elantech_attr_##_name, \
599 elantech_show_int_attr, \
600 elantech_set_int_attr)
602 ELANTECH_INT_ATTR(reg_10, 0x10);
603 ELANTECH_INT_ATTR(reg_11, 0x11);
604 ELANTECH_INT_ATTR(reg_20, 0x20);
605 ELANTECH_INT_ATTR(reg_21, 0x21);
606 ELANTECH_INT_ATTR(reg_22, 0x22);
607 ELANTECH_INT_ATTR(reg_23, 0x23);
608 ELANTECH_INT_ATTR(reg_24, 0x24);
609 ELANTECH_INT_ATTR(reg_25, 0x25);
610 ELANTECH_INT_ATTR(reg_26, 0x26);
611 ELANTECH_INT_ATTR(debug, 0);
612 ELANTECH_INT_ATTR(paritycheck, 0);
614 static struct attribute *elantech_attrs[] = {
615 &psmouse_attr_reg_10.dattr.attr,
616 &psmouse_attr_reg_11.dattr.attr,
617 &psmouse_attr_reg_20.dattr.attr,
618 &psmouse_attr_reg_21.dattr.attr,
619 &psmouse_attr_reg_22.dattr.attr,
620 &psmouse_attr_reg_23.dattr.attr,
621 &psmouse_attr_reg_24.dattr.attr,
622 &psmouse_attr_reg_25.dattr.attr,
623 &psmouse_attr_reg_26.dattr.attr,
624 &psmouse_attr_debug.dattr.attr,
625 &psmouse_attr_paritycheck.dattr.attr,
629 static struct attribute_group elantech_attr_group = {
630 .attrs = elantech_attrs,
633 static bool elantech_is_signature_valid(const unsigned char *param)
635 static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10 };
644 for (i = 0; i < ARRAY_SIZE(rates); i++)
645 if (param[2] == rates[i])
652 * Use magic knock to detect Elantech touchpad
654 int elantech_detect(struct psmouse *psmouse, bool set_properties)
656 struct ps2dev *ps2dev = &psmouse->ps2dev;
657 unsigned char param[3];
659 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
661 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
662 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
663 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
664 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
665 ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {
666 pr_debug("sending Elantech magic knock failed.\n");
671 * Report this in case there are Elantech models that use a different
672 * set of magic numbers
674 if (param[0] != 0x3c || param[1] != 0x03 || param[2] != 0xc8) {
675 pr_debug("unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n",
676 param[0], param[1], param[2]);
681 * Query touchpad's firmware version and see if it reports known
682 * value to avoid mis-detection. Logitech mice are known to respond
683 * to Elantech magic knock and there might be more.
685 if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) {
686 pr_debug("failed to query firmware version.\n");
690 pr_debug("Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n",
691 param[0], param[1], param[2]);
693 if (!elantech_is_signature_valid(param)) {
694 if (!force_elantech) {
695 pr_debug("Probably not a real Elantech touchpad. Aborting.\n");
699 pr_debug("Probably not a real Elantech touchpad. Enabling anyway due to force_elantech.\n");
702 if (set_properties) {
703 psmouse->vendor = "Elantech";
704 psmouse->name = "Touchpad";
711 * Clean up sysfs entries when disconnecting
713 static void elantech_disconnect(struct psmouse *psmouse)
715 sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj,
716 &elantech_attr_group);
717 kfree(psmouse->private);
718 psmouse->private = NULL;
722 * Put the touchpad back into absolute mode when reconnecting
724 static int elantech_reconnect(struct psmouse *psmouse)
726 if (elantech_detect(psmouse, 0))
729 if (elantech_set_absolute_mode(psmouse)) {
730 pr_err("failed to put touchpad back into absolute mode.\n");
738 * Initialize the touchpad and create sysfs entries
740 int elantech_init(struct psmouse *psmouse)
742 struct elantech_data *etd;
744 unsigned char param[3];
746 psmouse->private = etd = kzalloc(sizeof(struct elantech_data), GFP_KERNEL);
751 for (i = 1; i < 256; i++)
752 etd->parity[i] = etd->parity[i & (i - 1)] ^ 1;
755 * Do the version query again so we can store the result
757 if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) {
758 pr_err("failed to query firmware version.\n");
762 etd->fw_version = (param[0] << 16) | (param[1] << 8) | param[2];
765 * Assume every version greater than this is new EeePC style
766 * hardware with 6 byte packets
768 if (etd->fw_version >= 0x020030) {
770 /* For now show extra debug information */
772 /* Don't know how to do parity checking for version 2 */
773 etd->paritycheck = 0;
775 if (etd->fw_version >= 0x020800)
776 etd->reports_pressure = true;
780 etd->paritycheck = 1;
783 pr_info("assuming hardware version %d, firmware version %d.%d.%d\n",
784 etd->hw_version, param[0], param[1], param[2]);
786 if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY, param)) {
787 pr_err("failed to query capabilities.\n");
790 pr_info("Synaptics capabilities query result 0x%02x, 0x%02x, 0x%02x.\n",
791 param[0], param[1], param[2]);
792 etd->capabilities = param[0];
795 * This firmware suffers from misreporting coordinates when
796 * a touch action starts causing the mouse cursor or scrolled page
797 * to jump. Enable a workaround.
799 if (etd->fw_version == 0x020022 || etd->fw_version == 0x020600) {
800 pr_info("firmware version 2.0.34/2.6.0 detected, enabling jumpy cursor workaround\n");
801 etd->jumpy_cursor = true;
804 if (elantech_set_absolute_mode(psmouse)) {
805 pr_err("failed to put touchpad into absolute mode.\n");
809 elantech_set_input_params(psmouse);
811 error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj,
812 &elantech_attr_group);
814 pr_err("failed to create sysfs attributes, error: %d.\n", error);
818 psmouse->protocol_handler = elantech_process_byte;
819 psmouse->disconnect = elantech_disconnect;
820 psmouse->reconnect = elantech_reconnect;
821 psmouse->pktsize = etd->hw_version == 2 ? 6 : 4;