+tech@

On Tue, 30 Jun 2020 22:25:07 +0200
Marcus Glocker <[email protected]> wrote:

> Hello Gents,
> 
> The last pms.c commit rev. 1.92 introduces the same issue on my
> ThinkPad X1 Gen6 again which we already have fixed with pms.c
> rev. 1.87:
> 
> pms0: not in sync, discard input ...
> 
> This was caused by a missing delay() required in synaptics_set_mode().
> 
> The reason why I get it again is that I didn't reach the code on line
> 1215/1216 before pms.c rev. 1.92, which is basically also reflecting
> a synaptics_set_mode() call which would require another delay().
> Instead of sprinkling more delays in the code I found it a better
> idea to handle this code also with the synaptics_set_mode() function.
> 
> The below diff fixes the intermittent device initialization issues
> on my X1 again.
> 
> OK?
> 
> Regards,
> Marcus


Index: pms.c
===================================================================
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.92
diff -u -p -u -p -r1.92 pms.c
--- pms.c       18 Mar 2020 22:38:10 -0000      1.92
+++ pms.c       30 Jun 2020 20:23:32 -0000
@@ -304,7 +304,7 @@ void        pms_proc_elantech_v3(struct pms_sof
 void   pms_proc_elantech_v4(struct pms_softc *);
 
 int    synaptics_knock(struct pms_softc *);
-int    synaptics_set_mode(struct pms_softc *, int);
+int    synaptics_set_mode(struct pms_softc *, int, int);
 int    synaptics_query(struct pms_softc *, int, int *);
 int    synaptics_get_hwinfo(struct pms_softc *);
 void   synaptics_sec_proc(struct pms_softc *);
@@ -970,12 +970,12 @@ pmsinput(void *vsc, int data)
 }
 
 int
-synaptics_set_mode(struct pms_softc *sc, int mode)
+synaptics_set_mode(struct pms_softc *sc, int mode, int rate)
 {
        struct synaptics_softc *syn = sc->synaptics;
 
        if (pms_spec_cmd(sc, mode) ||
-           pms_set_rate(sc, SYNAPTICS_CMD_SET_MODE))
+           pms_set_rate(sc, rate == 0 ? SYNAPTICS_CMD_SET_MODE : rate))
                return (-1);
 
        /*
@@ -984,7 +984,8 @@ synaptics_set_mode(struct pms_softc *sc,
         */
        delay(10000);
 
-       syn->mode = mode;
+       if (rate == 0)
+               syn->mode = mode;
 
        return (0);
 }
@@ -1208,12 +1209,12 @@ pms_enable_synaptics(struct pms_softc *s
                mode |= SYNAPTICS_W_MODE;
        else if (SYNAPTICS_ID_MAJOR(syn->identify) >= 4)
                mode |= SYNAPTICS_DISABLE_GESTURE;
-       if (synaptics_set_mode(sc, mode))
+       if (synaptics_set_mode(sc, mode, 0))
                goto err;
 
        if (SYNAPTICS_SUPPORTS_AGM(syn->ext_capabilities) &&
-           (pms_spec_cmd(sc, SYNAPTICS_QUE_MODEL) ||
-            pms_set_rate(sc, SYNAPTICS_CMD_SET_ADV_GESTURE_MODE)))
+           synaptics_set_mode(sc, SYNAPTICS_QUE_MODEL,
+               SYNAPTICS_CMD_SET_ADV_GESTURE_MODE))
                goto err;
 
        return (1);
@@ -1386,7 +1387,7 @@ pms_disable_synaptics(struct pms_softc *
 
        if (syn->capabilities & SYNAPTICS_CAP_SLEEP)
                synaptics_set_mode(sc, SYNAPTICS_SLEEP_MODE |
-                   SYNAPTICS_DISABLE_GESTURE);
+                   SYNAPTICS_DISABLE_GESTURE, 0);
 }
 
 int

Reply via email to