Re: [Linuxwacom-devel] [PATCH input-wacom 2/2] Implement support for multitouch value conflict resolution on 2.6.35+

2018-01-25 Thread Ping Cheng
On Thu, Jan 25, 2018 at 11:49 AM, Jason Gerecke 
wrote:

> Devices using the 2.6.30 wacom-specific multitouch protocol have to be
> careful to ensure that two contacts don't use the same axis value. This
> is because the second contact's value will be swallowed by the kernel.
> The 2.6.36 kernel replaced direct-access to the value with an accessor
> function (named "input_abs_get_val"), but our 2.6.30-compatible branch
> kept using direct access, though only for pre-2.6.35 kernels (off-by-one
> error on the version number).
>
> This commit introduces an "input_abs_get_val" function for pre-2.6.36
> kernels. This allows us to use the native API where available and
> fallback to direct access when not. It also means that the fixups are
> now applied to 2.6.35+ kernels.
>

Nice cleanup! Thank you.


>
> Signed-off-by: Jason Gerecke 
>

Reviewed-by: Ping Cheng  for the set.

Cheers,
Ping

---
>  2.6.30/wacom_wac.c | 26 ++
>  1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/2.6.30/wacom_wac.c b/2.6.30/wacom_wac.c
> index 72c5f65..90c5c2b 100644
> --- a/2.6.30/wacom_wac.c
> +++ b/2.6.30/wacom_wac.c
> @@ -909,6 +909,14 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
> return 0;
>  }
>
> +
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
> +static int input_abs_get_val(struct input_dev *input, unsigned int axis)
> +{
> +   return input->abs[axis];
> +}
> +#endif
> +
>  static void wacom_multitouch_generic_finger(struct wacom_wac *wacom,
> int contact_id, bool prox,
> int x, int y)
> @@ -928,14 +936,12 @@ static void wacom_multitouch_generic_finger(struct
> wacom_wac *wacom,
>
> wacom->slots[slot] = prox ? contact_id : -1;
>
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
> if (wacom->last_finger != slot) {
> -   if (x == input->abs[ABS_X])
> +   if (x == input_abs_get_val(input, ABS_X))
> x++;
> -   if (y == input->abs[ABS_Y])
> +   if (y == input_abs_get_val(input, ABS_Y))
> y++;
> }
> -#endif
>
> if (wacom->shared)
> prox = prox && !wacom->shared->stylus_in_proximity;
> @@ -1063,15 +1069,13 @@ static void wacom_tpc_finger_in(struct wacom_wac
> *wacom, unsigned char *data, in
> int x = le16_to_cpup((__le16 *)[finger * 2]) & 0x7fff;
> int y = le16_to_cpup((__le16 *)[4 + finger * 2]) & 0x7fff;
>
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
> if (wacom->last_finger != finger) {
> -   if (x == input->abs[ABS_X])
> +   if (x == input_abs_get_val(input, ABS_X))
> x++;
>
> -   if (y == input->abs[ABS_Y])
> +   if (y == input_abs_get_val(input, ABS_Y))
> y++;
> }
> -#endif
>
> input_report_abs(input, ABS_X, x);
> input_report_abs(input, ABS_Y, y);
> @@ -1217,15 +1221,13 @@ static void wacom_tpc_mt(struct wacom_wac *wacom)
> int x = get_unaligned_le16([offset +
> x_offset + 7]);
> int y = get_unaligned_le16([offset +
> x_offset + 9]);
>
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
> if (wacom->last_finger == id) {
> -   if (x == input->abs[ABS_X])
> +   if (x == input_abs_get_val(input,
> ABS_X))
> x++;
>
> -   if (y == input->abs[ABS_Y])
> +   if (y == input_abs_get_val(input,
> ABS_Y))
> y++;
> }
> -#endif
>
> wacom->id[slot+1] = touch;
> if (!wacom->id[1] && !wacom->id[2])
> --
> 2.16.0
>
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


[Linuxwacom-devel] [PATCH input-wacom 1/2] Guard direct access of 'input->abs' in 2.6.30 tree where necessary

2018-01-25 Thread Jason Gerecke
The 2.6.36 kernel removed the "abs" member from "struct input_dev". Two
other blocks in the 2.6.30 tree already have surrounding #if guards to
ensure we don't try to reference "abs", but one is missing the guard.

Curiously, the guards check for a kernel earlier than 2.6.35 rather than
2.6.36. We'll follow that convention even though its not correct...

Ref: 898e7d46f8 ("Add Intous5 touch support in 2.6.30+")
Fixes: 126ec2dd60 ("Add support to ISDV4 0x100 and 0x101")
Signed-off-by: Jason Gerecke 
---
 2.6.30/wacom_wac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/2.6.30/wacom_wac.c b/2.6.30/wacom_wac.c
index 5aeb183..72c5f65 100644
--- a/2.6.30/wacom_wac.c
+++ b/2.6.30/wacom_wac.c
@@ -1217,6 +1217,7 @@ static void wacom_tpc_mt(struct wacom_wac *wacom)
int x = get_unaligned_le16([offset + 
x_offset + 7]);
int y = get_unaligned_le16([offset + 
x_offset + 9]);
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
if (wacom->last_finger == id) {
if (x == input->abs[ABS_X])
x++;
@@ -1224,6 +1225,7 @@ static void wacom_tpc_mt(struct wacom_wac *wacom)
if (y == input->abs[ABS_Y])
y++;
}
+#endif
 
wacom->id[slot+1] = touch;
if (!wacom->id[1] && !wacom->id[2])
-- 
2.16.0


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


[Linuxwacom-devel] [PATCH input-wacom 2/2] Implement support for multitouch value conflict resolution on 2.6.35+

2018-01-25 Thread Jason Gerecke
Devices using the 2.6.30 wacom-specific multitouch protocol have to be
careful to ensure that two contacts don't use the same axis value. This
is because the second contact's value will be swallowed by the kernel.
The 2.6.36 kernel replaced direct-access to the value with an accessor
function (named "input_abs_get_val"), but our 2.6.30-compatible branch
kept using direct access, though only for pre-2.6.35 kernels (off-by-one
error on the version number).

This commit introduces an "input_abs_get_val" function for pre-2.6.36
kernels. This allows us to use the native API where available and
fallback to direct access when not. It also means that the fixups are
now applied to 2.6.35+ kernels.

Signed-off-by: Jason Gerecke 
---
 2.6.30/wacom_wac.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/2.6.30/wacom_wac.c b/2.6.30/wacom_wac.c
index 72c5f65..90c5c2b 100644
--- a/2.6.30/wacom_wac.c
+++ b/2.6.30/wacom_wac.c
@@ -909,6 +909,14 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
return 0;
 }
 
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
+static int input_abs_get_val(struct input_dev *input, unsigned int axis)
+{
+   return input->abs[axis];
+}
+#endif
+
 static void wacom_multitouch_generic_finger(struct wacom_wac *wacom,
int contact_id, bool prox,
int x, int y)
@@ -928,14 +936,12 @@ static void wacom_multitouch_generic_finger(struct 
wacom_wac *wacom,
 
wacom->slots[slot] = prox ? contact_id : -1;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
if (wacom->last_finger != slot) {
-   if (x == input->abs[ABS_X])
+   if (x == input_abs_get_val(input, ABS_X))
x++;
-   if (y == input->abs[ABS_Y])
+   if (y == input_abs_get_val(input, ABS_Y))
y++;
}
-#endif
 
if (wacom->shared)
prox = prox && !wacom->shared->stylus_in_proximity;
@@ -1063,15 +1069,13 @@ static void wacom_tpc_finger_in(struct wacom_wac 
*wacom, unsigned char *data, in
int x = le16_to_cpup((__le16 *)[finger * 2]) & 0x7fff;
int y = le16_to_cpup((__le16 *)[4 + finger * 2]) & 0x7fff;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
if (wacom->last_finger != finger) {
-   if (x == input->abs[ABS_X])
+   if (x == input_abs_get_val(input, ABS_X))
x++;
 
-   if (y == input->abs[ABS_Y])
+   if (y == input_abs_get_val(input, ABS_Y))
y++;
}
-#endif
 
input_report_abs(input, ABS_X, x);
input_report_abs(input, ABS_Y, y);
@@ -1217,15 +1221,13 @@ static void wacom_tpc_mt(struct wacom_wac *wacom)
int x = get_unaligned_le16([offset + 
x_offset + 7]);
int y = get_unaligned_le16([offset + 
x_offset + 9]);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
if (wacom->last_finger == id) {
-   if (x == input->abs[ABS_X])
+   if (x == input_abs_get_val(input, 
ABS_X))
x++;
 
-   if (y == input->abs[ABS_Y])
+   if (y == input_abs_get_val(input, 
ABS_Y))
y++;
}
-#endif
 
wacom->id[slot+1] = touch;
if (!wacom->id[1] && !wacom->id[2])
-- 
2.16.0


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel