Merge branch 'mv-merge'
[powerpc.git] / drivers / video / neofb.c
index e18c9f9..24b12f7 100644 (file)
@@ -165,20 +165,20 @@ static int neoFindMode(int xres, int yres, int depth)
 
        switch (depth) {
        case 8:
-               size = sizeof(bios8) / sizeof(biosMode);
+               size = ARRAY_SIZE(bios8);
                mode = bios8;
                break;
        case 16:
-               size = sizeof(bios16) / sizeof(biosMode);
+               size = ARRAY_SIZE(bios16);
                mode = bios16;
                break;
        case 24:
-               size = sizeof(bios24) / sizeof(biosMode);
+               size = ARRAY_SIZE(bios24);
                mode = bios24;
                break;
 #ifdef NO_32BIT_SUPPORT_YET
        case 32:
-               size = sizeof(bios32) / sizeof(biosMode);
+               size = ARRAY_SIZE(bios32);
                mode = bios32;
                break;
 #endif
@@ -486,10 +486,8 @@ static void vgaHWRestore(const struct fb_info *info,
 static inline int neo2200_sync(struct fb_info *info)
 {
        struct neofb_par *par = info->par;
-       int waitcycles;
 
-       while (readl(&par->neo2200->bltStat) & 1)
-               waitcycles++;
+       while (readl(&par->neo2200->bltStat) & 1);
        return 0;
 }
 
@@ -843,6 +841,9 @@ static int neofb_set_par(struct fb_info *info)
 
        par->SysIfaceCntl2 = 0xc0;      /* VESA Bios sets this to 0x80! */
 
+       /* Initialize: by default, we want display config register to be read */
+       par->PanelDispCntlRegRead = 1;
+
        /* Enable any user specified display devices. */
        par->PanelDispCntlReg1 = 0x00;
        if (par->internal_display)
@@ -853,7 +854,7 @@ static int neofb_set_par(struct fb_info *info)
        /* If the user did not specify any display devices, then... */
        if (par->PanelDispCntlReg1 == 0x00) {
                /* Default to internal (i.e., LCD) only. */
-               par->PanelDispCntlReg1 |= 0x02;
+               par->PanelDispCntlReg1 = vga_rgfx(NULL, 0x20) & 0x03;
        }
 
        /* If we are using a fixed mode, then tell the chip we are. */
@@ -1334,6 +1335,18 @@ static int neofb_blank(int blank_mode, struct fb_info *info)
        struct neofb_par *par = info->par;
        int seqflags, lcdflags, dpmsflags, reg;
 
+
+       /*
+        * Reload the value stored in the register, if sensible. It might have
+        * been changed via FN keystroke.
+        */
+       if (par->PanelDispCntlRegRead) {
+               neoUnlock();
+               par->PanelDispCntlReg1 = vga_rgfx(NULL, 0x20) & 0x03;
+               neoLock(&par->state);
+       }
+       par->PanelDispCntlRegRead = !blank_mode;
+
        switch (blank_mode) {
        case FB_BLANK_POWERDOWN:        /* powerdown - both sync lines down */
                seqflags = VGA_SR01_SCREEN_OFF; /* Disable sequencer */
@@ -1366,7 +1379,7 @@ static int neofb_blank(int blank_mode, struct fb_info *info)
        case FB_BLANK_NORMAL:           /* just blank screen (backlight stays on) */
                seqflags = VGA_SR01_SCREEN_OFF; /* Disable sequencer */
                lcdflags = par->PanelDispCntlReg1 & 0x02; /* LCD normal */
-               dpmsflags = 0;                  /* no hsync/vsync suppression */
+               dpmsflags = 0x00;       /* no hsync/vsync suppression */
                break;
        case FB_BLANK_UNBLANK:          /* unblank */
                seqflags = 0;                   /* Enable sequencer */