CVS commit: src/sys/dev/pckbport

2024-04-18 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Apr 18 17:35:53 UTC 2024

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

Log Message:
Renamed border/boundary variables to better describe their use.
Fix edge default values, factor out percentage calculation for more consistent
values. Use device_printf/DPRINTF to show errors instead of aprint variants.
Print raw input for debugging.

Correct capability parsing. Old devices were probed with nonexistent
commands and then used undefined boundary values that made them unusuable.

Fixes PR 57874.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 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.82 src/sys/dev/pckbport/synaptics.c:1.83
--- src/sys/dev/pckbport/synaptics.c:1.82	Tue Sep  5 05:55:12 2023
+++ src/sys/dev/pckbport/synaptics.c	Thu Apr 18 17:35:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.82 2023/09/05 05:55:12 mrg Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.83 2024/04/18 17:35:53 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.82 2023/09/05 05:55:12 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.83 2024/04/18 17:35:53 mlelstv Exp $");
 
 #include 
 #include 
@@ -112,10 +112,10 @@ static int synaptics_edge_bottom = SYNAP
 static int synaptics_edge_motion_delta = 32;
 static u_int synaptics_finger_high = SYNAPTICS_FINGER_LIGHT + 5;
 static u_int synaptics_finger_low = SYNAPTICS_FINGER_LIGHT - 10;
-static int synaptics_horiz_pct = 0;
-static int synaptics_vert_pct = 0;
-static int synaptics_button_pct = 30;
-static int synaptics_button_boundary;
+static int synaptics_hscroll_pct = 0;
+static int synaptics_vscroll_pct = 0;
+static int synaptics_button_pct = 0;
+static int synaptics_button_boundary = SYNAPTICS_EDGE_BOTTOM;
 static int synaptics_button2;
 static int synaptics_button3;
 static int synaptics_two_fingers_emul = 0;
@@ -166,23 +166,26 @@ static int synaptics_movement_threshold_
 static int synaptics_movement_enable_nodenum;
 static int synaptics_button_region_movement_nodenum;
 static int synaptics_aux_mid_button_scroll_nodenum;
-static int synaptics_horiz_pct_nodenum;
-static int synaptics_vert_pct_nodenum;
+static int synaptics_hscroll_pct_nodenum;
+static int synaptics_vscroll_pct_nodenum;
 static int synaptics_button_pct_nodenum;
 
 /*
  * copy of edges so we can recalculate edge limit if there is 
  * vertical scroll region
  */
-static int synaptics_actual_edge_right;
-static int synaptics_actual_edge_bottom;
+static int synaptics_true_edge_right;
+static int synaptics_true_edge_bottom;
 
-static int synaptics_old_vert_pct = 0;
-static int synaptics_old_horiz_pct = 0;
-static int synaptics_old_button_pct = 0;
-static int synaptics_old_button_boundary = SYNAPTICS_EDGE_BOTTOM;
-static int synaptics_old_horiz_edge = SYNAPTICS_EDGE_BOTTOM;
-static int synaptics_old_vert_edge = SYNAPTICS_EDGE_RIGHT;
+/*
+ * invalid old values, recalculate everything
+ */
+static int synaptics_old_vscroll_pct = -1;
+static int synaptics_old_hscroll_pct = -1;
+static int synaptics_old_button_pct = -1;
+static int synaptics_old_button_boundary = -1;
+static int synaptics_old_edge_right = -1;
+static int synaptics_old_edge_bottom = -1;
 
 /*
  * This holds the processed packet data, it is global because multiple
@@ -208,7 +211,7 @@ synaptics_poll_cmd(struct pms_softc *psc
 	int res = pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot, cmd, i, 0,
 	NULL, 0);
 	if (res)
-		aprint_error_dev(psc->sc_dev, "command error %#x\n", cmd[0]);
+		device_printf(psc->sc_dev, "command error %#x\n", cmd[0]);
 	return res;
 }
 
@@ -221,7 +224,7 @@ synaptics_poll_reset(struct pms_softc *p
 	u_char cmd[1] = { PMS_RESET };
 	res = pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot, cmd, 1, 2,
 	resp, 1);
-	aprint_debug_dev(psc->sc_dev, "reset %d 0x%02x 0x%02x\n",
+	DPRINTF(10, >u.synaptics, "reset %d 0x%02x 0x%02x\n",
 	res, resp[0], resp[1]);
 	return res;
 }
@@ -251,80 +254,90 @@ synaptics_special_write(struct pms_softc
 	return res;
 }
 
+static int
+synaptics_value(int pct, int low, int high)
+{
+	return low + pct * (high - low) / 100UL;
+}
+
+static int
+synaptics_percentage(int val, int low, int high)
+{
+	return ((val - low) * 100UL + high - low - 1) / (high - low);
+}
+
 static void
 pms_synaptics_set_boundaries(void)
 {
-	if (synaptics_vert_pct != synaptics_old_vert_pct ) {
-		synaptics_edge_right = synaptics_actual_edge_right -
-		((unsigned long) synaptics_vert_pct *
-		(synaptics_actual_edge_right - synaptics_edge_left)) / 100;
-		synaptics_old_vert_pct = synaptics_vert_pct;
-		synaptics_old_vert_edge = synaptics_edge_right;
+	if (synaptics_vscroll_pct != synaptics_old_vscroll_pct ) {
+		

CVS commit: src/sys/dev/pckbport

2024-04-18 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Apr 18 17:35:53 UTC 2024

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

Log Message:
Renamed border/boundary variables to better describe their use.
Fix edge default values, factor out percentage calculation for more consistent
values. Use device_printf/DPRINTF to show errors instead of aprint variants.
Print raw input for debugging.

Correct capability parsing. Old devices were probed with nonexistent
commands and then used undefined boundary values that made them unusuable.

Fixes PR 57874.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 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.



CVS commit: src/sys/dev/pckbport

2023-09-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Sep  5 05:55:12 UTC 2023

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

Log Message:
panic on an condition that shouldn't be possible.

appease GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/pckbport/pms.c
cvs rdiff -u -r1.81 -r1.82 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/pms.c
diff -u src/sys/dev/pckbport/pms.c:1.40 src/sys/dev/pckbport/pms.c:1.41
--- src/sys/dev/pckbport/pms.c:1.40	Fri Oct 28 23:40:37 2022
+++ src/sys/dev/pckbport/pms.c	Tue Sep  5 05:55:12 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pms.c,v 1.40 2022/10/28 23:40:37 riastradh Exp $ */
+/* $NetBSD: pms.c,v 1.41 2023/09/05 05:55:12 mrg Exp $ */
 
 /*-
  * Copyright (c) 2004 Kentaro Kurahone.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.40 2022/10/28 23:40:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.41 2023/09/05 05:55:12 mrg Exp $");
 
 #include "opt_pms.h"
 
@@ -561,6 +561,8 @@ pmsinput(void *vsc, int data)
 		if ((data & 0xc0) != 0)
 			return;	/* not in sync yet, discard input */
 	}
+	if (sc->inputstate >= sizeof(sc->packet))
+		panic("inputstate should never be %d", sc->inputstate);
 
 	sc->packet[sc->inputstate++] = data & 0xff;
 	switch (sc->inputstate) {

Index: src/sys/dev/pckbport/synaptics.c
diff -u src/sys/dev/pckbport/synaptics.c:1.81 src/sys/dev/pckbport/synaptics.c:1.82
--- src/sys/dev/pckbport/synaptics.c:1.81	Wed Sep 28 16:43:00 2022
+++ src/sys/dev/pckbport/synaptics.c	Tue Sep  5 05:55:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.81 2022/09/28 16:43:00 nia Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.82 2023/09/05 05:55:12 mrg Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.81 2022/09/28 16:43:00 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.82 2023/09/05 05:55:12 mrg Exp $");
 
 #include 
 #include 
@@ -1759,6 +1759,8 @@ pms_synaptics_input(void *vsc, int data)
 			return;
 		}
 	}
