All of lore.kernel.org
 help / color / mirror / Atom feed
From: JJ Ding <jj_ding@emc.com.tw>
To: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Seth Forshee" <seth.forshee@canonical.com>,
	"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"Aaron Huang" <aaron_huang@emc.com.tw>,
	"Tom Lin" <tom_lin@emc.com.tw>,
	"Éric Piel" <E.A.B.Piel@tudelft.nl>,
	"Daniel Kurtz" <djkurtz@chromium.org>,
	"Chase Douglas" <chase.douglas@canonical.com>,
	"Henrik Rydberg" <rydberg@euromail.se>,
	"Alessandro Rubini" <rubini@cvml.unipv.it>,
	"JJ Ding" <jj_ding@emc.com.tw>
Subject: [PATCH v4 2/8] Input: elantech - get rid of ETP_2FT_* in elantech.h
Date: Mon, 29 Aug 2011 16:28:53 +0800	[thread overview]
Message-ID: <1314606539-24722-3-git-send-email-jj_ding@emc.com.tw> (raw)
In-Reply-To: <1314606539-24722-1-git-send-email-jj_ding@emc.com.tw>

For two finger touches the coordinate of each finger gets reported
separately but with reduced resolution.

With this change, we now have the same range for ST and MT data and
scale MT data because it has lower resolution to match ST.

Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: JJ Ding <jj_ding@emc.com.tw>
Acked-by: Daniel Kurtz <djkurtz@chromium.org>
---
 drivers/input/mouse/elantech.c |   28 +++++++++++++---------------
 drivers/input/mouse/elantech.h |   11 -----------
 2 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index da161da..cd8e2e5 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -273,11 +273,11 @@ 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;
-	unsigned int fingers, x1 = 0, y1 = 0, x2 = 0, y2 = 0, width = 0, pres = 0;
+	unsigned int fingers, x1 = 0, y1 = 0, x2 = 0, y2 = 0;
+	unsigned int width = 0, pres = 0;
 
 	/* byte 0: n1  n0   .   .   .   .   R   L */
 	fingers = (packet[0] & 0xc0) >> 6;
-	input_report_key(dev, BTN_TOUCH, fingers != 0);
 
 	switch (fingers) {
 	case 3:
@@ -300,9 +300,6 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
 		 */
 		y1 = ETP_YMAX_V2 - (((packet[4] & 0x0f) << 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;
@@ -314,22 +311,18 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
 		 * byte 0:  .   .  ay8 ax8  .   .   .   .
 		 * byte 1: ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0
 		 */
-		x1 = ((packet[0] & 0x10) << 4) | packet[1];
+		x1 = (((packet[0] & 0x10) << 4) | packet[1]) << 2;
 		/* byte 2: ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0 */
-		y1 = ETP_2FT_YMAX - (((packet[0] & 0x20) << 3) | packet[2]);
+		y1 = ETP_YMAX_V2 -
+			((((packet[0] & 0x20) << 3) | packet[2]) << 2);
 		/*
 		 * byte 3:  .   .  by8 bx8  .   .   .   .
 		 * byte 4: bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0
 		 */
-		x2 = ((packet[3] & 0x10) << 4) | packet[4];
+		x2 = (((packet[3] & 0x10) << 4) | packet[4]) << 2;
 		/* byte 5: by7 by8 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
-		 * one coordinate and report as ordinary mouse movent
-		 */
-		input_report_abs(dev, ABS_X, x1 << 2);
-		input_report_abs(dev, ABS_Y, y1 << 2);
+		y2 = ETP_YMAX_V2 -
+			((((packet[3] & 0x20) << 3) | packet[5]) << 2);
 
 		/* Unknown so just report sensible values */
 		pres = 127;
@@ -337,6 +330,11 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
 		break;
 	}
 
+	input_report_key(dev, BTN_TOUCH, fingers != 0);
+	if (fingers != 0) {
+		input_report_abs(dev, ABS_X, x1);
+		input_report_abs(dev, ABS_Y, y1);
+	}
 	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);
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index fabb2b9..1c5894e 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -82,17 +82,6 @@
 #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.
- */
-#define ETP_2FT_FUZZ			4
-
-#define ETP_2FT_XMIN			(  0 + ETP_2FT_FUZZ)
-#define ETP_2FT_XMAX			(288 - ETP_2FT_FUZZ)
-#define ETP_2FT_YMIN			(  0 + ETP_2FT_FUZZ)
-#define ETP_2FT_YMAX			(192 - ETP_2FT_FUZZ)
-
 struct elantech_data {
 	unsigned char reg_10;
 	unsigned char reg_11;
-- 
1.7.4.1


  parent reply	other threads:[~2011-08-29  8:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-29  8:28 [PATCH v4 0/8] Input: elantech: add support for newer hardware JJ Ding
2011-08-29  8:28 ` JJ Ding
2011-08-29  8:28 ` [PATCH v4 1/8] Input: elantech - correct x, y value range for v2 hardware JJ Ding
2011-08-29  8:28 ` JJ Ding [this message]
2011-08-29  8:28 ` [PATCH v4 3/8] Input: elantech - use firmware provided x, y ranges JJ Ding
2011-08-29  8:28 ` [PATCH v4 4/8] Input: elantech - remove ETP_EDGE_FUZZ_V2 JJ Ding
2011-08-29  8:28   ` JJ Ding
2011-08-29  8:28 ` [PATCH v4 5/8] Input: elantech - packet checking for v2 hardware JJ Ding
2011-08-29  8:28 ` [PATCH v4 6/8] Input: elantech - clean up elantech_init JJ Ding
2011-08-29  8:28 ` [PATCH v4 7/8] Input: elantech - add v3 hardware support JJ Ding
2011-08-29  8:28 ` [PATCH v4 8/8] Input: elantech - add v4 " JJ Ding
2011-08-30 13:50   ` Tom _Lin
2011-08-31 12:50   ` Éric Piel
2011-08-31 12:50     ` Éric Piel
2011-09-01  1:31     ` JJ Ding
2011-09-01  1:31       ` JJ Ding
2011-08-31  9:43 ` [PATCH v4 0/8] Input: elantech: add support for newer hardware JJ Ding
2011-08-31 21:10   ` Dmitry Torokhov
2011-09-01  1:38     ` JJ Ding
2011-08-31 12:54 ` Éric Piel
2011-08-31 12:54   ` Éric Piel
2011-09-01  1:39   ` JJ Ding
2011-09-01  1:39     ` JJ Ding

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=1314606539-24722-3-git-send-email-jj_ding@emc.com.tw \
    --to=jj_ding@emc.com.tw \
    --cc=E.A.B.Piel@tudelft.nl \
    --cc=aaron_huang@emc.com.tw \
    --cc=chase.douglas@canonical.com \
    --cc=djkurtz@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rubini@cvml.unipv.it \
    --cc=rydberg@euromail.se \
    --cc=seth.forshee@canonical.com \
    --cc=tom_lin@emc.com.tw \
    /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.