Merge branch 'next' into for-linus
[sfrench/cifs-2.6.git] / drivers / input / mouse / alps.c
index 4a3bc168a4a78866a007e619c0c61d5a2ccb656e..0a67f235ba88a7b6e25877a43b35488a31d8fdf5 100644 (file)
@@ -139,11 +139,11 @@ static const struct alps_model_info alps_model_data[] = {
 };
 
 static const struct alps_protocol_info alps_v3_protocol_data = {
-       ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT
+       ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
 };
 
 static const struct alps_protocol_info alps_v3_rushmore_data = {
-       ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT
+       ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
 };
 
 static const struct alps_protocol_info alps_v4_protocol_data = {
@@ -155,7 +155,7 @@ static const struct alps_protocol_info alps_v5_protocol_data = {
 };
 
 static const struct alps_protocol_info alps_v7_protocol_data = {
-       ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT
+       ALPS_PROTO_V7, 0x48, 0x48, ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE
 };
 
 static const struct alps_protocol_info alps_v8_protocol_data = {
@@ -583,7 +583,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
 
        x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f));
        y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f));
-       z = (packet[4] & 0x7c) >> 2;
+       z = packet[4] & 0x7c;
 
        /*
         * The x and y values tend to be quite large, and when used
@@ -595,6 +595,7 @@ static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
 
        input_report_rel(dev, REL_X, x);
        input_report_rel(dev, REL_Y, -y);
+       input_report_abs(dev, ABS_PRESSURE, z);
 
        /*
         * Most ALPS models report the trackstick buttons in the touchpad
@@ -827,7 +828,7 @@ static void alps_process_packet_v6(struct psmouse *psmouse)
        unsigned char *packet = psmouse->packet;
        struct input_dev *dev = psmouse->dev;
        struct input_dev *dev2 = priv->dev2;
-       int x, y, z, left, right, middle;
+       int x, y, z;
 
        /*
         * We can use Byte5 to distinguish if the packet is from Touchpad
@@ -847,9 +848,6 @@ static void alps_process_packet_v6(struct psmouse *psmouse)
                x = packet[1] | ((packet[3] & 0x20) << 2);
                y = packet[2] | ((packet[3] & 0x40) << 1);
                z = packet[4];
-               left = packet[3] & 0x01;
-               right = packet[3] & 0x02;
-               middle = packet[3] & 0x04;
 
                /* To prevent the cursor jump when finger lifted */
                if (x == 0x7F && y == 0x7F && z == 0x7F)
@@ -859,9 +857,7 @@ static void alps_process_packet_v6(struct psmouse *psmouse)
                input_report_rel(dev2, REL_X, (char)x / 4);
                input_report_rel(dev2, REL_Y, -((char)y / 4));
 
-               input_report_key(dev2, BTN_LEFT, left);
-               input_report_key(dev2, BTN_RIGHT, right);
-               input_report_key(dev2, BTN_MIDDLE, middle);
+               psmouse_report_standard_buttons(dev2, packet[3]);
 
                input_sync(dev2);
                return;
@@ -871,8 +867,6 @@ static void alps_process_packet_v6(struct psmouse *psmouse)
        x = packet[1] | ((packet[3] & 0x78) << 4);
        y = packet[2] | ((packet[4] & 0x78) << 4);
        z = packet[5];
-       left = packet[3] & 0x01;
-       right = packet[3] & 0x02;
 
        if (z > 30)
                input_report_key(dev, BTN_TOUCH, 1);
@@ -888,8 +882,8 @@ static void alps_process_packet_v6(struct psmouse *psmouse)
        input_report_key(dev, BTN_TOOL_FINGER, z > 0);
 
        /* v6 touchpad does not have middle button */
-       input_report_key(dev, BTN_LEFT, left);
-       input_report_key(dev, BTN_RIGHT, right);
+       packet[3] &= ~BIT(2);
+       psmouse_report_standard_buttons(dev2, packet[3]);
 
        input_sync(dev);
 }
@@ -1098,7 +1092,7 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
        struct alps_data *priv = psmouse->private;
        unsigned char *packet = psmouse->packet;
        struct input_dev *dev2 = priv->dev2;
-       int x, y, z, left, right, middle;
+       int x, y, z;
 
        /* It should be a DualPoint when received trackstick packet */
        if (!(priv->flags & ALPS_DUALPOINT)) {
@@ -1112,16 +1106,11 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
            ((packet[3] & 0x20) << 1);
        z = (packet[5] & 0x3f) | ((packet[3] & 0x80) >> 1);
 
-       left = (packet[1] & 0x01);
-       right = (packet[1] & 0x02) >> 1;
-       middle = (packet[1] & 0x04) >> 2;
-
        input_report_rel(dev2, REL_X, (char)x);
        input_report_rel(dev2, REL_Y, -((char)y));
+       input_report_abs(dev2, ABS_PRESSURE, z);
 
-       input_report_key(dev2, BTN_LEFT, left);
-       input_report_key(dev2, BTN_RIGHT, right);
-       input_report_key(dev2, BTN_MIDDLE, middle);
+       psmouse_report_standard_buttons(dev2, packet[1]);
 
        input_sync(dev2);
 }
@@ -1503,10 +1492,7 @@ static void alps_report_bare_ps2_packet(struct psmouse *psmouse,
                alps_report_buttons(dev, dev2,
                                packet[0] & 1, packet[0] & 2, packet[0] & 4);
 
-       input_report_rel(dev, REL_X,
-               packet[1] ? packet[1] - ((packet[0] << 4) & 0x100) : 0);
-       input_report_rel(dev, REL_Y,
-               packet[2] ? ((packet[0] << 3) & 0x100) - packet[2] : 0);
+       psmouse_report_standard_motion(dev, packet);
 
        input_sync(dev);
 }