Skip to contentSkip to conversation

Multicolor Framework

PATCH Superseded Dan Murphy 4 participants 19 messages Apr 11, 2019 – Apr 29, 2019

Subsystems (3)

v2 of 17 Superseded Latest is v17 →

lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

v2 cover Multicolor Framework

I have updated the patchset for the multicolor framework and scrubed the base code. I have incoroporated the minor changes that were asked for. But I still have not added any code for the brightness models as this is still in discussion.

I have also included the TI LP50xx driver that demonstrates how to use the Multicolor framework.

Finally I have built this on top of Jacek's LED name composition patchset
https://lore.kernel.org/patchwork/project/lkml/list/?series=388765

The MC FW will leverage the COLOR_ID and led_colors definitions provided there. And I have added a new COLOR_ID to support this framework because with multicolor having to declare a top level color for the directory just did not make sense

So the directory would be appended with multicolor which would denote that this directory supports the MC FW
multicolor:activity multicolor:standby multicolor:status

Dan

Dan Murphy (7):
leds: multicolor: Add sysfs interface definition
dt: bindings: Add multicolor class dt bindings documention
documention: leds: Add multicolor class documentation
dt-bindings: leds: Add multicolor ID to the color ID list
leds: multicolor: Introduce a multicolor class definition
dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers
leds: lp50xx: Add the LP50XX family of the RGB LED driver

 .../ABI/testing/sysfs-class-led-multicolor    |  91 +++
 .../devicetree/bindings/leds/common.txt       |   2 +
 .../bindings/leds/leds-class-multicolor.txt   | 142 ++++
 .../devicetree/bindings/leds/leds-lp50xx.txt  | 142 ++++
 Documentation/leds/leds-class-multicolor.txt  |  99 +++
 Documentation/leds/leds-lp50xx.txt            |  36 +
 drivers/leds/Kconfig                          |  17 +
 drivers/leds/Makefile                         |   2 +
 drivers/leds/led-class-multicolor.c           | 401 ++++++++++
 drivers/leds/led-class.c                      |   1 +
 drivers/leds/leds-lp50xx.c                    | 716 ++++++++++++++++++
 include/dt-bindings/leds/common.h             |   3 +-
 include/linux/led-class-multicolor.h          |  74 ++
 13 files changed, 1725 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-led-multicolor
 create mode 100644 Documentation/devicetree/bindings/leds/leds-class-multicolor.txt
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lp50xx.txt
 create mode 100644 Documentation/leds/leds-class-multicolor.txt
 create mode 100644 Documentation/leds/leds-lp50xx.txt
 create mode 100644 drivers/leds/led-class-multicolor.c
 create mode 100644 drivers/leds/leds-lp50xx.c
 create mode 100644 include/linux/led-class-multicolor.h
Signature · 1 line
2.21.0.5.gaeb582a983
author
#1 lore raw

PATCH v2 1/7 leds: multicolor: Add sysfs interface definition

Add a documentation of LED Multicolor LED class specific sysfs attributes.

---
 .../ABI/testing/sysfs-class-led-multicolor    | 91 +++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-led-multicolor
Documentation/ABI/testing/sysfs-class-led-multicolor new file +91 -0
new file mode 100644
index 000000000000..5583ecaa3170
@@ -0,0 +1,91 @@
+What:		/sys/class/leds/<led>/colors/sync_enable
+Date:		April 2019
+KernelVersion:	5.2
+Contact:	Dan Murphy <[email protected]>
+Description:	read/write
+		Writing a 1 to this file will enable the synchronization of all
+		the defined color LEDs within the LED node.  Brightness values
+		for each LED will be stored and written when sync is set to 1.
+		Writing a 0 to this file will disable syncing and allow
+		individual control of the LEDs brightness settings.
+
+What:		/sys/class/leds/<led>/colors/sync
+Date:		April 2019
+KernelVersion:	5.2
+Contact:	Dan Murphy <[email protected]>
+Description:	write only
+		Writing a 1 to this file while sync_enable is set to 1 will
+		write the current brightness values to 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>/colors/<led_color>/brightness
+Date:		April 2019
+KernelVersion:	5.2
+Contact:	Dan Murphy <[email protected]>
+Description:	read/write
+		The led_color directory is dynamically created based on the
+		colors defined by the registrar of the class.
+		The led_color can be but not limited to red, green, blue,
+		white, amber, yellow and violet.  Drivers can also declare a
+		LED color for presentation.  There is one directory per color
+		presented.  The brightness file is created under each
+		led_color directory and controls the individual LED color
+		setting.
+
+		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>/colors/<led_color>/max_brightness.
+
+What:		/sys/class/leds/<led>/colors/<led_color>/max_brightness
+Date:		April 2019
+KernelVersion:	5.2
+Contact:	Dan Murphy <[email protected]>
+Description:	read only
+		Maximum brightness level for the LED color, default is
+		255 (LED_FULL).
+
+		If the LED does not support different brightness levels, this
+		should be 1.
+
+What:		/sys/class/leds/<led>/brightness_model/<model_color>
+Date:		April 2019
+KernelVersion:	5.2
+Contact:	Jacek Anaszewski <[email protected]>
+Description:	read/write
+		This directory contains the defined color models that are read
+		from the firmware node.  The model color will be the read from
+		the firmware node.  The model names should be a color that the
+		LED cluster can produce.
+
+What:		/sys/class/leds/<led>/brightness_model/<model_color>/brightness
+Date:		April 2019
+KernelVersion:	5.2
+Contact:	Jacek Anaszewski <[email protected]>
+Description:	read/write
+		Writing this file will initiate a synchronized write to the LED
+		cluster to produce the color output defined in the firmware node.
+
+		This value cannot exceed <model_color>/max_brightness.
+		Writing a 0 to this file will cause the LED cluster to turn off.
+
+		The sync and sync_enable files do not have an affect on this as
+		this is a real time update of the LED cluster.
+
+What:		/sys/class/leds/<led>/brightness_model/<model_color>/max_brightness
+Date:		April 2019
+KernelVersion:	5.2
+Contact:	Jacek Anaszewski <[email protected]>
+Description:	read
+		Reading this file will return the maximum number of brightness
+		levels that are defined in the firmware node for the model color.
+		It should be assumed that the levels are from 1 -> max_brightness
+		and the LED cluster brightness is increasing.
Signature · 1 line
2.21.0.5.gaeb582a983
author
#2 lore raw

