diff options
Diffstat (limited to 'drivers/video/backlight/pwm_bl.c')
-rw-r--r-- | drivers/video/backlight/pwm_bl.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 550443518891..b8f38ec6eb18 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c | |||
@@ -25,8 +25,10 @@ struct pwm_bl_data { | |||
25 | struct pwm_device *pwm; | 25 | struct pwm_device *pwm; |
26 | struct device *dev; | 26 | struct device *dev; |
27 | unsigned int period; | 27 | unsigned int period; |
28 | unsigned int lth_brightness; | ||
28 | int (*notify)(struct device *, | 29 | int (*notify)(struct device *, |
29 | int brightness); | 30 | int brightness); |
31 | int (*check_fb)(struct device *, struct fb_info *); | ||
30 | }; | 32 | }; |
31 | 33 | ||
32 | static int pwm_backlight_update_status(struct backlight_device *bl) | 34 | static int pwm_backlight_update_status(struct backlight_device *bl) |
@@ -48,7 +50,9 @@ static int pwm_backlight_update_status(struct backlight_device *bl) | |||
48 | pwm_config(pb->pwm, 0, pb->period); | 50 | pwm_config(pb->pwm, 0, pb->period); |
49 | pwm_disable(pb->pwm); | 51 | pwm_disable(pb->pwm); |
50 | } else { | 52 | } else { |
51 | pwm_config(pb->pwm, brightness * pb->period / max, pb->period); | 53 | brightness = pb->lth_brightness + |
54 | (brightness * (pb->period - pb->lth_brightness) / max); | ||
55 | pwm_config(pb->pwm, brightness, pb->period); | ||
52 | pwm_enable(pb->pwm); | 56 | pwm_enable(pb->pwm); |
53 | } | 57 | } |
54 | return 0; | 58 | return 0; |
@@ -59,9 +63,18 @@ static int pwm_backlight_get_brightness(struct backlight_device *bl) | |||
59 | return bl->props.brightness; | 63 | return bl->props.brightness; |
60 | } | 64 | } |
61 | 65 | ||
66 | static int pwm_backlight_check_fb(struct backlight_device *bl, | ||
67 | struct fb_info *info) | ||
68 | { | ||
69 | struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev); | ||
70 | |||
71 | return !pb->check_fb || pb->check_fb(pb->dev, info); | ||
72 | } | ||
73 | |||
62 | static const struct backlight_ops pwm_backlight_ops = { | 74 | static const struct backlight_ops pwm_backlight_ops = { |
63 | .update_status = pwm_backlight_update_status, | 75 | .update_status = pwm_backlight_update_status, |
64 | .get_brightness = pwm_backlight_get_brightness, | 76 | .get_brightness = pwm_backlight_get_brightness, |
77 | .check_fb = pwm_backlight_check_fb, | ||
65 | }; | 78 | }; |
66 | 79 | ||
67 | static int pwm_backlight_probe(struct platform_device *pdev) | 80 | static int pwm_backlight_probe(struct platform_device *pdev) |
@@ -92,6 +105,9 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
92 | 105 | ||
93 | pb->period = data->pwm_period_ns; | 106 | pb->period = data->pwm_period_ns; |
94 | pb->notify = data->notify; | 107 | pb->notify = data->notify; |
108 | pb->check_fb = data->check_fb; | ||
109 | pb->lth_brightness = data->lth_brightness * | ||
110 | (data->pwm_period_ns / data->max_brightness); | ||
95 | pb->dev = &pdev->dev; | 111 | pb->dev = &pdev->dev; |
96 | 112 | ||
97 | pb->pwm = pwm_request(data->pwm_id, "backlight"); | 113 | pb->pwm = pwm_request(data->pwm_id, "backlight"); |
@@ -103,6 +119,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
103 | dev_dbg(&pdev->dev, "got pwm for backlight\n"); | 119 | dev_dbg(&pdev->dev, "got pwm for backlight\n"); |
104 | 120 | ||
105 | memset(&props, 0, sizeof(struct backlight_properties)); | 121 | memset(&props, 0, sizeof(struct backlight_properties)); |
122 | props.type = BACKLIGHT_RAW; | ||
106 | props.max_brightness = data->max_brightness; | 123 | props.max_brightness = data->max_brightness; |
107 | bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb, | 124 | bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb, |
108 | &pwm_backlight_ops, &props); | 125 | &pwm_backlight_ops, &props); |