From patchwork Sun Oct 6 01:04:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mazin Rezk X-Patchwork-Id: 11175957 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 E1877195A for ; Sun, 6 Oct 2019 01:04:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B5882222C8 for ; Sun, 6 Oct 2019 01:04:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="O4hOGLNf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726988AbfJFBEY (ORCPT ); Sat, 5 Oct 2019 21:04:24 -0400 Received: from mail-40133.protonmail.ch ([185.70.40.133]:40812 "EHLO mail-40133.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbfJFBEY (ORCPT ); Sat, 5 Oct 2019 21:04:24 -0400 Date: Sun, 06 Oct 2019 01:04:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1570323859; bh=EenmT9+ylx8vIRw7BMAiWOi3ZvFwek38x/+DNgZOMEc=; h=Date:To:From:Cc:Reply-To:Subject:Feedback-ID:From; b=O4hOGLNfVG9gqVm9o4EGx1rNJh2PtJE2ogwUApPkqkfIBZBMTx+WDMNT17ITK5A5m VnRXpPSMRUNkdWHZfzXl03IlbAAExaDhuU/OAu8Zs6gAstLoMbZSLLrLuFz3mL1JLa NOHf/PQRoxjZcm7WgsJj1iZtLPybTFcCIVIO7noI= To: "linux-input@vger.kernel.org" From: Mazin Rezk Cc: "benjamin.tissoires@redhat.com" , "jikos@kernel.org" , "linux-kernel@vger.kernel.org" , "lains@archlinux.org" , "mnrzk@protonmail.com" Reply-To: Mazin Rezk Subject: [PATCH v3 2/4] HID: logitech: Support HID++ devices without short reports 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 allows the hid-logitech-hidpp module to support devices that do not have support for Short HID++ reports. So far, it seems that Bluetooth HID++ 2.0 devices are missing short reports. This has been tested and confirmed with the MX Master and MX Master 2S and is therefore likely the case with the other Bluetooth devices. Signed-off-by: Mazin Rezk --- drivers/hid/hid-logitech-hidpp.c | 37 ++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) -- 2.23.0 diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 85fd0c17cc2f..a0efa8a43213 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -71,6 +71,7 @@ MODULE_PARM_DESC(disable_tap_to_click, #define HIDPP_QUIRK_HIDPP_WHEELS BIT(29) #define HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS BIT(30) #define HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS BIT(31) +#define HIDPP_QUIRK_CLASS_BLUETOOTH BIT(5) /* These are just aliases for now */ #define HIDPP_QUIRK_KBD_SCROLL_WHEEL HIDPP_QUIRK_HIDPP_WHEELS @@ -81,6 +82,9 @@ MODULE_PARM_DESC(disable_tap_to_click, HIDPP_QUIRK_HI_RES_SCROLL_X2120 | \ HIDPP_QUIRK_HI_RES_SCROLL_X2121) +/* Just an alias for now, may possibly be a catch-all in the future */ +#define HIDPP_QUIRK_MISSING_SHORT_REPORTS HIDPP_QUIRK_CLASS_BLUETOOTH + #define HIDPP_QUIRK_DELAYED_INIT HIDPP_QUIRK_NO_HIDINPUT #define HIDPP_CAPABILITY_HIDPP10_BATTERY BIT(0) @@ -340,6 +344,12 @@ 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_MISSING_SHORT_REPORTS && + 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 +3492,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_MISSING_SHORT_REPORTS) + 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, @@ -3775,22 +3791,29 @@ static const struct hid_device_id hidpp_devices[] = { .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 }, + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_CLASS_BLUETOOTH }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb018), - .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_CLASS_BLUETOOTH }, { /* MX Anywhere 2S mouse over Bluetooth */ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01a), - .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_CLASS_BLUETOOTH }, { /* MX Master mouse over Bluetooth */ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb012), - .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_CLASS_BLUETOOTH }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb017), - .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_CLASS_BLUETOOTH }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01e), - .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_CLASS_BLUETOOTH }, { /* MX Master 2S mouse over Bluetooth */ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb019), - .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 | + HIDPP_QUIRK_CLASS_BLUETOOTH }, {} };