Module Name: src Committed By: maya Date: Sat Jul 14 00:47:33 UTC 2018
Modified Files: src/sys/dev/pckbport: synaptics.c synapticsreg.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/pckbport/synaptics.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pckbport/synapticsreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pckbport/synaptics.c diff -u src/sys/dev/pckbport/synaptics.c:1.41 src/sys/dev/pckbport/synaptics.c:1.42 --- src/sys/dev/pckbport/synaptics.c:1.41 Sun Jun 3 15:10:12 2018 +++ src/sys/dev/pckbport/synaptics.c Sat Jul 14 00:47:33 2018 @@ -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 @@ synaptics_poll_reset(struct pms_softc *p } 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 @@ synaptics_poll_status(struct pms_softc * 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 @@ pms_synaptics_probe_extended(struct pms_ 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 @@ pms_synaptics_probe_extended(struct pms_ 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 @@ pms_synaptics_probe_init(void *vsc) /* 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 @@ pms_synaptics_enable(void *vsc) 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 @@ pms_synaptics_enable(void *vsc) 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); Index: src/sys/dev/pckbport/synapticsreg.h diff -u src/sys/dev/pckbport/synapticsreg.h:1.9 src/sys/dev/pckbport/synapticsreg.h:1.10 --- src/sys/dev/pckbport/synapticsreg.h:1.9 Mon Nov 6 21:07:17 2017 +++ src/sys/dev/pckbport/synapticsreg.h Sat Jul 14 00:47:33 2018 @@ -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