Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5941497ybg; Tue, 22 Oct 2019 10:33:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXiWtdMQp1OsCa04PKtEhwPKLOWQ8540qDJqTRh7IaS6COccZ4F554eqwAesgH3BnRifTV X-Received: by 2002:a17:906:6844:: with SMTP id a4mr723633ejs.102.1571765631166; Tue, 22 Oct 2019 10:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571765631; cv=none; d=google.com; s=arc-20160816; b=hG12foRrKRvX7gkWFcSREKVT54mAyuGjo+aZdp+nQCh/sIw7KXiX/QoC0HlSR+j81q 48mq3GylvAMyTZhFzQOhtyKZJkl6NDiNpwsBdJPuDSgm5W+tBavHIrG7e8Qzf5CAyeVc nTdDz6f8+HboWKpSiTWOvU+6Kt3FJp1nCsDVtktp7xg3axZ8IoCrL9wboVhHHJfwH5dz 51X7UOCT5b3/BKmieFlb92OkafQWd6ImPj5D/ATCSRdPnpW6OoFPLwY/5dYn8t/b9jJe fpqB7LOFjo155NxOzIgDM47nJDnrJpni+LZ3r5SrYdb9wlnVC0WzzzlXgNo5r6DAqTSC xaDA== 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:references:in-reply-to:message-id:subject:reply-to:cc :from:to:dkim-signature:date; bh=RgAmevJJ1qewaLeg/leiJzsVk2HdOJ+IKFqOdpfGz6U=; b=OoZ0rWBSQ+AS8QNCXJIZaITxH5BVMbMzp+R1p2/b7xeT1raqWKZuURngxCsCaIHRbw mo0Nby0kED/41xRIacD2xaBI05aF/3lbO8SU8DfuxAKAAiDiKzCzYyQJvt+4LTPJtLV+ X0ar2qxXQYF8jN1ImvsLMAFM4sR7NNu+EbuH6FQWl1ZRNGCcUpxI0CKCM0a3g/sjre3D tSrz4Vw+T12g7U+tepmIAYTA3NrnHTpVuBo6fT92LP9wF4pGj2wQAzH6Qu0lBHK+a2dc IOhV3LxQDk+uEBaA9dfg3LWrfc0yYYw1zk+gcv8Pd+w4fy+nlnN14Rs2U1TKeZ7r8dDr 9DnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=default header.b=tlZcCGJ7; 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 g21si12345388edm.116.2019.10.22.10.33.27; Tue, 22 Oct 2019 10:33:51 -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=tlZcCGJ7; 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 S2387441AbfJVRQv (ORCPT + 99 others); Tue, 22 Oct 2019 13:16:51 -0400 Received: from mail-40133.protonmail.ch ([185.70.40.133]:20941 "EHLO mail-40133.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730379AbfJVRQv (ORCPT ); Tue, 22 Oct 2019 13:16:51 -0400 Date: Tue, 22 Oct 2019 17:16:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1571764607; bh=RgAmevJJ1qewaLeg/leiJzsVk2HdOJ+IKFqOdpfGz6U=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References: Feedback-ID:From; b=tlZcCGJ7+W3I/BSSnuRSnrjZLTISv0g0mwES0rqy5n3Go0WxVIyrb3AdIQ2OXASEf keIzsAStniqfBzZjcyU4rM0s224GNSFHx2RtKDEi/l//2ZtamN319VRtfguPkvZwHO FxA2d+N1Smd9plLyIYotG/AppwSLh4oZYg0hSdOA= To: Benjamin Tissoires From: Mazin Rezk Cc: "linux-input@vger.kernel.org" , "jikos@kernel.org" , "linux-kernel@vger.kernel.org" , =?UTF-8?Q?Filipe_La=C3=ADns?= , "mnrzk@protonmail.com" Reply-To: Mazin Rezk Subject: Re: [PATCH v7 1/3] HID: logitech-hidpp: Support translations from short to long reports Message-ID: In-Reply-To: References: 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 On Tuesday, October 22, 2019 6:15 AM, Benjamin Tissoires wrote: > Hi Mazin, > > On Sun, Oct 20, 2019 at 6:41 AM Mazin Rezk mnrzk@protonmail.com wrote: > > > This patch allows short reports to be translated into long reports. > > hidpp_validate_device now returns a u8 instead of a bool which represen= ts > > the supported reports. The corresponding bits (i.e. > > HIDPP_REPORT_*_SUPPORTED) are set if an HID++ report is supported. > > If a short report is being sent and the device does not support it, it = is > > instead sent as a long report. > > Thanks, > > Mazin > > > > Signed-off-by: Mazin Rezk mnrzk@protonmail.com > > > > ----------------------------------------------- > > Yep, I like this patch much better. > > I also tested the 0xb012 MX Master, and it now works like a charm :) > > nitpick: can you squash the next patch into this one? Because to be > useful, this patch really need one or 2 supported devices. I'll do that in v8 but I'm just going to wait until this patch is tested more so I can see what other changes I need to make before the patch is finalised. Thanks, Mazin > > Cheers, > Benjamin > > > drivers/hid/hid-logitech-hidpp.c | 25 +++++++++++++++++++------ > > 1 file changed, 19 insertions(+), 6 deletions(-) > > diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitec= h-hidpp.c > > index e9bba282f9c1..ee604b17514f 100644 > > --- a/drivers/hid/hid-logitech-hidpp.c > > +++ b/drivers/hid/hid-logitech-hidpp.c > > @@ -49,6 +49,10 @@ MODULE_PARM_DESC(disable_tap_to_click, > > #define HIDPP_REPORT_LONG_LENGTH 20 > > #define HIDPP_REPORT_VERY_LONG_MAX_LENGTH 64 > > +#define HIDPP_REPORT_SHORT_SUPPORTED BIT(0) > > +#define HIDPP_REPORT_LONG_SUPPORTED BIT(1) > > +#define HIDPP_REPORT_VERY_LONG_SUPPORTED BIT(2) > > + > > #define HIDPP_SUB_ID_CONSUMER_VENDOR_KEYS 0x03 > > #define HIDPP_SUB_ID_ROLLER 0x05 > > #define HIDPP_SUB_ID_MOUSE_EXTRA_BTNS 0x06 > > @@ -183,6 +187,7 @@ struct hidpp_device { > > > > unsigned long quirks; > > unsigned long capabilities; > > > > > > - u8 supported_reports; > > > > struct hidpp_battery battery; > > struct hidpp_scroll_counter vertical_wheel_counter; > > > > > > > > @@ -340,6 +345,11 @@ static int hidpp_send_rap_command_sync(struct hidp= p_device *hidpp_dev, > > struct hidpp_report *message; > > int ret, max_count; > > > > - /* Send as long report if short reports are not supported. */ > > > > > > - if (report_id =3D=3D REPORT_ID_HIDPP_SHORT && > > > > > > - !(hidpp_dev->supported_reports & HIDPP_REPORT_SHORT_SUPPO= RTED)) > > > > > > - report_id =3D REPORT_ID_HIDPP_LONG; > > > > > > - switch (report_id) { > > case REPORT_ID_HIDPP_SHORT: > > max_count =3D HIDPP_REPORT_SHORT_LENGTH - 4; > > > > > > > > @@ -3458,10 +3468,11 @@ static int hidpp_get_report_length(struct hid_d= evice *hdev, int id) > > return report->field[0]->report_count + 1; > > } > > -static bool hidpp_validate_device(struct hid_device *hdev) > > +static u8 hidpp_validate_device(struct hid_device *hdev) > > { > > struct hidpp_device *hidpp =3D hid_get_drvdata(hdev); > > > > - int id, report_length, supported_reports =3D 0; > > > > > > > > - int id, report_length; > > > > > > - u8 supported_reports =3D 0; > > > > id =3D REPORT_ID_HIDPP_SHORT; > > report_length =3D hidpp_get_report_length(hdev, id); > > > > > > > > @@ -3469,7 +3480,7 @@ static bool hidpp_validate_device(struct hid_devi= ce *hdev) > > if (report_length < HIDPP_REPORT_SHORT_LENGTH) > > goto bad_device; > > > > - supported_reports++; > > > > > > > > - supported_reports |=3D HIDPP_REPORT_SHORT_SUPPORTED; > > } > > > > id =3D REPORT_ID_HIDPP_LONG; > > > > > > > > @@ -3478,7 +3489,7 @@ static bool hidpp_validate_device(struct hid_devi= ce *hdev) > > if (report_length < HIDPP_REPORT_LONG_LENGTH) > > goto bad_device; > > > > - supported_reports++; > > > > > > > > - supported_reports |=3D HIDPP_REPORT_LONG_SUPPORTED; > > } > > > > id =3D REPORT_ID_HIDPP_VERY_LONG; > > > > > > > > @@ -3488,7 +3499,7 @@ static bool hidpp_validate_device(struct hid_devi= ce *hdev) > > report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH) > > goto bad_device; > > > > - supported_reports++; > > > > > > > > - supported_reports |=3D HIDPP_REPORT_VERY_LONG_SUPPORT= ED; > > hidpp->very_long_report_length =3D report_length; > > } > > > > > > > > @@ -3536,7 +3547,9 @@ static int hidpp_probe(struct hid_device *hdev, c= onst struct hid_device_id id) > > /* Make sure the device is HID++ capable, otherwise treat as generic HI= D > > */ > > > > - if (!hidpp_validate_device(hdev)) { > > > > > > > > - hidpp->supported_reports =3D hidpp_validate_device(hdev); > > > > > > - > > - if (!hidpp->supported_reports) { > > hid_set_drvdata(hdev, NULL); > > devm_kfree(&hdev->dev, hidpp); > > return hid_hw_start(hdev, HID_CONNECT_DEFAULT); > > > > > > > > -- > > 2.23.0