Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269470
b: refs/heads/master
c: 230282a
h: refs/heads/master
v: v3
  • Loading branch information
JJ Ding authored and Dmitry Torokhov committed Sep 9, 2011
1 parent 37d57b3 commit eeb872d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 461a791765da501f73e3d5957788267101e800d2
refs/heads/master: 230282a77bcec97f4d0a54e50a44caab5eb39d5c
71 changes: 56 additions & 15 deletions trunk/drivers/input/mouse/elantech.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 */
Expand Down Expand Up @@ -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);
Expand All @@ -313,15 +313,15 @@ 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 . . . .
* byte 4: bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0
*/
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 */
Expand Down Expand Up @@ -468,13 +468,51 @@ 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
*/
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);
Expand All @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/input/mouse/elantech.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};

Expand Down

0 comments on commit eeb872d

Please sign in to comment.