summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTing Shen <phoenixshen@google.com>2021-04-14 17:46:47 +0800
committerCommit Bot <commit-bot@chromium.org>2021-04-15 11:46:17 +0000
commitf85969bcc0d0fae9b94dd460a2333fa8539c9d0a (patch)
treeae7ed86657a0d2188734524a4dfd7b44d78affaf
parent58cf225eec156aa1cf560b6d39f92a9c0798f0af (diff)
downloadchrome-ec-f85969bcc0d0fae9b94dd460a2333fa8539c9d0a.tar.gz
zed: update touchpad parameter
Update touchpad parameter for zed. There's no integer solution for CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y (calculation appended below), this CL also modified the runtime check in elan tp driver to allow rounding errors. Math details: Given dpi_y = 800, LOGICAL_MAX_Y = 1811, we want to find an integer PHYSICAL_MAX_Y such that dpi == 254 * LOGICAL_MAX_Y / PHYSICAL_MAX_Y. The closest solution is 1) PHYSICAL_MAX_Y = 574, 254 * LOGICAL_MAX_Y / PHYSICAL_MAX_Y = 801.3832 != dpi_y, or 2) PHYSICAL_MAX_Y = 575, 254 * LOGICAL_MAX_Y / PHYSICAL_MAX_Y = 799.9895 != dpi_y Both cannot pass our runtime verification. BUG=None TEST=No "TP mismatch" in ec console BRANCH=trogdor Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I9d0c54d029bb2f9e78114341a6246857b41937b4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2825473 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r--board/hammer/board.h1
-rw-r--r--board/hammer/variants.h20
-rw-r--r--driver/touchpad_elan.c24
3 files changed, 26 insertions, 19 deletions
diff --git a/board/hammer/board.h b/board/hammer/board.h
index d9e4236481..642fe908d4 100644
--- a/board/hammer/board.h
+++ b/board/hammer/board.h
@@ -83,6 +83,7 @@
#endif
#define CONFIG_LTO
#define CONFIG_FORCE_CONSOLE_RESUME
+#define CONFIG_MATH_UTIL
#define CONFIG_STM_HWTIMER32
/* USB Configuration */
diff --git a/board/hammer/variants.h b/board/hammer/variants.h
index e9ebadd0c6..d3ac1f7086 100644
--- a/board/hammer/variants.h
+++ b/board/hammer/variants.h
@@ -53,7 +53,7 @@
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 2925
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1440
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_PRESSURE 511
-#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 928 /* tenth of mm */
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 929 /* tenth of mm */
#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 457 /* tenth of mm */
#define CONFIG_TOUCHPAD_VIRTUAL_SIZE (56*1024)
#elif defined(BOARD_MAGNEMITE)
@@ -71,7 +71,7 @@
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 2925
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1440
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_PRESSURE 511
-#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 928 /* tenth of mm */
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 929 /* tenth of mm */
#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 457 /* tenth of mm */
#define CONFIG_TOUCHPAD_VIRTUAL_SIZE (56*1024)
#elif defined(BOARD_STAFF)
@@ -79,8 +79,8 @@
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 3206
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1832
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_PRESSURE 511
-#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 1017 /* tenth of mm */
-#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 581 /* tenth of mm */
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 1018 /* tenth of mm */
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 582 /* tenth of mm */
#define CONFIG_TOUCHPAD_VIRTUAL_SIZE (56*1024)
#elif defined(BOARD_STAR)
/* TODO: update correct parameters */
@@ -97,8 +97,8 @@
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 2160
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1573
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_PRESSURE 255
-#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 1030 /* tenth of mm */
-#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 750 /* tenth of mm */
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 1031 /* tenth of mm */
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 751 /* tenth of mm */
#define CONFIG_TOUCHPAD_VIRTUAL_SIZE (CONFIG_UPDATE_PDU_SIZE + 128*1024)
/* Enable to send heatmap to AP */
#define CONFIG_USB_ISOCHRONOUS
@@ -108,11 +108,11 @@
/* TODO: update correct parameters */
#define HAS_I2C_TOUCHPAD
-#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 3207
-#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1783
+#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 3340
+#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1811
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_PRESSURE 511
-#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 1018 /* tenth of mm */
-#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 566 /* tenth of mm */
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 1060 /* tenth of mm */
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 575 /* tenth of mm */
#define CONFIG_TOUCHPAD_VIRTUAL_SIZE (64*1024)
#else
#error "No touchpad information for board."
diff --git a/driver/touchpad_elan.c b/driver/touchpad_elan.c
index d2e28d53a6..6cd07dd2c2 100644
--- a/driver/touchpad_elan.c
+++ b/driver/touchpad_elan.c
@@ -10,6 +10,7 @@
#include "hwtimer.h"
#include "hooks.h"
#include "i2c.h"
+#include "math_util.h"
#include "sha256.h"
#include "shared_mem.h"
#include "task.h"
@@ -311,6 +312,15 @@ static int elan_get_fwinfo(void)
return EC_SUCCESS;
}
+/*
+ * - dpi == logical dimension / physical dimension (inches)
+ * (254 tenths of mm per inch)
+ */
+__maybe_unused static int calc_physical_dimension(int dpi, int logical_dim)
+{
+ return round_divide(254 * logical_dim, dpi);
+}
+
/* Initialize the controller ICs after reset */
static void elan_tp_init(void)
{
@@ -391,17 +401,13 @@ static void elan_tp_init(void)
elan_tp_params.pressure_adj, dpi_x, dpi_y);
#ifdef CONFIG_USB_HID_TOUCHPAD
- /*
- * Validity check dimensions provided at build time.
- * - dpi == logical dimension / physical dimension (inches)
- * (254 tenths of mm per inch)
- */
+ /* Validity check dimensions provided at build time. */
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) {
+ calc_physical_dimension(dpi_x, elan_tp_params.max_x) !=
+ CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X ||
+ calc_physical_dimension(dpi_y, elan_tp_params.max_y) !=
+ CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y) {
CPRINTS("*** TP mismatch!");
}
#endif