All of lore.kernel.org
 help / color / mirror / Atom feed
* Fix sudden warps in mousedev
@ 2007-03-24  7:16 ` Pete Zaitcev
  0 siblings, 0 replies; 15+ messages in thread
From: Pete Zaitcev @ 2007-03-24  7:16 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: zaitcev, linux-kernel, linux-input

Here's another one of those soon-to-be-obsoleted patches to mousedev.
But if it lives just in 2.6.21, it's good, right? It's a pure bugfix.

On my laptop with Synaptics, if I lift the finger and place it elsewhere,
the pointer sometimes warps dramatically. Here's the evtest trace
which illustrates what happens:

Event: time 1174703240.830555, type 3 (Absolute), code 0 (X), value 3907
Event: time 1174703240.830557, type 3 (Absolute), code 1 (Y), value 3684
Event: time 1174703240.830561, -------------- Report Sync ------------
Event: time 1174703240.842205, type 3 (Absolute), code 0 (X), value 3909
Event: time 1174703240.842208, type 3 (Absolute), code 1 (Y), value 3687
         <---- value used by fy(2) later
Event: time 1174703240.842211, -------------- Report Sync ------------
Event: time 1174703240.854912, type 3 (Absolute), code 24 (Pressure), value 30
Event: time 1174703240.854917, -------------- Report Sync ------------
Event: time 1174703240.867130, type 1 (Key), code 330 (Touch), value 0
         <---- touch=0 now, we drop pkt_count here
Event: time 1174703240.867133, type 3 (Absolute), code 0 (X), value 3913
Event: time 1174703240.867135, type 3 (Absolute), code 1 (Y), value 3699
Event: time 1174703240.867137, type 3 (Absolute), code 24 (Pressure), value 17
Event: time 1174703240.867139, -------------- Report Sync ------------
Event: time 1174703240.877716, type 3 (Absolute), code 0 (X), value 3899
Event: time 1174703240.877718, type 3 (Absolute), code 1 (Y), value 3720
Event: time 1174703240.877721, type 3 (Absolute), code 24 (Pressure), value 8
Event: time 1174703240.877723, type 3 (Absolute), code 28 (Tool Width), value 5
Event: time 1174703240.877725, -------------- Report Sync ------------
Event: time 1174703240.891954, type 3 (Absolute), code 0 (X), value 3898
Event: time 1174703240.891957, type 3 (Absolute), code 1 (Y), value 3746
Event: time 1174703240.891959, type 3 (Absolute), code 24 (Pressure), value 5
Event: time 1174703240.891960, type 3 (Absolute), code 28 (Tool Width), value 6
Event: time 1174703240.891965, -------------- Report Sync ------------
Event: time 1174703240.918746, type 3 (Absolute), code 0 (X), value 1
Event: time 1174703240.918749, type 3 (Absolute), code 1 (Y), value 5855
Event: time 1174703240.918751, type 3 (Absolute), code 24 (Pressure), value 3
Event: time 1174703240.918753, type 3 (Absolute), code 28 (Tool Width), value 5
Event: time 1174703240.918756, type 1 (Key), code 325 (ToolFinger), value 0
Event: time 1174703240.918758, type 1 (Key), code 333 (Tool Doubletap), value 1
Event: time 1174703240.918760, -------------- Report Sync ------------
Event: time 1174703240.929545, type 3 (Absolute), code 24 (Pressure), value 2
Event: time 1174703240.929549, -------------- Report Sync ------------
Event: time 1174703241.137650, type 3 (Absolute), code 24 (Pressure), value 1
Event: time 1174703241.137655, -------------- Report Sync ------------
Event: time 1174703241.386150, type 3 (Absolute), code 24 (Pressure), value 0
Event: time 1174703241.386153, type 3 (Absolute), code 28 (Tool Width), value 0
Event: time 1174703241.386155, type 1 (Key), code 333 (Tool Doubletap), value 0
Event: time 1174703241.386158, -------------- Report Sync ------------
Event: time 1174703243.119979, type 3 (Absolute), code 0 (X), value 4763
Event: time 1174703243.119982, type 3 (Absolute), code 1 (Y), value 1964
Event: time 1174703243.119984, type 3 (Absolute), code 24 (Pressure), value 8
Event: time 1174703243.119985, type 3 (Absolute), code 28 (Tool Width), value 5
Event: time 1174703243.119987, type 1 (Key), code 325 (ToolFinger), value 1
Event: time 1174703243.119990, -------------- Report Sync ------------
Event: time 1174703243.131696, type 3 (Absolute), code 0 (X), value 4760
Event: time 1174703243.131699, type 3 (Absolute), code 1 (Y), value 1961
Event: time 1174703243.131701, type 3 (Absolute), code 24 (Pressure), value 9
Event: time 1174703243.131703, -------------- Report Sync ------------
Event: time 1174703243.143436, type 3 (Absolute), code 24 (Pressure), value 12
Event: time 1174703243.143440, type 3 (Absolute), code 28 (Tool Width), value 4
Event: time 1174703243.143442, -------------- Report Sync ------------
Event: time 1174703243.157148, type 3 (Absolute), code 24 (Pressure), value 15
Event: time 1174703243.157153, -------------- Report Sync ------------
Event: time 1174703243.169804, type 3 (Absolute), code 0 (X), value 4757
Event: time 1174703243.169806, type 3 (Absolute), code 1 (Y), value 1999
Event: time 1174703243.169808, type 3 (Absolute), code 24 (Pressure), value 18
Event: time 1174703243.169811, -------------- Report Sync ------------
Event: time 1174703243.181728, type 3 (Absolute), code 0 (X), value 4753
Event: time 1174703243.181731, type 3 (Absolute), code 24 (Pressure), value 20
Event: time 1174703243.181735, -------------- Report Sync ------------
Event: time 1174703243.193445, type 3 (Absolute), code 24 (Pressure), value 21
Event: time 1174703243.193448, -------------- Report Sync ------------
Event: time 1174703243.206640, type 3 (Absolute), code 0 (X), value 4748
Event: time 1174703243.206643, type 3 (Absolute), code 1 (Y), value 1997
Event: time 1174703243.206645, type 3 (Absolute), code 24 (Pressure), value 23
Event: time 1174703243.206647, -------------- Report Sync ------------
Event: time 1174703243.219358, type 3 (Absolute), code 24 (Pressure), value 24
Event: time 1174703243.219362, -------------- Report Sync ------------
Event: time 1174703243.231448, type 3 (Absolute), code 0 (X), value 4752
Event: time 1174703243.231450, type 3 (Absolute), code 1 (Y), value 1993
Event: time 1174703243.231452, type 3 (Absolute), code 24 (Pressure), value 25
Event: time 1174703243.231455, -------------- Report Sync ------------
Event: time 1174703243.243435, type 3 (Absolute), code 1 (Y), value 1989
Event: time 1174703243.243438, type 3 (Absolute), code 24 (Pressure), value 27
Event: time 1174703243.243440, -------------- Report Sync ------------
Event: time 1174703243.255193, type 3 (Absolute), code 0 (X), value 4748
Event: time 1174703243.255197, type 3 (Absolute), code 24 (Pressure), value 28
Event: time 1174703243.255201, -------------- Report Sync ------------
Event: time 1174703243.268904, type 3 (Absolute), code 0 (X), value 4746
Event: time 1174703243.268907, type 3 (Absolute), code 1 (Y), value 1990
Event: time 1174703243.268909, type 3 (Absolute), code 24 (Pressure), value 29
Event: time 1174703243.268911, -------------- Report Sync ------------
Event: time 1174703243.293295, type 3 (Absolute), code 1 (Y), value 1986
Event: time 1174703243.293298, type 3 (Absolute), code 24 (Pressure), value 30
Event: time 1174703243.293301, -------------- Report Sync ------------
Event: time 1174703243.305535, type 1 (Key), code 330 (Touch), value 1
          <---- touch!=0 now, we're on
Event: time 1174703243.305538, type 3 (Absolute), code 24 (Pressure), value 31
Event: time 1174703243.305541, -------------- Report Sync ------------
          <---- We increment the pkt_count, leaving value of 3687 in old_y
Event: time 1174703243.342452, type 3 (Absolute), code 0 (X), value 4747
Event: time 1174703243.342455, type 3 (Absolute), code 1 (Y), value 1988
          <----- Later to be fy(1), not used for warping purposes :-)
Event: time 1174703243.342459, -------------- Report Sync ------------
Event: time 1174703243.356225, type 3 (Absolute), code 0 (X), value 4749
Event: time 1174703243.356237, type 3 (Absolute), code 1 (Y), value 1987
          <----- warp here, by the difference of 3687 and 1987, plus
                 some small frac_dy value. Easily jumps half the screen.
Event: time 1174703243.356246, -------------- Report Sync ------------

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>

--- linux-2.6/drivers/input/mousedev.c	2007-02-11 12:38:54.000000000 -0800
+++ linux-2.6.21-input/drivers/input/mousedev.c	2007-03-23 23:47:51.000000000 -0700
@@ -274,6 +279,8 @@ static void mousedev_notify_readers(stru
 
 static void mousedev_touchpad_touch(struct mousedev *mousedev, int value)
 {
+	struct input_dev *dev;
+
 	if (!value) {
 		if (mousedev->touch &&
 		    time_before(jiffies, mousedev->touch + msecs_to_jiffies(tap_time))) {
@@ -293,8 +300,22 @@ static void mousedev_touchpad_touch(stru
 		mousedev->frac_dx = 0;
 		mousedev->frac_dy = 0;
 
-	} else if (!mousedev->touch)
+	} else if (!mousedev->touch) {
 		mousedev->touch = jiffies;
+		/*
+		 * Seed the ring with new position where finger has just landed.
+		 *
+		 * Without this, a touchpad may report an unchanged position,
+		 * then a sync. The input_event() eats the position report, but
+		 * lets the sync through. We increment pkt_count and leave 
+		 * a stale position in the ring. If a future reference to fx(2)
+		 * hits the stale position, a large dx is reported, and the
+		 * pointer warps across the screen.
+		 */
+		dev = mousedev->handle.dev;
+		fx(0) = dev->abs[ABS_X];
+		fy(0) = dev->abs[ABS_Y];
+	}
 }
 
 static void mousedev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)

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

* Fix sudden warps in mousedev
@ 2007-03-24  7:16 ` Pete Zaitcev
  0 siblings, 0 replies; 15+ messages in thread
