Input: ALPS - fix TrackStick detection on Thinkpad L570 and Latitude 7370
authorMasaki Ota <masaki.ota@jp.alps.com>
Mon, 29 Jan 2018 22:36:54 +0000 (14:36 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 8 Apr 2018 12:26:32 +0000 (14:26 +0200)
commit 567b9b549cfa1cbc202762ae97b5385c29ade1e3 upstream.

The primary interface for the touchpad device in Thinkpad L570 is SMBus,
so ALPS overlooked PS2 interface Firmware setting of TrackStick, and
shipped with TrackStick otp bit is disabled.

The address 0xD7 contains device number information, so we can identify
the device by checking this value, but to access it we need to enable
Command mode, and then re-enable the device. Devices shipped in Thinkpad
L570 report either 0x0C or 0x1D as device numbers, if we see them we assume
that the devices are DualPoints.

The same issue exists on Dell Latitude 7370.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196929
Fixes: 646580f793 ("Input: ALPS - fix multi-touch decoding on SS4 plus touchpads")
Signed-off-by: Masaki Ota <masaki.ota@jp.alps.com>
Tested-by: Aaron Ma <aaron.ma@canonical.com>
Tested-by: Jonathan Liu <net147@gmail.com>
Tested-by: Jaak Ristioja <jaak@ristioja.ee>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/input/mouse/alps.c

index 3d9c294e84db65805f1937bcea085d951fe0b184..9a234da8cac23fa0c16f4efe4daf92be7e5863aa 100644 (file)
@@ -2544,13 +2544,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;
@@ -2573,7 +2591,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;
 }