diff options
Diffstat (limited to 'drivers/video/riva/fbdev.c')
-rw-r--r-- | drivers/video/riva/fbdev.c | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c index 2788655e6e7d..8ddb47a56b07 100644 --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
35 | #include <linux/string.h> | 35 | #include <linux/string.h> |
36 | #include <linux/mm.h> | 36 | #include <linux/mm.h> |
37 | #include <linux/tty.h> | ||
38 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
39 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
40 | #include <linux/fb.h> | 39 | #include <linux/fb.h> |
@@ -278,9 +277,11 @@ static const struct riva_regs reg_template = { | |||
278 | */ | 277 | */ |
279 | #define MIN_LEVEL 0x158 | 278 | #define MIN_LEVEL 0x158 |
280 | #define MAX_LEVEL 0x534 | 279 | #define MAX_LEVEL 0x534 |
280 | #define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX) | ||
281 | 281 | ||
282 | static struct backlight_properties riva_bl_data; | 282 | static struct backlight_properties riva_bl_data; |
283 | 283 | ||
284 | /* Call with fb_info->bl_mutex held */ | ||
284 | static int riva_bl_get_level_brightness(struct riva_par *par, | 285 | static int riva_bl_get_level_brightness(struct riva_par *par, |
285 | int level) | 286 | int level) |
286 | { | 287 | { |
@@ -288,9 +289,7 @@ static int riva_bl_get_level_brightness(struct riva_par *par, | |||
288 | int nlevel; | 289 | int nlevel; |
289 | 290 | ||
290 | /* Get and convert the value */ | 291 | /* Get and convert the value */ |
291 | mutex_lock(&info->bl_mutex); | 292 | nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP; |
292 | nlevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL; | ||
293 | mutex_unlock(&info->bl_mutex); | ||
294 | 293 | ||
295 | if (nlevel < 0) | 294 | if (nlevel < 0) |
296 | nlevel = 0; | 295 | nlevel = 0; |
@@ -302,7 +301,8 @@ static int riva_bl_get_level_brightness(struct riva_par *par, | |||
302 | return nlevel; | 301 | return nlevel; |
303 | } | 302 | } |
304 | 303 | ||
305 | static int riva_bl_update_status(struct backlight_device *bd) | 304 | /* Call with fb_info->bl_mutex held */ |
305 | static int __riva_bl_update_status(struct backlight_device *bd) | ||
306 | { | 306 | { |
307 | struct riva_par *par = class_get_devdata(&bd->class_dev); | 307 | struct riva_par *par = class_get_devdata(&bd->class_dev); |
308 | U032 tmp_pcrt, tmp_pmc; | 308 | U032 tmp_pcrt, tmp_pmc; |
@@ -327,6 +327,19 @@ static int riva_bl_update_status(struct backlight_device *bd) | |||
327 | return 0; | 327 | return 0; |
328 | } | 328 | } |
329 | 329 | ||
330 | static int riva_bl_update_status(struct backlight_device *bd) | ||
331 | { | ||
332 | struct riva_par *par = class_get_devdata(&bd->class_dev); | ||
333 | struct fb_info *info = pci_get_drvdata(par->pdev); | ||
334 | int ret; | ||
335 | |||
336 | mutex_lock(&info->bl_mutex); | ||
337 | ret = __riva_bl_update_status(bd); | ||
338 | mutex_unlock(&info->bl_mutex); | ||
339 | |||
340 | return ret; | ||
341 | } | ||
342 | |||
330 | static int riva_bl_get_brightness(struct backlight_device *bd) | 343 | static int riva_bl_get_brightness(struct backlight_device *bd) |
331 | { | 344 | { |
332 | return bd->props->brightness; | 345 | return bd->props->brightness; |
@@ -339,6 +352,20 @@ static struct backlight_properties riva_bl_data = { | |||
339 | .max_brightness = (FB_BACKLIGHT_LEVELS - 1), | 352 | .max_brightness = (FB_BACKLIGHT_LEVELS - 1), |
340 | }; | 353 | }; |
341 | 354 | ||
355 | static void riva_bl_set_power(struct fb_info *info, int power) | ||
356 | { | ||
357 | mutex_lock(&info->bl_mutex); | ||
358 | |||
359 | if (info->bl_dev) { | ||
360 | down(&info->bl_dev->sem); | ||
361 | info->bl_dev->props->power = power; | ||
362 | __riva_bl_update_status(info->bl_dev); | ||
363 | up(&info->bl_dev->sem); | ||
364 | } | ||
365 | |||
366 | mutex_unlock(&info->bl_mutex); | ||
367 | } | ||
368 | |||
342 | static void riva_bl_init(struct riva_par *par) | 369 | static void riva_bl_init(struct riva_par *par) |
343 | { | 370 | { |
344 | struct fb_info *info = pci_get_drvdata(par->pdev); | 371 | struct fb_info *info = pci_get_drvdata(par->pdev); |
@@ -359,7 +386,7 @@ static void riva_bl_init(struct riva_par *par) | |||
359 | bd = backlight_device_register(name, par, &riva_bl_data); | 386 | bd = backlight_device_register(name, par, &riva_bl_data); |
360 | if (IS_ERR(bd)) { | 387 | if (IS_ERR(bd)) { |
361 | info->bl_dev = NULL; | 388 | info->bl_dev = NULL; |
362 | printk("riva: Backlight registration failed\n"); | 389 | printk(KERN_WARNING "riva: Backlight registration failed\n"); |
363 | goto error; | 390 | goto error; |
364 | } | 391 | } |
365 | 392 | ||
@@ -370,11 +397,11 @@ static void riva_bl_init(struct riva_par *par) | |||
370 | 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL); | 397 | 0x534 * FB_BACKLIGHT_MAX / MAX_LEVEL); |
371 | mutex_unlock(&info->bl_mutex); | 398 | mutex_unlock(&info->bl_mutex); |
372 | 399 | ||
373 | up(&bd->sem); | 400 | down(&bd->sem); |
374 | bd->props->brightness = riva_bl_data.max_brightness; | 401 | bd->props->brightness = riva_bl_data.max_brightness; |
375 | bd->props->power = FB_BLANK_UNBLANK; | 402 | bd->props->power = FB_BLANK_UNBLANK; |
376 | bd->props->update_status(bd); | 403 | bd->props->update_status(bd); |
377 | down(&bd->sem); | 404 | up(&bd->sem); |
378 | 405 | ||
379 | #ifdef CONFIG_PMAC_BACKLIGHT | 406 | #ifdef CONFIG_PMAC_BACKLIGHT |
380 | mutex_lock(&pmac_backlight_mutex); | 407 | mutex_lock(&pmac_backlight_mutex); |
@@ -419,6 +446,7 @@ static void riva_bl_exit(struct riva_par *par) | |||
419 | #else | 446 | #else |
420 | static inline void riva_bl_init(struct riva_par *par) {} | 447 | static inline void riva_bl_init(struct riva_par *par) {} |
421 | static inline void riva_bl_exit(struct riva_par *par) {} | 448 | static inline void riva_bl_exit(struct riva_par *par) {} |
449 | static inline void riva_bl_set_power(struct fb_info *info, int power) {} | ||
422 | #endif /* CONFIG_FB_RIVA_BACKLIGHT */ | 450 | #endif /* CONFIG_FB_RIVA_BACKLIGHT */ |
423 | 451 | ||
424 | /* ------------------------------------------------------------------------- * | 452 | /* ------------------------------------------------------------------------- * |
@@ -1337,16 +1365,7 @@ static int rivafb_blank(int blank, struct fb_info *info) | |||
1337 | SEQout(par, 0x01, tmp); | 1365 | SEQout(par, 0x01, tmp); |
1338 | CRTCout(par, 0x1a, vesa); | 1366 | CRTCout(par, 0x1a, vesa); |
1339 | 1367 | ||
1340 | #ifdef CONFIG_FB_RIVA_BACKLIGHT | 1368 | riva_bl_set_power(info, blank); |
1341 | mutex_lock(&info->bl_mutex); | ||
1342 | if (info->bl_dev) { | ||
1343 | down(&info->bl_dev->sem); | ||
1344 | info->bl_dev->props->power = blank; | ||
1345 | info->bl_dev->props->update_status(info->bl_dev); | ||
1346 | up(&info->bl_dev->sem); | ||
1347 | } | ||
1348 | mutex_unlock(&info->bl_mutex); | ||
1349 | #endif | ||
1350 | 1369 | ||
1351 | NVTRACE_LEAVE(); | 1370 | NVTRACE_LEAVE(); |
1352 | 1371 | ||
@@ -2117,6 +2136,9 @@ static int __devinit rivafb_probe(struct pci_dev *pd, | |||
2117 | 2136 | ||
2118 | fb_destroy_modedb(info->monspecs.modedb); | 2137 | fb_destroy_modedb(info->monspecs.modedb); |
2119 | info->monspecs.modedb = NULL; | 2138 | info->monspecs.modedb = NULL; |
2139 | |||
2140 | pci_set_drvdata(pd, info); | ||
2141 | riva_bl_init(info->par); | ||
2120 | ret = register_framebuffer(info); | 2142 | ret = register_framebuffer(info); |
2121 | if (ret < 0) { | 2143 | if (ret < 0) { |
2122 | printk(KERN_ERR PFX | 2144 | printk(KERN_ERR PFX |
@@ -2124,8 +2146,6 @@ static int __devinit rivafb_probe(struct pci_dev *pd, | |||
2124 | goto err_iounmap_screen_base; | 2146 | goto err_iounmap_screen_base; |
2125 | } | 2147 | } |
2126 | 2148 | ||
2127 | pci_set_drvdata(pd, info); | ||
2128 | |||
2129 | printk(KERN_INFO PFX | 2149 | printk(KERN_INFO PFX |
2130 | "PCI nVidia %s framebuffer ver %s (%dMB @ 0x%lX)\n", | 2150 | "PCI nVidia %s framebuffer ver %s (%dMB @ 0x%lX)\n", |
2131 | info->fix.id, | 2151 | info->fix.id, |
@@ -2133,8 +2153,6 @@ static int __devinit rivafb_probe(struct pci_dev *pd, | |||
2133 | info->fix.smem_len / (1024 * 1024), | 2153 | info->fix.smem_len / (1024 * 1024), |
2134 | info->fix.smem_start); | 2154 | info->fix.smem_start); |
2135 | 2155 | ||
2136 | riva_bl_init(info->par); | ||
2137 | |||
2138 | NVTRACE_LEAVE(); | 2156 | NVTRACE_LEAVE(); |
2139 | return 0; | 2157 | return 0; |
2140 | 2158 | ||