Skip to content

Commit ccb51c2

Browse files
jigpuJiri Kosina
authored andcommitted
HID: wacom: Avoid sending empty sync events
Empty sync events clutter up logs and are a waste of CPU cycles. We can avoid sending mt_sync events if touch is disabled or a specific slot is unused. We can avoid sending full sync events if no events were generated. Signed-off-by: Ping Cheng <[email protected]> Signed-off-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 5bed012 commit ccb51c2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/hid/wacom_wac.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2551,8 +2551,17 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
25512551
int slot;
25522552

25532553
slot = input_mt_get_slot_by_key(input, hid_data->id);
2554-
if (slot < 0)
2554+
if (slot < 0) {
25552555
return;
2556+
} else {
2557+
struct input_mt_slot *ps = &input->mt->slots[slot];
2558+
int mt_id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
2559+
2560+
if (!prox && mt_id < 0) {
2561+
// No data to send for this slot; short-circuit
2562+
return;
2563+
}
2564+
}
25562565

25572566
input_mt_slot(input, slot);
25582567
input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
@@ -2696,6 +2705,10 @@ static void wacom_wac_finger_report(struct hid_device *hdev,
26962705
struct input_dev *input = wacom_wac->touch_input;
26972706
unsigned touch_max = wacom_wac->features.touch_max;
26982707

2708+
/* if there was nothing to process, don't send an empty sync */
2709+
if (wacom_wac->hid_data.num_expected == 0)
2710+
return;
2711+
26992712
/* If more packets of data are expected, give us a chance to
27002713
* process them rather than immediately syncing a partial
27012714
* update.

0 commit comments

Comments
 (0)