linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] HID: wacom: Don't set tool type until we're in range
@ 2019-04-24 22:12 Gerecke, Jason
  2019-04-24 22:12 ` [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range Gerecke, Jason
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Gerecke, Jason @ 2019-04-24 22:12 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires
  Cc: Ping Cheng, Aaron Armstrong Skomra, Jason Gerecke, stable,
	Aaron Armstrong Skomra

From: Jason Gerecke <jason.gerecke@wacom.com>

The serial number and tool type information that is reported by the tablet
while a pen is merely "in prox" instead of fully "in range" can be stale
and cause us to report incorrect tool information. Serial number, tool
type, and other information is only valid once the pen comes fully in range
so we should be careful to not use this information until that point.

In particular, this issue may cause the driver to incorectly report
BTN_TOOL_RUBBER after switching from the eraser tool back to the pen.

Fixes: a48324de6d ("HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range")
Cc: <stable@vger.kernel.org> # 4.11+
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
---
 drivers/hid/wacom_wac.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 747730d32ab6..4c1bc239207e 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1236,13 +1236,13 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
 		/* Add back in missing bits of ID for non-USI pens */
 		wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
 	}
-	wacom->tool[0]   = wacom_intuos_get_tool_type(wacom_intuos_id_mangle(wacom->id[0]));
 
 	for (i = 0; i < pen_frames; i++) {
 		unsigned char *frame = &data[i*pen_frame_len + 1];
 		bool valid = frame[0] & 0x80;
 		bool prox = frame[0] & 0x40;
 		bool range = frame[0] & 0x20;
+		bool invert = frame[0] & 0x10;
 
 		if (!valid)
 			continue;
@@ -1251,9 +1251,24 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
 			wacom->shared->stylus_in_proximity = false;
 			wacom_exit_report(wacom);
 			input_sync(pen_input);
+
+			wacom->tool[0] = 0;
+			wacom->id[0] = 0;
+			wacom->serial[0] = 0;
 			return;
 		}
+
 		if (range) {
+			if (!wacom->tool[0]) { /* first in range */
+				/* Going into range select tool */
+				if (invert)
+					wacom->tool[0] = BTN_TOOL_RUBBER;
+				else if (wacom->id[0])
+					wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
+				else
+					wacom->tool[0] = BTN_TOOL_PEN;
+			}
+
 			input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
 			input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
 
-- 
2.21.0

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

* [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range
  2019-04-24 22:12 [PATCH 1/2] HID: wacom: Don't set tool type until we're in range Gerecke, Jason
@ 2019-04-24 22:12 ` Gerecke, Jason
       [not found]   ` <20190425121506.7EBEC218B0@mail.kernel.org>
       [not found] ` <20190425121505.3AD33218AD@mail.kernel.org>
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: Gerecke, Jason @ 2019-04-24 22:12 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires
  Cc: Ping Cheng, Aaron Armstrong Skomra, Jason Gerecke, stable,
	Aaron Armstrong Skomra

From: Jason Gerecke <jason.gerecke@wacom.com>

If the tool spends some time in prox before entering range, a series of
events (e.g. ABS_DISTANCE, MSC_SERIAL) can be sent before we or userspace
have any clue about the pen whose data is being reported. We need to hold
off on reporting anything until the pen has entered range. Since we still
want to report events that occur "in prox" after the pen has *left* range
we use 'wacom-tool[0]' as the indicator that the pen did at one point
enter range and provide us/userspace with tool type and serial number
information.

Fixes: a48324de6d ("HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range")
Cc: <stable@vger.kernel.org> # 4.11+
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
---
 drivers/hid/wacom_wac.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 4c1bc239207e..613342bb9d6b 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1290,23 +1290,26 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
 						 get_unaligned_le16(&frame[11]));
 			}
 		}
-		input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
-		if (wacom->features.type == INTUOSP2_BT) {
-			input_report_abs(pen_input, ABS_DISTANCE,
-					 range ? frame[13] : wacom->features.distance_max);
-		} else {
-			input_report_abs(pen_input, ABS_DISTANCE,
-					 range ? frame[7] : wacom->features.distance_max);
-		}
 
