2015-02-19 21:14:51

by Felipe Balbi

[permalink] [raw]
Subject: "advanced" LED controllers

Hi,

Do we have support for LED controllers which can handle patterns of
different kinds ? I mean, currently, if we have an LED controller such
as TPIC2810 [1] which can control 8 different leds and each LED
corresponds to one bit on register 0x44, we could control leds by just
"playing" a wave file on the controller and create easy patterns with
that.

AFAICT, in linux today we would have to register each of the 8 LEDs as a
different LED and have driver magic to write the proper bits on register
0x44, that seems a bit overkill, specially when we want to make
patterns: instead of writing 0xff we would have to write 0x80, 0x40,
0x20, 0x10, 0x08, 0x04, 0x02, 0x01 separately and have the driver cache
the previous results so we don't end up switching off other LEDs.

IOW, what could be handled with a single write, currently needs 8.

I wonder if there's any work happening to support these slightly more
inteligent LED engines.

regards

[1] http://www.ti.com/product/tpic2810

ps: tpic2810 is probably the simplest example, lp551, lp5523 and others
have even more advanced pattern engines which can even handle RGB leds.

Currently the driver loads patterns as if it was a firmware blob and
registers each of R, G and B components as separate LEDs. Each component
also has its own brightness controls (something tpic2810 doesn't have,
it's either on or off).

--
balbi


Attachments:
(No filename) (1.35 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2015-02-23 22:35:05

by Pavel Machek

[permalink] [raw]
Subject: Re: "advanced" LED controllers

On Thu 2015-02-19 15:14:24, Felipe Balbi wrote:
> Hi,
>
> Do we have support for LED controllers which can handle patterns of
> different kinds ? I mean, currently, if we have an LED controller such
> as TPIC2810 [1] which can control 8 different leds and each LED
> corresponds to one bit on register 0x44, we could control leds by just
> "playing" a wave file on the controller and create easy patterns with
> that.
>
> AFAICT, in linux today we would have to register each of the 8 LEDs as a
> different LED and have driver magic to write the proper bits on register
> 0x44, that seems a bit overkill, specially when we want to make
> patterns: instead of writing 0xff we would have to write 0x80, 0x40,
> 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 separately and have the driver cache
> the previous results so we don't end up switching off other LEDs.
>
> IOW, what could be handled with a single write, currently needs 8.
>
> I wonder if there's any work happening to support these slightly more
> inteligent LED engines.
>
> regards
>
> [1] http://www.ti.com/product/tpic2810
>
> ps: tpic2810 is probably the simplest example, lp551, lp5523 and others
> have even more advanced pattern engines which can even handle RGB leds.

Well... some more advanced pattern engines can actually run code, up
to and including prime number computation. So yes, this is complex,
and how to handle it nicely is a question...

I have "notcc" to compile for that.

#!/usr/bin/python3
#
# NOTification Compiler
#
# for LP5523 chip.
#
# Copyright 2014 Pavel Machek <[email protected]>, GPLv3
#
# http://wiki.maemo.org/LED_patterns#Lysti_Format_Engine_Patterns_and_Commands
# http://www.ti.com/general/docs/lit/getliterature.tsp?genericPartNumber=lp5523&fileType=pdf
#
# Seems to have A,B local variables, C global variable,
#
# 2.6.28-omap1 seems to cut execution after 16 steps.

import sys



Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-02-23 22:59:12

by Felipe Balbi

[permalink] [raw]
Subject: Re: "advanced" LED controllers

On Mon, Feb 23, 2015 at 11:34:57PM +0100, Pavel Machek wrote:
> On Thu 2015-02-19 15:14:24, Felipe Balbi wrote:
> > Hi,
> >
> > Do we have support for LED controllers which can handle patterns of
> > different kinds ? I mean, currently, if we have an LED controller such
> > as TPIC2810 [1] which can control 8 different leds and each LED
> > corresponds to one bit on register 0x44, we could control leds by just
> > "playing" a wave file on the controller and create easy patterns with
> > that.
> >
> > AFAICT, in linux today we would have to register each of the 8 LEDs as a
> > different LED and have driver magic to write the proper bits on register
> > 0x44, that seems a bit overkill, specially when we want to make
> > patterns: instead of writing 0xff we would have to write 0x80, 0x40,
> > 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 separately and have the driver cache
> > the previous results so we don't end up switching off other LEDs.
> >
> > IOW, what could be handled with a single write, currently needs 8.
> >
> > I wonder if there's any work happening to support these slightly more
> > inteligent LED engines.
> >
> > regards
> >
> > [1] http://www.ti.com/product/tpic2810
> >
> > ps: tpic2810 is probably the simplest example, lp551, lp5523 and others
> > have even more advanced pattern engines which can even handle RGB leds.
>
> Well... some more advanced pattern engines can actually run code, up
> to and including prime number computation. So yes, this is complex,
> and how to handle it nicely is a question...
>
> I have "notcc" to compile for that.

right, the point is that this is a solution which only works with lp5523
and IMO linux led subsystem should do a little more for such devices.

--
balbi


Attachments:
(No filename) (1.70 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2015-02-25 08:25:26

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: "advanced" LED controllers

CC linux-gpio, as this looks like the LED equivalent of bulk gpio?

On Thu, Feb 19, 2015 at 10:14 PM, Felipe Balbi <[email protected]> wrote:
> Do we have support for LED controllers which can handle patterns of
> different kinds ? I mean, currently, if we have an LED controller such
> as TPIC2810 [1] which can control 8 different leds and each LED
> corresponds to one bit on register 0x44, we could control leds by just
> "playing" a wave file on the controller and create easy patterns with
> that.
>
> AFAICT, in linux today we would have to register each of the 8 LEDs as a
> different LED and have driver magic to write the proper bits on register
> 0x44, that seems a bit overkill, specially when we want to make
> patterns: instead of writing 0xff we would have to write 0x80, 0x40,
> 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 separately and have the driver cache
> the previous results so we don't end up switching off other LEDs.
>
> IOW, what could be handled with a single write, currently needs 8.
>
> I wonder if there's any work happening to support these slightly more
> inteligent LED engines.
>
> regards
>
> [1] http://www.ti.com/product/tpic2810
>
> ps: tpic2810 is probably the simplest example, lp551, lp5523 and others
> have even more advanced pattern engines which can even handle RGB leds.
>
> Currently the driver loads patterns as if it was a firmware blob and
> registers each of R, G and B components as separate LEDs. Each component
> also has its own brightness controls (something tpic2810 doesn't have,
> it's either on or off).

2015-02-25 09:06:35

by Alexandre Courbot

[permalink] [raw]
Subject: Re: "advanced" LED controllers

On Wed, Feb 25, 2015 at 5:25 PM, Geert Uytterhoeven
<[email protected]> wrote:
> CC linux-gpio, as this looks like the LED equivalent of bulk gpio?

Indeed. The LED core could implement something similar to
gpiod_set_array() to allow several LEDs to be set in one call. If the
controller supports it, it would then set all the LEDs at once,
otherwise the core would apply the values serially.

In leds-gpio.c, this multiple LED setting could be implemented by a
single call to gpiod_set_array() and the right thing would happen.

>
> On Thu, Feb 19, 2015 at 10:14 PM, Felipe Balbi <[email protected]> wrote:
>> Do we have support for LED controllers which can handle patterns of
>> different kinds ? I mean, currently, if we have an LED controller such
>> as TPIC2810 [1] which can control 8 different leds and each LED
>> corresponds to one bit on register 0x44, we could control leds by just
>> "playing" a wave file on the controller and create easy patterns with
>> that.
>>
>> AFAICT, in linux today we would have to register each of the 8 LEDs as a
>> different LED and have driver magic to write the proper bits on register
>> 0x44, that seems a bit overkill, specially when we want to make
>> patterns: instead of writing 0xff we would have to write 0x80, 0x40,
>> 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 separately and have the driver cache
>> the previous results so we don't end up switching off other LEDs.
>>
>> IOW, what could be handled with a single write, currently needs 8.
>>
>> I wonder if there's any work happening to support these slightly more
>> inteligent LED engines.
>>
>> regards
>>
>> [1] http://www.ti.com/product/tpic2810
>>
>> ps: tpic2810 is probably the simplest example, lp551, lp5523 and others
>> have even more advanced pattern engines which can even handle RGB leds.
>>
>> Currently the driver loads patterns as if it was a firmware blob and
>> registers each of R, G and B components as separate LEDs. Each component
>> also has its own brightness controls (something tpic2810 doesn't have,
>> it's either on or off).
> --
> To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2015-02-25 21:49:51

by Pavel Machek

[permalink] [raw]
Subject: Re: "advanced" LED controllers

On Mon 2015-02-23 16:58:36, Felipe Balbi wrote:
> On Mon, Feb 23, 2015 at 11:34:57PM +0100, Pavel Machek wrote:
> > On Thu 2015-02-19 15:14:24, Felipe Balbi wrote:
> > > Hi,
> > >
> > > Do we have support for LED controllers which can handle patterns of
> > > different kinds ? I mean, currently, if we have an LED controller such
> > > as TPIC2810 [1] which can control 8 different leds and each LED
> > > corresponds to one bit on register 0x44, we could control leds by just
> > > "playing" a wave file on the controller and create easy patterns with
> > > that.

> > > [1] http://www.ti.com/product/tpic2810
> > >
> > > ps: tpic2810 is probably the simplest example, lp551, lp5523 and others
> > > have even more advanced pattern engines which can even handle RGB leds.
> >
> > Well... some more advanced pattern engines can actually run code, up
> > to and including prime number computation. So yes, this is complex,
> > and how to handle it nicely is a question...
> >
> > I have "notcc" to compile for that.
>
> right, the point is that this is a solution which only works with lp5523
> and IMO linux led subsystem should do a little more for such devices.

Well, question is what we want. Possibilities I see:

1) We won't support all the features, just some common subset. Kernel
will get commands for LED controller and translate them. Question is
what reasonable subset is, then.

I guess "delay", "set led brightness to X", "jump" would be minimal
shared command set. lp5523 can do also "slowly increase/decrease
brightness to X" (I believe we should support that one), arithmetics,
conditional jumps, and communications between 3 threads.

2) We want to support all the features. I guess that would mean doing
compilation in userspace, and having "compiler" for each led
controller. Having common source code would still be nice.

Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2015-02-25 23:56:07

by NeilBrown

[permalink] [raw]
Subject: Re: "advanced" LED controllers

On Wed, 25 Feb 2015 22:49:41 +0100 Pavel Machek <[email protected]> wrote:

> On Mon 2015-02-23 16:58:36, Felipe Balbi wrote:
> > On Mon, Feb 23, 2015 at 11:34:57PM +0100, Pavel Machek wrote:
> > > On Thu 2015-02-19 15:14:24, Felipe Balbi wrote:
> > > > Hi,
> > > >
> > > > Do we have support for LED controllers which can handle patterns of
> > > > different kinds ? I mean, currently, if we have an LED controller such
> > > > as TPIC2810 [1] which can control 8 different leds and each LED
> > > > corresponds to one bit on register 0x44, we could control leds by just
> > > > "playing" a wave file on the controller and create easy patterns with
> > > > that.
>
> > > > [1] http://www.ti.com/product/tpic2810
> > > >
> > > > ps: tpic2810 is probably the simplest example, lp551, lp5523 and others
> > > > have even more advanced pattern engines which can even handle RGB leds.
> > >
> > > Well... some more advanced pattern engines can actually run code, up
> > > to and including prime number computation. So yes, this is complex,
> > > and how to handle it nicely is a question...
> > >
> > > I have "notcc" to compile for that.
> >
> > right, the point is that this is a solution which only works with lp5523
> > and IMO linux led subsystem should do a little more for such devices.
>
> Well, question is what we want. Possibilities I see:
>
> 1) We won't support all the features, just some common subset. Kernel
> will get commands for LED controller and translate them. Question is
> what reasonable subset is, then.
>
> I guess "delay", "set led brightness to X", "jump" would be minimal
> shared command set. lp5523 can do also "slowly increase/decrease
> brightness to X" (I believe we should support that one), arithmetics,
> conditional jumps, and communications between 3 threads.
>
> 2) We want to support all the features. I guess that would mean doing
> compilation in userspace, and having "compiler" for each led
> controller. Having common source code would still be nice.
>
> Pavel

All (most) current options for controlling LEDs are based on what a user
might want, rather than what the hardware can provide.

I think it would be good to keep that approach, but add more "interesting"
functions which each hardware can support in whichever way suits it best.

So "ramp_blink" which allow a ramp on/off time to be specified would be
useful.

"audio_meter" which allows a particular sound card (or output or something)
to be specified would also be useful. You could also specify a what volume
the LED saturates.
Then if you set each led on a given controller to saturate at different level
and to use the same sound source, then you could get the "graphic equaliser"
effect.

Maybe 'blinking' should have a 'synchronise' setting to that a bunch of LEDs
can be synchonised so you can create a "cylon eye" effect.

i.e. don't focus on the low-level 'what can we provide' but on the high level
"what might users want".

NeilBrown


Attachments:
(No filename) (811.00 B)
OpenPGP digital signature

2015-02-28 16:18:33

by Pavel Machek

[permalink] [raw]
Subject: Re: "advanced" LED controllers

Hi!

On Thu 2015-02-26 10:55:52, NeilBrown wrote:
> On Wed, 25 Feb 2015 22:49:41 +0100 Pavel Machek <[email protected]> wrote:
>
> > On Mon 2015-02-23 16:58:36, Felipe Balbi wrote:
> > > On Mon, Feb 23, 2015 at 11:34:57PM +0100, Pavel Machek wrote:
> > > > On Thu 2015-02-19 15:14:24, Felipe Balbi wrote:
> > > > > Hi,
> > > > >
> > > > > Do we have support for LED controllers which can handle patterns of
> > > > > different kinds ? I mean, currently, if we have an LED controller such
> > > > > as TPIC2810 [1] which can control 8 different leds and each LED
> > > > > corresponds to one bit on register 0x44, we could control leds by just
> > > > > "playing" a wave file on the controller and create easy patterns with
> > > > > that.
> >
> > > > > [1] http://www.ti.com/product/tpic2810

Does tpic2810 support brightness on the LEDs, or is it just one bit
per led?

> > Well, question is what we want. Possibilities I see:
> >
> > 1) We won't support all the features, just some common subset. Kernel
> > will get commands for LED controller and translate them. Question is
> > what reasonable subset is, then.
> >
> > I guess "delay", "set led brightness to X", "jump" would be minimal
> > shared command set. lp5523 can do also "slowly increase/decrease
> > brightness to X" (I believe we should support that one), arithmetics,
> > conditional jumps, and communications between 3 threads.
> >
> > 2) We want to support all the features. I guess that would mean doing
> > compilation in userspace, and having "compiler" for each led
> > controller. Having common source code would still be nice.
>
> All (most) current options for controlling LEDs are based on what a user
> might want, rather than what the hardware can provide.
>
> I think it would be good to keep that approach, but add more "interesting"
> functions which each hardware can support in whichever way suits it best.
>
> So "ramp_blink" which allow a ramp on/off time to be specified would be
> useful.

