Re: Future handling of complex RGB devices on Linux v3

Werner Sembach
2024-02-22T13:14:44Z

Hi,

Thanks everyone for the exhaustive feedback. And at least this thread is a good
comprehesive reference for the future ^^.

To recap the hopefully final UAPI for complex RGB lighting devices:

- By default there is a singular /sys/class/leds/* entry that treats the device
as if it was a single zone RGB keyboard backlight with no special effects.

- There is an accompanying misc device with the sysfs attributes "name",
"device_type",  "firmware_version_string", "serial_number" for device
identification and "use_leds_uapi" that defaults to 1.

- If set to 0 the /sys/class/leds/* entry disappears. The driver should
keep the last state the backlight was in active if possible.

- If set 1 it appears again. The driver should bring it back to a static 1
zone setting while avoiding flicker if possible.

- If the device is not controllable by for example hidraw, the misc device might
also implement additional ioctls or sysfs attributes to allow a more complex low
level control for the keyboard backlight. This is will be a highly vendor
specific UAPI.

- The actual logic interacting with this low level UAPI is implemented by a
userspace driver

Implementation wise: For the creation of the misc device with the use_leds_uapi
switch a helper function/macro might be useful? Wonder if it should go into
leds.h, led-class-multicolor.h, or a new header file?

- Out of my head it would look something like this:

led_classdev_add_optional_misc_control(
struct led_classdev *led_cdev,
char* name,
char* device_type,
char* firmware_version_string,
char* serial_number,
void (*deregister_led)(struct led_classdev *led_cdev),
void (*reregister_led)(struct led_classdev *led_cdev))

Let me know your thoughts and hopefully I can start implementing it soon for one
of our devices.

Kind regards,

Werner Sembach