aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/riva
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/riva')
-rw-r--r--drivers/video/riva/fbdev.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
index baf494cecc10..33dddbae5420 100644
--- a/drivers/video/riva/fbdev.c
+++ b/drivers/video/riva/fbdev.c
@@ -277,9 +277,11 @@ static const struct riva_regs reg_template = {
277 */ 277 */
278#define MIN_LEVEL 0x158 278#define MIN_LEVEL 0x158
279#define MAX_LEVEL 0x534 279#define MAX_LEVEL 0x534
280#define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX)
280 281
281static struct backlight_properties riva_bl_data; 282static struct backlight_properties riva_bl_data;
282 283
284/* Call with fb_info->bl_mutex held */
283static int riva_bl_get_level_brightness(struct riva_par *par, 285static int riva_bl_get_level_brightness(struct riva_par *par,
284 int level) 286 int level)
285{ 287{
@@ -287,9 +289,7 @@ static int riva_bl_get_level_brightness(struct riva_par *par,
287 int nlevel; 289 int nlevel;
288 290
289 /* Get and convert the value */ 291 /* Get and convert the value */
290 mutex_lock(&info->bl_mutex); 292 nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP;
291 nlevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL;
292 mutex_unlock(&info->bl_mutex);
293 293
294 if (nlevel < 0) 294 if (nlevel < 0)
295 nlevel = 0; 295 nlevel = 0;
@@ -301,7 +301,8 @@ static int riva_bl_get_level_brightness(struct riva_par *par,
301 return nlevel; 301 return nlevel;
302} 302}
303 303
304static 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)
305{ 306{
306 struct riva_par *par = class_get_devdata(&bd->class_dev); 307 struct riva_par *par = class_get_devdata(&bd->class_dev);
307 U032 tmp_pcrt, tmp_pmc; 308 U032 tmp_pcrt, tmp_pmc;
@@ -326,6 +327,19 @@ static int riva_bl_update_status(struct backlight_device *bd)
326 return 0; 327 return 0;
327} 328}
328 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
329static int riva_bl_get_brightness(struct backlight_device *bd) 343static int riva_bl_get_brightness(struct backlight_device *bd)
330{ 344{
331 return bd->props->brightness; 345 return bd->props->brightness;
@@ -338,6 +352,16 @@ static struct backlight_properties riva_bl_data = {
338 .max_brightness = (FB_BACKLIGHT_LEVELS - 1), 352 .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
339}; 353};
340 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
341static void riva_bl_init(struct riva_par *par) 365static void riva_bl_init(struct riva_par *par)
342{ 366{
343 struct fb_info *info = pci_get_drvdata(par->pdev); 367 struct fb_info *info = pci_get_drvdata(par->pdev);
@@ -418,6 +442,7 @@ static void riva_bl_exit(struct riva_par *par)
418#else 442#else
419static inline void riva_bl_init(struct riva_par *par) {} 443static inline void riva_bl_init(struct riva_par *par) {}
420static 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) {}
421#endif /* CONFIG_FB_RIVA_BACKLIGHT */ 446#endif /* CONFIG_FB_RIVA_BACKLIGHT */
422 447
423/* ------------------------------------------------------------------------- * 448/* ------------------------------------------------------------------------- *
@@ -1336,16 +1361,7 @@ static int rivafb_blank(int blank, struct fb_info *info)
1336 SEQout(par, 0x01, tmp); 1361 SEQout(par, 0x01, tmp);
1337 CRTCout(par, 0x1a, vesa); 1362 CRTCout(par, 0x1a, vesa);
1338 1363
1339#ifdef CONFIG_FB_RIVA_BACKLIGHT 1364 riva_bl_set_power(info, blank);
1340 mutex_lock(&info->bl_mutex);
1341 if (info->bl_dev) {
1342 down(&info->bl_dev->sem);
1343 info->bl_dev->props->power = blank;
1344 info->bl_dev->props->update_status(info->bl_dev);
1345 up(&info->bl_dev->sem);
1346 }
1347 mutex_unlock(&info->bl_mutex);
1348#endif
1349 1365
1350 NVTRACE_LEAVE(); 1366 NVTRACE_LEAVE();
1351 1367