Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2086112ybg; Sun, 27 Oct 2019 10:46:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTncUyxdQIDmI+eZyFDp6eGNPTBDPway5UUK7SjUkIR1gQg/0b4fF8pRVwrurBhfVuCPIS X-Received: by 2002:a17:906:1d59:: with SMTP id o25mr13264889ejh.115.1572198419074; Sun, 27 Oct 2019 10:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572198419; cv=none; d=google.com; s=arc-20160816; b=XU+c6Bd+zvi7P82/QU1h1Q1aEWH0KRUVcKUm9OhcLVKaXPd040ygn8318CN21oNGA6 ULxAdjjsRR7D81zd+gLDbv+NRZH+LZYhzINTA8RHLA0VaWRYZtJA9ssIdDlvDXsb32lt UAA75vmCxOFKsM7ZVZ7/WZ3fhj/SOFbE28/zQTpyg5zuxNzzwUjOrGqpABSOI4yqwXh9 HXVQfqHdYlV/9RDyk8Lod3YupAUWNGR+n8/AN+4bSxacXBu+lQ8jFlYXIwgygjj1Ue0C 2VGS51BXcf9kPDyPp8FMwKnwlBrE47q/q91HT7vX1OYUp+AveXLuI3E3qhGjwKdCy1qd qmfQ== 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=6yiWG/CL7XyQLz0voQvVHgInV2wrBSXgCFAj8egaYM4=; b=nAoAX7d6gNPM2K1ikaCLAUpXL2gGX3gzJ4693VbSB/0XKi2IcmDZOdQAqrlhKjcAKV 0HPWC/4MOuYrLKzmm0Dc1MrgwBUY1lwtTW1JpZvOAQu4L8emBMLsT522l4wDEl4zNoE4 tbB+WtvU3cLjm8ZzugFY0GEXN6KqnvWx9OOMhe9oOsQjP7y0mNCUj5gwCPaITio7QOQK 4LAhAak6+C/LBXiQzNXlfJrKQJgefY9PHyEPtVnIJUaupH6vAQ+wN21JyGyjHZ+fr4jM NQViCHguseLjhP3/cFGhYsnAxeYgd5B24SjOq+hhwbL6nGhcn7UgZHb4nnfjFlPA4ikw g7mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=default header.b=t89UEWkz; 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 k15si4848182eja.412.2019.10.27.10.46.35; Sun, 27 Oct 2019 10:46:59 -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=t89UEWkz; 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 S1727911AbfJ0Ro2 (ORCPT + 99 others); Sun, 27 Oct 2019 13:44:28 -0400 Received: from mail-40135.protonmail.ch ([185.70.40.135]:27742 "EHLO mail-40135.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727607AbfJ0Ro2 (ORCPT ); Sun, 27 Oct 2019 13:44:28 -0400 Date: Sun, 27 Oct 2019 17:44:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1572198264; bh=6yiWG/CL7XyQLz0voQvVHgInV2wrBSXgCFAj8egaYM4=; h=Date:To:From:Cc:Reply-To:Subject:Feedback-ID:From; b=t89UEWkzcW7FHkAjnYgDbtcUE65v1C9Q1KfdK6LSEEXdCUWGIn0PywQWW+rr156CV dZLy4cQMpPld0CUBdkHhce5/XzuJSqzi0vFFRdqpIVNAodCbwnnDqE6piAI8VKFkd7 ikMM+ewLrMCFerWwO/IOi8p0aXaVVEbk7fmEI8k8= To: "linux-input@vger.kernel.org" From: Mazin Rezk Cc: Benjamin Tissoires , "jikos@kernel.org" , "linux-kernel@vger.kernel.org" , =?UTF-8?Q?Filipe_La=C3=ADns?= , "adrian@freund.io" , "mnrzk@protonmail.com" Reply-To: Mazin Rezk Subject: [PATCH v8 2/2] HID: logitech-hidpp: Support WirelessDeviceStatus connect events Message-ID: <8digbnSpZ_FnleD2ei0nz-dB_rb8IuSFeYLUimi3LnWfQeYriniOHIZM9GKGz2-NEMDgMSXG1XFhuqTKzUt818yNTkfCF5oVVpe6LsgYkWs=@protonmail.com> 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 allows hidpp_report_is_connect_event to support WirelessDeviceStatus connect events. The WirelessDeviceStatus feature index is stored in hidpp_device when probed. The connect event's fap feature_index is compared against it if the device supports it. Signed-off-by: Mazin Rezk --- drivers/hid/hid-logitech-hidpp.c | 39 ++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hi= dpp.c index 19b315e4e91b..c8b23568d0b1 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -191,6 +191,8 @@ struct hidpp_device { =09struct hidpp_battery battery; =09struct hidpp_scroll_counter vertical_wheel_counter; + +=09u8 wireless_feature_index; }; /* HID++ 1.0 error codes */ @@ -403,10 +405,13 @@ static inline bool hidpp_match_error(struct hidpp_rep= ort *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) +static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidp= p, +=09=09struct hidpp_report *report) { -=09return (report->report_id =3D=3D REPORT_ID_HIDPP_SHORT) && -=09=09(report->rap.sub_id =3D=3D 0x41); +=09return (hidpp->wireless_feature_index && +=09=09(report->fap.feature_index =3D=3D hidpp->wireless_feature_index)) || +=09=09((report->report_id =3D=3D REPORT_ID_HIDPP_SHORT) && +=09=09(report->rap.sub_id =3D=3D 0x41)); } /** @@ -1283,6 +1288,24 @@ static int hidpp_battery_get_property(struct power_s= upply *psy, =09return ret; } +/* -----------------------------------------------------------------------= --- */ +/* 0x1d4b: Wireless device status = */ +/* -----------------------------------------------------------------------= --- */ +#define HIDPP_PAGE_WIRELESS_DEVICE_STATUS=09=09=090x1d4b + +static int hidpp_set_wireless_feature_index(struct hidpp_device *hidpp) +{ +=09u8 feature_type; +=09int ret; + +=09ret =3D hidpp_root_get_feature(hidpp, +=09=09=09=09 HIDPP_PAGE_WIRELESS_DEVICE_STATUS, +=09=09=09=09 &hidpp->wireless_feature_index, +=09=09=09=09 &feature_type); + +=09return ret; +} + /* -----------------------------------------------------------------------= --- */ /* 0x2120: Hi-resolution scrolling = */ /* -----------------------------------------------------------------------= --- */ @@ -3078,7 +3101,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) @@ -3628,6 +3651,14 @@ static int hidpp_probe(struct hid_device *hdev, cons= t struct hid_device_id *id) =09=09hidpp_overwrite_name(hdev); =09} +=09if (connected && hidpp->protocol_major >=3D 2) { +=09=09ret =3D hidpp_set_wireless_feature_index(hidpp); +=09=09if (ret =3D=3D -ENOENT) +=09=09=09hidpp->wireless_feature_index =3D 0; +=09=09else if (ret) +=09=09=09goto hid_hw_init_fail; +=09} + =09if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { =09=09ret =3D wtp_get_config(hidpp); =09=09if (ret) -- 2.23.0