diff options
author | Nicolas Boichat <drinkcat@google.com> | 2017-03-08 10:21:40 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-03-08 11:27:43 -0800 |
commit | 2b22a4b25f6aec16920a2670e7d74f58a91082d9 (patch) | |
tree | 4387eb6efa80004fc11cb4bb4ccf3534bb19f52e /driver/touchpad_elan.c | |
parent | b8c896788390526441fa52a0a3ce0b58675e7bc1 (diff) | |
download | chrome-ec-2b22a4b25f6aec16920a2670e7d74f58a91082d9.tar.gz |
driver/touchpad_elan: Use slightly more precise pressure adjustment
Matches the pressure multiplier used with elan trackpad on Chrome OS
(3.1416). We do fixed point arithmetic to avoid the need for
floating point or non-power of 2 division.
BRANCH=none
BUG=chrome-os-partner:59083
TEST=make BOARD=hammer -j && util/flash_ec --board=hammer
Change-Id: Ic3daad2645839955734eb7cbd9a60bbdf2520ce8
Reviewed-on: https://chromium-review.googlesource.com/450994
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.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/driver/touchpad_elan.c b/driver/touchpad_elan.c index 06bae3dcba..0610631d18 100644 --- a/driver/touchpad_elan.c +++ b/driver/touchpad_elan.c @@ -62,9 +62,10 @@ struct { /* * Report a more reasonable pressure value, so that no adjustment is necessary - * on Chrome OS side. + * on Chrome OS side. 3216/1024 ~= 3.1416. */ -const int pressure_mult = 3; +const int pressure_mult = 3216; +const int pressure_div = 1024; static int elan_tp_read_cmd(uint16_t reg, uint16_t *val) { @@ -149,10 +150,12 @@ static int elan_tp_read_report(void) int width = (finger[3] & 0xf0) >> 4; int height = finger[3] & 0x0f; int pressure = finger[4] + elan_tp_params.pressure_adj; + pressure = DIV_ROUND_NEAREST(pressure * pressure_mult, + pressure_div); width = MIN(4095, width * elan_tp_params.width_x); height = MIN(4095, height * elan_tp_params.width_y); - pressure = MIN(255, pressure * pressure_mult); + pressure = MIN(255, pressure); report.finger[ri].tip = 1; report.finger[ri].inrange = 1; |