Well, ramp_blink would certainly cover a lot of cases, but not
everything. For example, I'd like to do "ramp to 25% brightness, wait,
ramp to 50% brightness,

> > Well, question is what we want. Possibilities I see:
> >
> > 1) We won't support all the features, just some common subset. Kernel
> > will get commands for LED controller and translate them. Question is
> > what reasonable subset is, then.
> >
> > I guess "delay", "set led brightness to X", "jump" would be minimal
> > shared command set. lp5523 can do also "slowly increase/decrease
> > brightness to X" (I believe we should support that one), arithmetics,
> > conditional jumps, and communications between 3 threads.
> >
> > 2) We want to support all the features. I guess that would mean doing
> > compilation in userspace, and having "compiler" for each led
> > controller. Having common source code would still be nice.
>
> All (most) current options for controlling LEDs are based on what a user
> might want, rather than what the hardware can provide.
>
> I think it would be good to keep that approach, but add more "interesting"
> functions which each hardware can support in whichever way suits it best.
>
> So "ramp_blink" which allow a ramp on/off time to be specified would be
> useful.

Well, ramp_blink would certainly cover a lot of cases, but not
everything. For example, I'd like to do "ramp to 25% brightness, wait,
ramp to 50% brightness

> > Well, question is what we want. Possibilities I see:
> >
> > 1) We won't support all the features, just some common subset. Kernel
> > will get commands for LED controller and translate them. Question is
> > what reasonable subset is, then.
> >
> > I guess "delay", "set led brightness to X", "jump" would be minimal
> > shared command set. lp5523 can do also "slowly increase/decrease
> > brightness to X" (I believe we should support that one), arithmetics,
> > conditional jumps, and communications between 3 threads.
> >
> > 2) We want to support all the features. I guess that would mean doing
> > compilation in userspace, and having "compiler" for each led
> > controller. Having common source code would still be nice.
>
> All (most) current options for controlling LEDs are based on what a user
> might want, rather than what the hardware can provide.
>
> I think it would be good to keep that approach, but add more "interesting"
> functions which each hardware can support in whichever way suits it best.
>
> So "ramp_blink" which allow a ramp on/off time to be specified would be
> useful.

