Skip to content

Commit

Permalink
HID: wacom: Support sequence numbers smaller than 16-bit
Browse files Browse the repository at this point in the history
The current dropped packet reporting assumes that all sequence numbers
are 16 bits in length. This results in misleading "Dropped" messages if
the hardware uses fewer bits. For example, if a tablet uses only 8 bits
to store its sequence number, once it rolls over from 255 -> 0, the
driver will still be expecting a packet "256". This patch adjusts the
logic to reset the next expected packet to logical_minimum whenever
it overflows beyond logical_maximum.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Joshua Dickens <joshua.dickens@wacom.com>
Fixes: 6d09085 ("HID: wacom: Adding Support for new usages")
Signed-off-by: Jiri Kosina <jkosina@suse.com>
  • Loading branch information
Jason Gerecke authored and Jiri Kosina committed Sep 10, 2024
1 parent 19591e1 commit 359673e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/hid/wacom_wac.c
Original file line number Diff line number Diff line change
Expand Up @@ -2510,9 +2510,14 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
wacom_wac->hid_data.barrelswitch3 = value;
return;
case WACOM_HID_WD_SEQUENCENUMBER:
if (wacom_wac->hid_data.sequence_number != value)
hid_warn(hdev, "Dropped %hu packets", (unsigned short)(value - wacom_wac->hid_data.sequence_number));
if (wacom_wac->hid_data.sequence_number != value) {
int sequence_size = field->logical_maximum - field->logical_minimum + 1;
int drop_count = (value - wacom_wac->hid_data.sequence_number) % sequence_size;
hid_warn(hdev, "Dropped %d packets", drop_count);
}
wacom_wac->hid_data.sequence_number = value + 1;
if (wacom_wac->hid_data.sequence_number > field->logical_maximum)
wacom_wac->hid_data.sequence_number = field->logical_minimum;
return;
}

Expand Down

0 comments on commit 359673e

Please sign in to comment.