All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] some updates for newer elantech touchpads
@ 2011-11-21  5:53 JJ Ding
  2011-11-21  5:53 ` [PATCH v2 1/2] Input: elantech - add support for elantech fast command JJ Ding
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: JJ Ding @ 2011-11-21  5:53 UTC (permalink / raw)
  To: Dmitry Torokhov, Aaron Huang, Tom Lin, Éric Piel
  Cc: linux-input, JJ Ding

Hi,

These two are my last pending patches for newer elantech touchpads.
The first patch adds support for a shorter and faster send_cmd, available
since v3 hardware. The other one teaches the driver to query resolution
data from v4 hardware.

Patches are against Dmitry's current -next tree.

Any comment is welcome, thank you very much.

Change in v2:
 - allow resolution query to fail, print a warning if so. (Daniel)

JJ Ding (2):
  Input: elantech - add support for elantech fast command
  Input: elantech - add resolution query support for v4 hardware

 drivers/input/mouse/elantech.c |   75 +++++++++++++++++++++++++++++++++++----
 drivers/input/mouse/elantech.h |    2 +
 2 files changed, 69 insertions(+), 8 deletions(-)

-- 
1.7.8-rc2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] Input: elantech - add support for elantech fast command
  2011-11-21  5:53 [PATCH v2 0/2] some updates for newer elantech touchpads JJ Ding
@ 2011-11-21  5:53 ` JJ Ding
  2011-11-21  5:53 ` [PATCH v2 2/2] Input: elantech - add resolution query support for v4 hardware JJ Ding
  2011-11-21  6:37 ` [PATCH v2 0/2] some updates for newer elantech touchpads Dmitry Torokhov
  2 siblings, 0 replies; 5+ messages in thread
From: JJ Ding @ 2011-11-21  5:53 UTC (permalink / raw)
  To: Dmitry Torokhov, Aaron Huang, Tom Lin, Éric Piel
  Cc: linux-input, JJ Ding

Starting with v3 hardware, the firmware supports this shorter
elantech_send_cmd. Teach the driver to use it.

Signed-off-by: JJ Ding <jj_ding@emc.com.tw>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
---
 drivers/input/mouse/elantech.c |   38 ++++++++++++++++++++++++++++++--------
 drivers/input/mouse/elantech.h |    1 +
 2 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index b562392..dae020c 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -43,6 +43,24 @@ static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c,
 }
 
 /*
+ * V3 and later support this fast command
+ */
+static int elantech_send_cmd(struct psmouse *psmouse, unsigned char c,
+				unsigned char *param)
+{
+	struct ps2dev *ps2dev = &psmouse->ps2dev;
+
+	if (ps2_command(ps2dev, NULL, ETP_PS2_CUSTOM_COMMAND) ||
+	    ps2_command(ps2dev, NULL, c) ||
+	    ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {
+		psmouse_err(psmouse, "%s query 0x%02x failed.\n", __func__, c);
+		return -1;
+	}
+
+	return 0;
+}
+
+/*
  * A retrying version of ps2_command
  */
 static int elantech_ps2_command(struct psmouse *psmouse,
@@ -863,13 +881,13 @@ static int elantech_set_range(struct psmouse *psmouse,
 			i = (etd->fw_version > 0x020800 &&
 			     etd->fw_version < 0x020900) ? 1 : 2;
 
-			if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param))
+			if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param))
 				return -1;
 
 			fixed_dpi = param[1] & 0x10;
 
 			if (((etd->fw_version >> 16) == 0x14) && fixed_dpi) {
-				if (synaptics_send_cmd(psmouse, ETP_SAMPLE_QUERY, param))
+				if (etd->send_cmd(psmouse, ETP_SAMPLE_QUERY, param))
 					return -1;
 
 				*x_max = (etd->capabilities[1] - i) * param[1] / 2;
@@ -888,7 +906,7 @@ static int elantech_set_range(struct psmouse *psmouse,
 		break;
 
 	case 3:
-		if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param))
+		if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param))
 			return -1;
 
 		*x_max = (0x0f & param[0]) << 8 | param[1];
@@ -896,7 +914,7 @@ static int elantech_set_range(struct psmouse *psmouse,
 		break;
 
 	case 4:
-		if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param))
+		if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param))
 			return -1;
 
 		*x_max = (0x0f & param[0]) << 8 | param[1];
