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>, Eric 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 2/6] Input: elantech - use firmware provided x, y ranges
Date: Thu, 18 Aug 2011 09:57:05 +0800	[thread overview]
Message-ID: <1313632629-23603-3-git-send-email-jj_ding@emc.com.tw> (raw)
In-Reply-To: <1313632629-23603-1-git-send-email-jj_ding@emc.com.tw>

With newer hardware, the touchpad provides range info.
Let's use it.

Signed-off-by: JJ Ding <jj_ding@emc.com.tw>
---
 drivers/input/mouse/elantech.c |   73 +++++++++++++++++++++++++++++++--------
 drivers/input/mouse/elantech.h |    4 ++-
 2 files changed, 61 insertions(+), 16 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index da161da..cf41f23 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -223,7 +223,7 @@ static void elantech_report_absolute_v1(struct psmouse *psmouse)
 		input_report_abs(dev, ABS_X,
 			((packet[1] & 0x0c) << 6) | packet[2]);
 		input_report_abs(dev, ABS_Y,
-			ETP_YMAX_V1 - (((packet[1] & 0x03) << 8) | packet[3]));
+			etd->y_max - (((packet[1] & 0x03) << 8) | packet[3]));
 	}
 
 	input_report_key(dev, BTN_TOOL_FINGER, fingers == 1);
@@ -233,7 +233,7 @@ static void elantech_report_absolute_v1(struct psmouse *psmouse)
 	input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
 
 	if (etd->fw_version < 0x020000 &&
-	    (etd->capabilities & ETP_CAP_HAS_ROCKER)) {
+	    (etd->capabilities[0] & ETP_CAP_HAS_ROCKER)) {
 		/* rocker up */
 		input_report_key(dev, BTN_FORWARD, packet[0] & 0x40);
 		/* rocker down */
@@ -298,7 +298,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
 		 * byte 4:  .   .   .   .  y11 y10 y9  y8
 		 * byte 5: y7  y6  y5  y4  y3  y2  y1  y0
 		 */
-		y1 = ETP_YMAX_V2 - (((packet[4] & 0x0f) << 8) | packet[5]);
+		y1 = etd->y_max - (((packet[4] & 0x0f) << 8) | packet[5]);
 
 		input_report_abs(dev, ABS_X, x1);
 		input_report_abs(dev, ABS_Y, y1);
@@ -316,14 +316,14 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
 		 */
 		x1 = ((packet[0] & 0x10) << 4) | packet[1];
 		/* byte 2: ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0 */
-		y1 = ETP_2FT_YMAX - (((packet[0] & 0x20) << 3) | packet[2]);
+		y1 = etd->y_2ft_max - (((packet[0] & 0x20) << 3) | packet[2]);
 		/*
 		 * byte 3:  .   .  by8 bx8  .   .   .   .
 		 * 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 */
-		y2 = ETP_2FT_YMAX - (((packet[3] & 0x20) << 3) | packet[5]);
+		y2 = etd->y_2ft_max - (((packet[3] & 0x20) << 3) | packet[5]);
 		/*
 		 * For compatibility with the X Synaptics driver scale up
 		 * one coordinate and report as ordinary mouse movent
@@ -470,6 +470,42 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse)
 	return rc;
 }
 
+static void set_range(struct psmouse *psmouse, unsigned int *x_min,
+		     unsigned int *y_min, unsigned int *x_max,
+		     unsigned int *y_max, unsigned int *y_2ft_max)
+{
+	struct elantech_data *etd = psmouse->private;
+	int i;
+
+	switch (etd->hw_version) {
+	case 1:
+		*x_min = ETP_XMIN_V1;
+		*y_min = ETP_YMIN_V1;
+		*x_max = ETP_XMAX_V1;
+		*y_max = ETP_YMAX_V1;
+		break;
+
+	case 2:
+		if (etd->fw_version == 0x020800 ||
+		    etd->fw_version == 0x020b00 ||
+		    etd->fw_version == 0x020030) {
+			*x_min = ETP_XMIN_V2;
+			*y_min = ETP_YMIN_V2;
+			*x_max = ETP_XMAX_V2;
+			*y_max = ETP_YMAX_V2;
+			*y_2ft_max = ETP_2FT_YMAX;
+			break;
+		}
+
+		i = (etd->fw_version > 0x020800 &&
+		     etd->fw_version < 0x020900) ? 1 : 2;
+		*x_max = (etd->capabilities[1] - i) * 64;
+		*y_max = (etd->capabilities[2] - i) * 64;
+		*y_2ft_max = (*y_max - i) * 64 / 4;
+		break;
+	}
+}
+
 /*
  * Set the appropriate event bits for the input subsystem
  */
@@ -477,6 +513,9 @@ static void elantech_set_input_params(struct psmouse *psmouse)
 {
 	struct input_dev *dev = psmouse->dev;
 	struct elantech_data *etd = psmouse->private;
+	unsigned int x_min = 0, y_min = 0, x_max = 0, y_max = 0, y_2ft_max = 0;
+
+	set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &y_2ft_max);
 
 	__set_bit(EV_KEY, dev->evbit);
 	__set_bit(EV_ABS, dev->evbit);
@@ -494,18 +533,18 @@ static void elantech_set_input_params(struct psmouse *psmouse)
 	case 1:
 		/* Rocker button */
 		if (etd->fw_version < 0x020000 &&
-		    (etd->capabilities & ETP_CAP_HAS_ROCKER)) {
+		    (etd->capabilities[0] & ETP_CAP_HAS_ROCKER)) {
 			__set_bit(BTN_FORWARD, dev->keybit);
 			__set_bit(BTN_BACK, dev->keybit);
 		}
-		input_set_abs_params(dev, ABS_X, ETP_XMIN_V1, ETP_XMAX_V1, 0, 0);
-		input_set_abs_params(dev, ABS_Y, ETP_YMIN_V1, ETP_YMAX_V1, 0, 0);
+		input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
+		input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0);
 		break;
 
 	case 2:
 		__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);
