Re: [PATCH v19 04/18] leds: multicolor: Introduce a multicolor class definition

From: Vesa JÃÃskelÃinen
Date: Thu Apr 09 2020 - 01:32:08 EST


Hi,

On 2.4.2020 23.42, Dan Murphy wrote:
Introduce a multicolor class that groups colored LEDs
within a LED node.

The multi color class groups monochrome LEDs and allows controlling two
aspects of the final combined color: hue and lightness. The former is
controlled via <color>_intensity files and the latter is controlled
via brightness file.

Signed-off-by: Dan Murphy <dmurphy@xxxxxx>
---
.../ABI/testing/sysfs-class-led-multicolor | 42 ++++
Documentation/leds/index.rst | 1 +
Documentation/leds/leds-class-multicolor.rst | 95 ++++++++
drivers/leds/Kconfig | 10 +
drivers/leds/Makefile | 1 +
drivers/leds/led-class-multicolor.c | 206 ++++++++++++++++++
include/linux/led-class-multicolor.h | 121 ++++++++++
7 files changed, 476 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-class-led-multicolor
create mode 100644 Documentation/leds/leds-class-multicolor.rst
create mode 100644 drivers/leds/led-class-multicolor.c
create mode 100644 include/linux/led-class-multicolor.h

diff --git a/Documentation/ABI/testing/sysfs-class-led-multicolor b/Documentation/ABI/testing/sysfs-class-led-multicolor
new file mode 100644
index 000000000000..1f50324d24fd
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-led-multicolor
@@ -0,0 +1,42 @@
+What: /sys/class/leds/<led>/brightness
+Date: March 2020
+KernelVersion: 5.8
+Contact: Dan Murphy <dmurphy@xxxxxx>
+Description: read/write
+ Writing to this file will update all LEDs within the group to a
+ calculated percentage of what each color LED intensity is set
+ to. The percentage is calculated for each grouped LED via the
+ equation below:
+
+ led_brightness = brightness * color_intensity/max_brightness
+
+ For additional details please refer to
+ Documentation/leds/leds-class-multicolor.rst.
+
+ The value of the color is from 0 to
+ /sys/class/leds/<led>/max_brightness.
+
+What: /sys/class/leds/<led>/color_index
+Date: March 2020
+KernelVersion: 5.8
+Contact: Dan Murphy <dmurphy@xxxxxx>
+Description: read
+ The color_index array, when read, will output the LED colors
+ by name as they are indexed in the color_intensity array.
+
+What: /sys/class/leds/<led>/num_colors
+Date: March 2020
+KernelVersion: 5.8
+Contact: Dan Murphy <dmurphy@xxxxxx>
+Description: read
+ The num_colors indicates the number of LEDs defined in the
+ color_intensity and color_index arrays.
+
+What: /sys/class/leds/<led>/color_intensity
+Date: March 2020
+KernelVersion: 5.8
+Contact: Dan Murphy <dmurphy@xxxxxx>
+Description: read/write
+ Intensity level for the LED color within the array.
+ The intensities for each color must be entered based on the
+ color_index array.

For what it is worth --

I see that this interface covers our use cases and I assume that GPIO LED and PWM LED drivers can be implemented for this after this set is integrated.

Thanks,
Vesa JÃÃskelÃinen