From patchwork Sat May 14 06:49:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4PigLByaWMgUGllbA==?= X-Patchwork-Id: 784962 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4EB8E0K025085 for ; Sat, 14 May 2011 11:08:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756056Ab1ENLIM (ORCPT ); Sat, 14 May 2011 07:08:12 -0400 Received: from mailservice.tudelft.nl ([130.161.131.5]:52737 "EHLO mailservice.tudelft.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755045Ab1ENLIL (ORCPT ); Sat, 14 May 2011 07:08:11 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 14 May 2011 11:08:14 +0000 (UTC) X-Greylist: delayed 1503 seconds by postgrey-1.27 at vger.kernel.org; Sat, 14 May 2011 07:08:11 EDT Received: from localhost (localhost [127.0.0.1]) by amavis (Postfix) with ESMTP id DA9F42B8051; Sat, 14 May 2011 12:43:12 +0200 (CEST) X-Virus-Scanned: amavisd-new at tudelft.nl X-Spam-Flag: NO X-Spam-Score: -9.315 X-Spam-Level: X-Spam-Status: No, score=-9.315 tagged_above=-99 required=5 tests=[BAYES_00=-1.9, DATE_IN_PAST_03_06=1.592, PROLO_LEO3=0.01, RCVD_IN_PBL=10, RCVD_IN_SORBS_DUL=0.001, RDNS_DYNAMIC=0.982, TUD_REL01=-20] autolearn=ham Received: from mailservice.tudelft.nl ([130.161.131.73]) by localhost (tudelft.nl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id xzyKc7GeQ9IQ; Sat, 14 May 2011 12:43:12 +0200 (CEST) Received: from smtp-a.tudelft.nl (smtp-a.tudelft.nl [130.161.180.7]) by mx2.tudelft.nl (Postfix) with ESMTP id 14BE52B8047; Sat, 14 May 2011 12:43:12 +0200 (CEST) Received: from [192.168.1.33] (212-123-168-131.ip.telfort.nl [212.123.168.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-a.tudelft.nl (Postfix) with ESMTP id A3393B3A62; Sat, 14 May 2011 12:43:11 +0200 (CEST) Message-ID: <4DCE2608.6030003@tudelft.nl> Date: Sat, 14 May 2011 08:49:44 +0200 From: =?ISO-8859-1?Q?=C9ric_Piel?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Mandriva/3.1.10-1 (2011.0) Thunderbird/3.1.10 MIME-Version: 1.0 To: Dmitry Torokhov CC: "linux-input@vger.kernel.org" , Henrik Rydberg , Chris Bagwell , Florian Ragwitz Subject: [PATCH 5/6] elantech: Report multitouch with proper ABS_MT messages Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Multitouch info was reported only via a old protocol used by the proprietary X driver from elantech. Let's report the multitouch info also following the official MT protocol. It's semi-mt because the device only reports the lowest/highest coordinates. This was done following the multi-touch-protocol.txt documentation, and inspired by the bcm5974 and elantech implementations. Testing was light as there is not many applications using this protocol yet, but the X synaptics driver didn't complain and the X multitouch driver behaved correctly. Signed-off-by: Éric Piel --- drivers/input/mouse/elantech.c | 36 +++++++++++++++++++++++++++++++----- 1 files changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 6817284..a05d092 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include "psmouse.h" @@ -242,6 +243,24 @@ static void elantech_report_absolute_v1(struct psmouse *psmouse) input_sync(dev); } +static void set_slot(struct input_dev *dev, int slot, bool active, unsigned int x, unsigned int y) +{ + input_mt_slot(dev, slot); + input_mt_report_slot_state(dev, MT_TOOL_FINGER, active); + if (active) { + input_report_abs(dev, ABS_MT_POSITION_X, x); + input_report_abs(dev, ABS_MT_POSITION_Y, y); + } +} + +/* x1 < x2 and y1 < y2 when two fingers, x = y = 0 when not pressed */ +static void elantech_report_semi_mt_data(struct input_dev *dev, int num_fingers, + unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2) +{ + set_slot(dev, 0, (num_fingers > 0), x1, y1); + set_slot(dev, 1, (num_fingers == 2), x2, y2); +} + /* * Interpret complete data packets and report absolute mode input events for * hardware version 2. (6 byte packets) @@ -251,7 +270,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) struct elantech_data *etd = psmouse->private; struct input_dev *dev = psmouse->dev; unsigned char *packet = psmouse->packet; - int fingers, x1, y1, x2, y2, width = 0, pres = 0; + unsigned int fingers, x1 = 0, y1 = 0, x2 = 0, y2 = 0, width = 0, pres = 0; /* byte 0: n1 n0 . . . . R L */ fingers = (packet[0] & 0xc0) >> 6; @@ -271,14 +290,16 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) * byte 1: . . . . . x10 x9 x8 * byte 2: x7 x6 x5 x4 x4 x2 x1 x0 */ - input_report_abs(dev, ABS_X, - ((packet[1] & 0x07) << 8) | packet[2]); + x1 = ((packet[1] & 0x07) << 8) | packet[2]; /* * byte 4: . . . . . . y9 y8 * byte 5: y7 y6 y5 y4 y3 y2 y1 y0 */ - input_report_abs(dev, ABS_Y, - ETP_YMAX_V2 - (((packet[4] & 0x03) << 8) | packet[5])); + y1 = ETP_YMAX_V2 - (((packet[4] & 0x03) << 8) | packet[5]); + + input_report_abs(dev, ABS_X, x1); + input_report_abs(dev, ABS_Y, y1); + pres = (packet[1] & 0xf0) | ((packet[4] & 0xf0) >> 4); width = ((packet[0] & 0x30) >> 2) | ((packet[3] & 0x30) >> 4); break; @@ -321,6 +342,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) break; } + elantech_report_semi_mt_data(dev, fingers, x1, y1, x2, y2); input_report_key(dev, BTN_TOOL_FINGER, fingers == 1); input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2); input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3); @@ -548,6 +570,10 @@ static void elantech_set_input_params(struct psmouse *psmouse) input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2, ETP_WMAX_V2, 0, 0); } + __set_bit(INPUT_PROP_SEMI_MT, dev->propbit); + input_mt_init_slots(dev, 2); + input_set_abs_params(dev, ABS_MT_POSITION_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0); + input_set_abs_params(dev, ABS_MT_POSITION_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0); input_set_abs_params(dev, ABS_HAT0X, ETP_2FT_XMIN, ETP_2FT_XMAX, 0, 0); input_set_abs_params(dev, ABS_HAT0Y, ETP_2FT_YMIN, ETP_2FT_YMAX, 0, 0); input_set_abs_params(dev, ABS_HAT1X, ETP_2FT_XMIN, ETP_2FT_XMAX, 0, 0);