aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/nvidia/nv_backlight.c
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2007-02-10 09:10:33 -0500
committerRichard Purdie <rpurdie@rpsys.net>2007-02-20 03:38:46 -0500
commit37ce69a57ff217a4ca0871e9ee5aa58c052b7d86 (patch)
tree21cdbb8c988eed585437bb502ca15c2998ea7fbc /drivers/video/nvidia/nv_backlight.c
parentb5c6916b3118d4301dc2f8cf8d33f13e5324a3a5 (diff)
backlight: Rework backlight/fb interaction simplifying, lots
fb_info->bl_mutex is badly thought out and the backlight class doesn't need it if the framebuffer/backlight register/unregister order is consistent, particularly after the backlight locking fixes. Fix the drivers to use the order: backlight_device_register() register_framebuffer() unregister_framebuffer() backlight_device_unregister() and turn bl_mutex into a lock for the bl_curve data only. Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Diffstat (limited to 'drivers/video/nvidia/nv_backlight.c')
-rw-r--r--drivers/video/nvidia/nv_backlight.c40
1 files changed, 8 insertions, 32 deletions
diff --git a/drivers/video/nvidia/nv_backlight.c b/drivers/video/nvidia/nv_backlight.c
index 695b6bf54d92..2bebfeeb4f1d 100644
--- a/drivers/video/nvidia/nv_backlight.c
+++ b/drivers/video/nvidia/nv_backlight.c
@@ -30,7 +30,6 @@
30 30
31static struct backlight_properties nvidia_bl_data; 31static struct backlight_properties nvidia_bl_data;
32 32
33/* Call with fb_info->bl_mutex held */
34static int nvidia_bl_get_level_brightness(struct nvidia_par *par, 33static int nvidia_bl_get_level_brightness(struct nvidia_par *par,
35 int level) 34 int level)
36{ 35{
@@ -38,6 +37,7 @@ static int nvidia_bl_get_level_brightness(struct nvidia_par *par,
38 int nlevel; 37 int nlevel;
39 38
40 /* Get and convert the value */ 39 /* Get and convert the value */
40 /* No locking of bl_curve since we read a single value */
41 nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP; 41 nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP;
42 42
43 if (nlevel < 0) 43 if (nlevel < 0)
@@ -50,8 +50,7 @@ static int nvidia_bl_get_level_brightness(struct nvidia_par *par,
50 return nlevel; 50 return nlevel;
51} 51}
52 52
53/* Call with fb_info->bl_mutex held */ 53static int nvidia_bl_update_status(struct backlight_device *bd)
54static int __nvidia_bl_update_status(struct backlight_device *bd)
55{ 54{
56 struct nvidia_par *par = class_get_devdata(&bd->class_dev); 55 struct nvidia_par *par = class_get_devdata(&bd->class_dev);
57 u32 tmp_pcrt, tmp_pmc, fpcontrol; 56 u32 tmp_pcrt, tmp_pmc, fpcontrol;
@@ -85,19 +84,6 @@ static int __nvidia_bl_update_status(struct backlight_device *bd)
85 return 0; 84 return 0;
86} 85}
87 86
88static 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
101static int nvidia_bl_get_brightness(struct backlight_device *bd) 87static int nvidia_bl_get_brightness(struct backlight_device *bd)
102{ 88{
103 return bd->props->brightness; 89 return bd->props->brightness;
@@ -133,12 +119,10 @@ void nvidia_bl_init(struct nvidia_par *par)
133 goto error; 119 goto error;
134 } 120 }
135 121
136 mutex_lock(&info->bl_mutex);
137 info->bl_dev = bd; 122 info->bl_dev = bd;
138 fb_bl_default_curve(info, 0, 123 fb_bl_default_curve(info, 0,
139 0x158 * FB_BACKLIGHT_MAX / MAX_LEVEL, 124 0x158 * FB_BACKLIGHT_MAX / MAX_LEVEL,
140 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL); 125 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL);
141 mutex_unlock(&info->bl_mutex);
142 126
143 bd->props->brightness = nvidia_bl_data.max_brightness; 127 bd->props->brightness = nvidia_bl_data.max_brightness;
144 bd->props->power = FB_BLANK_UNBLANK; 128 bd->props->power = FB_BLANK_UNBLANK;
@@ -162,25 +146,17 @@ error:
162void nvidia_bl_exit(struct nvidia_par *par) 146void nvidia_bl_exit(struct nvidia_par *par)
163{ 147{
164 struct fb_info *info = pci_get_drvdata(par->pci_dev); 148 struct fb_info *info = pci_get_drvdata(par->pci_dev);
149 struct backlight_device *bd = info->bl_dev;
165 150
151 if (bd) {
166#ifdef CONFIG_PMAC_BACKLIGHT 152#ifdef CONFIG_PMAC_BACKLIGHT
167 mutex_lock(&pmac_backlight_mutex); 153 mutex_lock(&pmac_backlight_mutex);
168#endif 154 if (pmac_backlight == bd)
169
170 mutex_lock(&info->bl_mutex);
171 if (info->bl_dev) {
172#ifdef CONFIG_PMAC_BACKLIGHT
173 if (pmac_backlight == info->bl_dev)
174 pmac_backlight = NULL; 155 pmac_backlight = NULL;
156 mutex_unlock(&pmac_backlight_mutex);
175#endif 157#endif
176 158 backlight_device_unregister(bd);
177 backlight_device_unregister(info->bl_dev);
178 159
179 printk("nvidia: Backlight unloaded\n"); 160 printk("nvidia: Backlight unloaded\n");
180 } 161 }
181 mutex_unlock(&info->bl_mutex);
182
183#ifdef CONFIG_PMAC_BACKLIGHT
184 mutex_unlock(&pmac_backlight_mutex);
185#endif
186} 162}