Commit e6bd7121 authored by Jason Gerecke's avatar Jason Gerecke Committed by Greg Kroah-Hartman

HID: wacom: Fix poor prox handling in 'wacom_pl_irq'

commit 282e4637 upstream.

Commit 025bcc15 performed cleanup work on the 'wacom_pl_irq' function, making
it follow the standards used in the rest of the codebase. The change
unintiontionally allowed the function to send input events from reports
that are not marked as being in prox. This can cause problems as the
report values for X, Y, etc. are not guaranteed to be correct. In
particular, occasionally the tablet will send a report with these values
set to zero. If such a report is received it can caus an unexpected jump
in the XY position.

This patch surrounds more of the processing code with a proximity check,
preventing these zeroed reports from overwriting the current state. To
be safe, only the tool type and ABS_MISC events should be reported when
the pen is marked as being out of prox.

Fixes: 025bcc15 ("HID: wacom: Simplify 'wacom_pl_irq'")
Signed-off-by: default avatarJason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: default avatarPing Cheng <pingc@wacom.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f24bc920
...@@ -164,6 +164,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom) ...@@ -164,6 +164,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom)
wacom->id[0] = STYLUS_DEVICE_ID; wacom->id[0] = STYLUS_DEVICE_ID;
} }
if (prox) {
pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
if (features->pressure_max > 255) if (features->pressure_max > 255)
pressure = (pressure << 1) | ((data[4] >> 6) & 1); pressure = (pressure << 1) | ((data[4] >> 6) & 1);
...@@ -177,6 +178,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom) ...@@ -177,6 +178,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom)
input_report_key(input, BTN_STYLUS, data[4] & 0x10); input_report_key(input, BTN_STYLUS, data[4] & 0x10);
/* Only allow the stylus2 button to be reported for the pen tool. */ /* Only allow the stylus2 button to be reported for the pen tool. */
input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20)); input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
}
if (!prox) if (!prox)
wacom->id[0] = 0; wacom->id[0] = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment