diff options
author | Philippe Langlais <philippe.langlais@linaro.org> | 2011-03-23 15:47:22 +0100 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@stericsson.com> | 2011-09-19 15:14:38 +0200 |
commit | 13561778b94de34244746c8235b2d698bd416a2f (patch) | |
tree | 958c92e5524ef0cfb08fb97e7c9a22707e52974c | |
parent | 704a74e7be09a90a55beca53e4ff8f942dd4e529 (diff) |
backlight/leds: add low threshold to pwm backlight/led
The intensity of the backlight/led can be varied from a range of
max_brightness to zero. Though most, if not all the pwm based
backlight/led devices start flickering at lower brightness value.
And also for each device there exists a brightness value below
which the backlight appears to be turned off though the value is
not equal to zero.
If the range of brightness for a device is from zero to
max_brightness. A graph is plotted for brightness Vs intensity fo the
pwm based backlight/led device has to be a linear graph.
intensity
| /
| /
| /
|/
---------
0 max_brightness
But pratically on measuring the above we note that the intensity of
backlight/led goes to zero(OFF) when the value in not zero almost nearing to
zero(some x%). so the graph looks like
intensity
| /
| /
| /
| |
------------
0 x max_brightness
In order to overcome this drawback knowing this x% i.e nothing but the
low threshold beyond which the backlight/led is off and will have no effect,
the brightness value is being offset by the low threshold
value(retaining the linearity of the graph). Now the graph becomes
intensity
| /
| /
| /
| /
-------------
0 max_brightness
With this for each and every digit increment in the brightness from zero
there is a change in the intensity of backlight/led.
Devices having this behaviour can set the low threshold
brightness(lth_brightness) and pass the same as platform data else can
have it as zero.
ST-Ericsson ID: Task168737
Change-Id: I7198ec89aa69e0c687d329b21f723fd8d5368928
Signed-off-by: Prajadevi H <prajadevi.h@stericsson.com>
Signed-off-by: Arun Murthy <arun.murthy@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/5231
Reviewed-by: Linus WALLEIJ <linus.walleij@stericsson.com>
-rw-r--r-- | drivers/leds/leds-pwm.c | 8 | ||||
-rw-r--r-- | include/linux/leds_pwm.h | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index 666daf77872..775cd67c604 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -27,6 +27,7 @@ struct led_pwm_data { struct led_classdev cdev; struct pwm_device *pwm; unsigned int active_low; + unsigned int lth_brightness; unsigned int period; }; @@ -42,7 +43,10 @@ static void led_pwm_set(struct led_classdev *led_cdev, pwm_config(led_dat->pwm, 0, period); pwm_disable(led_dat->pwm); } else { - pwm_config(led_dat->pwm, brightness * period / max, period); + brightness = led_dat->lth_brightness + (brightness * + (led_dat->period - led_dat->lth_brightness) / max); + pwm_config(led_dat->pwm, brightness, led_dat->period); + pwm_enable(led_dat->pwm); } } @@ -79,6 +83,8 @@ static int led_pwm_probe(struct platform_device *pdev) led_dat->cdev.default_trigger = cur_led->default_trigger; led_dat->active_low = cur_led->active_low; led_dat->period = cur_led->pwm_period_ns; + led_dat->lth_brightness = cur_led->lth_brightness * + (cur_led->pwm_period_ns / cur_led->max_brightness); led_dat->cdev.brightness_set = led_pwm_set; led_dat->cdev.brightness = LED_OFF; led_dat->cdev.max_brightness = cur_led->max_brightness; diff --git a/include/linux/leds_pwm.h b/include/linux/leds_pwm.h index 33a07116748..9c5eab6e086 100644 --- a/include/linux/leds_pwm.h +++ b/include/linux/leds_pwm.h @@ -11,6 +11,7 @@ struct led_pwm { u8 active_low; unsigned max_brightness; unsigned pwm_period_ns; + unsigned int lth_brightness; }; struct led_pwm_platform_data { |