Re: [PATCH] HID: logitech-hidpp: Enable HID++ for all the Logitech Bluetooth devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2022-08-25 at 16:47 -0400, Peter F. Patel-Schneider wrote:
> This patch will cause more use of a part of the driver that
> constructs
> messages that do not conform to the HID++ 2.0 specification.  This
> makes now a good time to fix the parts of the driver that construct
> non-conforming messages.  More information follows.
> 
> 
> The Logitech HID++2.0 Draft Specification at
> https://lekensteyn.nl/files/logitech/logitech_hidpp_2.0_specification_draft_2012-06-04.pdf
> specifies (on pages 2 and 3) that the low-order nibble of the
> function
> (command) byte is non-zero.
> 
> The HID++ driver at
> https://github.com/torvalds/linux/blob/master/drivers/hid/hid-logitech-hidpp.c
> has 1 in that nibble for some commands, 
> 
> #define CMD_ROOT_GET_FEATURE                            0x01
> #define CMD_ROOT_GET_PROTOCOL_VERSION                   0x11
> 
> #define CMD_GET_DEVICE_NAME_TYPE_GET_COUNT              0x01
> #define CMD_GET_DEVICE_NAME_TYPE_GET_DEVICE_NAME        0x11
> #define CMD_GET_DEVICE_NAME_TYPE_GET_TYPE               0x21
> 
> But other commands have zero in that nibble, namely
> 
> #define CMD_BATTERY_LEVEL_STATUS_GET_BATTERY_LEVEL_STATUS       0x00
> #define CMD_BATTERY_LEVEL_STATUS_GET_BATTERY_CAPABILITY         0x10
> 
> #define CMD_BATTERY_VOLTAGE_GET_BATTERY_VOLTAGE 0x00
> 
> #define CMD_UNIFIED_BATTERY_GET_CAPABILITIES                    0x00
> #define CMD_UNIFIED_BATTERY_GET_STATUS                          0x10
> 
> #define CMD_HI_RESOLUTION_SCROLLING_SET_HIGHRES_SCROLLING_MODE  0x10
> 
> #define CMD_HIRES_WHEEL_GET_WHEEL_CAPABILITY    0x00
> #define CMD_HIRES_WHEEL_SET_WHEEL_MODE          0x20
> 
> #define CMD_SOLAR_SET_LIGHT_MEASURE                     0x00
> 
> #define CMD_TOUCHPAD_FW_ITEMS_SET                       0x10

Sounds like none of those commands should have anything set in that
lower nibble, but this patch should be enough to take care of either
case. I don't know whether the "rap" commands are used at all for HID++
2.0 commands, or just for HID++ 1.0.

Is the software ID something random that the software in question
chooses? I chose 0x06 as we're at Linux version 6.0...

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 86e7a38d8a9a..4c430b24b6bc 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -41,6 +41,9 @@ module_param(disable_tap_to_click, bool, 0644);
 MODULE_PARM_DESC(disable_tap_to_click,
        "Disable Tap-To-Click mode reporting for touchpads (only on the K400 currently).");
 
+/* Define a non-zero software ID to identify our own responses */
+#define LINUX_KERNEL_SW_ID                     0x06
+
 #define REPORT_ID_HIDPP_SHORT                  0x10
 #define REPORT_ID_HIDPP_LONG                   0x11
 #define REPORT_ID_HIDPP_VERY_LONG              0x12
@@ -343,7 +346,7 @@ static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp,
        else
                message->report_id = REPORT_ID_HIDPP_LONG;
        message->fap.feature_index = feat_index;
-       message->fap.funcindex_clientid = funcindex_clientid;
+       message->fap.funcindex_clientid = funcindex_clientid | LINUX_KERNEL_SW_ID;
        memcpy(&message->fap.params, params, param_count);
 
        ret = hidpp_send_message_sync(hidpp, message, response);




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux