]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/input/mouse/alps.c
Input: alps - only Dell laptops have separate button bits for v2 dualpoint sticks
[karo-tx-linux.git] / drivers / input / mouse / alps.c
index 4e1af89c774947981d4745f0b0ce3240f894dca7..4d246861d692b810f3074aa7917cda86893ac6c2 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/input/mt.h>
 #include <linux/serio.h>
 #include <linux/libps2.h>
+#include <linux/dmi.h>
 
 #include "psmouse.h"
 #include "alps.h"
@@ -99,6 +100,7 @@ static const struct alps_nibble_commands alps_v6_nibble_commands[] = {
 #define ALPS_FOUR_BUTTONS      0x40    /* 4 direction button present */
 #define ALPS_PS2_INTERLEAVED   0x80    /* 3-byte PS/2 packet interleaved with
                                           6-byte ALPS packet */
+#define ALPS_DELL              0x100   /* device is a Dell laptop */
 #define ALPS_BUTTONPAD         0x200   /* device is a clickpad */
 
 static const struct alps_model_info alps_model_data[] = {
@@ -251,6 +253,14 @@ static void alps_process_packet_v1_v2(struct psmouse *psmouse)
                return;
        }
 
+       /* Dell non interleaved V2 dualpoint has separate stick button bits */
+       if (priv->proto_version == ALPS_PROTO_V2 &&
+           priv->flags == (ALPS_DELL | ALPS_PASS | ALPS_DUALPOINT)) {
+               left |= packet[0] & 1;
+               right |= packet[0] & 2;
+               middle |= packet[0] & 4;
+       }
+
        alps_report_buttons(dev, dev2, left, right, middle);
 
        /* Convert hardware tap to a reasonable Z value */
@@ -941,6 +951,11 @@ static void alps_get_finger_coordinate_v7(struct input_mt_pos *mt,
        case V7_PACKET_ID_TWO:
                mt[1].x &= ~0x000F;
                mt[1].y |= 0x000F;
+               /* Detect false-postive touches where x & y report max value */
+               if (mt[1].y == 0x7ff && mt[1].x == 0xff0) {
+                       mt[1].x = 0;
+                       /* y gets set to 0 at the end of this function */
+               }
                break;
 
        case V7_PACKET_ID_MULTI:
@@ -1058,9 +1073,8 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
        right = (packet[1] & 0x02) >> 1;
        middle = (packet[1] & 0x04) >> 2;
 
-       /* Divide 2 since trackpoint's speed is too fast */
-       input_report_rel(dev2, REL_X, (char)x / 2);
-       input_report_rel(dev2, REL_Y, -((char)y / 2));
+       input_report_rel(dev2, REL_X, (char)x);
+       input_report_rel(dev2, REL_Y, -((char)y));
 
        input_report_key(dev2, BTN_LEFT, left);
        input_report_key(dev2, BTN_RIGHT, right);
@@ -1345,13 +1359,14 @@ static void alps_report_bare_ps2_packet(struct psmouse *psmouse,
                                        bool report_buttons)
 {
        struct alps_data *priv = psmouse->private;
-       struct input_dev *dev;
+       struct input_dev *dev, *dev2 = NULL;
 
        /* Figure out which device to use to report the bare packet */
        if (priv->proto_version == ALPS_PROTO_V2 &&
            (priv->flags & ALPS_DUALPOINT)) {
                /* On V2 devices the DualPoint Stick reports bare packets */
                dev = priv->dev2;
+               dev2 = psmouse->dev;
        } else if (unlikely(IS_ERR_OR_NULL(priv->dev3))) {
                /* Register dev3 mouse if we received PS/2 packet first time */
                if (!IS_ERR(priv->dev3))
@@ -1363,7 +1378,7 @@ static void alps_report_bare_ps2_packet(struct psmouse *psmouse,
        }
 
        if (report_buttons)
-               alps_report_buttons(dev, NULL,
+               alps_report_buttons(dev, dev2,
                                packet[0] & 1, packet[0] & 2, packet[0] & 4);
 
        input_report_rel(dev, REL_X,
@@ -2537,6 +2552,8 @@ static int alps_set_protocol(struct psmouse *psmouse,
        priv->byte0 = protocol->byte0;
        priv->mask0 = protocol->mask0;
        priv->flags = protocol->flags;
+       if (dmi_name_in_vendors("Dell"))
+               priv->flags |= ALPS_DELL;
 
        priv->x_max = 2000;
        priv->y_max = 1400;