PATCH v2 2/7 dt: bindings: Add multicolor class dt bindings documention

In reply to Dan Murphy

Add DT bindings for the LEDs multicolor class framework.

---
 .../devicetree/bindings/leds/common.txt       |   2 +
 .../bindings/leds/leds-class-multicolor.txt   | 142 ++++++++++++++++++
 2 files changed, 144 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-class-multicolor.txt
Documentation/devicetree/bindings/leds/common.txt +2 -0
index 7497a3c221fe..bc424a9ba547 100644
@@ -23,6 +23,8 @@ Optional properties for child nodes:
 - color : Color of the LED. Use one of the LED_COLOR_ID_* prefixed definitions
 	  from the header include/dt-bindings/leds/common.h.
 	  If there is no matching LED_COLOR_ID available, add a new one.
+	  For multi color LED support see leds-multicolor.txt within this
+	  directory.
 
 - led-enumerator: Integer to be used for LED differentiation when neither
 		  function nor color can be used for that purpose.
Documentation/devicetree/bindings/leds/leds-class-multicolor.txt new file +142 -0

142 lines not on this page · raw message

Signature · 1 line
2.21.0.5.gaeb582a983
author
#11 lore raw

PATCH v2 3/7 documention: leds: Add multicolor class documentation

In reply to Dan Murphy

Add the support documentation on the multicolor LED framework. This document defines the directores and file generated by the multicolor framework. It also documents usage.

---
 Documentation/leds/leds-class-multicolor.txt | 99 ++++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 Documentation/leds/leds-class-multicolor.txt
Documentation/leds/leds-class-multicolor.txt new file +99 -0
new file mode 100644
index 000000000000..edbb8139e514
@@ -0,0 +1,99 @@
+
+Multi Color LED handling under Linux
+=================================================
+
+Author: Dan Murphy <[email protected]>
+
+Description
+-----------
+There are varying monochrome LED colors available for application.  These
+LEDs can be used as a single use case LED or can be mixed with other color
+LEDs to produce the full spectrum of color.  Color LEDs that are grouped
+can be presented under a single LED node with individual color control.
+The multicolor class groups these LEDs and allows dynamically setting the value
+of a single LED or setting the brightness values of the LEDs in the group and
+updating the LEDs virtually simultaneously.
+
+Multicolor Class Control
+-------------------------
+The multicolor class presents the LED groups under a directory called "colors".
+This directory is a child under the LED parent node created by the led_class
+framework.  The led_class framework is documented in led-class.txt within this
+documentation directory.
+
+Each colored LED is given its own directory.  These directories can be, but not
+limited to red, green, blue, white, amber, yellow and violet.  Under these
+directories the brightness and max_brightness files are presented for each LED.
+
+Under the "colors" directory there are two files created: "sync" and
+"sync_enable". The sync_enable file controls whether the LED brightness
+value is set real time or if the LED brightness value setting is deferred until
+the "sync" file is written.  If sync_enable is set then writing to each LED
+"brightness" file will store the brightness value.  Once the "sync" file is
+written then each LED color defined in the node will write the brightness of
+the LED in the device driver.
+
+If "sync_enable" is not set then writing the brightness value of the LED to the
+device driver is done immediately.  Writing the "sync" file has no affect.
+
+Directory Layout Example
+------------------------
+root:/sys/class/leds/rgb:grouped_leds# ls -lR colors/
+colors/:
+drwxr-xr-x    2 root     root             0 Jun 28 20:21 blue
+drwxr-xr-x    2 root     root             0 Jun 28 20:21 green
+drwxr-xr-x    2 root     root             0 Jun 28 20:21 red
+--w-------    1 root     root          4096 Jun 28 20:21 sync
+-rw-------    1 root     root          4096 Jun 28 20:22 sync_enable
+
+colors/blue:
+-rw-------    1 root     root          4096 Jun 28 20:21 brightness
+-r--------    1 root     root          4096 Jun 28 20:27 max_brightness
+
+colors/green:
+-rw-------    1 root     root          4096 Jun 28 20:22 brightness
+-r--------    1 root     root          4096 Jun 28 20:27 max_brightness
+
+colors/red:
+-rw-------    1 root     root          4096 Jun 28 20:21 brightness
+-r--------    1 root     root          4096 Jun 28 20:27 max_brightness
+
+Example of Writing LEDs with Sync Enabled
+-----------------------------------------
+Below the red, green and blue LEDs are set to corresponding values.  These
+values are stored and not written until the sync file is written.
+
+cd /sys/class/leds/rgb:grouped_leds/colors
+
+echo 1 > sync_enable
+
+echo 100 > red/brightness
+echo 80 > green/brightness
+echo 180 > blue/brightness
+
+* LED device driver has not been updated and the LED states have not changed.
+* Writing the LED brightness files again will only change the stored value and
+* not the device driver value.
+
+echo 1 > sync
+
+* LED device driver has been updated; the LEDs should present the brightness
+* levels that have been set.  Since sync_enable is still enabled writing to the
+* LED brightness files will not change the current brightnesses.
+
+Example of Writing LEDs with Sync Disabled
+------------------------------------------
+Below the values of each LED are written to the device driver immediately upon
+request.
+
+cd /sys/class/leds/rgb:grouped_leds/colors
+
+echo 0 > sync_enable
+
+echo 100 > red/brightness // Red LED should be on with the current brightness
+echo 80 > green/brightness // Green LED should be on with the current brightness
+echo 180 > blue/brightness // Blue LED should be on with the current brightness
+.
+.
+.
+echo 0 > green/brightness // Green LED should be off
Signature · 1 line
2.21.0.5.gaeb582a983
author
#12 lore raw

