Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pckbport Send the 'magic reverse engineered sequence...



details:   https://anonhg.NetBSD.org/src/rev/fb42fccaa718
branches:  trunk
changeset: 991441:fb42fccaa718
user:      maya <maya%NetBSD.org@localhost>
date:      Sat Jul 14 00:47:33 2018 +0000

description:
Send the 'magic reverse engineered sequence' with a single sliced command,
don't wait for individual ACKs. Fixes kern/53444.

While here:
- use better descriptive names for functions
- use a function for the extended write command
- add macro for number from the old synaptics documentation
- don't get the resp from the command sequence if we're going to ignore
it anyway

most from uwe.

diffstat:

 sys/dev/pckbport/synaptics.c    |  56 ++++++++++++++++++----------------------
 sys/dev/pckbport/synapticsreg.h |   3 +-
 2 files changed, 27 insertions(+), 32 deletions(-)

diffs (143 lines):

diff -r 4f12b3b0de56 -r fb42fccaa718 sys/dev/pckbport/synaptics.c
--- a/sys/dev/pckbport/synaptics.c      Fri Jul 13 22:43:44 2018 +0000
+++ b/sys/dev/pckbport/synaptics.c      Sat Jul 14 00:47:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: synaptics.c,v 1.41 2018/06/03 15:10:12 christos Exp $  */
+/*     $NetBSD: synaptics.c,v 1.42 2018/07/14 00:47:33 maya Exp $      */
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.41 2018/06/03 15:10:12 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.42 2018/07/14 00:47:33 maya Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -179,7 +179,7 @@
 }
 
 static int
-synaptics_poll_status(struct pms_softc *psc, u_char slice, u_char resp[3])
+synaptics_special_read(struct pms_softc *psc, u_char slice, u_char resp[3])
 {
        u_char cmd[1] = { PMS_SEND_DEV_STATUS };
        int res = pms_sliced_command(psc->sc_kbctag, psc->sc_kbcslot, slice);
@@ -188,6 +188,21 @@
            cmd, 1, 3, resp, 0);
 }
 
+static int
+synaptics_special_write(struct pms_softc *psc, u_char command, u_char arg)
+{
+       int res = pms_sliced_command(psc->sc_kbctag, psc->sc_kbcslot, arg);
+       if (res)
+               return res;
+
+       u_char cmd[2];
+       cmd[0] = PMS_SET_SAMPLE;
+       cmd[1] = command;
+       res = pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot,
+           cmd, 2, 0, NULL, 0);
+       return res;
+}
+
 static void
 pms_synaptics_probe_extended(struct pms_softc *psc)
 {
@@ -213,7 +228,7 @@
        if (((sc->caps & SYNAPTICS_CAP_EXTNUM) + 0x08)
            >= SYNAPTICS_EXTENDED_QUERY)
        {
-               res = synaptics_poll_status(psc, SYNAPTICS_EXTENDED_QUERY, resp);
+               res = synaptics_special_read(psc, SYNAPTICS_EXTENDED_QUERY, resp);
                if (res == 0) {
                        int buttons = (resp[1] >> 4);
                        aprint_debug_dev(psc->sc_dev,
@@ -245,7 +260,7 @@
        if (((sc->caps & SYNAPTICS_CAP_EXTNUM) + 0x08) >=
            SYNAPTICS_CONTINUED_CAPABILITIES)
        {
-               res = synaptics_poll_status(psc,
+               res = synaptics_special_read(psc,
                    SYNAPTICS_CONTINUED_CAPABILITIES, resp);
 
 /*
@@ -362,7 +377,7 @@
 
 
        /* Query the hardware capabilities. */
-       res = synaptics_poll_status(psc, SYNAPTICS_READ_CAPABILITIES, resp);
+       res = synaptics_special_read(psc, SYNAPTICS_READ_CAPABILITIES, resp);
        if (res) {
                /* Hmm, failed to get capabilites. */
                aprint_error_dev(psc->sc_dev,
@@ -410,7 +425,6 @@
        struct synaptics_softc *sc = &psc->u.synaptics;
        u_char enable_modes;
        int res;
-       u_char cmd[1], resp[3];
 
        if (sc->flags & SYN_FLAG_HAS_PASSTHROUGH) {
                /*
@@ -441,37 +455,17 @@
        for (int i = 0; i < 2; i++)
                synaptics_poll_cmd(psc, PMS_SET_SCALE11, 0);
 
-       res = pms_sliced_command(psc->sc_kbctag, psc->sc_kbcslot,
-           enable_modes);
+       res = synaptics_special_write(psc, SYNAPTICS_CMD_SET_MODE2, enable_modes);
        if (res)
                aprint_error("synaptics: set mode error\n");
 
-       synaptics_poll_cmd(psc, PMS_SET_SAMPLE, SYNAPTICS_CMD_SET_MODE2, 0);
-
        /* a couple of set scales to clear out pending commands */
        for (int i = 0; i < 2; i++)
                synaptics_poll_cmd(psc, PMS_SET_SCALE11, 0);
 
-       /*
-        * Enable multi-finger capability in cold boot case with
-        * undocumented sequence.
-        * Parameters from
-        * https://github.com/RehabMan/OS-X-Voodoo-PS2-Controller/
-        * VoodooPS2Trackpad/VoodooPS2SynapticsTouchPad.cpp
-        * setTouchPadModeByte function.
-        */
-       if (sc->flags & SYN_FLAG_HAS_EXTENDED_WMODE) {
-               static const uint8_t seq[] = {
-                   0xe6, 0xe8, 0x00, 0xe8, 0x00,
-                   0xe8, 0x00, 0xe8, 0x03, 0xf3,
-                   0xc8,
-               };
-               for (size_t s = 0; s < __arraycount(seq); s++) {
-                       cmd[0] = seq[s];
-                       (void)pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot,
-                               cmd, 1, 3, resp, 0);
-               }
-       }
+       /* Set advanced gesture mode */
+       if (sc->flags & SYN_FLAG_HAS_EXTENDED_WMODE)
+               synaptics_special_write(psc, SYNAPTICS_WRITE_DELUXE_3, 0x3); 
 
        synaptics_poll_cmd(psc, PMS_DEV_ENABLE, 0);
 
diff -r 4f12b3b0de56 -r fb42fccaa718 sys/dev/pckbport/synapticsreg.h
--- a/sys/dev/pckbport/synapticsreg.h   Fri Jul 13 22:43:44 2018 +0000
+++ b/sys/dev/pckbport/synapticsreg.h   Sat Jul 14 00:47:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: synapticsreg.h,v 1.9 2017/11/06 21:07:17 blymn Exp $   */
+/*     $NetBSD: synapticsreg.h,v 1.10 2018/07/14 00:47:33 maya Exp $   */
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -45,6 +45,7 @@
 #define        SYNAPTICS_READ_MODEL_ID         0x3
 #define        SYNAPTICS_EXTENDED_QUERY        0x9
 #define        SYNAPTICS_CONTINUED_CAPABILITIES 0x0c
+#define        SYNAPTICS_WRITE_DELUXE_3        0xc8 /* 6.2.3. Deluxe mode setting sequence */
 
 /* Synaptics special commands */
 #define        SYNAPTICS_CMD_SET_MODE2         0x14



Home | Main Index | Thread Index | Old Index