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

Input: elantech - make sure touchpad is really in absolute mode

There exist laptops with Elantech touchpads where switching to absolute mode
does not happen, although writing the configuration register succeeds
without error. Reading back the register afterwards reveils that the
absolute mode bit is not set as if masked out by the touchpad firmware.

Always read back register 0x10, make sure that for hardware version 1 the
absolute mode bit is actually set and fail otherwise. This prevents the case
where the touchpad is claimed by the Elantech driver but is nonetheless not
working.

Signed-off-by: Arjan Opmeer <arjan@opmeer.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

authored by

Arjan Opmeer and committed by
Dmitry Torokhov
b2546df6 3f8c0df4

+16 -5
+16 -5
drivers/input/mouse/elantech.c
··· 375 375 rc = -1; 376 376 break; 377 377 } 378 + } 379 + 380 + if (rc == 0) { 378 381 /* 379 - * Read back reg 0x10. The touchpad is probably initalising 380 - * and not ready until we read back the value we just wrote. 382 + * Read back reg 0x10. For hardware version 1 we must make 383 + * sure the absolute mode bit is set. For hardware version 2 384 + * the touchpad is probably initalising and not ready until 385 + * we read back the value we just wrote. 381 386 */ 382 387 do { 383 388 rc = elantech_read_reg(psmouse, 0x10, &val); ··· 390 385 break; 391 386 tries--; 392 387 elantech_debug("elantech.c: retrying read (%d).\n", 393 - tries); 388 + tries); 394 389 msleep(ETP_READ_BACK_DELAY); 395 390 } while (tries > 0); 396 - if (rc) 391 + 392 + if (rc) { 397 393 pr_err("elantech.c: failed to read back register 0x10.\n"); 398 - break; 394 + } else if (etd->hw_version == 1 && 395 + !(val & ETP_R10_ABSOLUTE_MODE)) { 396 + pr_err("elantech.c: touchpad refuses " 397 + "to switch to absolute mode.\n"); 398 + rc = -1; 399 + } 399 400 } 400 401 401 402 if (rc)