From: Randy Dunlap <rdunlap@infradead.org>
To: Dan Murphy <dmurphy@ti.com>, jacek.anaszewski@gmail.com, pavel@ucw.cz
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v19 04/18] leds: multicolor: Introduce a multicolor class definition
Date: Thu, 2 Apr 2020 20:47:19 -0700 [thread overview]
Message-ID: <619a1251-d062-b9bf-6752-b867fcaa600b@infradead.org> (raw)
In-Reply-To: <20200402204311.14998-5-dmurphy@ti.com>
Hi,
Here are a few changes for you to consider:
On 4/2/20 1:42 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
multicolor
> 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@ti.com>
> ---
> diff --git a/Documentation/leds/leds-class-multicolor.rst b/Documentation/leds/leds-class-multicolor.rst
> new file mode 100644
> index 000000000000..5bb004999248
> --- /dev/null
> +++ b/Documentation/leds/leds-class-multicolor.rst
> @@ -0,0 +1,95 @@
> +====================================
> +Multi Color LED handling under Linux
Multicolor
> +====================================
> +
> +Description
> +===========
> +The multi color class groups monochrome LEDs and allows controlling two
multicolor
> +aspects of the final combined color: hue and lightness. The former is
> +controlled via the color_intensity array file and the latter is controlled
> +via brightness file.
> +
> +For more details on hue and lightness notions please refer to
> +https://en.wikipedia.org/wiki/CIECAM02.
> +
> +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 color_* files. The order of the
> +colors are arbitrary the color_index file can be read to determine the color
> +to index value.
> +
> +The color_index file is an array that contains the string list of the colors as
> +they are defined in each color_* array file.
> +
> +The color_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 color_max_intensity is an array that can be read to indicate each color LED
> +maximum intensity value.
> +
> +The num_color_leds file returns the total number of color LEDs that are
> +presented in each color_* 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 color_index
> +-rw-r--r-- 1 root root 4096 Oct 19 16:16 color_intensity
> +-r--r--r-- 1 root root 4096 Oct 19 16:16 num_color_leds
> +
> +Multicolor Class Brightness Control
> +===================================
> +The multiclor class framework will calculate each monochrome LEDs intensity.
multicolor
> +
> +The brightness level for each LED is calculated based on the color LED
> +intensity setting divided by the parent max_brightness setting multiplied by
> +the requested brightness.
> +
> +led_brightness = brightness * color_intensity/max_brightness
> +
> +Example:
> +A user first writes the color_intensity file with the brightness levels
> +that for each LED that is necessary to achieve a blueish violet output from a
drop first "that".
that are necessary from an
> +RGB LED group.
> +
> +cat /sys/class/leds/multicolor:status/color_index
> +green blue red
> +
> +echo 43 226 138 > /sys/class/leds/multicolor:status/color_intensity
> +
> +red -
> + intensity = 138
> + max_brightness = 255
> +green -
> + intensity = 43
> + max_brightness = 255
> +blue -
> + intensity = 226
> + max_brightness = 255
> +
> +The user can control the brightness of that RGB group by writing the parent
> +'brightness' control. Assuming a parent max_brightness of 255 the user may want
> +to dim the LED color group to half. The user would write a value of 128 to the
> +parent brightness file then the values written to each LED will be adjusted
> +base on this value
value.
> +
> +cat /sys/class/leds/multicolor:status/max_brightness
> +255
> +echo 128 > /sys/class/leds/multicolor:status/brightness
> +
> +adjusted_red_value = 128 * 138/255 = 69
> +adjusted_green_value = 128 * 43/255 = 21
> +adjusted_blue_value = 128 * 226/255 = 113
> +
> +Reading the parent brightness file will return the current brightness value of
> +the color LED group.
> +
> +cat /sys/class/leds/multicolor:status/brightness
> +128
> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index d82f1dea3711..2e4611b25054 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -30,6 +30,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 Multi Color LED Class Support"
Multicolor
> + 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
thanks.
--
~Randy
next prev parent reply other threads:[~2020-04-03 3:47 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-02 20:42 [PATCH v19 00/18] Multicolor Framework (array edition) Dan Murphy
2020-04-02 20:42 ` [PATCH v19 01/18] dt: bindings: Add multicolor class dt bindings documention Dan Murphy
2020-04-06 20:12 ` Pavel Machek
2020-04-02 20:42 ` [PATCH v19 02/18] dt-bindings: leds: Add multicolor ID to the color ID list Dan Murphy
2020-04-02 20:42 ` [PATCH v19 03/18] " Dan Murphy
2020-04-06 20:13 ` Pavel Machek
2020-04-14 13:21 ` Dan Murphy
2020-04-02 20:42 ` [PATCH v19 04/18] leds: multicolor: Introduce a multicolor class definition Dan Murphy
2020-04-03 3:47 ` Randy Dunlap [this message]
2020-04-03 14:39 ` Dan Murphy
2020-04-05 15:08 ` Jacek Anaszewski
[not found] ` <f09dadc9-f1ed-091b-f241-2f40b48f1117@ti.com>
2020-04-05 16:28 ` Randy Dunlap
2020-04-05 16:31 ` Dan Murphy
2020-04-06 14:33 ` Dan Murphy
2020-04-06 19:25 ` Jacek Anaszewski
2020-04-07 14:52 ` Dan Murphy
2020-04-07 21:08 ` Jacek Anaszewski
2020-04-08 16:33 ` Dan Murphy
2020-04-08 16:35 ` Dan Murphy
2020-04-14 13:23 ` Dan Murphy
2020-04-09 5:25 ` Vesa Jääskeläinen
2020-04-14 13:21 ` Dan Murphy
2020-04-02 20:42 ` [PATCH v19 05/18] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers Dan Murphy
2020-04-02 20:42 ` [PATCH v19 06/18] leds: lp50xx: Add the LP50XX family of the RGB LED driver Dan Murphy
2020-04-02 20:43 ` [PATCH v19 07/18] dt: bindings: lp55xx: Be consistent in the document with LED acronym Dan Murphy
2020-04-02 20:43 ` [PATCH v19 08/18] dt: bindings: lp55xx: Update binding for Multicolor Framework Dan Murphy
2020-04-02 20:43 ` [PATCH v19 09/18] ARM: dts: n900: Add reg property to the LP5523 channel node Dan Murphy
2020-04-02 20:43 ` [PATCH v19 10/18] ARM: dts: imx6dl-yapp4: Add reg property to the lp5562 " Dan Murphy
2020-04-02 20:43 ` [PATCH v19 11/18] ARM: dts: ste-href: Add reg property to the LP5521 channel nodes Dan Murphy
2020-04-02 20:43 ` [PATCH v19 12/18] leds: lp55xx: Convert LED class registration to devm_* Dan Murphy
2020-04-02 20:43 ` [PATCH v19 13/18] leds: lp55xx: Add multicolor framework support to lp55xx Dan Murphy
2020-04-02 20:43 ` [PATCH v19 14/18] leds: lp5523: Update the lp5523 code to add multicolor brightness function Dan Murphy
2020-04-02 20:43 ` [PATCH v19 15/18] leds: lp5521: Add multicolor framework multicolor brightness support Dan Murphy
2020-04-02 20:43 ` [PATCH v19 16/18] leds: lp55xx: Fix checkpatch file permissions issues Dan Murphy
2020-04-02 20:43 ` [PATCH v19 17/18] leds: lp5523: Fix checkpatch issues in the code Dan Murphy
2020-04-02 20:43 ` [PATCH v19 18/18] dt: bindings: Update lp55xx binding to recommended LED naming Dan Murphy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=619a1251-d062-b9bf-6752-b867fcaa600b@infradead.org \
--to=rdunlap@infradead.org \
--cc=dmurphy@ti.com \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).