@@ -191,6 +191,8 @@ struct hidpp_device {
191
191
192
192
struct hidpp_battery battery ;
193
193
struct hidpp_scroll_counter vertical_wheel_counter ;
194
+
195
+ u8 wireless_feature_index ;
194
196
};
195
197
196
198
/* HID++ 1.0 error codes */
@@ -403,10 +405,13 @@ static inline bool hidpp_match_error(struct hidpp_report *question,
403
405
(answer -> fap .params [0 ] == question -> fap .funcindex_clientid );
404
406
}
405
407
406
- static inline bool hidpp_report_is_connect_event (struct hidpp_report * report )
408
+ static inline bool hidpp_report_is_connect_event (struct hidpp_device * hidpp ,
409
+ struct hidpp_report * report )
407
410
{
408
- return (report -> report_id == REPORT_ID_HIDPP_SHORT ) &&
409
- (report -> rap .sub_id == 0x41 );
411
+ return (hidpp -> wireless_feature_index &&
412
+ (report -> fap .feature_index == hidpp -> wireless_feature_index )) ||
413
+ ((report -> report_id == REPORT_ID_HIDPP_SHORT ) &&
414
+ (report -> rap .sub_id == 0x41 ));
410
415
}
411
416
412
417
/**
@@ -1286,6 +1291,24 @@ static int hidpp_battery_get_property(struct power_supply *psy,
1286
1291
return ret ;
1287
1292
}
1288
1293
1294
+ /* -------------------------------------------------------------------------- */
1295
+ /* 0x1d4b: Wireless device status */
1296
+ /* -------------------------------------------------------------------------- */
1297
+ #define HIDPP_PAGE_WIRELESS_DEVICE_STATUS 0x1d4b
1298
+
1299
+ static int hidpp_set_wireless_feature_index (struct hidpp_device * hidpp )
1300
+ {
1301
+ u8 feature_type ;
1302
+ int ret ;
1303
+
1304
+ ret = hidpp_root_get_feature (hidpp ,
1305
+ HIDPP_PAGE_WIRELESS_DEVICE_STATUS ,
1306
+ & hidpp -> wireless_feature_index ,
1307
+ & feature_type );
1308
+
1309
+ return ret ;
1310
+ }
1311
+
1289
1312
/* -------------------------------------------------------------------------- */
1290
1313
/* 0x2120: Hi-resolution scrolling */
1291
1314
/* -------------------------------------------------------------------------- */
@@ -3101,7 +3124,7 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
3101
3124
}
3102
3125
}
3103
3126
3104
- if (unlikely (hidpp_report_is_connect_event (report ))) {
3127
+ if (unlikely (hidpp_report_is_connect_event (hidpp , report ))) {
3105
3128
atomic_set (& hidpp -> connected ,
3106
3129
!(report -> rap .params [0 ] & (1 << 6 )));
3107
3130
if (schedule_work (& hidpp -> work ) == 0 )
@@ -3652,6 +3675,14 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
3652
3675
hidpp_overwrite_name (hdev );
3653
3676
}
3654
3677
3678
+ if (connected && hidpp -> protocol_major >= 2 ) {
3679
+ ret = hidpp_set_wireless_feature_index (hidpp );
3680
+ if (ret == - ENOENT )
3681
+ hidpp -> wireless_feature_index = 0 ;
3682
+ else if (ret )
3683
+ goto hid_hw_init_fail ;
3684
+ }
3685
+
3655
3686
if (connected && (hidpp -> quirks & HIDPP_QUIRK_CLASS_WTP )) {
3656
3687
ret = wtp_get_config (hidpp );
3657
3688
if (ret )
0 commit comments