Linux LED subsystem development
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Pavel Machek <pavel@ucw.cz>
Cc: linux-leds@vger.kernel.org, Lee Jones <lee@kernel.org>
Subject: Re: [PATCH v2 1/3] leds: turris-omnia: change max brightness from 255 to 1
Date: Sun, 16 Jul 2023 17:01:12 +0200	[thread overview]
Message-ID: <20230716170112.1f90670a@thinkpad> (raw)
In-Reply-To: <20230716091929.GA1182@bug>

On Sun, 16 Jul 2023 11:19:30 +0200
Pavel Machek <pavel@ucw.cz> wrote:

> Hi!
> 
> > Using binary brightness makes more sense for this controller, because
> > internally in the MCU it works that way: the LED has a color, and a
> > state whether it is ON or OFF.  
> 
> So, controller can do (1, 3, 5) but not (3, 3, 3)?
> 
> > The resulting brightness computation with led_mc_calc_color_components()
> > will now always result in either (0, 0, 0) or the multi_intensity value.  
> 
> Won't that limit you to 8 colors total?
> 
> I guess I`m confused how this hw works...

Hi Pavel.

No no no. That's not how it is.

The HW exposes color control for three channels (RGB), each channel with
range 0-255 (so 16M colors). The driver exposes this via the
multi_intensity sysfs file. This is communicated to the HW via
LED_SET_COLOR I2C command.

HW also exposes setting the LED ON and OFF, via the LED_SET_STATE
I2C command.

We currently have the following sysfs files via which we set LED state
and color:
  brightness
  multi_intensity

Because currently the driver sets max_brightness to 255, the actual
color that is sent to HW is recalculated via
led_mc_calc_color_components(). For example with

  $ echo 255 255 100 >multi_intensity
  $ echo 150 >brightness

the led_mc_calc_color_components() function recalculates the channel
intensities with formula
  brightness * channel_intensity / max_brightness
and so the (255, 255, 100) tuple is converted to (150, 150, 58) before
sending to HW.

What I think would make more sense is to make the two sysfs files
  brightness
  multi_intensity
correspond 1-to-1 with I2C commands LED_SET_STATE and LED_SET_COLOR.

This can be simply done by setting max_brightness to 1. The brightness
sysfs file then can simply control whether the LED is ON or OFF. The
multi_intensity file control the color.

I realize now that in the patch I should also make away with the call
to led_mc_calc_color_components()...

Marek

  reply	other threads:[~2023-07-16 15:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-14  8:52 [PATCH v2 0/3] leds: turris-omnia: updates Marek Behún
2023-07-14  8:52 ` [PATCH v2 1/3] leds: turris-omnia: change max brightness from 255 to 1 Marek Behún
2023-07-16  9:19   ` Pavel Machek
2023-07-16 15:01     ` Marek Behún [this message]
2023-07-28  9:56       ` Lee Jones
2023-07-28 10:10       ` Pavel Machek
2023-08-01  9:07         ` Marek Behún
2023-07-14  8:52 ` [PATCH v2 2/3] leds: turris-omnia: initialize multi-intensity to full Marek Behún
2023-07-16  9:19   ` Pavel Machek
2023-07-14  8:52 ` [PATCH v2 3/3] leds: turris-omnia: support HW controlled mode via private trigger Marek Behún

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=20230716170112.1f90670a@thinkpad \
    --to=kabel@kernel.org \
    --cc=lee@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