From: Pete Zaitcev @ 2007-03-24  7:16 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: zaitcev, linux-kernel, linux-input

Here's another one of those soon-to-be-obsoleted patches to mousedev.
But if it lives just in 2.6.21, it's good, right? It's a pure bugfix.

On my laptop with Synaptics, if I lift the finger and place it elsewhere,
the pointer sometimes warps dramatically. Here's the evtest trace
which illustrates what happens:

Event: time 1174703240.830555, type 3 (Absolute), code 0 (X), value 3907
Event: time 1174703240.830557, type 3 (Absolute), code 1 (Y), value 3684
Event: time 1174703240.830561, -------------- Report Sync ------------
Event: time 1174703240.842205, type 3 (Absolute), code 0 (X), value 3909
Event: time 1174703240.842208, type 3 (Absolute), code 1 (Y), value 3687
         <---- value used by fy(2) later
Event: time 1174703240.842211, -------------- Report Sync ------------
Event: time 1174703240.854912, type 3 (Absolute), code 24 (Pressure), value 30
Event: time 1174703240.854917, -------------- Report Sync ------------
Event: time 1174703240.867130, type 1 (Key), code 330 (Touch), value 0
         <---- touch=0 now, we drop pkt_count here
Event: time 1174703240.867133, type 3 (Absolute), code 0 (X), value 3913
Event: time 1174703240.867135, type 3 (Absolute), code 1 (Y), value 3699
Event: time 1174703240.867137, type 3 (Absolute), code 24 (Pressure), value 17
Event: time 1174703240.867139, -------------- Report Sync ------------
Event: time 1174703240.877716, type 3 (Absolute), code 0 (X), value 3899
Event: time 1174703240.877718, type 3 (Absolute), code 1 (Y), value 3720
Event: time 1174703240.877721, type 3 (Absolute), code 24 (Pressure), value 8
Event: time 1174703240.877723, type 3 (Absolute), code 28 (Tool Width), value 5
Event: time 1174703240.877725, -------------- Report Sync ------------
Event: time 1174703240.891954, type 3 (Absolute), code 0 (X), value 3898
Event: time 1174703240.891957, type 3 (Absolute), code 1 (Y), value 3746
Event: time 1174703240.891959, type 3 (Absolute), code 24 (Pressure), value 5
Event: time 1174703240.891960, type 3 (Absolute), code 28 (Tool Width), value 6
Event: time 1174703240.891965, -------------- Report Sync ------------
Event: time 1174703240.918746, type 3 (Absolute), code 0 (X), value 1
Event: time 1174703240.918749, type 3 (Absolute), code 1 (Y), value 5855
Event: time 1174703240.918751, type 3 (Absolute), code 24 (Pressure), value 3
Event: time 1174703240.918753, type 3 (Absolute), code 28 (Tool Width), value 5
Event: time 1174703240.918756, type 1 (Key), code 325 (ToolFinger), value 0
Event: time 1174703240.918758, type 1 (Key), code 333 (Tool Doubletap), value 1
Event: time 1174703240.918760, -------------- Report Sync ------------
Event: time 1174703240.929545, type 3 (Absolute), code 24 (Pressure), value 2
Event: time 1174703240.929549, -------------- Report Sync ------------
Event: time 1174703241.137650, type 3 (Absolute), code 24 (Pressure), value 1
Event: time 1174703241.137655, -------------- Report Sync ------------
Event: time 1174703241.386150, type 3 (Absolute), code 24 (Pressure), value 0
Event: time 1174703241.386153, type 3 (Absolute), code 28 (Tool Width), value 0
Event: time 1174703241.386155, type 1 (Key), code 333 (Tool Doubletap), value 0
Event: time 1174703241.386158, -------------- Report Sync ------------
Event: time 1174703243.119979, type 3 (Absolute), code 0 (X), value 4763
Event: time 1174703243.119982, type 3 (Absolute), code 1 (Y), value 1964
Event: time 1174703243.119984, type 3 (Absolute), code 24 (Pressure), value 8
Event: time 1174703243.119985, type 3 (Absolute), code 28 (Tool Width), value 5
Event: time 1174703243.119987, type 1 (Key), code 325 (ToolFinger), value 1
Event: time 1174703243.119990, -------------- Report Sync ------------
Event: time 1174703243.131696, type 3 (Absolute), code 0 (X), value 4760
Event: time 1174703243.131699, type 3 (Absolute), code 1 (Y), value 1961
Event: time 1174703243.131701, type 3 (Absolute), code 24 (Pressure), value 9
Event: time 1174703243.131703, -------------- Report Sync ------------
Event: time 1174703243.143436, type 3 (Absolute), code 24 (Pressure), value 12
Event: time 1174703243.143440, type 3 (Absolute), code 28 (Tool Width), value 4
Event: time 1174703243.143442, -------------- Report Sync ------------
Event: time 1174703243.157148, type 3 (Absolute), code 24 (Pressure), value 15
Event: time 1174703243.157153, -------------- Report Sync ------------
Event: time 1174703243.169804, type 3 (Absolute), code 0 (X), value 4757
Event: time 1174703243.169806, type 3 (Absolute), code 1 (Y), value 1999
Event: time 1174703243.169808, type 3 (Absolute), code 24 (Pressure), value 18
Event: time 1174703243.169811, -------------- Report Sync ------------
Event: time 1174703243.181728, type 3 (Absolute), code 0 (X), value 4753
Event: time 1174703243.181731, type 3 (Absolute), code 24 (Pressure), value 20
Event: time 1174703243.181735, -------------- Report Sync ------------
Event: time 1174703243.193445, type 3 (Absolute), code 24 (Pressure), value 21
Event: time 1174703243.193448, -------------- Report Sync ------------
Event: time 1174703243.206640, type 3 (Absolute), code 0 (X), value 4748
Event: time 1174703243.206643, type 3 (Absolute), code 1 (Y), value 1997
Event: time 1174703243.206645, type 3 (Absolute), code 24 (Pressure), value 23
Event: time 1174703243.206647, -------------- Report Sync ------------
Event: time 1174703243.219358, type 3 (Absolute), code 24 (Pressure), value 24
Event: time 1174703243.219362, -------------- Report Sync ------------
Event: time 1174703243.231448, type 3 (Absolute), code 0 (X), value 4752
Event: time 1174703243.231450, type 3 (Absolute), code 1 (Y), value 1993
Event: time 1174703243.231452, type 3 (Absolute), code 24 (Pressure), value 25
Event: time 1174703243.231455, -------------- Report Sync ------------
Event: time 1174703243.243435, type 3 (Absolute), code 1 (Y), value 1989
Event: time 1174703243.243438, type 3 (Absolute), code 24 (Pressure), value 27
Event: time 1174703243.243440, -------------- Report Sync ------------
Event: time 1174703243.255193, type 3 (Absolute), code 0 (X), value 4748
Event: time 1174703243.255197, type 3 (Absolute), code 24 (Pressure), value 28
Event: time 1174703243.255201, -------------- Report Sync ------------
Event: time 1174703243.268904, type 3 (Absolute), code 0 (X), value 4746
Event: time 1174703243.268907, type 3 (Absolute), code 1 (Y), value 1990
Event: time 1174703243.268909, type 3 (Absolute), code 24 (Pressure), value 29
Event: time 1174703243.268911, -------------- Report Sync ------------
Event: time 1174703243.293295, type 3 (Absolute), code 1 (Y), value 1986
Event: time 1174703243.293298, type 3 (Absolute), code 24 (Pressure), value 30
Event: time 1174703243.293301, -------------- Report Sync ------------
Event: time 1174703243.305535, type 1 (Key), code 330 (Touch), value 1
          <---- touch!=0 now, we're on