Well, ramp_blink would certainly cover a lot of cases, but not
everything. For example, I'd like to do "ramp to 25% brightness, wait,
ramp to 50% brightness,

> > Well, question is what we want. Possibilities I see:
> >
> > 1) We won't support all the features, just some common subset. Kernel
> > will get commands for LED controller and translate them. Question is
> > what reasonable subset is, then.
> >
> > I guess "delay", "set led brightness to X", "jump" would be minimal
> > shared command set. lp5523 can do also "slowly increase/decrease
> > brightness to X" (I believe we should support that one), arithmetics,
> > conditional jumps, and communications between 3 threads.
> >
> > 2) We want to support all the features. I guess that would mean doing
> > compilation in userspace, and having "compiler" for each led
> > controller. Having common source code would still be nice.
>
> All (most) current options for controlling LEDs are based on what a user
> might want, rather than what the hardware can provide.
>
> I think it would be good to keep that approach, but add more "interesting"
> functions which each hardware can support in whichever way suits it best.
>
> So "ramp_blink" which allow a ramp on/off time to be specified would be
> useful.

Well, ramp_blink would certainly cover a lot of cases, but not
everything. For example, I'd like to do "ramp to 25% brightness, wait,
ramp to 50% brightness, wait, ramp to 75% brightness, wait, ramp to
100% brightness, wait, ramp back to 0" pattern to indicate charging..

