From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Jiri Kosina <jikos@kernel.org>,
Peter Hutterer <peter.hutterer@who-t.net>,
Sean O'Brien <seobrien@chromium.org>,
"open list:HID CORE LAYER" <linux-input@vger.kernel.org>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] HID: hid-input: avoid splitting keyboard, system and consumer controls
Date: Thu, 14 Jan 2021 10:43:45 -0800 [thread overview]
Message-ID: <YACQ4aPfH8y+9gkK@google.com> (raw)
In-Reply-To: <CAO-hwJK5QxxX26hFiVfQr2EfnwdZSEB2paCsZBbX58iPxJvfww@mail.gmail.com>
Hi Benjamin,
On Thu, Jan 14, 2021 at 10:23:02AM +0100, Benjamin Tissoires wrote:
> Hi Dmitry,
>
> On Thu, Jan 14, 2021 at 7:24 AM Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> >
> > A typical USB keyboard usually splits its keys into several reports:
> >
> > - one for the basic alphanumeric keys, modifier keys, F<n> keys, six pack
> > keys and keypad. This report's application is normally listed as
> > GenericDesktop.Keyboard
> > - a GenericDesktop.SystemControl report for the system control keys, such
> > as power and sleep
> > - Consumer.ConsumerControl report for multimedia (forward, rewind,
> > play/pause, mute, etc) and other extended keys.
> > - additional output, vendor specific, and feature reports
> >
> > Splitting each report into a separate input device is wasteful and even
> > hurts userspace as it makes it harder to determine the true capabilities
> > (set of available keys) of a keyboard, so let's adjust application
> > matching to merge system control and consumer control reports with
> > keyboard report, if one has already been processed.
> >
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> > drivers/hid/hid-input.c | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> > index f797659cb9d9..df45d8d07dc2 100644
> > --- a/drivers/hid/hid-input.c
> > +++ b/drivers/hid/hid-input.c
> > @@ -1851,6 +1851,16 @@ static struct hid_input *hidinput_match_application(struct hid_report *report)
> > list_for_each_entry(hidinput, &hid->inputs, list) {
> > if (hidinput->application == report->application)
> > return hidinput;
> > +
> > + /*
> > + * Keep SystemControl and ConsumerControl applications together
> > + * with the main keyboard, if present.
> > + */
> > + if ((report->application == HID_GD_SYSTEM_CONTROL ||
> > + report->application == HID_CP_CONSUMER_CONTROL) &&
> > + hidinput->application == HID_GD_KEYBOARD) {
>
> I am not fundamentally against the patch, but I think that if the
> device exposes first a HID_CP_CONSUMER_CONTROL and then a
> HID_GD_KEYBOARD we will end up with 2 different input nodes. We likely
> need to "convert" HID_GD_SYSTEM_CONTROL and HID_CP_CONSUMER_CONTROL to
> HID_GD_KEYBOARD when creating the hidinput.
While it is technically possible that consumer control or system control
comes first, before main keyboard report, in reality all keyboards that
I have seen so far have the main keyboard report first, so I opted not
to handle the uncommon case to keep the code simple.
I could add the above as a comment, and we could wait to see if there
are devices that are exceptions to the common practice, or I can go and
try to implement the conversion if you feel it is required. Please let
me know.
Note that we will still end up with 2+ input nodes if a device uses
several USB interfaces, but we can't really do much about such cases
(well, short of having a specialized driver claiming additional
interfaces while probing the first one, but that is really outside of
scope of this patch).
Thanks!
--
Dmitry
next prev parent reply other threads:[~2021-01-14 18:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 6:24 [PATCH] HID: hid-input: avoid splitting keyboard, system and consumer controls Dmitry Torokhov
2021-01-14 9:23 ` Benjamin Tissoires
2021-01-14 18:43 ` Dmitry Torokhov [this message]
2021-01-15 4:44 ` Peter Hutterer
2021-02-02 10:15 ` Jiri Kosina
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=YACQ4aPfH8y+9gkK@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.hutterer@who-t.net \
--cc=seobrien@chromium.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox