From patchwork Wed Dec 12 01:21:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe TORDEUX X-Patchwork-Id: 1864381 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 12A4D3FCA5 for ; Wed, 12 Dec 2012 01:21:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753535Ab2LLBVo (ORCPT ); Tue, 11 Dec 2012 20:21:44 -0500 Received: from smtp02.smtpout.orange.fr ([80.12.242.124]:57103 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753226Ab2LLBVn (ORCPT ); Tue, 11 Dec 2012 20:21:43 -0500 Received: from sherka ([90.50.227.147]) by mwinf5d03 with ME id aRMc1k0023BSlea03RMcen; Wed, 12 Dec 2012 02:21:41 +0100 Received: from maze by sherka with local (Exim 4.80) (envelope-from ) id 1Tib0x-0002qM-TQ; Wed, 12 Dec 2012 02:21:35 +0100 Date: Wed, 12 Dec 2012 02:21:35 +0100 From: Christophe TORDEUX To: Dmitry Torokhov Cc: Henrik Rydberg , Tai-hwa Liang , Oskari Saarenmaa , Paul Fox , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org Subject: [PATCH 01/01] Input multitouch: fix horizontal two-finger-scrolling on Sentelic touchpads Message-ID: <20121212012135.GA9043@sherka.no-ip.biz> MIME-Version: 1.0 Content-Disposition: inline X-PGP-Key: http://christophe.tordeux.net/data/pgp/c-tor2/pubkey.asc User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Christophe TORDEUX 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 ---- 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. 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); 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)); } 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)); } 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