Skip to content

Commit

Permalink
HID: wacom: Do not warn about dropped packets for first packet
Browse files Browse the repository at this point in the history
The driver currently assumes that the first sequence number it will see
is going to be 0. This is not a realiable assumption and can break if,
for example, the tablet has already been running for some time prior to
the kernel driver connecting to the device. This commit initializes the
expected sequence number to -1 and will only print the "Dropped" warning
the it has been updated to a non-negative value.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Joshua Dickens <joshua.dickens@wacom.com>
Fixes: 6d09085b38e5 ("HID: wacom: Adding Support for new usages")
Signed-off-by: Jiri Kosina <jkosina@suse.com>
[jason.gerecke@wacom.com: Imported into input-wacom (84aecf2d251a)]
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
  • Loading branch information
jigpu committed Sep 11, 2024
1 parent a4a2b27 commit 81a3fbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion 4.18/wacom_wac.c
Original file line number Diff line number Diff line change
Expand Up @@ -2409,6 +2409,9 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS3, 0);
features->quirks &= ~WACOM_QUIRK_PEN_BUTTON3;
break;
case WACOM_HID_WD_SEQUENCENUMBER:
wacom_wac->hid_data.sequence_number = -1;
break;
}
}

Expand Down Expand Up @@ -2533,7 +2536,8 @@ 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) {
if (wacom_wac->hid_data.sequence_number != value &&
wacom_wac->hid_data.sequence_number >= 0) {
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);
Expand Down
2 changes: 1 addition & 1 deletion 4.18/wacom_wac.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ struct hid_data {
int bat_connected;
int ps_connected;
bool pad_input_event_flag;
unsigned short sequence_number;
int sequence_number;
#ifdef WACOM_INPUT_SET_TIMESTAMP
ktime_t time_delayed;
#endif
Expand Down

0 comments on commit 81a3fbd

Please sign in to comment.