All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Mazin Rezk <mnrzk@protonmail.com>
Cc: "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"jikos@kernel.org" <jikos@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Filipe Laíns" <lains@archlinux.org>
Subject: Re: [PATCH v7 1/3] HID: logitech-hidpp: Support translations from short to long reports
Date: Tue, 22 Oct 2019 12:15:09 +0200	[thread overview]
Message-ID: <CAO-hwJKmZX8MksRvXC=iyG_eaDxmr3N4tRM_moACxX1aNYSokg@mail.gmail.com> (raw)
In-Reply-To: <rzUqln0ASGmn_QTpqCkke6UzMFQDj2H7fIngMOxQwtiX52PkWc_BbxkGy4XcIm7kaVcQHwAYhO7ITZoMotLSHw_2WZre9_QJBDhXoMPTLsw=@protonmail.com>

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 represents
> 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.

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-logitech-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 hidpp_device *hidpp_dev,
>         struct hidpp_report *message;
>         int ret, max_count;
>
> +       /* Send as long report if short reports are not supported. */
> +       if (report_id == REPORT_ID_HIDPP_SHORT &&
> +           !(hidpp_dev->supported_reports & HIDPP_REPORT_SHORT_SUPPORTED))
> +               report_id = REPORT_ID_HIDPP_LONG;
> +
>         switch (report_id) {
>         case REPORT_ID_HIDPP_SHORT:
>                 max_count = HIDPP_REPORT_SHORT_LENGTH - 4;
> @@ -3458,10 +3468,11 @@ static int hidpp_get_report_length(struct hid_device *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 = hid_get_drvdata(hdev);
> -       int id, report_length, supported_reports = 0;
> +       int id, report_length;
> +       u8 supported_reports = 0;
>
>         id = REPORT_ID_HIDPP_SHORT;
>         report_length = hidpp_get_report_length(hdev, id);
> @@ -3469,7 +3480,7 @@ static bool hidpp_validate_device(struct hid_device *hdev)
>                 if (report_length < HIDPP_REPORT_SHORT_LENGTH)
>                         goto bad_device;
>
> -               supported_reports++;
> +               supported_reports |= HIDPP_REPORT_SHORT_SUPPORTED;
>         }
>
>         id = REPORT_ID_HIDPP_LONG;
> @@ -3478,7 +3489,7 @@ static bool hidpp_validate_device(struct hid_device *hdev)
>                 if (report_length < HIDPP_REPORT_LONG_LENGTH)
>                         goto bad_device;
>
> -               supported_reports++;
> +               supported_reports |= HIDPP_REPORT_LONG_SUPPORTED;
>         }
>
>         id = REPORT_ID_HIDPP_VERY_LONG;
> @@ -3488,7 +3499,7 @@ static bool hidpp_validate_device(struct hid_device *hdev)
>                     report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH)
>                         goto bad_device;
>
> -               supported_reports++;
> +               supported_reports |= HIDPP_REPORT_VERY_LONG_SUPPORTED;
>                 hidpp->very_long_report_length = report_length;
>         }
>
> @@ -3536,7 +3547,9 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
>         /*
>          * Make sure the device is HID++ capable, otherwise treat as generic HID
>          */
> -       if (!hidpp_validate_device(hdev)) {
> +       hidpp->supported_reports = 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
>


  reply	other threads:[~2019-10-22 10:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-20  4:41 [PATCH v7 1/3] HID: logitech-hidpp: Support translations from short to long reports Mazin Rezk
2019-10-22 10:15 ` Benjamin Tissoires [this message]
2019-10-22 17:16   ` Mazin Rezk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAO-hwJKmZX8MksRvXC=iyG_eaDxmr3N4tRM_moACxX1aNYSokg@mail.gmail.com' \
    --to=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=lains@archlinux.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mnrzk@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.