Skip to contentSkip to conversation

elantech: Improved protocol support for hardware 2

PATCH In review Éric Piel 2 participants 7 messages May 8, 2010 – May 10, 2010

Subsystems (3)
lore
Share & tools
lore

Éric Piel

author
#0 lore raw

PATCH 1/2 elantech: Improved protocol support for hardware 2

Quoted 1 line

From observation of the values sent from the hardware, it is possible to

determine also:
* the width of the touch (coded on 6 bits)
* the lowest coordinates of a three-finger touch
* whether there is just three fingers or more
So report this information as well, and update the protocol description document.

---
 Documentation/input/elantech.txt |   22 +++++++++++++++-------
 drivers/input/mouse/elantech.c   |   36 ++++++++++++++++++++++++++----------
 drivers/input/mouse/elantech.h   |    2 ++
 3 files changed, 43 insertions(+), 17 deletions(-)
Documentation/input/elantech.txt +15 -7
index 56941ae..cb8471b 100644
@@ -319,7 +319,7 @@ For example:
 4.2 Native absolute mode 6 byte packet format
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-4.2.1 One finger touch
+4.2.1 One/Three finger touch
       ~~~~~~~~~~~~~~~~
 
 byte 0:
@@ -333,19 +333,22 @@ byte 0:
 byte 1:
 
    bit   7   6   5   4   3   2   1   0
+         w5  w4  w3  w2  .  x10 x9  x8
          .   .   .   .   .  x10 x9  x8
 
 byte 2:
 
    bit   7   6   5   4   3   2   1   0
-        x7  x6  x5  x4  x4  x2  x1  x0
+        x7  x6  x5  x4  x3  x2  x1  x0
 
          x10..x0 = absolute x value (horizontal)
 
 byte 3:
 
    bit   7   6   5   4   3   2   1   0
-         .   .   .   .   .   .   .   .
+        n4  .   w1  w0   .   .   .   .
+         w6..w0 = width of the finger touch
+         n4 = set if more than 3 fingers (only in 3 fingers mode)
 
 byte 4:
 
@@ -363,6 +366,11 @@ byte 5:
 4.2.2 Two finger touch
       ~~~~~~~~~~~~~~~~
 
+Note that the two pairs of coordinates are not exactly the coordinates of the 
+two fingers, but only the pair of the lowest and highest coordinates. So the 
+actual fingers might be situated on the other diagonal of the square defined by
+these two points.
+
 byte 0:
 
    bit   7   6   5   4   3   2   1   0
@@ -376,14 +384,14 @@ byte 1:
    bit   7   6   5   4   3   2   1   0
         ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0
 
-         ax8..ax0 = first finger absolute x value
+         ax8..ax0 = lower finger absolute x value
 
 byte 2:
 
    bit   7   6   5   4   3   2   1   0
         ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0
 
-         ay8..ay0 = first finger absolute y value
+         ay8..ay0 = lower finger absolute y value
 
 byte 3:
 
@@ -395,11 +403,11 @@ byte 4:
    bit   7   6   5   4   3   2   1   0
         bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0
 
-         bx8..bx0 = second finger absolute x value
+         bx8..bx0 = higher finger absolute x value
 
 byte 5:
 
    bit   7   6   5   4   3   2   1   0
         by7 by8 by5 by4 by3 by2 by1 by0
 
-         by8..by0 = second finger absolute y value
+         by8..by0 = higher finger absolute y value
drivers/input/mouse/elantech.c +26 -10
index 0520c2e..2708b22 100644
@@ -249,26 +249,38 @@ 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;
 	input_report_key(dev, BTN_TOUCH, fingers != 0);
 
 	switch (fingers) {
+	case 3:
+		/*
+		 * Same as one finger excepted report of more than 3
+		 * fingers pressed:
+		 * byte 3:  n4  .   w1  w0   .   .   .   .
+		 */
+		if (packet[3] & 0x80)
+			fingers = 4;
+		/* pass through... */
 	case 1:
 		/*
-		 * byte 1:  .   .   .   .   .  x10 x9  x8
-		 * byte 2: x7  x6  x5  x4  x4  x2  x1  x0
+		 * byte 1: w5  w4  w3  w2   .  x10 x9  x8
+		 * byte 2: x7  x6  x5  x4  x3  x2  x1  x0
+		 * byte 3: .   .   w1  w0   .   .   .   .
 		 */
-		input_report_abs(dev, ABS_X,
-			((packet[1] & 0x07) << 8) | packet[2]);
+		width = ((packet[1] & 0xf0) >> 2) | ((packet[3] & 0x30) >> 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 +298,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
@@ -308,6 +320,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
 	input_report_key(dev, BTN_TOOL_FINGER, fingers == 1);
 	input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2);
 	input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3);