-		input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01);
-		input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
-		input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
+		if (wacom->tool[0]) {
+			input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
+			if (wacom->features.type == INTUOSP2_BT) {
+				input_report_abs(pen_input, ABS_DISTANCE,
+						 range ? frame[13] : wacom->features.distance_max);
+			} else {
+				input_report_abs(pen_input, ABS_DISTANCE,
+						 range ? frame[7] : wacom->features.distance_max);
+			}
+
+			input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01);
+			input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
+			input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
 
-		input_report_key(pen_input, wacom->tool[0], prox);
-		input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
-		input_report_abs(pen_input, ABS_MISC,
-				 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
+			input_report_key(pen_input, wacom->tool[0], prox);
+			input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
+			input_report_abs(pen_input, ABS_MISC,
+					 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
+		}
 
 		wacom->shared->stylus_in_proximity = prox;
 
-- 
2.21.0

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

* Re: [PATCH 1/2] HID: wacom: Don't set tool type until we're in range
       [not found] ` <20190425121505.3AD33218AD@mail.kernel.org>
@ 2019-04-25 17:47   ` Jason Gerecke
  2019-04-26  3:33     ` Sasha Levin
  0 siblings, 1 reply; 14+ messages in thread
From: Jason Gerecke @ 2019-04-25 17:47 UTC (permalink / raw)
  To: Sasha Levin; +Cc: Jason Gerecke, Linux Input, Ping Cheng, # v3.17+

I can produce a version of this patch specific to v4.14.113. Please
let me know the proper process for submitting such a patch.

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one  /
(That is to say, eight) to the two,     /
But you can’t take seven from three,    /
So you look at the sixty-fours....


On Thu, Apr 25, 2019 at 5:15 AM Sasha Levin <sashal@kernel.org> wrote:
>
> Hi,
>
> [This is an automated email]
>
> This commit has been processed because it contains a "Fixes:" tag,
> fixing commit: a48324de6d4d HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range.
>
> The bot has tested the following trees: v5.0.9, v4.19.36, v4.14.113.
>
> v5.0.9: Build OK!
> v4.19.36: Build OK!
> v4.14.113: Failed to apply! Possible dependencies:
>     Unable to calculate
>
>
> How should we proceed with this patch?
>
> --
> Thanks,
> Sasha

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

* Re: [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range
       [not found]   ` <20190425121506.7EBEC218B0@mail.kernel.org>
@ 2019-04-25 17:47     ` Jason Gerecke
  2019-04-26 16:35       ` Gerecke, Jason
  0 siblings, 1 reply; 14+ messages in thread
From: Jason Gerecke @ 2019-04-25 17:47 UTC (permalink / raw)
  To: Sasha Levin; +Cc: Jason Gerecke, Linux Input, Ping Cheng, # v3.17+

I can produce a version of this patch specific to v4.14.113. Please
let me know the proper process for submitting such a patch.

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one  /
(That is to say, eight) to the two,     /
But you can’t take seven from three,    /
So you look at the sixty-fours....

On Thu, Apr 25, 2019 at 5:15 AM Sasha Levin <sashal@kernel.org> wrote:
>
> Hi,
>
> [This is an automated email]
>
> This commit has been processed because it contains a "Fixes:" tag,
> fixing commit: a48324de6d4d HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range.
>
> The bot has tested the following trees: v5.0.9, v4.19.36, v4.14.113.
>
> v5.0.9: Build OK!
> v4.19.36: Build OK!
> v4.14.113: Failed to apply! Possible dependencies:
>     87046b6c995c ("HID: wacom: Add support for 3rd generation Intuos BT")
>     c947218951da ("HID: wacom: Add support for One by Wacom (CTL-472 / CTL-672)")
>
>
> How should we proceed with this patch?
>
> --
> Thanks,
> Sasha

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

* Re: [PATCH 1/2] HID: wacom: Don't set tool type until we're in range
  2019-04-25 17:47   ` [PATCH 1/2] HID: wacom: Don't set tool type until we're in range Jason Gerecke
@ 2019-04-26  3:33     ` Sasha Levin
  2019-04-26 16:34       ` Gerecke, Jason
  0 siblings, 1 reply; 14+ messages in thread
From: Sasha Levin @ 2019-04-26  3:33 UTC (permalink / raw)
  To: Jason Gerecke; +Cc: Jason Gerecke, Linux Input, Ping Cheng, # v3.17+

On Thu, Apr 25, 2019 at 10:47:42AM -0700, Jason Gerecke wrote:
>I can produce a version of this patch specific to v4.14.113. Please
>let me know the proper process for submitting such a patch.

Just replying to this mail will do the job, thanks!

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

* [PATCH 1/2] HID: wacom: Don't set tool type until we're in range
  2019-04-26  3:33     ` Sasha Levin
@ 2019-04-26 16:34       ` Gerecke, Jason
  0 siblings, 0 replies; 14+ messages in thread
From: Gerecke, Jason @ 2019-04-26 16:34 UTC (permalink / raw)
  To: # v3.17+, Sasha Levin
  Cc: linux-input, Ping Cheng, Aaron Armstrong Skomra, Jason Gerecke,
	Aaron Armstrong Skomra

From: Jason Gerecke <jason.gerecke@wacom.com>

The serial number and tool type information that is reported by the tablet
while a pen is merely "in prox" instead of fully "in range" can be stale
and cause us to report incorrect tool information. Serial number, tool
type, and other information is only valid once the pen comes fully in range
so we should be careful to not use this information until that point.

In particular, this issue may cause the driver to incorectly report
BTN_TOOL_RUBBER after switching from the eraser tool back to the pen.

Fixes: a48324de6d ("HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range")
Cc: <stable@vger.kernel.org> # 4.11+
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
---
Version of patch specifically targeted to stable v4.14.113

 drivers/hid/wacom_wac.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 4c72e68637c2..03b04bc742dd 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1225,13 +1225,13 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
 		/* Add back in missing bits of ID for non-USI pens */
 		wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
 	}
-	wacom->tool[0]   = wacom_intuos_get_tool_type(wacom_intuos_id_mangle(wacom->id[0]));
 
 	for (i = 0; i < pen_frames; i++) {
 		unsigned char *frame = &data[i*pen_frame_len + 1];
 		bool valid = frame[0] & 0x80;
 		bool prox = frame[0] & 0x40;
 		bool range = frame[0] & 0x20;
+		bool invert = frame[0] & 0x10;
 
 		if (!valid)
 			continue;
@@ -1240,9 +1240,24 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
 			wacom->shared->stylus_in_proximity = false;
 			wacom_exit_report(wacom);
 			input_sync(pen_input);
+
+			wacom->tool[0] = 0;
+			wacom->id[0] = 0;
+			wacom->serial[0] = 0;
 			return;
 		}
+
 		if (range) {
+			if (!wacom->tool[0]) { /* first in range */
+				/* Going into range select tool */
+				if (invert)
+					wacom->tool[0] = BTN_TOOL_RUBBER;
+				else if (wacom->id[0])
+					wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
+				else
+					wacom->tool[0] = BTN_TOOL_PEN;
+			}
+
 			/* Fix rotation alignment: userspace expects zero at left */
 			int16_t rotation = (int16_t)get_unaligned_le16(&frame[9]);
 			rotation += 1800/4;
-- 
2.21.0

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

* [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range
  2019-04-25 17:47     ` Jason Gerecke
@ 2019-04-26 16:35       ` Gerecke, Jason
  2019-06-11 19:02         ` Jason Gerecke
  0 siblings, 1 reply; 14+ messages in thread
From: Gerecke, Jason @ 2019-04-26 16:35 UTC (permalink / raw)
  To: # v3.17+, Sasha Levin
  Cc: linux-input, Ping Cheng, Aaron Armstrong Skomra, Jason Gerecke,
	Aaron Armstrong Skomra

From: Jason Gerecke <jason.gerecke@wacom.com>

If the tool spends some time in prox before entering range, a series of
events (e.g. ABS_DISTANCE, MSC_SERIAL) can be sent before we or userspace
have any clue about the pen whose data is being reported. We need to hold
off on reporting anything until the pen has entered range. Since we still
want to report events that occur "in prox" after the pen has *left* range
we use 'wacom-tool[0]' as the indicator that the pen did at one point
enter range and provide us/userspace with tool type and serial number
information.

Fixes: a48324de6d ("HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range")
Cc: <stable@vger.kernel.org> # 4.11+
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
---
Version of patch specifically targeted to stable v4.14.113

 drivers/hid/wacom_wac.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 03b04bc742dd..e4aeffa56018 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1271,17 +1271,20 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
 			input_report_abs(pen_input, ABS_Z, rotation);
 			input_report_abs(pen_input, ABS_WHEEL, get_unaligned_le16(&frame[11]));
 		}
