LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor@insightbb.com>
To: Pete Zaitcev <zaitcev@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-input@atrey.karlin.mff.cuni.cz
Subject: Re: Fix sudden warps in mousedev
Date: Sun, 25 Mar 2007 23:19:38 -0400	[thread overview]
Message-ID: <200703252319.39676.dtor@insightbb.com> (raw)
In-Reply-To: <20070325111930.f6428509.zaitcev@redhat.com>

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;
 	}
 }
 

  reply	other threads:[~2007-03-26  3:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-24  7:16 Fix sudden warps in mousedev Pete Zaitcev
     [not found] ` <200703250134.03416.dtor@insightbb.com>
2007-03-25 18:19   ` Pete Zaitcev
2007-03-26  3:19     ` Dmitry Torokhov [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200703252319.39676.dtor@insightbb.com \
    --to=dtor@insightbb.com \
    --cc=linux-input@atrey.karlin.mff.cuni.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zaitcev@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).