diff options
author | Harry Cutts <hcutts@chromium.org> | 2018-08-30 17:56:20 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2018-09-05 04:12:07 -0400 |
commit | 051dc9b0579602bd63e9df74d0879b5293e71581 (patch) | |
tree | 07a33164adae6bb68c4adda1592074bebc415536 | |
parent | 1ff2e1a44e02d4bdbb9be67c7d9acc240a67141f (diff) |
HID: logitech: Add function to enable HID++ 1.0 "scrolling acceleration"
"Scrolling acceleration" is a bit of a misnomer: it doesn't deal with
acceleration at all. However, that's the name used in Logitech's spec,
so I used it here.
Signed-off-by: Harry Cutts <hcutts@chromium.org>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/hid/hid-logitech-hidpp.c | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 19cc980eebce..7f8218f6ff56 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c | |||
@@ -400,32 +400,53 @@ static void hidpp_prefix_name(char **name, int name_length) | |||
400 | #define HIDPP_SET_LONG_REGISTER 0x82 | 400 | #define HIDPP_SET_LONG_REGISTER 0x82 |
401 | #define HIDPP_GET_LONG_REGISTER 0x83 | 401 | #define HIDPP_GET_LONG_REGISTER 0x83 |
402 | 402 | ||
403 | #define HIDPP_REG_GENERAL 0x00 | 403 | /** |
404 | 404 | * hidpp10_set_register_bit() - Sets a single bit in a HID++ 1.0 register. | |
405 | static int hidpp10_enable_battery_reporting(struct hidpp_device *hidpp_dev) | 405 | * @hidpp_dev: the device to set the register on. |
406 | * @register_address: the address of the register to modify. | ||
407 | * @byte: the byte of the register to modify. Should be less than 3. | ||
408 | * Return: 0 if successful, otherwise a negative error code. | ||
409 | */ | ||
410 | static int hidpp10_set_register_bit(struct hidpp_device *hidpp_dev, | ||
411 | u8 register_address, u8 byte, u8 bit) | ||
406 | { | 412 | { |
407 | struct hidpp_report response; | 413 | struct hidpp_report response; |
408 | int ret; | 414 | int ret; |
409 | u8 params[3] = { 0 }; | 415 | u8 params[3] = { 0 }; |
410 | 416 | ||
411 | ret = hidpp_send_rap_command_sync(hidpp_dev, | 417 | ret = hidpp_send_rap_command_sync(hidpp_dev, |
412 | REPORT_ID_HIDPP_SHORT, | 418 | REPORT_ID_HIDPP_SHORT, |
413 | HIDPP_GET_REGISTER, | 419 | HIDPP_GET_REGISTER, |
414 | HIDPP_REG_GENERAL, | 420 | register_address, |
415 | NULL, 0, &response); | 421 | NULL, 0, &response); |
416 | if (ret) | 422 | if (ret) |
417 | return ret; | 423 | return ret; |
418 | 424 | ||
419 | memcpy(params, response.rap.params, 3); | 425 | memcpy(params, response.rap.params, 3); |
420 | 426 | ||
421 | /* Set the battery bit */ | 427 | params[byte] |= BIT(bit); |
422 | params[0] |= BIT(4); | ||
423 | 428 | ||
424 | return hidpp_send_rap_command_sync(hidpp_dev, | 429 | return hidpp_send_rap_command_sync(hidpp_dev, |
425 | REPORT_ID_HIDPP_SHORT, | 430 | REPORT_ID_HIDPP_SHORT, |
426 | HIDPP_SET_REGISTER, | 431 | HIDPP_SET_REGISTER, |
427 | HIDPP_REG_GENERAL, | 432 | register_address, |
428 | params, 3, &response); | 433 | params, 3, &response); |
434 | } | ||
435 | |||
436 | |||
437 | #define HIDPP_REG_GENERAL 0x00 | ||
438 | |||
439 | static int hidpp10_enable_battery_reporting(struct hidpp_device *hidpp_dev) | ||
440 | { | ||
441 | return hidpp10_set_register_bit(hidpp_dev, HIDPP_REG_GENERAL, 0, 4); | ||
442 | } | ||
443 | |||
444 | #define HIDPP_REG_FEATURES 0x01 | ||
445 | |||
446 | /* On HID++ 1.0 devices, high-res scroll was called "scrolling acceleration". */ | ||
447 | static int hidpp10_enable_scrolling_acceleration(struct hidpp_device *hidpp_dev) | ||
448 | { | ||
449 | return hidpp10_set_register_bit(hidpp_dev, HIDPP_REG_FEATURES, 0, 6); | ||
429 | } | 450 | } |
430 | 451 | ||
431 | #define HIDPP_REG_BATTERY_STATUS 0x07 | 452 | #define HIDPP_REG_BATTERY_STATUS 0x07 |