All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Henrik Rydberg" <rydberg@euromail.se>
To: Christophe TORDEUX <christophe@tordeux.net>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Tai-hwa Liang <avatar@sentelic.com>,
	Oskari Saarenmaa <os@ohmu.fi>, Paul Fox <pgf@laptop.org>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	torvalds@linux-foundation.org
Subject: Re: [PATCH 01/01] Input multitouch: fix horizontal two-finger-scrolling on Sentelic touchpads
Date: Wed, 19 Dec 2012 09:41:13 +0100	[thread overview]
Message-ID: <20121219084113.GA2758@polaris.bitmath.org> (raw)
In-Reply-To: <20121212012135.GA9043@sherka.no-ip.biz>

Hi Christophe,

> Fix horizontal two-finger scrolling on Sentelic touchpads. Currently
> horizontal two-fingers scrolling does not work with these touchpads.
> The patch also makes vertical two-finger scrolling smoother in some
> applications e.g. Firefox.
> 
> Signed-off-by: Christophe TORDEUX <christophe@tordeux.net>
> ----
> 
> This patch was inspired by the reading of
> drivers/input/mouse/synaptics.c. It is known to work (tested) on
> Sentelic touchpads version STL3888_C0. Very probably works on all later
> versions, and possibly works on some earlier versions of the hardware in
> question.

Thanks for the patch. I would prefer it if this driver was converted
to use input_mt_assign_slots() instead.

> 
> diff -uprN -X vanilla/linux-3.7-rc8/Documentation/dontdiff 
> vanilla/linux-3.7-rc8/drivers/input/mouse/sentelic.c 
> linux-3.7-rc8/drivers/input/mouse/sentelic.c
> --- vanilla/linux-3.7-rc8/drivers/input/mouse/sentelic.c	2012-12-11 04:32:44.476930522 +0100
> +++ linux-3.7-rc8/drivers/input/mouse/sentelic.c	2012-12-12 01:16:41.766018017 +0100
> @@ -706,8 +706,10 @@ static psmouse_ret_t fsp_process_byte(st
>  	struct input_dev *dev = psmouse->dev;
>  	struct fsp_data *ad = psmouse->private;
>  	unsigned char *packet = psmouse->packet;
> +	unsigned char *last_packet = ad->last_pkt;
>  	unsigned char button_status = 0, lscroll = 0, rscroll = 0;
>  	unsigned short abs_x, abs_y, fgrs = 0;
> +	unsigned short last_abs_x, last_abs_y;
>  	int rel_x, rel_y;
>  
>  	if (psmouse->pktcnt < 4)
> @@ -734,6 +736,9 @@ static psmouse_ret_t fsp_process_byte(st
>  
>  		abs_x = GET_ABS_X(packet);
>  		abs_y = GET_ABS_Y(packet);
> +		last_abs_x = GET_ABS_X(last_packet);
> +		last_abs_y = GET_ABS_Y(last_packet);
> +		memcpy(ad->last_pkt, packet, psmouse->pktcnt);

Why not save the variables instead of the array?

>  
>  		if (packet[0] & FSP_PB0_MFMC) {
>  			/*
> @@ -753,10 +758,19 @@ static psmouse_ret_t fsp_process_byte(st
>  					 */
>  					fgrs = 1;
>  					fsp_set_slot(dev, 0, false, 0, 0);
> +
> +					/* We don't need to re-order
> +					 * coordinates if last finger
> +					 * was same finger
> +					 */
> +					last_abs_x = abs_x;
> +					last_abs_y = abs_y;
>  				}
>  				ad->last_mt_fgr = 2;
>  
> -				fsp_set_slot(dev, 1, fgrs == 2, abs_x, abs_y);
> +				fsp_set_slot(dev, 1, fgrs == 2,
> +						max(abs_x, last_abs_x),
> +						max(abs_y, last_abs_y));

Relying on the box (x1, y1, max(x1, x2), max(y1, y2)) seems to assume
a lot about the behavior of the device.

>  			} else {
>  				/* 1st finger */
>  				if (ad->last_mt_fgr == 1) {
> @@ -767,9 +781,18 @@ static psmouse_ret_t fsp_process_byte(st
>  					 */
>  					fgrs = 1;
>  					fsp_set_slot(dev, 1, false, 0, 0);
> +
> +					/* We don't need to re-order
> +					 * coordinates if last finger
> +					 * was same finger
> +					 */
> +					last_abs_x = abs_x;
> +					last_abs_y = abs_y;
>  				}
>  				ad->last_mt_fgr = 1;
> -				fsp_set_slot(dev, 0, fgrs != 0, abs_x, abs_y);
> +				fsp_set_slot(dev, 0, fgrs != 0,
> +						min(abs_x, last_abs_x),
> +						min(abs_y, last_abs_y));
>  			}
>  		} else {
>  			/* SFAC packet */
> @@ -788,12 +811,18 @@ static psmouse_ret_t fsp_process_byte(st
>  			if (abs_x != 0 && abs_y != 0)
>  				fgrs = 1;
>  
> +			/* We don't need to re-order
> +			 * coordinates of SFAC packets
> +			 */
> +			last_abs_x = abs_x;
> +			last_abs_y = abs_y;
> +
>  			fsp_set_slot(dev, 0, fgrs > 0, abs_x, abs_y);
>  			fsp_set_slot(dev, 1, false, 0, 0);
>  		}
>  		if (fgrs > 0) {
> -			input_report_abs(dev, ABS_X, abs_x);
> -			input_report_abs(dev, ABS_Y, abs_y);
> +			input_report_abs(dev, ABS_X, min(abs_x, last_abs_x));
> +			input_report_abs(dev, ABS_Y, min(abs_y, last_abs_y));

Looks like this point could differ from the reported MT positions.

>  		}
>  		input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
>  		input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
> diff -uprN -X vanilla/linux-3.7-rc8/Documentation/dontdiff vanilla/linux-3.7-rc8/drivers/input/mouse/sentelic.h linux-3.7-rc8/drivers/input/mouse/sentelic.h
> --- vanilla/linux-3.7-rc8/drivers/input/mouse/sentelic.h	2012-12-11 04:32:44.476930522 +0100
> +++ linux-3.7-rc8/drivers/input/mouse/sentelic.h	2012-12-12 01:16:41.954018011 +0100
> @@ -117,6 +117,7 @@ struct fsp_data {
>  	unsigned char	last_reg;	/* Last register we requested read from */
>  	unsigned char	last_val;
>  	unsigned int	last_mt_fgr;	/* Last seen finger(multitouch) */
> +	unsigned char	last_pkt[8];    /* Last packet we processed from fsp */
>  };
>  
>  #ifdef CONFIG_MOUSE_PS2_SENTELIC

Thanks.
Henrik


  parent reply	other threads:[~2012-12-19  8:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-12  1:21 [PATCH 01/01] Input multitouch: fix horizontal two-finger-scrolling on Sentelic touchpads Christophe TORDEUX
2012-12-12  1:27 ` Christophe TORDEUX
2012-12-19  8:41 ` Henrik Rydberg [this message]
2012-12-19 21:42   ` Christophe TORDEUX
2012-12-19 23:09 ` Christophe TORDEUX
2012-12-20  0:37   ` Dmitry Torokhov

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=20121219084113.GA2758@polaris.bitmath.org \
    --to=rydberg@euromail.se \
    --cc=avatar@sentelic.com \
    --cc=christophe@tordeux.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=os@ohmu.fi \
    --cc=pgf@laptop.org \
    --cc=torvalds@linux-foundation.org \
    /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 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.