aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-07-26 01:47:25 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-07-26 17:03:17 -0400
commit68c21870179d78ab7375da432e8dd753d4dc2ba0 (patch)
treeb57d0721716d89542cfba900998a5651dadbe92e
parentc38a448a237534aecc40bd826c55132c479f4c42 (diff)
Input: alps - add an alps_report_semi_mt_data function
Move all the semi-mt specific handling shared between the v3 and v4 handling code to a common helper function. 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.c76
1 files changed, 29 insertions, 47 deletions
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 9a5f08db4537..f16fe7c7d215 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -441,6 +441,32 @@ static void alps_report_mt_data(struct psmouse *psmouse, int n)
441 input_mt_sync_frame(dev); 441 input_mt_sync_frame(dev);
442} 442}
443 443
444static void alps_report_semi_mt_data(struct psmouse *psmouse, int fingers)
445{
446 struct alps_data *priv = psmouse->private;
447 struct input_dev *dev = psmouse->dev;
448 struct alps_fields *f = &priv->f;
449
450 /* Use st data when we don't have mt data */
451 if (fingers < 2) {
452 f->mt[0].x = f->st.x;
453 f->mt[0].y = f->st.y;
454 fingers = f->pressure > 0 ? 1 : 0;
455 }
456
457 alps_report_mt_data(psmouse, (fingers <= 2) ? fingers : 1);
458
459 input_mt_report_finger_count(dev, fingers);
460
461 input_report_key(dev, BTN_LEFT, f->left);
462 input_report_key(dev, BTN_RIGHT, f->right);
463 input_report_key(dev, BTN_MIDDLE, f->middle);
464
465 input_report_abs(dev, ABS_PRESSURE, f->pressure);
466
467 input_sync(dev);
468}
469
444static void alps_process_trackstick_packet_v3(struct psmouse *psmouse) 470static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
445{ 471{
446 struct alps_data *priv = psmouse->private; 472 struct alps_data *priv = psmouse->private;
@@ -585,7 +611,6 @@ static void alps_process_touchpad_packet_v3_v5(struct psmouse *psmouse)
585{ 611{
586 struct alps_data *priv = psmouse->private; 612 struct alps_data *priv = psmouse->private;
587 unsigned char *packet = psmouse->packet; 613 unsigned char *packet = psmouse->packet;
588 struct input_dev *dev = psmouse->dev;
589 struct input_dev *dev2 = priv->dev2; 614 struct input_dev *dev2 = priv->dev2;
590 struct alps_fields *f = &priv->f; 615 struct alps_fields *f = &priv->f;
591 int fingers = 0; 616 int fingers = 0;
@@ -665,27 +690,7 @@ static void alps_process_touchpad_packet_v3_v5(struct psmouse *psmouse)
665 if (f->st.x && f->st.y && !f->pressure) 690 if (f->st.x && f->st.y && !f->pressure)
666 return; 691 return;
667 692
668 /* 693 alps_report_semi_mt_data(psmouse, fingers);
669 * If we don't have MT data or the bitmaps were empty, we have
670 * to rely on ST data.
671 */
672 if (fingers < 2) {
673 f->mt[0].x = f->st.x;
674 f->mt[0].y = f->st.y;
675 fingers = f->pressure > 0 ? 1 : 0;
676 }
677
678 alps_report_mt_data(psmouse, (fingers <= 2) ? fingers : 1);
679
680 input_mt_report_finger_count(dev, fingers);
681
682 input_report_key(dev, BTN_LEFT, f->left);
683 input_report_key(dev, BTN_RIGHT, f->right);
684 input_report_key(dev, BTN_MIDDLE, f->middle);
685
686 input_report_abs(dev, ABS_PRESSURE, f->pressure);
687
688 input_sync(dev);
689 694
690 if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) { 695 if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) {
691 input_report_key(dev2, BTN_LEFT, f->ts_left); 696 input_report_key(dev2, BTN_LEFT, f->ts_left);
@@ -789,9 +794,8 @@ static void alps_process_packet_v4(struct psmouse *psmouse)
789{ 794{
790 struct alps_data *priv = psmouse->private; 795 struct alps_data *priv = psmouse->private;
791 unsigned char *packet = psmouse->packet; 796 unsigned char *packet = psmouse->packet;
792 struct input_dev *dev = psmouse->dev;
793 struct alps_fields *f = &priv->f; 797 struct alps_fields *f = &priv->f;
794 int offset, fingers = 0; 798 int offset;
795 799
796 /* 800 /*
797 * v4 has a 6-byte encoding for bitmap data, but this data is 801 * v4 has a 6-byte encoding for bitmap data, but this data is
@@ -832,29 +836,7 @@ static void alps_process_packet_v4(struct psmouse *psmouse)
832 f->st.y = ((packet[2] & 0x7f) << 4) | (packet[3] & 0x0f); 836 f->st.y = ((packet[2] & 0x7f) << 4) | (packet[3] & 0x0f);
833 f->pressure = packet[5] & 0x7f; 837 f->pressure = packet[5] & 0x7f;
834 838
835 /* 839 alps_report_semi_mt_data(psmouse, f->fingers);
836 * If there were no contacts in the bitmap, use ST
837 * points in MT reports.
838 * If there were two contacts or more, report MT data.
839 */
840 if (f->fingers < 2) {
841 f->mt[0].x = f->st.x;
842 f->mt[0].y = f->st.y;
843 fingers = f->pressure > 0 ? 1 : 0;
844 } else {
845 fingers = f->fingers;
846 }
847
848 alps_report_mt_data(psmouse, (fingers <= 2) ? fingers : 1);
849
850 input_mt_report_finger_count(dev, fingers);
851
852 input_report_key(dev, BTN_LEFT, f->left);
853 input_report_key(dev, BTN_RIGHT, f->right);
854
855 input_report_abs(dev, ABS_PRESSURE, f->pressure);
856
857 input_sync(dev);
858} 840}
859 841
860static void alps_report_bare_ps2_packet(struct psmouse *psmouse, 842static void alps_report_bare_ps2_packet(struct psmouse *psmouse,