Lines Matching +full:max +full:- +full:fingers
1 // SPDX-License-Identifier: GPL-2.0-only
6 * Copyright (c) 2003-2005 Peter Osterlund <petero2@telia.com>
94 #define ALPS_PASS 0x04 /* device has a pass-through port */
100 #define ALPS_PS2_INTERLEAVED 0x80 /* 3-byte PS/2 packet interleaved with
101 6-byte ALPS packet */
117 { { 0x33, 0x02, 0x0a }, { ALPS_PROTO_V1, 0x88, 0xf8, 0 } }, /* UMAX-530T */
119 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED } }, /* Toshiba Tecra A11-11L */
128 …{ { 0x63, 0x02, 0x3c }, { ALPS_PROTO_V2, 0x8f, 0x8f, ALPS_WHEEL } }, /* Toshiba Satellite S2400-…
132 …{ { 0x73, 0x00, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_DUALPOINT } }, /* ThinkPad R61 8918-5QG…
180 /* Reported-by: Hans de Bruin <jmdebruin@xmsnet.nl> */
187 /* Reported-by: Hans de Goede <hdegoede@redhat.com> */
218 return (data & priv->mask0) == priv->byte0; in alps_is_valid_first_byte()
231 dev = (dev2 && test_bit(BTN_LEFT, dev2->key)) ? dev2 : dev1; in alps_report_buttons()
234 dev = (dev2 && test_bit(BTN_RIGHT, dev2->key)) ? dev2 : dev1; in alps_report_buttons()
237 dev = (dev2 && test_bit(BTN_MIDDLE, dev2->key)) ? dev2 : dev1; in alps_report_buttons()
250 struct alps_data *priv = psmouse->private; in alps_process_packet_v1_v2()
251 unsigned char *packet = psmouse->packet; in alps_process_packet_v1_v2()
252 struct input_dev *dev = psmouse->dev; in alps_process_packet_v1_v2()
253 struct input_dev *dev2 = priv->dev2; in alps_process_packet_v1_v2()
257 if (priv->proto_version == ALPS_PROTO_V1) { in alps_process_packet_v1_v2()
268 x = packet[1] | ((packet[2] & 0x78) << (7 - 3)); in alps_process_packet_v1_v2()
269 y = packet[4] | ((packet[3] & 0x70) << (7 - 4)); in alps_process_packet_v1_v2()
273 if (priv->flags & ALPS_FW_BK_1) { in alps_process_packet_v1_v2()
278 if (priv->flags & ALPS_FW_BK_2) { in alps_process_packet_v1_v2()
288 if ((priv->flags & ALPS_DUALPOINT) && z == 127) { in alps_process_packet_v1_v2()
289 input_report_rel(dev2, REL_X, (x > 383 ? (x - 768) : x)); in alps_process_packet_v1_v2()
290 input_report_rel(dev2, REL_Y, -(y > 255 ? (y - 512) : y)); in alps_process_packet_v1_v2()
299 if (priv->flags & ALPS_STICK_BITS) { in alps_process_packet_v1_v2()
316 if (ges && fin && !priv->prev_fin) { in alps_process_packet_v1_v2()
323 priv->prev_fin = fin; in alps_process_packet_v1_v2()
338 if (priv->flags & ALPS_WHEEL) in alps_process_packet_v1_v2()
339 input_report_rel(dev, REL_WHEEL, ((packet[2] << 1) & 0x08) - ((packet[0] >> 4) & 0x07)); in alps_process_packet_v1_v2()
341 if (priv->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { in alps_process_packet_v1_v2()
346 if (priv->flags & ALPS_FOUR_BUTTONS) { in alps_process_packet_v1_v2()
359 int *fingers) in alps_get_bitmap_points() argument
369 point->start_bit = i; in alps_get_bitmap_points()
370 point->num_bits = 0; in alps_get_bitmap_points()
371 (*fingers)++; in alps_get_bitmap_points()
373 point->num_bits++; in alps_get_bitmap_points()
383 * Process bitmap data from semi-mt protocols. Returns the number of
384 * fingers detected. A return value of 0 means at least one of the
387 * The bitmaps don't have enough data to track fingers, so this function
389 * These points are returned in fields->mt when the return value
395 int i, fingers_x = 0, fingers_y = 0, fingers, closest; in alps_process_bitmap() local
400 if (!fields->x_map || !fields->y_map) in alps_process_bitmap()
403 alps_get_bitmap_points(fields->x_map, &x_low, &x_high, &fingers_x); in alps_process_bitmap()
404 alps_get_bitmap_points(fields->y_map, &y_low, &y_high, &fingers_y); in alps_process_bitmap()
407 * Fingers can overlap, so we use the maximum count of fingers in alps_process_bitmap()
410 fingers = max(fingers_x, fingers_y); in alps_process_bitmap()
414 * adjacent fingers. Divide the single contact between the two points. in alps_process_bitmap()
417 i = (x_low.num_bits - 1) / 2; in alps_process_bitmap()
418 x_low.num_bits = x_low.num_bits - i; in alps_process_bitmap()
420 x_high.num_bits = max(i, 1); in alps_process_bitmap()
423 i = (y_low.num_bits - 1) / 2; in alps_process_bitmap()
424 y_low.num_bits = y_low.num_bits - i; in alps_process_bitmap()
426 y_high.num_bits = max(i, 1); in alps_process_bitmap()
429 /* top-left corner */ in alps_process_bitmap()
431 (priv->x_max * (2 * x_low.start_bit + x_low.num_bits - 1)) / in alps_process_bitmap()
432 (2 * (priv->x_bits - 1)); in alps_process_bitmap()
434 (priv->y_max * (2 * y_low.start_bit + y_low.num_bits - 1)) / in alps_process_bitmap()
435 (2 * (priv->y_bits - 1)); in alps_process_bitmap()
437 /* top-right corner */ in alps_process_bitmap()
439 (priv->x_max * (2 * x_high.start_bit + x_high.num_bits - 1)) / in alps_process_bitmap()
440 (2 * (priv->x_bits - 1)); in alps_process_bitmap()
442 (priv->y_max * (2 * y_low.start_bit + y_low.num_bits - 1)) / in alps_process_bitmap()
443 (2 * (priv->y_bits - 1)); in alps_process_bitmap()
445 /* bottom-right corner */ in alps_process_bitmap()
447 (priv->x_max * (2 * x_high.start_bit + x_high.num_bits - 1)) / in alps_process_bitmap()
448 (2 * (priv->x_bits - 1)); in alps_process_bitmap()
450 (priv->y_max * (2 * y_high.start_bit + y_high.num_bits - 1)) / in alps_process_bitmap()
451 (2 * (priv->y_bits - 1)); in alps_process_bitmap()
453 /* bottom-left corner */ in alps_process_bitmap()
455 (priv->x_max * (2 * x_low.start_bit + x_low.num_bits - 1)) / in alps_process_bitmap()
456 (2 * (priv->x_bits - 1)); in alps_process_bitmap()
458 (priv->y_max * (2 * y_high.start_bit + y_high.num_bits - 1)) / in alps_process_bitmap()
459 (2 * (priv->y_bits - 1)); in alps_process_bitmap()
461 /* x-bitmap order is reversed on v5 touchpads */ in alps_process_bitmap()
462 if (priv->proto_version == ALPS_PROTO_V5) { in alps_process_bitmap()
464 corner[i].x = priv->x_max - corner[i].x; in alps_process_bitmap()
467 /* y-bitmap order is reversed on v3 and v4 touchpads */ in alps_process_bitmap()
468 if (priv->proto_version == ALPS_PROTO_V3 || in alps_process_bitmap()
469 priv->proto_version == ALPS_PROTO_V4) { in alps_process_bitmap()
471 corner[i].y = priv->y_max - corner[i].y; in alps_process_bitmap()
479 if (priv->second_touch == -1) { in alps_process_bitmap()
483 int dx = fields->st.x - corner[i].x; in alps_process_bitmap()
484 int dy = fields->st.y - corner[i].y; in alps_process_bitmap()
488 priv->second_touch = i; in alps_process_bitmap()
493 priv->second_touch = (priv->second_touch + 2) % 4; in alps_process_bitmap()
496 fields->mt[0] = fields->st; in alps_process_bitmap()
497 fields->mt[1] = corner[priv->second_touch]; in alps_process_bitmap()
499 return fingers; in alps_process_bitmap()
512 struct alps_data *priv = psmouse->private; in alps_report_mt_data()
513 struct input_dev *dev = psmouse->dev; in alps_report_mt_data()
514 struct alps_fields *f = &priv->f; in alps_report_mt_data()
517 input_mt_assign_slots(dev, slot, f->mt, n, 0); in alps_report_mt_data()
519 alps_set_slot(dev, slot[i], f->mt[i].x, f->mt[i].y); in alps_report_mt_data()
524 static void alps_report_semi_mt_data(struct psmouse *psmouse, int fingers) in alps_report_semi_mt_data() argument
526 struct alps_data *priv = psmouse->private; in alps_report_semi_mt_data()
527 struct input_dev *dev = psmouse->dev; in alps_report_semi_mt_data()
528 struct alps_fields *f = &priv->f; in alps_report_semi_mt_data()
531 if (fingers < 2) { in alps_report_semi_mt_data()
532 f->mt[0].x = f->st.x; in alps_report_semi_mt_data()
533 f->mt[0].y = f->st.y; in alps_report_semi_mt_data()
534 fingers = f->pressure > 0 ? 1 : 0; in alps_report_semi_mt_data()
535 priv->second_touch = -1; in alps_report_semi_mt_data()
538 if (fingers >= 1) in alps_report_semi_mt_data()
539 alps_set_slot(dev, 0, f->mt[0].x, f->mt[0].y); in alps_report_semi_mt_data()
540 if (fingers >= 2) in alps_report_semi_mt_data()
541 alps_set_slot(dev, 1, f->mt[1].x, f->mt[1].y); in alps_report_semi_mt_data()
544 input_mt_report_finger_count(dev, fingers); in alps_report_semi_mt_data()
546 input_report_key(dev, BTN_LEFT, f->left); in alps_report_semi_mt_data()
547 input_report_key(dev, BTN_RIGHT, f->right); in alps_report_semi_mt_data()
548 input_report_key(dev, BTN_MIDDLE, f->middle); in alps_report_semi_mt_data()
550 input_report_abs(dev, ABS_PRESSURE, f->pressure); in alps_report_semi_mt_data()
557 struct alps_data *priv = psmouse->private; in alps_process_trackstick_packet_v3()
558 unsigned char *packet = psmouse->packet; in alps_process_trackstick_packet_v3()
559 struct input_dev *dev = priv->dev2; in alps_process_trackstick_packet_v3()
563 if (!(priv->flags & ALPS_DUALPOINT)) { in alps_process_trackstick_packet_v3()
595 input_report_rel(dev, REL_Y, -y); in alps_process_trackstick_packet_v3()
609 if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) && in alps_process_trackstick_packet_v3()
611 priv->quirks |= ALPS_QUIRK_TRACKSTICK_BUTTONS; in alps_process_trackstick_packet_v3()
613 if (priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) { in alps_process_trackstick_packet_v3()
625 f->left = !!(p[3] & 0x01); in alps_decode_buttons_v3()
626 f->right = !!(p[3] & 0x02); in alps_decode_buttons_v3()
627 f->middle = !!(p[3] & 0x04); in alps_decode_buttons_v3()
629 f->ts_left = !!(p[3] & 0x10); in alps_decode_buttons_v3()
630 f->ts_right = !!(p[3] & 0x20); in alps_decode_buttons_v3()
631 f->ts_middle = !!(p[3] & 0x40); in alps_decode_buttons_v3()
637 f->first_mp = !!(p[4] & 0x40); in alps_decode_pinnacle()
638 f->is_mp = !!(p[0] & 0x40); in alps_decode_pinnacle()
640 if (f->is_mp) { in alps_decode_pinnacle()
641 f->fingers = (p[5] & 0x3) + 1; in alps_decode_pinnacle()
642 f->x_map = ((p[4] & 0x7e) << 8) | in alps_decode_pinnacle()
645 f->y_map = ((p[3] & 0x70) << 4) | in alps_decode_pinnacle()
649 f->st.x = ((p[1] & 0x7f) << 4) | ((p[4] & 0x30) >> 2) | in alps_decode_pinnacle()
651 f->st.y = ((p[2] & 0x7f) << 4) | (p[4] & 0x0f); in alps_decode_pinnacle()
652 f->pressure = p[5] & 0x7f; in alps_decode_pinnacle()
663 f->first_mp = !!(p[4] & 0x40); in alps_decode_rushmore()
664 f->is_mp = !!(p[5] & 0x40); in alps_decode_rushmore()
666 if (f->is_mp) { in alps_decode_rushmore()
667 f->fingers = max((p[5] & 0x3), ((p[5] >> 2) & 0x3)) + 1; in alps_decode_rushmore()
668 f->x_map = ((p[5] & 0x10) << 11) | in alps_decode_rushmore()
672 f->y_map = ((p[5] & 0x20) << 6) | in alps_decode_rushmore()
677 f->st.x = ((p[1] & 0x7f) << 4) | ((p[4] & 0x30) >> 2) | in alps_decode_rushmore()
679 f->st.y = ((p[2] & 0x7f) << 4) | (p[4] & 0x0f); in alps_decode_rushmore()
680 f->pressure = p[5] & 0x7f; in alps_decode_rushmore()
692 struct alps_data *priv = psmouse->private; in alps_decode_dolphin()
694 f->first_mp = !!(p[0] & 0x02); in alps_decode_dolphin()
695 f->is_mp = !!(p[0] & 0x20); in alps_decode_dolphin()
697 if (!f->is_mp) { in alps_decode_dolphin()
698 f->st.x = ((p[1] & 0x7f) | ((p[4] & 0x0f) << 7)); in alps_decode_dolphin()
699 f->st.y = ((p[2] & 0x7f) | ((p[4] & 0xf0) << 3)); in alps_decode_dolphin()
700 f->pressure = (p[0] & 4) ? 0 : p[5] & 0x7f; in alps_decode_dolphin()
703 f->fingers = ((p[0] & 0x6) >> 1 | in alps_decode_dolphin()
714 /* Y-profile is stored in P(0) to p(n-1), n = y_bits; */ in alps_decode_dolphin()
715 f->y_map = palm_data & (BIT(priv->y_bits) - 1); in alps_decode_dolphin()
717 /* X-profile is stored in p(n) to p(n+m-1), m = x_bits; */ in alps_decode_dolphin()
718 f->x_map = (palm_data >> priv->y_bits) & in alps_decode_dolphin()
719 (BIT(priv->x_bits) - 1); in alps_decode_dolphin()
727 struct alps_data *priv = psmouse->private; in alps_process_touchpad_packet_v3_v5()
728 unsigned char *packet = psmouse->packet; in alps_process_touchpad_packet_v3_v5()
729 struct input_dev *dev2 = priv->dev2; in alps_process_touchpad_packet_v3_v5()
730 struct alps_fields *f = &priv->f; in alps_process_touchpad_packet_v3_v5()
731 int fingers = 0; in alps_process_touchpad_packet_v3_v5() local
735 priv->decode_fields(f, packet, psmouse); in alps_process_touchpad_packet_v3_v5()
743 if (priv->multi_packet) { in alps_process_touchpad_packet_v3_v5()
745 * Sometimes a position packet will indicate a multi-packet in alps_process_touchpad_packet_v3_v5()
750 if (f->is_mp) { in alps_process_touchpad_packet_v3_v5()
751 fingers = f->fingers; in alps_process_touchpad_packet_v3_v5()
756 priv->decode_fields(f, priv->multi_data, psmouse); in alps_process_touchpad_packet_v3_v5()
758 fingers = 0; /* Use st data */ in alps_process_touchpad_packet_v3_v5()
760 priv->multi_packet = 0; in alps_process_touchpad_packet_v3_v5()
772 if (f->is_mp) in alps_process_touchpad_packet_v3_v5()
775 if (!priv->multi_packet && f->first_mp) { in alps_process_touchpad_packet_v3_v5()
776 priv->multi_packet = 1; in alps_process_touchpad_packet_v3_v5()
777 memcpy(priv->multi_data, packet, sizeof(priv->multi_data)); in alps_process_touchpad_packet_v3_v5()
781 priv->multi_packet = 0; in alps_process_touchpad_packet_v3_v5()
789 if (f->st.x && f->st.y && !f->pressure) in alps_process_touchpad_packet_v3_v5()
792 alps_report_semi_mt_data(psmouse, fingers); in alps_process_touchpad_packet_v3_v5()
794 if ((priv->flags & ALPS_DUALPOINT) && in alps_process_touchpad_packet_v3_v5()
795 !(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) { in alps_process_touchpad_packet_v3_v5()
796 input_report_key(dev2, BTN_LEFT, f->ts_left); in alps_process_touchpad_packet_v3_v5()
797 input_report_key(dev2, BTN_RIGHT, f->ts_right); in alps_process_touchpad_packet_v3_v5()
798 input_report_key(dev2, BTN_MIDDLE, f->ts_middle); in alps_process_touchpad_packet_v3_v5()
805 unsigned char *packet = psmouse->packet; in alps_process_packet_v3()
825 struct alps_data *priv = psmouse->private; in alps_process_packet_v6()
826 unsigned char *packet = psmouse->packet; in alps_process_packet_v6()
827 struct input_dev *dev = psmouse->dev; in alps_process_packet_v6()
828 struct input_dev *dev2 = priv->dev2; in alps_process_packet_v6()
834 * Touchpad: 0 - 0x7E in alps_process_packet_v6()
839 if (!(priv->flags & ALPS_DUALPOINT)) { in alps_process_packet_v6()
856 input_report_rel(dev2, REL_Y, -((s8)y / 4)); in alps_process_packet_v6()
891 struct alps_data *priv = psmouse->private; in alps_process_packet_v4()
892 unsigned char *packet = psmouse->packet; in alps_process_packet_v4()
893 struct alps_fields *f = &priv->f; in alps_process_packet_v4()
897 * v4 has a 6-byte encoding for bitmap data, but this data is in alps_process_packet_v4()
898 * broken up between 3 normal packets. Use priv->multi_packet to in alps_process_packet_v4()
903 priv->multi_packet = 0; in alps_process_packet_v4()
906 if (WARN_ON_ONCE(priv->multi_packet > 2)) in alps_process_packet_v4()
909 offset = 2 * priv->multi_packet; in alps_process_packet_v4()
910 priv->multi_data[offset] = packet[6]; in alps_process_packet_v4()
911 priv->multi_data[offset + 1] = packet[7]; in alps_process_packet_v4()
913 f->left = !!(packet[4] & 0x01); in alps_process_packet_v4()
914 f->right = !!(packet[4] & 0x02); in alps_process_packet_v4()
916 f->st.x = ((packet[1] & 0x7f) << 4) | ((packet[3] & 0x30) >> 2) | in alps_process_packet_v4()
918 f->st.y = ((packet[2] & 0x7f) << 4) | (packet[3] & 0x0f); in alps_process_packet_v4()
919 f->pressure = packet[5] & 0x7f; in alps_process_packet_v4()
921 if (++priv->multi_packet > 2) { in alps_process_packet_v4()
922 priv->multi_packet = 0; in alps_process_packet_v4()
924 f->x_map = ((priv->multi_data[2] & 0x1f) << 10) | in alps_process_packet_v4()
925 ((priv->multi_data[3] & 0x60) << 3) | in alps_process_packet_v4()
926 ((priv->multi_data[0] & 0x3f) << 2) | in alps_process_packet_v4()
927 ((priv->multi_data[1] & 0x60) >> 5); in alps_process_packet_v4()
928 f->y_map = ((priv->multi_data[5] & 0x01) << 10) | in alps_process_packet_v4()
929 ((priv->multi_data[3] & 0x1f) << 5) | in alps_process_packet_v4()
930 (priv->multi_data[1] & 0x1f); in alps_process_packet_v4()
932 f->fingers = alps_process_bitmap(priv, f); in alps_process_packet_v4()
935 alps_report_semi_mt_data(psmouse, f->fingers); in alps_process_packet_v4()
940 switch (psmouse->pktcnt) { in alps_is_valid_package_v7()
942 return (psmouse->packet[2] & 0x40) == 0x40; in alps_is_valid_package_v7()
944 return (psmouse->packet[3] & 0x48) == 0x48; in alps_is_valid_package_v7()
946 return (psmouse->packet[5] & 0x40) == 0x00; in alps_is_valid_package_v7()
989 /* Detect false-positive touches where x & y report max value */ in alps_get_finger_coordinate_v7()
1010 mt[0].y = 0x7FF - mt[0].y; in alps_get_finger_coordinate_v7()
1011 mt[1].y = 0x7FF - mt[1].y; in alps_get_finger_coordinate_v7()
1016 int i, fingers = 0; in alps_get_mt_count() local
1020 fingers++; in alps_get_mt_count()
1023 return fingers; in alps_get_mt_count()
1030 struct alps_data *priv = psmouse->private; in alps_decode_packet_v7()
1037 return -1; in alps_decode_packet_v7()
1048 * typically send when the number of fingers changes. We cannot use in alps_decode_packet_v7()
1059 alps_get_finger_coordinate_v7(f->mt, p, pkt_id); in alps_decode_packet_v7()
1062 f->fingers = alps_get_mt_count(f->mt); in alps_decode_packet_v7()
1064 f->fingers = 3 + (p[5] & 0x03); in alps_decode_packet_v7()
1066 f->left = (p[0] & 0x80) >> 7; in alps_decode_packet_v7()
1067 if (priv->flags & ALPS_BUTTONPAD) { in alps_decode_packet_v7()
1069 f->fingers++; in alps_decode_packet_v7()
1071 f->fingers++; in alps_decode_packet_v7()
1073 f->right = (p[0] & 0x20) >> 5; in alps_decode_packet_v7()
1074 f->middle = (p[0] & 0x10) >> 4; in alps_decode_packet_v7()
1078 if (f->fingers == 1 && f->mt[0].x == 0 && f->mt[0].y == 0) { in alps_decode_packet_v7()
1079 f->mt[0].x = f->mt[1].x; in alps_decode_packet_v7()
1080 f->mt[0].y = f->mt[1].y; in alps_decode_packet_v7()
1081 f->mt[1].x = 0; in alps_decode_packet_v7()
1082 f->mt[1].y = 0; in alps_decode_packet_v7()
1090 struct alps_data *priv = psmouse->private; in alps_process_trackstick_packet_v7()
1091 unsigned char *packet = psmouse->packet; in alps_process_trackstick_packet_v7()
1092 struct input_dev *dev2 = priv->dev2; in alps_process_trackstick_packet_v7()
1096 if (!(priv->flags & ALPS_DUALPOINT)) { in alps_process_trackstick_packet_v7()
1108 input_report_rel(dev2, REL_Y, -((s8)y)); in alps_process_trackstick_packet_v7()
1118 struct alps_data *priv = psmouse->private; in alps_process_touchpad_packet_v7()
1119 struct input_dev *dev = psmouse->dev; in alps_process_touchpad_packet_v7()
1120 struct alps_fields *f = &priv->f; in alps_process_touchpad_packet_v7()
1124 if (priv->decode_fields(f, psmouse->packet, psmouse)) in alps_process_touchpad_packet_v7()
1127 alps_report_mt_data(psmouse, alps_get_mt_count(f->mt)); in alps_process_touchpad_packet_v7()
1129 input_mt_report_finger_count(dev, f->fingers); in alps_process_touchpad_packet_v7()
1131 input_report_key(dev, BTN_LEFT, f->left); in alps_process_touchpad_packet_v7()
1132 input_report_key(dev, BTN_RIGHT, f->right); in alps_process_touchpad_packet_v7()
1133 input_report_key(dev, BTN_MIDDLE, f->middle); in alps_process_touchpad_packet_v7()
1140 unsigned char *packet = psmouse->packet; in alps_process_packet_v7()
1161 /* two-finger finger positions */ in alps_get_pkt_id_ss4_v2()
1180 struct alps_data *priv = psmouse->private; in alps_decode_ss4_v2()
1189 f->mt[0].x = SS4_1F_X_V2(p); in alps_decode_ss4_v2()
1190 f->mt[0].y = SS4_1F_Y_V2(p); in alps_decode_ss4_v2()
1191 f->pressure = ((SS4_1F_Z_V2(p)) * 2) & 0x7f; in alps_decode_ss4_v2()
1198 f->fingers = f->pressure > 0 ? 1 : 0; in alps_decode_ss4_v2()
1199 f->first_mp = 0; in alps_decode_ss4_v2()
1200 f->is_mp = 0; in alps_decode_ss4_v2()
1204 if (priv->flags & ALPS_BUTTONPAD) { in alps_decode_ss4_v2()
1205 if (IS_SS4PLUS_DEV(priv->dev_id)) { in alps_decode_ss4_v2()
1206 f->mt[0].x = SS4_PLUS_BTL_MF_X_V2(p, 0); in alps_decode_ss4_v2()
1207 f->mt[1].x = SS4_PLUS_BTL_MF_X_V2(p, 1); in alps_decode_ss4_v2()
1209 f->mt[0].x = SS4_BTL_MF_X_V2(p, 0); in alps_decode_ss4_v2()
1210 f->mt[1].x = SS4_BTL_MF_X_V2(p, 1); in alps_decode_ss4_v2()
1212 f->mt[0].y = SS4_BTL_MF_Y_V2(p, 0); in alps_decode_ss4_v2()
1213 f->mt[1].y = SS4_BTL_MF_Y_V2(p, 1); in alps_decode_ss4_v2()
1215 if (IS_SS4PLUS_DEV(priv->dev_id)) { in alps_decode_ss4_v2()
1216 f->mt[0].x = SS4_PLUS_STD_MF_X_V2(p, 0); in alps_decode_ss4_v2()
1217 f->mt[1].x = SS4_PLUS_STD_MF_X_V2(p, 1); in alps_decode_ss4_v2()
1219 f->mt[0].x = SS4_STD_MF_X_V2(p, 0); in alps_decode_ss4_v2()
1220 f->mt[1].x = SS4_STD_MF_X_V2(p, 1); in alps_decode_ss4_v2()
1222 f->mt[0].y = SS4_STD_MF_Y_V2(p, 0); in alps_decode_ss4_v2()
1223 f->mt[1].y = SS4_STD_MF_Y_V2(p, 1); in alps_decode_ss4_v2()
1225 f->pressure = SS4_MF_Z_V2(p, 0) ? 0x30 : 0; in alps_decode_ss4_v2()
1228 f->first_mp = 1; in alps_decode_ss4_v2()
1230 f->fingers = 2; in alps_decode_ss4_v2()
1231 f->first_mp = 0; in alps_decode_ss4_v2()
1233 f->is_mp = 0; in alps_decode_ss4_v2()
1238 if (priv->flags & ALPS_BUTTONPAD) { in alps_decode_ss4_v2()
1239 if (IS_SS4PLUS_DEV(priv->dev_id)) { in alps_decode_ss4_v2()
1240 f->mt[2].x = SS4_PLUS_BTL_MF_X_V2(p, 0); in alps_decode_ss4_v2()
1241 f->mt[3].x = SS4_PLUS_BTL_MF_X_V2(p, 1); in alps_decode_ss4_v2()
1244 f->mt[2].x = SS4_BTL_MF_X_V2(p, 0); in alps_decode_ss4_v2()
1245 f->mt[3].x = SS4_BTL_MF_X_V2(p, 1); in alps_decode_ss4_v2()
1250 f->mt[2].y = SS4_BTL_MF_Y_V2(p, 0); in alps_decode_ss4_v2()
1251 f->mt[3].y = SS4_BTL_MF_Y_V2(p, 1); in alps_decode_ss4_v2()
1253 if (IS_SS4PLUS_DEV(priv->dev_id)) { in alps_decode_ss4_v2()
1254 f->mt[2].x = SS4_PLUS_STD_MF_X_V2(p, 0); in alps_decode_ss4_v2()
1255 f->mt[3].x = SS4_PLUS_STD_MF_X_V2(p, 1); in alps_decode_ss4_v2()
1258 f->mt[2].x = SS4_STD_MF_X_V2(p, 0); in alps_decode_ss4_v2()
1259 f->mt[3].x = SS4_STD_MF_X_V2(p, 1); in alps_decode_ss4_v2()
1264 f->mt[2].y = SS4_STD_MF_Y_V2(p, 0); in alps_decode_ss4_v2()
1265 f->mt[3].y = SS4_STD_MF_Y_V2(p, 1); in alps_decode_ss4_v2()
1268 f->first_mp = 0; in alps_decode_ss4_v2()
1269 f->is_mp = 1; in alps_decode_ss4_v2()
1272 f->fingers = 5; in alps_decode_ss4_v2()
1273 } else if (f->mt[3].x == no_data_x && in alps_decode_ss4_v2()
1274 f->mt[3].y == no_data_y) { in alps_decode_ss4_v2()
1275 f->mt[3].x = 0; in alps_decode_ss4_v2()
1276 f->mt[3].y = 0; in alps_decode_ss4_v2()
1277 f->fingers = 3; in alps_decode_ss4_v2()
1279 f->fingers = 4; in alps_decode_ss4_v2()
1288 f->first_mp = 0; in alps_decode_ss4_v2()
1289 f->is_mp = 0; in alps_decode_ss4_v2()
1300 f->ts_left = !!(SS4_BTN_V2(p) & 0x01); in alps_decode_ss4_v2()
1301 f->ts_right = !!(SS4_BTN_V2(p) & 0x02); in alps_decode_ss4_v2()
1302 f->ts_middle = !!(SS4_BTN_V2(p) & 0x04); in alps_decode_ss4_v2()
1304 f->left = !!(SS4_BTN_V2(p) & 0x01); in alps_decode_ss4_v2()
1305 if (!(priv->flags & ALPS_BUTTONPAD)) { in alps_decode_ss4_v2()
1306 f->right = !!(SS4_BTN_V2(p) & 0x02); in alps_decode_ss4_v2()
1307 f->middle = !!(SS4_BTN_V2(p) & 0x04); in alps_decode_ss4_v2()
1316 struct alps_data *priv = psmouse->private; in alps_process_packet_ss4_v2()
1317 unsigned char *packet = psmouse->packet; in alps_process_packet_ss4_v2()
1318 struct input_dev *dev = psmouse->dev; in alps_process_packet_ss4_v2()
1319 struct input_dev *dev2 = priv->dev2; in alps_process_packet_ss4_v2()
1320 struct alps_fields *f = &priv->f; in alps_process_packet_ss4_v2()
1323 priv->decode_fields(f, packet, psmouse); in alps_process_packet_ss4_v2()
1324 if (priv->multi_packet) { in alps_process_packet_ss4_v2()
1326 * Sometimes the first packet will indicate a multi-packet in alps_process_packet_ss4_v2()
1327 * sequence, but sometimes the next multi-packet would not in alps_process_packet_ss4_v2()
1331 if (f->is_mp) { in alps_process_packet_ss4_v2()
1333 priv->decode_fields(f, priv->multi_data, psmouse); in alps_process_packet_ss4_v2()
1335 priv->multi_packet = 0; in alps_process_packet_ss4_v2()
1343 if (f->is_mp) in alps_process_packet_ss4_v2()
1347 if (!priv->multi_packet && f->first_mp) { in alps_process_packet_ss4_v2()
1348 priv->multi_packet = 1; in alps_process_packet_ss4_v2()
1349 memcpy(priv->multi_data, packet, sizeof(priv->multi_data)); in alps_process_packet_ss4_v2()
1353 priv->multi_packet = 0; in alps_process_packet_ss4_v2()
1357 if (!(priv->flags & ALPS_DUALPOINT)) { in alps_process_packet_ss4_v2()
1367 input_report_key(dev2, BTN_LEFT, f->ts_left); in alps_process_packet_ss4_v2()
1368 input_report_key(dev2, BTN_RIGHT, f->ts_right); in alps_process_packet_ss4_v2()
1369 input_report_key(dev2, BTN_MIDDLE, f->ts_middle); in alps_process_packet_ss4_v2()
1376 alps_report_mt_data(psmouse, (f->fingers <= 4) ? f->fingers : 4); in alps_process_packet_ss4_v2()
1378 input_mt_report_finger_count(dev, f->fingers); in alps_process_packet_ss4_v2()
1380 input_report_key(dev, BTN_LEFT, f->left); in alps_process_packet_ss4_v2()
1381 input_report_key(dev, BTN_RIGHT, f->right); in alps_process_packet_ss4_v2()
1382 input_report_key(dev, BTN_MIDDLE, f->middle); in alps_process_packet_ss4_v2()
1384 input_report_abs(dev, ABS_PRESSURE, f->pressure); in alps_process_packet_ss4_v2()
1390 if (psmouse->pktcnt == 4 && ((psmouse->packet[3] & 0x08) != 0x08)) in alps_is_valid_package_ss4_v2()
1392 if (psmouse->pktcnt == 6 && ((psmouse->packet[5] & 0x10) != 0x0)) in alps_is_valid_package_ss4_v2()
1401 struct psmouse *psmouse = priv->psmouse; in alps_do_register_bare_ps2_mouse()
1408 return -ENOMEM; in alps_do_register_bare_ps2_mouse()
1411 snprintf(priv->phys3, sizeof(priv->phys3), "%s/%s", in alps_do_register_bare_ps2_mouse()
1412 psmouse->ps2dev.serio->phys, in alps_do_register_bare_ps2_mouse()
1413 (priv->dev2 ? "input2" : "input1")); in alps_do_register_bare_ps2_mouse()
1414 dev3->phys = priv->phys3; in alps_do_register_bare_ps2_mouse()
1418 * see function psmouse_switch_protocol() in psmouse-base.c in alps_do_register_bare_ps2_mouse()
1420 dev3->name = "PS/2 ALPS Mouse"; in alps_do_register_bare_ps2_mouse()
1422 dev3->id.bustype = BUS_I8042; in alps_do_register_bare_ps2_mouse()
1423 dev3->id.vendor = 0x0002; in alps_do_register_bare_ps2_mouse()
1424 dev3->id.product = PSMOUSE_PS2; in alps_do_register_bare_ps2_mouse()
1425 dev3->id.version = 0x0000; in alps_do_register_bare_ps2_mouse()
1426 dev3->dev.parent = &psmouse->ps2dev.serio->dev; in alps_do_register_bare_ps2_mouse()
1434 __set_bit(INPUT_PROP_POINTER, dev3->propbit); in alps_do_register_bare_ps2_mouse()
1444 priv->dev3 = dev3; in alps_do_register_bare_ps2_mouse()
1460 if (!priv->dev3) { in alps_register_bare_ps2_mouse()
1467 priv->dev3 = ERR_PTR(error); in alps_register_bare_ps2_mouse()
1476 struct alps_data *priv = psmouse->private; in alps_report_bare_ps2_packet()
1480 if (priv->proto_version == ALPS_PROTO_V2 && in alps_report_bare_ps2_packet()
1481 (priv->flags & ALPS_DUALPOINT)) { in alps_report_bare_ps2_packet()
1483 dev = priv->dev2; in alps_report_bare_ps2_packet()
1484 dev2 = psmouse->dev; in alps_report_bare_ps2_packet()
1485 } else if (unlikely(IS_ERR_OR_NULL(priv->dev3))) { in alps_report_bare_ps2_packet()
1487 if (!IS_ERR(priv->dev3)) in alps_report_bare_ps2_packet()
1488 psmouse_queue_work(psmouse, &priv->dev3_register_work, in alps_report_bare_ps2_packet()
1492 dev = priv->dev3; in alps_report_bare_ps2_packet()
1506 struct alps_data *priv = psmouse->private; in alps_handle_interleaved_ps2()
1508 if (psmouse->pktcnt < 6) in alps_handle_interleaved_ps2()
1511 if (psmouse->pktcnt == 6) { in alps_handle_interleaved_ps2()
1514 * 6-byte packet in the stream. Timer needs to fire in alps_handle_interleaved_ps2()
1518 mod_timer(&priv->timer, jiffies + msecs_to_jiffies(20)); in alps_handle_interleaved_ps2()
1522 del_timer(&priv->timer); in alps_handle_interleaved_ps2()
1524 if (psmouse->packet[6] & 0x80) { in alps_handle_interleaved_ps2()
1527 * Highest bit is set - that means we either had in alps_handle_interleaved_ps2()
1532 if (((psmouse->packet[3] | in alps_handle_interleaved_ps2()
1533 psmouse->packet[4] | in alps_handle_interleaved_ps2()
1534 psmouse->packet[5]) & 0x80) || in alps_handle_interleaved_ps2()
1535 (!alps_is_valid_first_byte(priv, psmouse->packet[6]))) { in alps_handle_interleaved_ps2()
1538 psmouse->packet + 3); in alps_handle_interleaved_ps2()
1542 priv->process_packet(psmouse); in alps_handle_interleaved_ps2()
1545 psmouse->packet[0] = psmouse->packet[6]; in alps_handle_interleaved_ps2()
1546 psmouse->pktcnt = 1; in alps_handle_interleaved_ps2()
1551 * High bit is 0 - that means that we indeed got a PS/2 in alps_handle_interleaved_ps2()
1554 * There is also possibility that we got 6-byte ALPS in alps_handle_interleaved_ps2()
1555 * packet followed by 3-byte packet from trackpoint. We in alps_handle_interleaved_ps2()
1563 * de-synchronization. in alps_handle_interleaved_ps2()
1566 alps_report_bare_ps2_packet(psmouse, &psmouse->packet[3], in alps_handle_interleaved_ps2()
1576 psmouse->packet[3] = psmouse->packet[6] & 0xf7; in alps_handle_interleaved_ps2()
1577 psmouse->pktcnt = 4; in alps_handle_interleaved_ps2()
1586 struct psmouse *psmouse = priv->psmouse; in alps_flush_packet()
1588 serio_pause_rx(psmouse->ps2dev.serio); in alps_flush_packet()
1590 if (psmouse->pktcnt == psmouse->pktsize) { in alps_flush_packet()
1597 if ((psmouse->packet[3] | in alps_flush_packet()
1598 psmouse->packet[4] | in alps_flush_packet()
1599 psmouse->packet[5]) & 0x80) { in alps_flush_packet()
1602 psmouse->packet + 3); in alps_flush_packet()
1604 priv->process_packet(psmouse); in alps_flush_packet()
1606 psmouse->pktcnt = 0; in alps_flush_packet()
1609 serio_continue_rx(psmouse->ps2dev.serio); in alps_flush_packet()
1614 struct alps_data *priv = psmouse->private; in alps_process_byte()
1619 * protocol does not have enough constant bits to self-synchronize in alps_process_byte()
1623 if (priv->proto_version != ALPS_PROTO_V8 && in alps_process_byte()
1624 !psmouse->out_of_sync_cnt && in alps_process_byte()
1625 (psmouse->packet[0] & 0xc8) == 0x08) { in alps_process_byte()
1627 if (psmouse->pktcnt == 3) { in alps_process_byte()
1628 alps_report_bare_ps2_packet(psmouse, psmouse->packet, in alps_process_byte()
1637 if ((priv->flags & ALPS_PS2_INTERLEAVED) && in alps_process_byte()
1638 psmouse->pktcnt >= 4 && (psmouse->packet[3] & 0x0f) == 0x0f) { in alps_process_byte()
1642 if (!alps_is_valid_first_byte(priv, psmouse->packet[0])) { in alps_process_byte()
1645 psmouse->packet[0], priv->mask0, priv->byte0); in alps_process_byte()
1649 /* Bytes 2 - pktsize should have 0 in the highest bit */ in alps_process_byte()
1650 if (priv->proto_version < ALPS_PROTO_V5 && in alps_process_byte()
1651 psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize && in alps_process_byte()
1652 (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) { in alps_process_byte()
1654 psmouse->pktcnt - 1, in alps_process_byte()
1655 psmouse->packet[psmouse->pktcnt - 1]); in alps_process_byte()
1657 if (priv->proto_version == ALPS_PROTO_V3_RUSHMORE && in alps_process_byte()
1658 psmouse->pktcnt == psmouse->pktsize) { in alps_process_byte()
1674 if ((priv->proto_version == ALPS_PROTO_V7 && in alps_process_byte()
1676 (priv->proto_version == ALPS_PROTO_V8 && in alps_process_byte()
1679 psmouse->pktcnt - 1, in alps_process_byte()
1680 psmouse->packet[psmouse->pktcnt - 1]); in alps_process_byte()
1684 if (psmouse->pktcnt == psmouse->pktsize) { in alps_process_byte()
1685 priv->process_packet(psmouse); in alps_process_byte()
1694 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_command_mode_send_nibble()
1695 struct alps_data *priv = psmouse->private; in alps_command_mode_send_nibble()
1702 command = priv->nibble_commands[nibble].command; in alps_command_mode_send_nibble()
1704 dummy : (unsigned char *)&priv->nibble_commands[nibble].data; in alps_command_mode_send_nibble()
1707 return -1; in alps_command_mode_send_nibble()
1714 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_command_mode_set_addr()
1715 struct alps_data *priv = psmouse->private; in alps_command_mode_set_addr()
1718 if (ps2_command(ps2dev, NULL, priv->addr_command)) in alps_command_mode_set_addr()
1719 return -1; in alps_command_mode_set_addr()
1721 for (i = 12; i >= 0; i -= 4) { in alps_command_mode_set_addr()
1724 return -1; in alps_command_mode_set_addr()
1732 struct ps2dev *ps2dev = &psmouse->ps2dev; in __alps_command_mode_read_reg()
1736 return -1; in __alps_command_mode_read_reg()
1744 return -1; in __alps_command_mode_read_reg()
1752 return -1; in alps_command_mode_read_reg()
1759 return -1; in __alps_command_mode_write_reg()
1761 return -1; in __alps_command_mode_write_reg()
1769 return -1; in alps_command_mode_write_reg()
1776 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_rpt_cmd()
1780 return -EIO; in alps_rpt_cmd()
1785 return -EIO; in alps_rpt_cmd()
1789 return -EIO; in alps_rpt_cmd()
1818 return -1; in alps_enter_command_mode()
1824 return -1; in alps_enter_command_mode()
1831 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_exit_command_mode()
1833 return -1; in alps_exit_command_mode()
1844 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_passthrough_mode_v2()
1851 return -1; in alps_passthrough_mode_v2()
1861 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_absolute_mode_v1_v2()
1863 /* Try ALPS magic knock - 4 disable before enable */ in alps_absolute_mode_v1_v2()
1869 return -1; in alps_absolute_mode_v1_v2()
1883 * b0-b11 are valid bits, send sequence is inverse. in alps_monitor_mode_send_word()
1889 return -1; in alps_monitor_mode_send_word()
1898 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_monitor_mode_write_reg()
1906 return -1; in alps_monitor_mode_write_reg()
1913 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_monitor_mode()
1925 return -1; in alps_monitor_mode()
1929 return -1; in alps_monitor_mode()
1942 return -1; in alps_absolute_mode_v6()
1947 ret = -1; in alps_absolute_mode_v6()
1956 return -1; in alps_get_status()
1972 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_tap_mode()
1981 return -1; in alps_tap_mode()
1984 return -1; in alps_tap_mode()
1990 * alps_poll() - poll the touchpad for current motion packet.
1995 struct alps_data *priv = psmouse->private; in alps_poll()
1996 unsigned char buf[sizeof(psmouse->packet)]; in alps_poll()
1999 if (priv->flags & ALPS_PASS) in alps_poll()
2002 poll_failed = ps2_command(&psmouse->ps2dev, buf, in alps_poll()
2003 PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)) < 0; in alps_poll()
2005 if (priv->flags & ALPS_PASS) in alps_poll()
2008 if (poll_failed || (buf[0] & priv->mask0) != priv->byte0) in alps_poll()
2009 return -1; in alps_poll()
2011 if ((psmouse->badbyte & 0xc8) == 0x08) { in alps_poll()
2015 if (ps2_command(&psmouse->ps2dev, buf, PSMOUSE_CMD_POLL | (3 << 8))) in alps_poll()
2016 return -1; in alps_poll()
2019 memcpy(psmouse->packet, buf, sizeof(buf)); in alps_poll()
2025 struct alps_data *priv = psmouse->private; in alps_hw_init_v1_v2()
2027 if ((priv->flags & ALPS_PASS) && in alps_hw_init_v1_v2()
2029 return -1; in alps_hw_init_v1_v2()
2034 return -1; in alps_hw_init_v1_v2()
2039 return -1; in alps_hw_init_v1_v2()
2042 if ((priv->flags & ALPS_PASS) && in alps_hw_init_v1_v2()
2044 return -1; in alps_hw_init_v1_v2()
2048 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSTREAM)) { in alps_hw_init_v1_v2()
2050 return -1; in alps_hw_init_v1_v2()
2061 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || in alps_trackstick_enter_extended_mode_v3_v6()
2062 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || in alps_trackstick_enter_extended_mode_v3_v6()
2063 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || in alps_trackstick_enter_extended_mode_v3_v6()
2064 ps2_command(&psmouse->ps2dev, ¶m[0], PSMOUSE_CMD_SETRATE) || in alps_trackstick_enter_extended_mode_v3_v6()
2065 ps2_command(&psmouse->ps2dev, ¶m[1], PSMOUSE_CMD_SETRATE)) in alps_trackstick_enter_extended_mode_v3_v6()
2066 return -1; in alps_trackstick_enter_extended_mode_v3_v6()
2077 return -1; in alps_hw_init_v6()
2082 return -1; in alps_hw_init_v6()
2089 return -1; in alps_hw_init_v6()
2101 int reg_val, ret = -1; in alps_passthrough_mode_v3()
2104 return -1; in alps_passthrough_mode_v3()
2107 if (reg_val == -1) in alps_passthrough_mode_v3()
2119 ret = -1; in alps_passthrough_mode_v3()
2129 if (reg_val == -1) in alps_absolute_mode_v3()
2130 return -1; in alps_absolute_mode_v3()
2134 return -1; in alps_absolute_mode_v3()
2141 int ret = -EIO, reg_val; in alps_probe_trackstick_v3_v7()
2147 if (reg_val == -1) in alps_probe_trackstick_v3_v7()
2151 ret = reg_val & 0x80 ? 0 : -ENODEV; in alps_probe_trackstick_v3_v7()
2173 return -EIO; in alps_setup_trackstick_v3()
2186 ret = -ENODEV; in alps_setup_trackstick_v3()
2191 ret = -EIO; in alps_setup_trackstick_v3()
2196 return -EIO; in alps_setup_trackstick_v3()
2202 return -EIO; in alps_setup_trackstick_v3()
2205 if (reg_val == -1) { in alps_setup_trackstick_v3()
2206 ret = -EIO; in alps_setup_trackstick_v3()
2214 ret = -EIO; in alps_setup_trackstick_v3()
2218 return -EIO; in alps_setup_trackstick_v3()
2225 struct alps_data *priv = psmouse->private; in alps_hw_init_v3()
2226 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_hw_init_v3()
2230 if ((priv->flags & ALPS_DUALPOINT) && in alps_hw_init_v3()
2231 alps_setup_trackstick_v3(psmouse, ALPS_REG_BASE_PINNACLE) == -EIO) in alps_hw_init_v3()
2241 if (reg_val == -1) in alps_hw_init_v3()
2247 if (reg_val == -1) in alps_hw_init_v3()
2252 if (alps_command_mode_read_reg(psmouse, 0x0144) == -1) in alps_hw_init_v3()
2257 if (alps_command_mode_read_reg(psmouse, 0x0159) == -1) in alps_hw_init_v3()
2262 if (alps_command_mode_read_reg(psmouse, 0x0163) == -1) in alps_hw_init_v3()
2267 if (alps_command_mode_read_reg(psmouse, 0x0162) == -1) in alps_hw_init_v3()
2279 return -1; in alps_hw_init_v3()
2291 return -1; in alps_hw_init_v3()
2297 struct alps_data *priv = psmouse->private; in alps_get_v3_v7_resolution()
2319 x_phys = x_pitch * (x_electrode - 1); /* In 0.1 mm units */ in alps_get_v3_v7_resolution()
2320 y_phys = y_pitch * (y_electrode - 1); /* In 0.1 mm units */ in alps_get_v3_v7_resolution()
2322 priv->x_res = priv->x_max * 10 / x_phys; /* units / mm */ in alps_get_v3_v7_resolution()
2323 priv->y_res = priv->y_max * 10 / y_phys; /* units / mm */ in alps_get_v3_v7_resolution()
2326 "pitch %dx%d num-electrodes %dx%d physical size %dx%d mm res %dx%d\n", in alps_get_v3_v7_resolution()
2328 x_phys / 10, y_phys / 10, priv->x_res, priv->y_res); in alps_get_v3_v7_resolution()
2335 struct alps_data *priv = psmouse->private; in alps_hw_init_rushmore_v3()
2336 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_hw_init_rushmore_v3()
2337 int reg_val, ret = -1; in alps_hw_init_rushmore_v3()
2339 if (priv->flags & ALPS_DUALPOINT) { in alps_hw_init_rushmore_v3()
2342 if (reg_val == -EIO) in alps_hw_init_rushmore_v3()
2347 alps_command_mode_read_reg(psmouse, 0xc2d9) == -1 || in alps_hw_init_rushmore_v3()
2355 if (reg_val == -1) in alps_hw_init_rushmore_v3()
2365 if (reg_val == -1) in alps_hw_init_rushmore_v3()
2384 if (reg_val == -1) in alps_absolute_mode_v4()
2385 return -1; in alps_absolute_mode_v4()
2389 return -1; in alps_absolute_mode_v4()
2396 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_hw_init_v4()
2434 * This sequence changes the output from a 9-byte to an in alps_hw_init_v4()
2435 * 8-byte format. All the same data seems to be present, in alps_hw_init_v4()
2445 return -1; in alps_hw_init_v4()
2452 return -1; in alps_hw_init_v4()
2464 return -1; in alps_hw_init_v4()
2470 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_get_otp_values_ss4_v2()
2477 return -1; in alps_get_otp_values_ss4_v2()
2485 return -1; in alps_get_otp_values_ss4_v2()
2500 if (IS_SS4PLUS_DEV(priv->dev_id)) { in alps_update_device_area_ss4_v2()
2506 priv->x_max = in alps_update_device_area_ss4_v2()
2507 (num_x_electrode - 1) * SS4PLUS_COUNT_PER_ELECTRODE; in alps_update_device_area_ss4_v2()
2508 priv->y_max = in alps_update_device_area_ss4_v2()
2509 (num_y_electrode - 1) * SS4PLUS_COUNT_PER_ELECTRODE; in alps_update_device_area_ss4_v2()
2520 priv->x_max = in alps_update_device_area_ss4_v2()
2521 (num_x_electrode - 1) * SS4_COUNT_PER_ELECTRODE; in alps_update_device_area_ss4_v2()
2522 priv->y_max = in alps_update_device_area_ss4_v2()
2523 (num_y_electrode - 1) * SS4_COUNT_PER_ELECTRODE; in alps_update_device_area_ss4_v2()
2529 x_phys = x_pitch * (num_x_electrode - 1); /* In 0.1 mm units */ in alps_update_device_area_ss4_v2()
2530 y_phys = y_pitch * (num_y_electrode - 1); /* In 0.1 mm units */ in alps_update_device_area_ss4_v2()
2532 priv->x_res = priv->x_max * 10 / x_phys; /* units / mm */ in alps_update_device_area_ss4_v2()
2533 priv->y_res = priv->y_max * 10 / y_phys; /* units / mm */ in alps_update_device_area_ss4_v2()
2543 if (IS_SS4PLUS_DEV(priv->dev_id)) in alps_update_btn_info_ss4_v2()
2549 priv->flags |= ALPS_BUTTONPAD; in alps_update_btn_info_ss4_v2()
2560 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_update_dual_info_ss4_v2()
2562 if (IS_SS4PLUS_DEV(priv->dev_id)) { in alps_update_dual_info_ss4_v2()
2581 priv->flags |= ALPS_DUALPOINT | in alps_update_dual_info_ss4_v2()
2596 return -1; in alps_set_defaults_ss4_v2()
2610 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_dolphin_get_device_area()
2615 return -1; in alps_dolphin_get_device_area()
2623 return -1; in alps_dolphin_get_device_area()
2626 return -1; in alps_dolphin_get_device_area()
2637 * So, x_max = (19 - 1) * 64 = 1152, and in alps_dolphin_get_device_area()
2638 * y_max = (9 - 1) * 64 = 512. in alps_dolphin_get_device_area()
2642 priv->x_bits = num_x_electrode; in alps_dolphin_get_device_area()
2643 priv->y_bits = num_y_electrode; in alps_dolphin_get_device_area()
2644 priv->x_max = (num_x_electrode - 1) * DOLPHIN_COUNT_PER_ELECTRODE; in alps_dolphin_get_device_area()
2645 priv->y_max = (num_y_electrode - 1) * DOLPHIN_COUNT_PER_ELECTRODE; in alps_dolphin_get_device_area()
2648 return -1; in alps_dolphin_get_device_area()
2655 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_hw_init_dolphin_v1()
2665 return -1; in alps_hw_init_dolphin_v1()
2672 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_hw_init_v7()
2673 int reg_val, ret = -1; in alps_hw_init_v7()
2676 alps_command_mode_read_reg(psmouse, 0xc2d9) == -1) in alps_hw_init_v7()
2686 if (reg_val == -1) in alps_hw_init_v7()
2701 struct ps2dev *ps2dev = &psmouse->ps2dev; in alps_hw_init_ss4_v2()
2703 int ret = -1; in alps_hw_init_ss4_v2()
2732 psmouse->private = priv; in alps_set_protocol()
2734 timer_setup(&priv->timer, alps_flush_packet, 0); in alps_set_protocol()
2736 priv->proto_version = protocol->version; in alps_set_protocol()
2737 priv->byte0 = protocol->byte0; in alps_set_protocol()
2738 priv->mask0 = protocol->mask0; in alps_set_protocol()
2739 priv->flags = protocol->flags; in alps_set_protocol()
2741 priv->x_max = 2000; in alps_set_protocol()
2742 priv->y_max = 1400; in alps_set_protocol()
2743 priv->x_bits = 15; in alps_set_protocol()
2744 priv->y_bits = 11; in alps_set_protocol()
2746 switch (priv->proto_version) { in alps_set_protocol()
2749 priv->hw_init = alps_hw_init_v1_v2; in alps_set_protocol()
2750 priv->process_packet = alps_process_packet_v1_v2; in alps_set_protocol()
2751 priv->set_abs_params = alps_set_abs_params_st; in alps_set_protocol()
2752 priv->x_max = 1023; in alps_set_protocol()
2753 priv->y_max = 767; in alps_set_protocol()
2755 priv->flags |= ALPS_STICK_BITS; in alps_set_protocol()
2759 priv->hw_init = alps_hw_init_v3; in alps_set_protocol()
2760 priv->process_packet = alps_process_packet_v3; in alps_set_protocol()
2761 priv->set_abs_params = alps_set_abs_params_semi_mt; in alps_set_protocol()
2762 priv->decode_fields = alps_decode_pinnacle; in alps_set_protocol()
2763 priv->nibble_commands = alps_v3_nibble_commands; in alps_set_protocol()
2764 priv->addr_command = PSMOUSE_CMD_RESET_WRAP; in alps_set_protocol()
2768 priv->flags &= ~ALPS_DUALPOINT; in alps_set_protocol()
2773 priv->hw_init = alps_hw_init_rushmore_v3; in alps_set_protocol()
2774 priv->process_packet = alps_process_packet_v3; in alps_set_protocol()
2775 priv->set_abs_params = alps_set_abs_params_semi_mt; in alps_set_protocol()
2776 priv->decode_fields = alps_decode_rushmore; in alps_set_protocol()
2777 priv->nibble_commands = alps_v3_nibble_commands; in alps_set_protocol()
2778 priv->addr_command = PSMOUSE_CMD_RESET_WRAP; in alps_set_protocol()
2779 priv->x_bits = 16; in alps_set_protocol()
2780 priv->y_bits = 12; in alps_set_protocol()
2784 priv->flags &= ~ALPS_DUALPOINT; in alps_set_protocol()
2789 priv->hw_init = alps_hw_init_v4; in alps_set_protocol()
2790 priv->process_packet = alps_process_packet_v4; in alps_set_protocol()
2791 priv->set_abs_params = alps_set_abs_params_semi_mt; in alps_set_protocol()
2792 priv->nibble_commands = alps_v4_nibble_commands; in alps_set_protocol()
2793 priv->addr_command = PSMOUSE_CMD_DISABLE; in alps_set_protocol()
2797 priv->hw_init = alps_hw_init_dolphin_v1; in alps_set_protocol()
2798 priv->process_packet = alps_process_touchpad_packet_v3_v5; in alps_set_protocol()
2799 priv->decode_fields = alps_decode_dolphin; in alps_set_protocol()
2800 priv->set_abs_params = alps_set_abs_params_semi_mt; in alps_set_protocol()
2801 priv->nibble_commands = alps_v3_nibble_commands; in alps_set_protocol()
2802 priv->addr_command = PSMOUSE_CMD_RESET_WRAP; in alps_set_protocol()
2803 priv->x_bits = 23; in alps_set_protocol()
2804 priv->y_bits = 12; in alps_set_protocol()
2807 return -EIO; in alps_set_protocol()
2812 priv->hw_init = alps_hw_init_v6; in alps_set_protocol()
2813 priv->process_packet = alps_process_packet_v6; in alps_set_protocol()
2814 priv->set_abs_params = alps_set_abs_params_st; in alps_set_protocol()
2815 priv->nibble_commands = alps_v6_nibble_commands; in alps_set_protocol()
2816 priv->x_max = 2047; in alps_set_protocol()
2817 priv->y_max = 1535; in alps_set_protocol()
2821 priv->hw_init = alps_hw_init_v7; in alps_set_protocol()
2822 priv->process_packet = alps_process_packet_v7; in alps_set_protocol()
2823 priv->decode_fields = alps_decode_packet_v7; in alps_set_protocol()
2824 priv->set_abs_params = alps_set_abs_params_v7; in alps_set_protocol()
2825 priv->nibble_commands = alps_v3_nibble_commands; in alps_set_protocol()
2826 priv->addr_command = PSMOUSE_CMD_RESET_WRAP; in alps_set_protocol()
2827 priv->x_max = 0xfff; in alps_set_protocol()
2828 priv->y_max = 0x7ff; in alps_set_protocol()
2830 if (priv->fw_ver[1] != 0xba) in alps_set_protocol()
2831 priv->flags |= ALPS_BUTTONPAD; in alps_set_protocol()
2834 priv->flags &= ~ALPS_DUALPOINT; in alps_set_protocol()
2839 priv->hw_init = alps_hw_init_ss4_v2; in alps_set_protocol()
2840 priv->process_packet = alps_process_packet_ss4_v2; in alps_set_protocol()
2841 priv->decode_fields = alps_decode_ss4_v2; in alps_set_protocol()
2842 priv->set_abs_params = alps_set_abs_params_ss4_v2; in alps_set_protocol()
2843 priv->nibble_commands = alps_v3_nibble_commands; in alps_set_protocol()
2844 priv->addr_command = PSMOUSE_CMD_RESET_WRAP; in alps_set_protocol()
2847 return -EIO; in alps_set_protocol()
2864 if (!memcmp(e7, model->signature, sizeof(model->signature))) in alps_match_table()
2865 return &model->protocol_info; in alps_match_table()
2875 if (ps2_command(&psmouse->ps2dev, in alps_is_cs19_trackpoint()
2882 * trackpoint-only devices have their variant_ids equal in alps_is_cs19_trackpoint()
2897 * The bits 0-2 of the first byte will be 1s if some buttons are in alps_identify()
2902 return -EIO; in alps_identify()
2905 return -EINVAL; in alps_identify()
2916 return -EIO; in alps_identify()
2942 return -EINVAL; in alps_identify()
2946 return -EINVAL; in alps_identify()
2952 memcpy(priv->dev_id, e7, 3); in alps_identify()
2953 memcpy(priv->fw_ver, ec, 3); in alps_identify()
2964 struct alps_data *priv = psmouse->private; in alps_reconnect()
2969 return -1; in alps_reconnect()
2971 return priv->hw_init(psmouse); in alps_reconnect()
2976 struct alps_data *priv = psmouse->private; in alps_disconnect()
2979 timer_shutdown_sync(&priv->timer); in alps_disconnect()
2980 if (priv->dev2) in alps_disconnect()
2981 input_unregister_device(priv->dev2); in alps_disconnect()
2982 if (!IS_ERR_OR_NULL(priv->dev3)) in alps_disconnect()
2983 input_unregister_device(priv->dev3); in alps_disconnect()
2990 input_set_abs_params(dev1, ABS_X, 0, priv->x_max, 0, 0); in alps_set_abs_params_st()
2991 input_set_abs_params(dev1, ABS_Y, 0, priv->y_max, 0, 0); in alps_set_abs_params_st()
2998 input_set_abs_params(dev1, ABS_MT_POSITION_X, 0, priv->x_max, 0, 0); in alps_set_abs_params_mt_common()
2999 input_set_abs_params(dev1, ABS_MT_POSITION_Y, 0, priv->y_max, 0, 0); in alps_set_abs_params_mt_common()
3001 input_abs_set_res(dev1, ABS_MT_POSITION_X, priv->x_res); in alps_set_abs_params_mt_common()
3002 input_abs_set_res(dev1, ABS_MT_POSITION_Y, priv->y_res); in alps_set_abs_params_mt_common()
3004 set_bit(BTN_TOOL_TRIPLETAP, dev1->keybit); in alps_set_abs_params_mt_common()
3005 set_bit(BTN_TOOL_QUADTAP, dev1->keybit); in alps_set_abs_params_mt_common()
3023 set_bit(BTN_TOOL_QUINTTAP, dev1->keybit); in alps_set_abs_params_v7()
3029 set_bit(BTN_TOOL_QUINTTAP, dev1->keybit); in alps_set_abs_params_v7()
3037 set_bit(BTN_TOOL_QUINTTAP, dev1->keybit); in alps_set_abs_params_ss4_v2()
3046 struct alps_data *priv = psmouse->private; in alps_init()
3047 struct input_dev *dev1 = psmouse->dev; in alps_init()
3050 error = priv->hw_init(psmouse); in alps_init()
3058 __clear_bit(EV_REL, dev1->evbit); in alps_init()
3059 __clear_bit(REL_X, dev1->relbit); in alps_init()
3060 __clear_bit(REL_Y, dev1->relbit); in alps_init()
3065 dev1->evbit[BIT_WORD(EV_KEY)] |= BIT_MASK(EV_KEY); in alps_init()
3066 dev1->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH); in alps_init()
3067 dev1->keybit[BIT_WORD(BTN_TOOL_FINGER)] |= BIT_MASK(BTN_TOOL_FINGER); in alps_init()
3068 dev1->keybit[BIT_WORD(BTN_LEFT)] |= in alps_init()
3071 dev1->evbit[BIT_WORD(EV_ABS)] |= BIT_MASK(EV_ABS); in alps_init()
3073 priv->set_abs_params(priv, dev1); in alps_init()
3075 if (priv->flags & ALPS_WHEEL) { in alps_init()
3076 dev1->evbit[BIT_WORD(EV_REL)] |= BIT_MASK(EV_REL); in alps_init()
3077 dev1->relbit[BIT_WORD(REL_WHEEL)] |= BIT_MASK(REL_WHEEL); in alps_init()
3080 if (priv->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { in alps_init()
3081 dev1->keybit[BIT_WORD(BTN_FORWARD)] |= BIT_MASK(BTN_FORWARD); in alps_init()
3082 dev1->keybit[BIT_WORD(BTN_BACK)] |= BIT_MASK(BTN_BACK); in alps_init()
3085 if (priv->flags & ALPS_FOUR_BUTTONS) { in alps_init()
3086 dev1->keybit[BIT_WORD(BTN_0)] |= BIT_MASK(BTN_0); in alps_init()
3087 dev1->keybit[BIT_WORD(BTN_1)] |= BIT_MASK(BTN_1); in alps_init()
3088 dev1->keybit[BIT_WORD(BTN_2)] |= BIT_MASK(BTN_2); in alps_init()
3089 dev1->keybit[BIT_WORD(BTN_3)] |= BIT_MASK(BTN_3); in alps_init()
3090 } else if (priv->flags & ALPS_BUTTONPAD) { in alps_init()
3091 set_bit(INPUT_PROP_BUTTONPAD, dev1->propbit); in alps_init()
3092 clear_bit(BTN_RIGHT, dev1->keybit); in alps_init()
3094 dev1->keybit[BIT_WORD(BTN_MIDDLE)] |= BIT_MASK(BTN_MIDDLE); in alps_init()
3097 if (priv->flags & ALPS_DUALPOINT) { in alps_init()
3104 error = -ENOMEM; in alps_init()
3108 snprintf(priv->phys2, sizeof(priv->phys2), "%s/input1", in alps_init()
3109 psmouse->ps2dev.serio->phys); in alps_init()
3110 dev2->phys = priv->phys2; in alps_init()
3114 * see function psmouse_switch_protocol() in psmouse-base.c in alps_init()
3116 dev2->name = "AlpsPS/2 ALPS DualPoint Stick"; in alps_init()
3118 dev2->id.bustype = BUS_I8042; in alps_init()
3119 dev2->id.vendor = 0x0002; in alps_init()
3120 dev2->id.product = PSMOUSE_ALPS; in alps_init()
3121 dev2->id.version = priv->proto_version; in alps_init()
3122 dev2->dev.parent = &psmouse->ps2dev.serio->dev; in alps_init()
3126 if (priv->flags & ALPS_DUALPOINT_WITH_PRESSURE) { in alps_init()
3134 __set_bit(INPUT_PROP_POINTER, dev2->propbit); in alps_init()
3135 __set_bit(INPUT_PROP_POINTING_STICK, dev2->propbit); in alps_init()
3146 priv->dev2 = dev2; in alps_init()
3149 priv->psmouse = psmouse; in alps_init()
3151 INIT_DELAYED_WORK(&priv->dev3_register_work, in alps_init()
3154 psmouse->protocol_handler = alps_process_byte; in alps_init()
3155 psmouse->poll = alps_poll; in alps_init()
3156 psmouse->disconnect = alps_disconnect; in alps_init()
3157 psmouse->reconnect = alps_reconnect; in alps_init()
3158 psmouse->pktsize = priv->proto_version == ALPS_PROTO_V4 ? 8 : 6; in alps_init()
3161 psmouse->resync_time = 0; in alps_init()
3164 psmouse->resetafter = psmouse->pktsize * 2; in alps_init()
3171 * Even though we did not allocate psmouse->private we do free in alps_init()
3174 kfree(psmouse->private); in alps_init()
3175 psmouse->private = NULL; in alps_init()
3189 * ALPS cs19 is a trackpoint-only device, and uses different in alps_detect()
3190 * protocol than DualPoint ones, so we return -EINVAL here and let in alps_detect()
3198 "ALPS CS19 trackpoint-only device detected, ignoring\n"); in alps_detect()
3199 return -EINVAL; in alps_detect()
3212 return -ENOMEM; in alps_detect()
3221 psmouse->vendor = "ALPS"; in alps_detect()
3222 psmouse->name = priv->flags & ALPS_DUALPOINT ? in alps_detect()
3224 psmouse->model = priv->proto_version; in alps_detect()
3233 psmouse->private = NULL; in alps_detect()