]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/input/mouse/alps.c
Input: mouse - use local variables consistently
[linux.git] / drivers / input / mouse / alps.c
index a76e5c6fce54fbb0bdf30e7f9a69dc261da12e37..72b28ebfe360030cbeeadec8a52385a9de09a7f0 100644 (file)
@@ -103,6 +103,7 @@ static const struct alps_nibble_commands alps_v6_nibble_commands[] = {
                                           6-byte ALPS packet */
 #define ALPS_STICK_BITS                0x100   /* separate stick button bits */
 #define ALPS_BUTTONPAD         0x200   /* device is a clickpad */
+#define ALPS_DUALPOINT_WITH_PRESSURE   0x400   /* device can report trackpoint pressure */
 
 static const struct alps_model_info alps_model_data[] = {
        { { 0x32, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } },      /* Toshiba Salellite Pro M10 */
@@ -1152,15 +1153,13 @@ static void alps_process_packet_v7(struct psmouse *psmouse)
                alps_process_touchpad_packet_v7(psmouse);
 }
 
-static unsigned char alps_get_pkt_id_ss4_v2(unsigned char *byte)
+static enum SS4_PACKET_ID alps_get_pkt_id_ss4_v2(unsigned char *byte)
 {
-       unsigned char pkt_id = SS4_PACKET_ID_IDLE;
+       enum SS4_PACKET_ID pkt_id = SS4_PACKET_ID_IDLE;
 
        switch (byte[3] & 0x30) {
        case 0x00:
-               if (byte[0] == 0x18 && byte[1] == 0x10 && byte[2] == 0x00 &&
-                   (byte[3] & 0x88) == 0x08 && byte[4] == 0x10 &&
-                   byte[5] == 0x00) {
+               if (SS4_IS_IDLE_V2(byte)) {
                        pkt_id = SS4_PACKET_ID_IDLE;
                } else {
                        pkt_id = SS4_PACKET_ID_ONE;
@@ -1187,7 +1186,7 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
                              unsigned char *p, struct psmouse *psmouse)
 {
        struct alps_data *priv = psmouse->private;
-       unsigned char pkt_id;
+       enum SS4_PACKET_ID pkt_id;
        unsigned int no_data_x, no_data_y;
 
        pkt_id = alps_get_pkt_id_ss4_v2(p);
@@ -1266,16 +1265,12 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
                break;
 
        case SS4_PACKET_ID_STICK:
-               if (!(priv->flags & ALPS_DUALPOINT)) {
-                       psmouse_warn(psmouse,
-                                    "Rejected trackstick packet from non DualPoint device");
-               } else {
-                       int x = (s8)(((p[0] & 1) << 7) | (p[1] & 0x7f));
-                       int y = (s8)(((p[3] & 1) << 7) | (p[2] & 0x7f));
-
-                       input_report_rel(priv->dev2, REL_X, x);
-                       input_report_rel(priv->dev2, REL_Y, -y);
-               }
+               /*
+                * x, y, and pressure are decoded in
+                * alps_process_packet_ss4_v2()
+                */
+               f->first_mp = 0;
+               f->is_mp = 0;
                break;
 
        case SS4_PACKET_ID_IDLE:
@@ -1343,6 +1338,27 @@ static void alps_process_packet_ss4_v2(struct psmouse *psmouse)
 
        priv->multi_packet = 0;
 
+       /* Report trackstick */
+       if (alps_get_pkt_id_ss4_v2(packet) == SS4_PACKET_ID_STICK) {
+               if (!(priv->flags & ALPS_DUALPOINT)) {
+                       psmouse_warn(psmouse,
+                                    "Rejected trackstick packet from non DualPoint device");
+                       return;
+               }
+
+               input_report_rel(dev2, REL_X, SS4_TS_X_V2(packet));
+               input_report_rel(dev2, REL_Y, SS4_TS_Y_V2(packet));
+               input_report_abs(dev2, ABS_PRESSURE, SS4_TS_Z_V2(packet));
+
+               input_report_key(dev2, BTN_LEFT, f->ts_left);
+               input_report_key(dev2, BTN_RIGHT, f->ts_right);
+               input_report_key(dev2, BTN_MIDDLE, f->ts_middle);
+
+               input_sync(dev2);
+               return;
+       }
+
+       /* Report touchpad */
        alps_report_mt_data(psmouse, (f->fingers <= 4) ? f->fingers : 4);
 
        input_mt_report_finger_count(dev, f->fingers);
@@ -1353,13 +1369,6 @@ static void alps_process_packet_ss4_v2(struct psmouse *psmouse)
 
        input_report_abs(dev, ABS_PRESSURE, f->pressure);
        input_sync(dev);
-
-       if (priv->flags & ALPS_DUALPOINT) {
-               input_report_key(dev2, BTN_LEFT, f->ts_left);
-               input_report_key(dev2, BTN_RIGHT, f->ts_right);
-               input_report_key(dev2, BTN_MIDDLE, f->ts_middle);
-               input_sync(dev2);
-       }
 }
 
 static bool alps_is_valid_package_ss4_v2(struct psmouse *psmouse)
@@ -1846,7 +1855,7 @@ static int alps_absolute_mode_v1_v2(struct psmouse *psmouse)
         * Switch mouse to poll (remote) mode so motion data will not
         * get in our way
         */
-       return ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETPOLL);
+       return ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETPOLL);
 }
 
 static int alps_monitor_mode_send_word(struct psmouse *psmouse, u16 word)
@@ -2744,6 +2753,10 @@ static int alps_set_protocol(struct psmouse *psmouse,
                if (alps_set_defaults_ss4_v2(psmouse, priv))
                        return -EIO;
 
+               if (priv->fw_ver[1] == 0x1)
+                       priv->flags |= ALPS_DUALPOINT |
+                                       ALPS_DUALPOINT_WITH_PRESSURE;
+
                break;
        }
 
@@ -2816,6 +2829,9 @@ static int alps_identify(struct psmouse *psmouse, struct alps_data *priv)
                } else if (e7[0] == 0x73 && e7[1] == 0x03 &&
                           e7[2] == 0x14 && ec[1] == 0x02) {
                        protocol = &alps_v8_protocol_data;
+               } else if (e7[0] == 0x73 && e7[1] == 0x03 &&
+                          e7[2] == 0x28 && ec[1] == 0x01) {
+                       protocol = &alps_v8_protocol_data;
                } else {
                        psmouse_dbg(psmouse,
                                    "Likely not an ALPS touchpad: E7=%3ph, EC=%3ph\n", e7, ec);
@@ -2998,6 +3014,10 @@ int alps_init(struct psmouse *psmouse)
 
                input_set_capability(dev2, EV_REL, REL_X);
                input_set_capability(dev2, EV_REL, REL_Y);
+               if (priv->flags & ALPS_DUALPOINT_WITH_PRESSURE) {
+                       input_set_capability(dev2, EV_ABS, ABS_PRESSURE);
+                       input_set_abs_params(dev2, ABS_PRESSURE, 0, 127, 0, 0);
+               }
                input_set_capability(dev2, EV_KEY, BTN_LEFT);
                input_set_capability(dev2, EV_KEY, BTN_RIGHT);
                input_set_capability(dev2, EV_KEY, BTN_MIDDLE);