From nobody@FreeBSD.org  Thu Oct  1 08:07:23 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 35ECC106568D
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  1 Oct 2009 08:07:23 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 234AF8FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  1 Oct 2009 08:07:23 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n9187MAe032355
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 1 Oct 2009 08:07:22 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n9187MK7032354;
	Thu, 1 Oct 2009 08:07:22 GMT
	(envelope-from nobody)
Message-Id: <200910010807.n9187MK7032354@www.freebsd.org>
Date: Thu, 1 Oct 2009 08:07:22 GMT
From: David Horn <dhorn2000@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] [psm] disable synaptics mouse taps
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         139272
>Category:       kern
>Synopsis:       [patch] [psm] disable synaptics mouse taps
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    dumbbell
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 01 08:10:01 UTC 2009
>Closed-Date:    Fri Dec 18 18:01:27 UTC 2009
>Last-Modified:  Fri Dec 18 18:01:27 UTC 2009
>Originator:     David Horn
>Release:        8.0 RC r197621
>Organization:
>Environment:
FreeBSD xxxxxxx 8.0-RC1 FreeBSD 8.0-RC1 #21 r197621M: Thu Oct  1 02:39:15 EDT 2009     dhorn@xxxxxxxxxxxx:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
The attached patch adds support for disabling or enabling mouse taps on synaptics touch pads (when running in generic mouse mode) using a loader tunable.

On my particular machine, disabling mouse taps is required since the location of the touchpad makes accidental touches of the mouse pad inevitable.  
>How-To-Repeat:

>Fix:
See patch

Patch attached with submission follows:

Index: share/man/man4/psm.4
===================================================================
--- share/man/man4/psm.4	(revision 197621)
+++ share/man/man4/psm.4	(working copy)
@@ -359,6 +359,33 @@
 This will enable
 .Nm
 to handle packets from guest devices (sticks) and extra buttons.
+
+If you wish to disable Synaptics touchpad tap events (mouse taps),
+set 
+.Va hw.psm.force_tap_events
+to
+.Em 2
+at boot time.  This only affects Generic
+.Nm
+mouse support
+(i.e. not when Extended Synaptics support is enabled)
+
+Boot-time
+.Nm
+device debugging is available using the 
+.Va debug.psm.loglevel
+tunable.
+ 
+These tunables can be set in /boot/loader.conf as /etc/sysctl.conf
+executes too late in the boot process. (e.g. hw.psm.force_tap_events="2")
+.Sh SYSCTL VARIABLES 
+Once Extended Synaptics support is enabled, many additional sysctl variables
+become available to customize the behavior of the touchpad. See sysctl -d
+.Va hw.psm
+after booting with Extended support enabled.
+Debug logging can be controlled using the 
+.Va debug.psm.loglevel
+knob.
 .Sh IOCTLS
 There are a few
 .Xr ioctl 2
Index: sys/dev/atkbdc/psm.c
===================================================================
--- sys/dev/atkbdc/psm.c	(revision 197621)
+++ sys/dev/atkbdc/psm.c	(working copy)
@@ -346,6 +346,9 @@
 static int synaptics_support = 0;
 TUNABLE_INT("hw.psm.synaptics_support", &synaptics_support);
 
+static int force_tap_events = 0;
+TUNABLE_INT("hw.psm.force_tap_events", &force_tap_events);
+
 static int verbose = PSM_DEBUG;
 TUNABLE_INT("debug.psm.loglevel", &verbose);
 
@@ -509,10 +512,24 @@
 enable_aux_dev(KBDC kbdc)
 {
 	int res;
-
+	int cval = 0x00; 
+	
 	res = send_aux_command(kbdc, PSMC_ENABLE_DEV);
 	VLOG(2, (LOG_DEBUG, "psm: ENABLE_DEV return code:%04x\n", res));
-
+	
+	/* and set synaptics touchpad tap mode only if tunable is set
+	   - value of 1 will force tap events 
+	   - value of 2 will force no tap events
+	   - value of 0 will not change currect state 
+	   This only works under standard mouse emulation mode,
+	   ignored in enhanced synaptics mode */
+        if (force_tap_events > 0) {
+		if (force_tap_events == 2)
+	        	cval |= 0x04;
+		mouse_ext_command(kbdc, cval);
+		set_mouse_sampling_rate(kbdc, 20);
+		VLOG(2, (LOG_DEBUG, "psm: set force_tap_events command byte value to:%02x \n", cval));
+	}
 	return (res == PSM_ACK);
 }
 
