Skip to content

Commit 56e8c56

Browse files
Joseph Strausslag-linaro
authored andcommitted
leds: Add multicolor support to BlinkM LED driver
Add multicolor support to the BlinkM driver, making it easier to control from userspace. The BlinkM LED is a programmable RGB LED. The driver currently supports only the regular LED sysfs class, resulting in the creation of three distinct classes, one for red, green, and blue. The user then has to input three values into the three seperate brightness files within those classes. The multicolor LED framework makes the device easier to control with the multi_intensity file: the user can input three values at once to form a color, while still controlling the lightness with the brightness file. The main struct blinkm_led has changed slightly. The struct led_classdev for the regular sysfs classes remain. The blinkm_probe function checks CONFIG_LEDS_BLINKM_MULTICOLOR to decide whether to load the seperate sysfs classes or the single multicolor one, but never both. The blinkm_set_mc_brightness() function had to be added to calculate the three color components and then set the fields of the blinkm_data structure accordingly. Signed-off-by: Joseph Strauss <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 6b08d07 commit 56e8c56

File tree

4 files changed

+196
-69
lines changed

4 files changed

+196
-69
lines changed

Documentation/leds/leds-blinkm.rst

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,31 @@ The device accepts RGB and HSB color values through separate commands.
1313
Also you can store blinking sequences as "scripts" in
1414
the controller and run them. Also fading is an option.
1515

16-
The interface this driver provides is 2-fold:
16+
The interface this driver provides is 3-fold:
1717

18-
a) LED class interface for use with triggers
18+
a) LED multicolor class interface for use with triggers
19+
#######################################################
20+
21+
The registration follows the scheme::
22+
23+
blinkm-<i2c-bus-nr>-<i2c-device-nr>:rgb:indicator
24+
25+
$ ls -h /sys/class/leds/blinkm-1-9:rgb:indicator
26+
brightness device max_brightness multi_index multi_intensity power subsystem trigger uevent
27+
28+
Hue is controlled by the multi_intensity file and lightness is controlled by
29+
the brightness file.
30+
31+
The order in which to write the intensity values can be found in multi_index.
32+
Exactly three values between 0 and 255 must be written to multi_intensity to
33+
change the color::
34+
35+
$ echo 255 100 50 > multi_intensity
36+
37+
The overall lightness be changed by writing a value between 0 and 255 to the
38+
brightness file.
39+
40+
b) LED class interface for use with triggers
1941
############################################
2042

2143
The registration follows the scheme::
@@ -79,6 +101,7 @@ E.g.::
79101

80102

81103

82-
as of 6/2012
104+
as of 07/2024
83105

84106
dl9pf <at> gmx <dot> de
107+
jstrauss <at> mailbox <dot> org

Documentation/leds/well-known-leds.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ Good: "platform:*:charging" (allwinner sun50i, leds-cht-wcove)
7272

7373
Good: ":backlight" (Motorola Droid 4)
7474

75+
* Indicators
76+
77+
Good: ":indicator" (Blinkm)
78+
79+
* RGB
80+
81+
Good: ":rgb" (Blinkm)
82+
7583
* Ethernet LEDs
7684

7785
Currently two types of Network LEDs are support, those controlled by

drivers/leds/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,14 @@ config LEDS_BLINKM
825825
This option enables support for the BlinkM RGB LED connected
826826
through I2C. Say Y to enable support for the BlinkM LED.
827827

828+
config LEDS_BLINKM_MULTICOLOR
829+
bool "Enable multicolor support for BlinkM I2C RGB LED"
830+
depends on LEDS_BLINKM
831+
depends on LEDS_CLASS_MULTICOLOR
832+
help
833+
This option enables multicolor sysfs class support for BlinkM LED and
834+
disables the older, separated sysfs interface
835+
828836
config LEDS_POWERNV
829837
tristate "LED support for PowerNV Platform"
830838
depends on LEDS_CLASS

0 commit comments

Comments
 (0)