Draft: udev: Add led support
General information about how work my implementation in back.
For led device, i have the following Linux files.
- color => Return color name (Ex: "rgb,white,yellow") is very arbitrary and can not exist. [Not used now because is very arbitrary]
- max_brightness => Return max valid value. (Ex: 1 for simple led or 255 if brightness can be managed for example)
- brightness => Current integer value of brightness, we can set new value with "echo [value] > brightness"
For RGB, we have other files.
- multi_index => Return index for each "channel" separate by space. (Ex: "red green blue")
- multi_intensity => Return value for each "channel" separate by space. (Ex: "255 0 0")
I tested on Playstation 5 Controller leds (rgb, player1, player2, ....), on my keyboard (basic led implementation), Oneplus 6 (Yellow flash, White flash)
My implementation
Implement basic led support
-
max brightness : int -
get brightness : int -
set brightness(int) : bool
Require +w permission on device_path/brightness
-
colorSupport : bool
Return true if current led device have multiple color
-
colorIntensities : QHash<String, int>
Can be blank if device not support it
Some device implement led color separatly so it appear separatly with Solid Each key == color Each value == intensity of color
-
set setColorIntensities (QHash<String, int>) : bool
Require +w permission on device_path/multi_intensity
-
rgbSupport : bool
Return true if current led device have multiple color and have red, green, blue color available
-
rgb : QColor
Can be blank if device not support it
Some device implement led color separatly so it appear separatly with Solid
but we can change color for each device with brightness value for each device
-
set rgb (QColor color) : bool
Require +w permission on device_path/multi_intensity
Not implemented:
- Signal when led brightness is changed (I don't found udev implement for this)
My implementation need unit test ? Or is checked from fakeled ?
Usefull resources
- https://docs.kernel.org/leds/leds-class-multicolor.html
- plasma/plasma-mobile#297
- https://github.com/torvalds/linux/blob/master/include/dt-bindings/leds/common.h
- https://www.kernel.org/doc/Documentation/leds/leds-class.rst
- https://invent.kde.org/plasma/powerdevil/-/blob/master/daemon/controllers/backlight_helper_actions.actions
- https://invent.kde.org/plasma/powerdevil/-/blob/master/daemon/controllers/backlightbrightness.cpp#L163
- https://develop.kde.org/docs/features/kauth/