From: Werner Sembach <wse@tuxedocomputers.com>
To: Benjamin Tissoires <bentiss@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>, Lee Jones <lee@kernel.org>,
jikos@kernel.org, linux-kernel@vger.kernel.org,
Jelle van der Waa <jelle@vdwaa.nl>,
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
linux-input@vger.kernel.org, ojeda@kernel.org,
linux-leds@vger.kernel.org, Pavel Machek <pavel@ucw.cz>,
Gregor Riepl <onitake@gmail.com>
Subject: Re: In kernel virtual HID devices (was Future handling of complex RGB devices on Linux v3)
Date: Tue, 26 Mar 2024 17:57:57 +0100 [thread overview]
Message-ID: <9b5151f9-4d1c-401e-abb5-540097749b76@tuxedocomputers.com> (raw)
In-Reply-To: <vjd5xqgd2gsyz4ubgk6eusuyqdtxpdw6vogc5u537x2a245xcj@m2twppbxea4p>
Hi all,
Am 26.03.24 um 16:39 schrieb Benjamin Tissoires:
> On Mar 26 2024, Werner Sembach wrote:
>> Hi all,
>>
>> Am 25.03.24 um 19:30 schrieb Hans de Goede:
>>
>> [snip]
>>>>> If the kernel already handles the custom protocol into generic HID, the
>>>>> work for userspace is not too hard because they can deal with a known
>>>>> protocol and can be cross-platform in their implementation.
>>>>>
>>>>> I'm mentioning that cross-platform because SDL used to rely on the
>>>>> input, LEDs, and other Linux peculiarities and eventually fell back on
>>>>> using hidraw only because it's way more easier that way.
>>>>>
>>>>> The other advantage of LampArray is that according to Microsoft's
>>>>> document, new devices are going to support it out of the box, so they'll
>>>>> be supported out of the box directly.
>>>>>
>>>>> Most of the time my stance is "do not add new kernel API, you'll regret
>>>>> it later". So in that case, given that we have a formally approved
>>>>> standard, I would suggest to use it, and consider it your API.
>>>> The only new UAPI would be the use_leds_uapi switch to turn on/off the backwards compatibility.
> I have my reserves with such a kill switch (see below).
>
>>> Actually we don't even need that. Typically there is a single HID
>>> driver handling both keys and the backlight, so userspace cannot
>>> just unbind the HID driver since then the keys stop working.
> I don't think Werner meant unbinding the HID driver, just a toggle to
> enable/disable the basic HID core processing of LampArray.
>
>>> But with a virtual LampArray HID device the only functionality
>>> for an in kernel HID driver would be to export a basic keyboard
>>> backlight control interface for simple non per key backlight control
>>> to integrate nicely with e.g. GNOME's backlight control.
>> Don't forget that in the future there will be devices that natively support
>> LampArray in their firmware, so for them it is the same device.
> Yeah, the generic LampArray support will not be able to differentiate
> "emulated" devices from native ones.
>
>> Regards,
>>
>> Werner
>>
>>> And then when OpenRGB wants to take over it can just unbind the HID
>>> driver from the HID device using existing mechanisms for that.
> Again no, it'll be too unpredicted.
>
>>> Hmm, I wonder if that will not also kill hidraw support though ...
>>> I guess getting hidraw support back might require then also manually
>>> binding the default HID input driver. Bentiss any input on this?
> To be able to talk over hidraw you need a driver to be bound, yes. But I
> had the impression that LampArray would be supported by default in
> hid-input.c, thus making this hard to remove. Having a separate driver
> will work, but as soon as the LampArray device will also export a
> multitouch touchpad, we are screwed and will have to make a choice
> between LampArray and touch...
>
>>> Background info: as discussed earlier in the thread Werner would like
>>> to have a basic driver registering a /sys/class/leds/foo::kbd_backlight/
>>> device, since those are automatically supported by GNOME (and others)
>>> and will give basic kbd backlight brightness control in the desktop
>>> environment. This could be a simple HID driver for
>>> the hid_allocate_device()-ed virtual HID device, but userspace needs
>>> to be able to move that out of the way when it wants to take over
>>> full control of the per key lighting.
> Do we really need to entirely unregister the led class device? Can't we
> snoop on the commands and get some "mean value"?
>
>>> Regards,
>>>
>>> Hans
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> The control flow for the whole system would look something like this:
>>>>
>>>> - System boots
>>>>
>>>> - Kernel driver initializes keyboard (maybe stops rainbowpuke boot effects, sets brightness to a default value, or initializes a solid color)
>>>>
>>>> - systemd-backlight restores last keyboard backlight brightness
>>>>
>>>> - UPower sees sysfs leds entry and exposes it to DBus for DEs to do keyboard brightness handling
>>>>
>>>> - If the user wants more control they (auto-)start OpenRGB
>>>>
>>>> - OpenRGB disables sysfs leds entry via use_leds_uapi to prevent double control of the same device by UPower
>>>>
>>>> - OpenRGB directly interacts with hidraw device via LampArray API to give fine granular control of the backlight
>>>>
>>>> - When OpenRGB closes it should reenable the sysfs leds entry
> That's where your plan falls short: if OpenRGB crashes, or is killed it
> will not reset that bit.
>
> Next question: is OpenRGB supposed to keep the hidraw node opened all
> the time or not?
TBH I didn't look at the OpenRGB code yet and LampArray there is currently only
planned. I somewhat hope that until the kernel driver is ready someone else
already picked up implementing LampArray in OpenRGB.
>
> If it has to keep it open, we should be able to come up with a somewhat
> similar hack that we have with hid-steam: when the hidraw node is
> opened, we disable the kernel processing of LampArray. When the node is
> closed, we re-enable it.
>
> But that also means we have to distinguish steam/SDL from OpenRGB...
My first thought here also: What is if something else is reading hidraw devices?
Especially for hidraw devices that are not just LampArray.
>
> I just carefully read the LampArray spec. And it's simpler than what
> I expected. But the thing that caught my attention was that it's
> mentioned that there is no way for the host to query the current
> color/illumination of the LEDs when the mode is set to
> AutonomousMode=false. Which means that the kernel should be able to
> snoop into any commands sent from OpenRGB to the device, compute a mean
> value and update its internal state.
>
> Basically all we need is the "toggle" to put the led class in read-only
> mode while OpenRGB kicks in. Maybe given that we are about to snoop on
> the commands sent, we can detect that there is a LampArray command
> emitted, attach this information to the struct file * in hidraw, and
> then re-enable rw when that user closes the hidraw node.
I think a read-only mode is not part of the current led class UAPI. Also I don't
want to associate AutonomousMode=true with led class is used.
AutonomousMode=true could for example mean that it is controlled via keyboard
shortcuts that are directly handled in the keyboard firmware, aka a case where
you want neither OpenRGB nor led class make any writes to the keyboard.
Or AutonomousMode=true could mean that on a device that implements both a
LampArray interface as well as a proprietary legacy interface is currently
controlled via the proprietary legacy interface (a lot of which are supported by
OpenRGB).
Regards,
Werner
>
> Cheers,
> Benjamin
>
>>>> - System shutdown
>>>>
>>>> - Since OpenRGB reenables the sysfs leds entry, systemd-backlight can correctly store a brightness value for next boot
>>>>
>>>> Regards,
>>>>
>>>> Werner
>>>>
>>>>> Side note to self: I really need to resurrect the hidraw revoke series
>>>>> so we could export those hidraw node to userspace with uaccess through
>>>>> logind...
>>>>>
>>>>> Cheers,
>>>>> Benjamin
next prev parent reply other threads:[~2024-03-26 16:58 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-11 19:00 [PATCH] leds: rgb: Implement per-key keyboard backlight for several TUXEDO devices Werner Sembach
2023-10-11 19:21 ` Werner Sembach
2023-10-12 8:58 ` Pavel Machek
2023-10-12 10:02 ` Werner Sembach
2023-10-12 14:05 ` Pavel Machek
2023-10-12 16:35 ` Werner Sembach
2023-10-13 12:19 ` Pavel Machek
2023-10-13 14:38 ` Werner Sembach
2023-10-13 14:54 ` Implement per-key keyboard backlight as auxdisplay? Werner Sembach
2023-10-13 19:56 ` Pavel Machek
2023-10-13 20:03 ` Pavel Machek
2023-10-16 10:57 ` Miguel Ojeda
2023-10-23 11:40 ` Jani Nikula
2023-10-23 11:44 ` Miguel Ojeda
2023-11-20 20:53 ` Pavel Machek
2023-11-20 20:52 ` Pavel Machek
2023-11-21 11:33 ` Werner Sembach
2023-11-21 12:20 ` Hans de Goede
2023-11-21 13:29 ` Werner Sembach
2023-11-22 18:34 ` Hans de Goede
2023-11-27 10:59 ` Werner Sembach
2023-12-29 19:13 ` Werner Sembach
2024-01-17 15:26 ` Hans de Goede
2024-01-17 16:50 ` Userspace API for per key backlight for non HID (no hidraw) keyboards Hans de Goede
2024-01-17 19:03 ` Armin Wolf
2024-01-18 0:58 ` Werner Sembach
2024-01-18 17:45 ` Implement per-key keyboard backlight as auxdisplay? Pavel Machek
2024-01-18 22:32 ` Werner Sembach
2024-01-19 8:44 ` Hans de Goede
2024-01-19 10:51 ` Jani Nikula
2024-01-19 16:06 ` Werner Sembach
2024-01-19 18:33 ` Dmitry Torokhov
2024-01-19 22:14 ` Pavel Machek
2024-01-23 16:51 ` Werner Sembach
2024-01-19 16:04 ` Werner Sembach
2024-01-29 13:24 ` Hans de Goede
2024-01-30 11:12 ` Werner Sembach
2024-01-30 17:10 ` Hans de Goede
2024-01-30 18:09 ` Werner Sembach
2024-01-30 18:35 ` Hans de Goede
2024-01-30 19:08 ` Werner Sembach
2024-01-30 19:46 ` Hans de Goede
2024-01-31 11:41 ` Future handling of complex RGB devices on Linux Werner Sembach
2024-01-31 15:52 ` Roderick Colenbrander
2024-02-21 11:12 ` Future handling of complex RGB devices on Linux v2 Werner Sembach
2024-02-21 22:17 ` Pavel Machek
2024-02-22 9:04 ` Pekka Paalanen
2024-02-22 17:38 ` Pavel Machek
2024-02-23 8:53 ` Pekka Paalanen
2024-07-23 20:40 ` Keybaords with arrays of RGB LEDs was " Pavel Machek
2024-02-23 9:21 ` Thomas Zimmermann
2024-02-22 10:46 ` Hans de Goede
2024-02-22 11:38 ` Gregor Riepl
2024-02-22 12:39 ` Hans de Goede
2024-02-22 13:14 ` Future handling of complex RGB devices on Linux v3 Werner Sembach
2024-03-18 11:11 ` Hans de Goede
2024-03-19 15:18 ` Werner Sembach
2024-03-25 14:18 ` Hans de Goede
2024-03-25 17:01 ` Werner Sembach
2024-03-20 11:16 ` Werner Sembach
2024-03-20 11:33 ` Werner Sembach
2024-03-20 18:45 ` Werner Sembach
2024-03-25 14:25 ` In kernel virtual HID devices (was Future handling of complex RGB devices on Linux v3) Hans de Goede
2024-03-25 15:56 ` Benjamin Tissoires
2024-03-25 16:48 ` Werner Sembach
2024-03-25 18:30 ` Hans de Goede
2024-03-26 7:57 ` Werner Sembach
2024-03-26 15:39 ` Benjamin Tissoires
2024-03-26 16:57 ` Werner Sembach [this message]
2024-03-27 11:03 ` Benjamin Tissoires
2024-03-28 23:52 ` Werner Sembach
2024-03-27 11:01 ` Hans de Goede
2024-07-24 17:36 ` Pavel Machek
2024-07-24 21:08 ` Werner Sembach
2024-03-25 18:38 ` Miguel Ojeda
2024-04-09 13:33 ` Andy Shevchenko
2024-02-22 17:42 ` Future handling of complex RGB devices on Linux v2 Pavel Machek
2024-02-22 17:52 ` Pavel Machek
2024-02-22 17:23 ` Pavel Machek
2024-02-23 8:33 ` Werner Sembach
2024-01-19 20:15 ` Implement per-key keyboard backlight as auxdisplay? Pavel Machek
2024-01-19 20:22 ` Werner Sembach
2024-01-19 20:32 ` Pavel Machek
2024-01-29 13:24 ` Hans de Goede
2023-10-12 13:00 ` [PATCH] leds: rgb: Implement per-key keyboard backlight for several TUXEDO devices kernel test robot
2023-10-16 11:21 ` kernel test robot
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=9b5151f9-4d1c-401e-abb5-540097749b76@tuxedocomputers.com \
--to=wse@tuxedocomputers.com \
--cc=bentiss@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hdegoede@redhat.com \
--cc=jelle@vdwaa.nl \
--cc=jikos@kernel.org \
--cc=lee@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ojeda@kernel.org \
--cc=onitake@gmail.com \
--cc=pavel@ucw.cz \
/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
all inboxes | Powered by JetHome®