diff options
Diffstat (limited to 'drivers/video/nvidia/nv_backlight.c')
-rw-r--r-- | drivers/video/nvidia/nv_backlight.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/drivers/video/nvidia/nv_backlight.c b/drivers/video/nvidia/nv_backlight.c index 1c1c10c699c5..b45f577094ac 100644 --- a/drivers/video/nvidia/nv_backlight.c +++ b/drivers/video/nvidia/nv_backlight.c | |||
@@ -26,9 +26,11 @@ | |||
26 | */ | 26 | */ |
27 | #define MIN_LEVEL 0x158 | 27 | #define MIN_LEVEL 0x158 |
28 | #define MAX_LEVEL 0x534 | 28 | #define MAX_LEVEL 0x534 |
29 | #define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX) | ||
29 | 30 | ||
30 | static struct backlight_properties nvidia_bl_data; | 31 | static struct backlight_properties nvidia_bl_data; |
31 | 32 | ||
33 | /* Call with fb_info->bl_mutex held */ | ||
32 | static int nvidia_bl_get_level_brightness(struct nvidia_par *par, | 34 | static int nvidia_bl_get_level_brightness(struct nvidia_par *par, |
33 | int level) | 35 | int level) |
34 | { | 36 | { |
@@ -36,9 +38,7 @@ static int nvidia_bl_get_level_brightness(struct nvidia_par *par, | |||
36 | int nlevel; | 38 | int nlevel; |
37 | 39 | ||
38 | /* Get and convert the value */ | 40 | /* Get and convert the value */ |
39 | mutex_lock(&info->bl_mutex); | 41 | nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP; |
40 | nlevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL; | ||
41 | mutex_unlock(&info->bl_mutex); | ||
42 | 42 | ||
43 | if (nlevel < 0) | 43 | if (nlevel < 0) |
44 | nlevel = 0; | 44 | nlevel = 0; |
@@ -50,7 +50,8 @@ static int nvidia_bl_get_level_brightness(struct nvidia_par *par, | |||
50 | return nlevel; | 50 | return nlevel; |
51 | } | 51 | } |
52 | 52 | ||
53 | static int nvidia_bl_update_status(struct backlight_device *bd) | 53 | /* Call with fb_info->bl_mutex held */ |
54 | static int __nvidia_bl_update_status(struct backlight_device *bd) | ||
54 | { | 55 | { |
55 | struct nvidia_par *par = class_get_devdata(&bd->class_dev); | 56 | struct nvidia_par *par = class_get_devdata(&bd->class_dev); |
56 | u32 tmp_pcrt, tmp_pmc, fpcontrol; | 57 | u32 tmp_pcrt, tmp_pmc, fpcontrol; |
@@ -84,6 +85,19 @@ static int nvidia_bl_update_status(struct backlight_device *bd) | |||
84 | return 0; | 85 | return 0; |
85 | } | 86 | } |
86 | 87 | ||
88 | static int nvidia_bl_update_status(struct backlight_device *bd) | ||
89 | { | ||
90 | struct nvidia_par *par = class_get_devdata(&bd->class_dev); | ||
91 | struct fb_info *info = pci_get_drvdata(par->pci_dev); | ||
92 | int ret; | ||
93 | |||
94 | mutex_lock(&info->bl_mutex); | ||
95 | ret = __nvidia_bl_update_status(bd); | ||
96 | mutex_unlock(&info->bl_mutex); | ||
97 | |||
98 | return ret; | ||
99 | } | ||
100 | |||
87 | static int nvidia_bl_get_brightness(struct backlight_device *bd) | 101 | static int nvidia_bl_get_brightness(struct backlight_device *bd) |
88 | { | 102 | { |
89 | return bd->props->brightness; | 103 | return bd->props->brightness; |
@@ -96,6 +110,16 @@ static struct backlight_properties nvidia_bl_data = { | |||
96 | .max_brightness = (FB_BACKLIGHT_LEVELS - 1), | 110 | .max_brightness = (FB_BACKLIGHT_LEVELS - 1), |
97 | }; | 111 | }; |
98 | 112 | ||
113 | void nvidia_bl_set_power(struct fb_info *info, int power) | ||
114 | { | ||
115 | mutex_lock(&info->bl_mutex); | ||
116 | up(&info->bl_dev->sem); | ||
117 | info->bl_dev->props->power = power; | ||
118 | __nvidia_bl_update_status(info->bl_dev); | ||
119 | down(&info->bl_dev->sem); | ||
120 | mutex_unlock(&info->bl_mutex); | ||
121 | } | ||
122 | |||
99 | void nvidia_bl_init(struct nvidia_par *par) | 123 | void nvidia_bl_init(struct nvidia_par *par) |
100 | { | 124 | { |
101 | struct fb_info *info = pci_get_drvdata(par->pci_dev); | 125 | struct fb_info *info = pci_get_drvdata(par->pci_dev); |