This patch makes two changes in the way pms(4) handles Synaptics touchpads.
It addresses problems that lead to this bug report:
    https://marc.info/?l=openbsd-bugs&m=158278943515495&w=2

Tests for regressions and OKs would be welcome.

1) The patched version doesn't enable the so-called "extended W-mode" (EW)
anymore.  In EW-mode, the touchpad sends additional packets when there
is more than one contact on the device, but our driver just drops these
packets, so the setup doesn't make sense.  (Properly supporting EW-mode
would require substantial changes in the synaptics code, and I think it's
debatable whether it would be worth the trouble.)

For the reason mentioned in the comment below, the "advanced gesture mode"
(AGM) will be enabled as before.

2) Some touchpads that support AGM don't report it in the
SYNAPTICS_EXT_CAP_ADV_GESTURE bit.  Another flag must be checked for these
cases, and the test has been extended accordingly.

OK?


Index: sys/dev/pckbc/pms.c
===================================================================
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.91
diff -u -p -r1.91 pms.c
--- sys/dev/pckbc/pms.c 22 Jan 2020 14:52:14 -0000      1.91
+++ sys/dev/pckbc/pms.c 12 Mar 2020 16:28:17 -0000
@@ -1186,25 +1186,32 @@ pms_enable_synaptics(struct pms_softc *s
                    nitems(synaptics_params)))
                        goto err;

-               printf("%s: Synaptics %s, firmware %d.%d, 0x%x 0x%x\n",
+               printf("%s: Synaptics %s, firmware %d.%d, "
+                   "0x%x 0x%x 0x%x 0x%x 0x%x\n",
                    DEVNAME(sc),
                    (syn->ext_capabilities & SYNAPTICS_EXT_CAP_CLICKPAD ?
                        "clickpad" : "touchpad"),
                    SYNAPTICS_ID_MAJOR(syn->identify),
                    SYNAPTICS_ID_MINOR(syn->identify),
-                   syn->model, syn->ext_model);
+                   syn->model, syn->ext_model, syn->modes,
+                   syn->capabilities, syn->ext_capabilities);
        }

+       /*
+        * Enable absolute mode, plain W-mode and "advanced gesture mode"
+        * (AGM), if possible.  AGM, which seems to be a prerequisite for the
+        * extended W-mode, might not always be necessary here, but at least
+        * some older Synaptics models do not report finger counts without it.
+        */
        mode = SYNAPTICS_ABSOLUTE_MODE | SYNAPTICS_HIGH_RATE;
-       if (SYNAPTICS_ID_MAJOR(syn->identify) >= 4)
-               mode |= SYNAPTICS_DISABLE_GESTURE;
        if (syn->capabilities & SYNAPTICS_CAP_EXTENDED)
                mode |= SYNAPTICS_W_MODE;
+       else if (SYNAPTICS_ID_MAJOR(syn->identify) >= 4)
+               mode |= SYNAPTICS_DISABLE_GESTURE;
        if (synaptics_set_mode(sc, mode))
                goto err;

-       /* enable advanced gesture mode if supported */
-       if ((syn->ext_capabilities & SYNAPTICS_EXT_CAP_ADV_GESTURE) &&
+       if (SYNAPTICS_SUPPORTS_AGM(syn->ext_capabilities) &&
            (pms_spec_cmd(sc, SYNAPTICS_QUE_MODEL) ||
             pms_set_rate(sc, SYNAPTICS_CMD_SET_ADV_GESTURE_MODE)))
                goto err;
@@ -1294,17 +1301,17 @@ pms_proc_synaptics(struct pms_softc *sc)
        }


-       if ((syn->capabilities & SYNAPTICS_CAP_PASSTHROUGH) && w == 3) {
-               synaptics_sec_proc(sc);
+       if (w == 3) {
+               if (syn->capabilities & SYNAPTICS_CAP_PASSTHROUGH)
+                       synaptics_sec_proc(sc);
                return;
        }

        if ((sc->sc_dev_enable & PMS_DEV_PRIMARY) == 0)
                return;

-       /* XXX ignore advanced gesture packet, not yet supported */
-       if ((syn->ext_capabilities & SYNAPTICS_EXT_CAP_ADV_GESTURE) && w == 2)
-               return;
+       if (w == 2)
+               return; /* EW-mode packets are not expected here. */

        x = ((sc->packet[3] & 0x10) << 8) | ((sc->packet[1] & 0x0f) << 8) |
            sc->packet[4];
Index: sys/dev/pckbc/pmsreg.h
===================================================================
RCS file: /cvs/src/sys/dev/pckbc/pmsreg.h,v
retrieving revision 1.17
diff -u -p -r1.17 pmsreg.h
--- sys/dev/pckbc/pmsreg.h      20 Sep 2019 21:21:47 -0000      1.17
+++ sys/dev/pckbc/pmsreg.h      12 Mar 2020 16:28:17 -0000
@@ -140,7 +140,11 @@
 #define SYNAPTICS_EXT_CAP_ADV_GESTURE          (1 << 19)
 #define SYNAPTICS_EXT_CAP_MAX_COORDS           (1 << 17)
 #define SYNAPTICS_EXT_CAP_MIN_COORDS           (1 << 13)
+#define SYNAPTICS_EXT_CAP_REPORTS_V            (1 << 11)
 #define SYNAPTICS_EXT_CAP_CLICKPAD_2BTN                (1 << 8)
+
+#define SYNAPTICS_SUPPORTS_AGM(extcaps) (extcaps & \
+    (SYNAPTICS_EXT_CAP_ADV_GESTURE | SYNAPTICS_EXT_CAP_REPORTS_V))

 /* Coordinate Limits */
 #define SYNAPTICS_X_LIMIT(d)                   ((((d) & 0xff0000) >> 11) | \

Reply via email to