@@ -49,6 +49,10 @@ MODULE_PARM_DESC(disable_tap_to_click,
49
49
#define HIDPP_REPORT_LONG_LENGTH 20
50
50
#define HIDPP_REPORT_VERY_LONG_MAX_LENGTH 64
51
51
52
+ #define HIDPP_REPORT_SHORT_SUPPORTED BIT(0)
53
+ #define HIDPP_REPORT_LONG_SUPPORTED BIT(1)
54
+ #define HIDPP_REPORT_VERY_LONG_SUPPORTED BIT(2)
55
+
52
56
#define HIDPP_SUB_ID_CONSUMER_VENDOR_KEYS 0x03
53
57
#define HIDPP_SUB_ID_ROLLER 0x05
54
58
#define HIDPP_SUB_ID_MOUSE_EXTRA_BTNS 0x06
@@ -183,6 +187,7 @@ struct hidpp_device {
183
187
184
188
unsigned long quirks ;
185
189
unsigned long capabilities ;
190
+ u8 supported_reports ;
186
191
187
192
struct hidpp_battery battery ;
188
193
struct hidpp_scroll_counter vertical_wheel_counter ;
@@ -340,6 +345,11 @@ static int hidpp_send_rap_command_sync(struct hidpp_device *hidpp_dev,
340
345
struct hidpp_report * message ;
341
346
int ret , max_count ;
342
347
348
+ /* Send as long report if short reports are not supported. */
349
+ if (report_id == REPORT_ID_HIDPP_SHORT &&
350
+ !(hidpp_dev -> supported_reports & HIDPP_REPORT_SHORT_SUPPORTED ))
351
+ report_id = REPORT_ID_HIDPP_LONG ;
352
+
343
353
switch (report_id ) {
344
354
case REPORT_ID_HIDPP_SHORT :
345
355
max_count = HIDPP_REPORT_SHORT_LENGTH - 4 ;
@@ -3481,18 +3491,19 @@ static int hidpp_get_report_length(struct hid_device *hdev, int id)
3481
3491
return report -> field [0 ]-> report_count + 1 ;
3482
3492
}
3483
3493
3484
- static bool hidpp_validate_device (struct hid_device * hdev )
3494
+ static u8 hidpp_validate_device (struct hid_device * hdev )
3485
3495
{
3486
3496
struct hidpp_device * hidpp = hid_get_drvdata (hdev );
3487
- int id , report_length , supported_reports = 0 ;
3497
+ int id , report_length ;
3498
+ u8 supported_reports = 0 ;
3488
3499
3489
3500
id = REPORT_ID_HIDPP_SHORT ;
3490
3501
report_length = hidpp_get_report_length (hdev , id );
3491
3502
if (report_length ) {
3492
3503
if (report_length < HIDPP_REPORT_SHORT_LENGTH )
3493
3504
goto bad_device ;
3494
3505
3495
- supported_reports ++ ;
3506
+ supported_reports |= HIDPP_REPORT_SHORT_SUPPORTED ;
3496
3507
}
3497
3508
3498
3509
id = REPORT_ID_HIDPP_LONG ;
@@ -3501,7 +3512,7 @@ static bool hidpp_validate_device(struct hid_device *hdev)
3501
3512
if (report_length < HIDPP_REPORT_LONG_LENGTH )
3502
3513
goto bad_device ;
3503
3514
3504
- supported_reports ++ ;
3515
+ supported_reports |= HIDPP_REPORT_LONG_SUPPORTED ;
3505
3516
}
3506
3517
3507
3518
id = REPORT_ID_HIDPP_VERY_LONG ;
@@ -3511,7 +3522,7 @@ static bool hidpp_validate_device(struct hid_device *hdev)
3511
3522
report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH )
3512
3523
goto bad_device ;
3513
3524
3514
- supported_reports ++ ;
3525
+ supported_reports |= HIDPP_REPORT_VERY_LONG_SUPPORTED ;
3515
3526
hidpp -> very_long_report_length = report_length ;
3516
3527
}
3517
3528
@@ -3560,7 +3571,9 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
3560
3571
/*
3561
3572
* Make sure the device is HID++ capable, otherwise treat as generic HID
3562
3573
*/
3563
- if (!hidpp_validate_device (hdev )) {
3574
+ hidpp -> supported_reports = hidpp_validate_device (hdev );
3575
+
3576
+ if (!hidpp -> supported_reports ) {
3564
3577
hid_set_drvdata (hdev , NULL );
3565
3578
devm_kfree (& hdev -> dev , hidpp );
3566
3579
return hid_hw_start (hdev , HID_CONNECT_DEFAULT );
@@ -3808,6 +3821,11 @@ static const struct hid_device_id hidpp_devices[] = {
3808
3821
{ /* MX5500 keyboard over Bluetooth */
3809
3822
HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_LOGITECH , 0xb30b ),
3810
3823
.driver_data = HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS },
3824
+ { /* MX Master mouse over Bluetooth */
3825
+ HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_LOGITECH , 0xb012 ),
3826
+ .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3827
+ { HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_LOGITECH , 0xb01e ),
3828
+ .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3811
3829
{}
3812
3830
};
3813
3831
0 commit comments