@@ -2267,6 +2284,8 @@
 static int tap_timeout = PSM_TAP_TIMEOUT;
 SYSCTL_INT(_hw_psm, OID_AUTO, tap_timeout, CTLFLAG_RW, &tap_timeout, 0,
     "Tap timeout for touchpads");
+SYSCTL_INT(_hw_psm, OID_AUTO, force_tap_events, CTLFLAG_RW, &force_tap_events, 0,
+    "Force tap events 0=no change 1=force events on 2=force events off");
 
 static void
 psmintr(void *arg)


>Release-Note:
>Audit-Trail:

From: David Horn <dhorn2000@gmail.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/139272: [patch] [psm] disable synaptics mouse taps
Date: Thu, 1 Oct 2009 16:47:14 -0400

 --00504502c8b39412c90474e5c0d0
 Content-Type: text/plain; charset=ISO-8859-1
 
 Updated patch to check for synaptics_support tunable, and only act on
 force_tap_events tunable if synaptics_support is disabled. (attached)
 Since this is gmail, the attachment will likely show up garbled in
 gnats web ui, so feel free to email me if you need a copy of the
 updated patch, but it is a 1 line change from the original patch to
 prevent a conflict :
 
 -         if(force_tap_events > 0) {
 +        if(force_tap_events > 0 && ! synaptics_support) {
 
 without this change, setting both tunables caused the mouse to not
 work at all, when the intention is to allow synaptics_support to win
 the tie.
 
 Thanks!
 
 --Dave H
 
 --00504502c8b39412c90474e5c0d0
 Content-Type: text/plain; charset=US-ASCII; name="mouse_taps.patch2.txt"
 Content-Disposition: attachment; filename="mouse_taps.patch2.txt"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_g09z33up0
 
 SW5kZXg6IHNoYXJlL21hbi9tYW40L3BzbS40Cj09PT09PT09PT09PT09PT09PT09PT09PT09PT09
 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIHNoYXJlL21hbi9tYW40
 L3BzbS40CShyZXZpc2lvbiAxOTc2ODIpCisrKyBzaGFyZS9tYW4vbWFuNC9wc20uNAkod29ya2lu
 ZyBjb3B5KQpAQCAtMzU5LDYgKzM1OSwzMyBAQAogVGhpcyB3aWxsIGVuYWJsZQogLk5tCiB0byBo
 YW5kbGUgcGFja2V0cyBmcm9tIGd1ZXN0IGRldmljZXMgKHN0aWNrcykgYW5kIGV4dHJhIGJ1dHRv
 bnMuCisKK0lmIHlvdSB3aXNoIHRvIGRpc2FibGUgU3luYXB0aWNzIHRvdWNocGFkIHRhcCBldmVu
 dHMgKG1vdXNlIHRhcHMpLAorc2V0IAorLlZhIGh3LnBzbS5mb3JjZV90YXBfZXZlbnRzCit0bwor
 LkVtIDIKK2F0IGJvb3QgdGltZS4gIFRoaXMgb25seSBhZmZlY3RzIEdlbmVyaWMKKy5ObQorbW91
 c2Ugc3VwcG9ydAorKGkuZS4gbm90IHdoZW4gRXh0ZW5kZWQgU3luYXB0aWNzIHN1cHBvcnQgaXMg
 ZW5hYmxlZCkKKworQm9vdC10aW1lCisuTm0KK2RldmljZSBkZWJ1Z2dpbmcgaXMgYXZhaWxhYmxl
 IHVzaW5nIHRoZSAKKy5WYSBkZWJ1Zy5wc20ubG9nbGV2ZWwKK3R1bmFibGUuCisgCitUaGVzZSB0
 dW5hYmxlcyBjYW4gYmUgc2V0IGluIC9ib290L2xvYWRlci5jb25mIGFzIC9ldGMvc3lzY3RsLmNv
 bmYKK2V4ZWN1dGVzIHRvbyBsYXRlIGluIHRoZSBib290IHByb2Nlc3MuIChlLmcuIGh3LnBz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ZlbnRzIGNvbW1h
 bmQgYnl0ZSB2YWx1ZSB0bzolMDJ4IFxuIiwgY3ZhbCkpOworCX0KIAlyZXR1cm4gKHJlcyA9PSBQ
 U01fQUNLKTsKIH0KIApAQCAtMjI2Nyw2ICsyMjg0LDggQEAKIHN0YXRpYyBpbnQgdGFwX3RpbWVv
 dXQgPSBQU01fVEFQX1RJTUVPVVQ7CiBTWVNDVExfSU5UKF9od19wc20sIE9JRF9BVVRPLCB0YXBf
 dGltZW91dCwgQ1RMRkxBR19SVywgJnRhcF90aW1lb3V0LCAwLAogICAgICJUYXAgdGltZW91dCBm
 b3IgdG91Y2hwYWRzIik7CitTWVNDVExfSU5UKF9od19wc20sIE9JRF9BVVRPLCBmb3JjZV90YXBf
 ZXZlbnRzLCBDVExGTEFHX1JXLCAmZm9yY2VfdGFwX2V2ZW50cywgMCwKKyAgICAiRm9yY2UgdGFw
 IGV2ZW50cyAwPW5vIGNoYW5nZSAxPWZvcmNlIGV2ZW50cyBvbiAyPWZvcmNlIGV2ZW50cyBvZmYi
 KTsKIAogc3RhdGljIHZvaWQKIHBzbWludHIodm9pZCAqYXJnKQo=
 --00504502c8b39412c90474e5c0d0--
Responsible-Changed-From-To: freebsd-bugs->dumbbell 
Responsible-Changed-By: dumbbell 
Responsible-Changed-When: Mon Dec 7 18:23:26 UTC 2009 
Responsible-Changed-Why:  
I'll take this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=139272 
State-Changed-From-To: open->feedback 
State-Changed-By: dumbbell 
State-Changed-When: Mon Dec 7 21:18:20 UTC 2009 
State-Changed-Why:  
To submitter: could you please test the patch in the follow-up? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=139272 

From: David Horn <dhorn2000@gmail.com>
To: dumbbell@freebsd.org, bug-followup@freebsd.org
Cc:  
Subject: Re: kern/139272: [patch] [psm] disable synaptics mouse taps
Date: Mon, 7 Dec 2009 17:31:37 -0500

 On Mon, Dec 7, 2009 at 4:22 PM,  <dumbbell@freebsd.org> wrote:
 > Synopsis: [patch] [psm] disable synaptics mouse taps
 >
 > State-Changed-From-To: open->feedback
 > State-Changed-By: dumbbell
 > State-Changed-When: Mon Dec 7 21:18:20 UTC 2009
 > State-Changed-Why:
 > To submitter: could you please test the patch in the follow-up?
 >
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=139272
 >
 
 Yes, I am ok with the patch from
 http://people.freebsd.org/~dumbbell/synaptics/psm-tap-enabled-c.patch
 
 The change to only two values is probably fine.  The only reason I
 originally had 3 values is that I did not want to touch the mode byte
 by default since that mode byte can survive a warm reboot from another
 OS. (but probably not a power-off ?).  Setting 0x00 by default (as per
 your patch) is consistent with the documentation for power-on
 defaults.
 
 As per Synaptics Interfacing Guide pp33:
 
 The power-on initial setting for the mode byte is $00. During normal
 operation, the mode bits are generally preserved except when
 explicitly changed by a host command. The PS/2 Reset ($FF) and Set
 Defaults ($F6) commands clear the Absolute bit to 0 but do not affect
 the other mode bits.
 
 In any case, thank you for taking a look at my patch and please commit
 your modified version.
 
 I tested against 8-stable r200236 and it works great with both 0 and 1 values.
 
 --Dave Horn

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/139272: commit references a PR
Date: Fri, 18 Dec 2009 17:47:27 +0000 (UTC)

 Author: dumbbell
 Date: Fri Dec 18 17:46:57 2009
 New Revision: 200674
 URL: http://svn.freebsd.org/changeset/base/200674
 
 Log:
   Add new "hw.psm.tap_enabled" tunable and sysctl.
   
   This tunable allows one to enable (1) or disable (0) gestures like tap
   and tap-hold on Synaptics TouchPad when the Extended mode isn't enabled
   (ie. "hw.psm.synaptics_support" not set).
   
   By default, the value is -1 in order to keep the current behaviour of
   not enabling/disabling gestures explicitly.
   
   PR:		kern/139272
   Submitted by:	David Horn <dhorn2000 AT gmail DOT com>
   Reviewed by:	David Horn <dhorn2000 AT gmail DOT com>
 
 Modified:
   head/share/man/man4/psm.4
   head/sys/dev/atkbdc/psm.c
 
 Modified: head/share/man/man4/psm.4
 ==============================================================================
 --- head/share/man/man4/psm.4	Fri Dec 18 17:22:21 2009	(r200673)
 +++ head/share/man/man4/psm.4	Fri Dec 18 17:46:57 2009	(r200674)
 @@ -359,6 +359,18 @@ at boot-time.
  This will enable
  .Nm
  to handle packets from guest devices (sticks) and extra buttons.
 +.Pp
 +Tap and drag gestures can be disabled by setting
 +.Va hw.psm.tap_enabled
 +to
 +.Em 0
 +at boot-time.
 +Currently, this is only supported on Synaptics touchpads with Extended
 +support disabled. The behaviour may be changed after boot by setting
 +the sysctl with the same name and by restarting
 +.Xr moused 8
 +using
 +.Pa /etc/rc.d/moused .
  .Sh IOCTLS
  There are a few
  .Xr ioctl 2
 
 Modified: head/sys/dev/atkbdc/psm.c
 ==============================================================================
 --- head/sys/dev/atkbdc/psm.c	Fri Dec 18 17:22:21 2009	(r200673)
 +++ head/sys/dev/atkbdc/psm.c	Fri Dec 18 17:46:57 2009	(r200674)
 @@ -343,6 +343,9 @@ static devclass_t psm_devclass;
  #define	PSM_FLAGS_FINGERDOWN	0x0001	/* VersaPad finger down */
  
  /* Tunables */
 +static int tap_enabled = -1;
 +TUNABLE_INT("hw.psm.tap_enabled", &tap_enabled);
 +
  static int synaptics_support = 0;
  TUNABLE_INT("hw.psm.synaptics_support", &synaptics_support);
  
 @@ -901,6 +904,36 @@ doopen(struct psm_softc *sc, int command
  		}
  	}
  
 +	/*
 +	 * A user may want to disable tap and drag gestures on a Synaptics
 +	 * TouchPad when it operates in Relative Mode.
 +	 */
 +	if (sc->hw.model == MOUSE_MODEL_GENERIC) {
 +		if (tap_enabled > 0) {
 +			/*
 +			 * Enable tap & drag gestures. We use a Mode Byte
 +			 * and clear the DisGest bit (see §2.5 of Synaptics
 +			 * TouchPad Interfacing Guide).
 +			 */
 +			VLOG(2, (LOG_DEBUG,
 +			    "psm%d: enable tap and drag gestures\n",
 +			    sc->unit));
 +			mouse_ext_command(sc->kbdc, 0x00);
 +			set_mouse_sampling_rate(sc->kbdc, 20);
 +		} else if (tap_enabled == 0) {
 +			/*
 +			 * Disable tap & drag gestures. We use a Mode Byte
 +			 * and set the DisGest bit (see §2.5 of Synaptics
 +			 * TouchPad Interfacing Guide).
 +			 */
 +			VLOG(2, (LOG_DEBUG,
 +			    "psm%d: disable tap and drag gestures\n",
 +			    sc->unit));
 +			mouse_ext_command(sc->kbdc, 0x04);
 +			set_mouse_sampling_rate(sc->kbdc, 20);
 +		}
 +	}
 +
  	/* enable the mouse device */
  	if (!enable_aux_dev(sc->kbdc)) {
  		/* MOUSE ERROR: failed to enable the mouse because:
 @@ -2261,6 +2294,8 @@ static int pkterrthresh = 2;
  SYSCTL_INT(_debug_psm, OID_AUTO, pkterrthresh, CTLFLAG_RW, &pkterrthresh, 0,
      "Number of error packets allowed before reinitializing the mouse");
  
 +SYSCTL_INT(_hw_psm, OID_AUTO, tap_enabled, CTLFLAG_RW, &tap_enabled, 0,
 +    "Enable tap and drag gestures");
  static int tap_threshold = PSM_TAP_THRESHOLD;
  SYSCTL_INT(_hw_psm, OID_AUTO, tap_threshold, CTLFLAG_RW, &tap_threshold, 0,
      "Button tap threshold");
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: feedback->closed 
State-Changed-By: dumbbell 
State-Changed-When: Fri Dec 18 18:00:06 UTC 2009 
State-Changed-Why:  
Patch committed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=139272 
>Unformatted:
