aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/riva/fbdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/riva/fbdev.c')
-rw-r--r--drivers/video/riva/fbdev.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
index 6a30c0ca1de0..9823ba939e11 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
282static struct backlight_properties riva_bl_data; 282static struct backlight_properties riva_bl_data;
283 283
284/* Call with fb_info->bl_mutex held */
284static int riva_bl_get_level_brightness(struct riva_par *par, 285static 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
305static int riva_bl_update_status(struct backlight_device *bd) 304/* Call with fb_info->bl_mutex held */
305static 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
330static 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
330static int riva_bl_get_brightness(struct backlight_device *bd) 343static int riva_bl_get_brightness(struct backlight_device *bd)
331{ 344{
332 return bd->props->brightness; 345 return bd->props->brightness;
@@ -339,6 +352,16 @@ 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
355static void riva_bl_set_power(struct fb_info *info, int power)
356{
357 mutex_lock(&info->bl_mutex);
358 up(&info->bl_dev->sem);
359 info->bl_dev->props->power = power;
360 __riva_bl_update_status(info->bl_dev);
361 down(&info->bl_dev->sem);
362 mutex_unlock(&info->bl_mutex);
363}
364
342static void riva_bl_init(struct riva_par *par) 365static void riva_bl_init(struct riva_par *par)
343{ 366{
344 struct fb_info *info = pci_get_drvdata(par->pdev); 367 struct fb_info *info = pci_get_drvdata(par->pdev);
@@ -419,6 +442,7 @@ static void riva_bl_exit(struct riva_par *par)
419#else 442#else
420static inline void riva_bl_init(struct riva_par *par) {} 443static inline void riva_bl_init(struct riva_par *par) {}
421static inline void riva_bl_exit(struct riva_par *par) {} 444static inline void riva_bl_exit(struct riva_par *par) {}
445static inline void riva_bl_set_power(struct fb_info *info, int power) {}
422#endif /* CONFIG_FB_RIVA_BACKLIGHT */ 446#endif /* CONFIG_FB_RIVA_BACKLIGHT */
423 447
424/* ------------------------------------------------------------------------- * 448/* ------------------------------------------------------------------------- *
@@ -1337,16 +1361,7 @@ static int rivafb_blank(int blank, struct fb_info *info)
1337 SEQout(par, 0x01, tmp); 1361 SEQout(par, 0x01, tmp);
1338 CRTCout(par, 0x1a, vesa); 1362 CRTCout(par, 0x1a, vesa);
1339 1363
1340#ifdef CONFIG_FB_RIVA_BACKLIGHT 1364 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 1365
1351 NVTRACE_LEAVE(); 1366 NVTRACE_LEAVE();
1352 1367
@@ -2116,6 +2131,9 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
2116 2131
2117 fb_destroy_modedb(info->monspecs.modedb); 2132 fb_destroy_modedb(info->monspecs.modedb);
2118 info->monspecs.modedb = NULL; 2133 info->monspecs.modedb = NULL;
2134
2135 pci_set_drvdata(pd, info);
2136 riva_bl_init(info->par);
2119 ret = register_framebuffer(info); 2137 ret = register_framebuffer(info);
2120 if (ret < 0) { 2138 if (ret < 0) {
2121 printk(KERN_ERR PFX 2139 printk(KERN_ERR PFX
@@ -2123,8 +2141,6 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
2123 goto err_iounmap_screen_base; 2141 goto err_iounmap_screen_base;
2124 } 2142 }
2125 2143
2126 pci_set_drvdata(pd, info);
2127
2128 printk(KERN_INFO PFX 2144 printk(KERN_INFO PFX
2129 "PCI nVidia %s framebuffer ver %s (%dMB @ 0x%lX)\n", 2145 "PCI nVidia %s framebuffer ver %s (%dMB @ 0x%lX)\n",
2130 info->fix.id, 2146 info->fix.id,
@@ -2132,8 +2148,6 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
2132 info->fix.smem_len / (1024 * 1024), 2148 info->fix.smem_len / (1024 * 1024),
2133 info->fix.smem_start); 2149 info->fix.smem_start);
2134 2150
2135 riva_bl_init(info->par);
2136
2137 NVTRACE_LEAVE(); 2151 NVTRACE_LEAVE();
2138 return 0; 2152 return 0;
2139 2153