diff options
author | JJ Ding <jj_ding@emc.com.tw> | 2011-09-09 10:26:16 -0700 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-09-09 10:34:36 -0700 |
commit | 230282a77bcec97f4d0a54e50a44caab5eb39d5c (patch) | |
tree | 4944a12840bb35cabeef7b63803ed8cb0f4bab1c /drivers/input | |
parent | 461a791765da501f73e3d5957788267101e800d2 (diff) |
Input: elantech - use firmware provided x, y ranges
With newer hardware, the touchpad provides range info.
Let's use it.
Signed-off-by: JJ Ding <jj_ding@emc.com.tw>
Acked-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Éric Piel <eric.piel@tremplin-utc.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/mouse/elantech.c | 71 | ||||
-rw-r--r-- | drivers/input/mouse/elantech.h | 3 |
2 files changed, 58 insertions, 16 deletions
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index cd8e2e5ced86..296b6a6250fd 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -223,7 +223,7 @@ static void elantech_report_absolute_v1(struct psmouse *psmouse) input_report_abs(dev, ABS_X, ((packet[1] & 0x0c) << 6) | packet[2]); input_report_abs(dev, ABS_Y, - ETP_YMAX_V1 - (((packet[1] & 0x03) << 8) | packet[3])); + etd->y_max - (((packet[1] & 0x03) << 8) | packet[3])); } input_report_key(dev, BTN_TOOL_FINGER, fingers == 1); @@ -233,7 +233,7 @@ static void elantech_report_absolute_v1(struct psmouse *psmouse) input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); if (etd->fw_version < 0x020000 && - (etd->capabilities & ETP_CAP_HAS_ROCKER)) { + (etd->capabilities[0] & ETP_CAP_HAS_ROCKER)) { /* rocker up */ input_report_key(dev, BTN_FORWARD, packet[0] & 0x40); /* rocker down */ @@ -298,7 +298,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) * byte 4: . . . . y11 y10 y9 y8 * byte 5: y7 y6 y5 y4 y3 y2 y1 y0 */ - y1 = ETP_YMAX_V2 - (((packet[4] & 0x0f) << 8) | packet[5]); + y1 = etd->y_max - (((packet[4] & 0x0f) << 8) | packet[5]); pres = (packet[1] & 0xf0) | ((packet[4] & 0xf0) >> 4); width = ((packet[0] & 0x30) >> 2) | ((packet[3] & 0x30) >> 4); @@ -313,7 +313,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) */ x1 = (((packet[0] & 0x10) << 4) | packet[1]) << 2; /* byte 2: ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0 */ - y1 = ETP_YMAX_V2 - + y1 = etd->y_max - ((((packet[0] & 0x20) << 3) | packet[2]) << 2); /* * byte 3: . . by8 bx8 . . . . @@ -321,7 +321,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) */ x2 = (((packet[3] & 0x10) << 4) | packet[4]) << 2; /* byte 5: by7 by8 by5 by4 by3 by2 by1 by0 */ - y2 = ETP_YMAX_V2 - + y2 = etd->y_max - ((((packet[3] & 0x20) << 3) | packet[5]) << 2); /* Unknown so just report sensible values */ @@ -468,6 +468,41 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse) return rc; } +static void elantech_set_range(struct psmouse *psmouse, + unsigned int *x_min, unsigned int *y_min, + unsigned int *x_max, unsigned int *y_max) +{ + struct elantech_data *etd = psmouse->private; + int i; + + switch (etd->hw_version) { + case 1: + *x_min = ETP_XMIN_V1; + *y_min = ETP_YMIN_V1; + *x_max = ETP_XMAX_V1; + *y_max = ETP_YMAX_V1; + break; + + case 2: + if (etd->fw_version == 0x020800 || + etd->fw_version == 0x020b00 || + etd->fw_version == 0x020030) { + *x_min = ETP_XMIN_V2; + *y_min = ETP_YMIN_V2; + *x_max = ETP_XMAX_V2; + *y_max = ETP_YMAX_V2; + } else { + i = (etd->fw_version > 0x020800 && + etd->fw_version < 0x020900) ? 1 : 2; + *x_min = 0; + *y_min = 0; + *x_max = (etd->capabilities[1] - i) * 64; + *y_max = (etd->capabilities[2] - i) * 64; + } + break; + } +} + /* * Set the appropriate event bits for the input subsystem */ @@ -475,6 +510,9 @@ static void elantech_set_input_params(struct psmouse *psmouse) { struct input_dev *dev = psmouse->dev; struct elantech_data *etd = psmouse->private; + unsigned int x_min = 0, y_min = 0, x_max = 0, y_max = 0; + + elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max); __set_bit(EV_KEY, dev->evbit); __set_bit(EV_ABS, dev->evbit); @@ -492,18 +530,18 @@ static void elantech_set_input_params(struct psmouse *psmouse) case 1: /* Rocker button */ if (etd->fw_version < 0x020000 && - (etd->capabilities & ETP_CAP_HAS_ROCKER)) { + (etd->capabilities[0] & ETP_CAP_HAS_ROCKER)) { __set_bit(BTN_FORWARD, dev->keybit); __set_bit(BTN_BACK, dev->keybit); } - input_set_abs_params(dev, ABS_X, ETP_XMIN_V1, ETP_XMAX_V1, 0, 0); - input_set_abs_params(dev, ABS_Y, ETP_YMIN_V1, ETP_YMAX_V1, 0, 0); + input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); + input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0); break; case 2: __set_bit(BTN_TOOL_QUADTAP, dev->keybit); - input_set_abs_params(dev, ABS_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0); - input_set_abs_params(dev, ABS_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0); + input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); + input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0); if (etd->reports_pressure) { input_set_abs_params(dev, ABS_PRESSURE, ETP_PMIN_V2, ETP_PMAX_V2, 0, 0); @@ -512,10 +550,12 @@ static void elantech_set_input_params(struct psmouse *psmouse) } __set_bit(INPUT_PROP_SEMI_MT, dev->propbit); input_mt_init_slots(dev, 2); - input_set_abs_params(dev, ABS_MT_POSITION_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0); - input_set_abs_params(dev, ABS_MT_POSITION_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0); + input_set_abs_params(dev, ABS_MT_POSITION_X, x_min, x_max, 0, 0); + input_set_abs_params(dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0); break; } + + etd->y_max = y_max; } struct elantech_attr_data { @@ -769,13 +809,14 @@ int elantech_init(struct psmouse *psmouse) pr_info("assuming hardware version %d, firmware version %d.%d.%d\n", etd->hw_version, param[0], param[1], param[2]); - if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY, param)) { + if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY, + etd->capabilities)) { pr_err("failed to query capabilities.\n"); goto init_fail; } pr_info("Synaptics capabilities query result 0x%02x, 0x%02x, 0x%02x.\n", - param[0], param[1], param[2]); - etd->capabilities = param[0]; + etd->capabilities[0], etd->capabilities[1], + etd->capabilities[2]); /* * This firmware suffers from misreporting coordinates when diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h index 1c5894efda5a..b54ea27d10af 100644 --- a/drivers/input/mouse/elantech.h +++ b/drivers/input/mouse/elantech.h @@ -93,13 +93,14 @@ struct elantech_data { unsigned char reg_25; unsigned char reg_26; unsigned char debug; - unsigned char capabilities; + unsigned char capabilities[3]; bool paritycheck; bool jumpy_cursor; bool reports_pressure; unsigned char hw_version; unsigned int fw_version; unsigned int single_finger_reports; + unsigned int y_max; unsigned char parity[256]; }; |