@@ -73,6 +73,7 @@ MODULE_LICENSE("GPL");
73
73
#define MT_QUIRK_FORCE_MULTI_INPUT BIT(20)
74
74
#define MT_QUIRK_DISABLE_WAKEUP BIT(21)
75
75
#define MT_QUIRK_ORIENTATION_INVERT BIT(22)
76
+ #define MT_QUIRK_APPLE_TOUCHBAR BIT(23)
76
77
77
78
#define MT_INPUTMODE_TOUCHSCREEN 0x02
78
79
#define MT_INPUTMODE_TOUCHPAD 0x03
@@ -220,6 +221,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
220
221
#define MT_CLS_GOOGLE 0x0111
221
222
#define MT_CLS_RAZER_BLADE_STEALTH 0x0112
222
223
#define MT_CLS_SMART_TECH 0x0113
224
+ #define MT_CLS_APPLE_TOUCHBAR 0x0114
223
225
#define MT_CLS_SIS 0x0457
224
226
225
227
#define MT_DEFAULT_MAXCONTACT 10
@@ -405,6 +407,12 @@ static const struct mt_class mt_classes[] = {
405
407
MT_QUIRK_CONTACT_CNT_ACCURATE |
406
408
MT_QUIRK_SEPARATE_APP_REPORT ,
407
409
},
410
+ { .name = MT_CLS_APPLE_TOUCHBAR ,
411
+ .quirks = MT_QUIRK_HOVERING |
412
+ MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE |
413
+ MT_QUIRK_APPLE_TOUCHBAR ,
414
+ .maxcontacts = 11 ,
415
+ },
408
416
{ .name = MT_CLS_SIS ,
409
417
.quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
410
418
MT_QUIRK_ALWAYS_VALID |
@@ -625,6 +633,7 @@ static struct mt_application *mt_find_application(struct mt_device *td,
625
633
static struct mt_report_data * mt_allocate_report_data (struct mt_device * td ,
626
634
struct hid_report * report )
627
635
{
636
+ struct mt_class * cls = & td -> mtclass ;
628
637
struct mt_report_data * rdata ;
629
638
struct hid_field * field ;
630
639
int r , n ;
@@ -649,7 +658,11 @@ static struct mt_report_data *mt_allocate_report_data(struct mt_device *td,
649
658
650
659
if (field -> logical == HID_DG_FINGER || td -> hdev -> group != HID_GROUP_MULTITOUCH_WIN_8 ) {
651
660
for (n = 0 ; n < field -> report_count ; n ++ ) {
652
- if (field -> usage [n ].hid == HID_DG_CONTACTID ) {
661
+ unsigned int hid = field -> usage [n ].hid ;
662
+
663
+ if (hid == HID_DG_CONTACTID ||
664
+ (cls -> quirks & MT_QUIRK_APPLE_TOUCHBAR &&
665
+ hid == HID_DG_TRANSDUCER_INDEX )) {
653
666
rdata -> is_mt_collection = true;
654
667
break ;
655
668
}
@@ -821,12 +834,31 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
821
834
822
835
MT_STORE_FIELD (confidence_state );
823
836
return 1 ;
837
+ case HID_DG_TOUCH :
838
+ /*
839
+ * Legacy devices use TIPSWITCH and not TOUCH.
840
+ * One special case here is of the Apple Touch Bars.
841
+ * In these devices, the tip state is contained in
842
+ * fields with the HID_DG_TOUCH usage.
843
+ * Let's just ignore this field for other devices.
844
+ */
845
+ if (!(cls -> quirks & MT_QUIRK_APPLE_TOUCHBAR ))
846
+ return -1 ;
847
+ fallthrough ;
824
848
case HID_DG_TIPSWITCH :
825
849
if (field -> application != HID_GD_SYSTEM_MULTIAXIS )
826
850
input_set_capability (hi -> input ,
827
851
EV_KEY , BTN_TOUCH );
828
852
MT_STORE_FIELD (tip_state );
829
853
return 1 ;
854
+ case HID_DG_TRANSDUCER_INDEX :
855
+ /*
856
+ * Contact ID in case of Apple Touch Bars is contained
857
+ * in fields with HID_DG_TRANSDUCER_INDEX usage.
858
+ */
859
+ if (!(cls -> quirks & MT_QUIRK_APPLE_TOUCHBAR ))
860
+ return 0 ;
861
+ fallthrough ;
830
862
case HID_DG_CONTACTID :
831
863
MT_STORE_FIELD (contactid );
832
864
app -> touches_by_report ++ ;
@@ -883,10 +915,6 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
883
915
case HID_DG_CONTACTMAX :
884
916
/* contact max are global to the report */
885
917
return -1 ;
886
- case HID_DG_TOUCH :
887
- /* Legacy devices use TIPSWITCH and not TOUCH.
888
- * Let's just ignore this field. */
889
- return -1 ;
890
918
}
891
919
/* let hid-input decide for the others */
892
920
return 0 ;
@@ -1314,13 +1342,27 @@ static int mt_touch_input_configured(struct hid_device *hdev,
1314
1342
struct input_dev * input = hi -> input ;
1315
1343
int ret ;
1316
1344
1345
+ /*
1346
+ * HID_DG_CONTACTMAX field is not present on Apple Touch Bars,
1347
+ * but the maximum contact count is greater than the default.
1348
+ */
1349
+ if (cls -> quirks & MT_QUIRK_APPLE_TOUCHBAR && cls -> maxcontacts )
1350
+ td -> maxcontacts = cls -> maxcontacts ;
1351
+
1317
1352
if (!td -> maxcontacts )
1318
1353
td -> maxcontacts = MT_DEFAULT_MAXCONTACT ;
1319
1354
1320
1355
mt_post_parse (td , app );
1321
1356
if (td -> serial_maybe )
1322
1357
mt_post_parse_default_settings (td , app );
1323
1358
1359
+ /*
1360
+ * The application for Apple Touch Bars is HID_DG_TOUCHPAD,
1361
+ * but these devices are direct.
1362
+ */
1363
+ if (cls -> quirks & MT_QUIRK_APPLE_TOUCHBAR )
1364
+ app -> mt_flags |= INPUT_MT_DIRECT ;
1365
+
1324
1366
if (cls -> is_indirect )
1325
1367
app -> mt_flags |= INPUT_MT_POINTER ;
1326
1368
@@ -1823,6 +1865,11 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
1823
1865
if (ret != 0 )
1824
1866
return ret ;
1825
1867
1868
+ if (mtclass -> name == MT_CLS_APPLE_TOUCHBAR &&
1869
+ !hid_find_field (hdev , HID_INPUT_REPORT ,
1870
+ HID_DG_TOUCHPAD , HID_DG_TRANSDUCER_INDEX ))
1871
+ return - ENODEV ;
1872
+
1826
1873
if (mtclass -> quirks & MT_QUIRK_FIX_CONST_CONTACT_ID )
1827
1874
mt_fix_const_fields (hdev , HID_DG_CONTACTID );
1828
1875
@@ -2320,6 +2367,11 @@ static const struct hid_device_id mt_devices[] = {
2320
2367
MT_USB_DEVICE (USB_VENDOR_ID_XIROKU ,
2321
2368
USB_DEVICE_ID_XIROKU_CSR2 ) },
2322
2369
2370
+ /* Apple Touch Bar */
2371
+ { .driver_data = MT_CLS_APPLE_TOUCHBAR ,
2372
+ HID_USB_DEVICE (USB_VENDOR_ID_APPLE ,
2373
+ USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY ) },
2374
+
2323
2375
/* Google MT devices */
2324
2376
{ .driver_data = MT_CLS_GOOGLE ,
2325
2377
HID_DEVICE (HID_BUS_ANY , HID_GROUP_ANY , USB_VENDOR_ID_GOOGLE ,
0 commit comments