Skip to contentSkip to conversation

Synaptics TouchPad driver for 2.5.70

PATCH In review Joseph Fannin 4 participants 5 messages Jun 11, 2003 Input drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Synaptics TouchPad driver for 2.5.70

Hi!

Here is a driver for the Synaptics TouchPad for 2.5.70. It is largely based on the XFree86 driver. This driver operates the touchpad in absolute mode and emulates a three button mouse with two scroll wheels. Features include:

* Multi finger tapping.
* Vertical and horizontal scrolling.
* Edge scrolling during drag operations.
* Palm detection.
* Corner tapping.

The only major missing feature is runtime configuration of driver parameters. What is the best way to implement that? I was thinking of sending EV_MSC events to the driver using the /dev/input/event* interface and define my own codes for the different driver parameters.

Comments?

drivers/input/mouse/Kconfig renamed from ../linus/main/linux/drivers/input/mouse/Kconfig +10 -0
diff -u -r -N ../../linus/main/linux/drivers/input/mouse/Kconfig linux/drivers/input/mouse/Kconfig
@@ -28,6 +28,16 @@
 	  The module will be called psmouse. If you want to compile it as a
 	  module, say M here and read <file:Documentation/modules.txt>.
 
+config MOUSE_PS2_SYNAPTICS
+	bool "Synaptics TouchPad"
+	default n
+	depends on INPUT && INPUT_MOUSE && SERIO && MOUSE_PS2
+	---help---
+	  Say Y here if you have a Synaptics TouchPad connected to your system.
+	  This touchpad is found on many modern laptop computers.
+
+	  If unsure, say Y.
+
 config MOUSE_SERIAL
 	tristate "Serial mouse"
 	depends on INPUT && INPUT_MOUSE && SERIO
drivers/input/mouse/psmouse.c renamed from ../linus/main/linux/drivers/input/mouse/psmouse.c +22 -7
diff -u -r -N ../../linus/main/linux/drivers/input/mouse/psmouse.c linux/drivers/input/mouse/psmouse.c
@@ -41,6 +41,7 @@
 #define PSMOUSE_RET_NAK		0xfe
 
 struct psmouse {
+	void *private;
 	struct input_dev dev;
 	struct serio *serio;
 	char *vendor;
@@ -65,8 +66,11 @@
 #define PSMOUSE_GENPS	4
 #define PSMOUSE_IMPS	5
 #define PSMOUSE_IMEX	6
+#define PSMOUSE_SYNAPTICS 7
 
-static char *psmouse_protocols[] = { "None", "PS/2", "PS2++", "PS2T++", "GenPS/2", "ImPS/2", "ImExPS/2" };
+#include "synaptics.c"
+
+static char *psmouse_protocols[] = { "None", "PS/2", "PS2++", "PS2T++", "GenPS/2", "ImPS/2", "ImExPS/2", "Synaptics"};
 
 /*
  * psmouse_process_packet() anlyzes the PS/2 mouse packet contents and
@@ -209,6 +213,16 @@
 		goto out;
 	}
 
+	if (psmouse->pktcnt == 1 && psmouse->type == PSMOUSE_SYNAPTICS) {
+		/*
+		 * The synaptics driver has its own resync logic,
+		 * so it needs to receive all bytes one at a time.
+		 */
+		synaptics_process_byte(psmouse, regs);
+		psmouse->pktcnt = 0;
+		goto out;
+	}
+
 	if (psmouse->pktcnt == 1 && psmouse->packet[0] == PSMOUSE_RET_BAT) {
 		serio_rescan(serio);
 		goto out;
@@ -343,12 +357,12 @@
        psmouse_command(psmouse, param, PSMOUSE_CMD_GETINFO);
 
        if (param[1] == 0x47) {
-               /* We could do more here. But it's sufficient just
-                  to stop the subsequent probes from screwing the
-                  thing up. */
-               psmouse->vendor = "Synaptics";
-               psmouse->name = "TouchPad";
-               return PSMOUSE_PS2;
+		int type = PSMOUSE_PS2;
+		psmouse->vendor = "Synaptics";
+		psmouse->name = "TouchPad";
+		if (synaptics_init(psmouse) == 0)
+			type = PSMOUSE_SYNAPTICS;
+		return type;
        }
 
 /*
@@ -598,6 +612,7 @@
 	struct psmouse *psmouse = serio->private;
 	input_unregister_device(&psmouse->dev);
 	serio_close(serio);
+	synaptics_disconnect(psmouse);
 	kfree(psmouse);
 }
 
drivers/input/mouse/synaptics.c renamed from ../linus/main/linux/drivers/input/mouse/synaptics.c +801 -0

801 lines not on this page · raw message

drivers/input/mouse/synaptics.h renamed from ../linus/main/linux/drivers/input/mouse/synaptics.h +158 -0

158 lines not on this page · raw message

Signature · 2 lines
Peter Osterlund - [email protected]
http://w1.894.telia.com/~u89404340
#1 lore raw

On Wed, Jun 11, 2003 at 12:52:06AM +0200, Joseph Fannin wrote:

Please note that I did not write this driver -- Peter Osterlund <[email protected]> did. I meant only to forward this here, since the original sender seems to have problems getting through to the list.

Quoted 19 lines

Hi!

Here is a driver for the Synaptics TouchPad for 2.5.70. It is largely based on the XFree86 driver. This driver operates the touchpad in absolute mode and emulates a three button mouse with two scroll wheels. Features include:

* Multi finger tapping.
* Vertical and horizontal scrolling.
* Edge scrolling during drag operations.
* Palm detection.
* Corner tapping.

The only major missing feature is runtime configuration of driver parameters. What is the best way to implement that? I was thinking of sending EV_MSC events to the driver using the /dev/input/event* interface and define my own codes for the different driver parameters.

Comments?

Signature · 6 lines
Joseph Fannin
[email protected]

Rothchild's Rule -- "For every phenomenon, however complex, someone will
eventually come up with a simple and elegant theory. This theory will
be wrong."
#2 lore raw
In reply to Joseph Fannin
Quoted 2 lines · Joseph Fannin

Here is a driver for the Synaptics TouchPad for 2.5.70.

The code looks nice.

Quoted 1 line

+#include "synaptics.c"

But why on earth do we need to do this?

#3 lore raw
Quoted 9 lines · Andrew Morton
Quoted 2 lines · Joseph Fannin

Here is a driver for the Synaptics TouchPad for 2.5.70.

The code looks nice.

Quoted 1 line

+#include "synaptics.c"

But why on earth do we need to do this?

I'm sure we don't. That will be fixed easily.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#4 lore raw
Quoted 6 lines · Vojtech Pavlik
Quoted 4 lines · Andrew Morton
Quoted 2 lines · Joseph Fannin

Here is a driver for the Synaptics TouchPad for 2.5.70.

Quoted 7 lines
Quoted 5 lines

The code looks nice.

Quoted 1 line

+#include "synaptics.c"

But why on earth do we need to do this?

I'm sure we don't. That will be fixed easily.

No we don't. That was just a hack to keep the size of the patch down. Something like the patch below (applies on top of my previous patch) would take care of this, except that it renames the psmouse module to psmouse2. To fix this I think we have to rename the psmouse.c file, and I didn't want to do that in the original patch, because that would have made it much harder to review the patch.

drivers/input/mouse/Makefile renamed from drivers/input/mouse.absolute/Makefile +3 -1
diff -u -r -N --exclude='.*' --exclude='*.o' --exclude='*~' linux/drivers/input/mouse.absolute/Makefile linux/drivers/input/mouse/Makefile
@@ -11,5 +11,7 @@
 obj-$(CONFIG_MOUSE_MAPLE)	+= maplemouse.o
 obj-$(CONFIG_MOUSE_PC110PAD)	+= pc110pad.o
 obj-$(CONFIG_MOUSE_PC9800)	+= 98busmouse.o
-obj-$(CONFIG_MOUSE_PS2)		+= psmouse.o
+obj-$(CONFIG_MOUSE_PS2)		+= psmouse2.o
 obj-$(CONFIG_MOUSE_SERIAL)	+= sermouse.o
+
+psmouse2-objs	:= psmouse.o synaptics.o
drivers/input/mouse/psmouse.c renamed from drivers/input/mouse.absolute/psmouse.c +3 -45

66 lines not on this page · raw message

drivers/input/mouse/psmouse.h renamed from drivers/input/mouse.absolute/psmouse.h +49 -0

49 lines not on this page · raw message

drivers/input/mouse/synaptics.c renamed from drivers/input/mouse.absolute/synaptics.c +7 -11
diff -u -r -N --exclude='.*' --exclude='*.o' --exclude='*~' linux/drivers/input/mouse.absolute/synaptics.c linux/drivers/input/mouse/synaptics.c
@@ -19,19 +19,15 @@
  * Trademarks are the property of their respective owners.
  */
 
-#ifndef CONFIG_MOUSE_PS2_SYNAPTICS
+#include <linux/module.h>
 
-static inline void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs) {}
-static inline int synaptics_init(struct psmouse *psmouse) { return -1; }
-static inline void synaptics_disconnect(struct psmouse *psmouse) {}
-
-#else
+#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
 
