From patchwork Sat May 14 06:48:20 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: 784952 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4EB8Fmt009023 for ; Sat, 14 May 2011 11:08:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755045Ab1ENLIP (ORCPT ); Sat, 14 May 2011 07:08:15 -0400 Received: from mailservice.tudelft.nl ([130.161.131.5]:48995 "EHLO mailservice.tudelft.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755593Ab1ENLIM (ORCPT ); Sat, 14 May 2011 07:08:12 -0400 Received: from localhost (localhost [127.0.0.1]) by amavis (Postfix) with ESMTP id E9712CC15C; Sat, 14 May 2011 12:43:15 +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.71]) by localhost (tudelft.nl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wrUG17v1xUDH; Sat, 14 May 2011 12:43:11 +0200 (CEST) Received: from smtp-a.tudelft.nl (smtp-a.tudelft.nl [130.161.180.7]) by mx4.tudelft.nl (Postfix) with ESMTP id 1DD1ECC141; Sat, 14 May 2011 12:43:11 +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 CD4DDB3A62; Sat, 14 May 2011 12:43:10 +0200 (CEST) Message-ID: <4DCE25B4.9000500@tudelft.nl> Date: Sat, 14 May 2011 08:48:20 +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 4/6] elantech: export pressure and width when supported 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.6 (demeter2.kernel.org [140.211.167.43]); Sat, 14 May 2011 11:08:16 +0000 (UTC) Using the info of the Dell/Ubuntu driver, described in the protocol document, report both width and pressure when pressing 1 and 3 fingers, for the versions of the touchpad which support it. Signed-off-by: Éric Piel --- drivers/input/mouse/elantech.c | 19 ++++++++++++++++++- drivers/input/mouse/elantech.h | 5 +++++ 2 files changed, 23 insertions(+), 1 deletions(-) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 8f0a1ee..6817284 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -248,9 +248,10 @@ static void elantech_report_absolute_v1(struct psmouse *psmouse) */ 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; + int fingers, x1, y1, x2, y2, width = 0, pres = 0; /* byte 0: n1 n0 . . . . R L */ fingers = (packet[0] & 0xc0) >> 6; @@ -278,6 +279,8 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) */ input_report_abs(dev, ABS_Y, ETP_YMAX_V2 - (((packet[4] & 0x03) << 8) | packet[5])); + pres = (packet[1] & 0xf0) | ((packet[4] & 0xf0) >> 4); + width = ((packet[0] & 0x30) >> 2) | ((packet[3] & 0x30) >> 4); break; case 2: @@ -311,6 +314,10 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) input_report_abs(dev, ABS_HAT0Y, y1); input_report_abs(dev, ABS_HAT1X, x2); input_report_abs(dev, ABS_HAT1Y, y2); + + /* Unknown so just report sensible values */ + pres = 127; + width = 7; break; } @@ -320,6 +327,10 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse) 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); + if (etd->reports_pres) { + input_report_abs(dev, ABS_PRESSURE, pres); + input_report_abs(dev, ABS_TOOL_WIDTH, width); + } input_sync(dev); } @@ -531,6 +542,12 @@ static void elantech_set_input_params(struct psmouse *psmouse) __set_bit(BTN_TOOL_QUADTAP, dev->keybit); 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); + if (etd->reports_pres) { + input_set_abs_params(dev, ABS_PRESSURE, ETP_PMIN_V2, + ETP_PMAX_V2, 0, 0); + input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2, + ETP_WMAX_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); diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h index 257d419..dcf9ad0 100644 --- a/drivers/input/mouse/elantech.h +++ b/drivers/input/mouse/elantech.h @@ -77,6 +77,11 @@ #define ETP_YMIN_V2 ( 0 + ETP_EDGE_FUZZ_V2) #define ETP_YMAX_V2 ( 768 - ETP_EDGE_FUZZ_V2) +#define ETP_PMIN_V2 0 +#define ETP_PMAX_V2 255 +#define ETP_WMIN_V2 0 +#define ETP_WMAX_V2 15 + /* * For two finger touches the coordinate of each finger gets reported * separately but with reduced resolution.