Event: time 1174703243.305538, type 3 (Absolute), code 24 (Pressure), value 31
Event: time 1174703243.305541, -------------- Report Sync ------------
          <---- We increment the pkt_count, leaving value of 3687 in old_y
Event: time 1174703243.342452, type 3 (Absolute), code 0 (X), value 4747
Event: time 1174703243.342455, type 3 (Absolute), code 1 (Y), value 1988
          <----- Later to be fy(1), not used for warping purposes :-)
Event: time 1174703243.342459, -------------- Report Sync ------------
Event: time 1174703243.356225, type 3 (Absolute), code 0 (X), value 4749
Event: time 1174703243.356237, type 3 (Absolute), code 1 (Y), value 1987
          <----- warp here, by the difference of 3687 and 1987, plus
                 some small frac_dy value. Easily jumps half the screen.
Event: time 1174703243.356246, -------------- Report Sync ------------

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>

--- linux-2.6/drivers/input/mousedev.c	2007-02-11 12:38:54.000000000 -0800
+++ linux-2.6.21-input/drivers/input/mousedev.c	2007-03-23 23:47:51.000000000 -0700
@@ -274,6 +279,8 @@ static void mousedev_notify_readers(stru
 
 static void mousedev_touchpad_touch(struct mousedev *mousedev, int value)
 {
+	struct input_dev *dev;
+
 	if (!value) {
 		if (mousedev->touch &&
 		    time_before(jiffies, mousedev->touch + msecs_to_jiffies(tap_time))) {
@@ -293,8 +300,22 @@ static void mousedev_touchpad_touch(stru
 		mousedev->frac_dx = 0;
 		mousedev->frac_dy = 0;
 
-	} else if (!mousedev->touch)
+	} else if (!mousedev->touch) {
 		mousedev->touch = jiffies;
+		/*
+		 * Seed the ring with new position where finger has just landed.
+		 *
+		 * Without this, a touchpad may report an unchanged position,
+		 * then a sync. The input_event() eats the position report, but
+		 * lets the sync through. We increment pkt_count and leave 
+		 * a stale position in the ring. If a future reference to fx(2)
+		 * hits the stale position, a large dx is reported, and the
+		 * pointer warps across the screen.
+		 */
+		dev = mousedev->handle.dev;
+		fx(0) = dev->abs[ABS_X];
+		fy(0) = dev->abs[ABS_Y];
+	}
 }
 
 static void mousedev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)

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

* Re: Fix sudden warps in mousedev
  2007-03-24  7:16 ` Pete Zaitcev
  (?)
@ 2007-03-25  5:34 ` Dmitry Torokhov
  2007-03-25 18:19   ` Pete Zaitcev
  -1 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2007-03-25  5:34 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: linux-kernel, linux-input

Hi Pete,

On Saturday 24 March 2007 03:16, Pete Zaitcev wrote:
> -       } else if (!mousedev->touch)
> +       } else if (!mousedev->touch) {
>                 mousedev->touch = jiffies;
> +               /*
> +                * Seed the ring with new position where finger has just landed.
> +                *
> +                * Without this, a touchpad may report an unchanged position,
> +                * then a sync. The input_event() eats the position report, but
> +                * lets the sync through. We increment pkt_count and leave 
> +                * a stale position in the ring. If a future reference to fx(2)
> +                * hits the stale position, a large dx is reported, and the
> +                * pointer warps across the screen.
> +                */
> +               dev = mousedev->handle.dev;
> +               fx(0) = dev->abs[ABS_X];
> +               fy(0) = dev->abs[ABS_Y];
> 

I do not like input hanlders poking into input devices... Can't we just
reset pkt_count at the beginning of the touch to get rid of stale data?

-- 
Dmitry

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

* Re: Fix sudden warps in mousedev
  2007-03-25  5:34 ` Dmitry Torokhov
@ 2007-03-25 18:19   ` Pete Zaitcev
  2007-03-26  3:19     ` Dmitry Torokhov
  0 siblings, 1 reply; 15+ messages in thread
From: Pete Zaitcev @ 2007-03-25 18:19 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, linux-input, zaitcev

On Sun, 25 Mar 2007 01:34:02 -0400, Dmitry Torokhov <dtor@insightbb.com> wrote:

> > +                * Without this, a touchpad may report an unchanged position,
> > +                * then a sync. The input_event() eats the position report, but
> > +                * lets the sync through. We increment pkt_count and leave 
> > +                * a stale position in the ring. If a future reference to fx(2)
> > +                * hits the stale position, a large dx is reported, and the
> > +                * pointer warps across the screen.
> > +                */
> > +               dev = mousedev->handle.dev;
> > +               fx(0) = dev->abs[ABS_X];
> > +               fy(0) = dev->abs[ABS_Y];
> 
> I do not like input hanlders poking into input devices... Can't we just
> reset pkt_count at the beginning of the touch to get rid of stale data?

The pkt_count is zero at the moment of assignment above.

Please look at the included trace again:

> > Event: time 1174703243.305535, type 1 (Key), code 330 (Touch), value 1
> >           <---- touch!=0 now, we're on
> > Event: time 1174703243.305538, type 3 (Absolute), code 24 (Pressure), value 31
> > Event: time 1174703243.305541, -------------- Report Sync ------------
> >           <---- We increment the pkt_count, leaving value of 3687 in old_y
> > Event: time 1174703243.342452, type 3 (Absolute), code 0 (X), value 4747
> > Event: time 1174703243.342455, type 3 (Absolute), code 1 (Y), value 1988
> >           <----- Later to be fy(1), not used for warping purposes :-)
> > Event: time 1174703243.342459, -------------- Report Sync ------------
> > Event: time 1174703243.356225, type 3 (Absolute), code 0 (X), value 4749
> > Event: time 1174703243.356237, type 3 (Absolute), code 1 (Y), value 1987
> >           <----- warp here, by the difference of 3687 and 1987, plus
> >                  some small frac_dy value. Easily jumps half the screen.
> > Event: time 1174703243.356246, -------------- Report Sync ------------