+#include <linux/input.h>
+#include "psmouse.h"
 #include "synaptics.h"
 
 
-static int psmouse_command(struct psmouse *psmouse, unsigned char *param, int command);
-
 /*****************************************************************************
  *	Synaptics communications functions
  ****************************************************************************/
@@ -217,7 +213,7 @@
 	set_bit(axis, dev->absbit);
 }
 
-static int synaptics_init(struct psmouse *psmouse)
+int synaptics_init(struct psmouse *psmouse)
 {
 	struct synaptics_data *priv;
 
@@ -263,7 +259,7 @@
 	return -1;
 }
 
-static void synaptics_disconnect(struct psmouse *psmouse)
+void synaptics_disconnect(struct psmouse *psmouse)
 {
 	struct synaptics_data *priv = psmouse->private;
 
@@ -360,7 +356,7 @@
 	input_sync(dev);
 }
 
-static void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
+void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
 {
 	struct input_dev *dev = &psmouse->dev;
 	struct synaptics_data *priv = psmouse->private;
drivers/input/mouse/synaptics.h renamed from drivers/input/mouse.absolute/synaptics.h +15 -0
diff -u -r -N --exclude='.*' --exclude='*.o' --exclude='*~' linux/drivers/input/mouse.absolute/synaptics.h linux/drivers/input/mouse/synaptics.h
@@ -9,6 +9,21 @@
 #ifndef _SYNAPTICS_H
 #define _SYNAPTICS_H
 
+#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
+
+extern void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs);
+extern int synaptics_init(struct psmouse *psmouse);
+extern void synaptics_disconnect(struct psmouse *psmouse);
+
+#else
+
+static inline void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs) {}
+static inline int synaptics_init(struct psmouse *psmouse) { return -1; }
+static inline void synaptics_disconnect(struct psmouse *psmouse) {}
+
+#endif
+
+
 /* synaptics queries */
 #define SYN_QUE_IDENTIFY		0x00
 #define SYN_QUE_MODES			0x01
Signature · 2 lines
Peter Osterlund - [email protected]
http://w1.894.telia.com/~u89404340