Merge tag 'v4.17-rc6' into next
[sfrench/cifs-2.6.git] / drivers / input / mouse / alps.c
index adf7f05c643a70d5a2c7b0818247e70a2e2f21c6..cb5579716dba69e0c85d9556505eff97c7d62fd4 100644 (file)
@@ -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;
+       z = packet[4] & 0x7f;
 
        /*
         * The x and y values tend to be quite large, and when used
@@ -2548,13 +2548,31 @@ static int alps_update_btn_info_ss4_v2(unsigned char otp[][4],
 }
 
 static int alps_update_dual_info_ss4_v2(unsigned char otp[][4],
-                                      struct alps_data *priv)
+                                       struct alps_data *priv,
+                                       struct psmouse *psmouse)
 {
        bool is_dual = false;
+       int reg_val = 0;
+       struct ps2dev *ps2dev = &psmouse->ps2dev;
 
-       if (IS_SS4PLUS_DEV(priv->dev_id))
+       if (IS_SS4PLUS_DEV(priv->dev_id)) {
                is_dual = (otp[0][0] >> 4) & 0x01;
 
+               if (!is_dual) {
+                       /* For support TrackStick of Thinkpad L/E series */
+                       if (alps_exit_command_mode(psmouse) == 0 &&
+                               alps_enter_command_mode(psmouse) == 0) {
+                               reg_val = alps_command_mode_read_reg(psmouse,
+                                                                       0xD7);
+                       }
+                       alps_exit_command_mode(psmouse);
+                       ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE);
+
+                       if (reg_val == 0x0C || reg_val == 0x1D)
+                               is_dual = true;
+               }
+       }
+
        if (is_dual)
                priv->flags |= ALPS_DUALPOINT |
                                        ALPS_DUALPOINT_WITH_PRESSURE;
@@ -2577,7 +2595,7 @@ static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
 
        alps_update_btn_info_ss4_v2(otp, priv);
 
-       alps_update_dual_info_ss4_v2(otp, priv);
+       alps_update_dual_info_ss4_v2(otp, priv, psmouse);
 
        return 0;
 }