NetBSD Problem Report #42853

From rafal@puck.waterside.net  Sat Feb 20 18:07:35 2010
Return-Path: <rafal@puck.waterside.net>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id A3B6B63B8DE
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 20 Feb 2010 18:07:35 +0000 (UTC)
Message-Id: <20100220164827.588F81D0B7@puck.waterside.net>
Date: Sat, 20 Feb 2010 11:48:27 -0500 (EST)
From: rafal@netbsd.org
Reply-To: rafal@netbsd.org
To: gnats-bugs@gnats.NetBSD.org
Subject: Synaptics touchpad driver breaks passthrough device (ie, trackpoint)
X-Send-Pr-Version: 3.95

>Number:         42853
>Category:       kern
>Synopsis:       Synaptics touchpad driver breaks passthrough device (ie, trackpoint)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 20 18:10:00 +0000 2010
>Closed-Date:    Sun Mar 21 20:06:34 +0000 2010
>Last-Modified:  Sat Nov 20 01:20:02 +0000 2010
>Originator:     Rafal Boni
>Release:        NetBSD 5.99.24 (2010/02/18 15:25:28 -0500)
>Organization:
TNF
>Environment:


System: NetBSD plasmodium 5.99.24 NetBSD 5.99.24 (MONOLITHIC_DRM) #19: Sat Feb 20 11:11:03 EST 2010  rafal@puck:/extra/i386/obj/sys/arch/i386/compile/MONOLITHIC_DRM i386
Architecture: i386 / x86_64
Machine: i386 / amd64
>Description:
	The synaptics driver apparently confuses the attached 'passthrough'
	device i.e., the trackpoint on my T4x during the capability probe
	sequence, resulting in a working touchpad but non-working trackpoint.

>How-To-Repeat:
	Boot -current on a Thinkpad T4x, wonder why the trackpoint doesn't
	work when it does in Windows.
>Fix:
	Resetting the device first think during attach seems to do the
	trick.  Included in the change is a sysctl knob for disabling
	the passthrough device for those who saw this as a 'feature'.

	Note that I've also changed the 'pms_synaptics_send_command'
	function to follow the strict(er) protocol followed by e.g.
	the Linux drivers, that is sending the PMS_SET_SCALE11 command
	before the 'sliced' command.  This didn't affect functionality
	but seemed The Right Thing(tm) to do.

diff --git a/sys/dev/pckbport/synaptics.c b/sys/dev/pckbport/synaptics.c
index 6712973..a022907 100644
--- a/sys/dev/pckbport/synaptics.c
+++ b/sys/dev/pckbport/synaptics.c
@@ -111,6 +111,7 @@ static int synaptics_scale_y = 16;
 static int synaptics_max_speed_x = 32;
 static int synaptics_max_speed_y = 32;
 static int synaptics_movement_threshold = 4;
+static int synaptics_passthrough_enable = 1;

 /* Sysctl nodes. */
 static int synaptics_up_down_emul_nodenum;
@@ -241,6 +242,10 @@ pms_synaptics_probe_init(void *vsc)
 		const char comma[] = ", ";
 		const char *sep = "";
 		aprint_normal_dev(psc->sc_dev, "");
