Skip to content

Commit a3686d0

Browse files
committed
Merge branch 'for-6.4' into 'master'
2 parents 08790be + 235fcdb commit a3686d0

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

4.5/wacom_wac.c

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,11 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
13181318

13191319
struct input_dev *pen_input = wacom->pen_input;
13201320
unsigned char *data = wacom->data;
1321+
int number_of_valid_frames = 0;
1322+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0)
1323+
int time_interval = 15000000;
1324+
ktime_t time_packet_received = ktime_get();
1325+
#endif
13211326
int i;
13221327

13231328
if (wacom->features.type == INTUOSP2_BT ||
@@ -1338,12 +1343,34 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
13381343
wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
13391344
}
13401345

1346+
/* number of valid frames */
13411347
for (i = 0; i < pen_frames; i++) {
13421348
unsigned char *frame = &data[i*pen_frame_len + 1];
13431349
bool valid = frame[0] & 0x80;
1350+
1351+
if (valid)
1352+
number_of_valid_frames++;
1353+
}
1354+
1355+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0)
1356+
if (number_of_valid_frames) {
1357+
if (wacom->hid_data.time_delayed)
1358+
time_interval = ktime_get() - wacom->hid_data.time_delayed;
1359+
time_interval /= number_of_valid_frames;
1360+
wacom->hid_data.time_delayed = time_packet_received;
1361+
}
1362+
#endif
1363+
1364+
for (i = 0; i < number_of_valid_frames; i++) {
1365+
unsigned char *frame = &data[i*pen_frame_len + 1];
1366+
bool valid = frame[0] & 0x80;
13441367
bool prox = frame[0] & 0x40;
13451368
bool range = frame[0] & 0x20;
13461369
bool invert = frame[0] & 0x10;
1370+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0)
1371+
int frames_number_reversed = number_of_valid_frames - i - 1;
1372+
int event_timestamp = time_packet_received - frames_number_reversed * time_interval;
1373+
#endif
13471374

13481375
if (!valid)
13491376
continue;
@@ -1356,6 +1383,7 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
13561383
wacom->tool[0] = 0;
13571384
wacom->id[0] = 0;
13581385
wacom->serial[0] = 0;
1386+
wacom->hid_data.time_delayed = 0;
13591387
return;
13601388
}
13611389

@@ -1392,6 +1420,7 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
13921420
get_unaligned_le16(&frame[11]));
13931421
}
13941422
}
1423+
13951424
if (wacom->tool[0]) {
13961425
input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
13971426
if (wacom->features.type == INTUOSP2_BT ||
@@ -1415,6 +1444,10 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
14151444

14161445
wacom->shared->stylus_in_proximity = prox;
14171446

1447+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0)
1448+
/* add timestamp to unpack the frames */
1449+
input_set_timestamp(pen_input, event_timestamp);
1450+
#endif
14181451
input_sync(pen_input);
14191452
}
14201453
}
@@ -1905,6 +1938,7 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
19051938
int fmax = field->logical_maximum;
19061939
unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
19071940
int resolution_code = code;
1941+
int resolution = hidinput_calc_abs_res(field, resolution_code);
19081942

19091943
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
19101944
if (equivalent_usage == HID_DG_TWIST) {
@@ -1930,8 +1964,16 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
19301964
switch (type) {
19311965
case EV_ABS:
19321966
input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
1933-
input_abs_set_res(input, code,
1934-
hidinput_calc_abs_res(field, resolution_code));
1967+
1968+
/* older tablet may miss physical usage */
1969+
if ((code == ABS_X || code == ABS_Y) && !resolution) {
1970+
resolution = WACOM_INTUOS_RES;
1971+
hid_warn(input,
1972+
"Wacom usage (%d) missing resolution \n",
1973+
code);
1974+
}
1975+
input_abs_set_res(input, code, resolution);
1976+
break;
19351977
break;
19361978
case EV_KEY:
19371979
case EV_MSC:

4.5/wacom_wac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ struct hid_data {
348348
int ps_connected;
349349
bool pad_input_event_flag;
350350
unsigned short sequence_number;
351+
int time_delayed;
351352
};
352353

353354
struct wacom_remote_data {

0 commit comments

Comments
 (0)