Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2688873ybp; Sat, 5 Oct 2019 18:07:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVdXcaFeZUj+5kfzf/W1ixxB8eibDW5ev6hV+TAA09p3JJrPGZKWDWAJDuY+yQ3NImKUjV X-Received: by 2002:a05:6402:1e4:: with SMTP id i4mr22712695edy.31.1570324063301; Sat, 05 Oct 2019 18:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570324063; cv=none; d=google.com; s=arc-20160816; b=E/XlKFnqAKLc0pmTetIusEB/rWMOeY7Z+eKqtKi7cd4bwvsxPmF7/VA8Sq5qo/YvuJ EJpjvUdHtl1ENDLLqwKo7XeEzn6Q4zvrEt6DbzE9YJZ/7ihW4h5XFBvHdUi/xgs9UCTh LQ/81mhxDy8LOEAl9EoivsiBVGXMEIJpZdmY53yxTI6kKL1NkUC6oN5+s93HQFT+nVl3 htT0WXFR9JLbEzy+N4TBYK8eWcY2zasVk5Z0yyWlR/rxygBcNRFOAa6QANQjgBZOGngs ld/3clRPbs9q3OXXgoU4kgPmS55gblC1t6M/4O2dutfzKjGknCoGh4OuQWgftmndVKbY lC3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :feedback-id:message-id:subject:reply-to:cc:from:to:dkim-signature :date; bh=nQLWuVtTWGi9TtxUQovyksAthP1snzF6VdySnTPCXW0=; b=Uqm5vc/D9/2itTf4rrByZ8Em1+C/3aSdWItQkMF8de1qG9iWbKWE+k8Ubvgupl4PtD FNPLFnuyjjDufE64FKGov3RrUqgqneRKdrR6rQCb/PiGay5PT9DQF1wss6RRpxPhPcNS kfAVBthV2gV+qtSrnppfAXlaONWN8RMHuYF8jfCQ5x3g44yLYw0FDwGtuZPgPbtMUTVI KdujvTLTOBev3aTu3ha7kH+LeRDMte5iyz/3LtiP/e2BEaTMfScb1pftOJ/9Bf3pRmpz FVqBvkv7y7f8w8pUGmjjhKXROOBegNDJ1qXAfJApggT+f91MY0O4KAaAKNv9uGmvvGD/ U7QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=default header.b=rkZ0XkGy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h20si6006580edb.218.2019.10.05.18.07.19; Sat, 05 Oct 2019 18:07:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@protonmail.com header.s=default header.b=rkZ0XkGy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727133AbfJFBFU (ORCPT + 99 others); Sat, 5 Oct 2019 21:05:20 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hi= dpp.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=09HIDPP_QUIRK_CLASS_BLUETOOTH +#define HIDPP_QUIRK_WIRELESS_DEVICE_STATUS=09HIDPP_QUIRK_CLASS_BLUETOOTH #define HIDPP_QUIRK_DELAYED_INIT=09=09HIDPP_QUIRK_NO_HIDINPUT @@ -406,9 +407,22 @@ static inline bool hidpp_match_error(struct hidpp_repo= rt *question, =09 (answer->fap.params[0] =3D=3D question->fap.funcindex_clientid); } -static inline bool hidpp_report_is_connect_event(struct hidpp_report *repo= rt) +#define HIDPP_PAGE_WIRELESS_DEVICE_STATUS=09=090x1d4b + +static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidp= p, +=09=09=09=09=09=09 struct hidpp_report *report) { -=09return (report->report_id =3D=3D REPORT_ID_HIDPP_SHORT) && +=09if (hidpp->quirks & HIDPP_QUIRK_WIRELESS_DEVICE_STATUS) { +=09=09/* If feature is invalid, skip array check */ +=09=09if (report->fap.feature_index > hidpp->feature_count) +=09=09=09return false; + +=09=09return (hidpp->features[report->fap.feature_index] =3D=3D +=09=09=09 HIDPP_PAGE_WIRELESS_DEVICE_STATUS); +=09} + +=09return ((report->report_id =3D=3D REPORT_ID_HIDPP_SHORT) || +=09=09(hidpp->quirks & HIDPP_QUIRK_MISSING_SHORT_REPORTS)) && =09=09(report->rap.sub_id =3D=3D 0x41); } @@ -3159,7 +3173,7 @@ static int hidpp_raw_hidpp_event(struct hidpp_device = *hidpp, u8 *data, =09=09} =09} -=09if (unlikely(hidpp_report_is_connect_event(report))) { +=09if (unlikely(hidpp_report_is_connect_event(hidpp, report))) { =09=09atomic_set(&hidpp->connected, =09=09=09=09!(report->rap.params[0] & (1 << 6))); =09=09if (schedule_work(&hidpp->work) =3D=3D 0) -- 2.23.0