fbcon: remove broken mac vbl handler
[safe/jmp/linux-2.6] / drivers / video / console / fbcon.c
index 2cedb49..e99bb7c 100644 (file)
@@ -81,9 +81,6 @@
 #ifdef CONFIG_ATARI
 #include <asm/atariints.h>
 #endif
-#ifdef CONFIG_MAC
-#include <asm/macints.h>
-#endif
 #if defined(__mc68000__)
 #include <asm/machdep.h>
 #include <asm/setup.h>
@@ -92,7 +89,7 @@
 #include "fbcon.h"
 
 #ifdef FBCONDEBUG
-#  define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
+#  define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
 #else
 #  define DPRINTK(fmt, args...)
 #endif
@@ -107,9 +104,7 @@ static struct display fb_display[MAX_NR_CONSOLES];
 
 static signed char con2fb_map[MAX_NR_CONSOLES];
 static signed char con2fb_map_boot[MAX_NR_CONSOLES];
-#ifndef MODULE
-static int logo_height;
-#endif
+
 static int logo_lines;
 /* logo_shown is an index to vc_cons when >= 0; otherwise follows FBCON_LOGO
    enums.  */
@@ -147,7 +142,7 @@ static char fontname[40];
 static int info_idx = -1;
 
 /* console rotation */
-static int rotate;
+static int initial_rotation;
 static int fbcon_has_sysfs;
 
 static const struct consw fb_con;
@@ -162,8 +157,6 @@ static int fbcon_set_origin(struct vc_data *);
 
 /* # VBL ints between cursor state changes */
 #define ATARI_CURSOR_BLINK_RATE                (42)
-#define MAC_CURSOR_BLINK_RATE          (32)
-#define DEFAULT_CURSOR_BLINK_RATE      (20)
 
 static int vbl_cursor_cnt;
 static int fbcon_cursor_noblink;
@@ -212,19 +205,6 @@ static void fbcon_start(void);
 static void fbcon_exit(void);
 static struct device *fbcon_device;
 