The assignment happens at .305535. The pkt_count is zero, and fy(0) contains
stale data (ovewritten by the assignment). The touchpad reports a position
next with input_report_abs(). If the position were different, we'd receive
an event between .305535 and .305538 and it would be stored in fy(0).

However, if position is the same, as in this case, input_report eats it.
At .305541 we increment pkt_count. The fy(0) location becomes fy(1) at
this point. Without the assignment it contains the stale position.

I can explore alternatives, but for now using dev->abs[] seems to be most
expedient.

-- Pete

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

* Re: Fix sudden warps in mousedev
  2007-03-25 18:19   ` Pete Zaitcev
@ 2007-03-26  3:19     ` Dmitry Torokhov
  2007-03-26 19:17       ` Pete Zaitcev
  0 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2007-03-26  3:19 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: linux-kernel, linux-input

On Sunday 25 March 2007 14:19, Pete Zaitcev wrote:
> On Sun, 25 Mar 2007 01:34:02 -0400, Dmitry Torokhov <dtor@insightbb.com> wrote:
> 
> > > +                * Without this, a touchpad may report an unchanged position,
> > > +                * then a sync. The input_event() eats the position report, but
> > > +                * lets the sync through. We increment pkt_count and leave 
> > > +                * a stale position in the ring. If a future reference to fx(2)
> > > +                * hits the stale position, a large dx is reported, and the
> > > +                * pointer warps across the screen.
> > > +                */
> > > +               dev = mousedev->handle.dev;
> > > +               fx(0) = dev->abs[ABS_X];
> > > +               fy(0) = dev->abs[ABS_Y];
> > 
> > I do not like input hanlders poking into input devices... Can't we just
> > reset pkt_count at the beginning of the touch to get rid of stale data?
> 
> The pkt_count is zero at the moment of assignment above.

Riiight... Of course you are right...

I tried to reproduce warping on console but could not for some reason. Could you
please try the patch below and tell me if it fixes the problem for you?

-- 
Dmitry

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/mousedev.c |   51 +++++++++++++++++++++++------------------------
 1 files changed, 26 insertions(+), 25 deletions(-)

Index: work/drivers/input/mousedev.c
===================================================================
--- work.orig/drivers/input/mousedev.c
+++ work/drivers/input/mousedev.c
@@ -124,32 +124,33 @@ static void mousedev_touchpad_event(stru
 	int size, tmp;
 	enum { FRACTION_DENOM = 128 };
 
-	if (mousedev->touch) {
-		size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
-		if (size == 0)
-			size = 256 * 2;
-
-		switch (code) {
-			case ABS_X:
-				fx(0) = value;
-				if (mousedev->pkt_count >= 2) {
-					tmp = ((value - fx(2)) * (256 * FRACTION_DENOM)) / size;
-					tmp += mousedev->frac_dx;
-					mousedev->packet.dx = tmp / FRACTION_DENOM;
-					mousedev->frac_dx = tmp - mousedev->packet.dx * FRACTION_DENOM;
-				}
-				break;
+	switch (code) {
+		case ABS_X:
+			fx(0) = value;
+			if (mousedev->touch && mousedev->pkt_count >= 2) {
+				size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
+				if (size == 0)
+					size = 256 * 2;
+				tmp = ((value - fx(2)) * (256 * FRACTION_DENOM)) / size;
+				tmp += mousedev->frac_dx;
+				mousedev->packet.dx = tmp / FRACTION_DENOM;
+				mousedev->frac_dx = tmp - mousedev->packet.dx * FRACTION_DENOM;
+			}
+			break;
 
-			case ABS_Y:
-				fy(0) = value;
-				if (mousedev->pkt_count >= 2) {
-					tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size;
-					tmp += mousedev->frac_dy;
-					mousedev->packet.dy = tmp / FRACTION_DENOM;
-					mousedev->frac_dy = tmp - mousedev->packet.dy * FRACTION_DENOM;
-				}
-				break;
-		}
+		case ABS_Y:
+			fy(0) = value;
+			if (mousedev->touch && mousedev->pkt_count >= 2) {
+				/* use X size to keep the same scale */
+				size = dev->absmax[ABS_X] - dev->absmin[ABS_X];
+				if (size == 0)
+					size = 256 * 2;
+				tmp = -((value - fy(2)) * (256 * FRACTION_DENOM)) / size;
+				tmp += mousedev->frac_dy;
+				mousedev->packet.dy = tmp / FRACTION_DENOM;
+				mousedev->frac_dy = tmp - mousedev->packet.dy * FRACTION_DENOM;
+			}
+			break;
 	}
 }
 

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

* Re: Fix sudden warps in mousedev
  2007-03-26  3:19     ` Dmitry Torokhov