+	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);
 
@@ -467,6 +480,8 @@ static void elantech_set_input_params(struct psmouse *psmouse)
 		break;
 
 	case 2:
+		__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
+		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);
@@ -693,8 +708,9 @@ int elantech_init(struct psmouse *psmouse)
 	 * Assume every version greater than this is new EeePC style
 	 * hardware with 6 byte packets
 	 */
-	if ((etd->fw_version_maj == 0x02 && etd->fw_version_min >= 0x30) ||
-	    etd->fw_version_maj > 0x02) {
+	//if ((etd->fw_version_maj == 0x02 && etd->fw_version_min >= 0x30) ||
+	//    etd->fw_version_maj > 0x02) {
+	if (etd->fw_version_maj >= 0x02) {
 		etd->hw_version = 2;
 		/* For now show extra debug information */
 		etd->debug = 1;
drivers/input/mouse/elantech.h +2 -0
index feac5f7..5093762 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			(1 << 6)
 
 /*
  * 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
#1 lore raw

Hi Éric,

Quoted 10 lines
Quoted 1 line

From observation of the values sent from the hardware, it is possible to

determine also:
* the width of the touch (coded on 6 bits)
* the lowest coordinates of a three-finger touch
* whether there is just three fingers or more
So report this information as well, and update the protocol description document.

---

Please run the ./scripts/checkpatch.pl on patches before submitting them, to remove trivial formatting errors.

Cheers,
Henrik

--
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
#2 lore raw

Op 08-05-10 19:45, Henrik Rydberg schreef:

Quoted 2 lines

Hi Éric,

:

Quoted 3 lines

Please run the ./scripts/checkpatch.pl on patches before submitting them, to remove trivial formatting errors.

Ooops, I usually run it... forgot this time, while it would have been very worthy. Thanks for noticing.
Here is a version fixed.

%<---------------------------------------------------

From observation of the values sent from the hardware, it is possible to determine also:
* the width of the touch (coded on 6 bits)
* the lowest coordinates of a three-finger touch
* whether there is just three fingers or more
So report this information as well, and update the protocol description document.

---
 Documentation/input/elantech.txt |   22 +++++++++++++++-------
 drivers/input/mouse/elantech.c   |   32 +++++++++++++++++++++++++---------
 drivers/input/mouse/elantech.h   |    2 ++
 3 files changed, 41 insertions(+), 15 deletions(-)
(quoted diff) +0 -0

b/Documentation/input/elantech.txt
index 56941ae..b115bb7 100644

Documentation/input/elantech.txt +7 -3
@@ -319,7 +319,7 @@ For example:
 4.2 Native absolute mode 6 byte packet format
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-4.2.1 One finger touch
+4.2.1 One/Three finger touch
       ~~~~~~~~~~~~~~~~
 
 byte 0:
@@ -333,19 +333,22 @@ byte 0:
 byte 1:
 
    bit   7   6   5   4   3   2   1   0
+         w5  w4  w3  w2  .  x10 x9  x8
          .   .   .   .   .  x10 x9  x8
 
 byte 2:
 
    bit   7   6   5   4   3   2   1   0
-        x7  x6  x5  x4  x4  x2  x1  x0
+        x7  x6  x5  x4  x3  x2  x1  x0
 
          x10..x0 = absolute x value (horizontal)
 
 byte 3:
 
    bit   7   6   5   4   3   2   1   0
-         .   .   .   .   .   .   .   .
+        n4  .   w1  w0   .   .   .   .
+         w6..w0 = width of the finger touch
+         n4 = set if more than 3 fingers (only in 3 fingers mode)
 
 byte 4:
 
@@ -363,6 +366,11 @@ byte 5:
 4.2.2 Two finger touch
       ~~~~~~~~~~~~~~~~
 
+Note that the two pairs of coordinates are not exactly the coordinates

of the
+two fingers, but only the pair of the lowest and highest coordinates. So the
+actual fingers might be situated on the other diagonal of the square defined by
+these two points.
+
byte 0:

bit 7 6 5 4 3 2 1 0
@@ -376,14 +384,14 @@ byte 1:
bit 7 6 5 4 3 2 1 0
ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0

- ax8..ax0 = first finger absolute x value
+ ax8..ax0 = lower finger absolute x value

byte 2:

bit 7 6 5 4 3 2 1 0
ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0

- ay8..ay0 = first finger absolute y value
+ ay8..ay0 = lower finger absolute y value

byte 3:

@@ -395,11 +403,11 @@ byte 4:
bit 7 6 5 4 3 2 1 0
bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0

- bx8..bx0 = second finger absolute x value
+ bx8..bx0 = higher finger absolute x value

byte 5:

bit 7 6 5 4 3 2 1 0
by7 by8 by5 by4 by3 by2 by1 by0

- by8..by0 = second finger absolute y value
+ by8..by0 = higher finger absolute y value

drivers/input/mouse/elantech.c +0 -0
index 0520c2e..2708b22 100644
@@ -249,26 +249,38 @@ 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; input_report_key(dev, BTN_TOUCH, fingers != 0);

switch (fingers) {
+ case 3:
+ /*
+ * Same as one finger excepted report of more than 3
+ * fingers pressed:
+ * byte 3: n4 . w1 w0 . . . .
+ */
+ if (packet[3] & 0x80)
+ fingers = 4;
+ /* pass through... */
case 1:
/*

-		 * byte 1:  .   .   .   .   .  x10 x9  x8
-		 * byte 2: x7  x6  x5  x4  x4  x2  x1  x0
+		 * byte 1: w5  w4  w3  w2   .  x10 x9  x8
+		 * byte 2: x7  x6  x5  x4  x3  x2  x1  x0

+ * byte 3: . . w1 w0 . . . .
*/
- input_report_abs(dev, ABS_X,
- ((packet[1] & 0x07) << 8) | packet[2]);
+ width = ((packet[1] & 0xf0) >> 2) | ((packet[3] & 0x30) >> 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 +298,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
@@ -308,6 +320,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
input_report_key(dev, BTN_TOOL_FINGER, fingers == 1); input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2); input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3);
+ 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);

