public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* synaptics mouse jitter in 2.6.0
@ 2003-12-23  2:40 Thomas Molina
  2003-12-23  3:38 ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Molina @ 2003-12-23  2:40 UTC (permalink / raw)
  To: Kernel Mailing List

I am running Fedora Core 1 updated on a Presario 12XL325 laptop.  For a 
long time during the 2.5 series I couldn't use the synaptics support.  As 
a result, I haven't tested this for some time.  I just compiled a fresh 
2.6.0 tree, included synaptics support and now I am getting mouse jitter.

The easiest way to see this is to open Mozilla and go to a page with a lot 
of text links such as a news site with links to a number of stories.  
With synaptics support compiled in I get side to side jitter when moving 
the mouse over a link.  It looks as if my finger has a nervous twitch in 
it.  Then, when I take my finger off the touchpad to click on the link, 
the mouse cursor jumps about an eighth of an inch in a random direction.  It 
is very annoying since the jump takes it off the link and I can't click on 
it.

Compiling synaptics support out gets me back to a stable mouse cursor.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: synaptics mouse jitter in 2.6.0
  2003-12-23  2:40 synaptics mouse jitter in 2.6.0 Thomas Molina
@ 2003-12-23  3:38 ` Dmitry Torokhov
  2003-12-23  7:41   ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2003-12-23  3:38 UTC (permalink / raw)
  To: Thomas Molina, Kernel Mailing List

On Monday 22 December 2003 09:40 pm, Thomas Molina wrote:
> I am running Fedora Core 1 updated on a Presario 12XL325 laptop.  For a
> long time during the 2.5 series I couldn't use the synaptics support. 
> As a result, I haven't tested this for some time.  I just compiled a
> fresh 2.6.0 tree, included synaptics support and now I am getting mouse
> jitter.
>
> The easiest way to see this is to open Mozilla and go to a page with a
> lot of text links such as a news site with links to a number of
> stories. With synaptics support compiled in I get side to side jitter
> when moving the mouse over a link.  It looks as if my finger has a
> nervous twitch in it.  Then, when I take my finger off the touchpad to
> click on the link, the mouse cursor jumps about an eighth of an inch in
> a random direction.  It is very annoying since the jump takes it off
> the link and I can't click on it.
>
> Compiling synaptics support out gets me back to a stable mouse cursor.

Right, I think I see it. The mousedev module does not do any smoothing
of the reported coordinates which would cause the jitter you are seeing.
Normally drivers do 3- or 4-point average.

I'll cook up something to fix it. Meanwhile could you give a try Peter
Osterlund XFree86 Synaptics driver:
http://w1.894.telia.com/~u89404340/touchpad/index.html

Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: synaptics mouse jitter in 2.6.0
  2003-12-23  3:38 ` Dmitry Torokhov
@ 2003-12-23  7:41   ` Dmitry Torokhov
  2003-12-23  8:37     ` Andres Salomon
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2003-12-23  7:41 UTC (permalink / raw)
  To: Thomas Molina, Kernel Mailing List
  Cc: Vojtech Pavlik, Peter Osterlund, Andrew Morton

On Monday 22 December 2003 10:38 pm, Dmitry Torokhov wrote:
> On Monday 22 December 2003 09:40 pm, Thomas Molina wrote:
> > I am running Fedora Core 1 updated on a Presario 12XL325 laptop.  For
> > a long time during the 2.5 series I couldn't use the synaptics
> > support. As a result, I haven't tested this for some time.  I just
> > compiled a fresh 2.6.0 tree, included synaptics support and now I am
> > getting mouse jitter.
> >
<..SKIP..>
>
> Right, I think I see it. The mousedev module does not do any smoothing
> of the reported coordinates which would cause the jitter you are
> seeing. Normally drivers do 3- or 4-point average.
>
> I'll cook up something to fix it. Meanwhile could you give a try Peter
> Osterlund XFree86 Synaptics driver:
> http://w1.894.telia.com/~u89404340/touchpad/index.html
>

OK, here it is. It will apply against 2.6.0 although will complain about
some offsets as I have extra stuff in my tree...

Dmitry

===================================================================


ChangeSet@1.1522, 2003-12-23 02:24:12-05:00, dtor_core@ameritech.net
  Input: when calculating deltas for touchpads that generate
         absolute events use average over the last 3 packets
         to remove jitter


 mouse/synaptics.c |   11 ++++---
 mousedev.c        |   84 +++++++++++++++++++++++++++++++-----------------------
 2 files changed, 56 insertions(+), 39 deletions(-)


===================================================================



diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c	Tue Dec 23 02:25:14 2003
+++ b/drivers/input/mouse/synaptics.c	Tue Dec 23 02:25:14 2003
@@ -553,15 +553,18 @@
 		finger_width = 0;
 	}
 
