From patchwork Sun Oct 6 01:05:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mazin Rezk X-Patchwork-Id: 11175961 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 C684D112B for ; Sun, 6 Oct 2019 01:05:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5320222CB for ; Sun, 6 Oct 2019 01:05:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="rkZ0XkGy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727126AbfJFBFT (ORCPT ); Sat, 5 Oct 2019 21:05:19 -0400 Received: from mail-40135.protonmail.ch ([185.70.40.135]:18794 "EHLO mail-40135.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726986AbfJFBFT (ORCPT ); Sat, 5 Oct 2019 21:05:19 -0400 Date: Sun, 06 Oct 2019 01:05:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1570323916; bh=nQLWuVtTWGi9TtxUQovyksAthP1snzF6VdySnTPCXW0=; h=Date:To:From:Cc:Reply-To:Subject:Feedback-ID:From; b=rkZ0XkGygESKNUBeUHoKz3tecOzx4f9NuHe/XR1nnLvFdm6r+3BbNQfqYz6PTWdb/ LXOsi7ZdKE3vDgL2TZ8Kt1O30nF6XDvqM2iH1sIW2ufXBEHsxPZwBD4FWCJr96BXq3 KdrM/X4JmcRNllx68MXPjnkN8AkSZzthgh62rDjk= 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 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 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. 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 64ac94c581aa..4a6e41c2c9fc 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); } @@ -3159,7 +3173,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)