All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Dan Murphy <dmurphy@ti.com>, pavel@ucw.cz
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v21 02/16] leds: multicolor: Introduce a multicolor class definition
Date: Tue, 28 Apr 2020 22:48:39 +0200	[thread overview]
Message-ID: <a53e0074-26a1-2b55-896c-e5bfff8d24ba@gmail.com> (raw)
In-Reply-To: <20200428160338.2793-3-dmurphy@ti.com>

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 <dmurphy@ti.com>
> ---
>   .../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 000000000000..7d33a82a4b07
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-class-led-multicolor
> @@ -0,0 +1,34 @@
> +What:		/sys/class/leds/<led>/brightness
> +Date:		March 2020
> +KernelVersion:	5.8
> +Contact:	Dan Murphy <dmurphy@ti.com>
> +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/<led>/max_brightness.
> +
> +What:		/sys/class/leds/<led>/multi_index
> +Date:		March 2020
> +KernelVersion:	5.8
> +Contact:	Dan Murphy <dmurphy@ti.com>
> +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/<led>/multi_intensity
> +Date:		March 2020
> +KernelVersion:	5.8
> +Contact:	Dan Murphy <dmurphy@ti.com>
> +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 000000000000..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 root     root          4096 Oct 19 16:16 multi_intensity

What about max_brightness?

> +
> +Multicolor Class Brightness Control
> +===================================
> +The multicolor class framework will calculate each monochrome LEDs intensity.
> +
> +The brightness level for each LED is calculated based on the color LED
> +intensity setting divided by the parent max_brightness setting multiplied by

Parent is counter-intuitive in this case. I'd call it global.

> +the requested brightness.
> +
> +led_brightness = brightness * multi_intensity/max_brightness
> +
> +Example:
> +A user first writes the multi_intensity file with the brightness levels
> +for each LED that are necessary to achieve a certain color output from a
> +multicolor LED group.
> +
> +cat /sys/class/leds/multicolor:status/multi_index
> +green blue red
> +
> +echo 43 226 138 > /sys/class/leds/multicolor:status/multi_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 multicolor LED group by writing the
> +parent 'brightness' control.  Assuming a max_brightness of 255 the user

s/parent/global/

> +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

Ditto.

> +adjusted base on this 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

Ditto.

-- 
Best regards,
Jacek Anaszewski

  reply	other threads:[~2020-04-28 20:48 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 16:03 [PATCH v21 00/16] Multicolor Framework Dan Murphy
2020-04-28 16:03 ` [PATCH v21 01/16] dt: bindings: Add multicolor class dt bindings documention Dan Murphy
2020-04-28 20:30   ` Jacek Anaszewski
2020-04-29 12:50     ` Dan Murphy
2020-04-28 16:03 ` [PATCH v21 02/16] leds: multicolor: Introduce a multicolor class definition Dan Murphy
2020-04-28 20:48   ` Jacek Anaszewski [this message]
2020-04-28 16:03 ` [PATCH v21 03/16] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers Dan Murphy
2020-04-28 16:03 ` [PATCH v21 04/16] leds: lp50xx: Add the LP50XX family of the RGB LED driver Dan Murphy
2020-04-28 20:25   ` Jacek Anaszewski
2020-04-29 12:50     ` Dan Murphy
2020-04-28 16:03 ` [PATCH v21 05/16] dt: bindings: lp55xx: Be consistent in the document with LED acronym Dan Murphy
2020-04-28 16:03 ` [PATCH v21 06/16] dt: bindings: lp55xx: Update binding for Multicolor Framework Dan Murphy
2020-04-28 16:03 ` [PATCH v21 07/16] ARM: dts: n900: Add reg property to the LP5523 channel node Dan Murphy
2020-04-28 16:03 ` [PATCH v21 08/16] ARM: dts: imx6dl-yapp4: Add reg property to the lp5562 " Dan Murphy
2020-04-28 16:03 ` [PATCH v21 09/16] ARM: dts: ste-href: Add reg property to the LP5521 channel nodes Dan Murphy
2020-04-28 16:03 ` [PATCH v21 10/16] leds: lp55xx: Convert LED class registration to devm_* Dan Murphy
2020-04-28 16:03 ` [PATCH v21 11/16] leds: lp55xx: Add multicolor framework support to lp55xx Dan Murphy
2020-04-28 20:59   ` Jacek Anaszewski
2020-04-29 12:49     ` Dan Murphy
2020-04-28 16:03 ` [PATCH v21 12/16] leds: lp5523: Update the lp5523 code to add multicolor brightness function Dan Murphy
2020-04-28 16:03 ` [PATCH v21 13/16] leds: lp5521: Add multicolor framework multicolor brightness support Dan Murphy
2020-04-28 16:03 ` [PATCH v21 14/16] leds: lp55xx: Fix checkpatch file permissions issues Dan Murphy
2020-04-28 16:03 ` [PATCH v21 15/16] leds: lp5523: Fix checkpatch issues in the code Dan Murphy
2020-04-28 16:03 ` [PATCH v21 16/16] 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=a53e0074-26a1-2b55-896c-e5bfff8d24ba@gmail.com \
    --to=jacek.anaszewski@gmail.com \
    --cc=dmurphy@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.