Skip to content

Commit

Permalink
HID: wacom: generic: support the 'report valid' usage for touch
Browse files Browse the repository at this point in the history
Finger data is separated into chunks in our Bluetooth report,
where each report contains the same number of chunks. Those chunks
are not aligned in any particular way to a set of finger touches.
That is, the first half of a group of simultaneous touches may
be in one chunk at the end of a report and the second half could
be at the beginning of the next report.

Also some chunks contain no data and potentially some chunks could
contain leftover (bad) data.

Introduce and process the WACOM_HID_WT_REPORT_VALID usage that the
device uses to let us know if we should process a chunk of data.

Signed-off-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Aaron Armstrong Skomra authored and Jiri Kosina committed Jun 13, 2019
1 parent 184eccd commit f4e11d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/hid/wacom_wac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,9 @@ int wacom_equivalent_usage(int usage)
int subpage = (usage & 0xFF00) << 8;
int subusage = (usage & 0xFF);

if (usage == WACOM_HID_WT_REPORT_VALID)
return usage;

if (subpage == HID_UP_UNDEFINED)
subpage = WACOM_HID_SP_DIGITIZER;

Expand Down Expand Up @@ -2494,6 +2497,9 @@ static void wacom_wac_finger_event(struct hid_device *hdev,
unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
struct wacom_features *features = &wacom->wacom_wac.features;

if (wacom_wac->is_invalid_bt_frame)
return;

switch (equivalent_usage) {
case HID_GD_X:
wacom_wac->hid_data.x = value;
Expand All @@ -2513,12 +2519,14 @@ static void wacom_wac_finger_event(struct hid_device *hdev,
case HID_DG_TIPSWITCH:
wacom_wac->hid_data.tipswitch = value;
break;
case WACOM_HID_WT_REPORT_VALID:
wacom_wac->is_invalid_bt_frame = !value;
return;
case HID_DG_CONTACTMAX:
features->touch_max = value;
return;
}


if (usage->usage_index + 1 == field->report_count) {
if (equivalent_usage == wacom_wac->hid_data.last_slot_field)
wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
Expand All @@ -2533,6 +2541,8 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev,
struct hid_data* hid_data = &wacom_wac->hid_data;
int i;

wacom_wac->is_invalid_bt_frame = false;

for (i = 0; i < report->maxfield; i++) {
struct hid_field *field = report->field[i];
int j;
Expand Down
1 change: 1 addition & 0 deletions drivers/hid/wacom_wac.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
#define WACOM_HID_WT_SERIALNUMBER (WACOM_HID_UP_WACOMTOUCH | 0x5b)
#define WACOM_HID_WT_X (WACOM_HID_UP_WACOMTOUCH | 0x130)
#define WACOM_HID_WT_Y (WACOM_HID_UP_WACOMTOUCH | 0x131)
#define WACOM_HID_WT_REPORT_VALID (WACOM_HID_UP_WACOMTOUCH | 0x1d0)

#define WACOM_BATTERY_USAGE(f) (((f)->hid == HID_DG_BATTERYSTRENGTH) || \
((f)->hid == WACOM_HID_WD_BATTERY_CHARGING) || \
Expand Down

0 comments on commit f4e11d5

Please sign in to comment.