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

From: Dan Murphy
Date: Tue Apr 14 2020 - 09:29:47 EST


Vesa

On 4/9/20 12:25 AM, Vesa JÃÃskelÃinen wrote:
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.

Thank you for looking

Dan


Thanks,
Vesa JÃÃskelÃinen