@@ -491,14 +491,16 @@ static void hidpp_scroll_counter_handle_scroll(struct input_dev *input_dev,
491
491
#define HIDPP_GET_LONG_REGISTER 0x83
492
492
493
493
/**
494
- * hidpp10_set_register_bit() - Sets a single bit in a HID++ 1.0 register.
494
+ * hidpp10_set_register - Modify a HID++ 1.0 register.
495
495
* @hidpp_dev: the device to set the register on.
496
496
* @register_address: the address of the register to modify.
497
497
* @byte: the byte of the register to modify. Should be less than 3.
498
+ * @mask: mask of the bits to modify
499
+ * @value: new values for the bits in mask
498
500
* Return: 0 if successful, otherwise a negative error code.
499
501
*/
500
- static int hidpp10_set_register_bit (struct hidpp_device * hidpp_dev ,
501
- u8 register_address , u8 byte , u8 bit )
502
+ static int hidpp10_set_register (struct hidpp_device * hidpp_dev ,
503
+ u8 register_address , u8 byte , u8 mask , u8 value )
502
504
{
503
505
struct hidpp_report response ;
504
506
int ret ;
@@ -514,7 +516,8 @@ static int hidpp10_set_register_bit(struct hidpp_device *hidpp_dev,
514
516
515
517
memcpy (params , response .rap .params , 3 );
516
518
517
- params [byte ] |= BIT (bit );
519
+ params [byte ] &= ~mask ;
520
+ params [byte ] |= value & mask ;
518
521
519
522
return hidpp_send_rap_command_sync (hidpp_dev ,
520
523
REPORT_ID_HIDPP_SHORT ,
@@ -523,20 +526,28 @@ static int hidpp10_set_register_bit(struct hidpp_device *hidpp_dev,
523
526
params , 3 , & response );
524
527
}
525
528
526
-
527
- #define HIDPP_REG_GENERAL 0x00
529
+ #define HIDPP_REG_ENABLE_REPORTS 0x00
530
+ #define HIDPP_ENABLE_CONSUMER_REPORT BIT(0)
531
+ #define HIDPP_ENABLE_WHEEL_REPORT BIT(2)
532
+ #define HIDPP_ENABLE_MOUSE_EXTRA_BTN_REPORT BIT(3)
533
+ #define HIDPP_ENABLE_BAT_REPORT BIT(4)
534
+ #define HIDPP_ENABLE_HWHEEL_REPORT BIT(5)
528
535
529
536
static int hidpp10_enable_battery_reporting (struct hidpp_device * hidpp_dev )
530
537
{
531
- return hidpp10_set_register_bit (hidpp_dev , HIDPP_REG_GENERAL , 0 , 4 );
538
+ return hidpp10_set_register (hidpp_dev , HIDPP_REG_ENABLE_REPORTS , 0 ,
539
+ HIDPP_ENABLE_BAT_REPORT , HIDPP_ENABLE_BAT_REPORT );
532
540
}
533
541
534
542
#define HIDPP_REG_FEATURES 0x01
543
+ #define HIDPP_ENABLE_SPECIAL_BUTTON_FUNC BIT(1)
544
+ #define HIDPP_ENABLE_FAST_SCROLL BIT(6)
535
545
536
546
/* On HID++ 1.0 devices, high-res scroll was called "scrolling acceleration". */
537
547
static int hidpp10_enable_scrolling_acceleration (struct hidpp_device * hidpp_dev )
538
548
{
539
- return hidpp10_set_register_bit (hidpp_dev , HIDPP_REG_FEATURES , 0 , 6 );
549
+ return hidpp10_set_register (hidpp_dev , HIDPP_REG_FEATURES , 0 ,
550
+ HIDPP_ENABLE_FAST_SCROLL , HIDPP_ENABLE_FAST_SCROLL );
540
551
}
541
552
542
553
#define HIDPP_REG_BATTERY_STATUS 0x07
0 commit comments