Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: elantech - improve clickpad detection

The current assumption in the elantech driver that hw version 3 touchpads
are never clickpads and hw version 4 touchpads are always clickpads is
wrong.

There are several bug reports for this, ie:
https://bugzilla.redhat.com/show_bug.cgi?id=1030802
http://superuser.com/questions/619582/right-elantech-touchpad-button-not-working-in-linux

I've spend a couple of hours wading through various bugzillas, launchpads
and forum posts to create a list of fw-versions and capabilities for
different laptop models to find a good method to differentiate between
clickpads and versions with separate hardware buttons.

Which shows that a device being a clickpad is reliable indicated by bit 12
being set in the fw_version. I've included the gathered list inside the
driver, so that we've this info at hand if we need to revisit this later.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Hans de Goede and committed by
Dmitry Torokhov
c15bdfd5 768d9aa5

+42 -3
+42 -3
drivers/input/mouse/elantech.c
··· 486 486 unsigned char *packet = psmouse->packet; 487 487 488 488 input_report_key(dev, BTN_LEFT, packet[0] & 0x01); 489 + input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); 489 490 input_mt_report_pointer_emulation(dev, true); 490 491 input_sync(dev); 491 492 } ··· 985 984 } 986 985 987 986 /* 987 + * Advertise INPUT_PROP_BUTTONPAD for clickpads. The testing of bit 12 in 988 + * fw_version for this is based on the following fw_version & caps table: 989 + * 990 + * Laptop-model: fw_version: caps: buttons: 991 + * Acer S3 0x461f00 10, 13, 0e clickpad 992 + * Acer S7-392 0x581f01 50, 17, 0d clickpad 993 + * Acer V5-131 0x461f02 01, 16, 0c clickpad 994 + * Acer V5-551 0x461f00 ? clickpad 995 + * Asus K53SV 0x450f01 78, 15, 0c 2 hw buttons 996 + * Asus G46VW 0x460f02 00, 18, 0c 2 hw buttons 997 + * Asus G750JX 0x360f00 00, 16, 0c 2 hw buttons 998 + * Asus UX31 0x361f00 20, 15, 0e clickpad 999 + * Asus UX32VD 0x361f02 00, 15, 0e clickpad 1000 + * Avatar AVIU-145A2 0x361f00 ? clickpad 1001 + * Gigabyte U2442 0x450f01 58, 17, 0c 2 hw buttons 1002 + * Lenovo L430 0x350f02 b9, 15, 0c 2 hw buttons (*) 1003 + * Samsung NF210 0x150b00 78, 14, 0a 2 hw buttons 1004 + * Samsung NP770Z5E 0x575f01 10, 15, 0f clickpad 1005 + * Samsung NP700Z5B 0x361f06 21, 15, 0f clickpad 1006 + * Samsung NP900X3E-A02 0x575f03 ? clickpad 1007 + * Samsung NP-QX410 0x851b00 19, 14, 0c clickpad 1008 + * Samsung RC512 0x450f00 08, 15, 0c 2 hw buttons 1009 + * Samsung RF710 0x450f00 ? 2 hw buttons 1010 + * System76 Pangolin 0x250f01 ? 2 hw buttons 1011 + * (*) + 3 trackpoint buttons 1012 + */ 1013 + static void elantech_set_buttonpad_prop(struct psmouse *psmouse) 1014 + { 1015 + struct input_dev *dev = psmouse->dev; 1016 + struct elantech_data *etd = psmouse->private; 1017 + 1018 + if (etd->fw_version & 0x001000) { 1019 + __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); 1020 + __clear_bit(BTN_RIGHT, dev->keybit); 1021 + } 1022 + } 1023 + 1024 + /* 988 1025 * Set the appropriate event bits for the input subsystem 989 1026 */ 990 1027 static int elantech_set_input_params(struct psmouse *psmouse) ··· 1065 1026 __set_bit(INPUT_PROP_SEMI_MT, dev->propbit); 1066 1027 /* fall through */ 1067 1028 case 3: 1029 + if (etd->hw_version == 3) 1030 + elantech_set_buttonpad_prop(psmouse); 1068 1031 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); 1069 1032 input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0); 1070 1033 if (etd->reports_pressure) { ··· 1088 1047 */ 1089 1048 psmouse_warn(psmouse, "couldn't query resolution data.\n"); 1090 1049 } 1091 - /* v4 is clickpad, with only one button. */ 1092 - __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); 1093 - __clear_bit(BTN_RIGHT, dev->keybit); 1050 + elantech_set_buttonpad_prop(psmouse); 1094 1051 __set_bit(BTN_TOOL_QUADTAP, dev->keybit); 1095 1052 /* For X to recognize me as touchpad. */ 1096 1053 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);