-	/* Post events */
+	/* Post events
+	 * BTN_TOUCH has to be first as mousedev relies on it when doing
+	 * absolute -> relative conversion
+	 */
+	if (hw.z > 30) input_report_key(dev, BTN_TOUCH, 1);
+	if (hw.z < 25) input_report_key(dev, BTN_TOUCH, 0);
+
 	if (hw.z > 0) {
 		input_report_abs(dev, ABS_X, hw.x);
 		input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - hw.y);
 	}
 	input_report_abs(dev, ABS_PRESSURE, hw.z);
-
-	if (hw.z > 30) input_report_key(dev, BTN_TOUCH, 1);
-	if (hw.z < 25) input_report_key(dev, BTN_TOUCH, 0);
 
 	input_report_abs(dev, ABS_TOOL_WIDTH, finger_width);
 	input_report_key(dev, BTN_TOOL_FINGER, num_fingers == 1);
diff -Nru a/drivers/input/mousedev.c b/drivers/input/mousedev.c
--- a/drivers/input/mousedev.c	Tue Dec 23 02:25:14 2003
+++ b/drivers/input/mousedev.c	Tue Dec 23 02:25:14 2003
@@ -53,12 +53,14 @@
 	struct fasync_struct *fasync;
 	struct mousedev *mousedev;
 	struct list_head node;
-	int dx, dy, dz, oldx, oldy;
-	signed char ps2[6];
+	int dx, dy, dz;
+	int old_x[4], old_y[4];
 	unsigned long buttons;
+	signed char ps2[6];
 	unsigned char ready, buffer, bufsiz;
 	unsigned char mode, imexseq, impsseq;
-	int finger;
+	unsigned int pkt_count;
+	unsigned char touch;
 };
 
 #define MOUSEDEV_SEQ_LEN	6
@@ -74,49 +76,49 @@
 static int xres = CONFIG_INPUT_MOUSEDEV_SCREEN_X;
 static int yres = CONFIG_INPUT_MOUSEDEV_SCREEN_Y;
 
+#define fx(i)  (list->old_x[(list->pkt_count - (i)) & 03])
+#define fy(i)  (list->old_y[(list->pkt_count - (i)) & 03])
+
 static void mousedev_abs_event(struct input_handle *handle, struct mousedev_list *list, unsigned int code, int value)
 {
 	int size;
+	int touchpad;
 
 	/* Ignore joysticks */
 	if (test_bit(BTN_TRIGGER, handle->dev->keybit))
 		return;
 
-	/* Handle touchpad data */
-	if (test_bit(BTN_TOOL_FINGER, handle->dev->keybit)) {
+	touchpad = test_bit(BTN_TOOL_FINGER, handle->dev->keybit);
 
-		if (list->finger && list->finger < 3)
-			list->finger++;
-
-		switch (code) {
-			case ABS_X:
-				if (list->finger == 3)
-					list->dx += (value - list->oldx) / 8;
-				list->oldx = value;
-				return;
-			case ABS_Y:
-				if (list->finger == 3)
-					list->dy -= (value - list->oldy) / 8;
-				list->oldy = value;
-				return;
-		}
-		return;
-	}
-
-	/* Handle tablet data */
 	switch (code) {
 		case ABS_X:
-			size = handle->dev->absmax[ABS_X] - handle->dev->absmin[ABS_X];
-			if (size == 0) size = xres;
-			list->dx += (value * xres - list->oldx) / size;
-			list->oldx += list->dx * size;
-			return;
+			if (touchpad) {
+				if (list->touch) {
+					fx(0) = value;
+					if (list->pkt_count >= 2)
+						list->dx = ((fx(0) - fx(1)) / 2 + (fx(1) - fx(2)) / 2) / 8;
+				}
+			} else {
+				size = handle->dev->absmax[ABS_X] - handle->dev->absmin[ABS_X];
+				if (size == 0) size = xres;
+				list->dx += (value * xres - list->old_x[0]) / size;
+				list->old_x[0] += list->dx * size;
+			}
+			break;
 		case ABS_Y:
-			size = handle->dev->absmax[ABS_Y] - handle->dev->absmin[ABS_Y];
-			if (size == 0) size = yres;
-			list->dy -= (value * yres - list->oldy) / size;
-			list->oldy -= list->dy * size;
-			return;
+			if (touchpad) {
+				if (list->touch) {
+					fy(0) = value;
+					if (list->pkt_count >= 2)
+						list->dy = -((fy(0) - fy(1)) / 2 + (fy(1) - fy(2)) / 2) / 8;
+				}
+			} else {
+				size = handle->dev->absmax[ABS_Y] - handle->dev->absmin[ABS_Y];
+				if (size == 0) size = yres;
+				list->dy -= (value * yres - list->old_y[0]) / size;
+				list->old_y[0] -= list->dy * size;
+			}
+			break;
 	}
 }
 
