Module Name:    src
Committed By:   mlelstv
Date:           Fri Jul  5 05:09:24 UTC 2019

Modified Files:
        src/sys/dev/pckbport: synaptics.c

Log Message:
Resynchronizing the input stream could infinitely wait when the touchpad
is in the wrong (relative) mode. The detection of relative mode is never
reached.

Limit the resynchronization to 6 bytes, then trigger a reset.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/pckbport/synaptics.c

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.49 src/sys/dev/pckbport/synaptics.c:1.50
--- src/sys/dev/pckbport/synaptics.c:1.49	Sun Jun  2 08:55:00 2019
+++ src/sys/dev/pckbport/synaptics.c	Fri Jul  5 05:09:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.49 2019/06/02 08:55:00 blymn Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.50 2019/07/05 05:09:24 mlelstv 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.49 2019/06/02 08:55:00 blymn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.50 2019/07/05 05:09:24 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1154,7 +1154,7 @@ pms_synaptics_input(void *vsc, int data)
 
 	getmicrouptime(&psc->current);
 
-	if (psc->inputstate > 0) {
+	if (psc->inputstate != 0) {
 		timersub(&psc->current, &psc->last, &diff);
 		if (diff.tv_sec > 0 || diff.tv_usec >= 40000) {
 			aprint_debug_dev(psc->sc_dev,
@@ -1173,14 +1173,23 @@ pms_synaptics_input(void *vsc, int data)
 	psc->last = psc->current;
 
 	switch (psc->inputstate) {
+	case -5:
+	case -4:
+	case -3:
+	case -2:
+	case -1:
 	case 0:
 		if ((data & 0xc8) != 0x80) {
 			aprint_debug_dev(psc->sc_dev,
 			    "pms_input: 0x%02x out of sync\n", data);
+			/* use negative counts to limit resync phase */
+			psc->inputstate--;
 			return;	/* not in sync yet, discard input */
 		}
+		psc->inputstate = 0;
 		/*FALLTHROUGH*/
 
+	case -6:
 	case 3:
 		if ((data & 8) == 8) {
 			aprint_debug_dev(psc->sc_dev,

Reply via email to