Input: alps - non interleaved V2 dualpoint has separate stick button bits
[firefly-linux-kernel-4.4.55.git] / drivers / input / mouse / alps.c
index e32625ccf8b6a2cc5c72dd07881710a59815f43a..da3af8db697cd61ab4ee0c4440f76b3168b2d759 100644 (file)
@@ -243,6 +243,14 @@ static void alps_process_packet_v1_v2(struct psmouse *psmouse)
                return;
        }
 
+       /* Non interleaved V2 dualpoint has separate stick button bits */
+       if (priv->proto_version == ALPS_PROTO_V2 &&
+           priv->flags == (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 */
@@ -1159,9 +1167,15 @@ static void alps_report_bare_ps2_packet(struct psmouse *psmouse,
                                        bool report_buttons)
 {
        struct alps_data *priv = psmouse->private;
-       struct input_dev *dev;
-
-       if (unlikely(IS_ERR_OR_NULL(priv->dev3))) {
+       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))
                        psmouse_queue_work(psmouse, &priv->dev3_register_work,
@@ -1172,7 +1186,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,