mirror of https://gitee.com/openkylin/linux.git
HID: logitech-hidpp: make hidpp10_set_register_bit a bit more generic
Make hidpp10_set_register_bit() take a mask and value for the register byte being changed, rather then making it only set a single bit. While at it also at defines for the bits which we will be using. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
This commit is contained in:
parent
0610430e3d
commit
35839f7723
|
@ -491,14 +491,16 @@ static void hidpp_scroll_counter_handle_scroll(struct input_dev *input_dev,
|
|||
#define HIDPP_GET_LONG_REGISTER 0x83
|
||||
|
||||
/**
|
||||
* hidpp10_set_register_bit() - Sets a single bit in a HID++ 1.0 register.
|
||||
* hidpp10_set_register - Modify a HID++ 1.0 register.
|
||||
* @hidpp_dev: the device to set the register on.
|
||||
* @register_address: the address of the register to modify.
|
||||
* @byte: the byte of the register to modify. Should be less than 3.
|
||||
* @mask: mask of the bits to modify
|
||||
* @value: new values for the bits in mask
|
||||
* Return: 0 if successful, otherwise a negative error code.
|
||||
*/
|
||||
static int hidpp10_set_register_bit(struct hidpp_device *hidpp_dev,
|
||||
u8 register_address, u8 byte, u8 bit)
|
||||
static int hidpp10_set_register(struct hidpp_device *hidpp_dev,
|
||||
u8 register_address, u8 byte, u8 mask, u8 value)
|
||||
{
|
||||
struct hidpp_report response;
|
||||
int ret;
|
||||
|
@ -514,7 +516,8 @@ static int hidpp10_set_register_bit(struct hidpp_device *hidpp_dev,
|
|||
|
||||
memcpy(params, response.rap.params, 3);
|
||||
|
||||
params[byte] |= BIT(bit);
|
||||
params[byte] &= ~mask;
|
||||
params[byte] |= value & mask;
|
||||
|
||||
return hidpp_send_rap_command_sync(hidpp_dev,
|
||||
REPORT_ID_HIDPP_SHORT,
|
||||
|
@ -523,20 +526,28 @@ static int hidpp10_set_register_bit(struct hidpp_device *hidpp_dev,
|
|||
params, 3, &response);
|
||||
}
|
||||
|
||||
|
||||
#define HIDPP_REG_GENERAL 0x00
|
||||
#define HIDPP_REG_ENABLE_REPORTS 0x00
|
||||
#define HIDPP_ENABLE_CONSUMER_REPORT BIT(0)
|
||||
#define HIDPP_ENABLE_WHEEL_REPORT BIT(2)
|
||||
#define HIDPP_ENABLE_MOUSE_EXTRA_BTN_REPORT BIT(3)
|
||||
#define HIDPP_ENABLE_BAT_REPORT BIT(4)
|
||||
#define HIDPP_ENABLE_HWHEEL_REPORT BIT(5)
|
||||
|
||||
static int hidpp10_enable_battery_reporting(struct hidpp_device *hidpp_dev)
|
||||
{
|
||||
return hidpp10_set_register_bit(hidpp_dev, HIDPP_REG_GENERAL, 0, 4);
|
||||
return hidpp10_set_register(hidpp_dev, HIDPP_REG_ENABLE_REPORTS, 0,
|
||||
HIDPP_ENABLE_BAT_REPORT, HIDPP_ENABLE_BAT_REPORT);
|
||||
}
|
||||
|
||||
#define HIDPP_REG_FEATURES 0x01
|
||||
#define HIDPP_ENABLE_SPECIAL_BUTTON_FUNC BIT(1)
|
||||
#define HIDPP_ENABLE_FAST_SCROLL BIT(6)
|
||||
|
||||
/* On HID++ 1.0 devices, high-res scroll was called "scrolling acceleration". */
|
||||
static int hidpp10_enable_scrolling_acceleration(struct hidpp_device *hidpp_dev)
|
||||
{
|
||||
return hidpp10_set_register_bit(hidpp_dev, HIDPP_REG_FEATURES, 0, 6);
|
||||
return hidpp10_set_register(hidpp_dev, HIDPP_REG_FEATURES, 0,
|
||||
HIDPP_ENABLE_FAST_SCROLL, HIDPP_ENABLE_FAST_SCROLL);
|
||||
}
|
||||
|
||||
#define HIDPP_REG_BATTERY_STATUS 0x07
|
||||
|
|
Loading…
Reference in New Issue