From: Hans de Goede <hdegoede@redhat.com>
To: Werner Sembach <wse@tuxedocomputers.com>,
Pavel Machek <pavel@ucw.cz>,
Jani Nikula <jani.nikula@linux.intel.com>,
jikos@kernel.org, Jelle van der Waa <jelle@vdwaa.nl>
Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
Lee Jones <lee@kernel.org>,
linux-kernel@vger.kernel.org,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
linux-input@vger.kernel.org, ojeda@kernel.org,
linux-leds@vger.kernel.org
Subject: Re: Implement per-key keyboard backlight as auxdisplay?
Date: Wed, 17 Jan 2024 16:26:37 +0100 [thread overview]
Message-ID: <8d77246d-ec1f-4106-8a33-b6e93bdbab45@redhat.com> (raw)
In-Reply-To: <ac02143c-d417-49e5-9c6e-150cbda71ba7@tuxedocomputers.com>
Hi Werner,
Once again, sorry for the very slow response here.
On 11/27/23 11:59, Werner Sembach wrote:
> Hi Hans,
>
> Am 22.11.23 um 19:34 schrieb Hans de Goede:
>> Hi Werner,
> [snip]
>>>>> Another idea I want to throw in the mix:
>>>>>
>>>>> Maybe the kernel is not the right place to implement this at all. RGB stuff is not at all standardized and every vendor is doing completely different interfaces, which does not fit the kernel userpsace apis desire to be uniformal and fixed. e.g. Auxdisplay might fit static setting of RGB values, but it does not fit the snake-effect mode, or the raindrops mode, or the 4-different-colors-in-the-edges-breathing-and-color-cycling mode.
>>>>>
>>>>> So my current idea: Implement these keyboards as a single zone RGB kbd_backlight in the leds interface to have something functional out of the box, but make it runtime disable-able if something like https://gitlab.com/CalcProgrammer1/OpenRGB wants to take over more fine granular control from userspace via hidraw.
>>>> That sounds like a good approach to me. We are seeing the same with game controllers where steam and wine/proton also sometimes use hidraw mode to get access to all the crazy^W interesting features.
>>>>
>>>> That would mean that all we need to standardize and the kernel <-> userspace API level is adding a standard way to disable the single zone RGB kbd_backlight support in the kernel.
>>> I would suggest a simple "enable" entry. Default is 1. When set to 0 the kernel driver no longer does anything.
>> I'm not in favor of using "enable" as sysfs attribute for this,
>> I would like to see a more descriptive name, how about:
>>
>> "disable_kernel_kbd_backlight_support"
>>
>> And then maybe also have the driver actually unregister
>> the LED class device ?
>>
>> Or just make the support inactive when writing 1 to
>> this and allow re-enabling it by writing 0?
>
> Unregistering would mean that it can't be reenabled without module reload/reboot?
Yes.
> I would prefer that the userspace driver could easily give back control to the leds interface.
Hmm, the problem here is that leaving a non-working LED class device
behind may confuse things like upower.
So maybe the disable_kbd_backlight_support sysfs attr should
not sit under /sys/class/leds/foobar::kbd_backlight, but rather
it should sit under the sysfs dir of the parent-device ?
So if we are talking [USB|I2C]-HID keyboards and userspace
using hidraw to takeover kbd_backlight control through,
then have "disable_kbd_backlight_support" sit under
/sys/bus/hid/devices/0003:xxxx:xxxx.xxxx/disable_kbd_backlight_support
and then re-register the LED class device for the keyboard
when 0 gets written to disable_kbd_backlight_support ?
That seems better to me then leaving a non-working LED
class device behind and this will not require any changes
to the LED subsystem.
>>> Questions:
>>>
>>> - Should the driver try to reset the settings to boot default? Or just leave the device in the current state? With the former I could see issues that they keyboard is flashing when changing from kernelspace control to userspace control. With the later the burden on bringing the device to a know state lies with the userspace driver.
>> My vote would go to leave the state as is. Even if the hw
>> does not support state readback, then the userspace code
>> can readback the state before writing 1 to
>> "disable_kernel_kbd_backlight_support"
> ack
>>
>>> - Should this be a optional entry that only shows up on drivers supporting it, or could this implemented in a generic way affecting all current led entries?
>> IMHO this should be optional. If we go with the variant
>> where writing 1 to "disable_kernel_kbd_backlight_support"
>> just disables support and 0 re-enables it then I guess
>> we could have support for this in the LED-core, enabled
>> by a flag set by the driver.
>>
>> If we go with unregistering the led class device,
>> then this needs to be mostly handled in the driver.
>>
>> Either way the kernel driver should know about this even
>> if it is mostly handled in the LED core so that e.g.
>> it does not try to restore settings on resume from suspend.
>
> So a generic implementation would still require all current led drivers to be touched?
>
> For the sake of simplicity I would then prefer the optional variant.
See above, I think we need to put the sysfs-attr to disable
the kernel's builtin kbd-backlight support in the parents
sysfs-dir and then actually unregister the LED class device,
this way we don't need any LED subsytem changes at all.
>>> - I guess UPower integration for the userspace driver could be archived with https://www.kernel.org/doc/html/latest/leds/uleds.html however this limited to brightness atm, so when accent colors actually come to UPower this would also need some expansion to be able to pass a preferred color to the userspace driver (regardless of what that driver is then doing with that information).
>> Using uleds is an interesting suggestion, but upower atm
>> does not support LED class kbd_backlight devices getting
>> hot-plugged. It only scans for them once at boot.
>>
>> Jelle van der Waa (a colleague of mine, added to the Cc)
>> has indicated he is interested in maybe working on fixing
>> this upower short-coming as a side project, once his
>> current side-projects are finished.
> Nice to hear.
>>
>>> On a different note: This approach does currently not cover the older EC controlled 3 zone keyboards from clevo. Here only the kernel has access access to the device so the kernel driver has to expose all functionality somehow. Should this be done by an arbitrarily designed platform device?
>> Interesting question, this reminds there was a discussion
>> about how to handle zoned keyboards using plain LED class
>> APIs here:
>>
>> https://lore.kernel.org/linux-leds/544484b9-c0ac-2fd0-1f41-8fa94cb94d4b@redhat.com/
>>
>> Basically the idea discussed there is to create
>> separate multi-color LED sysfs devices for each zone,
>> using :rgb:kbd_zoned_backlight-xxx as postfix, e.g. :
>>
>> :rgb:kbd_zoned_backlight-left
>> :rgb:kbd_zoned_backlight-middle
>> :rgb:kbd_zoned_backlight-right
>> :rgb:kbd_zoned_backlight-wasd
>>
>> As postfixes for the 4 per zone LED class devices
>> and then teach upower to just treat this as
>> a single kbd-backlight for the existing upower
>> DBUS API and maybe later extend the DBUS API.
>>
>> Would something like this work for the Clevo
>> case you are describing?
>
> Not entirely as some concept for the special modes would still be required.
Right, that can be done with some custom sysfs attr added
to the LED class device, like how dell-laptop.c sets
the .groups member of the "dell::kbd_backlight"
"struct led_classdev kbd_led" to add some extra
sysfs_attr to configure the timeout after which
the kbd_backlight automatically turns off when
no keys are pressed.
> Also it would be nice to be able to set the whole keyboard with a singular file access so that the keyboard changes at once and not zone by zone.
That is an interesting point. This could be implemented
by adding an "enable_atomic_commit" sysfs attr to
all 4:
:rgb:kbd_zoned_backlight-left
:rgb:kbd_zoned_backlight-middle
:rgb:kbd_zoned_backlight-right
:rgb:kbd_zoned_backlight-wasd
LED class devices, which is backed by only
1 variable in the kernel (so changing it
in one place changes it everywhere) and
then also have a "commit" sysfs attr and
writing say "1" to that will then commit
all changes at once.
So normally changes are still applied directly
(for compatibility with the usual sysfs API),
but then when "enable_atomic_commit" is set to 1,
writes only update in kernel variables and then
once "commit" is written all changes are send
out in 1 go.
I think we had the same issue where there was
a single WMI call to change all zones at once
(and having some sort of atomic API was desirable)
the last time the suggestion to use 4 LED class
devices for zoned kbds:
:rgb:kbd_zoned_backlight-left
:rgb:kbd_zoned_backlight-middle
:rgb:kbd_zoned_backlight-right
:rgb:kbd_zoned_backlight-wasd
came up, so we could start a new:
Documentation/ABI/testing/sysfs-class-led-zoned-kbd-backlight
document extending the standard:
Documentation/ABI/testing/sysfs-class-led
which documents both using the:
:rgb:kbd_zoned_backlight-left
:rgb:kbd_zoned_backlight-middle
:rgb:kbd_zoned_backlight-right
:rgb:kbd_zoned_backlight-wasd
suffixes there, as well as document some sort
of atomically change all 4 zones at once API.
Werner, if this sounds like something which would
work for you, then it would probably be best to
first submit a RFC patch introducing a:
Documentation/ABI/testing/sysfs-class-led-zoned-kbd-backlight
and then first discuss that with the LED subsys
maintainers, so that we have buy-in from the LED
subsys maintainers before you start actually
implementing this.
I'll reply to your "I also stumbled across a new Problem"
in another reply as it seems best to start a separate
thread for this.
Regards,
Hans
next prev parent reply other threads:[~2024-01-17 15:26 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 [this message]
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
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=8d77246d-ec1f-4106-8a33-b6e93bdbab45@redhat.com \
--to=hdegoede@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.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=pavel@ucw.cz \
--cc=wse@tuxedocomputers.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 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®