PATCH v2 4/7 dt-bindings: leds: Add multicolor ID to the color ID list

In reply to Dan Murphy

Add a new color ID that is declared as MULTICOLOR as with the multicolor framework declaring a definitive color is not accurate as the node can contain multiple colors.

---
 drivers/leds/led-class.c          | 1 +
 include/dt-bindings/leds/common.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/leds/led-class.c +1 -0
index bfd46a9bba63..11dd78b63403 100644
@@ -35,6 +35,7 @@ const char *led_colors[LED_COLOR_ID_COUNT] = {
 	[LED_COLOR_ID_VIOLET] = "violet",
 	[LED_COLOR_ID_YELLOW] = "yellow",
 	[LED_COLOR_ID_IR] = "ir",
+	[LED_COLOR_ID_MULTI] = "multicolor",
 };
 EXPORT_SYMBOL_GPL(led_colors);
 
include/dt-bindings/leds/common.h +2 -1
index c95f39b3a254..f6df2c63398e 100644
@@ -64,6 +64,7 @@
 #define LED_COLOR_ID_VIOLET	5
 #define LED_COLOR_ID_YELLOW	6
 #define LED_COLOR_ID_IR		7
-#define LED_COLOR_ID_COUNT	8
+#define LED_COLOR_ID_MULTI	8
+#define LED_COLOR_ID_COUNT	9
 
 #endif /* __DT_BINDINGS_LEDS_H */
Signature · 1 line
2.21.0.5.gaeb582a983
author
#13 lore raw

PATCH v2 5/7 leds: multicolor: Introduce a multicolor class definition

In reply to Dan Murphy

Introduce a multicolor class that groups colored LEDs within a LED node.

The framework allows for dynamically setting individual LEDs or setting brightness levels of LEDs and updating them virtually simultaneously.

---
 drivers/leds/Kconfig                 |  10 +
 drivers/leds/Makefile                |   1 +
 drivers/leds/led-class-multicolor.c  | 401 +++++++++++++++++++++++++++
 include/linux/led-class-multicolor.h |  74 +++++
 4 files changed, 486 insertions(+)
 create mode 100644 drivers/leds/led-class-multicolor.c
 create mode 100644 include/linux/led-class-multicolor.h
drivers/leds/Kconfig +10 -0
index f24d31138471..1e400af24114 100644
@@ -29,6 +29,16 @@ config LEDS_CLASS_FLASH
 	  for the flash related features of a LED device. It can be built
 	  as a module.
 
+config LEDS_CLASS_MULTI_COLOR
+	tristate "LED Mulit Color LED Class Support"
+	depends on LEDS_CLASS
+	help
+	  This option enables the multicolor LED sysfs class in /sys/class/leds.
+	  It wraps LED Class and adds multicolor LED specific sysfs attributes
+	  and kernel internal API to it. You'll need this to provide support
+	  for multicolor LEDs that are grouped together. This class is not
+	  intended for single color LEDs.  It can be built as a module.
+
 config LEDS_BRIGHTNESS_HW_CHANGED
 	bool "LED Class brightness_hw_changed attribute support"
 	depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index 4c1b0054f379..c57c2aec9510 100644
@@ -4,6 +4,7 @@
 obj-$(CONFIG_NEW_LEDS)			+= led-core.o
 obj-$(CONFIG_LEDS_CLASS)		+= led-class.o
 obj-$(CONFIG_LEDS_CLASS_FLASH)		+= led-class-flash.o
+obj-$(CONFIG_LEDS_CLASS_MULTI_COLOR)	+= led-class-multicolor.o
 obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
 
 # LED Platform Drivers
drivers/leds/led-class-multicolor.c new file +401 -0

401 lines not on this page · raw message

include/linux/led-class-multicolor.h new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.21.0.5.gaeb582a983
author
#14 lore raw

PATCH v2 6/7 dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers

In reply to Dan Murphy

Introduce the bindings for the Texas Instruments LP5036, LP5030, LP5024 and the LP5018 RGB LED device driver. The LP5036/3024/18 can control RGB LEDs individually or as part of a control bank group. These devices have the ability
to adjust the mixing control for the RGB LEDs to obtain different colors independent of the overall brightness of the LED grouping.

Datasheet:
http://www.ti.com/lit/ds/symlink/lp5024.pdf
http://www.ti.com/lit/ds/symlink/lp5036.pdf

---
 .../devicetree/bindings/leds/leds-lp50xx.txt  | 142 ++++++++++++++++++
 1 file changed, 142 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lp50xx.txt
