From patchwork Sat May 8 16:37:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?w4PigLByaWMgUGllbA==?= X-Patchwork-Id: 97926 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o48Gdjuc013566 for ; Sat, 8 May 2010 16:39:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753547Ab0EHQjY (ORCPT ); Sat, 8 May 2010 12:39:24 -0400 Received: from mailservice.tudelft.nl ([130.161.131.5]:44940 "EHLO mailservice.tudelft.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753407Ab0EHQjX (ORCPT ); Sat, 8 May 2010 12:39:23 -0400 Received: from localhost (localhost [127.0.0.1]) by amavis (Postfix) with ESMTP id D0E477F802F; Sat, 8 May 2010 18:39:22 +0200 (CEST) X-Virus-Scanned: amavisd-new at tudelft.nl X-Spam-Flag: NO X-Spam-Score: -22.589 X-Spam-Level: X-Spam-Status: No, score=-22.589 tagged_above=-99 required=5 tests=[BAYES_00=-2.599, PROLO_LEO3=0.01, TUD_REL01=-20] autolearn=ham Received: from mailservice.tudelft.nl ([130.161.131.69]) by localhost (tudelft.nl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id j3OgbKg9XShx; Sat, 8 May 2010 18:39:21 +0200 (CEST) Received: from smtp-a.tudelft.nl (smtp-a.tudelft.nl [130.161.180.7]) by mx1.tudelft.nl (Postfix) with ESMTP id CF44C7F8018; Sat, 8 May 2010 18:39:21 +0200 (CEST) Received: from [172.19.3.21] (63-103-dsl.ipact.nl [84.35.103.63]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-a.tudelft.nl (Postfix) with ESMTP id 345D7B3A63; Sat, 8 May 2010 18:39:21 +0200 (CEST) Message-ID: <4BE59352.4070407@tudelft.nl> Date: Sat, 08 May 2010 18:37:38 +0200 From: =?UTF-8?B?w4lyaWMgUGllbA==?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090319 Mandriva/2.0.0.21-1mdv2009.1 (2009.1) Thunderbird/2.0.0.21 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Dmitry Torokhov CC: Florian Ragwitz , "linux-input@vger.kernel.org" , Henrik Rydberg Subject: [PATCH 1/2] elantech: Improved protocol support for hardware 2 X-Enigmail-Version: 1.0.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 08 May 2010 16:39:46 +0000 (UTC) diff --git a/Documentation/input/elantech.txt b/Documentation/input/elantech.txt index 56941ae..cb8471b 100644 --- a/Documentation/input/elantech.txt +++ b/Documentation/input/elantech.txt @@ -319,7 +319,7 @@ For example: 4.2 Native absolute mode 6 byte packet format ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -4.2.1 One finger touch +4.2.1 One/Three finger touch ~~~~~~~~~~~~~~~~ byte 0: @@ -333,19 +333,22 @@ byte 0: byte 1: bit 7 6 5 4 3 2 1 0 + w5 w4 w3 w2 . x10 x9 x8 . . . . . x10 x9 x8 byte 2: bit 7 6 5 4 3 2 1 0 - x7 x6 x5 x4 x4 x2 x1 x0 + x7 x6 x5 x4 x3 x2 x1 x0 x10..x0 = absolute x value (horizontal) byte 3: bit 7 6 5 4 3 2 1 0 - . . . . . . . . + n4 . w1 w0 . . . . + w6..w0 = width of the finger touch + n4 = set if more than 3 fingers (only in 3 fingers mode) byte 4: @@ -363,6 +366,11 @@ byte 5: 4.2.2 Two finger touch ~~~~~~~~~~~~~~~~ +Note that the two pairs of coordinates are not exactly the coordinates of the +two fingers, but only the pair of the lowest and highest coordinates. So the +actual fingers might be situated on the other diagonal of the square defined by +these two points. + byte 0: bit 7 6 5 4 3 2 1 0 @@ -376,14 +384,14 @@ byte 1: bit 7 6 5 4 3 2 1 0 ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0 - ax8..ax0 = first finger absolute x value + ax8..ax0 = lower finger absolute x value byte 2: bit 7 6 5 4 3 2 1 0 ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0 - ay8..ay0 = first finger absolute y value + ay8..ay0 = lower finger absolute y value byte 3: @@ -395,11 +403,11 @@ byte 4: bit 7 6 5 4 3 2 1 0 bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0 - bx8..bx0 = second finger absolute x value + bx8..bx0 = higher finger absolute x value byte 5: bit 7 6 5 4 3 2 1 0 by7 by8 by5 by4 by3 by2 by1 by0 - by8..by0 = second finger absolute y value + by8..by0 = higher finger absolute y value diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 0520c2e..2708b22 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -249,26 +249,38 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) { struct input_dev *dev = psmouse->dev; unsigned char *packet = psmouse->packet; - int fingers, x1, y1, x2, y2; + int fingers, x1, y1, x2, y2, width; /* byte 0: n1 n0 . . . . R L */ fingers = (packet[0] & 0xc0) >> 6; input_report_key(dev, BTN_TOUCH, fingers != 0); switch (fingers) { + case 3: + /* + * Same as one finger excepted report of more than 3 + * fingers pressed: + * byte 3: n4 . w1 w0 . . . . + */ + if (packet[3] & 0x80) + fingers = 4; + /* pass through... */ case 1: /* - * byte 1: . . . . . x10 x9 x8 - * byte 2: x7 x6 x5 x4 x4 x2 x1 x0 + * byte 1: w5 w4 w3 w2 . x10 x9 x8 + * byte 2: x7 x6 x5 x4 x3 x2 x1 x0 + * byte 3: . . w1 w0 . . . . */ - input_report_abs(dev, ABS_X, - ((packet[1] & 0x07) << 8) | packet[2]); + width = ((packet[1] & 0xf0) >> 2) | ((packet[3] & 0x30) >> 4); + 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_TOOL_WIDTH, width); + input_report_abs(dev, ABS_X, x1); + input_report_abs(dev, ABS_Y, y1); break; case 2: @@ -286,7 +298,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) * byte 4: bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0 */ x2 = ((packet[3] & 0x10) << 4) | packet[4]; - /* byte 5: by7 by8 by5 by4 by3 by2 by1 by0 */ + /* byte 5: by7 by6 by5 by4 by3 by2 by1 by0 */ y2 = ETP_2FT_YMAX - (((packet[3] & 0x20) << 3) | packet[5]); /* * For compatibility with the X Synaptics driver scale up @@ -308,6 +320,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) 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); + input_report_key(dev, BTN_TOOL_QUADTAP, fingers == 4); input_report_key(dev, BTN_LEFT, packet[0] & 0x01); input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); @@ -467,6 +480,8 @@ static void elantech_set_input_params(struct psmouse *psmouse) break; case 2: + __set_bit(BTN_TOOL_QUADTAP, dev->keybit); + input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2, ETP_WMAX_V2, 0, 0); input_set_abs_params(dev, ABS_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0); input_set_abs_params(dev, ABS_Y, ETP_YMIN_V2, ETP_YMAX_V2, 0, 0); input_set_abs_params(dev, ABS_HAT0X, ETP_2FT_XMIN, ETP_2FT_XMAX, 0, 0); @@ -693,8 +708,9 @@ int elantech_init(struct psmouse *psmouse) * Assume every version greater than this is new EeePC style * hardware with 6 byte packets */ - if ((etd->fw_version_maj == 0x02 && etd->fw_version_min >= 0x30) || - etd->fw_version_maj > 0x02) { + //if ((etd->fw_version_maj == 0x02 && etd->fw_version_min >= 0x30) || + // etd->fw_version_maj > 0x02) { + if (etd->fw_version_maj >= 0x02) { etd->hw_version = 2; /* For now show extra debug information */ etd->debug = 1; diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h index feac5f7..5093762 100644 --- a/drivers/input/mouse/elantech.h +++ b/drivers/input/mouse/elantech.h @@ -76,6 +76,8 @@ #define ETP_XMAX_V2 (1152 - ETP_EDGE_FUZZ_V2) #define ETP_YMIN_V2 ( 0 + ETP_EDGE_FUZZ_V2) #define ETP_YMAX_V2 ( 768 - ETP_EDGE_FUZZ_V2) +#define ETP_WMIN_V2 0 +#define ETP_WMAX_V2 (1 << 6) /* * For two finger touches the coordinate of each finger gets reported