leds: Introduce the multi_max_intensity sysfs attribute
Status from this message: Applied, thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest1 patch 3 repliesApplied
- v31 patch 4 repliesSuperseded
- v21 patch 3 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 1 patch | 4 replies | Superseded |
Changes in v4 from the cover letter
- add additional Reviewed-by tag
- fix coding style and spelling issues
Patches in v4 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/1 | leds: Introduce the multi_max_intensity sysfs attributeDocumentation/ Documentation/ drivers/ +3 more | +113 | 3 replies |
Reviews trailers per patch
The patch has a Reviewed-by or Acked-by.
| Patch | Werner Sembach | Jacek Anaszewski | Lee Jones |
|---|---|---|---|
| 1/1 | R-b | R-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v4 0/1] leds: Introduce the multi_max_intensity sysfs attribute
This patch series was born out of of a mailing list thread [1] where i asked how to properly model a RGB LED as a multicolor LED. Said LED has some exotic properties:
1. 5 global brightness levels.
2. 50 intensity levels for each R/G/B color components.
The current sysfs interface mandates that the maximum intensity value for each color component should be the same as the maximum global brightness. This makes sense for LEDs that only emulate global brightness using led_mc_calc_color_components(), but causes problems for LEDs that perform global brightness control in hardware.
Faking a maximum global brightness of 50 will not work in this case, as the hardware can change the global brightness on its own. Userspace applications might also prefer to know the true maximum brightness value.
Because of this i decided to add a new sysfs attribute called "multi_max_intensity". This attribute is similar to the "max_brightness" sysfs attribute, except that it targets the intensity values inside the "multi_intensity" sysfs atribute. I also decided to cap intensity values comming from userspace to said maximum intensity values to relieve drivers from doing it themself. This was already proposed in a unrelated patch [2] and might break some misbehaving userspace applications that do not respect max_brightness.
#include <linux/module.h>
#include <linux/init.h>
#include <linux/led-class-multicolor.h>
static int test_brightness_set_blocking(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
struct led_classdev_mc *mc_cdev = lcdev_to_mccdev(led_cdev);
for (int i = 0; i < mc_cdev->num_colors; i++) {
if (mc_cdev->subled_info[i].intensity > 30)
return -EIO;
}
return 0;
}static struct mc_subled subleds[] = {
{
.color_index = LED_COLOR_ID_RED,
.max_intensity = 0,
.channel = 1,
},
{
.color_index = LED_COLOR_ID_GREEN,
.max_intensity = 0,
.channel = 2,
},
{
.color_index = LED_COLOR_ID_BLUE,
.max_intensity = 0,
.channel = 3,
},
};static struct led_classdev_mc led_mc_cdev = {
.led_cdev = {
.max_brightness = 255,
.color = LED_COLOR_ID_MULTI,
.flags = LED_CORE_SUSPENDRESUME | LED_REJECT_NAME_CONFLICT, .brightness_set_blocking = test_brightness_set_blocking,
},
.num_colors = ARRAY_SIZE(subleds),
.subled_info = subleds,
};
static int __init test_init(void)
{
struct led_init_data init_data = {
.devicename = "test-led",
.default_label = "multicolor:" LED_FUNCTION_KBD_BACKLIGHT,
.devname_mandatory = true,
};
return led_classdev_multicolor_register_ext(NULL, &led_mc_cdev, &init_data);
}module_init(test_init);
static void __exit test_exit(void)
{
led_classdev_multicolor_unregister(&led_mc_cdev);
}module_exit(test_exit);
MODULE_AUTHOR("Armin Wolf <[email protected]>");MODULE_DESCRIPTION("Multicolor LED test device");MODULE_LICENSE("GPL");
[1] https://lore.kernel.org/linux-leds/[email protected]/
[2] https://lore.kernel.org/linux-leds/20260123-leds-multicolor-limit-intensity-v1-1-b37761c2fdfd@pengutronix.de/
Changes since v3:
- add additional Reviewed-by tag
- fix coding style and spelling issues
Changes since v2:
- add Reviewed-by tags
- fix spelling mistake
Changes since v1:
- use sysfs_emit_at()
- fix documentation issues
Changes since RFC:
- rework documentation
- drop useless defines
- reduce amount of driver code churn
Armin Wolf (1):
leds: Introduce the multi_max_intensity sysfs attribute
.../ABI/testing/sysfs-class-led-multicolor | 19 ++++++-- Documentation/leds/leds-class-multicolor.rst | 21 ++++++++- drivers/leds/led-class-multicolor.c | 47 ++++++++++++++++++- drivers/leds/leds-lp50xx.c | 1 + drivers/leds/rgb/leds-ncp5623.c | 4 +- include/linux/led-class-multicolor.h | 30 +++++++++++- 6 files changed, 113 insertions(+), 9 deletions(-)
Signature · 1 line
2.39.5