aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/input/mouse/alps.c47
-rw-r--r--drivers/input/mouse/alps.h8
2 files changed, 33 insertions, 22 deletions
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index bfc193806fc1..2cd8be774f91 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -27,12 +27,6 @@
27/* 27/*
28 * Definitions for ALPS version 3 and 4 command mode protocol 28 * Definitions for ALPS version 3 and 4 command mode protocol
29 */ 29 */
30#define ALPS_V3_X_MAX 2000
31#define ALPS_V3_Y_MAX 1400
32
33#define ALPS_BITMAP_X_BITS 15
34#define ALPS_BITMAP_Y_BITS 11
35
36#define ALPS_CMD_NIBBLE_10 0x01f2 30#define ALPS_CMD_NIBBLE_10 0x01f2
37 31
38static const struct alps_nibble_commands alps_v3_nibble_commands[] = { 32static const struct alps_nibble_commands alps_v3_nibble_commands[] = {
@@ -269,7 +263,8 @@ static void alps_process_packet_v1_v2(struct psmouse *psmouse)
269 * These points are returned in x1, y1, x2, and y2 when the return value 263 * These points are returned in x1, y1, x2, and y2 when the return value
270 * is greater than 0. 264 * is greater than 0.
271 */ 265 */
272static int alps_process_bitmap(unsigned int x_map, unsigned int y_map, 266static int alps_process_bitmap(struct alps_data *priv,
267 unsigned int x_map, unsigned int y_map,
273 int *x1, int *y1, int *x2, int *y2) 268 int *x1, int *y1, int *x2, int *y2)
274{ 269{
275 struct alps_bitmap_point { 270 struct alps_bitmap_point {
@@ -311,7 +306,7 @@ static int alps_process_bitmap(unsigned int x_map, unsigned int y_map,
311 * y bitmap is reversed for what we need (lower positions are in 306 * y bitmap is reversed for what we need (lower positions are in
312 * higher bits), so we process from the top end. 307 * higher bits), so we process from the top end.
313 */ 308 */
314 y_map = y_map << (sizeof(y_map) * BITS_PER_BYTE - ALPS_BITMAP_Y_BITS); 309 y_map = y_map << (sizeof(y_map) * BITS_PER_BYTE - priv->y_bits);
315 prev_bit = 0; 310 prev_bit = 0;
316 point = &y_low; 311 point = &y_low;
317 for (i = 0; y_map != 0; i++, y_map <<= 1) { 312 for (i = 0; y_map != 0; i++, y_map <<= 1) {
@@ -357,16 +352,18 @@ static int alps_process_bitmap(unsigned int x_map, unsigned int y_map,
357 } 352 }
358 } 353 }
359 354
360 *x1 = (ALPS_V3_X_MAX * (2 * x_low.start_bit + x_low.num_bits - 1)) / 355 *x1 = (priv->x_max * (2 * x_low.start_bit + x_low.num_bits - 1)) /
361 (2 * (ALPS_BITMAP_X_BITS - 1)); 356 (2 * (priv->x_bits - 1));
362 *y1 = (ALPS_V3_Y_MAX * (2 * y_low.start_bit + y_low.num_bits - 1)) / 357 *y1 = (priv->y_max * (2 * y_low.start_bit + y_low.num_bits - 1)) /
363 (2 * (ALPS_BITMAP_Y_BITS - 1)); 358 (2 * (priv->y_bits - 1));
364 359
365 if (fingers > 1) { 360 if (fingers > 1) {
366 *x2 = (ALPS_V3_X_MAX * (2 * x_high.start_bit + x_high.num_bits - 1)) / 361 *x2 = (priv->x_max *
367 (2 * (ALPS_BITMAP_X_BITS - 1)); 362 (2 * x_high.start_bit + x_high.num_bits - 1)) /
368 *y2 = (ALPS_V3_Y_MAX * (2 * y_high.start_bit + y_high.num_bits - 1)) / 363 (2 * (priv->x_bits - 1));
369 (2 * (ALPS_BITMAP_Y_BITS - 1)); 364 *y2 = (priv->y_max *
365 (2 * y_high.start_bit + y_high.num_bits - 1)) /
366 (2 * (priv->y_bits - 1));
370 } 367 }
371 368
372 return fingers; 369 return fingers;
@@ -484,7 +481,8 @@ static void alps_process_touchpad_packet_v3(struct psmouse *psmouse)
484 ((packet[2] & 0x7f) << 1) | 481 ((packet[2] & 0x7f) << 1) |
485 (packet[4] & 0x01); 482 (packet[4] & 0x01);
486 483
487 bmap_fingers = alps_process_bitmap(x_bitmap, y_bitmap, 484 bmap_fingers = alps_process_bitmap(priv,
485 x_bitmap, y_bitmap,
488 &x1, &y1, &x2, &y2); 486 &x1, &y1, &x2, &y2);
489 487
490 /* 488 /*
@@ -641,7 +639,7 @@ static void alps_process_packet_v4(struct psmouse *psmouse)
641 ((priv->multi_data[3] & 0x1f) << 5) | 639 ((priv->multi_data[3] & 0x1f) << 5) |
642 (priv->multi_data[1] & 0x1f); 640 (priv->multi_data[1] & 0x1f);
643 641
644 fingers = alps_process_bitmap(x_bitmap, y_bitmap, 642 fingers = alps_process_bitmap(priv, x_bitmap, y_bitmap,
645 &x1, &y1, &x2, &y2); 643 &x1, &y1, &x2, &y2);
646 644
647 /* Store MT data.*/ 645 /* Store MT data.*/
@@ -1414,6 +1412,11 @@ static void alps_set_defaults(struct alps_data *priv)
1414 priv->mask0 = 0x8f; 1412 priv->mask0 = 0x8f;
1415 priv->flags = ALPS_DUALPOINT; 1413 priv->flags = ALPS_DUALPOINT;
1416 1414
1415 priv->x_max = 2000;
1416 priv->y_max = 1400;
1417 priv->x_bits = 15;
1418 priv->y_bits = 11;
1419
1417 switch (priv->proto_version) { 1420 switch (priv->proto_version) {
1418 case ALPS_PROTO_V1: 1421 case ALPS_PROTO_V1:
1419 case ALPS_PROTO_V2: 1422 case ALPS_PROTO_V2:
@@ -1544,15 +1547,15 @@ static void alps_set_abs_params_mt(struct alps_data *priv,
1544{ 1547{
1545 set_bit(INPUT_PROP_SEMI_MT, dev1->propbit); 1548 set_bit(INPUT_PROP_SEMI_MT, dev1->propbit);
1546 input_mt_init_slots(dev1, 2, 0); 1549 input_mt_init_slots(dev1, 2, 0);
1547 input_set_abs_params(dev1, ABS_MT_POSITION_X, 0, ALPS_V3_X_MAX, 0, 0); 1550 input_set_abs_params(dev1, ABS_MT_POSITION_X, 0, priv->x_max, 0, 0);
1548 input_set_abs_params(dev1, ABS_MT_POSITION_Y, 0, ALPS_V3_Y_MAX, 0, 0); 1551 input_set_abs_params(dev1, ABS_MT_POSITION_Y, 0, priv->y_max, 0, 0);
1549 1552
1550 set_bit(BTN_TOOL_DOUBLETAP, dev1->keybit); 1553 set_bit(BTN_TOOL_DOUBLETAP, dev1->keybit);
1551 set_bit(BTN_TOOL_TRIPLETAP, dev1->keybit); 1554 set_bit(BTN_TOOL_TRIPLETAP, dev1->keybit);
1552 set_bit(BTN_TOOL_QUADTAP, dev1->keybit); 1555 set_bit(BTN_TOOL_QUADTAP, dev1->keybit);
1553 1556
1554 input_set_abs_params(dev1, ABS_X, 0, ALPS_V3_X_MAX, 0, 0); 1557 input_set_abs_params(dev1, ABS_X, 0, priv->x_max, 0, 0);
1555 input_set_abs_params(dev1, ABS_Y, 0, ALPS_V3_Y_MAX, 0, 0); 1558 input_set_abs_params(dev1, ABS_Y, 0, priv->y_max, 0, 0);
1556} 1559}
1557 1560
1558int alps_init(struct psmouse *psmouse) 1561int alps_init(struct psmouse *psmouse)
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index 0934f8bf7d76..5e638be33dc9 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -72,6 +72,10 @@ struct alps_nibble_commands {
72 * mask0, should match byte0. 72 * mask0, should match byte0.
73 * @mask0: The mask used to check the first byte of the report. 73 * @mask0: The mask used to check the first byte of the report.
74 * @flags: Additional device capabilities (passthrough port, trackstick, etc.). 74 * @flags: Additional device capabilities (passthrough port, trackstick, etc.).
75 * @x_max: Largest possible X position value.
76 * @y_max: Largest possible Y position value.
77 * @x_bits: Number of X bits in the MT bitmap.
78 * @y_bits: Number of Y bits in the MT bitmap.
75 * @hw_init: Protocol-specific hardware init function. 79 * @hw_init: Protocol-specific hardware init function.
76 * @process_packet: Protocol-specific function to process a report packet. 80 * @process_packet: Protocol-specific function to process a report packet.
77 * @set_abs_params: Protocol-specific function to configure the input_dev. 81 * @set_abs_params: Protocol-specific function to configure the input_dev.
@@ -96,6 +100,10 @@ struct alps_data {
96 unsigned char proto_version; 100 unsigned char proto_version;
97 unsigned char byte0, mask0; 101 unsigned char byte0, mask0;
98 unsigned char flags; 102 unsigned char flags;
103 int x_max;
104 int y_max;
105 int x_bits;
106 int y_bits;
99 107
100 int (*hw_init)(struct psmouse *psmouse); 108 int (*hw_init)(struct psmouse *psmouse);
101 void (*process_packet)(struct psmouse *psmouse); 109 void (*process_packet)(struct psmouse *psmouse);