From a8f340e394ff30b79ab5b03c67ab4c94b2ac3646 Mon Sep 17 00:00:00 2001 From: Jon Smirl Date: Mon, 10 Jul 2006 04:44:12 -0700 Subject: [PATCH] vt: Remove VT-specific declarations and definitions from tty.h MAX_NR_CONSOLES, fg_console, want_console and last_console are more of a function of the VT layer than the TTY one. Moving these to vt.h and vt_kern.h allows all of the framebuffer and VT console drivers to remove their dependency on tty.h. [akpm@osdl.org: fix alpha build] Signed-off-by: Jon Smirl Signed-off-by: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/riva/fbdev.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/video/riva') diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c index 2788655e6e7..baf494cecc1 100644 --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From e01af0384f54023b4548b7742952da2ffcafd4cd Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Mon, 10 Jul 2006 04:44:45 -0700 Subject: [PATCH] powermac: Combined fixes for backlight code This patch fixes several problems: - pmac_backlight_key() is called under interrupt context, and therefore can't use mutexes or semaphores, so defer the backlight level for later, as it's not critical (original code by Aristeu S. Rozanski F. ). - Add exports for functions that might be called from modules - Fix Kconfig depdencies on PMAC_BACKLIGHT. - Fix locking issues on calls from inside the driver (reported by Aristeu S. Rozanski F., too) - Fix wrong calculation of backlight values in some of the drivers - Replace pmac_backlight_key_up/down by inline functions [akpm@osdl.org: fix function prototypes] Signed-off-by: Michael Hanselmann Acked-by: Aristeu S. Rozanski F. Acked-by: Rene Nussbaumer Cc: Benjamin Herrenschmidt Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/riva/fbdev.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'drivers/video/riva') diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c index baf494cecc1..33dddbae542 100644 --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c @@ -277,9 +277,11 @@ static const struct riva_regs reg_template = { */ #define MIN_LEVEL 0x158 #define MAX_LEVEL 0x534 +#define LEVEL_STEP ((MAX_LEVEL - MIN_LEVEL) / FB_BACKLIGHT_MAX) static struct backlight_properties riva_bl_data; +/* Call with fb_info->bl_mutex held */ static int riva_bl_get_level_brightness(struct riva_par *par, int level) { @@ -287,9 +289,7 @@ static int riva_bl_get_level_brightness(struct riva_par *par, int nlevel; /* Get and convert the value */ - mutex_lock(&info->bl_mutex); - nlevel = info->bl_curve[level] * FB_BACKLIGHT_MAX / MAX_LEVEL; - mutex_unlock(&info->bl_mutex); + nlevel = MIN_LEVEL + info->bl_curve[level] * LEVEL_STEP; if (nlevel < 0) nlevel = 0; @@ -301,7 +301,8 @@ static int riva_bl_get_level_brightness(struct riva_par *par, return nlevel; } -static int riva_bl_update_status(struct backlight_device *bd) +/* Call with fb_info->bl_mutex held */ +static int __riva_bl_update_status(struct backlight_device *bd) { struct riva_par *par = class_get_devdata(&bd->class_dev); U032 tmp_pcrt, tmp_pmc; @@ -326,6 +327,19 @@ static int riva_bl_update_status(struct backlight_device *bd) return 0; } +static int riva_bl_update_status(struct backlight_device *bd) +{ + struct riva_par *par = class_get_devdata(&bd->class_dev); + struct fb_info *info = pci_get_drvdata(par->pdev); + int ret; + + mutex_lock(&info->bl_mutex); + ret = __riva_bl_update_status(bd); + mutex_unlock(&info->bl_mutex); + + return ret; +} + static int riva_bl_get_brightness(struct backlight_device *bd) { return bd->props->brightness; @@ -338,6 +352,16 @@ static struct backlight_properties riva_bl_data = { .max_brightness = (FB_BACKLIGHT_LEVELS - 1), }; +static void riva_bl_set_power(struct fb_info *info, int power) +{ + mutex_lock(&info->bl_mutex); + up(&info->bl_dev->sem); + info->bl_dev->props->power = power; + __riva_bl_update_status(info->bl_dev); + down(&info->bl_dev->sem); + mutex_unlock(&info->bl_mutex); +} + static void riva_bl_init(struct riva_par *par) { struct fb_info *info = pci_get_drvdata(par->pdev); @@ -418,6 +442,7 @@ static void riva_bl_exit(struct riva_par *par) #else static inline void riva_bl_init(struct riva_par *par) {} static inline void riva_bl_exit(struct riva_par *par) {} +static inline void riva_bl_set_power(struct fb_info *info, int power) {} #endif /* CONFIG_FB_RIVA_BACKLIGHT */ /* ------------------------------------------------------------------------- * @@ -1336,16 +1361,7 @@ static int rivafb_blank(int blank, struct fb_info *info) SEQout(par, 0x01, tmp); CRTCout(par, 0x1a, vesa); -#ifdef CONFIG_FB_RIVA_BACKLIGHT - mutex_lock(&info->bl_mutex); - if (info->bl_dev) { - down(&info->bl_dev->sem); - info->bl_dev->props->power = blank; - info->bl_dev->props->update_status(info->bl_dev); - up(&info->bl_dev->sem); - } - mutex_unlock(&info->bl_mutex); -#endif + riva_bl_set_power(info, blank); NVTRACE_LEAVE(); -- cgit v1.2.3 From ce38cac48209d270d07fd6d1a8e94446b37abcd5 Mon Sep 17 00:00:00 2001 From: Guido Guenther Date: Sun, 30 Jul 2006 03:04:21 -0700 Subject: [PATCH] rivafb/nvidiafb: race between register_framebuffer and *_bl_init Since we now use the generic backlight infrastructure, I think we need to call rivafb_bl_init before calling register_framebuffer since otherwise rivafb_bl_init might race with the framebuffer layer already opening the device and setting up the video mode. In this case we might end up with a not yet fully intialized backlight (info->bl_dev still NULL) when calling riva_bl_set_power via rivafb_set_par/rivafb_load_video_mode and the kernel dies without any further notice during boot. This fixes booting current git on a PB 6,1. In this case radeonfb/atyfb would be affected too - I can fix that too but don't have any hardware to test this on. Cc: "Antonino A. Daplas" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/riva/fbdev.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/video/riva') diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c index 33dddbae542..76fc9d355eb 100644 --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c @@ -2132,6 +2132,9 @@ static int __devinit rivafb_probe(struct pci_dev *pd, fb_destroy_modedb(info->monspecs.modedb); info->monspecs.modedb = NULL; + + pci_set_drvdata(pd, info); + riva_bl_init(info->par); ret = register_framebuffer(info); if (ret < 0) { printk(KERN_ERR PFX @@ -2139,8 +2142,6 @@ static int __devinit rivafb_probe(struct pci_dev *pd, goto err_iounmap_screen_base; } - pci_set_drvdata(pd, info); - printk(KERN_INFO PFX "PCI nVidia %s framebuffer ver %s (%dMB @ 0x%lX)\n", info->fix.id, @@ -2148,8 +2149,6 @@ static int __devinit rivafb_probe(struct pci_dev *pd, info->fix.smem_len / (1024 * 1024), info->fix.smem_start); - riva_bl_init(info->par); - NVTRACE_LEAVE(); return 0; -- cgit v1.2.3