Documentation/devicetree/bindings/leds/leds-lp50xx.txt new file +142 -0
new file mode 100644
index 000000000000..48ea7f164ce6
@@ -0,0 +1,142 @@
+* Texas Instruments - LP5018/24/30/36 RGB LED driver
+
+The LP50XX is multi-channel, I2C RGB LED Drivers that can group RGB LEDs into
+a LED group or control them individually.
+
+The difference in these RGB LED drivers is the number of supported RGB modules.
+
+Required parent properties:
+	- compatible:
+		"ti,lp5018"
+		"ti,lp5024"
+		"ti,lp5030"
+		"ti,lp5036"
+	- reg :  I2C slave address
+		lp5018/24 - 0x28
+		lp5030/36 - 0x30
+	- #address-cells : 1
+	- #size-cells : 0
+
+Optional parent properties:
+	- enable-gpios : gpio pin to enable/disable the device.
+	- vled-supply : LED supply
+
+Required child properties:
+	- #address-cells : 1
+	- #size-cells : 0
+	- reg : This is the LED module number.
+	- color : see Documentation/devicetree/bindings/leds/common.txt
+	- function : see Documentation/devicetree/bindings/leds/common.txt
+
+Required child properties only is LED modules will be banked:
+	- ti,led-bank : This property denotes the LED module numbers that will
+			be controlled as a single RGB cluster.  Each LED module
+			number will be controlled by a single LED class instance.
+			There can only be one instance of the ti,led-bank
+			property for each device node.
+
+Required grandchildren properties:
+	- reg : A single entry denoting the LED module that controls
+		the RGB cluster.
+	- color : see Documentation/devicetree/bindings/leds/leds-multicolor.txt
+	- led-sources : see Documentation/devicetree/bindings/leds/common.txt
+
+The LED outputs associated with the LED modules are defined in Table 1 of the
+corresponding data sheets.
+
+LP5018 - 6 Total RGB cluster LED outputs 0-5
+LP5024 - 8 Total RGB cluster LED outputs 0-7
+LP5030 - 10 Total RGB cluster LED outputs 0-9
+LP5036 - 12 Total RGB cluster LED outputs 0-11
+
+Optional child properties:
+	- label : see Documentation/devicetree/bindings/leds/common.txt
+	- linux,default-trigger :
+	   see Documentation/devicetree/bindings/leds/common.txt
+
+Examples:
+led-controller@29 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	compatible = "ti,lp5024";
+	reg = <0x29>;
+	enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
+	vled-supply = <&vmmcsd_fixed>;
+
+	multi-led@2 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <2>;
+		color = <LED_COLOR_ID_MULTI>;
+		function = LED_FUNCTION_STANDBY;
+		ti,led-bank = <2 3 5>;
+
+		led@6 {
+			reg = <0x6>;
+			color = <LED_COLOR_ID_RED>;
+			led-sources = <6 9 15>;
+		};
+
+		led@7 {
+			reg = <0x7>;
+			color = <LED_COLOR_ID_GREEN>;
+			led-sources = <7 10 16>;
+		};
+
+		led@8 {
+			reg = <0x8>;
+			color = <LED_COLOR_ID_BLUE>;
+			led-sources = <8 11 17>;
+		};
+	};
+
+	multi-led@1 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <1>;
+		color = <LED_COLOR_ID_MULTI>;
+		function = LED_FUNCTION_STATUS;
+		
+		led@3 {
+			reg = <3>;
+			color = <LED_COLOR_ID_RED>;
+		};
+
+		led@4 {
+			reg = <4>;
+			color = <LED_COLOR_ID_GREEN>;
+		};
+
+		led@5 {
+			reg = <5>;
+			color = <LED_COLOR_ID_BLUE>;
+		};
+	};
+
+	multi-led@4 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <4>;
+		color = <LED_COLOR_ID_MULTI>;
+		function = LED_FUNCTION_ACTIVITY;
+		
+		led@12 {
+			reg = <12>;
+			color = <LED_COLOR_ID_RED>;
+		};
+
+		led@13 {
+			reg = <13>;
+			color = <LED_COLOR_ID_GREEN>;
+		};
+
+		led@14 {
+			reg = <14>;
+			color = <LED_COLOR_ID_BLUE>;
+		};
+	};
+};
+
+For more product information please see the link below:
+http://www.ti.com/lit/ds/symlink/lp5024.pdf
+http://www.ti.com/lit/ds/symlink/lp5036.pdf
Signature · 1 line
2.21.0.5.gaeb582a983
author
#17 lore raw

PATCH v2 7/7 leds: lp50xx: Add the LP50XX family of the RGB LED driver

In reply to Dan Murphy

Introduce the LP5036/30/24/18 RGB LED driver.
The difference in these parts are the number of
LED outputs where the:

LP5036 can control 36 LEDs
LP5030 can control 30 LEDs
LP5024 can control 24 LEDs
LP5018 can control 18 LEDs

The device has the ability to group LED output into control banks so that multiple LED banks can be controlled with the same mixing and brightness. Inversely the LEDs can also be controlled independently.

---
 Documentation/leds/leds-lp50xx.txt |  36 ++
 drivers/leds/Kconfig               |   7 +
 drivers/leds/Makefile              |   1 +
 drivers/leds/leds-lp50xx.c         | 716 +++++++++++++++++++++++++++++
 4 files changed, 760 insertions(+)
 create mode 100644 Documentation/leds/leds-lp50xx.txt
 create mode 100644 drivers/leds/leds-lp50xx.c
Documentation/leds/leds-lp50xx.txt new file +36 -0
new file mode 100644
index 000000000000..8b1b01dfdd22
@@ -0,0 +1,36 @@
+LP5018/LP5024/LP5030/LP5036 Common Driver
+=================================================
+
+Authors: Dan Murphy <[email protected]>
+
+Description
+-----------
+The LP50XX RGB LED drivers have the ability to group multiple RGB cluster
+LEDs into a single group for simultaneous control or expose single RGB cluster
+for control.  This device exposes different register interfaces to control
+the cluster brightness as well as the individual RGB LEDs color intensity.
+
+RGB Cluster Color Control
+-------------------------
+The LP50xx driver will expose a file called "color" for each LED class instance
+defined.  This file will accept a 24-bit RGB value in which the the color of the
+RGB LEDs will be set.
+
+The 24-bit RGB value passed in follows the pattern 0xXXRRGGBB
+XX - Do not care ignored by the driver
+RR - is the 8 bit Red LED value
+GG - is the 8 bit Green LED value
+BB - is the 8 bit Blue LED value
+
+Example:
+LED module output 4 of the LP5024 will be a yellow color:
+echo 0xe6de00 > /sys/class/leds/lp5024\:led4_mod/color
+
+LED module output 4 of the LP5024 will be dimmed 50%:
+echo 0x80 > /sys/class/leds/lp5024\:led4_mod/brightness
+
+LED banked RGBs of the LP5036 will be a white color:
+echo 0xffffff > /sys/class/leds/lp5036\:led_banked/color
+
+LED banked RGBs of the LP50364 will be dimmed 50%:
+echo 0x80 > /sys/class/leds/lp5036\:led_banked/brightness
drivers/leds/Kconfig +7 -0
index 1e400af24114..287c8802e89c 100644
@@ -336,6 +336,13 @@ config LEDS_LP3952
 	  To compile this driver as a module, choose M here: the
 	  module will be called leds-lp3952.
 
+config LEDS_LP50XX
+	tristate "LED Support for TI LP5036/30/24/18 LED driver chip"
+	depends on LEDS_CLASS && REGMAP_I2C
+	help
+	  If you say yes here you get support for the Texas Instruments
+	  LP5036, LP5030, LP5024 and LP5018 LED driver.
+
 config LEDS_LP55XX_COMMON
 	tristate "Common Driver for TI/National LP5521/5523/55231/5562/8501"
 	depends on LEDS_LP5521 || LEDS_LP5523 || LEDS_LP5562 || LEDS_LP8501
drivers/leds/Makefile +1 -0
index c57c2aec9510..5e8dfe28c5a5 100644
@@ -33,6 +33,7 @@ obj-$(CONFIG_LEDS_GPIO_REGISTER)	+= leds-gpio-register.o
 obj-$(CONFIG_LEDS_GPIO)			+= leds-gpio.o
 obj-$(CONFIG_LEDS_LP3944)		+= leds-lp3944.o
 obj-$(CONFIG_LEDS_LP3952)		+= leds-lp3952.o
+obj-$(CONFIG_LEDS_LP50XX)		+= leds-lp50xx.o
 obj-$(CONFIG_LEDS_LP55XX_COMMON)	+= leds-lp55xx-common.o
 obj-$(CONFIG_LEDS_LP5521)		+= leds-lp5521.o
 obj-$(CONFIG_LEDS_LP5523)		+= leds-lp5523.o
drivers/leds/leds-lp50xx.c new file +716 -0

716 lines not on this page · raw message

Signature · 1 line
2.21.0.5.gaeb582a983
author
#18 lore raw

Re: [PATCH v2 7/7] leds: lp50xx: Add the LP50XX family of the RGB LED driver

Hello

Quoted 9 lines · Dan Murphy

Introduce the LP5036/30/24/18 RGB LED driver.
The difference in these parts are the number of
LED outputs where the:

LP5036 can control 36 LEDs
LP5030 can control 30 LEDs
LP5024 can control 24 LEDs
LP5018 can control 18 LEDs

Quoted 7 lines

The device has the ability to group LED output into control banks so that multiple LED banks can be controlled with the same mixing and brightness. Inversely the LEDs can also be controlled independently.

---
 Documentation/leds/leds-lp50xx.txt |  36 ++

This document needs to be removed or updated as it is not correct.

Dan
<snip>

author
#15 lore raw

Re: [PATCH v2 6/7] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers

In reply to Dan Murphy

Hello

Quoted 2 lines · Dan Murphy

Introduce the bindings for the Texas Instruments LP5036, LP5030, LP5024 and the LP5018 RGB LED device driver. The LP5036/3024/18 can control RGB LEDs individually

s/LP5036/3024/18->LP5036/30/24/18

Dan

<snip>

#3 lore raw

Re: [PATCH v2 2/7] dt: bindings: Add multicolor class dt bindings documention

In reply to Dan Murphy

Hi Dan,
this probaly was discussed, but I did not follow brightness model discussions:
what will happen if I set yellow by writing into yellow mode brightness, and then orange by writing orange model brightness? Will the resulting color be a mix of yellow and orange, or will the orange overwrite the yellow setting?

Marek

author
#4 lore raw

Re: [PATCH v2 2/7] dt: bindings: Add multicolor class dt bindings documention

Marek

Quoted 8 lines · Marek Behun

Hi Dan,
this probaly was discussed, but I did not follow brightness model discussions:
what will happen if I set yellow by writing into yellow mode brightness, and then orange by writing orange model brightness? Will the resulting color be a mix of yellow and orange, or will the orange overwrite the yellow setting?

This was not discussed and is a good question. If you write the yellow mode for a group of LEDs then yellow would be produced for the brightness requested.

If orange is then requested then orange should be displayed at the brightness level requested. So yes the orange will over write the yellow.

The next question is if the absolute colors are written does it produce the same behavior?

So if you have yellow and write to the red should the red LED brightness be modified or should the
color switch to red?
And if the red LED is on and the blue LED is written should the color switch to blue or should the blue and red LEDs be mixed together?

This is tricky as the user space can write the individual absolute colors and mix the LEDs to produce varying colors. But the behavior writing the brightness models are different.

I would almost prefer that the user space reads the available absolute LED colors and creates the devices supported color palette and write the absolute LED colors only. But this violates the requirements asked for.

Dan

Quoted 2 lines

Marek

#8 lore raw

Re: [PATCH v2 2/7] dt: bindings: Add multicolor class dt bindings documention

In reply to Marek Behun

Hi Marek,

Quoted 7 lines · Marek Behun

Hi Dan,
this probaly was discussed, but I did not follow brightness model discussions:
what will happen if I set yellow by writing into yellow mode brightness, and then orange by writing orange model brightness? Will the resulting color be a mix of yellow and orange, or will the orange overwrite the yellow setting?

Orange will overwrite yellow settings. When color name is given it should be treated as a hue. Then changing brightness level should affect the lightness of a hue, similarly like changing L component of HSL color model. This will be however entirely up to DT brightness-model designer how they will design their models. We are not going to verify that in the LED multi color class.

It implies that it will be possible to define arbitrary range of color levels, not necessarily adhering to any established color model. I think it could be useful to define brightness model that allows to go from blue color (for cold) up to red (hot) for representing a temperature for instance.

These ideas will need however more documentation. Generally we aim to propose only a convention.

Signature · 2 lines
Best regards,
Jacek Anaszewski
author
#9 lore raw

Re: [PATCH v2 2/7] dt: bindings: Add multicolor class dt bindings documention

Jacek

Quoted 18 lines · Jacek Anaszewski

Hi Marek,

Quoted 7 lines · Marek Behun

Hi Dan,
this probaly was discussed, but I did not follow brightness model discussions:
what will happen if I set yellow by writing into yellow mode brightness, and then orange by writing orange model brightness? Will the resulting color be a mix of yellow and orange, or will the orange overwrite the yellow setting?

Orange will overwrite yellow settings. When color name is given it should be treated as a hue. Then changing brightness level should affect the lightness of a hue, similarly like changing L component of HSL color model. This will be however entirely up to DT brightness-model designer how they will design their models. We are not going to verify that in the LED multi color class.

Quoted 9 lines

It implies that it will be possible to define arbitrary range of color levels, not necessarily adhering to any established color model. I think it could be useful to define brightness model that allows to go from blue color (for cold) up to red (hot) for representing a temperature for instance.

These ideas will need however more documentation. Generally we aim to propose only a convention.

Ah but what about the issue of writing the monochrome LED color. With your description it implies that when we write the red LED, the red LED will come on and if we write the blue LED then the red LED in theory should turn off and the blue come on.

But these could be used to mix the colors to create some abstract violet that is not defined in the brightness model. Why should the brightness models and monochrome LEDs have two different operations.

Dan

#5 lore raw

Re: [PATCH v2 2/7] dt: bindings: Add multicolor class dt bindings documention

In reply to Dan Murphy

Dan,

Quoted 12 lines · Dan Murphy

Marek

Quoted 8 lines · Marek Behun

Hi Dan,
this probaly was discussed, but I did not follow brightness model discussions:
what will happen if I set yellow by writing into yellow mode brightness, and then orange by writing orange model brightness? Will the resulting color be a mix of yellow and orange, or will the orange overwrite the yellow setting?

Quoted 5 lines

This was not discussed and is a good question. If you write the yellow mode for a group of LEDs then yellow would be produced for the brightness requested.

If orange is then requested then orange should be displayed at the brightness level requested. So yes the orange will over write the yellow.

Yes, and individual color brightness levels should correspond to the color components of the brightness-model level currently set.

Quoted 5 lines

The next question is if the absolute colors are written does it produce the same behavior?

So if you have yellow and write to the red should the red LED brightness be modified or should the
color switch to red?
And if the red LED is on and the blue LED is written should the color switch to blue or should the blue and red LEDs be mixed together?

Now, if any of the color brightness files is altered it should update the hardware with this new setting, but brightness-model and main brightness level should not be changed. The thing that is missing in our proposal is lack of the way to check if brightness-model is up to date (i.e. if it reflects what is written to the hardware).

How about utilizing the sync file from the new colors directory? It could return 1 on read when brightness levels of all colors match exactly the ones assigned to the brightness model level currently set.

Quoted 10 lines

This is tricky as the user space can write the individual absolute colors and mix the LEDs to produce varying colors. But the behavior writing the brightness models are different.

I would almost prefer that the user space reads the available absolute LED colors and creates the devices supported color palette and write the absolute LED colors only. But this violates the requirements asked for.

Dan

Quoted 2 lines

Marek

Signature · 2 lines
Best regards,
Jacek Anaszewski
#10 lore raw

Re: [PATCH v2 2/7] dt: bindings: Add multicolor class dt bindings documention

In reply to Dan Murphy

Dan,

Quoted 27 lines · Dan Murphy

Jacek

Quoted 24 lines · Jacek Anaszewski

Hi Marek,

Quoted 7 lines · Marek Behun

Hi Dan,
this probaly was discussed, but I did not follow brightness model discussions:
what will happen if I set yellow by writing into yellow mode brightness, and then orange by writing orange model brightness? Will the resulting color be a mix of yellow and orange, or will the orange overwrite the yellow setting?

Orange will overwrite yellow settings. When color name is given it should be treated as a hue. Then changing brightness level should affect the lightness of a hue, similarly like changing L component of HSL color model. This will be however entirely up to DT brightness-model designer how they will design their models. We are not going to verify that in the LED multi color class.

It implies that it will be possible to define arbitrary range of color levels, not necessarily adhering to any established color model. I think it could be useful to define brightness model that allows to go from blue color (for cold) up to red (hot) for representing a temperature for instance.

Quoted 7 lines
Quoted 3 lines

These ideas will need however more documentation. Generally we aim to propose only a convention.

Ah but what about the issue of writing the monochrome LED color. With your description it implies that when we write the red LED, the red LED will come on and if we write the blue LED then the red LED in theory should turn off and the blue come on.

Where did I write that? Probably the way I used word "color" was not adequate in at least two cases, which may have confused the reader.

Modifying monochrome color brightness levels (under colors dir) will just modify corresponding IOUT brightness. Not affecting the other. I'll try to rephrase what seems to may sound equivocal:

s/When color name is given/When brightness-model is given a color name/

s/arbitrary range of color levels/arbitrary range of brightness-model levels/

Quoted 5 lines

But these could be used to mix the colors to create some abstract violet that is not defined in the brightness model. Why should the brightness models and monochrome LEDs have two different operations.

Dan

Signature · 2 lines
Best regards,
Jacek Anaszewski
author
#6 lore raw

Re: [PATCH v2 2/7] dt: bindings: Add multicolor class dt bindings documention

In reply to Jacek Anaszewski

All

Quoted 36 lines · Jacek Anaszewski

Dan,

Quoted 12 lines · Dan Murphy

Marek

Quoted 8 lines · Marek Behun

Hi Dan,
this probaly was discussed, but I did not follow brightness model discussions:
what will happen if I set yellow by writing into yellow mode brightness, and then orange by writing orange model brightness? Will the resulting color be a mix of yellow and orange, or will the orange overwrite the yellow setting?

Quoted 5 lines

This was not discussed and is a good question.  If you write the yellow mode for a group of LEDs then yellow would be produced for the brightness requested.

If orange is then requested then orange should be displayed at the brightness level requested. So yes the orange will over write the yellow.

Yes, and individual color brightness levels should correspond to the color components of the brightness-model level currently set.

Quoted 5 lines

The next question is if the absolute colors are written does it produce the same behavior?

So if you have yellow and write to the red should the red LED brightness be modified or should the
color switch to red?
And if the red LED is on and the blue LED is written should the color switch to blue or should the blue and red LEDs be mixed together?

Now, if any of the color brightness files is altered it should update the hardware with this new setting, but brightness-model and main brightness level should not be changed. The thing that is missing in our proposal is lack of the way to check if brightness-model is up to date (i.e. if it reflects what is written to the hardware).

Quoted 5 lines

How about utilizing the sync file from the new colors directory? It could return 1 on read when brightness levels of all colors match exactly the ones assigned to the brightness model level currently set.

There maybe a more pragmatic way to set the color brightness as opposed to defining each level. By defining the monochrome LEDs base maximum brightness for the brightness model and calculating a percentage for each LED from max I shared this with Jacek earlier and he did not go for it but lets see if others agree or disagree.

With this method we don't have to define a slew of levels. This in theory may work but not sure it will work in practice.

For instance

	lp5024_model_yellow: brightness-models {
		led-brightness-model;
		model@0 {
			model_name = "yellow";
			layout = <LED_COLOR_ID_RED
				  LED_COLOR_ID_GREEN
				  LED_COLOR_ID_BLUE>;
			max_level = <255 247 196>;  //max level of the monochrome LEDs to obtain the color model.
		};
	};

Assumption made that a linear slope for each color model is expected.

Then in the code when a new brightness level is requested for the color the brightness of the monochrome LEDs would be based off the percentage from the max_brightness of the max in the max_level array

The hue is presented as just another color in the colors dir with brightness and max_brightness files. So it "appears" as a single LED.

max_brightness = 255 This is the max of the LEDs in the array and this would also be presented to the user in the max_brightness of the hue.

Red = (255/255) = 100% Green = (247/255) = 97% Blue = (196/255) = 77%

brightness_val 128

Red = (128 * 100) / 100 = 128 Green = (128 * 97) / 100 = 124 Blue = (128 * 77) / 100 = 98

brightness_val 80

Red = (80 * 100) / 100 = 80 Green = (80 * 97) / 100 = 77 Blue = (80 * 77) / 100 = 61

brightness_val 10

Red = (10 * 100) / 100 = 10 Green = (10 * 97) / 100 = 9 Blue = (10 * 77) / 100 = 7

This method maintains a rough percentage delta between the LEDs. Where in the MAX brightness case (255) blue is 77% dimmer in intensity then Red and with a brightness that is 1/4 max the delta percentage is 75% so the delta is within 5% tolerance.

This would keep the directory structures clean and the user space would just need to know colors, brightness and max_brightness for each color.

Also with this simplistic model we can simplify the DT nodes to

	lp5024_model_yellow: brightness-models {
		led-brightness-model;
		model@0 {
			model_name = "yellow";
			layout = <LED_COLOR_ID_RED
				  LED_COLOR_ID_GREEN
				  LED_COLOR_ID_BLUE>;
			max_level = <255 247 196>;
		};
	};

	lp5024_model_orange: brightness-models {
		led-brightness-model;
		model@1 {
			model_name = "orange";
			layout = <LED_COLOR_ID_RED
				  LED_COLOR_ID_GREEN
				  LED_COLOR_ID_BLUE>;
			max_level = <236 140 16>;
		};
	}; 

For orange
max_brightness = 236 This is the max of the LEDs in the array and this would also be presented to the user in the max_brightness of the hue.

Red = (236/236) = 100% Green = (140/236) = 59% Blue = (16/236) = 6%

<same math from above involved here>

After all of this most likely someone will say this will not work.
Like I indicated it works in principle maybe not in practice but it keeps the user interface simple and keeps the dt small.

The other alternative is to have the user space define the color models and just expose the monochrome LEDs.

Dan

<snip>

#7 lore raw

Re: [PATCH v2 2/7] dt: bindings: Add multicolor class dt bindings documention

Dan,

Quoted 122 lines · Dan Murphy

All

Quoted 36 lines · Jacek Anaszewski

Dan,

Quoted 12 lines · Dan Murphy

Marek

Quoted 8 lines · Marek Behun

Hi Dan,
this probaly was discussed, but I did not follow brightness model discussions:
what will happen if I set yellow by writing into yellow mode brightness, and then orange by writing orange model brightness? Will the resulting color be a mix of yellow and orange, or will the orange overwrite the yellow setting?

Quoted 5 lines

This was not discussed and is a good question.  If you write the yellow mode for a group of LEDs then yellow would be produced for the brightness requested.

If orange is then requested then orange should be displayed at the brightness level requested. So yes the orange will over write the yellow.

Yes, and individual color brightness levels should correspond to the color components of the brightness-model level currently set.

Quoted 5 lines

The next question is if the absolute colors are written does it produce the same behavior?

So if you have yellow and write to the red should the red LED brightness be modified or should the
color switch to red?
And if the red LED is on and the blue LED is written should the color switch to blue or should the blue and red LEDs be mixed together?

Now, if any of the color brightness files is altered it should update the hardware with this new setting, but brightness-model and main brightness level should not be changed. The thing that is missing in our proposal is lack of the way to check if brightness-model is up to date (i.e. if it reflects what is written to the hardware).

Quoted 5 lines

How about utilizing the sync file from the new colors directory? It could return 1 on read when brightness levels of all colors match exactly the ones assigned to the brightness model level currently set.

There maybe a more pragmatic way to set the color brightness as opposed to defining each level. By defining the monochrome LEDs base maximum brightness for the brightness model and calculating a percentage for each LED from max I shared this with Jacek earlier and he did not go for it but lets see if others agree or disagree.

With this method we don't have to define a slew of levels. This in theory may work but not sure it will work in practice.

For instance

	lp5024_model_yellow: brightness-models {
		led-brightness-model;
		model@0 {
			model_name = "yellow";
			layout = <LED_COLOR_ID_RED
				  LED_COLOR_ID_GREEN
				  LED_COLOR_ID_BLUE>;
			max_level = <255 247 196>;  //max level of the monochrome LEDs to obtain the color model.
		};
	};

Assumption made that a linear slope for each color model is expected.

Then in the code when a new brightness level is requested for the color the brightness of the monochrome LEDs would be based off the percentage from the max_brightness of the max in the max_level array

The hue is presented as just another color in the colors dir with brightness and max_brightness files. So it "appears" as a single LED.

max_brightness = 255 This is the max of the LEDs in the array and this would also be presented to the user in the max_brightness of the hue.

Red = (255/255) = 100% Green = (247/255) = 97% Blue = (196/255) = 77%

brightness_val 128

Red = (128 * 100) / 100 = 128 Green = (128 * 97) / 100 = 124 Blue = (128 * 77) / 100 = 98

brightness_val 80

Red = (80 * 100) / 100 = 80 Green = (80 * 97) / 100 = 77 Blue = (80 * 77) / 100 = 61

brightness_val 10

Red = (10 * 100) / 100 = 10 Green = (10 * 97) / 100 = 9 Blue = (10 * 77) / 100 = 7

This method maintains a rough percentage delta between the LEDs. Where in the MAX brightness case (255) blue is 77% dimmer in intensity then Red and with a brightness that is 1/4 max the delta percentage is 75% so the delta is within 5% tolerance.

This would keep the directory structures clean and the user space would just need to know colors, brightness and max_brightness for each color.

Also with this simplistic model we can simplify the DT nodes to

	lp5024_model_yellow: brightness-models {
		led-brightness-model;
		model@0 {
			model_name = "yellow";
			layout = <LED_COLOR_ID_RED
				  LED_COLOR_ID_GREEN
				  LED_COLOR_ID_BLUE>;
			max_level = <255 247 196>;
		};
	};

	lp5024_model_orange: brightness-models {
		led-brightness-model;
		model@1 {
			model_name = "orange";
			layout = <LED_COLOR_ID_RED
				  LED_COLOR_ID_GREEN
				  LED_COLOR_ID_BLUE>;
			max_level = <236 140 16>;
		};
	};

For orange
max_brightness = 236 This is the max of the LEDs in the array and this would also be presented to the user in the max_brightness of the hue.

Quoted 8 lines

Red = (236/236) = 100% Green = (140/236) = 59% Blue = (16/236) = 6%

<same math from above involved here>

After all of this most likely someone will say this will not work.
Like I indicated it works in principle maybe not in practice but it keeps the user interface simple and keeps the dt small.

Great, we will have simple. not working interface.

If you will prove that it works for the whole range of devices and LEDs and is able to produce uniform colors then I'm all in.

Especially, I'd expect it will be able to keep the same hue and increase only lightness as brightness level rises.

Quoted 1 line

The other alternative is to have the user space define the color models and just expose the monochrome LEDs.

Please propose the whole interface since I don't see how it would work, and especially how its functionality would differ from the discussed approach.

Would it allow to support LEDn_BRIGHTNESS of lp50xx devices?

I'm afraid we're making a full circle now.

We've discussed many aspects of the problem throughout last months - does your design introduce some novelty in regard to what has been discussed so far?

If not, and if there is no consensus regarding brightness-models, then let's implement iouts as monochrome LEDs, without the support for LEDn_BRIGHTNESS.

Signature · 2 lines
Best regards,
Jacek Anaszewski
maintainer Reviewed-by on v2 6/7
#16 lore raw

Re: [PATCH v2 6/7] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers

In reply to Dan Murphy
Quoted 10 lines · Dan Murphy

Introduce the bindings for the Texas Instruments LP5036, LP5030, LP5024 and the LP5018 RGB LED device driver. The LP5036/3024/18 can control RGB LEDs individually or as part of a control bank group. These devices have the ability
to adjust the mixing control for the RGB LEDs to obtain different colors independent of the overall brightness of the LED grouping.

Datasheet:
http://www.ti.com/lit/ds/symlink/lp5024.pdf
http://www.ti.com/lit/ds/symlink/lp5036.pdf

Quoted 6 lines
---
 .../devicetree/bindings/leds/leds-lp50xx.txt  | 142 ++++++++++++++++++
 1 file changed, 142 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-lp50xx.txt