linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Murphy <dmurphy@ti.com>
To: Jacek Anaszewski <jacek.anaszewski@gmail.com>, <pavel@ucw.cz>
Cc: <linux-leds@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 6/9] leds: multicolor: Introduce a multicolor class definition
Date: Fri, 2 Aug 2019 09:14:33 -0500	[thread overview]
Message-ID: <eefe2541-29d4-e438-eade-6c15f506fc53@ti.com> (raw)
In-Reply-To: <f78ee3a4-596c-1b0c-3c91-15aad85ba9b2@gmail.com>

Jacek

On 7/31/19 3:44 PM, Jacek Anaszewski wrote:
> Dan,
>
[...]
> +    for (i = 0; i < mcled_cdev->num_leds; i++) {
> +        ret = sscanf(buf + offset, "%i%n", &value[i], &nrchars);
> +        if (ret != 1)
> +            break;
> +
> +        offset += nrchars;
> +    }
> +
> +    if (i != mcled_cdev->num_leds) {
>>> Shouldn't we return error if i != mcled_cdev->num_leds - 1 ?
>>> How can we know which color the value will be for if there is less
>>> values passed than the total number of colors in the cluster?
>> Ok so during my testing if I had the monochrome array as <R G B>
>>
>> When I wrote only <R G> and no blue I was getting random values in the
>> array for the
>>
>> remaining indexes and the blue LED would randomly turn on/off at
>> different levels.
>>
>> So if the user passes in less then expected only ids with data will be
>> written and the other colors will be turned off by the for loop below.
>  From what I see it will lead to wrong mapping of given color to the
> value array element in the following case:
>
> echo "<green> <blue>" > color_mix
>
> Then green intensity will be assigned to value[0] (expects red) and blue
> to value[1] (expects green). Unless I don't get something.
> Your ABI documentation doesn't mention any way to redefine the color_id
> returned by <color>/color_id file. And that is good.
>
This is exactly the issue I had previously brought up.  The user would 
need to

write all leading colors with a value, even if 0, to correctly set the 
target LEDs.

We can protect against the trailing colors but not leading colors.

The expectation is that the user space would read the color_id from the 
file and align

the array accordingly.  This is also why I exposed the intensity under 
the color so if the

user wanted to not use color_mix file they can update the intensity per 
LED color.

>>>> +        for (; i < LED_COLOR_ID_MAX; i++)
>>>> +            value[i] = 0;
>>> What use case is it for?
>> See above but this should be
>>
>> for (; i < mcled_cdev->num_leds; i++)
>>
I might be able to eliminate this loop by initializing the array to 0.


>>>> +    }
>>>> +
>>>> +    list_for_each_entry(priv, &data->color_list, list) {
>>>> +        if (data->cluster_brightness) {
>>>> +            adj_brightness =
>>>> calculate_brightness(data->cluster_brightness,
>>>> +                                  value[priv->color_index],
>>>> +                                 priv->max_intensity);
>>>> +            ret = ops->set_color_brightness(priv->mcled_cdev,
>>>> +                            priv->color_id,
>>>> +                            adj_brightness);
>>>> +            if (ret < 0)
>>>> +                goto done;
>>>> +        }
>>>> +
>>>> +        priv->intensity = value[priv->color_index];
>>>> +    }
>>> Here we could use just brightness_set op as a single call. We should
>>> always write all colors as a result of write to color_mix anyway.
>> I guess what is gained by just passing the array down to the device
>> driver and having it
>>
>> parse the array and do the peripheral call?
> Those array values would not be directly written to the device,
> but used for calculating the actual iout intensities. Driver
> will just have to call calculate_brightness() (sticking to the naming
> from this patch) and write the results calculated basing on brightness
> and max_brightness.

I would expect that we would do the same behavior for the color_mix file 
then.


> [...]
>>>> +
>>>> +    priv->new_intensity = value;
>>>> +
>>>> +    if (data->cluster_brightness) {
>>>> +        adj_value = calculate_brightness(data->cluster_brightness,
>>>> +                    priv->new_intensity,
>>>> +                    priv->max_intensity);
>>>> +        ret = ops->set_color_brightness(priv->mcled_cdev,
>>>> +                        priv->color_id, adj_value);
>>>> +        if (ret < 0) {
>>>> +            priv->new_intensity = priv->intensity;
>>> This is unnecessary complication. Just write the calculated iout
>>> intensity.
>> Not sure what complication you are referring to.
> The whole need for new_intensity and cluster_brightness, and then
> bringing back old intensity value on set_color_brightness() failure.

OK

>
>>> We need to highlight it in the documentation that exact requested color
>>> intensity values are written to the hardware only when
>>> brightness == max_brightness.
>> But that is not a true statement.  Thats not really how it was designed.
> But it probably should be. It would simplify the design.
>
> So my idea is like I previously described the way I had first understood
> this design:
>
> The colors set under colors directory don't reflect the iout
> intensities, but are only used for calculating them, basing on the
> brightness and max_intensity values.
>
> Effectively, after changing the colors/<color>/intensity the global
> (legacy monochrome) brightness value will be still valid, since iout
> color will be recalculated basing on it and the new color intensity.
>
OK.  This this would remove the ops from the driver as it is no longer 
needed.

The color_mix file will work the same way.

What is the trigger then to update the LEDs?

We cannot write the same brightness value to trigger as the class blocks 
calling down

to the driver if brightness_in == brightness_current.

Dan


  reply	other threads:[~2019-08-02 14:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-25 18:28 [PATCH v4 0/9] Multicolor Framwork Dan Murphy
2019-07-25 18:28 ` [PATCH v4 1/9] leds: multicolor: Add sysfs interface definition Dan Murphy
2019-07-29 20:45   ` Jacek Anaszewski
2019-08-27 16:54     ` Dan Murphy
2019-07-25 18:28 ` [PATCH v4 2/9] documention: leds: Add multicolor class documentation Dan Murphy
2019-07-29 20:46   ` Jacek Anaszewski
2019-07-25 18:28 ` [PATCH v4 3/9] dt: bindings: Add multicolor class dt bindings documention Dan Murphy
2019-07-29 20:47   ` Jacek Anaszewski
2019-07-25 18:28 ` [PATCH v4 4/9] dt-bindings: leds: Add multicolor ID to the color ID list Dan Murphy
2019-07-25 18:28 ` [PATCH v4 5/9] " Dan Murphy
2019-07-25 18:28 ` [PATCH v4 6/9] leds: multicolor: Introduce a multicolor class definition Dan Murphy
2019-07-29 20:50   ` Jacek Anaszewski
2019-07-31 19:06     ` Dan Murphy
2019-07-31 20:44       ` Jacek Anaszewski
2019-08-02 14:14         ` Dan Murphy [this message]
2019-08-02 19:27           ` Jacek Anaszewski
2019-07-25 18:28 ` [PATCH v4 7/9] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers Dan Murphy
2019-07-25 18:28 ` [PATCH v4 8/9] leds: lp50xx: Add the LP50XX family of the RGB LED driver Dan Murphy
2019-07-30 21:24   ` Jacek Anaszewski
2019-07-31 18:46     ` Dan Murphy
2019-07-25 18:28 ` [PATCH v4 9/9] leds: Update the lp55xx to use the multi color framework Dan Murphy
2019-07-31 18:45   ` Jacek Anaszewski
2019-07-31 18:55     ` Dan Murphy
2019-07-31 19:45       ` Jacek Anaszewski
2019-07-31 19:49         ` 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=eefe2541-29d4-e438-eade-6c15f506fc53@ti.com \
    --to=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).