+	if (psc->inputstate >= sizeof(psc->packet))
+		panic("inputstate should never be %d", psc->inputstate);
 
 	psc->packet[psc->inputstate++] = data & 0xff;
 	if (psc->inputstate == 6) {



CVS commit: src/sys/dev/pckbport

2023-09-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Sep  5 05:55:12 UTC 2023

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

Log Message:
panic on an condition that shouldn't be possible.

appease GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/pckbport/pms.c
cvs rdiff -u -r1.81 -r1.82 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.



CVS commit: src/sys/dev/pckbport

2023-07-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jul 16 19:09:07 UTC 2023

Modified Files:
src/sys/dev/pckbport: pckbd.c pckbdreg.h

Log Message:
>From Vladimir 'phcoder' Serbinenko in tech-kern:

On at least some Chromebooks PS/2 reset command generates no
response and we end up reading garbage and disabling keyboard
support altogether even though that controller otherwise works
fine. Linux issues reset but ignores the reply and relies on
getid instead. So does Haiku. FreeB= SD assumes that all coreboot
systems have PS/2 which is wrong as it supports some MacBooks as
well. No idea what windows does but keyboard works there.

Also do some KNF while here.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/pckbport/pckbd.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pckbport/pckbdreg.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/pckbd.c
diff -u src/sys/dev/pckbport/pckbd.c:1.37 src/sys/dev/pckbport/pckbd.c:1.38
--- src/sys/dev/pckbport/pckbd.c:1.37	Fri Oct 28 19:40:37 2022
+++ src/sys/dev/pckbport/pckbd.c	Sun Jul 16 15:09:07 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pckbd.c,v 1.37 2022/10/28 23:40:37 riastradh Exp $ */
+/* $NetBSD: pckbd.c,v 1.38 2023/07/16 19:09:07 christos Exp $ */
 
 /*-
  * Copyright (c) 1998, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pckbd.c,v 1.37 2022/10/28 23:40:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pckbd.c,v 1.38 2023/07/16 19:09:07 christos Exp $");
 
 #include 
 #include 
@@ -124,8 +124,6 @@ struct pckbd_softc {
 #endif
 };
 
-static int pckbd_is_console(pckbport_tag_t, pckbport_slot_t);
-
 int pckbdprobe(device_t, cfdata_t, void *);
 void pckbdattach(device_t, device_t, void *);
 
@@ -177,10 +175,6 @@ int	pckbd_init(struct pckbd_internal *, 
 			int);
 void	pckbd_input(void *, int);
 
-static int	pckbd_decode(struct pckbd_internal *, int, u_int *, int *);
-static int	pckbd_led_encode(int);
-static int	pckbd_led_decode(int);
-
 struct pckbd_internal pckbd_consdata;
 
 int
@@ -212,7 +206,7 @@ pckbd_set_xtscancode(pckbport_tag_t kbct
 		res = pckbport_poll_cmd(kbctag, kbcslot, cmd, 2, 0, 0, 0);
 		if (res) {
 			u_char cmdb[1];
-			aprint_debug("pckbd: error setting scanset 2\n");
+			aprint_debug("%s: error setting scanset 2\n", __func__);
 			/*
 			 * XXX at least one keyboard is reported to lock up
 			 * if a "set table" is attempted, thus the "reset".
@@ -220,7 +214,8 @@ pckbd_set_xtscancode(pckbport_tag_t kbct
 			 * default anyway.
 			 */
 			cmdb[0] = KBC_RESET;
-			(void)pckbport_poll_cmd(kbctag, kbcslot, cmdb, 1, 1, 0, 1);
+			(void)pckbport_poll_cmd(kbctag, kbcslot, cmdb, 1, 1,
+			0, 1);
 			pckbport_flush(kbctag, kbcslot);
 			res = 0;
 		}
@@ -236,7 +231,7 @@ pckbd_set_xtscancode(pckbport_tag_t kbct
 		cmd[1] = 1;
 		res = pckbport_poll_cmd(kbctag, kbcslot, cmd, 2, 0, 0, 0);
 		if (res)
-			aprint_debug("pckbd: error setting scanset 1\n");
+			aprint_debug("%s: error setting scanset 1\n", __func__);
 		if (id != NULL)
 			id->t_translating = 1;
 	}
