linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Werner Sembach <wse@tuxedocomputers.com>, Pavel Machek <pavel@ucw.cz>
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
	jikos@kernel.org, Jelle van der Waa <jelle@vdwaa.nl>,
	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: Tue, 30 Jan 2024 18:10:37 +0100	[thread overview]
Message-ID: <952409e1-2f0e-4d7a-a7a9-3b78f2eafec7@redhat.com> (raw)
In-Reply-To: <730bead8-6e1d-4d21-90d2-4ee73155887a@tuxedocomputers.com>

Hi Werner,

On 1/30/24 12:12, Werner Sembach wrote:
> Hi Hans,
> 
> Am 29.01.24 um 14:24 schrieb Hans de Goede:

<snip>

>> That sounds workable OTOH combined with your remarks about also supporting
>> lightbars. I'm starting to think that we need to just punt this to userspace.
>>
>> So basically change things from trying to present a standardized address
>> space where say the 'Q' key is always in the same place just model
>> a keyboard as a string of LEDs (1 dimensional / so an array) and leave
>> mapping which address in the array is which key to userspace, then userspace
>> can have json or whatever files for this per keyboard.
>>
>> This keeps the kernel interface much more KISS which I think is what
>> we need to strive for.
>>
>> So instead of having /dev/rgbkbd we get a /dev/rgbledstring and then
>> that can be used for rbb-kbds and also your lightbar example as well
>> as actual RGB LED strings, which depending on the controller may
>> also have zones / effects, etc. just like the keyboards.

<snip>

>> Right, so see above I think we need to push all these complications
>> into userspace. And simple come up for a kernel interface
>> for RGB LED strings with zones / effects / possibly individual
>> addressable LEDs.
>>
>> Also we should really only use whatever kernel interface we come up
>> with for devices which cannot be supported directly from userspace
>> through e.g. hidraw access. Looking at keyboards then the openrgb project:
>>
>> https://openrgb.org/devices_0.9.html
>>
>> Currently already supports 398 keyboard modes, we really do not want
>> to be adding support for all those to the kernel.

> I think that are mostly external keyboards, so in theory a possible cut could also between built-in and external devices.

IMHO it would be better to limit /dev/rgbledstring use to only
cases where direct userspace control is not possible and thus
have the cut be based on whether direct userspace control
(e.g. /dev/hidraw access) is possible or not.


>> Further down in the thread you mention Mice with RGB LEDs,
>> Mice are almost always HID devices and already have extensive support,
>> including for their LEDs in userspace through libratbag and the piper UI,
>> see the screenshots here (click on the camera icon):
>> https://linux.softpedia.com/get/Utilities/Piper-libratbag-104168.shtml
>>
>> Again we really don't want to be re-doing all this work in the kernel
>> only to end up conflicting with the existing userspace support.
>>
>> <snip>
>>
>>>> 5. A set_effect ioctl which takes a struct with the following members:
>>>>
>>>> {
>>>> long size; /* Size of passed in struct including the size member itself */
>>>> int effect_nr; /* enum value of the effect to enable, 0 for disable effect */
>>>> int zone;  /* zone to apply the effect to */
>>> Don't know if this is necessary, the keyboards I have seen so far apply firmware effects globally.
>>>> int speed; /* cycle speed of the effect in milli-hz */
>>> I would split this into speed and speed_max and don't specify an actual unit. The firmwares effects I have seen so far: If they have a speed value, it's some low number interpreted as a proportional x/n * the max speed of this effect, with n being some low number like 8 or 10.
>>>
>>> But i don't know if such clearly named properties are even sensefull, see below.
>>>
>>>> char color1[3]; /* effect dependend may be unused. */
>>>> char color2[3]; /* effect dependend may be unused. */
>>>> }
>>> We can not predetermine how many colors we might need in the future.
>>>
>>> Firmware effects can vary vastly in complexity, e.g. breathing can be a single bit switch that just varies the brightness of whatever color setting is currently applied. It could have an optional speed argument. It could have nth additional color arguments to cycle through, it could have an optional randomize bit that either randomizes the order of the defined colors or means that it is picking completely random color ignoring the color settings if set.
>>>
>>> Like this we could have a very fast explosion of the effects enum e.g.: breathing, breathing_2_colors, breathing_3_colors, ... breathing_n_colors, breathing_speed_controlled, breathing_speed_controlled_2_colors, ... breathing_speed_controlled_n_colors_random_bit, etc.
>>>
>>> Or we give up on generic names and just make something like: tongfang_breathing_1, tongfang_scan_1, tongfang_breathing_2, clevo_breathing_1
>>>
>>> Each with an own struct defined in a big .h file.
>>>
>>> Otherwise I think the config struct needs to be dynamically created out of information the driver gives to userspace.
>> Given that as mentioned above I believe that we should only use a kernel
>> driver where direct userspace access is impossible I believe that having
>> things like tongfang_breathing_1, tongfang_scan_1, tongfang_breathing_2,
>> clevo_breathing_1, etc. for the hopefully small set of devices which
>> needs an actual kernel driver to be reasonable.

> So also no basic driver? Or still the concept from before with a basic 1 zone only driver via leds subsystem to have something working, but it is unregistered by userspace, if open rgb wants to take over for fine granular support?

Ah good point, no I think that a basic driver just for kbd backlight
brightness support which works with the standard desktop environment
controls for this makes sense.

Combined with some mechanism for e.g. openrgb to fully take over
control as discussed. It is probably a good idea to file a separate
issue with the openrgb project to discuss the takeover API.

>> Talking about existing RGB LED support I believe that we should also
>> reach out to and get feedback on (or even an ack for) the new rgbledstring
>> API from the OpenRGB folks: https://openrgb.org
>>
>> Maybe they already have a nice abstraction to deal with different
>> kind of effects which we can copy for the kernel API ?
> I opened an issue regarding this: https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/3916

Great, thank you.

Regards,

Hans




  reply	other threads:[~2024-01-30 17:10 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 [this message]
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=952409e1-2f0e-4d7a-a7a9-3b78f2eafec7@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;
as well as URLs for NNTP newsgroup(s).