+		if (sc->flags & SYN_FLAG_HAS_PASSTHROUGH) {
+			aprint_normal("%sPassthrough", sep);
+			sep = comma;
+		}
 		if (sc->flags & SYN_FLAG_HAS_MIDDLE_BUTTON) {
 			aprint_normal("%sMiddle button", sep);
 			sep = comma;
@@ -276,9 +281,19 @@ pms_synaptics_enable(void *vsc)
 {
 	struct pms_softc *psc = vsc;
 	struct synaptics_softc *sc = &psc->u.synaptics;
-	u_char cmd[2];
+	u_char cmd[2], resp[2] = { 0,0 };
 	int res;

+	if (sc->flags & SYN_FLAG_HAS_PASSTHROUGH) {
+	    /* 
+	     * Extended capability probes can confuse the passthrough device;
+	     * reset the touchpad now to cure that.
+	     */
+	    cmd[0] = PMS_RESET;
+	    res = pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot, cmd, 1, 2,
+		resp, 1);
+	}
+
 	/*
 	 * Enable Absolute mode with W (width) reporting, and set
 	 * the packet rate to maximum (80 packets per second).
@@ -286,7 +301,7 @@ pms_synaptics_enable(void *vsc)
 	res = pms_synaptics_send_command(psc->sc_kbctag, psc->sc_kbcslot,
 	    SYNAPTICS_MODE_ABSOLUTE | SYNAPTICS_MODE_W | SYNAPTICS_MODE_RATE);
 	cmd[0] = PMS_SET_SAMPLE;
-	cmd[1] = 0x14; /* doit */
+	cmd[1] = SYNAPTICS_CMD_SET_MODE2; /* doit */
 	res |= pckbport_enqueue_cmd(psc->sc_kbctag, psc->sc_kbcslot, cmd, 2, 0,
 	    1, NULL);
 	sc->up_down = 0;
@@ -541,6 +556,17 @@ pms_sysctl_synaptics(struct sysctllog **clog)
 		goto err;

 	synaptics_movement_threshold_nodenum = node->sysctl_num;
+
+	if ((rc = sysctl_createv(clog, 0, NULL, &node,
+	    CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+	    CTLTYPE_INT, "passthrough_enable",
+	    SYSCTL_DESCR("Enable/disable passthrough port"),
+	    NULL, 0, 
+	    &synaptics_passthrough_enable,
+	    0, CTL_HW, root_num, CTL_CREATE,
+	    CTL_EOL)) != 0)
+		goto err;
+
 	return;

 err:
@@ -616,13 +642,16 @@ pms_synaptics_send_command(pckbport_tag_t tag, pckbport_slot_t slot,
 	u_char cmd[2];
 	int res;

+	cmd[0] = PMS_SET_SCALE11;
+	res = pckbport_poll_cmd(tag, slot, cmd, 1, 0, NULL, 0);
+
 	/*
 	 * Need to send 4 Set Resolution commands, with the argument
 	 * encoded in the bottom most 2 bits.
 	 */
 	cmd[0] = PMS_SET_RES;
 	cmd[1] = syn_cmd >> 6;
-	res = pckbport_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0);
+	res |= pckbport_poll_cmd(tag, slot, cmd, 2, 0, NULL, 0);

 	cmd[0] = PMS_SET_RES;
 	cmd[1] = (syn_cmd & 0x30) >> 4;
@@ -710,6 +739,9 @@ pms_synaptics_passthrough(struct pms_softc *psc)
 	int buttons, changed;
 	int s;

+	if (!synaptics_passthrough_enable)
+		return;
+
 	buttons = ((psc->packet[1] & PMS_LBUTMASK) ? 0x20 : 0) |
 		((psc->packet[1] & PMS_MBUTMASK) ? 0x40 : 0) |
 		((psc->packet[1] & PMS_RBUTMASK) ? 0x80 : 0);
diff --git a/sys/dev/pckbport/synapticsreg.h b/sys/dev/pckbport/synapticsreg.h
index c9c5d6e..a31c47d 100644
--- a/sys/dev/pckbport/synapticsreg.h
+++ b/sys/dev/pckbport/synapticsreg.h
@@ -45,6 +45,10 @@
 #define SYNAPTICS_READ_MODEL_ID		0x3
 #define SYNAPTICS_EXTENDED_QUERY	0x9

+/* Synaptics special commands */
+#define SYNAPTICS_CMD_SET_MODE2		0x14
+#define SYNAPTICS_CMD_CLIENT_CMD	0x28
+
 /* Magic numbers. */
 #define SYNAPTICS_MIN_VERSION		45 /* 4.5 */
 #define SYNAPTICS_MAGIC_BYTE		0x47
@@ -64,6 +68,7 @@
 #define SYNAPTICS_MODE_RATE		(1 << 6)
 #define SYNAPTICS_MODE_SLEEP		(1 << 3)
 #define SYNAPTICS_MODE_GEST		(1 << 2)
+#define SYNAPTICS_MODE_4BYTE_CLIENT     (1 << 1)
 #define SYNAPTICS_MODE_W		(1)

 /* Extended mode button masks. */

>Release-Note:

>Audit-Trail:
From: Rafal Boni <rafal@pobox.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/42853: Synaptics touchpad driver breaks passthrough device
 (ie, trackpoint)
Date: Sat, 20 Feb 2010 17:24:57 -0500

 Attached is also an update to the pms(4) man page.

 --rafal

 diff --git a/share/man/man4/pms.4 b/share/man/man4/pms.4
 index 12ba439..a3e9f27 100644
 --- a/share/man/man4/pms.4
 +++ b/share/man/man4/pms.4
 @@ -149,6 +149,12 @@ event (default 32).
  .It Dv hw.synaptics.movement_threshold
  Movements of less than this value (in Synaptics coordinates) are
  ignored (default 4).
 +.It Dv hw.synaptics.passthrough_enable
 +Enable / disable a secondary pointing device attached to the touchpad; for example, the 
 +.Dq TrackPoint 
 +available on 
 +.Dq ThinkPad
 +laptops (default 1).
  .El
  .Pp
  The following

 -- 
   Time is an illusion; lunchtime, doubly so.     |/\/\|           Rafal Boni
                    -- Ford Prefect               |\/\/|      rafal@pobox.com

From: Iain Hibbert <plunky@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42853 CVS commit: src/sys/dev/pckbport
Date: Sun, 21 Mar 2010 19:53:52 +0000

 Module Name:	src
 Committed By:	plunky
 Date:		Sun Mar 21 19:53:52 UTC 2010

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

 Log Message:
 some definitions from the Linux driver (via PR kern/42853)


 To generate a diff of this commit:
 cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pckbport/synaptics.c
 cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pckbport/synapticsreg.h

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

From: Iain Hibbert <plunky@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42853 CVS commit: src/sys/dev/pckbport
Date: Sun, 21 Mar 2010 20:04:43 +0000

 Module Name:	src
 Committed By:	plunky
 Date:		Sun Mar 21 20:04:43 UTC 2010

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

 Log Message:
 send the SET_SCALE11 command before the 'sliced' command as per the
 Linux driver (and elantech(4)), via PR kern/42853


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

State-Changed-From-To: open->closed
State-Changed-By: plunky@NetBSD.org
State-Changed-When: Sun, 21 Mar 2010 20:06:34 +0000
State-Changed-Why:
I committed these changes, except for the sysctl which I deemed un-necessary (it
seems that it ought to Just Work)


From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/42853
Date: Sun, 25 Apr 2010 19:28:46 -0500 (CDT)

 As a new owner of a T42, I ran into this problem on 5.0_STABLE.  I see
 that it's been fixed in -current.  Just to see, I updated the
 "sys/dev/pckbport/synaptics*" files to HEAD and built a kernel and
 now my 3-button trackpoint works.

 Could this be pulled up to netbsd-5?

 Thanks.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org, 
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, rafal@netbsd.org
Cc: 
Subject: Re: kern/42853
Date: Sun, 25 Apr 2010 20:57:21 -0400

 On Apr 26, 12:30am, jdbaker@mylinuxisp.com ("John D. Baker") wrote:
 -- Subject: Re: kern/42853

 Please send the filenames with the relevant revisions,
 and the commit messages for them.

 Thanks,

 christos

From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/42853
Date: Wed, 28 Apr 2010 07:27:57 -0500 (CDT)

 In response to my direct email, the committer has requested a pullup.

    http://releng.netbsd.org/cgi-bin/req-5.cgi?show=1383

 The relevant information is contained therein.

 Thanks.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42853 CVS commit: [netbsd-5] src/sys/dev/pckbport
Date: Sat, 20 Nov 2010 01:19:02 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Sat Nov 20 01:19:01 UTC 2010

 Modified Files:
 	src/sys/dev/pckbport [netbsd-5]: synaptics.c synapticsreg.h

 Log Message:
 Pull up following revision(s) (requested by plunky in ticket #1383):
 	sys/dev/pckbport/synapticsreg.h: revision 1.6
 	sys/dev/pckbport/synaptics.c: revision 1.22
 	sys/dev/pckbport/synaptics.c: revision 1.23
 	sys/dev/pckbport/synaptics.c: revision 1.24
 some definitions from the Linux driver (via PR kern/42853)
 Extended capability probes can confuse the passthrough device,
 reset the touchpad on enable to cure that.
 send the SET_SCALE11 command before the 'sliced' command as per the
 Linux driver (and elantech(4)), via PR kern/42853


 To generate a diff of this commit:
 cvs rdiff -u -r1.21 -r1.21.10.1 src/sys/dev/pckbport/synaptics.c
 cvs rdiff -u -r1.5 -r1.5.56.1 src/sys/dev/pckbport/synapticsreg.h

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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.