diff options
author | Hans de Goede <hdegoede@redhat.com> | 2015-05-20 17:43:09 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-05-20 17:45:45 -0400 |
commit | dccf1dd8458236a28552510b83a06a8cc0f1c473 (patch) | |
tree | 73cd5b0a11fab0106ae684333ef378a5d3fa498f | |
parent | 688ea364b2e73ae4d757e550ec06663a4903b334 (diff) |
Input: alps - use the generic process_bitmap function for v5 touchpads
Now that the generic process_bitmap function has been improved to offer
accurate coordinates for the first touch we can use it for v5 (dolphin)
touchpads too.
Besides being a nice code cleanup this also fixes the saw tooth pattern
in the coordinates for the second touch the dolphin specific version had.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/mouse/alps.c | 74 |
1 files changed, 12 insertions, 62 deletions
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index e9e13cd026d2..4e1af89c7749 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
@@ -302,53 +302,6 @@ static void alps_process_packet_v1_v2(struct psmouse *psmouse) | |||
302 | input_sync(dev); | 302 | input_sync(dev); |
303 | } | 303 | } |
304 | 304 | ||
305 | /* | ||
306 | * Process bitmap data for V5 protocols. Return value is null. | ||
307 | * | ||
308 | * The bitmaps don't have enough data to track fingers, so this function | ||
309 | * only generates points representing a bounding box of at most two contacts. | ||
310 | * These two points are returned in fields->mt. | ||
311 | */ | ||
312 | static void alps_process_bitmap_dolphin(struct alps_data *priv, | ||
313 | struct alps_fields *fields) | ||
314 | { | ||
315 | int box_middle_x, box_middle_y; | ||
316 | unsigned int x_map, y_map; | ||
317 | unsigned char start_bit, end_bit; | ||
318 | unsigned char x_msb, x_lsb, y_msb, y_lsb; | ||
319 | |||
320 | x_map = fields->x_map; | ||
321 | y_map = fields->y_map; | ||
322 | |||
323 | if (!x_map || !y_map) | ||
324 | return; | ||
325 | |||
326 | /* Get Most-significant and Least-significant bit */ | ||
327 | x_msb = fls(x_map); | ||
328 | x_lsb = ffs(x_map); | ||
329 | y_msb = fls(y_map); | ||
330 | y_lsb = ffs(y_map); | ||
331 | |||
332 | /* Most-significant bit should never exceed max sensor line number */ | ||
333 | if (x_msb > priv->x_bits || y_msb > priv->y_bits) | ||
334 | return; | ||
335 | |||
336 | if (fields->fingers > 1) { | ||
337 | start_bit = priv->x_bits - x_msb; | ||
338 | end_bit = priv->x_bits - x_lsb; | ||
339 | box_middle_x = (priv->x_max * (start_bit + end_bit)) / | ||
340 | (2 * (priv->x_bits - 1)); | ||
341 | |||
342 | start_bit = y_lsb - 1; | ||
343 | end_bit = y_msb - 1; | ||
344 | box_middle_y = (priv->y_max * (start_bit + end_bit)) / | ||
345 | (2 * (priv->y_bits - 1)); | ||
346 | fields->mt[0] = fields->st; | ||
347 | fields->mt[1].x = 2 * box_middle_x - fields->mt[0].x; | ||
348 | fields->mt[1].y = 2 * box_middle_y - fields->mt[0].y; | ||
349 | } | ||
350 | } | ||
351 | |||
352 | static void alps_get_bitmap_points(unsigned int map, | 305 | static void alps_get_bitmap_points(unsigned int map, |
353 | struct alps_bitmap_point *low, | 306 | struct alps_bitmap_point *low, |
354 | struct alps_bitmap_point *high, | 307 | struct alps_bitmap_point *high, |
@@ -376,7 +329,7 @@ static void alps_get_bitmap_points(unsigned int map, | |||
376 | } | 329 | } |
377 | 330 | ||
378 | /* | 331 | /* |
379 | * Process bitmap data from v3 and v4 protocols. Returns the number of | 332 | * Process bitmap data from semi-mt protocols. Returns the number of |
380 | * fingers detected. A return value of 0 means at least one of the | 333 | * fingers detected. A return value of 0 means at least one of the |
381 | * bitmaps was empty. | 334 | * bitmaps was empty. |
382 | * | 335 | * |
@@ -454,8 +407,15 @@ static int alps_process_bitmap(struct alps_data *priv, | |||
454 | (priv->y_max * (2 * y_high.start_bit + y_high.num_bits - 1)) / | 407 | (priv->y_max * (2 * y_high.start_bit + y_high.num_bits - 1)) / |
455 | (2 * (priv->y_bits - 1)); | 408 | (2 * (priv->y_bits - 1)); |
456 | 409 | ||
457 | /* y-bitmap order is reversed, except on rushmore */ | 410 | /* x-bitmap order is reversed on v5 touchpads */ |
458 | if (priv->proto_version != ALPS_PROTO_V3_RUSHMORE) { | 411 | if (priv->proto_version == ALPS_PROTO_V5) { |
412 | for (i = 0; i < 4; i++) | ||
413 | corner[i].x = priv->x_max - corner[i].x; | ||
414 | } | ||
415 | |||
416 | /* y-bitmap order is reversed on v3 and v4 touchpads */ | ||
417 | if (priv->proto_version == ALPS_PROTO_V3 || | ||
418 | priv->proto_version == ALPS_PROTO_V4) { | ||
459 | for (i = 0; i < 4; i++) | 419 | for (i = 0; i < 4; i++) |
460 | corner[i].y = priv->y_max - corner[i].y; | 420 | corner[i].y = priv->y_max - corner[i].y; |
461 | } | 421 | } |
@@ -742,18 +702,8 @@ static void alps_process_touchpad_packet_v3_v5(struct psmouse *psmouse) | |||
742 | * data, so we need to do decode it first. | 702 | * data, so we need to do decode it first. |
743 | */ | 703 | */ |
744 | priv->decode_fields(f, priv->multi_data, psmouse); | 704 | priv->decode_fields(f, priv->multi_data, psmouse); |
745 | 705 | if (alps_process_bitmap(priv, f) == 0) | |
746 | if (priv->proto_version == ALPS_PROTO_V3 || | 706 | fingers = 0; /* Use st data */ |
747 | priv->proto_version == ALPS_PROTO_V3_RUSHMORE) { | ||
748 | if (alps_process_bitmap(priv, f) == 0) | ||
749 | fingers = 0; /* Use st data */ | ||
750 | } else { | ||
751 | /* | ||
752 | * Since Dolphin's finger number is reliable, | ||
753 | * there is no need to compare with bmap_fn. | ||
754 | */ | ||
755 | alps_process_bitmap_dolphin(priv, f); | ||
756 | } | ||
757 | } else { | 707 | } else { |
758 | priv->multi_packet = 0; | 708 | priv->multi_packet = 0; |
759 | } | 709 | } |