
From: Peter Osterlund <petero2@telia.com>

Only parse a "z == 127" packet as a relative Dualpoint stick packet if the
touchpad actually is a Dualpoint device.  The Glidepoint models don't have a
stick, and can report z == 127 for a very wide finger.  If such a packet is
parsed as a stick packet, the mouse pointer will typically jump to one corner
of the screen.

Signed-off-by: Peter Osterlund <petero2@telia.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/input/mouse/alps.c |   20 ++++++++++----------
 25-akpm/drivers/input/mouse/alps.h |    1 +
 2 files changed, 11 insertions(+), 10 deletions(-)

diff -puN drivers/input/mouse/alps.c~input-fix-pointer-jumps-to-corner-of-screen-problem-on-alps-glidepoint-touchpads drivers/input/mouse/alps.c
--- 25/drivers/input/mouse/alps.c~input-fix-pointer-jumps-to-corner-of-screen-problem-on-alps-glidepoint-touchpads	2005-02-02 15:08:13.832511312 -0800
+++ 25-akpm/drivers/input/mouse/alps.c	2005-02-02 15:08:13.838510400 -0800
@@ -109,7 +109,8 @@ static void alps_process_packet(struct p
 	y = (packet[4] & 0x7f) | ((packet[3] & 0x70)<<(7-4));
 	z = packet[5];
 
-	if (z == 127) {	/* DualPoint stick is relative, not absolute */
+	if ((priv->model == ALPS_MODEL_DUALPOINT) && (z == 127)) {
+		/* DualPoint stick, relative packet */
 		if (x > 383)
 			x = x - 768;
 		if (y > 255)
@@ -344,13 +345,13 @@ static int alps_tap_mode(struct psmouse 
 
 static int alps_reconnect(struct psmouse *psmouse)
 {
-	int model;
+	struct alps_data *priv = psmouse->private;
 	unsigned char param[4];
 
-	if ((model = alps_get_model(psmouse)) < 0)
+	if ((priv->model = alps_get_model(psmouse)) < 0)
 		return -1;
 
-	if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 1))
+	if (priv->model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 1))
 		return -1;
 
 	if (alps_get_status(psmouse, param))
@@ -364,7 +365,7 @@ static int alps_reconnect(struct psmouse
 		return -1;
 	}
 
-	if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 0))
+	if (priv->model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 0))
 		return -1;
 
 	return 0;
@@ -380,20 +381,19 @@ int alps_init(struct psmouse *psmouse)
 {
 	struct alps_data *priv;
 	unsigned char param[4];
-	int model;
 
 	psmouse->private = priv = kmalloc(sizeof(struct alps_data), GFP_KERNEL);
 	if (!priv)
 		goto init_fail;
 	memset(priv, 0, sizeof(struct alps_data));
 
-	if ((model = alps_get_model(psmouse)) < 0)
+	if ((priv->model = alps_get_model(psmouse)) < 0)
 		goto init_fail;
 
 	printk(KERN_INFO "ALPS Touchpad (%s) detected\n",
-		model == ALPS_MODEL_GLIDEPOINT ? "Glidepoint" : "Dualpoint");
+		priv->model == ALPS_MODEL_GLIDEPOINT ? "Glidepoint" : "Dualpoint");
 
-	if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 1))
+	if (priv->model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 1))
 		goto init_fail;
 
 	if (alps_get_status(psmouse, param)) {
@@ -412,7 +412,7 @@ int alps_init(struct psmouse *psmouse)
 		goto init_fail;
 	}
 
-	if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 0))
+	if (priv->model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 0))
 		goto init_fail;
 
 	psmouse->dev.evbit[LONG(EV_REL)] |= BIT(EV_REL);
diff -puN drivers/input/mouse/alps.h~input-fix-pointer-jumps-to-corner-of-screen-problem-on-alps-glidepoint-touchpads drivers/input/mouse/alps.h
--- 25/drivers/input/mouse/alps.h~input-fix-pointer-jumps-to-corner-of-screen-problem-on-alps-glidepoint-touchpads	2005-02-02 15:08:13.834511008 -0800
+++ 25-akpm/drivers/input/mouse/alps.h	2005-02-02 15:08:13.838510400 -0800
@@ -15,6 +15,7 @@ int alps_detect(struct psmouse *psmouse,
 int alps_init(struct psmouse *psmouse);
 
 struct alps_data {
+	int model;			    /* Glidepoint or Dualpoint */
 	int prev_fin;			    /* Finger bit from previous packet */
 };
 
_
