linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Vesa Jääskeläinen" <dachaac@gmail.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Dan Murphy <dmurphy@ti.com>,
	robh+dt@kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH 2/2] leds: lp5024: Add the LP5024/18 RGB LED driver
Date: Fri, 4 Jan 2019 21:49:06 +0200	[thread overview]
Message-ID: <e99036ea-ffb6-83ab-726b-824e2557d161@gmail.com> (raw)
In-Reply-To: <20190103233425.GA10071@amd>

Hi Pavel,

On 04/01/2019 1.34, Pavel Machek wrote:
> Hi!
> 
>>> Regarding led_scale_color_elements() - I checked it in GIMP and
>>> the results are not satisfactory when increasing brightness.
>>> Even if we managed to fix it, the result would not be guaranteed
>>> to be the same across all devices.
>>
>> No and they will never be the same. I was told by our hardware expert that
>> it is rather impossible to get linearly behaving LED control without special
>> curve fitting trimmed for particular hardware and LED component in use. And
>> if you go and change LED component/vendor it would need to be "calibrated"
>> again if such accuracy would be required. Also LEDs age and that has also
>> effect on this.
> 
> Well, it is not possible to "perfectly" calibrate LCD monitors,
> either. Yet, color tables make sense for them.
> 
> And we should aim for the same thing.
> 
> And yes, it may mean re-doing calibration when vendor changes. And it
> will mean some math and some understanding of colors.
> 
> And... LEDs are linear-enough as it is. That is not a problem. But RGB
> does _not_ expect linear response. That's why colors are _way_ off currently.

Example what I was given was some LEDs are off for let's say 20% of PWM 
linearity and then there is non-linear curve for PWM value vs. intensity 
(this was in context of white LCD backlight).

One case where we currently are interested in linear intensity is LCD 
background color. For that we have ramp defined in device tree. There 
would probably be simple fix to get that curve fitting to work better 
but let's keep that as another topic for now.

I was thinking that if we get "calibration" curve support in PWM LED 
brightness we could then just use that as one solution within kernel and 
let LCD PWM brightness support use same functionality from LED 
framework. (eg. LCD backlight would bind to PWM controlled mono color 
LED node)

Other case is that we need to dim LEDs in low light situations.

As such I have nothing against adding support for HSL or other color 
space based brightness calculations. It might just need to be 
configurable what kind of mode is being used based on hardware solution 
in place. HSL seem to need a bit of fixed point math. Got floating point 
version working already but that does not work with kernel space so one 
needs to adapt it to fixed point.

One problem here is to figure out is if user configures some color -- is 
it configured with 100% brightness eg. Should one calculate RGB->HSL and 
then scale L with brightness and calculate RGB back for setting color -- 
or does it mean replacing L with brightness value?

Additional problem is then if you have let's say yellow LED color 
element there. How would one scale that then? Linear is of course easy. 
If you need to configure this to some color space then how does one 
define the color in device tree so that such color space conversion is 
possible? One possible solution is to calibrate the curve (like what you 
do with LCD calibration) and then just assume brightness as linear 
brightness value in that case.

Or if you have multi-color LED with red and green but no other color 
elements. How does brightness scaling work with this one?

>>> I have another proposal, being a mix of what has been discussed so far:
>>>
>>>     RGB LED class will expose following files:
>>>     a) available by default:
>>>       - red, green, blue
>>>         Writing any of these file will result in writing corresponding
>>>         device register.
>>
>> Problem with this is that we are basically back at square one and one cannot
>> do "atomic" color change with this.
>>
>> In order to set or activate new values one would need "load values" file or
>> such that when writing to it would activate new values. However it becomes
>> quite clumsy interface at that point as you need to handle multiple writes
>> to multiple files and makes those operations rather slow.
> 
> If you don't like the interface, create an shared library. It may be
> neccessary, anyway, for the color operations.
> 
> You say it is "rather slow" to change all 3 colors. How long does it
> take, and how long do you need it to take?

Some times in embedded linux systems you can see "stalls" in operation 
of an application flow eg. time is spent in different places. I believe 
"slowest" CPU with embedded linux we are using is Atmel's AT91 series 
(ARM9) and executing code in there can at times be a bit time consuming.

I have seen delays like 18ms in TI's AM335x CPU series (Cortex-A8) and 
not even too high load situations (eg. breaking some serial protocols 
because of breaks in transmission in-between transfer without being a 
problem in application code as such). It is completely different story 
when there is a bit of load in system or some special situation in the 
kernel/OS.

Running high priority thread for configuring LEDs to avoid problems 
sounds like a wrong solution.

Co-worker of mine tried multi-color LED brightness sliding from user 
space with current PWM led driver and it was visible from eye that it 
was not timed smoothly.

For GPIO LED we decided to use out-of-tree solution for multi-color LEDs 
because we didn't want to see wrong colors in LEDs or sliding colors. 
For this we have color preset table in device tree and with it color 
change is more or less atomic. And also it supports kernel based LED 
blinking with whatever color you have configured there first.

For PWM controlled multi-color LEDs we don't yet have a solution. We 
need configurable color kernel based blinking.

With Jacek's proposed interface one could do kernel based blinking if 
brightness is simulated or calculated (if trigger's ON brightness can be 
configured). Only problem I suppose is color transition from A to B 
state and after that the blinking would work nicely as target color 
would already be known by driver.

If we could figure out acceptable solution for color transition problem 
then I suppose all parties would be happy?

Thanks,
Vesa Jääskeläinen

  reply	other threads:[~2019-01-04 19:49 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 16:26 [PATCH 0/2] LP5024/18 LED introduction Dan Murphy
2018-12-19 16:26 ` [PATCH 1/2] dt: bindings: lp5024: Introduce the lp5024 and lp5018 RGB driver Dan Murphy
2018-12-28 23:53   ` Rob Herring
2018-12-31 18:54     ` Dan Murphy
2019-01-08 20:33   ` Jacek Anaszewski
2019-01-08 20:53     ` Dan Murphy
2019-01-08 21:16       ` Jacek Anaszewski
2019-01-08 21:22         ` Dan Murphy
2019-01-09 20:12           ` Jacek Anaszewski
2019-01-09 21:12             ` Dan Murphy
2019-01-09 21:28               ` Jacek Anaszewski
2019-01-09 21:31                 ` Dan Murphy
2019-01-10 18:44                   ` Jacek Anaszewski
2019-01-10 19:22                     ` Dan Murphy
2019-01-10 19:57                       ` Jacek Anaszewski
2019-01-10 20:43                         ` Dan Murphy
2019-01-10 22:03                           ` Jacek Anaszewski
2019-01-10 23:51                             ` Dan Murphy
2019-01-11 12:38                             ` Dan Murphy
2019-01-11 21:52                               ` Jacek Anaszewski
2019-01-12 17:09                                 ` Dan Murphy
2019-01-12 19:48                                   ` Jacek Anaszewski
2019-01-14 12:27                                     ` Dan Murphy
2019-01-14 20:11                                       ` Jacek Anaszewski
2019-01-14 20:14                                         ` Dan Murphy
2019-01-14 20:28                                           ` Jacek Anaszewski
2019-01-14 20:29                                             ` Dan Murphy
2018-12-19 16:26 ` [PATCH 2/2] leds: lp5024: Add the LP5024/18 RGB LED driver Dan Murphy
2018-12-19 19:04   ` Dan Murphy
2018-12-19 19:34   ` Pavel Machek
2018-12-19 19:41     ` Dan Murphy
2018-12-19 20:10       ` Pavel Machek
2018-12-19 20:41         ` Dan Murphy
2018-12-19 21:36           ` Jacek Anaszewski
2018-12-19 21:50             ` Dan Murphy
2018-12-20 12:40               ` Vesa Jääskeläinen
2018-12-20 13:56                 ` Dan Murphy
2019-01-01 13:45                 ` Vesa Jääskeläinen
2019-01-03 22:05                   ` Jacek Anaszewski
2019-01-03 23:19                     ` Vesa Jääskeläinen
2019-01-03 23:34                       ` Pavel Machek
2019-01-04 19:49                         ` Vesa Jääskeläinen [this message]
2019-01-04 20:43                           ` Pavel Machek
2019-01-04 19:12                       ` Jacek Anaszewski
2019-01-04 20:12                         ` Pavel Machek
2019-01-04 21:37                           ` Jacek Anaszewski
2019-01-04 22:07                             ` Pavel Machek
2019-01-05 12:16                               ` Jacek Anaszewski
2019-01-05 12:31                                 ` Pavel Machek
2019-01-05 13:16                                   ` Jacek Anaszewski
2019-01-05 22:12                                     ` Generic RGB LED support was " Pavel Machek
2019-01-06 15:52                                       ` Jacek Anaszewski
2019-01-07 19:13                                         ` Jacek Anaszewski
2019-01-07 19:36                                           ` Dan Murphy
2019-01-07 20:59                                             ` Jacek Anaszewski
2019-01-07 21:14                                               ` Dan Murphy
2019-01-08 21:18                                                 ` Jacek Anaszewski
2019-01-08 21:25                                                   ` Dan Murphy
2019-01-10 12:46                                                     ` Dan Murphy
2019-01-10 19:23                                                       ` Jacek Anaszewski
2019-01-10 19:58                                                         ` Dan Murphy
2019-01-10 21:02                                                           ` Jacek Anaszewski
2019-01-10 21:07                                                             ` Dan Murphy
2019-01-08 22:59                                         ` Pavel Machek
2019-01-09  7:11                                           ` Vesa Jääskeläinen
2019-01-13 16:37                                             ` Jacek Anaszewski
2019-01-05  0:39                             ` Vesa Jääskeläinen
2019-01-07 19:34                               ` Dan Murphy
2019-01-09  6:20                                 ` Vesa Jääskeläinen
2019-01-07 21:13                               ` Jacek Anaszewski
2019-01-07 21:15                                 ` Dan Murphy
2019-01-09  6:46                                 ` Vesa Jääskeläinen
2019-01-13 16:36                                   ` Jacek Anaszewski
2018-12-20 20:31               ` Jacek Anaszewski
2018-12-21  7:32                 ` Jacek Anaszewski
2018-12-21 13:05                   ` Dan Murphy
2018-12-29 18:28                     ` Jacek Anaszewski
2018-12-29 19:07                       ` Pavel Machek
2018-12-30 17:09                         ` Jacek Anaszewski
2018-12-30 17:35                           ` Pavel Machek
2018-12-31 15:43                             ` Jacek Anaszewski
2018-12-31 15:47                               ` Jacek Anaszewski
2018-12-31 19:15                                 ` Dan Murphy
2019-01-01 14:42                                   ` Jacek Anaszewski
2019-01-01 18:11                                     ` Dan Murphy
2019-01-01 22:06                                       ` Jacek Anaszewski
2018-12-31 16:28                               ` Pavel Machek
2019-01-01 14:26                                 ` Jacek Anaszewski
2018-12-19 22:03             ` Pavel Machek
2018-12-19 22:08               ` Dan Murphy
2018-12-19 22:27                 ` Pavel Machek
2018-12-20  1:31                   ` Dan Murphy
2018-12-20  9:06                     ` Pavel Machek
2018-12-20 14:03                       ` Dan Murphy
2019-01-08 21:10   ` Jacek Anaszewski
2019-01-08 21:17     ` Dan Murphy
2019-07-22 20:59 ` Backlight in motorola Droid 4 Pavel Machek
2019-07-23 15:53   ` Dan Murphy
2019-07-24  8:22     ` Pavel Machek
2019-07-24 12:45     ` Pavel Machek
2019-07-24 15:10       ` Dan Murphy
2019-07-24 15:22       ` Dan Murphy
2019-07-26 14:38         ` Dan Murphy
2019-07-29 22:00           ` Pavel Machek
2019-07-30 18:21             ` Dan Murphy
2019-07-30 21:52               ` Pavel Machek

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=e99036ea-ffb6-83ab-726b-824e2557d161@gmail.com \
    --to=dachaac@gmail.com \
    --cc=devicetree@vger.kernel.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 \
    --cc=robh+dt@kernel.org \
    /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).