Commit fef7764f8bca9d603a8a51dcb522db97739a33c2

Authored by Arun Murthy
Committed by Linus Torvalds
1 parent a1025e224c

backlight: add low threshold to pwm backlight

The intensity of the backlight can be varied from a range of
max_brightness to zero.  Though most, if not all the pwm based backlight
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 for the pwm based backlight
device has to be a linear graph.

intensity
	  |   /
	  |  /
	  | /
	  |/
	  ---------
	 0	max_brightness

But pratically on measuring the above we note that the intensity of
backlight 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 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.  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.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Arun Murthy <arun.murthy@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Acked-by: Richard Purdie <rpurdie@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 7 additions and 1 deletions Side-by-side Diff

drivers/video/backlight/pwm_bl.c
... ... @@ -25,6 +25,7 @@
25 25 struct pwm_device *pwm;
26 26 struct device *dev;
27 27 unsigned int period;
  28 + unsigned int lth_brightness;
28 29 int (*notify)(struct device *,
29 30 int brightness);
30 31 };
... ... @@ -48,7 +49,9 @@
48 49 pwm_config(pb->pwm, 0, pb->period);
49 50 pwm_disable(pb->pwm);
50 51 } else {
51   - pwm_config(pb->pwm, brightness * pb->period / max, pb->period);
  52 + brightness = pb->lth_brightness +
  53 + (brightness * (pb->period - pb->lth_brightness) / max);
  54 + pwm_config(pb->pwm, brightness, pb->period);
52 55 pwm_enable(pb->pwm);
53 56 }
54 57 return 0;
... ... @@ -92,6 +95,8 @@
92 95  
93 96 pb->period = data->pwm_period_ns;
94 97 pb->notify = data->notify;
  98 + pb->lth_brightness = data->lth_brightness *
  99 + (data->pwm_period_ns / data->max_brightness);
95 100 pb->dev = &pdev->dev;
96 101  
97 102 pb->pwm = pwm_request(data->pwm_id, "backlight");
include/linux/pwm_backlight.h
... ... @@ -8,6 +8,7 @@
8 8 int pwm_id;
9 9 unsigned int max_brightness;
10 10 unsigned int dft_brightness;
  11 + unsigned int lth_brightness;
11 12 unsigned int pwm_period_ns;
12 13 int (*init)(struct device *dev);
13 14 int (*notify)(struct device *dev, int brightness);