Re: [PATCH v21 02/16] leds: multicolor: Introduce a multicolor class definition

2020-04-28 Thread Jacek Anaszewski

Dan,

Thanks for the update.

On 4/28/20 6:03 PM, 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 the intensity file and the latter is controlled
via brightness file.

Signed-off-by: Dan Murphy 
---
  .../ABI/testing/sysfs-class-led-multicolor|  34 +++
  Documentation/leds/index.rst  |   1 +
  Documentation/leds/leds-class-multicolor.rst  |  88 
  MAINTAINERS   |   8 +
  drivers/leds/Kconfig  |  10 +
  drivers/leds/Makefile |   1 +
  drivers/leds/led-class-multicolor.c   | 210 ++
  include/linux/led-class-multicolor.h  | 121 ++
  8 files changed, 473 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 ..7d33a82a4b07
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-led-multicolor
@@ -0,0 +1,34 @@
+What:  /sys/class/leds//brightness
+Date:  March 2020
+KernelVersion: 5.8
+Contact:   Dan Murphy 
+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 * multi_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//max_brightness.
+
+What:  /sys/class/leds//multi_index
+Date:  March 2020
+KernelVersion: 5.8
+Contact:   Dan Murphy 
+Description:   read
+   The multi_index array, when read, will output the LED colors
+   by name as they are indexed in the multi_intensity file.
+
+What:  /sys/class/leds//multi_intensity
+Date:  March 2020
+KernelVersion: 5.8
+Contact:   Dan Murphy 
+Description:   read/write
+   Intensity level for the LED color within the array.
+   The intensities for each color must be entered based on the
+   multi_index array.
diff --git a/Documentation/leds/index.rst b/Documentation/leds/index.rst
index 060f4e485897..bc70c6aa7138 100644
--- a/Documentation/leds/index.rst
+++ b/Documentation/leds/index.rst
@@ -9,6 +9,7 @@ LEDs
  
 leds-class

 leds-class-flash
+   leds-class-multicolor
 ledtrig-oneshot
 ledtrig-transient
 ledtrig-usbport
diff --git a/Documentation/leds/leds-class-multicolor.rst 
b/Documentation/leds/leds-class-multicolor.rst
new file mode 100644
index ..7e4907a5c87b
--- /dev/null
+++ b/Documentation/leds/leds-class-multicolor.rst
@@ -0,0 +1,88 @@
+
+MultiColor LED handling under Linux
+
+
+Description
+===
+The multicolor class groups monochrome LEDs and allows controlling two
+aspects of the final combined color: hue and lightness. The former is
+controlled via the multi_intensity array file and the latter is controlled
+via brightness file.
+
+Multicolor Class Control
+
+The multicolor class presents files that groups the colors as indexes in an
+array.  These files are children under the LED parent node created by the
+led_class framework.  The led_class framework is documented in led-class.rst
+within this documentation directory.
+
+Each colored LED will be indexed under the multi_* files. The order of the
+colors will be arbitrary. The multi_index file can be read to determine the
+color name to indexed value.
+
+The multi_index file is an array that contains the string list of the colors as
+they are defined in each multi_* array file.
+
+The multi_intensity is an array that can be read or written to for the
+individual color intensities.  All elements within this array must be written 
in
+order for the color LED intensities to be updated.
+
+The num_multi_leds file returns the total number of LEDs that are presented in
+each multi_* array.


It is no longer present in this version.


+
+Directory Layout Example
+
+root:/sys/class/leds/multicolor:status# ls -lR
+-rw-r--r--1 root root  4096 Oct 19 16:16 brightness
+-r--r--r--1 root root  4096 Oct 19 16:16 multi_index
+-rw-r--r--1 roo

[PATCH v21 02/16] leds: multicolor: Introduce a multicolor class definition

2020-04-28 Thread Dan Murphy
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 the intensity file and the latter is controlled
via brightness file.

Signed-off-by: Dan Murphy 
---
 .../ABI/testing/sysfs-class-led-multicolor|  34 +++
 Documentation/leds/index.rst  |   1 +
 Documentation/leds/leds-class-multicolor.rst  |  88 
 MAINTAINERS   |   8 +
 drivers/leds/Kconfig  |  10 +
 drivers/leds/Makefile |   1 +
 drivers/leds/led-class-multicolor.c   | 210 ++
 include/linux/led-class-multicolor.h  | 121 ++
 8 files changed, 473 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 ..7d33a82a4b07
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-led-multicolor
@@ -0,0 +1,34 @@
+What:  /sys/class/leds//brightness
+Date:  March 2020
+KernelVersion: 5.8
+Contact:   Dan Murphy 
+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 * multi_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//max_brightness.
+
+What:  /sys/class/leds//multi_index
+Date:  March 2020
+KernelVersion: 5.8
+Contact:   Dan Murphy 
+Description:   read
+   The multi_index array, when read, will output the LED colors
+   by name as they are indexed in the multi_intensity file.
+
+What:  /sys/class/leds//multi_intensity
+Date:  March 2020
+KernelVersion: 5.8
+Contact:   Dan Murphy 
+Description:   read/write
+   Intensity level for the LED color within the array.
+   The intensities for each color must be entered based on the
+   multi_index array.
diff --git a/Documentation/leds/index.rst b/Documentation/leds/index.rst
index 060f4e485897..bc70c6aa7138 100644
--- a/Documentation/leds/index.rst
+++ b/Documentation/leds/index.rst
@@ -9,6 +9,7 @@ LEDs
 
leds-class
leds-class-flash
+   leds-class-multicolor
ledtrig-oneshot
ledtrig-transient
ledtrig-usbport
diff --git a/Documentation/leds/leds-class-multicolor.rst 
b/Documentation/leds/leds-class-multicolor.rst
new file mode 100644
index ..7e4907a5c87b
--- /dev/null
+++ b/Documentation/leds/leds-class-multicolor.rst
@@ -0,0 +1,88 @@
+
+MultiColor LED handling under Linux
+
+
+Description
+===
+The multicolor class groups monochrome LEDs and allows controlling two
+aspects of the final combined color: hue and lightness. The former is
+controlled via the multi_intensity array file and the latter is controlled
+via brightness file.
+
+Multicolor Class Control
+
+The multicolor class presents files that groups the colors as indexes in an
+array.  These files are children under the LED parent node created by the
+led_class framework.  The led_class framework is documented in led-class.rst
+within this documentation directory.
+
+Each colored LED will be indexed under the multi_* files. The order of the
+colors will be arbitrary. The multi_index file can be read to determine the
+color name to indexed value.
+
+The multi_index file is an array that contains the string list of the colors as
+they are defined in each multi_* array file.
+
+The multi_intensity is an array that can be read or written to for the
+individual color intensities.  All elements within this array must be written 
in
+order for the color LED intensities to be updated.
+
+The num_multi_leds file returns the total number of LEDs that are presented in
+each multi_* array.
+
+Directory Layout Example
+
+root:/sys/class/leds/multicolor:status# ls -lR
+-rw-r--r--1 root root  4096 Oct 19 16:16 brightness
+-r--r--r--1 root root  4096 Oct 19 16:16 multi_index
+-rw-r--r--1 root root  4096 Oct 19 16:16 multi_intensity
+
+Multicolor Class Brightness Control
+===
+The