@@ -262,8 +257,8 @@ pckbd_suspend(device_t dv, const pmf_qua
 	 * it even if it's the console kbd
 	 */
 	cmd[0] = KBC_DISABLE;
-	res = pckbport_enqueue_cmd(sc->id->t_kbctag,
-	sc->id->t_kbcslot, cmd, 1, 0, 1, 0);
+	res = pckbport_enqueue_cmd(sc->id->t_kbctag, sc->id->t_kbcslot,
+	cmd, 1, 0, 1, 0);
 	if (res)
 		return false;
 
@@ -300,8 +295,33 @@ pckbd_resume(device_t dv, const pmf_qual
 }
 
 /*
- * these are both bad jokes
+ * these are three bad jokes
  */
+static bool
+check_keyboard_by_id(struct pckbport_attach_args *pa)
+{
+	u_char cmd[1], resp[2];
+	int res;
+
+	cmd[0] = KBC_GETID;
+	res = pckbport_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 2, resp, 0);
+	if (res) {
+		aprint_debug("%s: getid failed with %d\n", __func__, res);
+		return false;
+	}
+
+	switch (resp[0]) {
+	case 0xab: case 0xac:	/* Regular and NCD Sun keyboards */
+	case 0x2b: case 0x5d:	/* Trust keyboard, raw and translated */
+	case 0x60: case 0x47:	/* NMB SGI keyboard, raw and translated */
+		return true;
+	default:
+		aprint_debug("%s: getid returned %#x\n", __func__, resp[0]);
+		return false;
+	}
+
+}
+
 int
 pckbdprobe(device_t parent, cfdata_t cf, void *aux)
 {
@@ -326,7 +346,22 @@ pckbdprobe(device_t parent, cfdata_t cf,
 	cmd[0] = KBC_RESET;
 	res = pckbport_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 1, resp, 1);
 	if (res) {
-		aprint_debug("pckbdprobe: reset error %d\n", res);
+		aprint_debug("%s: reset error %d\n", __func__, res);
+
+		/*
+		 * On Chromebooks reset fails but otherwise the controller
+		 * works fine.
+		 * Check keyboard IDs similar to Linux and Haiku.
+		 * FreeBSD's approach here is to skip probing if
+		 * coreboot is detected which is suboptimal as coreboot
+		 * also supports some mac models which have no PC controller
+		 */
+		if (check_keyboard_by_id(pa)) {
+			if 

CVS commit: src/sys/dev/pckbport

2023-07-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jul 16 19:09:07 UTC 2023

Modified Files:
src/sys/dev/pckbport: pckbd.c pckbdreg.h

Log Message:
>From Vladimir 'phcoder' Serbinenko in tech-kern:

On at least some Chromebooks PS/2 reset command generates no
response and we end up reading garbage and disabling keyboard
support altogether even though that controller otherwise works
fine. Linux issues reset but ignores the reply and relies on
getid instead. So does Haiku. FreeB= SD assumes that all coreboot
systems have PS/2 which is wrong as it supports some MacBooks as
well. No idea what windows does but keyboard works there.

Also do some KNF while here.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/pckbport/pckbd.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pckbport/pckbdreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pckbport

2022-09-28 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Sep 28 16:43:00 UTC 2022

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

Log Message:
synaptics: Lower scale factor to give less sluggish mouse performance
on modern displays.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 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.



CVS commit: src/sys/dev/pckbport

2022-09-28 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Sep 28 16:43:00 UTC 2022

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

Log Message:
synaptics: Lower scale factor to give less sluggish mouse performance
on modern displays.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 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.80 src/sys/dev/pckbport/synaptics.c:1.81
--- src/sys/dev/pckbport/synaptics.c:1.80	Sat Sep 17 06:33:55 2022
+++ src/sys/dev/pckbport/synaptics.c	Wed Sep 28 16:43:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.80 2022/09/17 06:33:55 mlelstv Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.81 2022/09/28 16:43:00 nia Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.80 2022/09/17 06:33:55 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.81 2022/09/28 16:43:00 nia Exp $");
 
 #include 
 #include 
@@ -119,8 +119,8 @@ static int synaptics_button_boundary;
 static int synaptics_button2;
 static int synaptics_button3;
 static int synaptics_two_fingers_emul = 0;
-static int synaptics_scale_x = 16;
-static int synaptics_scale_y = 16;
+static int synaptics_scale_x = 8;
+static int synaptics_scale_y = 8;
 static int synaptics_scale_z = 32;
 static int synaptics_max_speed_x = 32;
 static int synaptics_max_speed_y = 32;



CVS commit: src/sys/dev/pckbport

2022-09-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 17 06:33:55 UTC 2022

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

Log Message:
- synaptics_filter_policy no longer generates movements from stale data.
- button boundary is now computed consistently.
- multi finger operation now works for MULTI_FINGER and MULTI_FINGER_REPORT.

Fixes PR kern/56476 and probably kern/56998.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 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.79 src/sys/dev/pckbport/synaptics.c:1.80
--- src/sys/dev/pckbport/synaptics.c:1.79	Tue May 31 08:43:16 2022
+++ src/sys/dev/pckbport/synaptics.c	Sat Sep 17 06:33:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.79 2022/05/31 08:43:16 andvar Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.80 2022/09/17 06:33:55 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.79 2022/05/31 08:43:16 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.80 2022/09/17 06:33:55 mlelstv Exp $");
 
 #include 
 #include 
@@ -296,32 +296,33 @@ pms_synaptics_set_boundaries(void)
 	}
 
 	if (synaptics_button_pct != synaptics_old_button_pct) {
-		synaptics_button_boundary = synaptics_edge_bottom + 
-		((unsigned long) synaptics_button_pct * 
-		(synaptics_edge_top - synaptics_edge_bottom)) / 100;
 		synaptics_old_button_pct = synaptics_button_pct;
-		synaptics_old_button_boundary = synaptics_button_boundary;
 	}
 
 	if (synaptics_button_boundary != synaptics_old_button_boundary) {
 		if (synaptics_button_boundary <= synaptics_edge_bottom) {
 			synaptics_button_pct = 0;
-			synaptics_button_boundary = synaptics_edge_bottom;
+		} else if (synaptics_button_boundary >= synaptics_edge_top) {
+			synaptics_button_pct = 100;
 		} else {
-			synaptics_button_pct = 100 -
-			((unsigned long) 100 * synaptics_button_boundary) /
-			(synaptics_edge_top - synaptics_edge_bottom);
+			synaptics_button_pct =
+			(synaptics_button_boundary - synaptics_edge_bottom)
+			* 100
+			/ (synaptics_edge_top - synaptics_edge_bottom);
 		}
-		synaptics_old_button_boundary = synaptics_button_boundary;
+		synaptics_old_button_pct = synaptics_button_pct;
 	}
 
 	/*
-	 * recalculate the button boundary yet again just in case the
-	 * bottom edge changed above.
+	 * calculate the button boundary
 	 */
-	synaptics_button_boundary = synaptics_edge_bottom + 
-	((unsigned long) synaptics_button_pct * 
-	(synaptics_edge_top - synaptics_edge_bottom)) / 100;
+	if (synaptics_edge_top > synaptics_edge_bottom) {
+		synaptics_button_boundary = synaptics_edge_bottom + 
+		((unsigned long) synaptics_button_pct * 
+		(synaptics_edge_top - synaptics_edge_bottom)) / 100;
+	} else {
+		synaptics_button_boundary = synaptics_edge_bottom;
+	}
 	synaptics_old_button_boundary = synaptics_button_boundary;
 
 	synaptics_button2 = synaptics_edge_left +
@@ -1231,7 +1232,7 @@ pms_synaptics_get_fingers(struct pms_sof
 		 * just punt with one finger, if this really is a palm
 		 * then it will be caught later.
 		 */
-		if (sc->flags & SYN_FLAG_HAS_MULTI_FINGER) {
+		if (sc->flags & (SYN_FLAG_HAS_MULTI_FINGER | SYN_FLAG_HAS_MULTI_FINGER_REPORT)) {
 			if (w == SYNAPTICS_WIDTH_TWO_FINGERS)
 fingers = 2;
 			else if (w == SYNAPTICS_WIDTH_THREE_OR_MORE)
@@ -1636,75 +1637,13 @@ skip_position:
 	nsp.sp_primary, nsp.sp_secondary, v, primary_finger,
 	secondary_finger);
 
+	pms_synaptics_process_packet(psc, );
 
-	/* If no fingers and we at least saw the primary finger
-	 * or the buttons changed then process the last packet.
-	 */
-	if (pms_synaptics_get_fingers(psc, nsp.sp_w, nsp.sp_z) == 0 ||
-	nsp.sp_left != packet.sp_left ||
-	nsp.sp_right != packet.sp_right ||
-	nsp.sp_middle != packet.sp_middle ||
-	nsp.sp_up != packet.sp_up ||
-	nsp.sp_down != packet.sp_down) {
-		if (nsp.sp_primary == 1) {
-			pms_synaptics_process_packet(psc, );
-			sc->packet_count[SYN_PRIMARY_FINGER] = 0;
-			sc->packet_count[SYN_SECONDARY_FINGER] = 0;
-		}
-
-		/* clear the fingers seen since we have processed */
+	/* Clear fingers */
+	if ((nsp.sp_primary && nsp.sp_finger_count <= 1) || nsp.sp_secondary) {
 		nsp.sp_primary = 0;
 		nsp.sp_secondary = 0;
 		nsp.sp_finger_status = 0;
-	} else if (nsp.sp_finger_count != packet.sp_finger_count) {
-		/*
-		 * If the number of fingers changes then send the current packet
-		 * for processing and restart the process.
-		 */
-		if (packet.sp_primary == 1) {
-			pms_synaptics_process_packet(psc, );
-			sc->packet_count[SYN_PRIMARY_FINGER]++;
-		}
-
-		sc->packet_count[SYN_PRIMARY_FINGER] = 0;
-		sc->packet_count[SYN_SECONDARY_FINGER] = 0;
-	}
-
-	/* Only one finger, process the new packet 

CVS commit: src/sys/dev/pckbport

2022-09-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Sep 17 06:33:55 UTC 2022

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

Log Message:
- synaptics_filter_policy no longer generates movements from stale data.
- button boundary is now computed consistently.
- multi finger operation now works for MULTI_FINGER and MULTI_FINGER_REPORT.

Fixes PR kern/56476 and probably kern/56998.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 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.



CVS commit: src/sys/dev/pckbport

2022-04-04 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Apr  4 07:04:21 UTC 2022

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

Log Message:
Use the original right boundary when calculating the vertical scroll
region so the boundary does not creep left on each subsequent setting.
Thanks to Martin@ for the report.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 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.77 src/sys/dev/pckbport/synaptics.c:1.78
--- src/sys/dev/pckbport/synaptics.c:1.77	Fri Apr  1 06:31:29 2022
+++ src/sys/dev/pckbport/synaptics.c	Mon Apr  4 07:04:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.77 2022/04/01 06:31:29 blymn Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.78 2022/04/04 07:04:20 blymn Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.77 2022/04/01 06:31:29 blymn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.78 2022/04/04 07:04:20 blymn Exp $");
 
 #include 
 #include 
@@ -255,7 +255,8 @@ static void
 pms_synaptics_set_boundaries(void)
 {
 	if (synaptics_vert_pct != synaptics_old_vert_pct ) {
-		synaptics_edge_right -= ((unsigned long) synaptics_vert_pct *
+		synaptics_edge_right = synaptics_actual_edge_right -
+		((unsigned long) synaptics_vert_pct *
 		(synaptics_actual_edge_right - synaptics_edge_left)) / 100;
 		synaptics_old_vert_pct = synaptics_vert_pct;
 		synaptics_old_vert_edge = synaptics_edge_right;
@@ -270,6 +271,7 @@ pms_synaptics_set_boundaries(void)
 			((unsigned long) 100 * synaptics_edge_right) /
 			(synaptics_actual_edge_right - synaptics_edge_left);
 		}
+		synaptics_old_vert_pct = synaptics_vert_pct;
 		synaptics_old_vert_edge = synaptics_edge_right;
 	}
 



CVS commit: src/sys/dev/pckbport

2022-04-04 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Apr  4 07:04:21 UTC 2022

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

Log Message:
Use the original right boundary when calculating the vertical scroll
region so the boundary does not creep left on each subsequent setting.
Thanks to Martin@ for the report.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 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.



CVS commit: src/sys/dev/pckbport

2022-04-01 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Fri Apr  1 06:31:30 UTC 2022

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

Log Message:
Fix regression introduced when fixing PR kern/56613 and related tweaks

* A trackpad with external buttons needs to mask a number of lower bits
  of the X and Y coordinates IFF a button is down.  This was not being
  done so a button held down looked like an out of range packet and
  was therefore dropped.

* Now that trackpads are probed for their boundaries make the emulated
  button boundary settable by a percentage, also allow the right and
  bottom boundaries to be adjusted by a percentage to allow for
  horizontal and vertical scroll regions.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pckbport/synapticsvar.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.76 src/sys/dev/pckbport/synaptics.c:1.77
--- src/sys/dev/pckbport/synaptics.c:1.76	Thu Mar  3 21:03:14 2022
+++ src/sys/dev/pckbport/synaptics.c	Fri Apr  1 06:31:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.76 2022/03/03 21:03:14 blymn Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.77 2022/04/01 06:31:29 blymn Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.76 2022/03/03 21:03:14 blymn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.77 2022/04/01 06:31:29 blymn Exp $");
 
 #include 
 #include 
@@ -112,9 +112,12 @@ static int synaptics_edge_bottom = SYNAP
 static int synaptics_edge_motion_delta = 32;
 static u_int synaptics_finger_high = SYNAPTICS_FINGER_LIGHT + 5;
 static u_int synaptics_finger_low = SYNAPTICS_FINGER_LIGHT - 10;
-static int synaptics_button_boundary = SYNAPTICS_EDGE_BOTTOM + 720;
-static int synaptics_button2 = SYNAPTICS_EDGE_LEFT + (SYNAPTICS_EDGE_RIGHT - SYNAPTICS_EDGE_LEFT) / 3;
-static int synaptics_button3 = SYNAPTICS_EDGE_LEFT + 2 * (SYNAPTICS_EDGE_RIGHT - SYNAPTICS_EDGE_LEFT) / 3;
+static int synaptics_horiz_pct = 0;
+static int synaptics_vert_pct = 0;
+static int synaptics_button_pct = 30;
+static int synaptics_button_boundary;
+static int synaptics_button2;
+static int synaptics_button3;
 static int synaptics_two_fingers_emul = 0;
 static int synaptics_scale_x = 16;
 static int synaptics_scale_y = 16;
@@ -163,6 +166,23 @@ static int synaptics_movement_threshold_
 static int synaptics_movement_enable_nodenum;
 static int synaptics_button_region_movement_nodenum;
 static int synaptics_aux_mid_button_scroll_nodenum;
+static int synaptics_horiz_pct_nodenum;
+static int synaptics_vert_pct_nodenum;
+static int synaptics_button_pct_nodenum;
+
+/*
+ * copy of edges so we can recalculate edge limit if there is 
+ * vertical scroll region
+ */
+static int synaptics_actual_edge_right;
+static int synaptics_actual_edge_bottom;
+
+static int synaptics_old_vert_pct = 0;
+static int synaptics_old_horiz_pct = 0;
+static int synaptics_old_button_pct = 0;
+static int synaptics_old_button_boundary = SYNAPTICS_EDGE_BOTTOM;
+static int synaptics_old_horiz_edge = SYNAPTICS_EDGE_BOTTOM;
+static int synaptics_old_vert_edge = SYNAPTICS_EDGE_RIGHT;
 
 /*
  * This holds the processed packet data, it is global because multiple
@@ -232,6 +252,84 @@ synaptics_special_write(struct pms_softc
 }
 
 static void
+pms_synaptics_set_boundaries(void)
+{
+	if (synaptics_vert_pct != synaptics_old_vert_pct ) {
+		synaptics_edge_right -= ((unsigned long) synaptics_vert_pct *
+		(synaptics_actual_edge_right - synaptics_edge_left)) / 100;
+		synaptics_old_vert_pct = synaptics_vert_pct;
+		synaptics_old_vert_edge = synaptics_edge_right;
+	}
+
+	if (synaptics_edge_right != synaptics_old_vert_edge) {
+		if (synaptics_edge_right >= synaptics_actual_edge_right) {
+			synaptics_vert_pct = 0;
+			synaptics_edge_right = synaptics_actual_edge_right;
+		} else {
+			synaptics_vert_pct = 100 -
+			((unsigned long) 100 * synaptics_edge_right) /
+			(synaptics_actual_edge_right - synaptics_edge_left);
+		}
+		synaptics_old_vert_edge = synaptics_edge_right;
+	}
+
+	if (synaptics_horiz_pct != synaptics_old_horiz_pct ) {
+		synaptics_edge_bottom = synaptics_actual_edge_bottom +
+		((unsigned long) synaptics_horiz_pct *
+		(synaptics_edge_top - synaptics_actual_edge_bottom)) / 100;
+		synaptics_old_horiz_pct = synaptics_horiz_pct;
+		synaptics_old_horiz_edge = synaptics_edge_bottom;
+	}
+
+	if (synaptics_edge_bottom != synaptics_old_horiz_edge) {
+		if (synaptics_edge_bottom <= synaptics_actual_edge_bottom) {
+			synaptics_vert_pct = 0;
+			synaptics_edge_bottom = synaptics_actual_edge_bottom;
+		} else {
+			synaptics_horiz_pct = 100 -
+			((unsigned long) 100 * synaptics_edge_bottom) /
+			(synaptics_edge_top - 

CVS commit: src/sys/dev/pckbport

2022-04-01 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Fri Apr  1 06:31:30 UTC 2022

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

Log Message:
Fix regression introduced when fixing PR kern/56613 and related tweaks

* A trackpad with external buttons needs to mask a number of lower bits
  of the X and Y coordinates IFF a button is down.  This was not being
  done so a button held down looked like an out of range packet and
  was therefore dropped.

* Now that trackpads are probed for their boundaries make the emulated
  button boundary settable by a percentage, also allow the right and
  bottom boundaries to be adjusted by a percentage to allow for
  horizontal and vertical scroll regions.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pckbport/synapticsvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pckbport

2022-03-03 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Mar  3 21:03:14 UTC 2022

Modified Files:
src/sys/dev/pckbport: synaptics.c synapticsreg.h synapticsvar.h

Log Message:
Fix for PR kern/56613

* For trackpads that report max and min coordinates, retrieve these and
  use them as the boundaries instead of the hard coded limits.
* Drop packets that are have x/y values that are outside the limits of
  the trackpad.  Some trackpads report a stream of low values in some
  situations that cause cursor jumping.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pckbport/synapticsreg.h \
src/sys/dev/pckbport/synapticsvar.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.75 src/sys/dev/pckbport/synaptics.c:1.76
--- src/sys/dev/pckbport/synaptics.c:1.75	Sat Dec  4 14:53:56 2021
+++ src/sys/dev/pckbport/synaptics.c	Thu Mar  3 21:03:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.75 2021/12/04 14:53:56 nia Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.76 2022/03/03 21:03:14 blymn Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.75 2021/12/04 14:53:56 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.76 2022/03/03 21:03:14 blymn Exp $");
 
 #include 
 #include 
@@ -342,6 +342,12 @@ pms_synaptics_probe_extended(struct pms_
 
 			if ((val & SYN_CCAP_HAS_ADV_GESTURE_MODE))
 sc->flags |= SYN_FLAG_HAS_ADV_GESTURE_MODE;
+
+			if ((val & SYN_CCAP_REPORT_MAX))
+sc->flags |= SYN_FLAG_HAS_MAX_REPORT;
+
+			if ((val & SYN_CCAP_REPORT_MIN))
+sc->flags |= SYN_FLAG_HAS_MIN_REPORT;
 		}
 	}
 }
@@ -362,6 +368,8 @@ static const struct {
 	{ SYN_FLAG_HAS_HORIZONTAL_SCROLL, "Horizontal scroll", },
 	{ SYN_FLAG_HAS_MULTI_FINGER_REPORT, "Multi-finger Report", },
 	{ SYN_FLAG_HAS_MULTI_FINGER, "Multi-finger", },
+	{ SYN_FLAG_HAS_MAX_REPORT, "Reports max", },
+	{ SYN_FLAG_HAS_MIN_REPORT, "Reports min", },
 };
 
 int
@@ -444,6 +452,42 @@ pms_synaptics_probe_init(void *vsc)
 		aprint_normal("\n");
 	}
 
+	if (sc->flags & SYN_FLAG_HAS_MAX_REPORT) {
+		res = synaptics_special_read(psc, SYNAPTICS_READ_MAX_COORDS,
+		resp);
+		if (res) {
+			aprint_error_dev(psc->sc_dev,
+			"synaptics_probe: Failed to query max coords.\n");
+		} else {
+			synaptics_edge_right = (resp[0] << 5) +
+			((resp[1] & 0x0f) << 1);
+			synaptics_edge_top = (resp[2] << 5) + 
+			((resp[1] & 0xf0) >> 3);
+
+			aprint_normal_dev(psc->sc_dev,
+			"Probed max coordinates right: %d, top: %d\n",
+			synaptics_edge_right, synaptics_edge_top);
+		}
+	}
+
+	if (sc->flags & SYN_FLAG_HAS_MIN_REPORT) {
+		res = synaptics_special_read(psc, SYNAPTICS_READ_MIN_COORDS,
+		resp);
+		if (res) {
+			aprint_error_dev(psc->sc_dev,
+			"synaptics_probe: Failed to query min coords.\n");
+		} else {
+			synaptics_edge_left = (resp[0] << 5) +
+			((resp[1] & 0x0f) << 1);
+			synaptics_edge_bottom = (resp[2] << 5) + 
+			((resp[1] & 0xf0) >> 3);
+
+			aprint_normal_dev(psc->sc_dev,
+			"Probed min coordinates left: %d, bottom: %d\n",
+			synaptics_edge_left, synaptics_edge_bottom);
+		}
+	}
+
 done:
 	pms_sysctl_synaptics();
 	pckbport_set_inputhandler(psc->sc_kbctag, psc->sc_kbcslot,
@@ -1068,6 +1112,27 @@ pms_synaptics_parse(struct pms_softc *ps
 			nsp.sp_sz = (psc->packet[3] & 0x30)
 			+ ((psc->packet[5] & 0x0e) << 1);
 
+			/*
+			 * Check if the x and y are non-zero that they
+			 * are within the bounds of the trackpad
+			 * otherwise ignore the packet.
+			 */
+			if (((nsp.sp_sx != 0) &&
+			((nsp.sp_sx < synaptics_edge_left) ||
+			 (nsp.sp_sx > synaptics_edge_right))) ||
+			   ((nsp.sp_sy != 0) &&
+			((nsp.sp_sy < synaptics_edge_bottom) ||
+			 (nsp.sp_sy > synaptics_edge_top {
+sc->gesture_type = 0;
+sc->gesture_buttons = 0;
+sc->total_packets--;
+DPRINTF(20, sc,
+"synaptics_parse: dropping out of bounds "
+"packet sp_sx %d sp_sy %d\n",
+nsp.sp_sx, nsp.sp_sy);
+return;
+			}
+
 			/* work out the virtual finger width */
 			v = 8 + (psc->packet[1] & 0x01) +
 ((psc->packet[2] & 0x01) << 1) +
@@ -1152,6 +1217,27 @@ pms_synaptics_parse(struct pms_softc *ps
 			nsp.sp_z = psc->packet[2];
 		}
 
+		/*
+		 * Check if the x and y are non-zero that they
+		 * are within the bounds of the trackpad
+		 * otherwise ignore the packet.
+		 */
+		if (((nsp.sp_x != 0) &&
+		((nsp.sp_x < synaptics_edge_left) ||
+		 (nsp.sp_x > synaptics_edge_right))) ||
+		((nsp.sp_y != 0) &&
+		((nsp.sp_y < synaptics_edge_bottom) ||
+		 (nsp.sp_y > synaptics_edge_top {
+			sc->gesture_type = 0;
+			sc->gesture_buttons = 0;
+			sc->total_packets--;
+			DPRINTF(20, sc,
+			

CVS commit: src/sys/dev/pckbport

2022-03-03 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Mar  3 21:03:14 UTC 2022

Modified Files:
src/sys/dev/pckbport: synaptics.c synapticsreg.h synapticsvar.h

Log Message:
Fix for PR kern/56613

* For trackpads that report max and min coordinates, retrieve these and
  use them as the boundaries instead of the hard coded limits.
* Drop packets that are have x/y values that are outside the limits of
  the trackpad.  Some trackpads report a stream of low values in some
  situations that cause cursor jumping.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pckbport/synapticsreg.h \
src/sys/dev/pckbport/synapticsvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pckbport

2021-12-04 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Dec  4 14:53:56 UTC 2021

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

Log Message:
synaptics: Fix tracking of extended buttons.

- Ensure that packets are processed whenever any button change
  occurs, instead of just processing packets when there is movement
  or trackpad finger activity
- Only transfer the state of the "extended buttons" to the button
  masks when actual changes occur OR a button is being held down.

With this patch, my middle mouse button no longer gets "stuck down",
but proper press/release tracking and dragging behavior is preserved.

Thanks to blymn for pointers.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 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.



CVS commit: src/sys/dev/pckbport

2021-12-04 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Dec  4 14:53:56 UTC 2021

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

Log Message:
synaptics: Fix tracking of extended buttons.

- Ensure that packets are processed whenever any button change
  occurs, instead of just processing packets when there is movement
  or trackpad finger activity
- Only transfer the state of the "extended buttons" to the button
  masks when actual changes occur OR a button is being held down.

With this patch, my middle mouse button no longer gets "stuck down",
but proper press/release tracking and dragging behavior is preserved.

Thanks to blymn for pointers.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 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.74 src/sys/dev/pckbport/synaptics.c:1.75
--- src/sys/dev/pckbport/synaptics.c:1.74	Fri Dec  3 13:27:39 2021
+++ src/sys/dev/pckbport/synaptics.c	Sat Dec  4 14:53:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.74 2021/12/03 13:27:39 andvar Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.75 2021/12/04 14:53:56 nia Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.74 2021/12/03 13:27:39 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.75 2021/12/04 14:53:56 nia Exp $");
 
 #include 
 #include 
@@ -1031,6 +1031,8 @@ pms_synaptics_parse(struct pms_softc *ps
 	struct synaptics_packet nsp;
 	char new_buttons, ew_mode;
 	unsigned v, primary_finger, secondary_finger;
+	int ext_left = -1, ext_right = -1, ext_middle = -1,
+	ext_up = -1, ext_down = -1;
 
 	sc->total_packets++;
 
@@ -1177,29 +1179,29 @@ pms_synaptics_parse(struct pms_softc *ps
 			psc->packet[3], psc->packet[4], psc->packet[5]);
 
 			if ((psc->packet[4] & SYN_1BUTMASK) != 0)
-sc->ext_left = PMS_LBUTMASK;
+ext_left = PMS_LBUTMASK;
 			else
-sc->ext_left = 0;
+ext_left = 0;
 
 			if ((psc->packet[4] & SYN_3BUTMASK) != 0)
-sc->ext_middle = PMS_MBUTMASK;
+ext_middle = PMS_MBUTMASK;
 			else
-sc->ext_middle = 0;
+ext_middle = 0;
 
 			if ((psc->packet[5] & SYN_2BUTMASK) != 0)
-sc->ext_right = PMS_RBUTMASK;
+ext_right = PMS_RBUTMASK;
 			else
-sc->ext_right = 0;
+ext_right = 0;
 
 			if ((psc->packet[5] & SYN_4BUTMASK) != 0)
-sc->ext_up = 1;
+ext_up = 1;
 			else
-sc->ext_up = 0;
+ext_up = 0;
 
 			if ((psc->packet[4] & SYN_5BUTMASK) != 0)
-sc->ext_down = 1;
+ext_down = 1;
 			else
-sc->ext_down = 0;
+ext_down = 0;
 		} else {
 			/* Left/Right button handling. */
 			nsp.sp_left = psc->packet[0] & PMS_LBUTMASK;
@@ -1275,16 +1277,38 @@ pms_synaptics_parse(struct pms_softc *ps
 			/* Old style Middle Button. */
 			nsp.sp_middle = (psc->packet[0] & PMS_LBUTMASK) ^
 			(psc->packet[3] & PMS_LBUTMASK);
-		} else if (synaptics_up_down_emul != 1) {
+		} else {
 			nsp.sp_middle = 0;
 		}
 
-		/* Overlay extended button state */
-		nsp.sp_left |= sc->ext_left;
-		nsp.sp_right |= sc->ext_right;
-		nsp.sp_middle |= sc->ext_middle;
-		nsp.sp_up |= sc->ext_up;
-		nsp.sp_down |= sc->ext_down;
+		/*
+		 * Overlay extended button state if anything changed,
+		 * preserve the state if a button is being held.
+		 */
+		if (ext_left != -1)
+			nsp.sp_left = sc->ext_left = ext_left;
+		else if (sc->ext_left != 0)
+			nsp.sp_left = sc->ext_left;
+
+		if (ext_right != -1)
+			nsp.sp_right = sc->ext_right = ext_right;
+		else if (sc->ext_right != 0)
+			nsp.sp_right = sc->ext_right;
+
+		if (ext_middle != -1)
+			nsp.sp_middle = sc->ext_middle = ext_middle;
+		else if (sc->ext_middle != 0)
+			nsp.sp_middle = sc->ext_middle;
+
+		if (ext_up != -1)
+			nsp.sp_up = sc->ext_up = ext_up;
+		else if (sc->ext_up != 0)
+			nsp.sp_up = sc->ext_up;
+
+		if (ext_down != -1)
+			nsp.sp_down = sc->ext_down = ext_down;
+		else if (sc->ext_down != 0)
+			nsp.sp_down = sc->ext_down;
 
 		switch (synaptics_up_down_emul) {
 		case 1:
@@ -1328,7 +1352,12 @@ skip_position:
 	/* If no fingers and we at least saw the primary finger
 	 * or the buttons changed then process the last packet.
 	 */
-	if (pms_synaptics_get_fingers(psc, nsp.sp_w, nsp.sp_z) == 0) {
+	if (pms_synaptics_get_fingers(psc, nsp.sp_w, nsp.sp_z) == 0 ||
+	nsp.sp_left != packet.sp_left ||
+	nsp.sp_right != packet.sp_right ||
+	nsp.sp_middle != packet.sp_middle ||
+	nsp.sp_up != packet.sp_up ||
+	nsp.sp_down != packet.sp_down) {
 		if (nsp.sp_primary == 1) {
 			pms_synaptics_process_packet(psc, );
 			sc->packet_count[SYN_PRIMARY_FINGER] = 0;



CVS commit: src/sys/dev/pckbport

2021-10-20 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Oct 21 04:49:28 UTC 2021

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

Log Message:
Significant update to the synaptics touchpad driver.

* Accumulate packets for primary, secondary, finger count packets
  before handing off to pms_synaptics_process_packet.  This means
  that both primary and, possibly, secondary finger locations will
  be processed at the same time.  Previously the processing each
  packet as it arrived.

* Fix the secondary finger position reporting, there was an off by
  one in the shifts when decoding which effectively halved the
  reported position.

* For a clickpad, make the emulated button region "dead" so that finger
  movements in this region are ignored.  This makes it easier to click
  a button without accidentally repositioning the cursor.  There is a
  sysctl variable "button_region_movement_enable" that will allow
  these finger movements to be reported if this is desirable.

* Reset the finger ballistics when the number of fingers changes.  This
  stops the annoying position jumps when a second finger touch is added
  to or removed from the touchpad.

* Add a level argument to the DPRINTF macro so one can choose their
  level of debug spam via the debug sysctl variable.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pckbport/synapticsvar.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.72 src/sys/dev/pckbport/synaptics.c:1.73
--- src/sys/dev/pckbport/synaptics.c:1.72	Tue Sep 28 06:16:13 2021
+++ src/sys/dev/pckbport/synaptics.c	Thu Oct 21 04:49:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.72 2021/09/28 06:16:13 nia Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.73 2021/10/21 04:49:28 blymn Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.72 2021/09/28 06:16:13 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.73 2021/10/21 04:49:28 blymn Exp $");
 
 #include 
 #include 
@@ -79,11 +79,14 @@ struct synaptics_packet {
 	signed short	sp_x;	/* Unscaled absolute X/Y coordinates */
 	signed short	sp_y;
 	u_char	sp_z;		/* Z (pressure) */
+	signed short	sp_sx;	/* Unscaled absolute X/Y coordinates */
+	signed short	sp_sy;  /* for secondary finger */
+	u_char	sp_sz;		/* Z (pressure) */
 	u_char	sp_w;		/* W (contact patch width) */
-	signed short	sp_sx;	/* Secondary finger unscaled absolute */
-/* X/Y coordinates */
-	signed short	sp_xy;
-	u_char	sp_finger;	/* 0 for primary, 1 for secondary */
+	u_char  sp_primary;	/* seen primary finger packet */
+	u_char  sp_secondary;	/* seen secondary finger packet */
+	u_char	sp_finger_status; /* seen extended finger packet */
+	u_char	sp_finger_count; /* number of fingers seen */
 	char	sp_left;	/* Left mouse button status */
 	char	sp_right;	/* Right mouse button status */
 	char	sp_middle;	/* Middle button status (possibly emulated) */
@@ -121,12 +124,13 @@ static int synaptics_max_speed_y = 32;
 static int synaptics_max_speed_z = 2;
 static int synaptics_movement_threshold = 4;
 static int synaptics_movement_enable = 1;
+static int synaptics_button_region_movement = 1;
 static bool synaptics_aux_mid_button_scroll = TRUE;
 static int synaptics_debug = 0;
 
-#define	DPRINTF(SC, FMT, ARGS...) do	  \
+#define	DPRINTF(LEVEL, SC, FMT, ARGS...) do	  \
 {	  \
-	if (synaptics_debug) {		  \
+	if (synaptics_debug >= LEVEL) {		  \
 		struct pms_softc *_dprintf_psc =			  \
 		container_of((SC), struct pms_softc, u.synaptics);	  \
 		device_printf(_dprintf_psc->sc_dev, FMT, ##ARGS);	  \
@@ -157,8 +161,16 @@ static int synaptics_max_speed_y_nodenum
 static int synaptics_max_speed_z_nodenum;
 static int synaptics_movement_threshold_nodenum;
 static int synaptics_movement_enable_nodenum;
+static int synaptics_button_region_movement_nodenum;
 static int synaptics_aux_mid_button_scroll_nodenum;
 
+/*
+ * This holds the processed packet data, it is global because multiple
+ * packets from the trackpad may be processed when handling multiple
+ * fingers on the trackpad to gather all the data.
+ */
+static struct synaptics_packet packet;
+
 static int
 synaptics_poll_cmd(struct pms_softc *psc, ...)
 {
@@ -490,6 +502,10 @@ pms_synaptics_enable(void *vsc)
 	(sc->flags & SYN_FLAG_HAS_ADV_GESTURE_MODE))
 		synaptics_special_write(psc, SYNAPTICS_WRITE_DELUXE_3, 0x3); 
 
+	/* Disable motion in the button region for clickpads */
+	if(sc->flags & SYN_FLAG_HAS_ONE_BUTTON_CLICKPAD)
+		synaptics_button_region_movement = 0;
+
 	sc->up_down = 0;
 	sc->prev_fingers = 0;
 	sc->gesture_start_x = sc->gesture_start_y = 0;
@@ -497,11 +513,14 @@ 

CVS commit: src/sys/dev/pckbport

2021-10-20 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Oct 21 04:49:28 UTC 2021

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

Log Message:
Significant update to the synaptics touchpad driver.

* Accumulate packets for primary, secondary, finger count packets
  before handing off to pms_synaptics_process_packet.  This means
  that both primary and, possibly, secondary finger locations will
  be processed at the same time.  Previously the processing each
  packet as it arrived.

* Fix the secondary finger position reporting, there was an off by
  one in the shifts when decoding which effectively halved the
  reported position.

* For a clickpad, make the emulated button region "dead" so that finger
  movements in this region are ignored.  This makes it easier to click
  a button without accidentally repositioning the cursor.  There is a
  sysctl variable "button_region_movement_enable" that will allow
  these finger movements to be reported if this is desirable.

* Reset the finger ballistics when the number of fingers changes.  This
  stops the annoying position jumps when a second finger touch is added
  to or removed from the touchpad.

* Add a level argument to the DPRINTF macro so one can choose their
  level of debug spam via the debug sysctl variable.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pckbport/synapticsvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pckbport

2021-09-28 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Sep 28 06:16:13 UTC 2021

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

Log Message:
synaptics: use the new WSCONS_EVENT_(H|V)SCROLL event types
to implement two-finger scrolling. remove non-functional code for
detecting reported finger width.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 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.



CVS commit: src/sys/dev/pckbport

2021-09-28 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Sep 28 06:16:13 UTC 2021

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

Log Message:
synaptics: use the new WSCONS_EVENT_(H|V)SCROLL event types
to implement two-finger scrolling. remove non-functional code for
detecting reported finger width.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 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.71 src/sys/dev/pckbport/synaptics.c:1.72
--- src/sys/dev/pckbport/synaptics.c:1.71	Sun May 30 13:20:01 2021
+++ src/sys/dev/pckbport/synaptics.c	Tue Sep 28 06:16:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.71 2021/05/30 13:20:01 riastradh Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.72 2021/09/28 06:16:13 nia Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.71 2021/05/30 13:20:01 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.72 2021/09/28 06:16:13 nia Exp $");
 
 #include 
 #include 
@@ -120,9 +120,6 @@ static int synaptics_max_speed_x = 32;
 static int synaptics_max_speed_y = 32;
 static int synaptics_max_speed_z = 2;
 static int synaptics_movement_threshold = 4;
-static int synaptics_fscroll_min = 13;
-static int synaptics_fscroll_max = 14;
-static int synaptics_dz_hold = 30;
 static int synaptics_movement_enable = 1;
 static bool synaptics_aux_mid_button_scroll = TRUE;
 static int synaptics_debug = 0;
@@ -159,9 +156,6 @@ static int synaptics_max_speed_x_nodenum
 static int synaptics_max_speed_y_nodenum;
 static int synaptics_max_speed_z_nodenum;
 static int synaptics_movement_threshold_nodenum;
-static int synaptics_finger_scroll_min_nodenum;
-static int synaptics_finger_scroll_max_nodenum;
-static int synaptics_dz_hold_nodenum;
 static int synaptics_movement_enable_nodenum;
 static int synaptics_aux_mid_button_scroll_nodenum;
 
@@ -503,7 +497,6 @@ pms_synaptics_enable(void *vsc)
 	sc->gesture_tap_packet = 0;
 	sc->gesture_type = 0;
 	sc->gesture_buttons = 0;
-	sc->dz_hold = 0;
 	for (i = 0; i < SYN_MAX_FINGERS; i++) {
 		sc->rem_x[i] = sc->rem_y[i] = sc->rem_z[i] = 0;
 		sc->movement_history[i] = 0;
@@ -809,42 +802,6 @@ pms_sysctl_synaptics(struct sysctllog **
 
 	if ((rc = sysctl_createv(clog, 0, NULL, ,
 	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
-	CTLTYPE_INT, "finger_scroll-min",
-	SYSCTL_DESCR("Minimum width at which y cursor movements will be converted to scroll wheel events"),
-	pms_sysctl_synaptics_verify, 0,
-	_fscroll_min,
-	0, CTL_HW, root_num, CTL_CREATE,
-	CTL_EOL)) != 0)
-		goto err;
-
-	synaptics_finger_scroll_min_nodenum = node->sysctl_num;
-
-	if ((rc = sysctl_createv(clog, 0, NULL, ,
-	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
-	CTLTYPE_INT, "finger_scroll-max",
-	SYSCTL_DESCR("Maximum width at which y cursor movements will be converted to scroll wheel events"),
-	pms_sysctl_synaptics_verify, 0,
-	_fscroll_max,
-	0, CTL_HW, root_num, CTL_CREATE,
-	CTL_EOL)) != 0)
-		goto err;
-
-	synaptics_finger_scroll_max_nodenum = node->sysctl_num;
-
-	if ((rc = sysctl_createv(clog, 0, NULL, ,
-	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
-	CTLTYPE_INT, "finger_scroll-hysteresis",
-	SYSCTL_DESCR("Number of packets to keep reporting y cursor movements as scroll wheel events"),
-	pms_sysctl_synaptics_verify, 0,
-	_dz_hold,
-	0, CTL_HW, root_num, CTL_CREATE,
-	CTL_EOL)) != 0)
-		goto err;
-
-	synaptics_dz_hold_nodenum = node->sysctl_num;
-
-	if ((rc = sysctl_createv(clog, 0, NULL, ,
-	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
 	CTLTYPE_BOOL, "aux_mid_button_scroll",
 	SYSCTL_DESCR("Interpet Y-Axis movement with the middle button held as scrolling on the passthrough device (e.g. TrackPoint)"),
 	pms_sysctl_synaptics_verify, 0,
@@ -943,17 +900,6 @@ pms_sysctl_synaptics_verify(SYSCTLFN_ARG
 		if (t < SYNAPTICS_EDGE_LEFT || t > SYNAPTICS_EDGE_RIGHT)
 			return (EINVAL);
 	} else
-	if (node.sysctl_num == synaptics_finger_scroll_min_nodenum ||
-	node.sysctl_num == synaptics_finger_scroll_max_nodenum) {
-		/* make sure we avoid the "magic" widths, 4 and below
-		   are for fingers, 15 is palm detect. */
-		if ((t < 5) || (t > 14))
-			return (EINVAL);
-	} else
-	if (node.sysctl_num == synaptics_dz_hold_nodenum) {
-		if (t < 0)
-			return (EINVAL);
-	} else
 	if (node.sysctl_num == synaptics_movement_enable_nodenum) {
 		if (t < 0 || t > 1)
 			return (EINVAL);
@@ -1213,20 +1159,20 @@ pms_synaptics_passthrough(struct pms_sof
 	psc->buttons ^= changed;
 
 	if (dx || dy || dz || changed) {
+		s = spltty();
 		/*
-		 * If the middle button is held, interpret Y-axis
-		 * movement as scrolling.
+		 * If the middle button is held, interpret movement as
+		 * scrolling.
 		 */
 		if 

Re: CVS commit: src/sys/dev/pckbport

2020-02-26 Thread Izumi Tsutsui
> Modified Files:
>   src/sys/dev/pckbport: synaptics.c
> 
> Log Message:
> Messages in pms_synaptics_input() should not start with "pms_input"
> 
> Use "pms_synaptics_input" instead.

Maybe it's better to use ("%s", __func__) C99 predefined identifier.

---
Izumi Tsutsui


CVS commit: src/sys/dev/pckbport

2019-07-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jul 23 12:28:52 UTC 2019

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

Log Message:
pckbd_cngetc: Set type=0 and return if no data is available


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pckbport/pckbd.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/pckbd.c
diff -u src/sys/dev/pckbport/pckbd.c:1.33 src/sys/dev/pckbport/pckbd.c:1.34
--- src/sys/dev/pckbport/pckbd.c:1.33	Sun Jun 11 03:55:56 2017
+++ src/sys/dev/pckbport/pckbd.c	Tue Jul 23 12:28:52 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: pckbd.c,v 1.33 2017/06/11 03:55:56 nat Exp $ */
+/* $NetBSD: pckbd.c,v 1.34 2019/07/23 12:28:52 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 1998, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pckbd.c,v 1.33 2017/06/11 03:55:56 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pckbd.c,v 1.34 2019/07/23 12:28:52 jmcneill Exp $");
 
 #include 
 #include 
@@ -1094,8 +1094,11 @@ pckbd_cngetc(void *v, u_int *type, int *
 
 	for (;;) {
 		val = pckbport_poll_data(t->t_kbctag, t->t_kbcslot);
-		if (val == -1)
-			continue;
+		if (val == -1) {
+			*type = 0;
+			*data = 0;
+			return;
+		}
 
 		val = pckbd_scancode_translate(t, val);
 		if (val == 0)



CVS commit: src/sys/dev/pckbport

2019-07-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jul 23 12:28:52 UTC 2019

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

Log Message:
pckbd_cngetc: Set type=0 and return if no data is available


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pckbport/pckbd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pckbport

2019-07-22 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Mon Jul 22 09:58:39 UTC 2019

Modified Files:
src/sys/dev/pckbport: files.pckbport

Log Message:
hvkbd requires pckbd_keydesctab in wskbdmap_mfii.c.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pckbport/files.pckbport

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pckbport

2019-07-22 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Mon Jul 22 09:58:39 UTC 2019

Modified Files:
src/sys/dev/pckbport: files.pckbport

Log Message:
hvkbd requires pckbd_keydesctab in wskbdmap_mfii.c.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pckbport/files.pckbport

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/files.pckbport
diff -u src/sys/dev/pckbport/files.pckbport:1.9 src/sys/dev/pckbport/files.pckbport:1.10
--- src/sys/dev/pckbport/files.pckbport:1.9	Sun Aug 13 08:49:27 2017
+++ src/sys/dev/pckbport/files.pckbport	Mon Jul 22 09:58:39 2019
@@ -1,4 +1,4 @@
-# $NetBSD: files.pckbport,v 1.9 2017/08/13 08:49:27 christos Exp $
+# $NetBSD: files.pckbport,v 1.10 2019/07/22 09:58:39 nakayama Exp $
 # devices attached at pckbport, for use with wscons
 
 defflag	opt_wskbdmap.h			WSKBD_USONLY
@@ -9,7 +9,7 @@ file	dev/pckbport/pckbport.c		pckbport |
 device	pckbd: wskbddev
 attach	pckbd at pckbport
 file	dev/pckbport/pckbd.c		pckbd			needs-flag
-file	dev/pckbport/wskbdmap_mfii.c	pckbd
+file	dev/pckbport/wskbdmap_mfii.c	pckbd | hvkbd
 defparam PCKBD_LAYOUT
 defflag	PCKBD_CNATTACH_MAY_FAIL
 



CVS commit: src/sys/dev/pckbport

2019-07-04 Thread Michael van Elst
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 
-__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 
 #include 
@@ -1154,7 +1154,7 @@ pms_synaptics_input(void *vsc, int data)
 
 	getmicrouptime(>current);
 
-	if (psc->inputstate > 0) {
+	if (psc->inputstate != 0) {
 		timersub(>current, >last, );
 		if (diff.tv_sec > 0 || diff.tv_usec >= 4) {
 			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,



CVS commit: src/sys/dev/pckbport

2019-07-04 Thread Michael van Elst
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.



CVS commit: src/sys/dev/pckbport

2019-06-02 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Sun Jun  2 08:55:00 UTC 2019

Modified Files:
src/sys/dev/pckbport: synaptics.c synapticsreg.h synapticsvar.h

Log Message:
Changes based on code from an anonymous contributor.  This should make
trackpads work for Thinkpads.  Also adds code to handle externally
connected buttons (synaptics parlance), the first five are mapped to
mouse buttons 1-5.  The rest are currently not reported but could be
decoded if required.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pckbport/synapticsreg.h
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pckbport/synapticsvar.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.48 src/sys/dev/pckbport/synaptics.c:1.49
--- src/sys/dev/pckbport/synaptics.c:1.48	Mon Apr 22 00:53:59 2019
+++ src/sys/dev/pckbport/synaptics.c	Sun Jun  2 08:55:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.48 2019/04/22 00:53:59 blymn Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.49 2019/06/02 08:55:00 blymn Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.48 2019/04/22 00:53:59 blymn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.49 2019/06/02 08:55:00 blymn Exp $");
 
 #include 
 #include 
@@ -321,6 +321,9 @@ pms_synaptics_probe_extended(struct pms_
 /* unreached */
 break;
 			}
+
+			if ((val & SYN_CCAP_HAS_ADV_GESTURE_MODE))
+sc->flags |= SYN_FLAG_HAS_ADV_GESTURE_MODE;
 		}
 	}
 }
@@ -477,7 +480,8 @@ pms_synaptics_enable(void *vsc)
 		synaptics_poll_cmd(psc, PMS_SET_SCALE11, 0);
 
 	/* Set advanced gesture mode */
-	if (sc->flags & SYN_FLAG_HAS_EXTENDED_WMODE)
+	if ((sc->flags & SYN_FLAG_HAS_EXTENDED_WMODE) ||
+	(sc->flags & SYN_FLAG_HAS_ADV_GESTURE_MODE))
 		synaptics_special_write(psc, SYNAPTICS_WRITE_DELUXE_3, 0x3); 
 
 	synaptics_poll_cmd(psc, PMS_DEV_ENABLE, 0);
@@ -990,9 +994,33 @@ pms_synaptics_parse(struct pms_softc *ps
 		/* Pressure */
 		sp.sp_z = psc->packet[2];
 
-		/* Left/Right button handling. */
-		sp.sp_left = psc->packet[0] & PMS_LBUTMASK;
-		sp.sp_right = psc->packet[0] & PMS_RBUTMASK;
+		if ((psc->packet[0] ^ psc->packet[3]) & 0x02) {
+			/* extended buttons */
+
+			aprint_debug_dev(psc->sc_dev,
+			"synaptics_parse: %02x %02x %02x %02x %02x %02x\n",
+			psc->packet[0], psc->packet[1], psc->packet[2],
+			psc->packet[3], psc->packet[4], psc->packet[5]);
+
+			if ((psc->packet[4] & SYN_1BUTMASK) != 0)
+sp.sp_left = PMS_LBUTMASK;
+
+			if ((psc->packet[4] & SYN_3BUTMASK) != 0)
+sp.sp_middle = PMS_MBUTMASK;
+
+			if ((psc->packet[5] & SYN_2BUTMASK) != 0)
+sp.sp_right = PMS_RBUTMASK;
+
+			if ((psc->packet[5] & SYN_4BUTMASK) != 0)
+sp.sp_up = 1;
+
+			if ((psc->packet[4] & SYN_5BUTMASK) != 0)
+sp.sp_down = 1;
+		} else {
+			/* Left/Right button handling. */
+			sp.sp_left = psc->packet[0] & PMS_LBUTMASK;
+			sp.sp_right = psc->packet[0] & PMS_RBUTMASK;
+		}
 
 		/* Up/Down buttons. */
 		if (sc->flags & SYN_FLAG_HAS_BUTTONS_4_5) {

Index: src/sys/dev/pckbport/synapticsreg.h
diff -u src/sys/dev/pckbport/synapticsreg.h:1.11 src/sys/dev/pckbport/synapticsreg.h:1.12
--- src/sys/dev/pckbport/synapticsreg.h:1.11	Mon Apr 22 00:53:59 2019
+++ src/sys/dev/pckbport/synapticsreg.h	Sun Jun  2 08:55:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: synapticsreg.h,v 1.11 2019/04/22 00:53:59 blymn Exp $	*/
+/*	$NetBSD: synapticsreg.h,v 1.12 2019/06/02 08:55:00 blymn Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -101,6 +101,12 @@
 /* Extended mode button masks. */
 #define	SYN_1BUTMASK			0x1
 #define	SYN_2BUTMASK			0x1
+#define	SYN_3BUTMASK			0x2
+#define	SYN_4BUTMASK			0x2
+#define	SYN_5BUTMASK			0x4
+#define	SYN_6BUTMASK			0x4
+#define	SYN_7BUTMASK			0x8
+#define	SYN_8BUTMASK			0x8
 
 /* Touchpad edge boundaries (Recommended values from Synaptics documentation) */
 #define	SYNAPTICS_EDGE_LEFT		1632

Index: src/sys/dev/pckbport/synapticsvar.h
diff -u src/sys/dev/pckbport/synapticsvar.h:1.8 src/sys/dev/pckbport/synapticsvar.h:1.9
--- src/sys/dev/pckbport/synapticsvar.h:1.8	Tue Nov  6 09:13:17 2018
+++ src/sys/dev/pckbport/synapticsvar.h	Sun Jun  2 08:55:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: synapticsvar.h,v 1.8 2018/11/06 09:13:17 blymn Exp $	*/
+/*	$NetBSD: synapticsvar.h,v 1.9 2019/06/02 08:55:00 blymn Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -54,6 +54,7 @@ struct synaptics_softc {
 #define	SYN_FLAG_HAS_ONE_BUTTON_CLICKPAD	(1 << 9)
 #define	SYN_FLAG_HAS_TWO_BUTTON_CLICKPAD	(1 << 10)
 #define	SYN_FLAG_HAS_EXTENDED_WMODE		(1 << 11)
+#define	SYN_FLAG_HAS_ADV_GESTURE_MODE		(1 << 12)
 
 	u_int	total_packets[2];	/* Total number of packets received */
 #define	SYN_TIME(sc,c,n)	(((sc)->total_packets[(n)] >= (c)) ?	\



CVS commit: src/sys/dev/pckbport

2019-06-02 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Sun Jun  2 08:55:00 UTC 2019

Modified Files:
src/sys/dev/pckbport: synaptics.c synapticsreg.h synapticsvar.h

Log Message:
Changes based on code from an anonymous contributor.  This should make
trackpads work for Thinkpads.  Also adds code to handle externally
connected buttons (synaptics parlance), the first five are mapped to
mouse buttons 1-5.  The rest are currently not reported but could be
decoded if required.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pckbport/synapticsreg.h
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pckbport/synapticsvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/pckbport

2010-01-08 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Fri Jan  8 20:00:33 UTC 2010

Modified Files:
src/sys/dev/pckbport: pckbd.c pms.c

Log Message:
Expand PMF_FN_* macros.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/pckbport/pckbd.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pckbport/pms.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.