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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Saturday, May 2, 2009 - 5:00 pm

Gitweb:     http://git.kernel.org/linus/b2546df69b6bef19513112fd54ffb5d37cb3eb7a
Commit:     b2546df69b6bef19513112fd54ffb5d37cb3eb7a
Parent:     3f8c0df43dec51fbdfb2627f7574aa00a5fce98c
Author:     Arjan Opmeer <arjan@opmeer.net>
AuthorDate: Sat Apr 18 19:10:17 2009 -0700
Committer:  Dmitry Torokhov <dmitry.torokhov@gmail.com>
CommitDate: Sat Apr 18 19:11:59 2009 -0700

    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>
---
 drivers/input/mouse/elantech.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index d3b5916..4bc7889 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -375,9 +375,14 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse)
 			rc = -1;
 			break;
 		}
+	}
+
+	if (rc == 0) {
 		/*
-		 * Read back reg 0x10. The touchpad is probably initalising
-		 * and not ready until we read back the value we just wrote.
+		 * Read back reg 0x10. For hardware version 1 we must make
+		 * sure the absolute mode bit is set. For hardware version 2
+		 * the touchpad is probably initalising and not ready until
+		 * we read back the value we just wrote.
 		 */
 		do {
 			rc = elantech_read_reg(psmouse, 0x10, &val);
@@ -385,12 +390,18 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse)
 				break;
 			tries--;
 			elantech_debug("elantech.c: retrying read (%d).\n",
-				tries);
+					tries);
 			msleep(ETP_READ_BACK_DELAY);
 		} while (tries > 0);
-		if (rc)
+
+		if (rc) {
 			pr_err("elantech.c: failed to read back register 0x10.\n");
-		break;
+		} else if (etd->hw_version == 1 &&
+			   !(val & ETP_R10_ABSOLUTE_MODE)) {
+			pr_err("elantech.c: touchpad refuses "
+				"to switch to absolute mode.\n");
+			rc = -1;
+		}
 	}
 
 	if (rc)
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Input: elantech - make sure touchpad is really in absolute ..., Linux Kernel Mailing ..., (Sat May 2, 5:00 pm)