-#ifdef CONFIG_MAC
-/*
- * On the Macintoy, there may or may not be a working VBL int. We need to probe
- */
-static int vbl_detected;
-
-static irqreturn_t fb_vbl_detect(int irq, void *dummy)
-{
-       vbl_detected++;
-       return IRQ_HANDLED;
-}
-#endif
-
 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
 static inline void fbcon_set_rotation(struct fb_info *info)
 {
@@ -334,10 +314,7 @@ static inline int get_color(struct vc_data *vc, struct fb_info *info,
        switch (depth) {
        case 1:
        {
-               int col = ~(0xfff << (max(info->var.green.length,
-                                         max(info->var.red.length,
-                                             info->var.blue.length)))) & 0xff;
-
+               int col = mono_col(info);
                /* 0 or 1 */
                int fg = (info->fix.visual != FB_VISUAL_MONO01) ? col : 0;
                int bg = (info->fix.visual != FB_VISUAL_MONO01) ? 0 : col;
@@ -426,7 +403,7 @@ static void fb_flashcursor(struct work_struct *work)
        release_console_sem();
 }
 
-#if defined(CONFIG_ATARI) || defined(CONFIG_MAC)
+#ifdef CONFIG_ATARI
 static int cursor_blink_rate;
 static irqreturn_t fb_vbl_handler(int irq, void *dev_id)
 {
@@ -537,9 +514,9 @@ static int __init fb_console_setup(char *this_opt)
                if (!strncmp(options, "rotate:", 7)) {
                        options += 7;
                        if (*options)
-                               rotate = simple_strtoul(options, &options, 0);
-                       if (rotate > 3)
-                               rotate = 0;
+                               initial_rotation = simple_strtoul(options, &options, 0);
+                       if (initial_rotation > 3)
+                               initial_rotation = 0;
                }
        }
        return 1;
@@ -610,6 +587,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
        struct fbcon_ops *ops = info->fbcon_par;
        int cnt, erase = vc->vc_video_erase_char, step;
        unsigned short *save = NULL, *r, *q;
+       int logo_height;
 
        if (info->flags & FBINFO_MODULE) {
                logo_shown = FBCON_LOGO_DONTSHOW;
@@ -623,8 +601,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
        if (fb_get_color_depth(&info->var, &info->fix) == 1)
                erase &= ~0x400;
        logo_height = fb_prepare_logo(info, ops->rotate);
-       logo_lines = (logo_height + vc->vc_font.height - 1) /
-               vc->vc_font.height;
+       logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height);
        q = (unsigned short *) (vc->vc_origin +
                                vc->vc_size_row * rows);
        step = logo_lines * cols;
@@ -954,9 +931,7 @@ static const char *fbcon_startup(void)
        struct fb_info *info = NULL;
        struct fbcon_ops *ops;
        int rows, cols;
-       int irqres;
 
-       irqres = 1;
        /*
         *  If num_registered_fb is zero, this is a call for the dummy part.
         *  The frame buffer devices weren't initialized yet.
@@ -989,7 +964,7 @@ static const char *fbcon_startup(void)
        ops->graphics = 1;
        ops->cur_rotate = -1;
        info->fbcon_par = ops;
-       p->con_rotate = rotate;
+       p->con_rotate = initial_rotation;
        set_blitting_type(vc, info);
 
        if (info->fix.type != FB_TYPE_TEXT) {
@@ -1045,56 +1020,11 @@ static const char *fbcon_startup(void)
 #ifdef CONFIG_ATARI
        if (MACH_IS_ATARI) {
                cursor_blink_rate = ATARI_CURSOR_BLINK_RATE;
-               irqres =
-                   request_irq(IRQ_AUTO_4, fb_vbl_handler,
+               (void)request_irq(IRQ_AUTO_4, fb_vbl_handler,
                                IRQ_TYPE_PRIO, "framebuffer vbl",
                                info);
        }
-#endif                         /* CONFIG_ATARI */
-
-#ifdef CONFIG_MAC
-       /*
-        * On a Macintoy, the VBL interrupt may or may not be active. 
-        * As interrupt based cursor is more reliable and race free, we 
-        * probe for VBL interrupts.
-        */
-       if (MACH_IS_MAC) {
-               int ct = 0;
-               /*
-                * Probe for VBL: set temp. handler ...
-                */
-               irqres = request_irq(IRQ_MAC_VBL, fb_vbl_detect, 0,
-                                    "framebuffer vbl", info);
-               vbl_detected = 0;
-
-               /*
-                * ... and spin for 20 ms ...
-                */
-               while (!vbl_detected && ++ct < 1000)
-                       udelay(20);
-
-               if (ct == 1000)
-                       printk
-                           ("fbcon_startup: No VBL detected, using timer based cursor.\n");
-
-               free_irq(IRQ_MAC_VBL, fb_vbl_detect);
-
-               if (vbl_detected) {
-                       /*
-                        * interrupt based cursor ok
-                        */
-                       cursor_blink_rate = MAC_CURSOR_BLINK_RATE;
-                       irqres =
-                           request_irq(IRQ_MAC_VBL, fb_vbl_handler, 0,
-                                       "framebuffer vbl", info);
-               } else {
-                       /*
-                        * VBL not detected: fall through, use timer based cursor
-                        */
-                       irqres = 1;
-               }
-       }
-#endif                         /* CONFIG_MAC */
+#endif /* CONFIG_ATARI */
 
        fbcon_add_cursor_timer(info);
        fbcon_has_exited = 0;
@@ -1176,7 +1106,7 @@ static void fbcon_init(struct vc_data *vc, int init)
                con_copy_unimap(vc, svc);
 
        ops = info->fbcon_par;
-       p->con_rotate = rotate;
+       p->con_rotate = initial_rotation;
        set_blitting_type(vc, info);
 
        cols = vc->vc_cols;
@@ -1316,6 +1246,9 @@ static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
        if (!height || !width)
                return;
 
+       if (sy < vc->vc_top && vc->vc_top == logo_lines)
+               vc->vc_top = 0;
+
        /* Split blits that cross physical y_wrap boundary */
 
        y_break = p->vrows - p->yscroll;
@@ -2120,7 +2053,7 @@ static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int s
                   height, width);
 }
 
-static __inline__ void updatescrollmode(struct display *p,
+static void updatescrollmode(struct display *p,
                                        struct fb_info *info,
                                        struct vc_data *vc)
 {
@@ -2268,9 +2201,7 @@ static int fbcon_switch(struct vc_data *vc)
         * in fb_set_var()
         */
        info->var.activate = var.activate;
-       var.yoffset = info->var.yoffset;
-       var.xoffset = info->var.xoffset;
-       var.vmode = info->var.vmode;
+       var.vmode |= info->var.vmode & ~FB_VMODE_MASK;
        fb_set_var(info, &var);
        ops->var = info->var;
 
@@ -2397,8 +2328,9 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
                        fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
                        ops->cursor_flash = (!blank);
 
-                       if (fb_blank(info, blank))
-                               fbcon_generic_blank(vc, info, blank);
+                       if (!(info->flags & FBINFO_MISC_USEREVENT))
+                               if (fb_blank(info, blank))
+                                       fbcon_generic_blank(vc, info, blank);
                }
 
                if (!blank)
@@ -2795,7 +2727,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
 {
        struct fb_info *info = registered_fb[con2fb_map[fg_console]];
        struct fbcon_ops *ops = info->fbcon_par;
-       struct display *p = &fb_display[fg_console];
+       struct display *disp = &fb_display[fg_console];
        int offset, limit, scrollback_old;
 
        if (softback_top) {
@@ -2833,7 +2765,7 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
                        logo_shown = FBCON_LOGO_CANSHOW;
                }
                fbcon_cursor(vc, CM_ERASE | CM_SOFTBACK);
-               fbcon_redraw_softback(vc, p, lines);
+               fbcon_redraw_softback(vc, disp, lines);
                fbcon_cursor(vc, CM_DRAW | CM_SOFTBACK);
                return 0;
        }
@@ -2855,9 +2787,9 @@ static int fbcon_scrolldelta(struct vc_data *vc, int lines)
 
        fbcon_cursor(vc, CM_ERASE);
 
-       offset = p->yscroll - scrollback_current;
-       limit = p->vrows;
-       switch (p->scrollmode) {
+       offset = disp->yscroll - scrollback_current;
+       limit = disp->vrows;
+       switch (disp->scrollmode) {
        case SCROLL_WRAP_MOVE:
                info->var.vmode |= FB_VMODE_YWRAP;
                break;
@@ -2977,8 +2909,8 @@ static void fbcon_set_all_vcs(struct fb_info *info)
                p = &fb_display[vc->vc_num];
                set_blitting_type(vc, info);
                var_to_display(p, &info->var, info);
-               cols = FBCON_SWAP(p->rotate, info->var.xres, info->var.yres);
-               rows = FBCON_SWAP(p->rotate, info->var.yres, info->var.xres);
+               cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
+               rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
                cols /= vc->vc_font.width;
                rows /= vc->vc_font.height;
                vc_resize(vc, cols, rows);
@@ -3525,21 +3457,23 @@ static void fbcon_exit(void)
 #ifdef CONFIG_ATARI
        free_irq(IRQ_AUTO_4, fb_vbl_handler);
 #endif
-#ifdef CONFIG_MAC
-       if (MACH_IS_MAC && vbl_detected)
-               free_irq(IRQ_MAC_VBL, fb_vbl_handler);
-#endif
 
        kfree((void *)softback_buf);
        softback_buf = 0UL;
 
        for (i = 0; i < FB_MAX; i++) {
+               int pending;
+
                mapped = 0;
                info = registered_fb[i];
 
                if (info == NULL)
                        continue;
 
+               pending = cancel_work_sync(&info->queue);
+               DPRINTK("fbcon: %s pending work\n", (pending ? "canceled" :
+                       "no"));
+
                for (j = first_fb_vc; j <= last_fb_vc; j++) {
                        if (con2fb_map[j] == i)
                                mapped = 1;
@@ -3573,7 +3507,8 @@ static int __init fb_console_init(void)
 
        acquire_console_sem();
        fb_register_client(&fbcon_event_notifier);
-       fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), "fbcon");
+       fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
+                                    "fbcon");
 
        if (IS_ERR(fbcon_device)) {
                printk(KERN_WARNING "Unable to create device "