@ 2007-03-26 19:17       ` Pete Zaitcev
  2007-03-26 19:30         ` Dmitry Torokhov
  0 siblings, 1 reply; 15+ messages in thread
From: Pete Zaitcev @ 2007-03-26 19:17 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, linux-input, zaitcev

On Sun, 25 Mar 2007 23:19:38 -0400, Dmitry Torokhov <dtor@insightbb.com> wrote:

> I tried to reproduce warping on console but could not for some reason. Could you
> please try the patch below and tell me if it fixes the problem for you?

> +++ work/drivers/input/mousedev.c
> @@ -124,32 +124,33 @@ static void mousedev_touchpad_event(stru
> -				if (mousedev->pkt_count >= 2) {
> +			if (mousedev->touch && mousedev->pkt_count >= 2) {

This works, thanks a lot.

The double-indented switch() is annoying, but since the whole driver
is written to the same style, I can live with it, for the uniformity
purposes :-)

You can't imagine the relief of using a reliable pointer again, after
months of touching the pad with a certain trepidation.

-- Pete

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

* Re: Fix sudden warps in mousedev
  2007-03-26 19:17       ` Pete Zaitcev
@ 2007-03-26 19:30         ` Dmitry Torokhov
  2007-03-26 21:42           ` Pete Zaitcev
  0 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2007-03-26 19:30 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: linux-kernel, linux-input

On 3/26/07, Pete Zaitcev <zaitcev@redhat.com> wrote:
> On Sun, 25 Mar 2007 23:19:38 -0400, Dmitry Torokhov <dtor@insightbb.com> wrote:
>
> > I tried to reproduce warping on console but could not for some reason. Could you
> > please try the patch below and tell me if it fixes the problem for you?
>
> > +++ work/drivers/input/mousedev.c
> > @@ -124,32 +124,33 @@ static void mousedev_touchpad_event(stru
> > -                             if (mousedev->pkt_count >= 2) {
> > +                     if (mousedev->touch && mousedev->pkt_count >= 2) {
>
> This works, thanks a lot.
>

Great! Then I'll queue it for 2.6.22.

> The double-indented switch() is annoying, but since the whole driver
> is written to the same style, I can live with it, for the uniformity
> purposes :-)
>

Yes, the whole input is like this so I keep it consistent.

Regarding the synaptics driver and scroll problem. Yesterday I
scrolled twice through entire Remarque's "Spark of Life" off lib.ru
(once with 0.14.2 and once with latest git pull) and did not see any
scrollbar getting "stuck". Could it be newer xorg problem instead of
individual driver problem? I am using whatever xorg was installed in
FC3 which is somewhat dated... Also, could it be that the scroll issue
happens only in a certain application?

-- 
Dmitry

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

* Re: Fix sudden warps in mousedev
  2007-03-26 19:30         ` Dmitry Torokhov
@ 2007-03-26 21:42           ` Pete Zaitcev
  2007-03-27  1:14             ` Dmitry Torokhov
  0 siblings, 1 reply; 15+ messages in thread
From: Pete Zaitcev @ 2007-03-26 21:42 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, linux-input, zaitcev

On Mon, 26 Mar 2007 15:30:42 -0400, "Dmitry Torokhov" <dmitry.torokhov@gmail.com> wrote:

> Regarding the synaptics driver and scroll problem. Yesterday I
> scrolled twice through entire Remarque's "Spark of Life" off lib.ru
> (once with 0.14.2 and once with latest git pull) and did not see any
> scrollbar getting "stuck". Could it be newer xorg problem instead of
> individual driver problem? I am using whatever xorg was installed in
> FC3 which is somewhat dated... Also, could it be that the scroll issue
> happens only in a certain application?

It's not a "scroll" issue. The issue is that the "up" event is getting
lost. It can be observed with any GUI elements, such as buttons.
However, since the event is delivered upon any motion, there's no
harm done with a button. Needless to say, this is not application
specific. It may be GNOME specific though.

FC-3 is far too old to be a good reference. I don't even know if it
has a usable synaptics module in its pre-modular X. You may be looking
at very different software stack.

I don't think that you need to concern yourself with this too much
at present. If X11 people (e.g. Kristian) present evidence that kernel
fails to deliver an event, then we'll look at it. However it might
help if evtest continued to work when X11 reads from /dev/input/eventN.
It was an unpleasant surprise that it doesn't.

-- Pete

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

* Re: Fix sudden warps in mousedev
  2007-03-26 21:42           ` Pete Zaitcev
@ 2007-03-27  1:14             ` Dmitry Torokhov
  2007-03-27 15:14               ` Chuck Ebbert
  2007-04-11 21:51               ` Peter Osterlund
  0 siblings, 2 replies; 15+ messages in thread
From: Dmitry Torokhov @ 2007-03-27  1:14 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: linux-kernel, linux-input, Peter Osterlund

On Monday 26 March 2007 17:42, Pete Zaitcev wrote:
> On Mon, 26 Mar 2007 15:30:42 -0400, "Dmitry Torokhov" <dmitry.torokhov@gmail.com> wrote:
> 
> > Regarding the synaptics driver and scroll problem. Yesterday I
> > scrolled twice through entire Remarque's "Spark of Life" off lib.ru
> > (once with 0.14.2 and once with latest git pull) and did not see any
> > scrollbar getting "stuck". Could it be newer xorg problem instead of
> > individual driver problem? I am using whatever xorg was installed in
> > FC3 which is somewhat dated... Also, could it be that the scroll issue
> > happens only in a certain application?
> 
> It's not a "scroll" issue. The issue is that the "up" event is getting
> lost. It can be observed with any GUI elements, such as buttons.
> However, since the event is delivered upon any motion, there's no
> harm done with a button. Needless to say, this is not application
> specific. It may be GNOME specific though.

Could be as I am KDE user.

> 
> FC-3 is far too old to be a good reference. I don't even know if it
> has a usable synaptics module in its pre-modular X. You may be looking
> at very different software stack.
>

See above. _My_ box certainly has usable synaptics module.
 
> I don't think that you need to concern yourself with this too much
> at present. If X11 people (e.g. Kristian) present evidence that kernel
> fails to deliver an event, then we'll look at it. However it might
> help if evtest continued to work when X11 reads from /dev/input/eventN.
> It was an unpleasant surprise that it doesn't.
> 

The driver grabs tochpad with EVIOCGRAB ioctl to prevent input events
from bveing delivered to X through /dev/input/mice which is still in
whidespread use. That's why evtest does not work. We could as Peter
(CCed) to implement an option to turn off grabbing so users who don't
use mousedev multiplexor can use evtest and other commands.

-- 
Dmitry

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

* Re: Fix sudden warps in mousedev
  2007-03-27  1:14             ` Dmitry Torokhov
@ 2007-03-27 15:14               ` Chuck Ebbert
  2007-03-27 15:46                 ` Dmitry Torokhov
  2007-04-11 21:51               ` Peter Osterlund
  1 sibling, 1 reply; 15+ messages in thread
From: Chuck Ebbert @ 2007-03-27 15:14 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Pete Zaitcev, linux-kernel, linux-input, Peter Osterlund

Dmitry Torokhov wrote:
> 
> The driver grabs tochpad with EVIOCGRAB ioctl to prevent input events
> from bveing delivered to X through /dev/input/mice which is still in
> whidespread use. That's why evtest does not work. We could as Peter
> (CCed) to implement an option to turn off grabbing so users who don't
> use mousedev multiplexor can use evtest and other commands.
> 

What should people be using instead of /dev/input/mice ?

And why did the mouse numbers all get rearranged in 2.6.20, e.g.
mouse1 became mouse2 for many people?


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

* Re: Fix sudden warps in mousedev
  2007-03-27 15:14               ` Chuck Ebbert
@ 2007-03-27 15:46                 ` Dmitry Torokhov
  2007-03-27 16:04                   ` Chuck Ebbert
  0 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2007-03-27 15:46 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: Pete Zaitcev, linux-kernel, linux-input, Peter Osterlund

On 3/27/07, Chuck Ebbert <cebbert@redhat.com> wrote:
> Dmitry Torokhov wrote:
> >
> > The driver grabs tochpad with EVIOCGRAB ioctl to prevent input events
> > from bveing delivered to X through /dev/input/mice which is still in
> > whidespread use. That's why evtest does not work. We could as Peter
> > (CCed) to implement an option to turn off grabbing so users who don't
> > use mousedev multiplexor can use evtest and other commands.
> >
>
> What should people be using instead of /dev/input/mice ?

/dev/input/mice is most convenient source untill X gets hotplug ability.

>
> And why did the mouse numbers all get rearranged in 2.6.20, e.g.
> mouse1 became mouse2 for many people?

Input devices are not guaranteed to be stable.

-- 
Dmitry

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

* Re: Fix sudden warps in mousedev
  2007-03-27 15:46                 ` Dmitry Torokhov
@ 2007-03-27 16:04                   ` Chuck Ebbert
  2007-03-27 16:19                     ` Dmitry Torokhov
  0 siblings, 1 reply; 15+ messages in thread
From: Chuck Ebbert @ 2007-03-27 16:04 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Pete Zaitcev, linux-kernel, linux-input, Peter Osterlund

Dmitry Torokhov wrote:
>>
>> And why did the mouse numbers all get rearranged in 2.6.20, e.g.
>> mouse1 became mouse2 for many people?
> 
> Input devices are not guaranteed to be stable.
> 

So people with z-axis mice need to redo their X config for each
kernel release when the device numbers change? Or should they
be using some other configuration?

People using this now have X crashes on kernel upgrade because
event1 became event2:

        Driver      "evdev"
        Option      "Device" "/dev/input/event1"


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

* Re: Fix sudden warps in mousedev
  2007-03-27 16:04                   ` Chuck Ebbert
@ 2007-03-27 16:19                     ` Dmitry Torokhov
  2007-03-28 20:51                       ` Matt Keenan
  0 siblings, 1 reply; 15+ messages in thread
From: Dmitry Torokhov @ 2007-03-27 16:19 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: Pete Zaitcev, linux-kernel, linux-input, Peter Osterlund

On 3/27/07, Chuck Ebbert <cebbert@redhat.com> wrote:
> Dmitry Torokhov wrote:
> >>
> >> And why did the mouse numbers all get rearranged in 2.6.20, e.g.
> >> mouse1 became mouse2 for many people?
> >
> > Input devices are not guaranteed to be stable.
> >
>
> So people with z-axis mice need to redo their X config for each
> kernel release when the device numbers change? Or should they
> be using some other configuration?
>
> People using this now have X crashes on kernel upgrade because
> event1 became event2:
>
>        Driver      "evdev"
>        Option      "Device" "/dev/input/event1"
>

I'd recommend matching on "phys" or individual capabilities bits
instead of device node. See "man evdev".

-- 
Dmitry

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

* Re: Fix sudden warps in mousedev
  2007-03-27 16:19                     ` Dmitry Torokhov
@ 2007-03-28 20:51                       ` Matt Keenan
  0 siblings, 0 replies; 15+ messages in thread
From: Matt Keenan @ 2007-03-28 20:51 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Chuck Ebbert, Pete Zaitcev, linux-kernel, linux-input, Peter Osterlund

Dmitry Torokhov wrote:
> On 3/27/07, Chuck Ebbert <cebbert@redhat.com> wrote:
>> Dmitry Torokhov wrote:
>> >>
>> >> And why did the mouse numbers all get rearranged in 2.6.20, e.g.
>> >> mouse1 became mouse2 for many people?
>> >
>> > Input devices are not guaranteed to be stable.
>> >
>>
>> So people with z-axis mice need to redo their X config for each
>> kernel release when the device numbers change? Or should they
>> be using some other configuration?
>>
>> People using this now have X crashes on kernel upgrade because
>> event1 became event2:
>>
>>        Driver      "evdev"
>>        Option      "Device" "/dev/input/event1"
>>
>
> I'd recommend matching on "phys" or individual capabilities bits
> instead of device node. See "man evdev".
>
I wrote a few udev rules to create specific /dev nodes for X with evedv 
(I run with multiple X users / screens / keyboards / mice on one 
machine).  I can forward you the udev rules and helper scripts if you 
want.  This means that you can hardcode the /dev nodes in your xorg.conf 
file and udev will make sure they don't move on you.  I wrote this up in 
the early days of evdev development before the phys stuff was there.

Matt

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

* Re: Fix sudden warps in mousedev
  2007-03-27  1:14             ` Dmitry Torokhov
  2007-03-27 15:14               ` Chuck Ebbert
@ 2007-04-11 21:51               ` Peter Osterlund
  1 sibling, 0 replies; 15+ messages in thread
From: Peter Osterlund @ 2007-04-11 21:51 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Pete Zaitcev, linux-kernel, linux-input

On Mon, 26 Mar 2007, Dmitry Torokhov wrote:

> On Monday 26 March 2007 17:42, Pete Zaitcev wrote:
>>
>> I don't think that you need to concern yourself with this too much
>> at present. If X11 people (e.g. Kristian) present evidence that kernel
>> fails to deliver an event, then we'll look at it. However it might
>> help if evtest continued to work when X11 reads from /dev/input/eventN.
>> It was an unpleasant surprise that it doesn't.
>
> The driver grabs tochpad with EVIOCGRAB ioctl to prevent input events
> from bveing delivered to X through /dev/input/mice which is still in
> whidespread use. That's why evtest does not work. We could as Peter
> (CCed) to implement an option to turn off grabbing so users who don't
> use mousedev multiplexor can use evtest and other commands.

That sounds like a useful option. Implemented in my git tree:

git clone http://web.telia.com/~u89404340/touchpad/synaptics/.git

-- 
Peter Osterlund - petero2@telia.com
http://web.telia.com/~u89404340

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

end of thread, other threads:[~2007-04-11 21:51 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-24  7:16 Fix sudden warps in mousedev Pete Zaitcev
2007-03-24  7:16 ` Pete Zaitcev
2007-03-25  5:34 ` Dmitry Torokhov
2007-03-25 18:19   ` Pete Zaitcev
2007-03-26  3:19     ` Dmitry Torokhov
2007-03-26 19:17       ` Pete Zaitcev
2007-03-26 19:30         ` Dmitry Torokhov
2007-03-26 21:42           ` Pete Zaitcev
2007-03-27  1:14             ` Dmitry Torokhov
2007-03-27 15:14               ` Chuck Ebbert
2007-03-27 15:46                 ` Dmitry Torokhov
2007-03-27 16:04                   ` Chuck Ebbert
2007-03-27 16:19                     ` Dmitry Torokhov
2007-03-28 20:51                       ` Matt Keenan
2007-04-11 21:51               ` Peter Osterlund

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.