From: Shreshtha Kumar SAHU <shreshthakumar.sahu@stericsson.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Andrew Morton <akpm@linux-foundation.org>,
Denis Kuzmenko <linux@solonet.org.ua>,
Linus WALLEIJ <linus.walleij@stericsson.com>,
Richard Purdie <rpurdie@rpsys.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Samuel Ortiz <sameo@linux.intel.com>
Subject: Re: [PATCH] leds: driver for ab5500 high voltage leds
Date: Fri, 16 Dec 2011 10:40:31 +0530 [thread overview]
Message-ID: <20111216051031.GA13690@bnru05.bnr.st.com> (raw)
In-Reply-To: <20111215071113.GD24248@opensource.wolfsonmicro.com>
On Thu, Dec 15, 2011 at 08:11:14 +0100, Mark Brown wrote:
> On Wed, Dec 14, 2011 at 07:34:50PM +0100, Linus Walleij wrote:
>
> > The problem is I think this table is dependent on the LED fitted
> > and needs to be supplied as platform data from the board,
> > which knows which LED is on that board.
>
> To a good approximation the restriction from the LED comes from the
> maximum current it can sustain so it's usually a fairly simple input.
As I understnad, please corrent me if I am worng, it is decided during
platform design and setting the max current for each LED in a platform
fulfills the above requirement which is already taken care in driver.
Based on suggestion by Mark, to control both PWM and Sink current to
vary brightness, here is the outcome:
How it was:
Max sink current was set for each LED (range 2.5mA to 40mA), and PWM
was varied to get the desired brightness (PWM in range 0 to 1023).
Current increase on each PWM increase was constant i.e. max_curr/1023.
How it is now:
Max sink current is known, but sink current value is set along with
PWM to control the brightness. So now with each request to increase
brightness, sink current is determined based on:
requested_brt / (LED_FULL/SINKCURR_MAX)
In this case requested_brt vary from 0 to 255 and SINKCURR_MAX is 15.
Now sink_current is changing, hence current increase on each PWM increase
will vary based on:
As current increase on each PWM increase is based on (sink_current / PWM_MAX)
where PWM_MAX is 1023. But now sink_currnet is changing so current increase
on each PWM increase will also change.
So the idea in implementation is to change the sink_current and calculate
the PWM value based on currently set sink current, so that the current
change on each PWM rise remains same.
Implementation is greatly simplified by following lookup table:
#define AB5500_LED_SINKCURR_MAX 0x0F
#define AB5500_LED_SINKCURR_STEPS(_max_curr) (LED_FULL/(_max_curr))
/*
* This table provides the multiplier to get linear variation of current
* and hence led brightness. In actual these are PWM steps multiplier to
* get PWM value such that the current vary linearly (as sink current
* along with PWM is configured) and hence the led brightness.
*
* rows are max_current set for the led instance
* cols are current step of 16 step current stair
*
*/
static u8 led_lin_table[AB5500_LED_SINKCURR_MAX+2]
[AB5500_LED_SINKCURR_MAX+2] = {
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
{8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
{12, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
{16, 8, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
{20, 10, 7, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
{24, 12, 8, 6, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
{28, 14, 9, 7, 6, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
{32, 16, 11, 8, 6, 5, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0,},
{36, 18, 12, 9, 7, 6, 5, 4, 4, 0, 0, 0, 0, 0, 0, 0,},
{40, 20, 13, 10, 8, 7, 6, 5, 4, 4, 0, 0, 0, 0, 0, 0,},
{44, 22, 15, 11, 9, 7, 6, 5, 5, 4, 4, 0, 0, 0, 0, 0,},
{48, 24, 16, 12, 10, 8, 7, 6, 5, 5, 4, 4, 0, 0, 0, 0,},
{52, 26, 17, 13, 10, 9, 7, 6, 6, 5, 5, 4, 4, 0, 0, 0,},
{56, 28, 19, 14, 11, 9, 8, 7, 6, 5, 5, 5, 4, 4, 0, 0,},
{60, 30, 20, 15, 12, 10, 8, 7, 7, 6, 5, 5, 5, 4, 4, 0,},
{64, 32, 21, 16, 13, 11, 9, 8, 7, 6, 6, 5, 5, 4, 4, 4,},
};
And the formula used when brightness change is requested from user:
u8 curr_max = led->max_current, curr_val;
u16 pwm_val;
curr_val = (led->brt_val / (AB5500_LED_SINKCURR_STEPS(curr_max)));
pwm_val = led->brt_val * led_lin_table[curr_max][curr_val];
Please provide feedback on this, if it fulfills the requirement.
Regards,
Shreshtha
next prev parent reply other threads:[~2011-12-16 5:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-02 13:56 Linus Walleij
2011-12-03 21:49 ` Mark Brown
2011-12-07 14:16 ` Linus Walleij
2011-12-07 15:47 ` Mark Brown
2011-12-03 22:49 ` Denis Kuzmenko
2011-12-07 14:07 ` Linus Walleij
2011-12-07 18:01 ` Denis Kuzmenko
2011-12-08 0:00 ` Andrew Morton
2011-12-08 1:19 ` Mark Brown
2011-12-14 10:23 ` Shreshtha Kumar SAHU
2011-12-14 11:37 ` Mark Brown
2011-12-14 14:01 ` Shreshtha Kumar SAHU
2011-12-14 14:47 ` Mark Brown
2011-12-14 18:34 ` Linus Walleij
2011-12-15 7:11 ` Mark Brown
2011-12-16 5:10 ` Shreshtha Kumar SAHU [this message]
2011-12-22 17:43 ` Mark Brown
2011-12-19 11:26 ` Samuel Ortiz
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=20111216051031.GA13690@bnru05.bnr.st.com \
--to=shreshthakumar.sahu@stericsson.com \
--cc=akpm@linux-foundation.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linus.walleij@linaro.org \
--cc=linus.walleij@stericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@solonet.org.ua \
--cc=rpurdie@rpsys.net \
--cc=sameo@linux.intel.com \
/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
all inboxes | Powered by JetHome®