From patchwork Fri Oct 11 00:57:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mazin Rezk X-Patchwork-Id: 11184747 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 6CBD2912 for ; Fri, 11 Oct 2019 00:57:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 307CF214E0 for ; Fri, 11 Oct 2019 00:57:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="MTUThyLt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727584AbfJKA5H (ORCPT ); Thu, 10 Oct 2019 20:57:07 -0400 Received: from mail-40133.protonmail.ch ([185.70.40.133]:39155 "EHLO mail-40133.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727518AbfJKA5H (ORCPT ); Thu, 10 Oct 2019 20:57:07 -0400 Date: Fri, 11 Oct 2019 00:57:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1570755424; bh=TaWqFGzwNnSXrjd7mMijBXSMPxeqM7gfm+RUBuvzjjE=; h=Date:To:From:Cc:Reply-To:Subject:Feedback-ID:From; b=MTUThyLtEblJX5Ca3b2QsWgOwQWgSDEyxmQnoxabqZyXFaO1q4RWDp26EoafDESN0 hjbd7d33hvhGvn6k6N1Wl0wlv9lAF9kc/Z2qBWpfzDYAxMQCx9TtrCCy1BwcIppQBg N2mTg+XyZUEmTdbeZWh0h1mSTYw2FKRrfTXKJQ18= To: "linux-input@vger.kernel.org" From: Mazin Rezk Cc: "benjamin.tissoires@redhat.com" , "jikos@kernel.org" , "linux-kernel@vger.kernel.org" , =?utf-8?q?Fi?= =?utf-8?q?lipe_La=C3=ADns?= , "mnrzk@protonmail.com" Reply-To: Mazin Rezk Subject: [PATCH v4 1/4] HID: logitech: Add MX Mice over Bluetooth 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 On Saturday, October 5, 2019 9:04 PM, Mazin Rezk wrote: > This patch adds support for several MX mice over Bluetooth. The device IDs > have been copied from the libratbag device database and their features > have been based on their DJ device counterparts. No changes have been made to this patch in v4. However, it should be noted that the only device that has been thoroughly tested in this patch is the MX Master (b01e). Further testing for the other devices may be required. Signed-off-by: Mazin Rezk Reviewed-by: Filipe LaĆ­ns --- drivers/hid/hid-logitech-hidpp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 2.23.0 diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 0179f7ed77e5..85fd0c17cc2f 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -3773,6 +3773,24 @@ 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 }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb018), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { /* MX Anywhere 2S mouse over Bluetooth */ + HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01a), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { /* MX Master mouse over Bluetooth */ + HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb012), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb017), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01e), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { /* MX Master 2S mouse over Bluetooth */ + HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb019), + .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, {} }; From patchwork Fri Oct 11 00:57:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mazin Rezk X-Patchwork-Id: 11184749 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 9EA56912 for ; Fri, 11 Oct 2019 00:57:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7674421A4A for ; Fri, 11 Oct 2019 00:57:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="EUwSWTIm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727518AbfJKA5Y (ORCPT ); Thu, 10 Oct 2019 20:57:24 -0400 Received: from mail-40136.protonmail.ch ([185.70.40.136]:18974 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727709AbfJKA5Y (ORCPT ); Thu, 10 Oct 2019 20:57:24 -0400 Date: Fri, 11 Oct 2019 00:57:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1570755441; bh=Gsf6n79Vl+GtF90MQ1MHtnCzUGb6OQITOclBiAJVQ6o=; h=Date:To:From:Cc:Reply-To:Subject:Feedback-ID:From; b=EUwSWTImbWg0E5MObn7Qo9qZaXH4D95Ny4YV2OE8P8GaD7yO/NuQk5hBMZInHk06l zWOuYmXsCZvc6iJU3udbH7Xp9rdTf4su8XvP0YtTYeX20kqpeBAsJf1p5fUsUhEHbU Ch3X1QYNaVs4l+hCcrcIUM9AFWtyKyBaoXyn0UFU= To: "linux-input@vger.kernel.org" From: Mazin Rezk Cc: "benjamin.tissoires@redhat.com" , "jikos@kernel.org" , "linux-kernel@vger.kernel.org" , =?utf-8?q?Fi?= =?utf-8?q?lipe_La=C3=ADns?= , "mnrzk@protonmail.com" Reply-To: Mazin Rezk Subject: [PATCH v4 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 On Saturday, October 5, 2019 9:04 PM, Mazin Rezk wrote: > 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. No changes have been made to this patch in v4. 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 }, {} }; From patchwork Fri Oct 11 00:57:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mazin Rezk X-Patchwork-Id: 11184751 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 4CEB8912 for ; Fri, 11 Oct 2019 00:57:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D52321A4C for ; Fri, 11 Oct 2019 00:57:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="DmFkeHu9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727777AbfJKA5k (ORCPT ); Thu, 10 Oct 2019 20:57:40 -0400 Received: from mail-40130.protonmail.ch ([185.70.40.130]:35622 "EHLO mail-40130.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727709AbfJKA5k (ORCPT ); Thu, 10 Oct 2019 20:57:40 -0400 Date: Fri, 11 Oct 2019 00:57:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1570755456; bh=tE9eDZpDoC2wZB6O3L2pIo7bsgVJsjeG1+vFvwgLxCc=; h=Date:To:From:Cc:Reply-To:Subject:Feedback-ID:From; b=DmFkeHu93hfjVR7lJwH3ChGZ2G+ftk3wzf5NgXog+xqVBExUJIICz0HZOy4czJToN drcBdFfGXeDsYXtaqO0E53Z4FK8D+zA4sOHIwLeX7qHwGvlPEf6IE0ovGieXVark09 Yu/IB/J4I053sDG8oR1wqMF0Qzqq8xyeruv8n7Mg= To: "linux-input@vger.kernel.org" From: Mazin Rezk Cc: "benjamin.tissoires@redhat.com" , "jikos@kernel.org" , "linux-kernel@vger.kernel.org" , =?utf-8?q?Fi?= =?utf-8?q?lipe_La=C3=ADns?= , "mnrzk@protonmail.com" Reply-To: Mazin Rezk Subject: [PATCH v4 3/4] HID: logitech: Add feature 0x0001: FeatureSet 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 On Saturday, October 5, 2019 9:04 PM, Mazin Rezk wrote: > This patch adds support for the 0x0001 (FeatureSet) feature. This feature > is used to look up the feature ID of a feature index on a device and list > the total count of features on the device. > > I also added the hidpp20_get_features function which iterates through all > feature indexes on the device and stores a map of them in features an > hidpp_device struct. This function runs when an HID++ 2.0 device is probed. Changes in the version: - Renamed hidpp20_featureset_get_feature to hidpp20_featureset_get_feature_id. - Re-ordered hidpp20_featureset_get_count and hidpp20_featureset_get_feature_id based on their command IDs. - Made feature_count initialize to 0 before running hidpp20_get_features. Signed-off-by: Mazin Rezk --- drivers/hid/hid-logitech-hidpp.c | 90 ++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) -- 2.23.0 diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index a0efa8a43213..2062be922c08 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -190,6 +190,9 @@ struct hidpp_device { struct hidpp_battery battery; struct hidpp_scroll_counter vertical_wheel_counter; + + u16 *features; + u8 feature_count; }; /* HID++ 1.0 error codes */ @@ -911,6 +914,82 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) return 0; } +/* -------------------------------------------------------------------------- */ +/* 0x0001: FeatureSet */ +/* -------------------------------------------------------------------------- */ + +#define HIDPP_PAGE_FEATURESET 0x0001 + +#define CMD_FEATURESET_GET_COUNT 0x00 +#define CMD_FEATURESET_GET_FEATURE 0x11 + +static int hidpp20_featureset_get_count(struct hidpp_device *hidpp, + u8 feature_index, u8 *count) +{ + struct hidpp_report response; + int ret; + + ret = hidpp_send_fap_command_sync(hidpp, feature_index, + CMD_FEATURESET_GET_COUNT, NULL, 0, &response); + + if (ret) + return ret; + + *count = response.fap.params[0]; + + return ret; +} + +static int hidpp20_featureset_get_feature_id(struct hidpp_device *hidpp, + u8 featureset_index, u8 feature_index, u16 *feature_id) +{ + struct hidpp_report response; + int ret; + + ret = hidpp_send_fap_command_sync(hidpp, featureset_index, + CMD_FEATURESET_GET_FEATURE, &feature_index, 1, &response); + + if (ret) + return ret; + + *feature_id = (response.fap.params[0] << 8) | response.fap.params[1]; + + return ret; +} + +static int hidpp20_get_features(struct hidpp_device *hidpp) +{ + int ret; + u8 featureset_index, featureset_type; + u8 i; + + ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_FEATURESET, + &featureset_index, &featureset_type); + + if (ret == -ENOENT) { + hid_warn(hidpp->hid_dev, "Unable to retrieve feature set."); + return 0; + } + + if (ret) + return ret; + + ret = hidpp20_featureset_get_count(hidpp, featureset_index, + &hidpp->feature_count); + + if (ret) + return ret; + + hidpp->features = devm_kzalloc(&hidpp->hid_dev->dev, + hidpp->feature_count * sizeof(u16), GFP_KERNEL); + + for (i = 0; i < hidpp->feature_count && !ret; i++) + ret = hidpp20_featureset_get_feature_id(hidpp, featureset_index, + i, &(hidpp->features[i])); + + return ret; +} + /* -------------------------------------------------------------------------- */ /* 0x0005: GetDeviceNameType */ /* -------------------------------------------------------------------------- */ @@ -3625,6 +3704,17 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) hidpp_overwrite_name(hdev); } + /* Cache feature indexes and IDs to check reports faster */ + hidpp->feature_count = 0; + + if (hidpp->protocol_major >= 2) { + if (hidpp20_get_features(hidpp)) { + hid_err(hdev, "%s:hidpp20_get_features returned error\n", + __func__); + goto hid_hw_init_fail; + } + } + if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { ret = wtp_get_config(hidpp); if (ret) From patchwork Fri Oct 11 00:57:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mazin Rezk X-Patchwork-Id: 11184753 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 7F21B912 for ; Fri, 11 Oct 2019 00:58:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5FE692053B for ; Fri, 11 Oct 2019 00:58:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="xhN0fejB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727935AbfJKA6D (ORCPT ); Thu, 10 Oct 2019 20:58:03 -0400 Received: from mail-40130.protonmail.ch ([185.70.40.130]:62324 "EHLO mail-40130.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727584AbfJKA6D (ORCPT ); Thu, 10 Oct 2019 20:58:03 -0400 Date: Fri, 11 Oct 2019 00:57:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1570755479; bh=40ozhm8SAMu/Ca+SqfeDN4mOkL6t9KC8t8EHDPyCn0c=; h=Date:To:From:Cc:Reply-To:Subject:Feedback-ID:From; b=xhN0fejB9ReFC1TO16gDyD8ibJaaqJkpZL7gqIM7KlNtHThyiEZm/2iDmzfhbgCwE ahnmLjTCIyc+y/Z552MqBIcL4B0FoaBWaUPQJyIGWA9ZBPAq8v3Xm1EclfMiky1sBg uTX1sbQlY2whmccpqSsNBDgSKPMdTgRYYvKSEPnA= To: "linux-input@vger.kernel.org" From: Mazin Rezk Cc: "benjamin.tissoires@redhat.com" , "jikos@kernel.org" , "linux-kernel@vger.kernel.org" , =?utf-8?q?Fi?= =?utf-8?q?lipe_La=C3=ADns?= , "mnrzk@protonmail.com" Reply-To: Mazin Rezk Subject: [PATCH v4 4/4] HID: logitech: Support WirelessDeviceStatus connect events 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 On Saturday, October 5, 2019 9:05 PM, Mazin Rezk wrote: > This patch makes WirelessDeviceStatus (0x1d4b) events get detected as > connection events on devices with HIDPP_QUIRK_WIRELESS_DEVICE_STATUS. > > This quirk is currently an alias for HIDPP_QUIRK_CLASS_BLUETOOTH since > the added Bluetooth devices do not support regular connect events. No changes have been made to this patch in v4. Signed-off-by: Mazin Rezk --- drivers/hid/hid-logitech-hidpp.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) -- 2.23.0 diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 2062be922c08..b2b5fe2c74db 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -84,6 +84,7 @@ MODULE_PARM_DESC(disable_tap_to_click, /* 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_WIRELESS_DEVICE_STATUS HIDPP_QUIRK_CLASS_BLUETOOTH #define HIDPP_QUIRK_DELAYED_INIT HIDPP_QUIRK_NO_HIDINPUT @@ -406,9 +407,22 @@ static inline bool hidpp_match_error(struct hidpp_report *question, (answer->fap.params[0] == question->fap.funcindex_clientid); } -static inline bool hidpp_report_is_connect_event(struct hidpp_report *report) +#define HIDPP_PAGE_WIRELESS_DEVICE_STATUS 0x1d4b + +static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidpp, + struct hidpp_report *report) { - return (report->report_id == REPORT_ID_HIDPP_SHORT) && + if (hidpp->quirks & HIDPP_QUIRK_WIRELESS_DEVICE_STATUS) { + /* If feature is invalid, skip array check */ + if (report->fap.feature_index > hidpp->feature_count) + return false; + + return (hidpp->features[report->fap.feature_index] == + HIDPP_PAGE_WIRELESS_DEVICE_STATUS); + } + + return ((report->report_id == REPORT_ID_HIDPP_SHORT) || + (hidpp->quirks & HIDPP_QUIRK_MISSING_SHORT_REPORTS)) && (report->rap.sub_id == 0x41); } @@ -3157,7 +3171,7 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, } } - if (unlikely(hidpp_report_is_connect_event(report))) { + if (unlikely(hidpp_report_is_connect_event(hidpp, report))) { atomic_set(&hidpp->connected, !(report->rap.params[0] & (1 << 6))); if (schedule_work(&hidpp->work) == 0)