提交 fef7764f 编写于 作者: A Arun Murthy 提交者: Linus Torvalds

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: NArun Murthy <arun.murthy@stericsson.com>
Acked-by: NLinus Walleij <linus.walleij@stericsson.com>
Acked-by: NRichard Purdie <rpurdie@linux.intel.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 a1025e22
...@@ -25,6 +25,7 @@ struct pwm_bl_data { ...@@ -25,6 +25,7 @@ struct pwm_bl_data {
struct pwm_device *pwm; struct pwm_device *pwm;
struct device *dev; struct device *dev;
unsigned int period; unsigned int period;
unsigned int lth_brightness;
int (*notify)(struct device *, int (*notify)(struct device *,
int brightness); int brightness);
}; };
...@@ -48,7 +49,9 @@ static int pwm_backlight_update_status(struct backlight_device *bl) ...@@ -48,7 +49,9 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
pwm_config(pb->pwm, 0, pb->period); pwm_config(pb->pwm, 0, pb->period);
pwm_disable(pb->pwm); pwm_disable(pb->pwm);
} else { } else {
pwm_config(pb->pwm, brightness * pb->period / max, pb->period); brightness = pb->lth_brightness +
(brightness * (pb->period - pb->lth_brightness) / max);
pwm_config(pb->pwm, brightness, pb->period);
pwm_enable(pb->pwm); pwm_enable(pb->pwm);
} }
return 0; return 0;
...@@ -92,6 +95,8 @@ static int pwm_backlight_probe(struct platform_device *pdev) ...@@ -92,6 +95,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
pb->period = data->pwm_period_ns; pb->period = data->pwm_period_ns;
pb->notify = data->notify; pb->notify = data->notify;
pb->lth_brightness = data->lth_brightness *
(data->pwm_period_ns / data->max_brightness);
pb->dev = &pdev->dev; pb->dev = &pdev->dev;
pb->pwm = pwm_request(data->pwm_id, "backlight"); pb->pwm = pwm_request(data->pwm_id, "backlight");
......
...@@ -8,6 +8,7 @@ struct platform_pwm_backlight_data { ...@@ -8,6 +8,7 @@ struct platform_pwm_backlight_data {
int pwm_id; int pwm_id;
unsigned int max_brightness; unsigned int max_brightness;
unsigned int dft_brightness; unsigned int dft_brightness;
unsigned int lth_brightness;
unsigned int pwm_period_ns; unsigned int pwm_period_ns;
int (*init)(struct device *dev); int (*init)(struct device *dev);
int (*notify)(struct device *dev, int brightness); int (*notify)(struct device *dev, int brightness);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册