+		input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
+		input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0);
 		if (etd->reports_pressure) {
 			input_set_abs_params(dev, ABS_PRESSURE, ETP_PMIN_V2,
 					     ETP_PMAX_V2, 0, 0);
@@ -514,10 +553,13 @@ static void elantech_set_input_params(struct psmouse *psmouse)
 		}
 		__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_MT_POSITION_X, x_min, x_max, 0, 0);
+		input_set_abs_params(dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0);
 		break;
 	}
+
+	etd->y_max = y_max;
+	etd->y_2ft_max = y_2ft_max;
 }
 
 struct elantech_attr_data {
@@ -771,13 +813,14 @@ int elantech_init(struct psmouse *psmouse)
 	pr_info("assuming hardware version %d, firmware version %d.%d.%d\n",
 		etd->hw_version, param[0], param[1], param[2]);
 
-	if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY, param)) {
+	if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY,
+	    etd->capabilities)) {
 		pr_err("failed to query capabilities.\n");
 		goto init_fail;
 	}
 	pr_info("Synaptics capabilities query result 0x%02x, 0x%02x, 0x%02x.\n",
-		param[0], param[1], param[2]);
-	etd->capabilities = param[0];
+		etd->capabilities[0], etd->capabilities[1],
+		etd->capabilities[2]);
 
 	/*
 	 * This firmware suffers from misreporting coordinates when
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index fabb2b9..4b7447e 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -104,13 +104,15 @@ struct elantech_data {
 	unsigned char reg_25;
 	unsigned char reg_26;
 	unsigned char debug;
-	unsigned char capabilities;
+	unsigned char capabilities[3];
 	bool paritycheck;
 	bool jumpy_cursor;
 	bool reports_pressure;
 	unsigned char hw_version;
 	unsigned int fw_version;
 	unsigned int single_finger_reports;
+	unsigned int y_max;
+	unsigned int y_2ft_max;
 	unsigned char parity[256];
 };
 
-- 
1.7.4.1


  parent reply	other threads:[~2011-08-18  1:55 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-18  1:57 [PATCH 0/6] elantech: add support for newer generation hardware JJ Ding
2011-08-18  1:57 ` [PATCH 1/6] Input: elantech - correct x, y value range for v2 hardware JJ Ding
2011-08-19 12:20   ` Éric Piel
2011-08-19 12:20     ` Éric Piel
2011-08-18  1:57 ` JJ Ding [this message]
2011-08-18  2:44   ` [PATCH 2/6] Input: elantech - use firmware provided x, y ranges Daniel Kurtz
2011-08-18  7:47   ` Dmitry Torokhov
2011-08-19  9:47     ` JJ Ding
2011-08-19 12:19       ` Éric Piel
2011-08-19 12:19         ` Éric Piel
2011-09-01 18:26     ` Chase Douglas
2011-09-05  3:22       ` JJ Ding
2011-09-06 17:03         ` Chase Douglas
2011-09-06 17:36           ` Dmitry Torokhov
2011-09-06 18:05             ` Chase Douglas
2011-09-06 18:20               ` Dmitry Torokhov
2011-09-06 19:29                 ` Chase Douglas
2011-09-07  2:33                   ` Daniel Kurtz
2011-09-07  2:33                     ` Daniel Kurtz
2011-09-06 18:47               ` Henrik Rydberg
2011-09-06 18:58                 ` Chase Douglas
2011-08-18  1:57 ` [PATCH 3/6] Input: elantech - packet checking for v2 hardware JJ Ding
2011-08-18  2:49   ` Daniel Kurtz
2011-08-18  6:38   ` Dmitry Torokhov
2011-08-18  7:31     ` JJ Ding
2011-08-18  7:52       ` Dmitry Torokhov
2011-08-18  8:06         ` JJ Ding
2011-08-19 12:22   ` Éric Piel
2011-08-19 12:22     ` Éric Piel
2011-08-18  1:57 ` [PATCH 4/6] Input: elantech - work around EC buffer JJ Ding
2011-08-18  2:50   ` Daniel Kurtz
2011-08-18  3:07   ` Wanlong Gao
2011-08-18  6:48     ` JJ Ding
2011-08-18  6:54       ` Wanlong Gao
2011-08-18  6:39   ` Dmitry Torokhov
2011-08-18  6:54     ` JJ Ding
2011-08-18  1:57 ` [PATCH 5/6] Input: elantech - clean up elantech_init JJ Ding
2011-08-18  3:04   ` Daniel Kurtz
2011-08-18  3:08     ` Wanlong Gao
2011-08-18  5:35       ` JJ Ding
2011-08-18  5:38         ` Wanlong Gao
2011-08-18  6:00         ` Dmitry Torokhov
2011-08-18  7:44           ` JJ Ding
2011-08-18  6:34   ` Wanlong Gao
2011-08-19 12:29   ` Éric Piel
2011-08-19 12:29     ` Éric Piel
2011-08-18  1:57 ` [PATCH 6/6] Input: elantech - add v3 hardware support JJ Ding
2011-08-18  2:57   ` Daniel Kurtz
2011-08-18  3:04     ` Wanlong Gao
2011-08-18  3:09       ` Daniel Kurtz
2011-08-18  3:09         ` Daniel Kurtz
2011-08-18  3:22         ` Wanlong Gao
2011-08-18  5:39     ` JJ Ding
2011-08-18  3:01   ` Wanlong Gao
2011-08-18  5:26     ` JJ Ding
2011-08-18  5:31       ` Wanlong Gao
2011-08-18  5:34         ` Daniel Kurtz
2011-08-18  5:44           ` Wanlong Gao
2011-08-18  6:01             ` Daniel Kurtz
2011-08-18  6:01               ` Daniel Kurtz
2011-08-18  6:06               ` Wanlong Gao
2011-08-18  7:49                 ` Tom _Lin
2011-08-18  3:30   ` Wanlong Gao
2011-08-18  3:47     ` Li Zefan
2011-08-18  4:15       ` Wanlong Gao
2011-08-18  6:02         ` Dmitry Torokhov
2011-08-18  6:08           ` Wanlong Gao
2011-08-18 13:58   ` Seth Forshee
2011-08-18 14:25     ` Seth Forshee
2011-08-18 14:25       ` Seth Forshee
2011-08-19  0:15       ` Wanlong Gao
2011-08-19  0:15         ` Wanlong Gao
2011-08-19  2:23       ` JJ Ding
2011-08-19  2:23         ` JJ Ding
2011-08-18 17:39   ` Seth Forshee
2011-08-19  8:29     ` JJ Ding
2011-08-19 12:13       ` Seth Forshee
2011-08-19 12:41         ` Éric Piel
2011-08-19 12:41           ` Éric Piel
2011-08-19 12:50           ` Seth Forshee
2011-08-19 12:50             ` Seth Forshee
2011-08-19 13:39             ` Éric Piel
2011-08-19 13:39               ` Éric Piel
2011-08-22  0:55         ` JJ Ding
2011-08-19 13:03   ` Éric Piel
2011-08-19 13:03     ` Éric Piel
2011-08-22  6:05     ` JJ Ding
2011-08-22  6:05       ` JJ Ding
2011-08-22  7:20       ` Tom _Lin
2011-08-22  7:20         ` Tom _Lin

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=1313632629-23603-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.