summaryrefslogtreecommitdiff
path: root/driver/touchpad_elan.c
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2017-05-16 11:32:03 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-05-18 02:26:08 -0700
commit8151b3f7e6b15c5de88f6d754aeda3fcf25bf6ad (patch)
tree3a5bf305512d5b48b2a21fa6d60df8f7d8a13ad3 /driver/touchpad_elan.c
parent12a8ab8a5c59f754caa098a2ac09d6a2db4fcc2a (diff)
downloadchrome-ec-8151b3f7e6b15c5de88f6d754aeda3fcf25bf6ad.tar.gz
touchpad_elan: Read resolution and validate against build-time values
At init time, read resolution/dpi from trackpad, and check that logical/physical dimensions match the expected values, provided at build-time. BRANCH=none BUG=b:38277869 TEST=Flash staff, no error message at boot time. Flash hammer image onto staff, a warning is shown at boot time. Change-Id: I5ef7d25b6e6525c2bd6fc023f58f3a242134d962 Reviewed-on: https://chromium-review.googlesource.com/505857 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'driver/touchpad_elan.c')
-rw-r--r--driver/touchpad_elan.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/driver/touchpad_elan.c b/driver/touchpad_elan.c
index 0610631d18..f0d3e6c9c1 100644
--- a/driver/touchpad_elan.c
+++ b/driver/touchpad_elan.c
@@ -29,6 +29,7 @@
#define ETP_I2C_XY_TRACENUM_CMD 0x0105
#define ETP_I2C_MAX_X_AXIS_CMD 0x0106
#define ETP_I2C_MAX_Y_AXIS_CMD 0x0107
+#define ETP_I2C_RESOLUTION_CMD 0x0108
#define ETP_I2C_PRESSURE_CMD 0x010A
#define ETP_I2C_SET_CMD 0x0300
@@ -190,6 +191,7 @@ static int elan_tp_init(void)
{
int rv;
uint8_t val[2];
+ int dpi_x, dpi_y;
CPRINTS("%s", __func__);
@@ -234,10 +236,33 @@ static int elan_tp_init(void)
goto out;
elan_tp_params.pressure_adj = (val[0] & 0x10) ? 0 : ETP_PRESSURE_OFFSET;
- CPRINTS("max=%d/%d width=%d/%d adj=%d",
+ rv = elan_tp_read_cmd(ETP_I2C_RESOLUTION_CMD, (uint16_t *)val);
+ if (rv)
+ goto out;
+
+ dpi_x = 10*val[0] + 790;
+ dpi_y = 10*val[1] + 790;
+
+ CPRINTS("max=%d/%d width=%d/%d adj=%d dpi=%d/%d",
elan_tp_params.max_x, elan_tp_params.max_y,
elan_tp_params.width_x, elan_tp_params.width_y,
- elan_tp_params.pressure_adj);
+ elan_tp_params.pressure_adj, dpi_x, dpi_y);
+
+#ifdef CONFIG_USB_HID_TOUCHPAD
+ /*
+ * Sanity check dimensions provided at build time.
+ * - dpi == logical dimension / physical dimension (inches)
+ * (254 tenths of mm per inch)
+ */
+ if (elan_tp_params.max_x != CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X ||
+ elan_tp_params.max_y != CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y ||
+ dpi_x != 254*CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X /
+ CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X ||
+ dpi_y != 254*CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y /
+ CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y) {
+ CPRINTS("*** TP mismatch!");
+ }
+#endif
/* Switch to absolute mode */
rv = elan_tp_write_cmd(ETP_I2C_SET_CMD, ETP_ENABLE_ABS);