@@ -1318,6 +1318,11 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1318
1318
1319
1319
struct input_dev * pen_input = wacom -> pen_input ;
1320
1320
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
1321
1326
int i ;
1322
1327
1323
1328
if (wacom -> features .type == INTUOSP2_BT ||
@@ -1338,12 +1343,34 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1338
1343
wacom -> id [0 ] |= (wacom -> serial [0 ] >> 32 ) & 0xFFFFF ;
1339
1344
}
1340
1345
1346
+ /* number of valid frames */
1341
1347
for (i = 0 ; i < pen_frames ; i ++ ) {
1342
1348
unsigned char * frame = & data [i * pen_frame_len + 1 ];
1343
1349
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 ;
1344
1367
bool prox = frame [0 ] & 0x40 ;
1345
1368
bool range = frame [0 ] & 0x20 ;
1346
1369
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
1347
1374
1348
1375
if (!valid )
1349
1376
continue ;
@@ -1356,6 +1383,7 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1356
1383
wacom -> tool [0 ] = 0 ;
1357
1384
wacom -> id [0 ] = 0 ;
1358
1385
wacom -> serial [0 ] = 0 ;
1386
+ wacom -> hid_data .time_delayed = 0 ;
1359
1387
return ;
1360
1388
}
1361
1389
@@ -1392,6 +1420,7 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1392
1420
get_unaligned_le16 (& frame [11 ]));
1393
1421
}
1394
1422
}
1423
+
1395
1424
if (wacom -> tool [0 ]) {
1396
1425
input_report_abs (pen_input , ABS_PRESSURE , get_unaligned_le16 (& frame [5 ]));
1397
1426
if (wacom -> features .type == INTUOSP2_BT ||
@@ -1415,6 +1444,10 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
1415
1444
1416
1445
wacom -> shared -> stylus_in_proximity = prox ;
1417
1446
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
1418
1451
input_sync (pen_input );
1419
1452
}
1420
1453
}
@@ -1905,6 +1938,7 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
1905
1938
int fmax = field -> logical_maximum ;
1906
1939
unsigned int equivalent_usage = wacom_equivalent_usage (usage -> hid );
1907
1940
int resolution_code = code ;
1941
+ int resolution = hidinput_calc_abs_res (field , resolution_code );
1908
1942
1909
1943
#if LINUX_VERSION_CODE >= KERNEL_VERSION (4 ,10 ,0 )
1910
1944
if (equivalent_usage == HID_DG_TWIST ) {
@@ -1930,8 +1964,16 @@ static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
1930
1964
switch (type ) {
1931
1965
case EV_ABS :
1932
1966
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 ;
1935
1977
break ;
1936
1978
case EV_KEY :
1937
1979
case EV_MSC :
0 commit comments