Also, I'd like to do "smoothly go through colors of rainbow" pattern
to indicate booting.

So yes, "ramp_blink" would cover some common cases, but not nearly everything.

> "audio_meter" which allows a particular sound card (or output or something)
> to be specified would also be useful. You could also specify a what volume
> the LED saturates.

audio_meter would have to be done by software, as hardware can not
really accelerate that.

256 brightness values to cycle through for each r/g/b channel might be
enough for most patterns... but it would be quite hard to "compile"
that into program for lp5523.

Other solution would be specifying series of "time, brightness"
points, with expectation of linear change between those".

So [ 0sec, 0%; 1sec, 0%; 1sec, 100%] would be turn the LED on quickly,
and [ 0sec, 0%, 1sec, 100% ] would be slowly ramp the LED over one
second.

Advantage would be that it should be fairly easy to compile from this
to lp5523 and similar.

> Maybe 'blinking' should have a 'synchronise' setting to that a bunch of LEDs
> can be synchonised so you can create a "cylon eye" effect.

> i.e. don't focus on the low-level 'what can we provide' but on the high level
> "what might users want".

See above what I'd want, and

http://my-maemo.com/software/applications.php?fldAuto=1275&faq=42
http://my-maemo.com/software/applications.php?fldAuto=2096&faq=42
https://wiki.maemo.org/LED_patterns

what other people want.

Best regards,

Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html