NetBSD Problem Report #56476

From mlelstv@tazz.1st.de  Sat Oct 30 14:09:58 2021
Return-Path: <mlelstv@tazz.1st.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 0A4341A923A
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 30 Oct 2021 14:09:58 +0000 (UTC)
Message-Id: <20211030140926.33F61CCAE5@tazz.1st.de>
Date: Sat, 30 Oct 2021 16:09:26 +0200 (CEST)
From: mlelstv@serpens.de
Reply-To: mlelstv@serpens.de
To: gnats-bugs@NetBSD.org
Subject: Pointer jumps with synaptics driver
X-Send-Pr-Version: 3.95

>Number:         56476
>Category:       kern
>Synopsis:       Pointer jumps with synaptics driver
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 30 14:10:00 +0000 2021
>Last-Modified:  Sun Sep 18 23:20:01 +0000 2022
>Originator:     Michael van Elst
>Release:        NetBSD 9.99.92
>Organization:

>Environment:


System: NetBSD tazz 9.99.92 NetBSD 9.99.92 (GENERIC) #4: Sat Oct 30 13:58:25 UTC 2021 mlelstv@slowpoke:/scratch2/obj.amd64/scratch/netbsd-current/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
Since the update of synaptics.c to 1.73 the contact to the touch pad
jumps the pointer to a position resembling the absolute position on the
touch pad.

>How-To-Repeat:
Put finger to the left top quadrant of the touchpad and see the pointer
jump a few centimeters to the top left. Put finger on the right top
and see it jump to the right. You can touch any position and the pointer
roughly follows as if the touchpad would use absolute coordinates.

Moving the pointer outside that rectangle is only possible thanks to
pointer acceleration.
>Fix:
Reverting to 1.72 restores the normal behaviour.

>Audit-Trail:
From: Michael van Elst <mlelstv@serpens.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/56476 Pointer jumps with synaptics driver
Date: Sun, 6 Mar 2022 23:45:27 +0100

 The latest update to the synaptics driver (synaptics.c 1.76)
 unfortunately didn't fix the broken behaviour.

 -- 
                                 Michael van Elst
 Internet: mlelstv@serpens.de
                                 "A potential Snark may lurk in every tree."

