Re: [RFC PATCH] leds: multicolor: Add sysfs interface definition

From: Jacek Anaszewski
Date: Wed Jan 30 2019 - 15:20:18 EST


Dan,

On 1/30/19 8:59 PM, Dan Murphy wrote:
Jacek

On 1/30/19 1:37 PM, Jacek Anaszewski wrote:
Hi Dan,

Thank you for the RFC.

One vital thing is missing - documentation of brightness file must
be updated to define its semantics for LED multi color class.

Either we need brightness-model file returning only "onoff" option
available, or, for time being, fix the max_brightness for LED multi
color class to 1 (which will map to max intensity level for each color).


I can make max_brightness default to 1 if not set by the LED driver.

But the LP50xx has brightness controls so setting max_brightness from the driver should over ride
the max of 1 in the upper level.

Yes, so the max_brightness should be updated basing on current
brightness-model. For LEDn_BRIGHTNESS of LP50xx we could have
"hw" or maybe even better just "lp50xx-linear" and "lp50xx-logarithmic"
- I just forgot about that capability of the device.

For devices that do not support brightness as a separate control we can create a file called
max_brightness_<color> that defines the max that a specific color can be set to. If max_brightness
is set to 1 then create max_brightness_<color>. If max_brightness > 1 then do not create the files.

Right. We will need dedicated max_brightness for each color.
They should be placed also in the colors directory, next to the color
files.

I don't think we have fully vetted the brightness-model yet so I prefer to omit
it and possibly introduce that later.

We need to start from something. It will give better overview of the
whole idea.

Best regards,
Jacek Anaszewski

Dan

Best regards,
Jacek Anaszewski

On 1/30/19 7:30 PM, Dan Murphy wrote:
Add a documentation of LED Multicolor LED class specific
sysfs attributes.

Signed-off-by: Dan Murphy <dmurphy@xxxxxx>
---
 .../ABI/testing/sysfs-class-led-multicolor | 38 +++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-led-multicolor

diff --git a/Documentation/ABI/testing/sysfs-class-led-multicolor b/Documentation/ABI/testing/sysfs-class-led-multicolor
new file mode 100644
index 000000000000..19f8da9b150e
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-led-multicolor
@@ -0,0 +1,38 @@
+What:ÂÂÂÂÂÂÂ /sys/class/leds/<led>/color/sync_enable
+Date:ÂÂÂÂÂÂÂ January 2019
+KernelVersion:ÂÂÂ 5.0
+Contact:ÂÂÂ Dan Murphy <dmurphy@xxxxxx>
+Description:ÂÂÂ read/write
+ÂÂÂÂÂÂÂ Writing a 1 to this file will enable the sychronization of all
+ the defined color LEDs within the LED node. Writing a 0 to
+ÂÂÂÂÂÂÂ this file will disable syncing.
+
+What:ÂÂÂÂÂÂÂ /sys/class/leds/<led>/color/sync
+Date:ÂÂÂÂÂÂÂ January 2019
+KernelVersion:ÂÂÂ 5.0
+Contact:ÂÂÂ Dan Murphy <dmurphy@xxxxxx>
+Description:ÂÂÂ write only
+ÂÂÂÂÂÂÂ Writing a 1 to this file while sync_enable is set to 1 will
+ synchronize all defined LEDs within the LED node. All LEDs
+ÂÂÂÂÂÂÂ defined will be configured based on the brightness that has
+ÂÂÂÂÂÂÂ been requested.
+
+ÂÂÂÂÂÂÂ If sync_enable is set to 0 then writing a 1 to sync has no
+ÂÂÂÂÂÂÂ affect on the LEDs.
+
+What:ÂÂÂÂÂÂÂ /sys/class/leds/<led>/color/<led color>
+Date:ÂÂÂÂÂÂÂ January 2019
+KernelVersion:ÂÂÂ 5.0
+Contact:ÂÂÂ Dan Murphy <dmurphy@xxxxxx>
+Description:ÂÂÂ read/write
+ÂÂÂÂÂÂÂ These files are dynamically created based on the colors defined
+ÂÂÂÂÂÂÂ by the registrar of the class.
+ÂÂÂÂÂÂÂ The led color(s) can be but not limited to red, green, blue,
+ white, amber and violet. If sync is enabled then writing the
+ÂÂÂÂÂÂÂ brightness value of the LED is deferred until a 1 is
+ written to /sys/class/leds/<led>/color/sync. If syncing is
+ÂÂÂÂÂÂÂ disabled then the LED brightness value will be written
+ÂÂÂÂÂÂÂ immediately to the LED driver.
+
+ÂÂÂÂÂÂÂ The value of the color is from 0 to
+ÂÂÂÂÂÂÂ /sys/class/leds/<led>/max_brightness.