-		input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
-		input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max);
 
-		input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01);
-		input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
-		input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
+		if (wacom->tool[0]) {
+			input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
+			input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max);
 
-		input_report_key(pen_input, wacom->tool[0], prox);
-		input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
-		input_report_abs(pen_input, ABS_MISC,
-				 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
+			input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01);
+			input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
+			input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
+
+			input_report_key(pen_input, wacom->tool[0], prox);
+			input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
+			input_report_abs(pen_input, ABS_MISC,
+					 wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
+		}
 
 		wacom->shared->stylus_in_proximity = prox;
 
-- 
2.21.0

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

* Re: [PATCH 1/2] HID: wacom: Don't set tool type until we're in range
  2019-04-24 22:12 [PATCH 1/2] HID: wacom: Don't set tool type until we're in range Gerecke, Jason
  2019-04-24 22:12 ` [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range Gerecke, Jason
       [not found] ` <20190425121505.3AD33218AD@mail.kernel.org>
@ 2019-05-07 18:43 ` Jason Gerecke
  2019-05-17 14:27 ` Benjamin Tissoires
  3 siblings, 0 replies; 14+ messages in thread
From: Jason Gerecke @ 2019-05-07 18:43 UTC (permalink / raw)
  To: Linux Input, Benjamin Tissoires
  Cc: Ping Cheng, Aaron Armstrong Skomra, Jason Gerecke, # v3.17+,
	Aaron Armstrong Skomra

