@@ -2563,25 +2563,9 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev,
2563
2563
case HID_DG_TIPSWITCH :
2564
2564
hid_data -> last_slot_field = equivalent_usage ;
2565
2565
break ;
2566
- case HID_DG_CONTACTCOUNT :
2567
- hid_data -> cc_report = report -> id ;
2568
- hid_data -> cc_index = i ;
2569
- hid_data -> cc_value_index = j ;
2570
- break ;
2571
2566
}
2572
2567
}
2573
2568
}
2574
-
2575
- if (hid_data -> cc_report != 0 &&
2576
- hid_data -> cc_index >= 0 ) {
2577
- struct hid_field * field = report -> field [hid_data -> cc_index ];
2578
- int value = field -> value [hid_data -> cc_value_index ];
2579
- if (value )
2580
- hid_data -> num_expected = value ;
2581
- }
2582
- else {
2583
- hid_data -> num_expected = wacom_wac -> features .touch_max ;
2584
- }
2585
2569
}
2586
2570
2587
2571
static void wacom_wac_finger_report (struct hid_device * hdev ,
@@ -2591,6 +2575,7 @@ static void wacom_wac_finger_report(struct hid_device *hdev,
2591
2575
struct wacom_wac * wacom_wac = & wacom -> wacom_wac ;
2592
2576
struct input_dev * input = wacom_wac -> touch_input ;
2593
2577
unsigned touch_max = wacom_wac -> features .touch_max ;
2578
+ struct hid_data * hid_data = & wacom_wac -> hid_data ;
2594
2579
2595
2580
/* If more packets of data are expected, give us a chance to
2596
2581
* process them rather than immediately syncing a partial
@@ -2604,6 +2589,7 @@ static void wacom_wac_finger_report(struct hid_device *hdev,
2604
2589
2605
2590
input_sync (input );
2606
2591
wacom_wac -> hid_data .num_received = 0 ;
2592
+ hid_data -> num_expected = 0 ;
2607
2593
2608
2594
/* keep touch state for pen event */
2609
2595
wacom_wac -> shared -> touch_down = wacom_wac_finger_count_touches (wacom_wac );
@@ -2678,12 +2664,73 @@ static void wacom_report_events(struct hid_device *hdev,
2678
2664
}
2679
2665
}
2680
2666
2667
+ static void wacom_set_num_expected (struct hid_device * hdev ,
2668
+ struct hid_report * report ,
2669
+ int collection_index ,
2670
+ struct hid_field * field ,
2671
+ int field_index )
2672
+ {
2673
+ struct wacom * wacom = hid_get_drvdata (hdev );
2674
+ struct wacom_wac * wacom_wac = & wacom -> wacom_wac ;
2675
+ struct hid_data * hid_data = & wacom_wac -> hid_data ;
2676
+ unsigned int original_collection_level =
2677
+ hdev -> collection [collection_index ].level ;
2678
+ bool end_collection = false;
2679
+ int i ;
2680
+
2681
+ if (hid_data -> num_expected )
2682
+ return ;
2683
+
2684
+ // find the contact count value for this segment
2685
+ for (i = field_index ; i < report -> maxfield && !end_collection ; i ++ ) {
2686
+ struct hid_field * field = report -> field [i ];
2687
+ unsigned int field_level =
2688
+ hdev -> collection [field -> usage [0 ].collection_index ].level ;
2689
+ unsigned int j ;
2690
+
2691
+ if (field_level != original_collection_level )
2692
+ continue ;
2693
+
2694
+ for (j = 0 ; j < field -> maxusage ; j ++ ) {
2695
+ struct hid_usage * usage = & field -> usage [j ];
2696
+
2697
+ if (usage -> collection_index != collection_index ) {
2698
+ end_collection = true;
2699
+ break ;
2700
+ }
2701
+ if (wacom_equivalent_usage (usage -> hid ) == HID_DG_CONTACTCOUNT ) {
2702
+ hid_data -> cc_report = report -> id ;
2703
+ hid_data -> cc_index = i ;
2704
+ hid_data -> cc_value_index = j ;
2705
+
2706
+ if (hid_data -> cc_report != 0 &&
2707
+ hid_data -> cc_index >= 0 ) {
2708
+
2709
+ struct hid_field * field =
2710
+ report -> field [hid_data -> cc_index ];
2711
+ int value =
2712
+ field -> value [hid_data -> cc_value_index ];
2713
+
2714
+ if (value )
2715
+ hid_data -> num_expected = value ;
2716
+ }
2717
+ }
2718
+ }
2719
+ }
2720
+
2721
+ if (hid_data -> cc_report == 0 || hid_data -> cc_index < 0 )
2722
+ hid_data -> num_expected = wacom_wac -> features .touch_max ;
2723
+ }
2724
+
2681
2725
static int wacom_wac_collection (struct hid_device * hdev , struct hid_report * report ,
2682
2726
int collection_index , struct hid_field * field ,
2683
2727
int field_index )
2684
2728
{
2685
2729
struct wacom * wacom = hid_get_drvdata (hdev );
2686
2730
2731
+ if (WACOM_FINGER_FIELD (field ))
2732
+ wacom_set_num_expected (hdev , report , collection_index , field ,
2733
+ field_index );
2687
2734
wacom_report_events (hdev , report , collection_index , field_index );
2688
2735
2689
2736
/*
0 commit comments