From: Michael van Elst <mlelstv@serpens.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/56476 Pointer jumps with synaptics driver
Date: Tue, 19 Jul 2022 10:23:32 +0200

 Here is a patch that fixes the behaviour for me. It mostly corrects the
 broken movement filtering, but I may have dropped some magic that is
 required for other hardware. Comments?

 ? sys/dev/pckbport/ChangeLog
 Index: sys/dev/pckbport/synaptics.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/pckbport/synaptics.c,v
 retrieving revision 1.79
 diff -p -u -r1.79 synaptics.c
 --- sys/dev/pckbport/synaptics.c	31 May 2022 08:43:16 -0000	1.79
 +++ sys/dev/pckbport/synaptics.c	19 Jul 2022 08:19:43 -0000
 @@ -1636,76 +1636,13 @@ skip_position:
  	    nsp.sp_primary, nsp.sp_secondary, v, primary_finger,
  	    secondary_finger);

 -
 -	/* 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, &nsp);
 -			sc->packet_count[SYN_PRIMARY_FINGER] = 0;
 -			sc->packet_count[SYN_SECONDARY_FINGER] = 0;
 -		}
 -
 -		/* clear the fingers seen since we have processed */
 -		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, &packet);
 -			sc->packet_count[SYN_PRIMARY_FINGER]++;
 -		}
 -
 +	/* Clear history when number of fingers changes */
 +	if (nsp.sp_finger_count != packet.sp_finger_count) {
  		sc->packet_count[SYN_PRIMARY_FINGER] = 0;
  		sc->packet_count[SYN_SECONDARY_FINGER] = 0;
  	}

 -	/* Only one finger, process the new packet */
 -	if (nsp.sp_finger_count == 1) {
 -		if (nsp.sp_finger_count != packet.sp_finger_count) {
 -			sc->packet_count[SYN_PRIMARY_FINGER] = 0;
 -			sc->packet_count[SYN_SECONDARY_FINGER] = 0;
 -		}
 -		pms_synaptics_process_packet(psc, &nsp);
 -
 -		/* clear the fingers seen since we have processed */
 -		nsp.sp_primary = 0;
 -		nsp.sp_secondary = 0;
 -		nsp.sp_finger_status = 0;
 -
 -		sc->packet_count[SYN_PRIMARY_FINGER]++;
 -	}
 -
 -	/*
 -	 *  More than one finger and we have seen the primary and secondary
 -	 * fingers then process the packet.
 -	 */
 -	if ((nsp.sp_finger_count > 1) && (nsp.sp_primary == 1) 
 -	    && (nsp.sp_secondary == 1)) {
 -		if (nsp.sp_finger_count != packet.sp_finger_count) {
 -			sc->packet_count[SYN_PRIMARY_FINGER] = 0;
 -			sc->packet_count[SYN_SECONDARY_FINGER] = 0;
 -		}
 -		pms_synaptics_process_packet(psc, &nsp);
 -
 -		/* clear the fingers seen since we have processed */
 -		nsp.sp_primary = 0;
 -		nsp.sp_secondary = 0;
 -		nsp.sp_finger_status = 0;
 -
 -		sc->packet_count[SYN_PRIMARY_FINGER]++;
 -		sc->packet_count[SYN_SECONDARY_FINGER]++;
 -	}
 +	pms_synaptics_process_packet(psc, &nsp);

  	memcpy(&packet, &nsp, sizeof(packet));
  }
 @@ -2095,10 +2032,10 @@ synaptics_filter_policy(struct synaptics
  	 * tiny finger movements.
  	 */
  	if (count >= SYN_HIST_SIZE) {
 -		a = (history[(count + 0) % SYN_HIST_SIZE] +
 -		    history[(count + 1) % SYN_HIST_SIZE]) / 2;
 +		a = (history[(count - 2) % SYN_HIST_SIZE] +
 +		     history[(count - 1) % SYN_HIST_SIZE]) / 2;

 -		b = (value + history[(count + 0) % SYN_HIST_SIZE]) / 2;
 +		b = (value + history[(count - 1) % SYN_HIST_SIZE]) / 2;

  		rv = b - a;

 @@ -2114,7 +2051,7 @@ synaptics_filter_policy(struct synaptics
  	/*
  	 * Add the new value to the history buffer.
  	 */
 -	history[(count + 1) % SYN_HIST_SIZE] = value;
 +	history[(count + 0) % SYN_HIST_SIZE] = value;

  	return (rv);
  }
 @@ -2201,6 +2138,7 @@ synaptics_movement(struct synaptics_soft
  	dy = synaptics_filter_policy(sc, 0,
  	    sc->history_y[SYN_PRIMARY_FINGER], sp->sp_y,
  	    sc->packet_count[SYN_PRIMARY_FINGER]);
 +	sc->packet_count[SYN_PRIMARY_FINGER]++;

  	if (sp->sp_finger_count > 1) {
  		sdx = synaptics_filter_policy(sc, 1,
 @@ -2209,6 +2147,7 @@ synaptics_movement(struct synaptics_soft
  		sdy = synaptics_filter_policy(sc, 1,
  		    sc->history_y[SYN_SECONDARY_FINGER], sp->sp_sy,
  		    sc->packet_count[SYN_SECONDARY_FINGER]);
 +		sc->packet_count[SYN_SECONDARY_FINGER]++;
  		DPRINTF(10, sc, "synaptics_movement: dx %d dy %d sdx %d sdy %d\n",
  		    dx, dy, sdx, sdy);
  	}
 @@ -2419,6 +2358,9 @@ pms_synaptics_process_packet(struct pms_
  			sc->rem_x[SYN_SECONDARY_FINGER] = 0;
  			sc->rem_y[SYN_SECONDARY_FINGER] = 0;
  			dx = dy = 0;
 +
 +			sc->packet_count[SYN_PRIMARY_FINGER] = 0;
 +			sc->packet_count[SYN_SECONDARY_FINGER] = 0;
  		}
  	} else {
  		/*


 -- 
                                 Michael van Elst
 Internet: mlelstv@serpens.de
                                 "A potential Snark may lurk in every tree."

From: "Michael van Elst" <mlelstv@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/56476 CVS commit: src/sys/dev/pckbport
Date: Sat, 17 Sep 2022 06:33:55 +0000

 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.

From: "David H. Gutteridge" <david@gutteridge.ca>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: PR/56476 CVS commit: src/sys/dev/pckbport
Date: Sun, 18 Sep 2022 19:15:34 -0400

 Thanks! Now my trackpad works properly again.

 Dave

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2022 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.