Skip to content

Commit 051dc9b

Browse files
HarryCuttsJiri Kosina
authored andcommitted
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>
1 parent 1ff2e1a commit 051dc9b

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

drivers/hid/hid-logitech-hidpp.c

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -400,32 +400,53 @@ static void hidpp_prefix_name(char **name, int name_length)
400400
#define HIDPP_SET_LONG_REGISTER 0x82
401401
#define HIDPP_GET_LONG_REGISTER 0x83
402402

403-
#define HIDPP_REG_GENERAL 0x00
404-
405-
static int hidpp10_enable_battery_reporting(struct hidpp_device *hidpp_dev)
403+
/**
404+
* hidpp10_set_register_bit() - Sets a single bit in a HID++ 1.0 register.
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)
406412
{
407413
struct hidpp_report response;
408414
int ret;
409415
u8 params[3] = { 0 };
410416

411417
ret = hidpp_send_rap_command_sync(hidpp_dev,
412-
REPORT_ID_HIDPP_SHORT,
413-
HIDPP_GET_REGISTER,
414-
HIDPP_REG_GENERAL,
415-
NULL, 0, &response);
418+
REPORT_ID_HIDPP_SHORT,
419+
HIDPP_GET_REGISTER,
420+
register_address,
421+
NULL, 0, &response);
416422
if (ret)
417423
return ret;
418424

419425
memcpy(params, response.rap.params, 3);
420426

421-
/* Set the battery bit */
422-
params[0] |= BIT(4);
427+
params[byte] |= BIT(bit);
423428

424429
return hidpp_send_rap_command_sync(hidpp_dev,
425-
REPORT_ID_HIDPP_SHORT,
426-
HIDPP_SET_REGISTER,
427-
HIDPP_REG_GENERAL,
428-
params, 3, &response);
430+
REPORT_ID_HIDPP_SHORT,
431+
HIDPP_SET_REGISTER,
432+
register_address,
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);
429450
}
430451

431452
#define HIDPP_REG_BATTERY_STATUS 0x07

0 commit comments

Comments
 (0)