@@ -1220,9 +1238,13 @@ static int elantech_set_properties(struct elantech_data *etd)
 	else
 		return -1;
 
-	/*
-	 * Turn on packet checking by default.
-	 */
+	/* decide which send_cmd we're gonna use early */
+	if (etd->hw_version > 2)
+		etd->send_cmd = elantech_send_cmd;
+	else
+		etd->send_cmd = synaptics_send_cmd;
+
+	/* Turn on packet checking by default */
 	etd->paritycheck = 1;
 
 	/*
@@ -1278,7 +1300,7 @@ int elantech_init(struct psmouse *psmouse)
 		     "assuming hardware version %d (with firmware version 0x%02x%02x%02x)\n",
 		     etd->hw_version, param[0], param[1], param[2]);
 
-	if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY,
+	if (etd->send_cmd(psmouse, ETP_CAPABILITIES_QUERY,
 	    etd->capabilities)) {
 		psmouse_err(psmouse, "failed to query capabilities.\n");
 		goto init_fail;
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index 9e5f1aa..08d00bd 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -135,6 +135,7 @@ struct elantech_data {
 	unsigned int width;
 	struct finger_pos mt[ETP_MAX_FINGERS];
 	unsigned char parity[256];
+	int (*send_cmd)(struct psmouse *psmouse, unsigned char c, unsigned char *param);
 };
 
 #ifdef CONFIG_MOUSE_PS2_ELANTECH
-- 
1.7.8-rc2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] Input: elantech - add resolution query support for v4 hardware
  2011-11-21  5:53 [PATCH v2 0/2] some updates for newer elantech touchpads JJ Ding
  2011-11-21  5:53 ` [PATCH v2 1/2] Input: elantech - add support for elantech fast command JJ Ding
@ 2011-11-21  5:53 ` JJ Ding
  2011-11-21  6:37 ` [PATCH v2 0/2] some updates for newer elantech touchpads Dmitry Torokhov
  2 siblings, 0 replies; 5+ messages in thread
From: JJ Ding @ 2011-11-21  5:53 UTC (permalink / raw)
  To: Dmitry Torokhov, Aaron Huang, Tom Lin, Éric Piel
  Cc: linux-input, JJ Ding

It turns out that v4's firmware provides a command so we can query
the resolution. Let's use it.

Signed-off-by: JJ Ding <jj_ding@emc.com.tw>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
---

Hi Daniel,

I still add your Reviewed-by. I checked synaptics.c and it leaves resolution
zero if touchpad doesn't support it. So I just allow the query to fail and don't
check x_res != 0 && y_res != 0. If the query fails, x_res and y_res should be 0
as they've been initialized. Please let me know if you think this behavior might
cause problems. Thank you very much.

jj

 drivers/input/mouse/elantech.c |   37 +++++++++++++++++++++++++++++++++++++
 drivers/input/mouse/elantech.h |    1 +
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index dae020c..1122924 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -931,6 +931,30 @@ static int elantech_set_range(struct psmouse *psmouse,
 }
 
 /*
+ * (value from firmware) * 10 + 790 = dpi
+ * we also have to convert dpi to dots/mm (*10/254 to avoid floating point)
+ */
+static inline unsigned int convert_res(unsigned int val)
+{
+	return (val * 10 + 790) * 10 / 254;
+}
+
+static int set_resolution_v4(struct psmouse *psmouse,
+			     unsigned int *x_res,
+			     unsigned int *y_res)
+{
+	unsigned char param[3];
+
+	if (elantech_send_cmd(psmouse, ETP_RESOLUTION_QUERY, param))
+		return -1;
+
+	*x_res = convert_res(param[1] & 0x0f);
+	*y_res = convert_res((param[1] & 0xf0) >> 4);
+
+	return 0;
+}
+
+/*
  * Set the appropriate event bits for the input subsystem
  */
 static int elantech_set_input_params(struct psmouse *psmouse)
@@ -938,6 +962,7 @@ static int 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, width = 0;
+	unsigned int x_res = 0, y_res = 0;
 
 	if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width))
 		return -1;
@@ -985,10 +1010,20 @@ static int elantech_set_input_params(struct psmouse *psmouse)
 		break;
 
 	case 4:
+		if (set_resolution_v4(psmouse, &x_res, &y_res)) {
+			/*
+			 * if query failed, print a warning and leave the values
+			 * zero to resemble synaptics.c behavior.
+			 */
+			psmouse_warn(psmouse, "couldn't query resolution data.\n");
+		}
+
 		__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
 		/* For X to recognize me as touchpad. */
 		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);
+		input_abs_set_res(dev, ABS_X, x_res);
+		input_abs_set_res(dev, ABS_Y, y_res);
 		/*
 		 * range of pressure and width is the same as v2,
 		 * report ABS_PRESSURE, ABS_TOOL_WIDTH for compatibility.
@@ -1001,6 +1036,8 @@ static int elantech_set_input_params(struct psmouse *psmouse)
 		input_mt_init_slots(dev, ETP_MAX_FINGERS);
 		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);
+		input_abs_set_res(dev, ABS_MT_POSITION_X, x_res);
+		input_abs_set_res(dev, ABS_MT_POSITION_Y, y_res);
 		input_set_abs_params(dev, ABS_MT_PRESSURE, ETP_PMIN_V2,
 				     ETP_PMAX_V2, 0, 0);
 		/*
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index 08d00bd..46db3be 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -20,6 +20,7 @@
 #define ETP_FW_VERSION_QUERY		0x01
 #define ETP_CAPABILITIES_QUERY		0x02
 #define ETP_SAMPLE_QUERY		0x03
+#define ETP_RESOLUTION_QUERY		0x04
 
 /*
  * Command values for register reading or writing
-- 
1.7.8-rc2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/2] some updates for newer elantech touchpads
  2011-11-21  5:53 [PATCH v2 0/2] some updates for newer elantech touchpads JJ Ding
  2011-11-21  5:53 ` [PATCH v2 1/2] Input: elantech - add support for elantech fast command JJ Ding
  2011-11-21  5:53 ` [PATCH v2 2/2] Input: elantech - add resolution query support for v4 hardware JJ Ding
@ 2011-11-21  6:37 ` Dmitry Torokhov
  2011-11-21  9:29   ` JJ Ding
  2 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2011-11-21  6:37 UTC (permalink / raw)
  To: JJ Ding; +Cc: Aaron Huang, Tom Lin, Éric Piel, Daniel Kurtz, linux-input

On Mon, Nov 21, 2011 at 01:53:04PM +0800, JJ Ding wrote:
> Hi,
> 
> These two are my last pending patches for newer elantech touchpads.
> The first patch adds support for a shorter and faster send_cmd, available
> since v3 hardware. The other one teaches the driver to query resolution
> data from v4 hardware.
> 
> Patches are against Dmitry's current -next tree.
> 
> Any comment is welcome, thank you very much.
> 
> Change in v2:
>  - allow resolution query to fail, print a warning if so. (Daniel)
> 

Applied both, thanks JJ.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/2] some updates for newer elantech touchpads
  2011-11-21  6:37 ` [PATCH v2 0/2] some updates for newer elantech touchpads Dmitry Torokhov
@ 2011-11-21  9:29   ` JJ Ding
  0 siblings, 0 replies; 5+ messages in thread
From: JJ Ding @ 2011-11-21  9:29 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Aaron Huang, Tom Lin, Éric Piel, Daniel Kurtz, linux-input

Hi Dmitry,

On Sun, 20 Nov 2011 22:37:25 -0800, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> On Mon, Nov 21, 2011 at 01:53:04PM +0800, JJ Ding wrote:
> > Hi,
> > 
> > These two are my last pending patches for newer elantech touchpads.
> > The first patch adds support for a shorter and faster send_cmd, available
> > since v3 hardware. The other one teaches the driver to query resolution
> > data from v4 hardware.
> > 
> > Patches are against Dmitry's current -next tree.
> > 
> > Any comment is welcome, thank you very much.
> > 
> > Change in v2:
> >  - allow resolution query to fail, print a warning if so. (Daniel)
> > 
> 
> Applied both, thanks JJ.

Thank you for taking these patches.

jj
> 
> -- 
> Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-21  9:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-21  5:53 [PATCH v2 0/2] some updates for newer elantech touchpads JJ Ding
2011-11-21  5:53 ` [PATCH v2 1/2] Input: elantech - add support for elantech fast command JJ Ding
2011-11-21  5:53 ` [PATCH v2 2/2] Input: elantech - add resolution query support for v4 hardware JJ Ding
2011-11-21  6:37 ` [PATCH v2 0/2] some updates for newer elantech touchpads Dmitry Torokhov
2011-11-21  9:29   ` JJ Ding

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.