Haven't heard anything back from you about this patch set, Benjamin.
Just making sure it doesn't get lost down a crack :)

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one  /
(That is to say, eight) to the two,     /
But you can’t take seven from three,    /
So you look at the sixty-fours....


On Wed, Apr 24, 2019 at 3:13 PM Gerecke, Jason <killertofu@gmail.com> wrote:
>
> From: Jason Gerecke <jason.gerecke@wacom.com>
>
> The serial number and tool type information that is reported by the tablet
> while a pen is merely "in prox" instead of fully "in range" can be stale
> and cause us to report incorrect tool information. Serial number, tool
> type, and other information is only valid once the pen comes fully in range
> so we should be careful to not use this information until that point.
>
> In particular, this issue may cause the driver to incorectly report
> BTN_TOOL_RUBBER after switching from the eraser tool back to the pen.
>
> Fixes: a48324de6d ("HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range")
> Cc: <stable@vger.kernel.org> # 4.11+
> Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
> Reviewed-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
> ---
>  drivers/hid/wacom_wac.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> index 747730d32ab6..4c1bc239207e 100644
> --- a/drivers/hid/wacom_wac.c
> +++ b/drivers/hid/wacom_wac.c
> @@ -1236,13 +1236,13 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
>                 /* Add back in missing bits of ID for non-USI pens */
>                 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
>         }
> -       wacom->tool[0]   = wacom_intuos_get_tool_type(wacom_intuos_id_mangle(wacom->id[0]));
>
>         for (i = 0; i < pen_frames; i++) {
>                 unsigned char *frame = &data[i*pen_frame_len + 1];
>                 bool valid = frame[0] & 0x80;
>                 bool prox = frame[0] & 0x40;
>                 bool range = frame[0] & 0x20;
> +               bool invert = frame[0] & 0x10;
>
>                 if (!valid)
>                         continue;
> @@ -1251,9 +1251,24 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
>                         wacom->shared->stylus_in_proximity = false;
>                         wacom_exit_report(wacom);
>                         input_sync(pen_input);
> +
> +                       wacom->tool[0] = 0;
> +                       wacom->id[0] = 0;
> +                       wacom->serial[0] = 0;
>                         return;
>                 }
> +
>                 if (range) {
> +                       if (!wacom->tool[0]) { /* first in range */
> +                               /* Going into range select tool */
> +                               if (invert)
> +                                       wacom->tool[0] = BTN_TOOL_RUBBER;
> +                               else if (wacom->id[0])
> +                                       wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
> +                               else
> +                                       wacom->tool[0] = BTN_TOOL_PEN;
> +                       }
> +
>                         input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
>                         input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
>
> --
> 2.21.0
>

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

* Re: [PATCH 1/2] HID: wacom: Don't set tool type until we're in range
  2019-04-24 22:12 [PATCH 1/2] HID: wacom: Don't set tool type until we're in range Gerecke, Jason
                   ` (2 preceding siblings ...)
  2019-05-07 18:43 ` Jason Gerecke
@ 2019-05-17 14:27 ` Benjamin Tissoires
  3 siblings, 0 replies; 14+ messages in thread
From: Benjamin Tissoires @ 2019-05-17 14:27 UTC (permalink / raw)
  To: Gerecke, Jason
  Cc: open list:HID CORE LAYER, Ping Cheng, Aaron Armstrong Skomra,
	Jason Gerecke, 3.8+,
	Aaron Armstrong Skomra

On Thu, Apr 25, 2019 at 12:13 AM Gerecke, Jason <killertofu@gmail.com> wrote:
>
> From: Jason Gerecke <jason.gerecke@wacom.com>
>
> The serial number and tool type information that is reported by the tablet
> while a pen is merely "in prox" instead of fully "in range" can be stale
> and cause us to report incorrect tool information. Serial number, tool
> type, and other information is only valid once the pen comes fully in range
> so we should be careful to not use this information until that point.
>
> In particular, this issue may cause the driver to incorectly report
> BTN_TOOL_RUBBER after switching from the eraser tool back to the pen.
>
> Fixes: a48324de6d ("HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range")
> Cc: <stable@vger.kernel.org> # 4.11+
> Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
> Reviewed-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
> ---

Series applied to for-5.2/fixes

Sorry for the delay

Cheers,
Benjamin

>  drivers/hid/wacom_wac.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> index 747730d32ab6..4c1bc239207e 100644
> --- a/drivers/hid/wacom_wac.c
> +++ b/drivers/hid/wacom_wac.c
> @@ -1236,13 +1236,13 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
>                 /* Add back in missing bits of ID for non-USI pens */
>                 wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
>         }
> -       wacom->tool[0]   = wacom_intuos_get_tool_type(wacom_intuos_id_mangle(wacom->id[0]));
>
>         for (i = 0; i < pen_frames; i++) {
>                 unsigned char *frame = &data[i*pen_frame_len + 1];
>                 bool valid = frame[0] & 0x80;
>                 bool prox = frame[0] & 0x40;
>                 bool range = frame[0] & 0x20;
> +               bool invert = frame[0] & 0x10;
>
>                 if (!valid)
>                         continue;
> @@ -1251,9 +1251,24 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
>                         wacom->shared->stylus_in_proximity = false;
>                         wacom_exit_report(wacom);
>                         input_sync(pen_input);
> +
> +                       wacom->tool[0] = 0;
> +                       wacom->id[0] = 0;
> +                       wacom->serial[0] = 0;
>                         return;
>                 }
> +
>                 if (range) {
> +                       if (!wacom->tool[0]) { /* first in range */
> +                               /* Going into range select tool */
> +                               if (invert)
> +                                       wacom->tool[0] = BTN_TOOL_RUBBER;
> +                               else if (wacom->id[0])
> +                                       wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
> +                               else
> +                                       wacom->tool[0] = BTN_TOOL_PEN;
> +                       }
> +
>                         input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
>                         input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
>
> --
> 2.21.0
>

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

* Re: [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range
  2019-04-26 16:35       ` Gerecke, Jason
@ 2019-06-11 19:02         ` Jason Gerecke
  2019-06-11 19:22           ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Jason Gerecke @ 2019-06-11 19:02 UTC (permalink / raw)
  To: # v3.17+, Sasha Levin
  Cc: Linux Input, Ping Cheng, Aaron Armstrong Skomra, Jason Gerecke,
	Aaron Armstrong Skomra

I haven't been keeping a close eye on this and just noticed that this
patch set doesn't seem to have been merged into stable. There's also a
second patch series (beginning with "[PATCH 1/3] HID: wacom: Send
BTN_TOUCH in response to INTUOSP2_BT eraser contact") that hasn't seen
any stable activity either.

Any idea what's up?

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one  /
(That is to say, eight) to the two,     /
But you can’t take seven from three,    /
So you look at the sixty-fours....
On Fri, Apr 26, 2019 at 9:35 AM Gerecke, Jason <killertofu@gmail.com> wrote:
>
> From: Jason Gerecke <jason.gerecke@wacom.com>
>
> If the tool spends some time in prox before entering range, a series of
> events (e.g. ABS_DISTANCE, MSC_SERIAL) can be sent before we or userspace
> have any clue about the pen whose data is being reported. We need to hold
> off on reporting anything until the pen has entered range. Since we still
> want to report events that occur "in prox" after the pen has *left* range
> we use 'wacom-tool[0]' as the indicator that the pen did at one point
> enter range and provide us/userspace with tool type and serial number
> information.
>
> Fixes: a48324de6d ("HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range")
> Cc: <stable@vger.kernel.org> # 4.11+
> Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
> Reviewed-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
> ---
> Version of patch specifically targeted to stable v4.14.113
>
>  drivers/hid/wacom_wac.c | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> index 03b04bc742dd..e4aeffa56018 100644
> --- a/drivers/hid/wacom_wac.c
> +++ b/drivers/hid/wacom_wac.c
> @@ -1271,17 +1271,20 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
>                         input_report_abs(pen_input, ABS_Z, rotation);
>                         input_report_abs(pen_input, ABS_WHEEL, get_unaligned_le16(&frame[11]));
>                 }
> -               input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
> -               input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max);
>
> -               input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01);
> -               input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
> -               input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
> +               if (wacom->tool[0]) {
> +                       input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
> +                       input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max);
>
> -               input_report_key(pen_input, wacom->tool[0], prox);
> -               input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
> -               input_report_abs(pen_input, ABS_MISC,
> -                                wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
> +                       input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01);
> +                       input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
> +                       input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
> +
> +                       input_report_key(pen_input, wacom->tool[0], prox);
> +                       input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
> +                       input_report_abs(pen_input, ABS_MISC,
> +                                        wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
> +               }
>
>                 wacom->shared->stylus_in_proximity = prox;
>
> --
> 2.21.0
>

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

* Re: [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range
  2019-06-11 19:02         ` Jason Gerecke
@ 2019-06-11 19:22           ` Greg KH
  2019-06-11 20:45             ` Jason Gerecke
  0 siblings, 1 reply; 14+ messages in thread
From: Greg KH @ 2019-06-11 19:22 UTC (permalink / raw)
  To: Jason Gerecke
  Cc: # v3.17+,
	Sasha Levin, Linux Input, Ping Cheng, Aaron Armstrong Skomra,
	Jason Gerecke, Aaron Armstrong Skomra

On Tue, Jun 11, 2019 at 12:02:47PM -0700, Jason Gerecke wrote:
> I haven't been keeping a close eye on this and just noticed that this
> patch set doesn't seem to have been merged into stable. There's also a
> second patch series (beginning with "[PATCH 1/3] HID: wacom: Send
> BTN_TOUCH in response to INTUOSP2_BT eraser contact") that hasn't seen
> any stable activity either.
> 
> Any idea what's up?

I don't see these in my queue at all.

What is the git commit id of these patches in Linus's tree?

thanks,

greg k-h

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

* Re: [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range
  2019-06-11 19:22           ` Greg KH
@ 2019-06-11 20:45             ` Jason Gerecke
  2019-06-12  7:10               ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Jason Gerecke @ 2019-06-11 20:45 UTC (permalink / raw)
  To: Greg KH
  Cc: # v3.17+,
	Sasha Levin, Linux Input, Ping Cheng, Aaron Armstrong Skomra,
	Jason Gerecke, Aaron Armstrong Skomra

On Tue, Jun 11, 2019 at 12:22 PM Greg KH <greg@kroah.com> wrote:
>
> On Tue, Jun 11, 2019 at 12:02:47PM -0700, Jason Gerecke wrote:
> > I haven't been keeping a close eye on this and just noticed that this
> > patch set doesn't seem to have been merged into stable. There's also a
> > second patch series (beginning with "[PATCH 1/3] HID: wacom: Send
> > BTN_TOUCH in response to INTUOSP2_BT eraser contact") that hasn't seen
> > any stable activity either.
> >
> > Any idea what's up?
>
> I don't see these in my queue at all.
>
> What is the git commit id of these patches in Linus's tree?
>
> thanks,
>
> greg k-h

Ah, looks like the HID tree's "for-5.2/fixes" branch hasn't been
pulled yet. That could explain things.

69dbdfffef20c715df9f381b2cee4e9e0a4efd93 HID: wacom: Sync INTUOSP2_BT
touch state after each frame if necessary
6441fc781c344df61402be1fde582c4491fa35fa HID: wacom: Correct button
numbering 2nd-gen Intuos Pro over Bluetooth
fe7f8d73d1af19b678171170e4e5384deb57833d HID: wacom: Send BTN_TOUCH in
response to INTUOSP2_BT eraser contact
e92a7be7fe5b2510fa60965eaf25f9e3dc08b8cc HID: wacom: Don't report
anything prior to the tool entering range
2cc08800a6b9fcda7c7afbcf2da1a6e8808da725 HID: wacom: Don't set tool
type until we're in range

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one  /
(That is to say, eight) to the two,     /
But you can’t take seven from three,    /
So you look at the sixty-fours....

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

* Re: [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range
  2019-06-11 20:45             ` Jason Gerecke
@ 2019-06-12  7:10               ` Greg KH
  2019-06-15 15:32                 ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Greg KH @ 2019-06-12  7:10 UTC (permalink / raw)
  To: Jason Gerecke
  Cc: # v3.17+,
	Sasha Levin, Linux Input, Ping Cheng, Aaron Armstrong Skomra,
	Jason Gerecke, Aaron Armstrong Skomra

On Tue, Jun 11, 2019 at 01:45:36PM -0700, Jason Gerecke wrote:
> On Tue, Jun 11, 2019 at 12:22 PM Greg KH <greg@kroah.com> wrote:
> >
> > On Tue, Jun 11, 2019 at 12:02:47PM -0700, Jason Gerecke wrote:
> > > I haven't been keeping a close eye on this and just noticed that this
> > > patch set doesn't seem to have been merged into stable. There's also a
> > > second patch series (beginning with "[PATCH 1/3] HID: wacom: Send
> > > BTN_TOUCH in response to INTUOSP2_BT eraser contact") that hasn't seen
> > > any stable activity either.
> > >
> > > Any idea what's up?
> >
> > I don't see these in my queue at all.
> >
> > What is the git commit id of these patches in Linus's tree?
> >
> > thanks,
> >
> > greg k-h
> 
> Ah, looks like the HID tree's "for-5.2/fixes" branch hasn't been
> pulled yet. That could explain things.
> 
> 69dbdfffef20c715df9f381b2cee4e9e0a4efd93 HID: wacom: Sync INTUOSP2_BT
> touch state after each frame if necessary
> 6441fc781c344df61402be1fde582c4491fa35fa HID: wacom: Correct button
> numbering 2nd-gen Intuos Pro over Bluetooth
> fe7f8d73d1af19b678171170e4e5384deb57833d HID: wacom: Send BTN_TOUCH in
> response to INTUOSP2_BT eraser contact
> e92a7be7fe5b2510fa60965eaf25f9e3dc08b8cc HID: wacom: Don't report
> anything prior to the tool entering range
> 2cc08800a6b9fcda7c7afbcf2da1a6e8808da725 HID: wacom: Don't set tool
> type until we're in range

There is nothing I can do until the patches are in Linus's tree, sorry.

greg k-h

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

* Re: [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range
  2019-06-12  7:10               ` Greg KH
@ 2019-06-15 15:32                 ` Greg KH
  0 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2019-06-15 15:32 UTC (permalink / raw)
  To: Jason Gerecke
  Cc: # v3.17+,
	Sasha Levin, Linux Input, Ping Cheng, Aaron Armstrong Skomra,
	Jason Gerecke, Aaron Armstrong Skomra

On Wed, Jun 12, 2019 at 09:10:42AM +0200, Greg KH wrote:
> On Tue, Jun 11, 2019 at 01:45:36PM -0700, Jason Gerecke wrote:
> > On Tue, Jun 11, 2019 at 12:22 PM Greg KH <greg@kroah.com> wrote:
> > >
> > > On Tue, Jun 11, 2019 at 12:02:47PM -0700, Jason Gerecke wrote:
> > > > I haven't been keeping a close eye on this and just noticed that this
> > > > patch set doesn't seem to have been merged into stable. There's also a
> > > > second patch series (beginning with "[PATCH 1/3] HID: wacom: Send
> > > > BTN_TOUCH in response to INTUOSP2_BT eraser contact") that hasn't seen
> > > > any stable activity either.
> > > >
> > > > Any idea what's up?
> > >
> > > I don't see these in my queue at all.
> > >
> > > What is the git commit id of these patches in Linus's tree?
> > >
> > > thanks,
> > >
> > > greg k-h
> > 
> > Ah, looks like the HID tree's "for-5.2/fixes" branch hasn't been
> > pulled yet. That could explain things.
> > 
> > 69dbdfffef20c715df9f381b2cee4e9e0a4efd93 HID: wacom: Sync INTUOSP2_BT
> > touch state after each frame if necessary
> > 6441fc781c344df61402be1fde582c4491fa35fa HID: wacom: Correct button
> > numbering 2nd-gen Intuos Pro over Bluetooth
> > fe7f8d73d1af19b678171170e4e5384deb57833d HID: wacom: Send BTN_TOUCH in
> > response to INTUOSP2_BT eraser contact
> > e92a7be7fe5b2510fa60965eaf25f9e3dc08b8cc HID: wacom: Don't report
> > anything prior to the tool entering range
> > 2cc08800a6b9fcda7c7afbcf2da1a6e8808da725 HID: wacom: Don't set tool
> > type until we're in range
> 
> There is nothing I can do until the patches are in Linus's tree, sorry.

Now applied for the ones that I could, you should have some "FAILED"
emails for the rejects that did not apply to 4.14.y

thanks,

greg k-h

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

end of thread, other threads:[~2019-06-15 15:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 22:12 [PATCH 1/2] HID: wacom: Don't set tool type until we're in range Gerecke, Jason
2019-04-24 22:12 ` [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range Gerecke, Jason
     [not found]   ` <20190425121506.7EBEC218B0@mail.kernel.org>
2019-04-25 17:47     ` Jason Gerecke
2019-04-26 16:35       ` Gerecke, Jason
2019-06-11 19:02         ` Jason Gerecke
2019-06-11 19:22           ` Greg KH
2019-06-11 20:45             ` Jason Gerecke
2019-06-12  7:10               ` Greg KH
2019-06-15 15:32                 ` Greg KH
     [not found] ` <20190425121505.3AD33218AD@mail.kernel.org>
2019-04-25 17:47   ` [PATCH 1/2] HID: wacom: Don't set tool type until we're in range Jason Gerecke
2019-04-26  3:33     ` Sasha Levin
2019-04-26 16:34       ` Gerecke, Jason
2019-05-07 18:43 ` Jason Gerecke
2019-05-17 14:27 ` Benjamin Tissoires

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).