@@ -467,6 +480,8 @@ static void elantech_set_input_params(struct psmouse *psmouse)
break;

case 2:
+ __set_bit(BTN_TOOL_QUADTAP, dev->keybit);
+ 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..5093762 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			(1 << 6)
 
 /*
  * For two finger touches the coordinate of each finger gets reported
Signature · 6 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
#3 lore raw
Quoted 9 lines · Éric Piel

Op 08-05-10 19:45, Henrik Rydberg schreef:

Quoted 2 lines

Hi Éric,

:

Quoted 2 lines

Please run the ./scripts/checkpatch.pl on patches before submitting them, to remove trivial formatting errors.

Ooops, I usually run it... forgot this time, while it would have been very worthy. Thanks for noticing.
Here is a version fixed.

Thanks, comments below.

Quoted 62 lines

%<---------------------------------------------------

From observation of the values sent from the hardware, it is possible to determine also:
* the width of the touch (coded on 6 bits)
* the lowest coordinates of a three-finger touch
* whether there is just three fingers or more
So report this information as well, and update the protocol description document.

---
 Documentation/input/elantech.txt |   22 +++++++++++++++-------
 drivers/input/mouse/elantech.c   |   32 +++++++++++++++++++++++++---------
 drivers/input/mouse/elantech.h   |    2 ++
 3 files changed, 41 insertions(+), 15 deletions(-)
Documentation/input/elantech.txt +7 -3
index 56941ae..b115bb7 100644
@@ -319,7 +319,7 @@ For example:
 4.2 Native absolute mode 6 byte packet format
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-4.2.1 One finger touch
+4.2.1 One/Three finger touch
       ~~~~~~~~~~~~~~~~
 
 byte 0:
@@ -333,19 +333,22 @@ byte 0:
 byte 1:
 
    bit   7   6   5   4   3   2   1   0
+         w5  w4  w3  w2  .  x10 x9  x8
          .   .   .   .   .  x10 x9  x8
 
 byte 2:
 
    bit   7   6   5   4   3   2   1   0
-        x7  x6  x5  x4  x4  x2  x1  x0
+        x7  x6  x5  x4  x3  x2  x1  x0
 
          x10..x0 = absolute x value (horizontal)
 
 byte 3:
 
    bit   7   6   5   4   3   2   1   0
-         .   .   .   .   .   .   .   .
+        n4  .   w1  w0   .   .   .   .
+         w6..w0 = width of the finger touch
+         n4 = set if more than 3 fingers (only in 3 fingers mode)
 
 byte 4:
 
@@ -363,6 +366,11 @@ byte 5:
 4.2.2 Two finger touch
       ~~~~~~~~~~~~~~~~
 
+Note that the two pairs of coordinates are not exactly the coordinates
Quoted 6 lines

of the
+two fingers, but only the pair of the lowest and highest coordinates. So the
+actual fingers might be situated on the other diagonal of the square defined by
+these two points.

Somewhat odd linebreaking (at least in my mailreader). How about lower-left and upper-right for clarity?

Quoted 8 lines
Documentation/input/elantech.txt +1 -0
+
 byte 0:
 
    bit   7   6   5   4   3   2   1   0
@@ -376,14 +384,14 @@ byte 1:
    bit   7   6   5   4   3   2   1   0
         ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0
 

Documentation/input/elantech.txt byte 1: · line 394

Quoted 10 lines
Documentation/input/elantech.txt +2 -2
-         ax8..ax0 = first finger absolute x value
+         ax8..ax0 = lower finger absolute x value
 
 byte 2:
 
    bit   7   6   5   4   3   2   1   0
         ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0
 
-         ay8..ay0 = first finger absolute y value
+         ay8..ay0 = lower finger absolute y value

lower-left?

Documentation/input/elantech.txt byte 4: · line 406

Quoted 9 lines
Documentation/input/elantech.txt +1 -1
 byte 3:
 
@@ -395,11 +403,11 @@ byte 4:
    bit   7   6   5   4   3   2   1   0
         bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0
 
-         bx8..bx0 = second finger absolute x value
+         bx8..bx0 = higher finger absolute x value

upper-right?

Quoted 19 lines
Documentation/input/elantech.txt +1 -1
 byte 5:
 
    bit   7   6   5   4   3   2   1   0
         by7 by8 by5 by4 by3 by2 by1 by0
 
-         by8..by0 = second finger absolute y value
+         by8..by0 = higher finger absolute y value
drivers/input/mouse/elantech.c +1 -1
index 0520c2e..2708b22 100644
@@ -249,26 +249,38 @@ 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;

drivers/input/mouse/elantech.c static void elantech_report_absolute_v2(struct · line 263

Quoted 10 lines
drivers/input/mouse/elantech.c +4 -0
 
 	/* byte 0: n1  n0   .   .   .   .   R   L */
 	fingers = (packet[0] & 0xc0) >> 6;
 	input_report_key(dev, BTN_TOUCH, fingers != 0);
 
 	switch (fingers) {
+	case 3:
+		/*
+		 * Same as one finger excepted report of more than 3
+		 * fingers pressed:

should this read ", except report more than three"?

Quoted 18 lines
drivers/input/mouse/elantech.c +10 -4
+		 * byte 3:  n4  .   w1  w0   .   .   .   .
+		 */
+		if (packet[3] & 0x80)
+			fingers = 4;
+		/* pass through... */
 	case 1:
 		/*
-		 * byte 1:  .   .   .   .   .  x10 x9  x8
-		 * byte 2: x7  x6  x5  x4  x4  x2  x1  x0
+		 * byte 1: w5  w4  w3  w2   .  x10 x9  x8
+		 * byte 2: x7  x6  x5  x4  x3  x2  x1  x0
+		 * byte 3: .   .   w1  w0   .   .   .   .
 		 */
-		input_report_abs(dev, ABS_X,
-			((packet[1] & 0x07) << 8) | packet[2]);
+		width = ((packet[1] & 0xf0) >> 2) | ((packet[3] & 0x30) >> 4);
+		x1 = ((packet[1] & 0x07) << 8) | packet[2];
 		/*

drivers/input/mouse/elantech.c static void elantech_report_absolute_v2(struct · line 285

Quoted 10 lines
drivers/input/mouse/elantech.c +4 -2
 		 * byte 4:  .   .   .   .   .   .  y9  y8
 		 * byte 5: y7  y6  y5  y4  y3  y2  y1  y0z
 		 */
-		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;

I agree usage of x1 is somehow better, but it is not strictly necessary, since the patch only adds the width. Just adding width would suffice. It also makes it easier to prove that the patch does the right thing.

Quoted 22 lines
drivers/input/mouse/elantech.c +1 -1
 	case 2:
@@ -286,7 +298,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]);
 		/*
drivers/input/mouse/elantech.c +1 -0
 		 * For compatibility with the X Synaptics driver scale up
@@ -308,6 +320,7 @@ static void elantech_report_absolute_v2(struct
 psmouse *psmouse)
 	input_report_key(dev, BTN_TOOL_FINGER, fingers == 1);
 	input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2);
 	input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3);
+	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);

drivers/input/mouse/elantech.c static void elantech_set_input_params(struct psmouse · line 486

Quoted 7 lines
drivers/input/mouse/elantech.c +2 -0
@@ -467,6 +480,8 @@ static void elantech_set_input_params(struct psmouse
 *psmouse)
 		break;
 
 	case 2:
+		__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
+		input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2, ETP_WMAX_V2,
 0, 0);

Is there an appropriate signal-to-noise ratio for the width? How does the device handle fingers going away? Does it send one or several zero-width events?

Quoted 8 lines
drivers/input/mouse/elantech.c +0 -0
 		input_set_abs_params(dev, ABS_X, ETP_XMIN_V2, ETP_XMAX_V2, 0, 0);
drivers/input/mouse/elantech.c +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 +0 -0
index feac5f7..5093762 100644

drivers/input/mouse/elantech.h line 83

Quoted 8 lines
drivers/input/mouse/elantech.h +2 -0
@@ -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			(1 << 6)
 
 /*
  * For two finger touches the coordinate of each finger gets reported

Thanks,
Henrik
--
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
#4 lore raw

Op 09-05-10 19:08, Henrik Rydberg schreef:

Quoted 4 lines
Quoted 3 lines · Éric Piel

Op 08-05-10 19:45, Henrik Rydberg schreef:

Quoted 2 lines

Hi Éric,

Quoted 8 lines
Quoted 6 lines

:

Quoted 2 lines

Please run the ./scripts/checkpatch.pl on patches before submitting them, to remove trivial formatting errors.

Ooops, I usually run it... forgot this time, while it would have been very worthy. Thanks for noticing.
Here is a version fixed.

Thanks, comments below.

:
Thanks for the feedback. I'll fix the comments and resend.

Quoted 11 lines

Review static void elantech_set_input_params(struct psmouse · line 486

Quoted 8 lines
(quoted diff) +2 -0
@@ -467,6 +480,8 @@ static void elantech_set_input_params(struct psmouse
 *psmouse)
 		break;
 
 	case 2:
+		__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
+		input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2, ETP_WMAX_V2,
 0, 0);

Is there an appropriate signal-to-noise ratio for the width? How does the device handle fingers going away? Does it send one or several zero-width events?

What do you mean by SNR for the width? The minimal variation which is significant for an actual change in the width of the finger? On my hardware it was fairly precise, and a unit was stable as long as I kept the finger pressed the same way. Actually at some low pressures I could swear it detects my blood pulse ;-) That said, in all the measures the values were between 13 and 55, but I put as min and max 0 and 64. I did this because I'm not sure it's the same with every version of the hardware (apparently some old versions of the hardware even just report 0 all the time). It sounded more conservative this way. Is that the right way?

When you leave the last finger, the device sends one message with "0 finger". However, as it is currently working, the driver then just sends one "BTN_TOUCH 0", but not any change in the ABS_TOOL_WIDTH. According to the input protocol, should it also sends in this case a "ABS_TOOL_WIDTH 0"?

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

#5 lore raw
Quoted 10 lines
Quoted 10 lines

Review static void elantech_set_input_params(struct psmouse · line 486

Quoted 8 lines
(quoted diff) +2 -0
@@ -467,6 +480,8 @@ static void elantech_set_input_params(struct psmouse
 *psmouse)
 		break;
 
 	case 2:
+		__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
+		input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2, ETP_WMAX_V2,
 0, 0);

Is there an appropriate signal-to-noise ratio for the width? How does the device handle fingers going away? Does it send one or several zero-width events?

Quoted 4 lines

What do you mean by SNR for the width? The minimal variation which is significant for an actual change in the width of the finger? On my hardware it was fairly precise, and a unit was stable as long as I kept the finger pressed the same way.

Yes, that was what I was thinking of. If there is a lot of variation, it makes sense to use the fuzz parameter to reduce the number of events emitted from the input core.

Quoted 2 lines

Actually at some low pressures I could
swear it detects my blood pulse ;-)

It probably does - question is if that means the fuzz should be increased somewhat. :-)

Quoted 6 lines

That said, in all the measures the
values were between 13 and 55, but I put as min and max 0 and 64. I did this because I'm not sure it's the same with every version of the hardware (apparently some old versions of the hardware even just report 0 all the time). It sounded more conservative this way. Is that the right way?

It sounds fine. The min and max are not exactly enforced by the input core, but having the theoretic scale helps a lot when setting up applications.

Quoted 5 lines

When you leave the last finger, the device sends one message with "0 finger". However, as it is currently working, the driver then just sends one "BTN_TOUCH 0", but not any change in the ABS_TOOL_WIDTH. According to the input protocol, should it also sends in this case a "ABS_TOOL_WIDTH 0"?

It is fine with just BTN_TOUCH for the non-MT protocol.

The reason I asked specifically about this is partly because the current defuzz mechanism might need to be extended for some special values, like zero for the width and pressure events. For example, rather than emit zero, the input core will emit anything between zero and the value of the fuzz parameter, upon receiving a zero value.

Dmitry, this problem is very similar, but not identical to, the flat parameter used for joysticks. Is there or has there been any thought about a similar mechanism for the ABS events?

Henrik

author
#6 lore raw
In reply to Éric Piel

Here is a revised version fixing the comments from Henrik. Note that I have changed the way the width is reported as after the discussion the current behaviour appears to be correct.

Eric 8<-------------------------------------------------------------

From observation of the values sent from the hardware, it is possible to determine also:
* the width of the touch (coded on 6 bits)
* the lowest coordinates of a three-finger touch
* whether there is just three fingers or more
So report this information as well, and update the protocol description document.

---
 Documentation/input/elantech.txt |   22 +++++++++++++++-------
 drivers/input/mouse/elantech.c   |   27 +++++++++++++++++++++------
 drivers/input/mouse/elantech.h   |    2 ++
 3 files changed, 38 insertions(+), 13 deletions(-)
Documentation/input/elantech.txt +15 -7
index 56941ae..41dee4e 100644
@@ -319,7 +319,7 @@ For example:
 4.2 Native absolute mode 6 byte packet format
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-4.2.1 One finger touch
+4.2.1 One/Three finger touch
       ~~~~~~~~~~~~~~~~
 
 byte 0:
@@ -333,19 +333,22 @@ byte 0:
 byte 1:
 
    bit   7   6   5   4   3   2   1   0
+         w5  w4  w3  w2  .  x10 x9  x8
          .   .   .   .   .  x10 x9  x8
 
 byte 2:
 
    bit   7   6   5   4   3   2   1   0
-        x7  x6  x5  x4  x4  x2  x1  x0
+        x7  x6  x5  x4  x3  x2  x1  x0
 
          x10..x0 = absolute x value (horizontal)
 
 byte 3:
 
    bit   7   6   5   4   3   2   1   0
-         .   .   .   .   .   .   .   .
+        n4  .   w1  w0   .   .   .   .
+         w6..w0 = width of the finger touch
+         n4 = set if more than 3 fingers (only in 3 fingers mode)
 
 byte 4:
 
@@ -363,6 +366,11 @@ byte 5:
 4.2.2 Two finger touch
       ~~~~~~~~~~~~~~~~
 
+Note that the two pairs of coordinates are not exactly the coordinates of the
+two fingers, but only the pair of the lower-left and upper-right coordinates.
+So the actual fingers might be situated on the other diagonal of the square
+defined by these two points.
+
 byte 0:
 
    bit   7   6   5   4   3   2   1   0
@@ -376,14 +384,14 @@ byte 1:
    bit   7   6   5   4   3   2   1   0
         ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0
 
-         ax8..ax0 = first finger absolute x value
+         ax8..ax0 = lower-left finger absolute x value
 
 byte 2:
 
    bit   7   6   5   4   3   2   1   0
         ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0
 
-         ay8..ay0 = first finger absolute y value
+         ay8..ay0 = lower-left finger absolute y value
 
 byte 3:
 
@@ -395,11 +403,11 @@ byte 4:
    bit   7   6   5   4   3   2   1   0
         bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0
 
-         bx8..bx0 = second finger absolute x value
+         bx8..bx0 = upper-right finger absolute x value
 
 byte 5:
 
    bit   7   6   5   4   3   2   1   0
         by7 by8 by5 by4 by3 by2 by1 by0
 
-         by8..by0 = second finger absolute y value
+         by8..by0 = upper-right finger absolute y value
drivers/input/mouse/elantech.c +18 -4
index 0520c2e..3dceb0f 100644
@@ -249,18 +249,29 @@ 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;
 	input_report_key(dev, BTN_TOUCH, fingers != 0);
 
 	switch (fingers) {
+	case 3:
+		/*
+		 * Same as one finger, except report of more than 3 fingers:
+		 * byte 3:  n4  .   w1  w0   .   .   .   .
+		 */
+		if (packet[3] & 0x80)
+			fingers = 4;
+		/* pass through... */
 	case 1:
 		/*
-		 * byte 1:  .   .   .   .   .  x10 x9  x8
-		 * byte 2: x7  x6  x5  x4  x4  x2  x1  x0
+		 * byte 1: w5  w4  w3  w2   .  x10 x9  x8
+		 * byte 2: x7  x6  x5  x4  x3  x2  x1  x0
+		 * byte 3: .   .   w1  w0   .   .   .   .
 		 */
+		width = ((packet[1] & 0xf0) >> 2) | ((packet[3] & 0x30) >> 4);
+		input_report_abs(dev, ABS_TOOL_WIDTH, width);
 		input_report_abs(dev, ABS_X,
 			((packet[1] & 0x07) << 8) | packet[2]);
 		/*
@@ -286,7 +297,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
@@ -308,6 +319,7 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
 	input_report_key(dev, BTN_TOOL_FINGER, fingers == 1);
 	input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2);
 	input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3);
+	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);
 
@@ -467,6 +479,8 @@ static void elantech_set_input_params(struct psmouse *psmouse)
 		break;
 
 	case 2:
+		__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
+		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..5093762 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			(1 << 6)
 
 /*
  * For two finger touches the coordinate of each finger gets reported
Signature · 6 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