3434 */
3535#define WACOM_CONTACT_AREA_SCALE 2607
3636
37+ static bool touch_arbitration = 1 ;
38+ module_param (touch_arbitration , bool , 0644 );
39+ MODULE_PARM_DESC (touch_arbitration , " on (Y) off (N)" );
40+
3741static void wacom_report_numbered_buttons (struct input_dev * input_dev ,
3842 int button_count , int mask );
3943
@@ -882,6 +886,16 @@ static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
882886 wacom_schedule_work (wacom_wac , WACOM_WORKER_REMOTE );
883887}
884888
889+ static inline bool report_touch_events (struct wacom_wac * wacom )
890+ {
891+ return (touch_arbitration ? !wacom -> shared -> stylus_in_proximity : 1 );
892+ }
893+
894+ static inline bool delay_pen_events (struct wacom_wac * wacom )
895+ {
896+ return (wacom -> shared -> touch_down && touch_arbitration );
897+ }
898+
885899static int wacom_intuos_general (struct wacom_wac * wacom )
886900{
887901 struct wacom_features * features = & wacom -> features ;
@@ -895,7 +909,7 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
895909 data [0 ] != WACOM_REPORT_INTUOS_PEN )
896910 return 0 ;
897911
898- if (wacom -> shared -> touch_down )
912+ if (delay_pen_events ( wacom ) )
899913 return 1 ;
900914
901915 /* don't report events if we don't know the tool ID */
@@ -1155,7 +1169,7 @@ static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
11551169
11561170 if (touch_max == 1 )
11571171 return test_bit (BTN_TOUCH , input -> key ) &&
1158- ! wacom -> shared -> stylus_in_proximity ;
1172+ report_touch_events ( wacom ) ;
11591173
11601174 for (i = 0 ; i < input -> mt -> num_slots ; i ++ ) {
11611175 struct input_mt_slot * ps = & input -> mt -> slots [i ];
@@ -1196,7 +1210,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
11961210
11971211 for (i = 0 ; i < contacts_to_send ; i ++ ) {
11981212 int offset = (byte_per_packet * i ) + 1 ;
1199- bool touch = (data [offset ] & 0x1 ) && ! wacom -> shared -> stylus_in_proximity ;
1213+ bool touch = (data [offset ] & 0x1 ) && report_touch_events ( wacom ) ;
12001214 int slot = input_mt_get_slot_by_key (input , data [offset + 1 ]);
12011215
12021216 if (slot < 0 )
@@ -1260,7 +1274,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
12601274
12611275 for (i = 0 ; i < contacts_to_send ; i ++ ) {
12621276 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset ) * i + 3 ;
1263- bool touch = (data [offset ] & 0x1 ) && ! wacom -> shared -> stylus_in_proximity ;
1277+ bool touch = (data [offset ] & 0x1 ) && report_touch_events ( wacom ) ;
12641278 int id = get_unaligned_le16 (& data [offset + 1 ]);
12651279 int slot = input_mt_get_slot_by_key (input , id );
12661280
@@ -1294,7 +1308,7 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
12941308
12951309 for (i = 0 ; i < 2 ; i ++ ) {
12961310 int p = data [1 ] & (1 << i );
1297- bool touch = p && ! wacom -> shared -> stylus_in_proximity ;
1311+ bool touch = p && report_touch_events ( wacom ) ;
12981312
12991313 input_mt_slot (input , i );
13001314 input_mt_report_slot_state (input , MT_TOOL_FINGER , touch );
@@ -1318,7 +1332,7 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
13181332{
13191333 unsigned char * data = wacom -> data ;
13201334 struct input_dev * input = wacom -> touch_input ;
1321- bool prox = ! wacom -> shared -> stylus_in_proximity ;
1335+ bool prox = report_touch_events ( wacom ) ;
13221336 int x = 0 , y = 0 ;
13231337
13241338 if (wacom -> features .touch_max > 1 || len > WACOM_PKGLEN_TPC2FG )
@@ -1363,8 +1377,10 @@ static int wacom_tpc_pen(struct wacom_wac *wacom)
13631377 /* keep pen state for touch events */
13641378 wacom -> shared -> stylus_in_proximity = prox ;
13651379
1366- /* send pen events only when touch is up or forced out */
1367- if (!wacom -> shared -> touch_down ) {
1380+ /* send pen events only when touch is up or forced out
1381+ * or touch arbitration is off
1382+ */
1383+ if (!delay_pen_events (wacom )) {
13681384 input_report_key (input , BTN_STYLUS , data [1 ] & 0x02 );
13691385 input_report_key (input , BTN_STYLUS2 , data [1 ] & 0x10 );
13701386 input_report_abs (input , ABS_X , le16_to_cpup ((__le16 * )& data [2 ]));
@@ -1506,8 +1522,10 @@ static int wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
15061522 return 0 ;
15071523 }
15081524
1509- /* send pen events only when touch is up or forced out */
1510- if (!usage -> type || wacom_wac -> shared -> touch_down )
1525+ /* send pen events only when touch is up or forced out
1526+ * or touch arbitration is off
1527+ */
1528+ if (!usage -> type || delay_pen_events (wacom_wac ))
15111529 return 0 ;
15121530
15131531 input_event (input , usage -> type , usage -> code , value );
@@ -1537,8 +1555,7 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
15371555 /* keep pen state for touch events */
15381556 wacom_wac -> shared -> stylus_in_proximity = prox ;
15391557
1540- /* send pen events only when touch is up or forced out */
1541- if (!wacom_wac -> shared -> touch_down ) {
1558+ if (!delay_pen_events (wacom_wac )) {
15421559 input_report_key (input , BTN_TOUCH ,
15431560 wacom_wac -> hid_data .tipswitch );
15441561 input_report_key (input , wacom_wac -> tool [0 ], prox );
@@ -1609,7 +1626,7 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
16091626 struct hid_data * hid_data = & wacom_wac -> hid_data ;
16101627 bool mt = wacom_wac -> features .touch_max > 1 ;
16111628 bool prox = hid_data -> tipswitch &&
1612- ! wacom_wac -> shared -> stylus_in_proximity ;
1629+ report_touch_events ( wacom_wac ) ;
16131630
16141631 wacom_wac -> hid_data .num_received ++ ;
16151632 if (wacom_wac -> hid_data .num_received > wacom_wac -> hid_data .num_expected )
@@ -1835,15 +1852,8 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
18351852
18361853 for (i = 0 ; i < 2 ; i ++ ) {
18371854 int offset = (data [1 ] & 0x80 ) ? (8 * i ) : (9 * i );
1838- bool touch = data [offset + 3 ] & 0x80 ;
1839-
1840- /*
1841- * Touch events need to be disabled while stylus is
1842- * in proximity because user's hand is resting on touchpad
1843- * and sending unwanted events. User expects tablet buttons
1844- * to continue working though.
1845- */
1846- touch = touch && !wacom -> shared -> stylus_in_proximity ;
1855+ bool touch = report_touch_events (wacom )
1856+ && (data [offset + 3 ] & 0x80 );
18471857
18481858 input_mt_slot (input , i );
18491859 input_mt_report_slot_state (input , MT_TOOL_FINGER , touch );
@@ -1880,7 +1890,7 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
18801890 if (slot < 0 )
18811891 return ;
18821892
1883- touch = touch && ! wacom -> shared -> stylus_in_proximity ;
1893+ touch = touch && report_touch_events ( wacom ) ;
18841894
18851895 input_mt_slot (input , slot );
18861896 input_mt_report_slot_state (input , MT_TOOL_FINGER , touch );
@@ -1993,7 +2003,7 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
19932003 }
19942004
19952005 wacom -> shared -> stylus_in_proximity = prox ;
1996- if (wacom -> shared -> touch_down )
2006+ if (delay_pen_events ( wacom ) )
19972007 return 0 ;
19982008
19992009 if (prox ) {
@@ -2087,7 +2097,7 @@ static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
20872097
20882098 for (id = 0 ; id < wacom -> features .touch_max ; id ++ ) {
20892099 valid = !!(prefix & BIT (id )) &&
2090- ! wacom -> shared -> stylus_in_proximity ;
2100+ report_touch_events ( wacom ) ;
20912101
20922102 input_mt_slot (input , id );
20932103 input_mt_report_slot_state (input , MT_TOOL_FINGER , valid );
@@ -2109,8 +2119,7 @@ static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
21092119 input_report_key (input , BTN_RIGHT , prefix & 0x80 );
21102120
21112121 /* keep touch state for pen event */
2112- wacom -> shared -> touch_down = !!prefix &&
2113- !wacom -> shared -> stylus_in_proximity ;
2122+ wacom -> shared -> touch_down = !!prefix && report_touch_events (wacom );
21142123
21152124 return 1 ;
21162125}
0 commit comments