From patchwork Fri Sep 13 02:40:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mazin Rezk X-Patchwork-Id: 11143927 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00BEB912 for ; Fri, 13 Sep 2019 02:40:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 501FC2084F for ; Fri, 13 Sep 2019 02:40:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="X4VoIHWl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726754AbfIMCk5 (ORCPT ); Thu, 12 Sep 2019 22:40:57 -0400 Received: from mail-40133.protonmail.ch ([185.70.40.133]:38135 "EHLO mail-40133.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726905AbfIMCk5 (ORCPT ); Thu, 12 Sep 2019 22:40:57 -0400 Date: Fri, 13 Sep 2019 02:40:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1568342455; bh=V4PbAJ58X+/Rvcujigi4yKfg4K9q6TNuxl6Z4Nsh+s4=; h=Date:To:From:Reply-To:Subject:Feedback-ID:From; b=X4VoIHWlfPPNXVjhp9jqh+Cb+7h7kAcuPtMqBGZcjHJnY6IiqRaYbibqX76//CVYE w9xpj/4ti9PbegiFoFDhBMIoFTVDBUWat4fvT/xp7SbylT5BckEJhUmha032gTFjjQ Jep0GpipevgNyk6+h8agTPGs3P2XUX89gyE//cHE= To: "benjamin.tissoires@redhat.com" , "linux-input@vger.kernel.org" From: Mazin Rezk Reply-To: Mazin Rezk Subject: [PATCH] HID: hid-logitech-hidpp: Implement support for some Bluetooth HID++ devices Message-ID: Feedback-ID: 18B_FC5q-t32TXzMsVp9BgkgrdNH3iwklfW8WOrHrcxZA0WRj7JodCh5VXKxs6A3OaiHK0QNd8wi3SImKex8yQ==:Ext:ProtonMail MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This patch adds support the MX Anywhere 2, MX Anywhere 2S, MX Master, and MX Master 2S over Bluetooth to the hid-logitech-hidpp module. This patch also implements a foundation for other Bluetooth devices to be added to the module. Changes include: 1) Adding the device IDs for the aforementioned mice over Bluetooth (these IDs have been copied from the libratbag device database). Their quirks have been based on their DJ device counterparts. 2) Adding an additional HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID as these devices do not support Short HID++ reports. This quirk causes short reports to be sent as long reports to the device and overrides the device validation to only check if the long report descriptor exists. Without this quirk, these devices will fail the HID++ device validation. Note about these changes: I only own an MX Master (b01e) so I have not been able to test this patch on other devices. However, I have also noticed that the MX Master 2S over Bluetooth does not pass the original HID++ report descriptor tests which leads me to believe all MX Bluetooth LE devices are missing short report descriptors. Further testing with the other devices may be required. Signed-off-by: Mazin Rezk --- drivers/hid/hid-logitech-hidpp.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) -- 2.23.0 diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 0179f7ed77e5..a80c4486756c 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -72,6 +72,9 @@ MODULE_PARM_DESC(disable_tap_to_click, #define HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS BIT(30) #define HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS BIT(31) +/* This is required to fix report ids on some bluetooth devices */ +#define HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID BIT(32) + /* These are just aliases for now */ #define HIDPP_QUIRK_KBD_SCROLL_WHEEL HIDPP_QUIRK_HIDPP_WHEELS #define HIDPP_QUIRK_KBD_ZOOM_WHEEL HIDPP_QUIRK_HIDPP_WHEELS @@ -340,6 +343,11 @@ static int hidpp_send_rap_command_sync(struct hidpp_device *hidpp_dev, struct hidpp_report *message; int ret, max_count; + /* Force long reports on devices that do not support short reports */ + if (hidpp_dev->quirks & HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID && + report_id == REPORT_ID_HIDPP_SHORT) + report_id = REPORT_ID_HIDPP_LONG; + switch (report_id) { case REPORT_ID_HIDPP_SHORT: max_count = HIDPP_REPORT_SHORT_LENGTH - 4; @@ -3482,6 +3490,12 @@ static bool hidpp_validate_report(struct hid_device *hdev, int id, static bool hidpp_validate_device(struct hid_device *hdev) { + struct hidpp_device *hidpp = hid_get_drvdata(hdev); + /* Skip the short report check if the device does not support it */ + if (hidpp->quirks & HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID) + return hidpp_validate_report(hdev, REPORT_ID_HIDPP_LONG, + HIDPP_REPORT_LONG_LENGTH, false); + return hidpp_validate_report(hdev, REPORT_ID_HIDPP_SHORT, HIDPP_REPORT_SHORT_LENGTH, false) && hidpp_validate_report(hdev, REPORT_ID_HIDPP_LONG, @@ -3773,6 +3787,31 @@ static const struct hid_device_id hidpp_devices[] = { { /* MX5500 keyboard over Bluetooth */ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb30b), .driver_data = HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS }, + { /* MX Anywhere 2 mouse over Bluetooth */ + HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb013), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb018), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID }, + { /* MX Anywhere 2S mouse over Bluetooth */ + HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01a), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID }, + { /* MX Master mouse over Bluetooth */ + HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb012), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb017), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01e), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID }, + { /* MX Master 2S mouse over Bluetooth */ + HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb019), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_BLUETOOTH_MISSING_SHORT_ID }, {} };