Skip to contentSkip to conversation

elantech: Report tool width when it is known

PATCH Superseded Éric Piel 3 participants 9 messages May 5, 2010

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Éric Piel

author
#0 lore raw

PATCH 1/2 elantech: Report tool width when it is known

Quoted 1 line

From observation of the values sent from the hardware version 2, it

seems that the first four bits of byte 1 represents the width. So we can report it as well. Observed values on my hardware were always between 1 and 12, so let's use this for min and max.

---
 drivers/input/mouse/elantech.c |   22 +++++++++++++---------
 drivers/input/mouse/elantech.h |    2 ++
 2 files changed, 15 insertions(+), 9 deletions(-)
drivers/input/mouse/elantech.c +10 -7
index 0520c2e..6a99b30 100644
@@ -249,7 +249,7 @@ 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;
@@ -258,17 +258,19 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
 	switch (fingers) {
 	case 1:
 		/*
-		 * byte 1:  .   .   .   .   .  x10 x9  x8
+		 * byte 1: w3  w2  w1  w0   .  x10 x9  x8
 		 * byte 2: x7  x6  x5  x4  x4  x2  x1  x0
 		 */
-		input_report_abs(dev, ABS_X,
-			((packet[1] & 0x07) << 8) | packet[2]);
+		width = ((packet[1] & 0xf0) >> 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 +288,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
@@ -467,6 +469,7 @@ static void elantech_set_input_params(struct psmouse *psmouse)
 		break;
 
 	case 2:
+		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);
drivers/input/mouse/elantech.h +2 -0
index feac5f7..2ce79c1 100644
@@ -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			12
 
 /*
  * For two finger touches the coordinate of each finger gets reported
Signature · 7 lines
1.7.1


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#1 lore raw
Quoted 5 lines · Éric Piel
Quoted 1 line

From observation of the values sent from the hardware version 2, it

seems that the first four bits of byte 1 represents the width. So we can report it as well. Observed values on my hardware were always between 1 and 12, so let's use this for min and max.

I think we shoudl have threshold for the firmware version when we start reporting the width.

Signature · 5 lines
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#7 lore raw
In reply to Éric Piel
Quoted 4 lines · Éric Piel
Quoted 1 line

From observation of the values sent from the hardware version 2, it

seems that the first four bits of byte 1 represents the width. So we can report it as well. Observed values on my hardware were always between 1 and 12, so let's use this for min and max.

Excellent. I'm quite happy to see this.

I've actually thought about reporting some kind of width based on the "thumb" bit in the first byte. The actual width information being available didn't occur to me for some reason.

The patch itself looks just fine to me, but it might also want to update the elantech documentation accordingly.

See also https://patchwork.kernel.org/patch/95448/ which isn't part of the -input tree yet.

Signature · 2 lines
BOFH excuse #362:
Plasma conduit breach
author
#2 lore raw
In reply to Dmitry Torokhov

Op 05-05-10 18:39, Dmitry Torokhov schreef:

Quoted 10 lines · Éric Piel
Quoted 5 lines
Quoted 1 line

From observation of the values sent from the hardware version 2, it

seems that the first four bits of byte 1 represents the width. So we can report it as well. Observed values on my hardware were always between 1 and 12, so let's use this for min and max.

I think we shoudl have threshold for the firmware version when we start reporting the width.

What do you mean? That the width might not be reported correctly by all the firmwares? I have no idea if that is the case. For info, IIRC my firmware report 2.1 with middle byte 8.

Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#8 lore raw
In reply to Florian Ragwitz
Quoted 12 lines · Florian Ragwitz
Quoted 4 lines · Éric Piel
Quoted 1 line

From observation of the values sent from the hardware version 2, it

seems that the first four bits of byte 1 represents the width. So we can report it as well. Observed values on my hardware were always between 1 and 12, so let's use this for min and max.

Excellent. I'm quite happy to see this.

I've actually thought about reporting some kind of width based on the "thumb" bit in the first byte. The actual width information being available didn't occur to me for some reason.

Quoted 6 lines

The patch itself looks just fine to me, but it might also want to update the elantech documentation accordingly.

See also https://patchwork.kernel.org/patch/95448/ which isn't part of the -input tree yet.

It is - I folded it with the changes to the driver and it is upstream. I left out the new 4.1 signature patch until we know better about firmware versions, but otherwise your changes are in mainline.

Signature · 5 lines
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#3 lore raw
In reply to Éric Piel
Quoted 8 lines · Éric Piel

Op 05-05-10 18:39, Dmitry Torokhov schreef:

Quoted 7 lines · Éric Piel
Quoted 5 lines
Quoted 1 line

From observation of the values sent from the hardware version 2, it

seems that the first four bits of byte 1 represents the width. So we can report it as well. Observed values on my hardware were always between 1 and 12, so let's use this for min and max.

Quoted 7 lines
Quoted 3 lines

I think we shoudl have threshold for the firmware version when we start reporting the width.

What do you mean? That the width might not be reported correctly by all the firmwares? I have no idea if that is the case. For info, IIRC my firmware report 2.1 with middle byte 8.

My understanding was that older firmwares would report 0. I might be mistaken.

Signature · 5 lines
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
Quoted 11 lines · Dmitry Torokhov
Quoted 7 lines · Éric Piel

Op 05-05-10 18:39, Dmitry Torokhov schreef:

Quoted 3 lines

I think we shoudl have threshold for the firmware version when we start reporting the width.

What do you mean? That the width might not be reported correctly by all the firmwares? I have no idea if that is the case. For info, IIRC my firmware report 2.1 with middle byte 8.

My understanding was that older firmwares would report 0. I might be mistaken.

Some firmwares always set the upper bits to 0. Others don't.

As far as I can see, we only know about firmware version 2.1 and 4.1 using those high bits for width reports.

However, there's firmware versions inbetween, like 2.48, which don't report width information. And there's even other firmware versions inbetween, like 2.36, which actually implment what the driver calls hardware version 1. Those have a quite different packet format, and also no width information.

Currently it seems to be unknown how to detect hw ver 1 vs. 2 based on the firmware version. Guesses tend towards the middle bit being signifficant, somehow.

Signature · 2 lines
BOFH excuse #136:
Daemons loose in system.
maintainer
#5 lore raw
Quoted 15 lines · Florian Ragwitz
Quoted 11 lines · Dmitry Torokhov
Quoted 7 lines · Éric Piel

Op 05-05-10 18:39, Dmitry Torokhov schreef:

Quoted 2 lines

I think we shoudl have threshold for the firmware version when we start reporting the width.

What do you mean? That the width might not be reported correctly by all the firmwares? I have no idea if that is the case. For info, IIRC my firmware report 2.1 with middle byte 8.

My understanding was that older firmwares would report 0. I might be mistaken.

Some firmwares always set the upper bits to 0. Others don't.

Quoted 8 lines

As far as I can see, we only know about firmware version 2.1 and 4.1 using those high bits for width reports.

However, there's firmware versions inbetween, like 2.48, which don't report width information. And there's even other firmware versions inbetween, like 2.36, which actually implment what the driver calls hardware version 1. Those have a quite different packet format, and also no width information.

What we need to figure out if 2.48 and 2.36 are in fact something like 2.0.48 and 2.0.36.. And 2.1 is actually 2.x.1. Then it would all make better sense.

Quoted 4 lines

Currently it seems to be unknown how to detect hw ver 1 vs. 2 based on the firmware version. Guesses tend towards the middle bit being signifficant, somehow.

Signature · 5 lines
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#6 lore raw

Op 05-05-10 20:09, Dmitry Torokhov schreef:

Quoted 1 line · Florian Ragwitz

:

Quoted 11 lines
Quoted 10 lines

Some firmwares always set the upper bits to 0. Others don't.

As far as I can see, we only know about firmware version 2.1 and 4.1 using those high bits for width reports.

However, there's firmware versions inbetween, like 2.48, which don't report width information. And there's even other firmware versions inbetween, like 2.36, which actually implment what the driver calls hardware version 1. Those have a quite different packet format, and also no width information.

Quoted 3 lines

What we need to figure out if 2.48 and 2.36 are in fact something like 2.0.48 and 2.0.36.. And 2.1 is actually 2.x.1. Then it would all make better sense.

Could it be that the ability of detecting width is indicated in the capability bytes? Here I have 0x08 0x13 0x0d .

Eric