@@ -149,7 +151,9 @@
 					switch (code) {
 						case BTN_TOUCH: /* Handle touchpad data */
 							if (test_bit(BTN_TOOL_FINGER, handle->dev->keybit)) {
-								list->finger = value;
+								list->touch = value;
+								if (!list->touch)
+									list->pkt_count = 0;
 								return;
 							}
 						case BTN_0:
@@ -178,6 +182,16 @@
 				case EV_SYN:
 					switch (code) {
 						case SYN_REPORT:
+							if (list->touch) {
+								list->pkt_count++;
+								/* Input system eats duplicate events, 
+								 * but we need all of them to do correct
+								 * averaging so apply present one forward
+								 */
+								fx(0) = fx(1);
+								fy(0) = fy(1);
+							}
+
 							list->ready = 1;
 							kill_fasync(&list->fasync, SIGIO, POLL_IN);
 							wake = 1;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: synaptics mouse jitter in 2.6.0
  2003-12-23  7:41   ` Dmitry Torokhov
@ 2003-12-23  8:37     ` Andres Salomon
  2003-12-23 18:37       ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: Andres Salomon @ 2003-12-23  8:37 UTC (permalink / raw)
  To: linux-kernel

On Tue, 23 Dec 2003 02:41:49 -0500, Dmitry Torokhov wrote:

> On Monday 22 December 2003 10:38 pm, Dmitry Torokhov wrote:
>> On Monday 22 December 2003 09:40 pm, Thomas Molina wrote:
>> > I am running Fedora Core 1 updated on a Presario 12XL325 laptop.  For
>> > a long time during the 2.5 series I couldn't use the synaptics
>> > support. As a result, I haven't tested this for some time.  I just
>> > compiled a fresh 2.6.0 tree, included synaptics support and now I am
>> > getting mouse jitter.
>> >
> <..SKIP..>
>>
>> Right, I think I see it. The mousedev module does not do any smoothing
>> of the reported coordinates which would cause the jitter you are
>> seeing. Normally drivers do 3- or 4-point average.
>>
>> I'll cook up something to fix it. Meanwhile could you give a try Peter
>> Osterlund XFree86 Synaptics driver:
>> http://w1.894.telia.com/~u89404340/touchpad/index.html
>>
> 
> OK, here it is. It will apply against 2.6.0 although will complain about
> some offsets as I have extra stuff in my tree...
> 
> Dmitry
> 
[...]

This works a lot better than both -mm1 and stock 2.6.0's mouse behavior
for me; 2.6.0 likes to drop packets inside the interrupt handler and make
the mouse jump to the edge of the screen, and 2.6.0-mm1 likes to move the
pointer between the time I take my finger off the touchpad and hit the
mouse button.  This appears to fix both issues; however, I still see the
following in logs:

Dec 23 03:33:53 spiral kernel: Synaptics driver lost sync at byte 4
Dec 23 03:33:53 spiral kernel: Synaptics driver lost sync at byte 1
Dec 23 03:33:53 spiral kernel: Synaptics driver resynced.
Dec 23 03:33:55 spiral kernel: Synaptics driver lost sync at byte 1
Dec 23 03:33:55 spiral last message repeated 4 times
Dec 23 03:33:55 spiral kernel: Synaptics driver resynced.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: synaptics mouse jitter in 2.6.0
  2003-12-23  8:37     ` Andres Salomon
@ 2003-12-23 18:37       ` Dmitry Torokhov
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2003-12-23 18:37 UTC (permalink / raw)
  To: Andres Salomon, linux-kernel

On Tuesday 23 December 2003 03:37 am, Andres Salomon wrote:

> [...]
>
> This works a lot better than both -mm1 and stock 2.6.0's mouse behavior
> for me; 2.6.0 likes to drop packets inside the interrupt handler and
> make the mouse jump to the edge of the screen, and 2.6.0-mm1 likes to
> move the pointer between the time I take my finger off the touchpad and
> hit the mouse button.  This appears to fix both issues; however, I
> still see the following in logs:
>
> Dec 23 03:33:53 spiral kernel: Synaptics driver lost sync at byte 4
> Dec 23 03:33:53 spiral kernel: Synaptics driver lost sync at byte 1
> Dec 23 03:33:53 spiral kernel: Synaptics driver resynced.
> Dec 23 03:33:55 spiral kernel: Synaptics driver lost sync at byte 1
> Dec 23 03:33:55 spiral last message repeated 4 times
> Dec 23 03:33:55 spiral kernel: Synaptics driver resynced.
>

That is a known issue with ACPI and i8042 (you do use ACPI, don't you?)
that we were not able to pinpoint yet. The solution that helps a bit is
to poll battery state/tepmerature less frequently.

Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-12-23 18:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-23  2:40 synaptics mouse jitter in 2.6.0 Thomas Molina
2003-12-23  3:38 ` Dmitry Torokhov
2003-12-23  7:41   ` Dmitry Torokhov
2003-12-23  8:37     ` Andres Salomon
2003-12-23 18:37       ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox