2016-04-01 13:07:17

by Gabriele Mazzotta

[permalink] [raw]
Subject: [PATCH v4 0/4] input: synaptics - report correct width and pressure values

The problem of the previous set, v3, was the use of ABS_MT_TOUCH_MAJOR
to report finger widths without them being expressed in surface units.
In this set only the width of the first touch is reported, this time
using ABS_TOOL_WIDTH.

Gabriele Mazzotta (4):
input: synaptics - fix pressure values calculation on image sensors
input: synaptics - fix width values calculation on image sensors
input: synaptics - change default width value of cr48 sensors
input: synaptics - make image sensors and cr48 sensors report widths

drivers/input/mouse/synaptics.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)

--
2.8.0.rc3


2016-04-01 13:07:19

by Gabriele Mazzotta

[permalink] [raw]
Subject: [PATCH v4 3/4] input: synaptics - change default width value of cr48 sensors

The minimum value these sensors can report is 4, so this should be the
value used when W is not reporting the width.

Signed-off-by: Gabriele Mazzotta <[email protected]>
---
drivers/input/mouse/synaptics.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index ba321e7..27a091b 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -1032,7 +1032,7 @@ static void synaptics_process_packet(struct psmouse *psmouse)

if (hw.z > 0 && hw.x > 1) {
num_fingers = 1;
- finger_width = 5;
+ finger_width = 4;
if (SYN_CAP_EXTENDED(priv->capabilities)) {
switch (hw.w) {
case 0 ... 1:
--
2.8.0.rc3

2016-04-01 13:07:41

by Gabriele Mazzotta

[permalink] [raw]
Subject: [PATCH v4 4/4] input: synaptics - make image sensors and cr48 sensors report widths

Despite claiming to report finger widths, image sensors and cr48
profile sensors were not doing it. Since the touchpad uses an
abstract unit for the width of the fingers, report only the witdh
of the first touch using ABS_TOOL_WIDTH.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=77161
Signed-off-by: Gabriele Mazzotta <[email protected]>
---
drivers/input/mouse/synaptics.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 27a091b..bed268b 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -943,6 +943,8 @@ static void synaptics_report_mt_data(struct psmouse *psmouse,
input_report_abs(dev, ABS_MT_PRESSURE, hw[i]->z);
}

+ input_report_abs(dev, ABS_TOOL_WIDTH, hw[0]->w);
+
input_mt_drop_unused(dev);

/* Don't use active slot count to generate BTN_TOOL events. */
--
2.8.0.rc3

2016-04-01 13:08:05

by Gabriele Mazzotta

[permalink] [raw]
Subject: [PATCH v4 2/4] input: synaptics - fix width values calculation on image sensors

When multiple fingers are on the touchpad, W reports the finger
count rather than the width. Retrieve the correct value that is
encoded in X, Y and Z of AGM and SGM packets.

The minimum width reported is 8 rather than 4 in this case, while the
maximum remains 15.

Signed-off-by: Gabriele Mazzotta <[email protected]>
---
drivers/input/mouse/synaptics.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 01fccca..ba321e7 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -674,10 +674,12 @@ static void synaptics_parse_agm(const unsigned char buf[],
switch (agm_packet_type) {
case 1:
/* Gesture packet: (x, y, z) half resolution */
- agm->w = hw->w;
- agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
- agm->y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1;
- agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 2;
+ agm->w = ((buf[1] & 0x01) |
+ ((buf[2] & 0x01) << 1) |
+ ((buf[5] & 0x01) << 2)) + 8;
+ agm->x = (((buf[4] & 0x0f) << 8) | (buf[1] & 0xfe)) << 1;
+ agm->y = (((buf[4] & 0xf0) << 4) | (buf[2] & 0xfe)) << 1;
+ agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0e)) << 2;
break;

case 2:
@@ -974,6 +976,17 @@ static void synaptics_image_sensor_process(struct psmouse *psmouse,
else
num_fingers = 4;

+ /* When multiple fingers are on the TouchPad, the width is encoded in
+ * X, Y and Z */
+ if (sgm->w == 0 || sgm->w == 1) {
+ sgm->w = (((sgm->x & BIT(1)) >> 1) |
+ (sgm->y & BIT(1)) |
+ ((sgm->z & BIT(0)) << 2)) + 8;
+ sgm->x &= ~BIT(1);
+ sgm->y &= ~BIT(1);
+ sgm->z &= ~BIT(0);
+ }
+
/* Send resulting input events to user space */
synaptics_report_mt_data(psmouse, sgm, num_fingers);
}
--
2.8.0.rc3

2016-04-01 13:09:21

by Gabriele Mazzotta

[permalink] [raw]
Subject: [PATCH v4 1/4] input: synaptics - fix pressure values calculation on image sensors

The pressure values retrieved from secondary packets was incorrectly
shifted, making them lower than what they actually were.
Since this only happened with secondary packets, the values reported
when only one finger was present on the touchpad were correct.

Signed-off-by: Gabriele Mazzotta <[email protected]>
---
drivers/input/mouse/synaptics.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index a41d832..01fccca 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -677,7 +677,7 @@ static void synaptics_parse_agm(const unsigned char buf[],
agm->w = hw->w;
agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
agm->y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1;
- agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1;
+ agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 2;
break;

case 2:
--
2.8.0.rc3