Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.5.62-ac1 /fbdev.diff

Filename:/fbdev.diff
Lines Added:26578
Lines Deleted:0
Also changed in: (Previous)
(Following)

Location
[  2.5.62-ac1
   o  fbdev.diff

Patch

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux-2.5.62/fbdev.diff linux-2.5.62-ac1/fbdev.diff
--- linux-2.5.62/fbdev.diff   1970-01-01 01:00:00.000000000 +0100
+++ linux-2.5.62-ac1/fbdev.diff   2003-02-20 01:08:02.000000000 +0000
@@ -0,0 +1,26578 @@
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/arch/mips64/Kconfig fbdev-2.5/arch/mips64/Kconfig
+--- linus-2.5/arch/mips64/Kconfig   Wed Feb 12 09:10:45 2003
++++ fbdev-2.5/arch/mips64/Kconfig   Wed Feb 19 17:16:00 2003
+@@ -5,6 +5,10 @@
+ 
+ mainmenu "Linux Kernel Configuration"
+ 
++config MIPS64
++   bool
++   default y
++
+ config MMU
+    bool
+    default y
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/arch/ppc/syslib/prom.c fbdev-2.5/arch/ppc/syslib/prom.c
+--- linus-2.5/arch/ppc/syslib/prom.c   Wed Feb 12 09:10:53 2003
++++ fbdev-2.5/arch/ppc/syslib/prom.c   Wed Feb 19 17:16:14 2003
+@@ -37,9 +37,6 @@
+ #include <asm/pci-bridge.h>
+ #include <asm/open_pic.h>
+ 
+-#ifdef CONFIG_FB
+-#include <asm/linux_logo.h>
+-#endif
+ 
+ struct pci_address {
+    unsigned a_hi;
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/arch/ppc/syslib/prom_init.c fbdev-2.5/arch/ppc/syslib/prom_init.c
+--- linus-2.5/arch/ppc/syslib/prom_init.c   Wed Feb 12 09:10:54 2003
++++ fbdev-2.5/arch/ppc/syslib/prom_init.c   Wed Feb 19 17:16:14 2003
+@@ -34,8 +34,9 @@
+ #include <asm/open_pic.h>
+ #include <asm/cacheflush.h>
+ 
+-#ifdef CONFIG_FB
+-#include <asm/linux_logo.h>
++#ifdef CONFIG_LOGO_LINUX_CLUT224
++#include <linux/linux_logo.h>
++extern const struct linux_logo logo_linux_clut224;
+ #endif
+ 
+ /*
+@@ -294,6 +295,7 @@
+       0xff, 0xff, 0x55,
+       0xff, 0xff, 0xff
+    };
++   const unsigned char *clut;
+ 
+    prom_disp_node = 0;
+ 
+@@ -360,20 +362,20 @@
+           * method is available.
+           * Should update this to use set-colors.
+           */
+-         for (i = 0; i < 32; i++)
+-            if (prom_set_color(ih, i, default_colors[i*3],
+-                     default_colors[i*3+1],
+-                     default_colors[i*3+2]) != 0)
++         clut = default_colors;
++         for (i = 0; i < 32; i++, clut += 3)
++            if (prom_set_color(ih, i, clut[0], clut[1],
++                     clut[2]) != 0)
+                break;
+ 
+-#ifdef CONFIG_FRAMEBUFFER_CONSOLE
+-         for (i = 0; i < LINUX_LOGO_COLORS; i++)
+-            if (prom_set_color(ih, i + 32,
+-                     linux_logo_red[i],
+-                     linux_logo_green[i],
+-                     linux_logo_blue[i]) != 0)
++#ifdef CONFIG_LOGO_LINUX_CLUT224
++         clut = logo_linux_clut224.clut;
++         for (i = 0; i < logo_linux_clut224.clutsize;
++              i++, clut += 3)
++            if (prom_set_color(ih, i + 32, clut[0],
++                     clut[1], clut[2]) != 0)
+                break;
+-#endif /* CONFIG_FRAMEBUFFER_CONSOLE */
++#endif /* CONFIG_LOGO_LINUX_CLUT224 */
+       }
+    }
+ 
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/arch/ppc64/kernel/prom.c fbdev-2.5/arch/ppc64/kernel/prom.c
+--- linus-2.5/arch/ppc64/kernel/prom.c   Wed Feb 12 09:10:54 2003
++++ fbdev-2.5/arch/ppc64/kernel/prom.c   Wed Feb 19 17:16:16 2003
+@@ -49,8 +49,9 @@
+ #include <asm/ppcdebug.h>
+ #include "open_pic.h"
+ 
+-#ifdef CONFIG_FB
+-#include <asm/linux_logo.h>
++#ifdef CONFIG_LOGO_LINUX_CLUT224
++#include <linux/linux_logo.h>
++extern const struct linux_logo logo_linux_clut224;
+ #endif
+ 
+ /*
+@@ -1232,6 +1233,7 @@
+       0xff, 0xff, 0x55,
+       0xff, 0xff, 0xff
+    };
++   const unsigned char *clut;
+ 
+    _prom->disp_node = 0;
+ 
+@@ -1261,20 +1263,19 @@
+ 
+       /* Setup a useable color table when the appropriate
+        * method is available. Should update this to set-colors */
+-      for (i = 0; i < 32; i++)
+-         if (prom_set_color(ih, i, RELOC(default_colors)[i*3],
+-                  RELOC(default_colors)[i*3+1],
+-                  RELOC(default_colors)[i*3+2]) != 0)
++      clut = RELOC(default_colors);
++      for (i = 0; i < 32; i++, clut += 3)
++         if (prom_set_color(ih, i, clut[0], clut[1],
++                  clut[2]) != 0)
+             break;
+ 
+-#ifdef CONFIG_FRAMEBUFFER_CONSOLE
+-      for (i = 0; i < LINUX_LOGO_COLORS; i++)
+-         if (prom_set_color(ih, i + 32,
+-                  RELOC(linux_logo_red)[i],
+-                  RELOC(linux_logo_green)[i],
+-                  RELOC(linux_logo_blue)[i]) != 0)
++#ifdef CONFIG_LOGO_LINUX_CLUT224
++      clut = RELOC(RELOC(&logo_linux_clut224)->clut);
++      for (i = 0; i < logo_linux_clut224.clutsize; i++, clut += 3)
++         if (prom_set_color(ih, i + 32, clut[0], clut[1],
++                  clut[2]) != 0)
+             break;
+-#endif /* CONFIG_FRAMEBUFFER_CONSOLE */
++#endif /* CONFIG_LOGO_LINUX_CLUT224 */
+ 
+       /*
+        * If this display is the device that OF is using for stdout,
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/char/vt.c fbdev-2.5/drivers/char/vt.c
+--- linus-2.5/drivers/char/vt.c   Wed Feb 19 13:08:32 2003
++++ fbdev-2.5/drivers/char/vt.c   Wed Feb 19 17:16:52 2003
+@@ -732,6 +732,10 @@
+    if (new_cols == video_num_columns && new_rows == video_num_lines)
+       return 0;
+ 
++   err = resize_screen(currcons, new_cols, new_rows);
++   if (err)
++      return err;
++
+    newscreen = (unsigned short *) kmalloc(new_screen_size, GFP_USER);
+    if (!newscreen)
+       return -ENOMEM;
+@@ -745,10 +749,6 @@
+    video_num_columns = new_cols;
+    video_size_row = new_row_size;
+    screenbuf_size = new_screen_size;
+-
+-   err = resize_screen(currcons, new_cols, new_rows);
+-   if (err)
+-      return err;
+ 
+    rlth = min(old_row_size, new_row_size);
+    rrem = new_row_size - rlth;
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/Kconfig fbdev-2.5/drivers/video/Kconfig
+--- linus-2.5/drivers/video/Kconfig   Wed Feb 19 13:08:44 2003
++++ fbdev-2.5/drivers/video/Kconfig   Wed Feb 19 17:18:07 2003
+@@ -923,6 +923,7 @@
+      If unsure, say N.
+ 
+ source "drivers/video/console/Kconfig"
++source "drivers/video/logo/Kconfig"
+ 
+ endmenu
+ 
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/Makefile fbdev-2.5/drivers/video/Makefile
+--- linus-2.5/drivers/video/Makefile   Wed Feb 12 09:12:08 2003
++++ fbdev-2.5/drivers/video/Makefile   Wed Feb 19 17:18:07 2003
+@@ -5,6 +5,7 @@
+ # Each configuration option enables a list of files.
+ 
+ obj-$(CONFIG_VT)        += console/
++obj-$(CONFIG_LOGO)        += logo/
+ 
+ obj-$(CONFIG_FB)                  += fbmem.o fbmon.o fbcmap.o modedb.o softcursor.o
+ # Only include macmodes.o if we have FB support and are PPC
+@@ -65,7 +66,7 @@
+ obj-$(CONFIG_FB_MATROX)        += matrox/
+ obj-$(CONFIG_FB_RIVA)        += riva/ cfbimgblt.o vgastate.o 
+ obj-$(CONFIG_FB_SIS)        += sis/
+-obj-$(CONFIG_FB_ATY)        += aty/ cfbimgblt.o cfbfillrect.o cfbimgblt.o
++obj-$(CONFIG_FB_ATY)        += aty/ cfbimgblt.o cfbfillrect.o cfbcopyarea.o
+ obj-$(CONFIG_FB_I810)             += i810/ cfbfillrect.o cfbcopyarea.o \
+                                 cfbimgblt.o vgastate.o
+ 
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/aty/atyfb_base.c fbdev-2.5/drivers/video/aty/atyfb_base.c
+--- linus-2.5/drivers/video/aty/atyfb_base.c   Wed Feb 12 09:12:09 2003
++++ fbdev-2.5/drivers/video/aty/atyfb_base.c   Wed Feb 19 17:18:11 2003
+@@ -148,9 +148,9 @@
+ static int atyfb_blank(int blank, struct fb_info *info);
+ static int atyfb_ioctl(struct inode *inode, struct file *file, u_int cmd,
+              u_long arg, struct fb_info *info);
+-extern void atyfb_fillrect(struct fb_info *info, struct fb_fillrect *rect);
+-extern void atyfb_copyarea(struct fb_info *info, struct fb_copyarea *area);
+-extern void atyfb_imageblit(struct fb_info *info, struct fb_image *image);
++extern void atyfb_fillrect(struct fb_info *info,const struct fb_fillrect *rect);
++extern void atyfb_copyarea(struct fb_info *info,const struct fb_copyarea *area);
++extern void atyfb_imageblit(struct fb_info *info,const struct fb_image *image);
+ #ifdef __sparc__
+ static int atyfb_mmap(struct fb_info *info, struct file *file,
+             struct vm_area_struct *vma);
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/aty/mach64_accel.c fbdev-2.5/drivers/video/aty/mach64_accel.c
+--- linus-2.5/drivers/video/aty/mach64_accel.c   Wed Feb 12 09:12:09 2003
++++ fbdev-2.5/drivers/video/aty/mach64_accel.c   Wed Feb 19 17:18:11 2003
+@@ -170,11 +170,11 @@
+    par->blitter_may_be_busy = 1;
+ }
+ 
+-void atyfb_copyarea(struct fb_info *info, struct fb_copyarea *area)
++void atyfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
+ {
+    struct atyfb_par *par = (struct atyfb_par *) info->par;
+-   
+-   u32 direction = DST_LAST_PEL;
++   u32 dy = area->dy, sy = area->sy, direction = DST_LAST_PEL;
++   u32 sx = area->sx, dx = area->dx, width = area->width;   
+    u32 pitch_value;
+ 
+    if (!area->width || !area->height)
+@@ -191,34 +191,35 @@
+       /* In 24 bpp, the engine is in 8 bpp - this requires that all */
+       /* horizontal coordinates and widths must be adjusted */
+       pitch_value *= 3;
+-      area->sx *= 3;
+-      area->dx *= 3;
+-      area->width *= 3;
++      sx *= 3;
++      dx *= 3;
++      width *= 3;
+    }
+ 
+    if (area->sy < area->dy) {
+-      area->dy += area->height - 1;
+-      area->sy += area->height - 1;
++      dy += area->height - 1;
++      sy += area->height - 1;
+    } else
+       direction |= DST_Y_TOP_TO_BOTTOM;
+ 
+-   if (area->sx < area->dx) {
+-      area->dx += area->width - 1;
+-      area->sx += area->width - 1;
++   if (sx < dx) {
++      dx += width - 1;
++      sx += width - 1;
+    } else
+       direction |= DST_X_LEFT_TO_RIGHT;
+ 
+    wait_for_fifo(4, par);
+    aty_st_le32(DP_SRC, FRGD_SRC_BLIT, par);
+-   aty_st_le32(SRC_Y_X, (area->sx << 16) | area->sy, par);
+-   aty_st_le32(SRC_HEIGHT1_WIDTH1, (area->width << 16) | area->height,par);
++   aty_st_le32(SRC_Y_X, (sx << 16) | sy, par);
++   aty_st_le32(SRC_HEIGHT1_WIDTH1, (width << 16) | area->height, par);
+    aty_st_le32(DST_CNTL, direction, par);
+-   draw_rect(area->dx, area->dy, area->width, area->height, par);
++   draw_rect(dx, dy, width, area->height, par);
+ }
+ 
+-void atyfb_fillrect(struct fb_info *info, struct fb_fillrect *rect)
++void atyfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
+ {
+    struct atyfb_par *par = (struct atyfb_par *) info->par;
++   u32 color = rect->color, dx = rect->dx, width = rect->width;
+ 
+    if (!rect->width || !rect->height)
+       return;
+@@ -229,28 +230,28 @@
+       return;
+    }
+ 
+-   rect->color |= (rect->color << 8);
+-   rect->color |= (rect->color << 16);
++   color |= (rect->color << 8);
++   color |= (rect->color << 16);
+ 
+    if (info->var.bits_per_pixel == 24) {
+       /* In 24 bpp, the engine is in 8 bpp - this requires that all */
+       /* horizontal coordinates and widths must be adjusted */
+-      rect->dx *= 3;
+-      rect->width *= 3;
++      dx *= 3;
++      width *= 3;
+    }
+ 
+    wait_for_fifo(3, par);
+-   aty_st_le32(DP_FRGD_CLR, rect->color, par);
++   aty_st_le32(DP_FRGD_CLR, color, par);
+    aty_st_le32(DP_SRC,
+           BKGD_SRC_BKGD_CLR | FRGD_SRC_FRGD_CLR | MONO_SRC_ONE,
+           par);
+    aty_st_le32(DST_CNTL,
+           DST_LAST_PEL | DST_Y_TOP_TO_BOTTOM |
+           DST_X_LEFT_TO_RIGHT, par);
+-   draw_rect(rect->dx, rect->dy, rect->width, rect->height, par);
++   draw_rect(dx, rect->dy, width, rect->height, par);
+ }
+ 
+-void atyfb_imageblit(struct fb_info *info, struct fb_image *image)
++void atyfb_imageblit(struct fb_info *info, const struct fb_image *image)
+ {
+    struct atyfb_par *par = (struct atyfb_par *) info->par;
+     
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/aty/mach64_ct.c fbdev-2.5/drivers/video/aty/mach64_ct.c
+--- linus-2.5/drivers/video/aty/mach64_ct.c   Wed Feb 12 09:12:09 2003
++++ fbdev-2.5/drivers/video/aty/mach64_ct.c   Wed Feb 19 17:18:11 2003
+@@ -1,30 +1,26 @@
+-
+ /*
+  *  ATI Mach64 CT/VT/GT/LT Support
+  */
+ 
+ #include <linux/fb.h>
+-
+ #include <asm/io.h>
+-
+ #include <video/mach64.h>
+ #include "atyfb.h"
+ 
+-
+ /* FIXME: remove the FAIL definition */
+ #define FAIL(x) do { printk(x "\n"); return -EINVAL; } while (0)
+ 
+ static void aty_st_pll(int offset, u8 val, const struct atyfb_par *par);
+ static int aty_valid_pll_ct(const struct fb_info *info, u32 vclk_per,
+              struct pll_ct *pll);
+-static int aty_dsp_gt(const struct fb_info *info, u8 bpp,
++static int aty_dsp_gt(const struct fb_info *info, u32 bpp, u32 stretch,
+             struct pll_ct *pll);
+ static int aty_var_to_pll_ct(const struct fb_info *info, u32 vclk_per,
+-              u8 bpp, union aty_pll *pll);
++              u32 bpp, u32 stretch, union aty_pll *pll);
+ static u32 aty_pll_ct_to_var(const struct fb_info *info,
+               const union aty_pll *pll);
+ 
+-
++static u8 postdividers[] = {1,2,4,8,3};
+ 
+ static void aty_st_pll(int offset, u8 val, const struct atyfb_par *par)
+ {
+@@ -32,7 +28,7 @@
+    aty_st_8(CLOCK_CNTL + 1, (offset << 2) | PLL_WR_EN, par);
+    /* write the register value */
+    aty_st_8(CLOCK_CNTL + 2, val, par);
+-   aty_st_8(CLOCK_CNTL + 1, (offset << 2) & ~PLL_WR_EN, par);
++   aty_st_8(CLOCK_CNTL + 1, (offset << 2), par);
+ }
+ 
+ 
+@@ -42,58 +38,39 @@
+      *  PLL programming (Mach64 CT family)
+      */
+ 
+-static int aty_dsp_gt(const struct fb_info *info, u8 bpp,
+-            struct pll_ct *pll)
++static int aty_dsp_gt(const struct fb_info *info, u32 bpp,
++            u32 width, struct pll_ct *pll)
+ {
+    struct atyfb_par *par = (struct atyfb_par *) info->par;
+-   u32 dsp_xclks_per_row, dsp_loop_latency, dsp_precision, dsp_off,
+-       dsp_on;
+-   u32 xclks_per_row, fifo_off, fifo_on, y, fifo_size, page_size;
++   u32 dsp_xclks_per_row, dsp_precision, dsp_off, dsp_on;
++   u32 xclks_per_row, fifo_off, fifo_on, y, page_size;
+ 
+    /* xclocks_per_row<<11 */
+    xclks_per_row =
+        (pll->mclk_fb_div * pll->vclk_post_div_real * 64 << 11) /
+-       (pll->vclk_fb_div * pll->mclk_post_div_real * bpp);
++       (pll->vclk_fb_div * pll->xclk_post_div_real * bpp);
++#ifdef CONFIG_FB_ATY_GENERIC_LCD
++   if (width != 0)
++      xclks_per_row = (xclks_per_row * par->lcd_width) / width;
++#endif
+    if (xclks_per_row < (1 << 11))
+       FAIL("Dotclock to high");
+-   if (M64_HAS(FIFO_24)) {
+-      fifo_size = 24;
+-      dsp_loop_latency = 0;
+-   } else {
+-      fifo_size = 32;
+-      dsp_loop_latency = 2;
+-   }
++
+    dsp_precision = 0;
+-   y = (xclks_per_row * fifo_size) >> 11;
++   y = (xclks_per_row * par->fifo_size) >> 11;
+    while (y) {
+       y >>= 1;
+       dsp_precision++;
+    }
+    dsp_precision -= 5;
+    /* fifo_off<<6 */
+-   fifo_off = ((xclks_per_row * (fifo_size - 1)) >> 5) + (3 << 6);
++   fifo_off = ((xclks_per_row * (par->fifo_size - 1)) >> 5) + (3 << 6);
+ 
+-   if (info->fix.smem_len > 1 * 1024 * 1024) {
+-      if (par->ram_type >= SDRAM) {
+-         /* >1 MB SDRAM */
+-         dsp_loop_latency += 8;
+-         page_size = 8;
+-      } else {
+-         /* >1 MB DRAM */
+-         dsp_loop_latency += 6;
+-         page_size = 9;
+-      }
+-   } else {
+-      if (par->ram_type >= SDRAM) {
+-         /* <2 MB SDRAM */
+-         dsp_loop_latency += 9;
+-         page_size = 10;
+-      } else {
+-         /* <2 MB DRAM */
+-         dsp_loop_latency += 8;
+-         page_size = 10;
+-      }
+-   }
++   page_size = par->page_size;
++#ifdef CONFIG_FB_ATY_GENERIC_LCD
++   if (width != 0)
++      page_size = (page_size * par->lcd_width) / width;
++#endif
+    /* fifo_on<<6 */
+    if (xclks_per_row >= (page_size << 11))
+       fifo_on =
+@@ -106,7 +83,7 @@
+    dsp_off = fifo_off >> dsp_precision;
+ 
+    pll->dsp_config = (dsp_xclks_per_row & 0x3fff) |
+-       ((dsp_loop_latency & 0xf) << 16) | ((dsp_precision & 7) << 20);
++       ((par->dsp_loop_latency & 0xf) << 16) | ((dsp_precision & 7) << 20);
+    pll->dsp_on_off = (dsp_on & 0x7ff) | ((dsp_off & 0x7ff) << 16);
+    return 0;
+ }
+@@ -120,107 +97,36 @@
+ 
+    pll->pll_ref_div = par->pll_per * 2 * 255 / par->ref_clk_per;
+ 
+-   /* FIXME: use the VTB/GTB /3 post divider if it's better suited */
+-   q = par->ref_clk_per * pll->pll_ref_div * 4 / par->mclk_per;   /* actually 8*q */
+-   if (q < 16 * 8 || q > 255 * 8)
+-      FAIL("mclk out of range");
+-   else if (q < 32 * 8)
+-      pll->mclk_post_div_real = 8;
+-   else if (q < 64 * 8)
+-      pll->mclk_post_div_real = 4;
+-   else if (q < 128 * 8)
+-      pll->mclk_post_div_real = 2;
+-   else
+-      pll->mclk_post_div_real = 1;
+-   pll->mclk_fb_div = q * pll->mclk_post_div_real / 8;
+-
+    /* FIXME: use the VTB/GTB /{3,6,12} post dividers if they're better suited */
+    q = par->ref_clk_per * pll->pll_ref_div * 4 / vclk_per;   /* actually 8*q */
+-   if (q < 16 * 8 || q > 255 * 8)
++   if (q < 16*8 || q > 255*8)
+       FAIL("vclk out of range");
+-   else if (q < 32 * 8)
+-      pll->vclk_post_div_real = 8;
+-   else if (q < 64 * 8)
+-      pll->vclk_post_div_real = 4;
+-   else if (q < 128 * 8)
+-      pll->vclk_post_div_real = 2;
+-   else
+-      pll->vclk_post_div_real = 1;
+-   pll->vclk_fb_div = q * pll->vclk_post_div_real / 8;
+-   return 0;
+-}
+-
+-void aty_calc_pll_ct(const struct fb_info *info, struct pll_ct *pll)
+-{
+-   struct atyfb_par *par = (struct atyfb_par *) info->par;
+-   u8 mpostdiv = 0;
+-   u8 vpostdiv = 0;
+-
+-   if (M64_HAS(SDRAM_MAGIC_PLL) && (par->ram_type >= SDRAM))
+-      pll->pll_gen_cntl = 0x04;
+-   else
+-      pll->pll_gen_cntl = 0x84;
+-
+-   switch (pll->mclk_post_div_real) {
+-   case 1:
+-      mpostdiv = 0;
+-      break;
+-   case 2:
+-      mpostdiv = 1;
+-      break;
+-   case 3:
+-      mpostdiv = 4;
+-      break;
+-   case 4:
+-      mpostdiv = 2;
+-      break;
+-   case 8:
+-      mpostdiv = 3;
+-      break;
+-   }
+-   pll->pll_gen_cntl |= mpostdiv << 4;   /* mclk */
+-
+-   if (M64_HAS(MAGIC_POSTDIV))
+-      pll->pll_ext_cntl = 0;
+-   else
+-      pll->pll_ext_cntl = mpostdiv;   /* xclk == mclk */
+-
+-   switch (pll->vclk_post_div_real) {
+-   case 2:
+-      vpostdiv = 1;
+-      break;
+-   case 3:
+-      pll->pll_ext_cntl |= 0x10;
+-   case 1:
+-      vpostdiv = 0;
+-      break;
+-   case 6:
+-      pll->pll_ext_cntl |= 0x10;
+-   case 4:
+-      vpostdiv = 2;
+-      break;
+-   case 12:
+-      pll->pll_ext_cntl |= 0x10;
+-   case 8:
+-      vpostdiv = 3;
+-      break;
++   else {
++      pll->vclk_post_div = 0;
++      if (q < 128*8)
++         pll->vclk_post_div++;
++      if (q < 64*8)
++         pll->vclk_post_div++;
++      if (q < 32*8)
++         pll->vclk_post_div++;
+    }
+-
++   pll->vclk_post_div_real = postdividers[pll->vclk_post_div];
++   pll->vclk_fb_div = q*pll->vclk_post_div_real/8;
+    pll->pll_vclk_cntl = 0x03;   /* VCLK = PLL_VCLK/VCLKx_POST */
+-   pll->vclk_post_div = vpostdiv;
++
++   return 0;
+ }
+ 
+ static int aty_var_to_pll_ct(const struct fb_info *info, u32 vclk_per,
+-              u8 bpp, union aty_pll *pll)
++              u32 bpp, u32 width, union aty_pll *pll)
+ {
+    struct atyfb_par *par = (struct atyfb_par *) info->par;
+    int err;
+ 
+    if ((err = aty_valid_pll_ct(info, vclk_per, &pll->ct)))
+       return err;
+-   if (M64_HAS(GTB_DSP) && (err = aty_dsp_gt(info, bpp, &pll->ct)))
++   if (M64_HAS(GTB_DSP) && (err = aty_dsp_gt(info, bpp, width, &pll->ct)))
+       return err;
+-   aty_calc_pll_ct(info, &pll->ct);
+    return 0;
+ }
+ 
+@@ -240,16 +146,183 @@
+ void aty_set_pll_ct(const struct fb_info *info,
+           const union aty_pll *pll)
+ {
+-   struct atyfb_par *par = (struct atyfb_par *) info->par;
++   struct atyfb_par *par = (struct atyfb_par *)info->par;
++
++   u8 tmp, tmp2; u32 crtc_gen_cntl;
++#ifdef DEBUG
++   printk("aty_set_pll_ct: setting clock %i for FeedBackDivider %i, ReferenceDivider %i, PostDivider %i\n",
++      par->clock, pll->ct.vclk_fb_div, par->pll_ref_div, pll->ct.vclk_post_div);
++#endif
++    /* Temporarily switch to accelerator mode */
++    crtc_gen_cntl = aty_ld_le32(CRTC_GEN_CNTL, par);
++    if (!(crtc_gen_cntl & CRTC_EXT_DISP_EN))
++        aty_st_le32(CRTC_GEN_CNTL, crtc_gen_cntl | CRTC_EXT_DISP_EN, par);
++
++    /* Reset VCLK generator */
++    aty_st_pll(PLL_VCLK_CNTL, pll->ct.pll_vclk_cntl, par);
++
++    /* Set post-divider */
++    tmp2 = par->clock << 1;
++    tmp = aty_ld_pll(VCLK_POST_DIV, par);
++    tmp &= ~(0x03U << tmp2);
++    tmp |= ((pll->ct.vclk_post_div & 0x03U) << tmp2);
++    aty_st_pll(VCLK_POST_DIV, tmp, par);
++
++    /* Set extended post-divider */
++    tmp = aty_ld_pll(PLL_EXT_CNTL, par);
++    tmp &= ~(0x10U << par->clock);
++    tmp |= (((pll->ct.vclk_post_div >> 2) & 0x10U) << par->clock);
++    aty_st_pll(PLL_EXT_CNTL, tmp, par);
++
++    /* Set feedback divider */
++    tmp = VCLK0_FB_DIV + par->clock;
++    aty_st_pll(tmp, (pll->ct.vclk_fb_div & 0xFFU), par);
++
++    /* End VCLK generator reset */
++    aty_st_pll(PLL_VCLK_CNTL, pll->ct.pll_vclk_cntl & ~(0x04U), par);
++
++    /* Reset write bit */
++    /* ATIAccessMach64PLLReg(pATI, 0, FALSE); */
++
++    /* Restore register */
++    if (!(crtc_gen_cntl & CRTC_EXT_DISP_EN))
++        aty_st_le32(CRTC_GEN_CNTL, crtc_gen_cntl, par);
++
++    if (M64_HAS(GTB_DSP)) {
++   aty_st_le32(DSP_CONFIG, pll->ct.dsp_config, par);
++   aty_st_le32(DSP_ON_OFF, pll->ct.dsp_on_off, par);
++    }
++}
++
+ 
+-   aty_st_pll(PLL_REF_DIV, pll->ct.pll_ref_div, par);
+-   aty_st_pll(PLL_GEN_CNTL, pll->ct.pll_gen_cntl, par);
+-   aty_st_pll(MCLK_FB_DIV, pll->ct.mclk_fb_div, par);
+-   aty_st_pll(PLL_VCLK_CNTL, pll->ct.pll_vclk_cntl, par);
+-   aty_st_pll(VCLK_POST_DIV, pll->ct.vclk_post_div, par);
+-   aty_st_pll(VCLK0_FB_DIV, pll->ct.vclk_fb_div, par);
+-   aty_st_pll(PLL_EXT_CNTL, pll->ct.pll_ext_cntl, par);
++static void __init aty_init_pll_ct(struct fb_info *info)
++{
++   struct atyfb_par *par = (struct atyfb_par *)info->par;
++   struct pll_ct *pll = &par->pll.ct;
++   u8 pll_ref_div, pll_gen_cntl, pll_ext_cntl;
++   u8 mpost_div, xpost_div;
++   u8 sclk_post_div_real, sclk_fb_div, spll_cntl2;
++   u32 q;
+ 
++   if (M64_HAS(FIFO_24)) {
++      par->fifo_size = 24;
++      par->dsp_loop_latency = 0;
++   } else {
++      par->fifo_size = 32;
++      par->dsp_loop_latency = 2;
++   }
++
++   if (info->fix.smem_len > 1*1024*1024) {
++      if (par->ram_type >= SDRAM) {
++         /* >1 MB SDRAM */
++         par->dsp_loop_latency += 8;
++         par->page_size = 8;
++      } else {
++         /* >1 MB DRAM */
++         par->dsp_loop_latency += 6;
++         par->page_size = 9;
++      }
++   } else {
++      if (par->ram_type >= SDRAM) {
++         /* <2 MB SDRAM */
++         par->dsp_loop_latency += 9;
++         par->page_size = 10;
++      } else {
++         /* <2 MB DRAM */
++         par->dsp_loop_latency += 8;
++         par->page_size = 10;
++      }
++   }
++
++   /* Exit if the user does not want us to play with the clock
++      rates of her chip. */
++   if (par->mclk_per == 0) {
++      u16 mclk_fb_div;
++      u8 pll_ext_cntl;
++
++      pll->pll_ref_div = aty_ld_pll(PLL_REF_DIV, par);
++      pll_ext_cntl = aty_ld_pll(PLL_EXT_CNTL, par);
++      pll->xclk_post_div_real = postdividers[pll_ext_cntl & 7];
++      mclk_fb_div = aty_ld_pll(MCLK_FB_DIV, par);
++      if (pll_ext_cntl & 8)
++         mclk_fb_div <<= 1;
++      pll->mclk_fb_div = mclk_fb_div;
++      return;
++   }
++
++   pll_ref_div = par->pll_per * 2 * 255 / par->ref_clk_per;
++   pll->pll_ref_div = pll_ref_div;
++
++   /* FIXME: use the VTB/GTB /3 post divider if it's better suited */
++   q = par->ref_clk_per * pll_ref_div * 4 / par->xclk_per;   /* actually 8*q */
++   if (q < 16*8 || q > 255*8) {
++      printk(KERN_CRIT "xclk out of range\n");
++      return;
++   } else {
++      xpost_div = 0;
++      if (q < 128*8)
++         xpost_div++;
++      if (q < 64*8)
++         xpost_div++;
++      if (q < 32*8)
++         xpost_div++;
++   }
++   pll->xclk_post_div_real = postdividers[xpost_div];
++   pll->mclk_fb_div = q * pll->xclk_post_div_real / 8;
++
++   if (M64_HAS(SDRAM_MAGIC_PLL) && (par->ram_type >= SDRAM))
++      pll_gen_cntl = 0x04;
++   else
++      pll_gen_cntl = 0x84;
++
++   if (M64_HAS(MAGIC_POSTDIV))
++      pll_ext_cntl = 0;
++   else
++      pll_ext_cntl = xpost_div;
++
++   if (par->mclk_per == par->xclk_per)
++      pll_gen_cntl |= xpost_div<<4; /* mclk == xclk */
++   else {
++      pll_gen_cntl |= 6<<4;   /* mclk == sclk*/
++
++      q = par->ref_clk_per * pll_ref_div * 4 / par->mclk_per;   /* actually 8*q */
++      if (q < 16 * 8 || q > 255 * 8) {
++         printk(KERN_CRIT "mclk out of range\n");
++         return;
++      } else {
++         mpost_div = 0;
++         if (q < 128*8)
++            mpost_div++;
++         if (q < 64*8)
++            mpost_div++;
++         if (q < 32*8)
++            mpost_div++;
++      }
++      sclk_post_div_real = postdividers[mpost_div];
++      sclk_fb_div = q * sclk_post_div_real / 8;
++      spll_cntl2 = mpost_div << 4;
++/*
++      This disables the sclk, crashes the computer as reported:
++      aty_st_pll(SPLL_CNTL2, 3, info);
++
++      So it seems the sclk must be enabled before it is used;
++      so PLL_GEN_CNTL must be programmed *after* the sclk.
++*/
++#ifdef DEBUG
++      printk(KERN_INFO "sclk_fb_div: %x spll_cntl2:%x\n",
++         sclk_fb_div, spll_cntl2);
++#endif
++      aty_st_pll(SPLL_CNTL2, spll_cntl2, par);
++      aty_st_pll(SCLK_FB_DIV, sclk_fb_div, par);
++   }
++#ifdef DEBUG
++   printk(KERN_INFO "pll_ref_div: %x pll_gencntl: %x mclk_fb_div: %x pll_ext_cntl: %x\n",
++      pll_ref_div, pll_gen_cntl, par->mclk_fb_div, pll_ext_cntl);
++#endif
++   aty_st_pll(PLL_REF_DIV, pll_ref_div, par);
++   aty_st_pll(PLL_GEN_CNTL, pll_gen_cntl, par);
++   aty_st_pll(MCLK_FB_DIV, pll->mclk_fb_div, par);
++   aty_st_pll(PLL_EXT_CNTL, pll_ext_cntl, par);
+    if (M64_HAS(GTB_DSP)) {
+       if (M64_HAS(XL_DLL))
+          aty_st_pll(DLL_CNTL, 0x80, par);
+@@ -258,8 +331,6 @@
+       else
+          aty_st_pll(DLL_CNTL, 0xa0, par);
+       aty_st_pll(VFC_CNTL, 0x1b, par);
+-      aty_st_le32(DSP_CONFIG, pll->ct.dsp_config, par);
+-      aty_st_le32(DSP_ON_OFF, pll->ct.dsp_on_off, par);
+    }
+ }
+ 
+@@ -269,11 +340,12 @@
+ }
+ 
+ const struct aty_dac_ops aty_dac_ct = {
+-   .set_dac   = (void *) dummy,
++   .set_dac   = (void *)dummy,
+ };
+ 
+ const struct aty_pll_ops aty_pll_ct = {
+    .var_to_pll   = aty_var_to_pll_ct,
+    .pll_to_var   = aty_pll_ct_to_var,
+    .set_pll   = aty_set_pll_ct,
++   .init_pll   = aty_init_pll_ct
+ };
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/aty/mach64_cursor.c fbdev-2.5/drivers/video/aty/mach64_cursor.c
+--- linus-2.5/drivers/video/aty/mach64_cursor.c   Wed Feb 12 09:12:09 2003
++++ fbdev-2.5/drivers/video/aty/mach64_cursor.c   Wed Feb 19 17:18:11 2003
+@@ -135,6 +135,10 @@
+          yoff = 0;
+       }
+ 
++      /* In doublescan mode, the cursor location also needs to be
++         doubled. */
++                if (par->crtc.gen_cntl & CRTC_DBL_SCAN_EN)
++         y<<=1;
+       wait_for_fifo(4, par);
+       aty_st_le32(CUR_OFFSET, (info->fix.smem_len >> 3) + (yoff << 1),
+              par);
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/aty/mach64_gx.c fbdev-2.5/drivers/video/aty/mach64_gx.c
+--- linus-2.5/drivers/video/aty/mach64_gx.c   Wed Feb 12 09:12:09 2003
++++ fbdev-2.5/drivers/video/aty/mach64_gx.c   Wed Feb 19 17:18:11 2003
+@@ -1,11 +1,9 @@
+-
+ /*
+  *  ATI Mach64 GX Support
+  */
+ 
+ #include <linux/delay.h>
+ #include <linux/fb.h>
+-#include <linux/sched.h>
+ 
+ #include <asm/io.h>
+ 
+@@ -121,7 +119,7 @@
+ }
+ 
+ static int aty_var_to_pll_514(const struct fb_info *info, u32 vclk_per,
+-               u8 bpp, union aty_pll *pll)
++               u32 bpp, u32 width, union aty_pll *pll)
+ {
+    /*
+     *  FIXME: use real calculations instead of using fixed values from the old
+@@ -339,8 +337,8 @@
+      *  ATI 18818 / ICS 2595 Clock Chip
+      */
+ 
+-static int aty_var_to_pll_18818(const struct fb_info *info,
+-            u32 vclk_per, u8 bpp, union aty_pll *pll)
++static int aty_var_to_pll_18818(const struct fb_info *info, u32 vclk_per,
++            u32 bpp, u32 width, union aty_pll *pll)
+ {
+    u32 MHz100;      /* in 0.01 MHz */
+    u32 program_bits;
+@@ -495,8 +493,8 @@
+      *  STG 1703 Clock Chip
+      */
+ 
+-static int aty_var_to_pll_1703(const struct fb_info *info,
+-                u32 vclk_per, u8 bpp, union aty_pll *pll)
++static int aty_var_to_pll_1703(const struct fb_info *info, u32 vclk_per,
++                u32 bpp, u32 width, union aty_pll *pll)
+ {
+    u32 mhz100;      /* in 0.01 MHz */
+    u32 program_bits;
+@@ -611,8 +609,8 @@
+      *  Chrontel 8398 Clock Chip
+      */
+ 
+-static int aty_var_to_pll_8398(const struct fb_info *info,
+-                u32 vclk_per, u8 bpp, union aty_pll *pll)
++static int aty_var_to_pll_8398(const struct fb_info *info, u32 vclk_per,
++                u32 bpp, u32 width, union aty_pll *pll)
+ {
+    u32 tempA, tempB, fOut, longMHz100, diff, preDiff;
+ 
+@@ -736,7 +734,7 @@
+      */
+ 
+ static int aty_var_to_pll_408(const struct fb_info *info, u32 vclk_per,
+-               u8 bpp, union aty_pll *pll)
++               u32 bpp, u32 width, union aty_pll *pll)
+ {
+    u32 mhz100;      /* in 0.01 MHz */
+    u32 program_bits;
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/aty128fb.c fbdev-2.5/drivers/video/aty128fb.c
+--- linus-2.5/drivers/video/aty128fb.c   Wed Feb 12 09:12:08 2003
++++ fbdev-2.5/drivers/video/aty128fb.c   Wed Feb 19 17:18:07 2003
+@@ -7,7 +7,7 @@
+  *                Ani Joshi / Jeff Garzik
+  *                      - Code cleanup
+  *
+- *                Michel Dänzer <michdaen@iiic.ethz.ch>
++ *                Michel Danzer <michdaen@iiic.ethz.ch>
+  *                      - 15/16 bit cleanup
+  *                      - fix panning
+  *
+@@ -153,14 +153,20 @@
+      PCI_ANY_ID, PCI_ANY_ID, 0, 0, rage_128 },
+    { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RAGE128_RF,
+      PCI_ANY_ID, PCI_ANY_ID, 0, 0, rage_128 },
++   { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RAGE128_RI,
++     PCI_ANY_ID, PCI_ANY_ID, 0, 0, rage_128 },
+    { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RAGE128_RK,
+      PCI_ANY_ID, PCI_ANY_ID, 0, 0, rage_128 },
+    { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RAGE128_RL,
+      PCI_ANY_ID, PCI_ANY_ID, 0, 0, rage_128 },
++   { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_Rage128_PD,
++     PCI_ANY_ID, PCI_ANY_ID, 0, 0, rage_128_pro },
+    { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RAGE128_PF,
+      PCI_ANY_ID, PCI_ANY_ID, 0, 0, rage_128_pro },
+    { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RAGE128_PR,
+      PCI_ANY_ID, PCI_ANY_ID, 0, 0, rage_128_pro },
++   { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RAGE128_PP,
++     PCI_ANY_ID, PCI_ANY_ID, 0, 0, rage_128_pro },
+    { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RAGE128_U3,
+      PCI_ANY_ID, PCI_ANY_ID, 0, 0, rage_128_pro },
+    { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RAGE128_U1,
+@@ -367,8 +373,9 @@
+                              struct aty128fb_par *par);
+ #if !defined(CONFIG_PPC) && !defined(__sparc__)
+ static void __init aty128_get_pllinfo(struct aty128fb_par *par,
+-                  char *bios_seg);
+-static char __init *aty128find_ROM(void);
++                  void *bios);
++static void __init *aty128_map_ROM(struct pci_dev *pdev);
++static void __init aty128_unmap_ROM(struct pci_dev *dev, void * rom);
+ #endif
+ static void aty128_timings(struct aty128fb_par *par);
+ static void aty128_init_engine(struct aty128fb_par *par);
+@@ -1415,13 +1422,16 @@
+ #ifdef CONFIG_PMAC_PBOOK
+       if (!strncmp(this_opt, "lcd:", 4)) {
+          default_lcd_on = simple_strtoul(this_opt+4, NULL, 0);
++         continue;
+       } else if (!strncmp(this_opt, "crt:", 4)) {
+          default_crt_on = simple_strtoul(this_opt+4, NULL, 0);
++         continue;
+       }
+ #endif
+ #ifdef CONFIG_MTRR
+       if(!strncmp(this_opt, "nomtrr", 6)) {
+          mtrr = 0;
++         continue;
+       }
+ #endif
+ #ifdef CONFIG_ALL_PPC
+@@ -1430,6 +1440,7 @@
+          unsigned int vmode = simple_strtoul(this_opt+6, NULL, 0);
+          if (vmode > 0 && vmode <= VMODE_MAX)
+             default_vmode = vmode;
++         continue;
+       } else if (!strncmp(this_opt, "cmode:", 6)) {
+          unsigned int cmode = simple_strtoul(this_opt+6, NULL, 0);
+          switch (cmode) {
+@@ -1446,10 +1457,10 @@
+             default_cmode = CMODE_32;
+             break;
+          }
++         continue;
+       }
+ #endif /* CONFIG_ALL_PPC */
+-      else
+-         mode_option = this_opt;
++      mode_option = this_opt;
+    }
+    return 0;
+ }
+@@ -1488,6 +1499,9 @@
+       case PCI_DEVICE_ID_ATI_RAGE128_RL:
+          strcpy(video_card, "Rage128 RL (AGP)");
+          break;
++      case PCI_DEVICE_ID_ATI_Rage128_PD:
++         strcpy(video_card, "Rage128 Pro PD (PCI)");
++         break;
+       case PCI_DEVICE_ID_ATI_RAGE128_PF:
+          strcpy(video_card, "Rage128 Pro PF (AGP)");
+          break;
+@@ -1636,7 +1650,7 @@
+    struct fb_info *info;
+    int err, size;
+ #if !defined(CONFIG_PPC) && !defined(__sparc__)
+-   char *bios_seg = NULL;
++   void *bios = NULL;
+ #endif
+ 
+    /* Enable device in PCI config */
+@@ -1651,21 +1665,21 @@
+             "aty128fb FB")) {
+       printk(KERN_ERR "aty128fb: cannot reserve frame "
+             "buffer memory\n");
+-      goto err_free_fb;
++      return -ENODEV;
+    }
+ 
+    reg_addr = pci_resource_start(pdev, 2);
+    if (!request_mem_region(reg_addr, pci_resource_len(pdev, 2),
+             "aty128fb MMIO")) {
+       printk(KERN_ERR "aty128fb: cannot reserve MMIO region\n");
+-      goto err_free_mmio;
++      goto err_free_fb;
+    }
+ 
+    /* We have the resources. Now virtualize them */
+    size = sizeof(struct fb_info) + sizeof(struct aty128fb_par);
+    if (!(info = kmalloc(size, GFP_ATOMIC))) {
+       printk(KERN_ERR "aty128fb: can't alloc fb_info_aty128\n");
+-      goto err_unmap_out;
++      goto err_free_mmio;
+    }
+    memset(info, 0, size);
+ 
+@@ -1677,19 +1691,18 @@
+ 
+    /* Virtualize mmio region */
+    info->fix.mmio_start = reg_addr;
+-   par->regbase = ioremap(reg_addr, 0x2000);
++   par->regbase = ioremap(reg_addr, pci_resource_len(pdev, 2));
+    if (!par->regbase)
+       goto err_free_info;
+ 
+    /* Grab memory size from the card */
++   // How does this relate to the resource length from the PCI hardware?
+    par->vram_size = aty_ld_le32(CONFIG_MEMSIZE) & 0x03FFFFFF;
+ 
+    /* Virtualize the framebuffer */
+    info->screen_base = ioremap(fb_addr, par->vram_size);
+-   if (!info->screen_base) {
+-      iounmap(par->regbase);
+-      goto err_free_info;
+-   }
++   if (!info->screen_base)
++      goto err_unmap_out;
+ 
+    /* Set up info->fix */
+    info->fix = aty128fb_fix;
+@@ -1704,13 +1717,13 @@
+    }
+ 
+ #if !defined(CONFIG_PPC) && !defined(__sparc__)
+-   if (!(bios_seg = aty128find_ROM()))
+-      printk(KERN_INFO "aty128fb: Rage128 BIOS not located. "
+-               "Guessing...\n");
++   if (!(bios = aty128_map_ROM(pdev)))
++      printk(KERN_INFO "aty128fb: BIOS not located, guessing timings.\n");
+    else {
+-      printk(KERN_INFO "aty128fb: Rage128 BIOS located at "
+-            "segment %4.4X\n", (unsigned int)bios_seg);
+-      aty128_get_pllinfo(par, bios_seg);
++      printk(KERN_INFO "aty128fb: Rage128 BIOS located at %lx\n",
++            pdev->resource[PCI_ROM_RESOURCE].start);
++      aty128_get_pllinfo(par, bios);
++      aty128_unmap_ROM(pdev, bios);
+    }
+ #endif
+    aty128_timings(par);
+@@ -1732,18 +1745,16 @@
+ 
+ err_out:
+    iounmap(info->screen_base);
++err_unmap_out:
+    iounmap(par->regbase);
+ err_free_info:
+    kfree(info);
+-err_unmap_out:
++err_free_mmio:
+    release_mem_region(pci_resource_start(pdev, 2),
+          pci_resource_len(pdev, 2));
+-err_free_mmio:
++err_free_fb:
+    release_mem_region(pci_resource_start(pdev, 0),
+          pci_resource_len(pdev, 0));
+-err_free_fb:
+-   release_mem_region(pci_resource_start(pdev, 1),
+-         pci_resource_len(pdev, 1));
+    return -ENODEV;
+ }
+ 
+@@ -1780,86 +1791,65 @@
+ 
+ /* PPC and Sparc cannot read video ROM */
+ #if !defined(CONFIG_PPC) && !defined(__sparc__)
+-static char * __init aty128find_ROM(void)
++static void * __init aty128_map_ROM(struct pci_dev *dev)
+ {
+-   u32  segstart;
+-   char *rom_base;
+-   char *rom;
+-   int  stage;
+-   int  i, j;
+-   char aty_rom_sig[] = "761295520";   /* ATI ROM Signature      */
+-   char *R128_sig[] = {
+-      "R128",      /* Rage128 ROM identifier */
+-      "128b"
+-   };
+-
+-   for (segstart=0x000c0000; segstart<0x000f0000; segstart+=0x00001000) {
+-           stage = 1;
+-
+-      rom_base = (char *)ioremap(segstart, 0x1000);
+-
+-      if ((*rom_base == 0x55) && (((*(rom_base + 1)) & 0xff) == 0xaa))
+-         stage = 2;
+-
+-      if (stage != 2) {
+-         iounmap(rom_base);
+-         continue;
+-      }
+-      rom = rom_base;
+-
+-      for (i = 0; (i < 128 - strlen(aty_rom_sig)) && (stage != 3); i++) {
+-         if (aty_rom_sig[0] == *rom)
+-            if (strncmp(aty_rom_sig, rom,
+-                  strlen(aty_rom_sig)) == 0)
+-               stage = 3;
+-         rom++;
+-      }
+-      if (stage != 3) {
+-         iounmap(rom_base);
+-         continue;
+-      }
+-      rom = rom_base;
+-
+-      /* ATI signature found.  Let's see if it's a Rage128 */
+-      for (i = 0; (i < 512) && (stage != 4); i++) {
+-         for (j = 0; j < sizeof(R128_sig)/sizeof(char *);j++) {
+-            if (R128_sig[j][0] == *rom)
+-               if (strncmp(R128_sig[j], rom, 
+-                   strlen(R128_sig[j])) == 0) {
+-                  stage = 4;
+-                  break;
+-               }
+-         }
+-         rom++;
+-      }
+-      if (stage != 4) {
+-         iounmap(rom_base);
+-         continue;
+-      }
+-      return rom_base;
++   // If this is a primary card, there is a shadow copy of the
++   // ROM somewhere in the first meg. We will just ignore the copy
++   // and use the ROM directly.
++   
++   // no need to search for the ROM, just ask the card where it is.
++   struct resource *r = &dev->resource[PCI_ROM_RESOURCE];
++   
++   // assign the ROM an address if it doesn't have one
++   if (r->start == 0)
++      pci_assign_resource(dev, PCI_ROM_RESOURCE);
++   
++   // enable if needed
++   if (!(r->flags & PCI_ROM_ADDRESS_ENABLE))
++      pci_write_config_dword(dev, dev->rom_base_reg, r->start | PCI_ROM_ADDRESS_ENABLE);
++   
++   unsigned char *addr = ioremap(r->start, r->end - r->start + 1);
++   
++   // Very simple test to make sure it appeared
++   if (addr && (*addr != 0x55)) {
++      printk("aty128fb: Invalid ROM signature %x\n", *addr);
++      iounmap(addr);
++      return NULL;
+    }
+-   return NULL;
++   return (void *)addr;
+ }
+ 
++static void __init aty128_unmap_ROM(struct pci_dev *dev, void * rom)
++{
++   iounmap(rom);
++   
++   // leave it disabled and unassigned
++   struct resource *r = &dev->resource[PCI_ROM_RESOURCE];
++   r->flags &= !PCI_ROM_ADDRESS_ENABLE;
++   r->end -= r->start;
++   r->start = 0;
++   pci_write_config_dword(dev, dev->rom_base_reg, 0);
++   
++}
+ 
+ static void __init
+-aty128_get_pllinfo(struct aty128fb_par *par, char *bios_seg)
++aty128_get_pllinfo(struct aty128fb_par *par, void *bios)
+ {
+    void *bios_header;
+    void *header_ptr;
+    u16 bios_header_offset, pll_info_offset;
+    PLL_BLOCK pll;
+ 
+-   bios_header = bios_seg + 0x48L;
++   bios_header = (char *)bios + 0x48L;
+    header_ptr  = bios_header;
+ 
+    bios_header_offset = readw(header_ptr);
+-   bios_header = bios_seg + bios_header_offset;
++   bios_header = (char *)bios + bios_header_offset;
+    bios_header += 0x30;
+ 
+    header_ptr = bios_header;
+    pll_info_offset = readw(header_ptr);
+-   header_ptr = bios_seg + pll_info_offset;
++   header_ptr = (char *)bios + pll_info_offset;
+ 
+    memcpy_fromio(&pll, header_ptr, 50);
+ 
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/cfbcopyarea.c fbdev-2.5/drivers/video/cfbcopyarea.c
+--- linus-2.5/drivers/video/cfbcopyarea.c   Wed Feb 12 09:12:08 2003
++++ fbdev-2.5/drivers/video/cfbcopyarea.c   Wed Feb 19 17:18:08 2003
+@@ -342,8 +342,10 @@
+    }
+ }
+ 
+-void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area)
++void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
+ {
++   u32 dx = area->dx, dy = area->dy, sx = area->sx, sy = area->sy;
++   u32 height = area->height, width = area->width;
+    int x2, y2, old_dx, old_dy, vxres, vyres;
+    unsigned long next_line = p->fix.line_length;
+    int dst_idx = 0, src_idx = 0, rev_copy = 0;
+@@ -370,40 +372,40 @@
+     */
+    x2 = area->dx + area->width;
+    y2 = area->dy + area->height;
+-   area->dx = area->dx > 0 ? area->dx : 0;
+-   area->dy = area->dy > 0 ? area->dy : 0;
++   dx = area->dx > 0 ? area->dx : 0;
++   dy = area->dy > 0 ? area->dy : 0;
+    x2 = x2 < vxres ? x2 : vxres;
+    y2 = y2 < vyres ? y2 : vyres;
+-   area->width = x2 - area->dx;
+-   area->height = y2 - area->dy;
++   width = x2 - dx;
++   height = y2 - dy;
+ 
+    /* update sx1,sy1 */
+-   area->sx += (area->dx - old_dx);
+-   area->sy += (area->dy - old_dy);
++   sx += (dx - old_dx);
++   sy += (dy - old_dy);
+ 
+    /* the source must be completely inside the virtual screen */
+-   if (area->sx < 0 || area->sy < 0 ||
+-       (area->sx + area->width) > vxres ||
+-       (area->sy + area->height) > vyres)
++   if (sx < 0 || sy < 0 ||
++       (sx + width) > vxres ||
++       (sy + height) > vyres)
+       return;
+ 
+-   if ((area->dy == area->sy && area->dx > area->sx) ||   
+-       (area->dy > area->sy)) { 
+-      area->dy += area->height;
+-      area->sy += area->height;
++   if ((dy == sy && dx > sx) ||   
++       (dy > sy)) { 
++      dy += height;
++      sy += height;
+       rev_copy = 1;
+    }
+ 
+    dst = src = (unsigned long *)((unsigned long)p->screen_base & 
+                   ~(BYTES_PER_LONG-1));
+    dst_idx = src_idx = (unsigned long)p->screen_base & (BYTES_PER_LONG-1);
+-   dst_idx += area->dy*next_line*8 + area->dx*p->var.bits_per_pixel;
+-   src_idx += area->sy*next_line*8 + area->sx*p->var.bits_per_pixel;
++   dst_idx += dy*next_line*8 + dx*p->var.bits_per_pixel;
++   src_idx += sy*next_line*8 + sx*p->var.bits_per_pixel;
+    
+    if (p->fbops->fb_sync)
+       p->fbops->fb_sync(p);
+    if (rev_copy) {
+-      while (area->height--) {
++      while (height--) {
+          dst_idx -= next_line*8;
+          src_idx -= next_line*8;
+          dst += dst_idx >> SHIFT_PER_LONG;
+@@ -412,17 +414,17 @@
+          src_idx &= (BYTES_PER_LONG-1);
+          bitcpy_rev((unsigned long*)dst, dst_idx, 
+                (unsigned long *)src, src_idx, 
+-               area->width*p->var.bits_per_pixel);
++               width*p->var.bits_per_pixel);
+       }   
+    } else {
+-      while (area->height--) {
++      while (height--) {
+          dst += dst_idx >> SHIFT_PER_LONG;
+          dst_idx &= (BYTES_PER_LONG-1);
+          src += src_idx >> SHIFT_PER_LONG;
+          src_idx &= (BYTES_PER_LONG-1);
+          bitcpy((unsigned long*)dst, dst_idx, 
+                 (unsigned long *)src, src_idx, 
+-                area->width*p->var.bits_per_pixel);
++                width*p->var.bits_per_pixel);
+          dst_idx += next_line*8;
+          src_idx += next_line*8;
+       }   
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/cfbfillrect.c fbdev-2.5/drivers/video/cfbfillrect.c
+--- linus-2.5/drivers/video/cfbfillrect.c   Wed Feb 12 09:12:08 2003
++++ fbdev-2.5/drivers/video/cfbfillrect.c   Wed Feb 19 17:18:08 2003
+@@ -359,13 +359,13 @@
+    }
+ }
+ 
+-void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect)
++void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
+ {
+-   unsigned long height, fg;
++   u32 bpp = p->var.bits_per_pixel;
+    unsigned long x2, y2, vxres, vyres;
++   unsigned long height, width, fg;
+    unsigned long *dst;
+    int dst_idx, left;
+-   u32 bpp = p->var.bits_per_pixel;
+ 
+    /* We want rotation but lack hardware to do it for us. */
+    if (!p->fbops->fb_rotate && p->var.rotate) {
+@@ -385,7 +385,7 @@
+    y2 = rect->dy + rect->height;
+    x2 = x2 < vxres ? x2 : vxres;
+    y2 = y2 < vyres ? y2 : vyres;
+-   rect->width = x2 - rect->dx;
++   width = x2 - rect->dx;
+    height = y2 - rect->dy;
+    
+    if (p->fix.visual == FB_VISUAL_TRUECOLOR ||
+@@ -419,7 +419,7 @@
+       while (height--) {
+          dst += dst_idx >> SHIFT_PER_LONG;
+          dst_idx &= (BITS_PER_LONG-1);
+-         fill_op32(dst, dst_idx, pat, rect->width*bpp);
++         fill_op32(dst, dst_idx, pat, width*bpp);
+          dst_idx += p->fix.line_length*8;
+       }
+    } else {
+@@ -443,7 +443,7 @@
+          dst += dst_idx >> SHIFT_PER_LONG;
+          dst_idx &= (BITS_PER_LONG-1);
+          fill_op(dst, dst_idx, pat, left, right, 
+-            rect->width*bpp);
++            width*bpp);
+          r = (p->fix.line_length*8) % bpp;
+          pat = pat << (bpp-r) | pat >> r;
+          dst_idx += p->fix.line_length*8;
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/cfbimgblt.c fbdev-2.5/drivers/video/cfbimgblt.c
+--- linus-2.5/drivers/video/cfbimgblt.c   Wed Feb 12 09:12:08 2003
++++ fbdev-2.5/drivers/video/cfbimgblt.c   Wed Feb 19 17:18:08 2003
+@@ -73,28 +73,39 @@
+    0x00000000, 0xffffffff
+ };
+ 
+-#if BITS_PER_LONG == 32
+-#define FB_WRITEL fb_writel
+-#define FB_READL  fb_readl
+-#else
+-#define FB_WRITEL fb_writeq
+-#define FB_READL  fb_readq
+-#endif 
+-
+ #if defined (__BIG_ENDIAN)
+ #define LEFT_POS(bpp)          (BITS_PER_LONG - bpp)
+-#define NEXT_POS(pos, bpp)     ((pos) -= (bpp))
+ #define SHIFT_HIGH(val, bits)  ((val) >> (bits))
+ #define SHIFT_LOW(val, bits)   ((val) << (bits))
+ #else
+ #define LEFT_POS(bpp)          (0)
+-#define NEXT_POS(pos, bpp)     ((pos) += (bpp))
+ #define SHIFT_HIGH(val, bits)  ((val) << (bits))
+ #define SHIFT_LOW(val, bits)   ((val) >> (bits))
+ #endif
+ 
+-static inline void color_imageblit(struct fb_image *image, struct fb_info *p, 
+-               u8 *dst1, unsigned long start_index,
++#if BITS_PER_LONG == 32
++#define FB_WRITEL   fb_writel
++#define FB_READL   fb_readl
++#define INIT_FASTPATH   {}
++#define FASTPATH   fb_writel((end_mask & eorx)^bgx, dst++)
++#else
++#define FB_WRITEL   fb_writeq
++#define FB_READL   fb_readq
++#define INIT_FASTPATH   unsigned long val = 0, bpl = 0
++#define FASTPATH {               \
++   val |= SHIFT_HIGH((end_mask & eorx)^bgx, bpl);   \
++   bpl += 32;               \
++   bpl &= BITS_PER_LONG - 1;         \
++   if (!bpl) {               \
++      FB_WRITEL(val, dst++);         \
++      val = 0;            \
++   }                  \
++}
++#endif
++
++static inline void color_imageblit(const struct fb_image *image, 
++               struct fb_info *p, u8 *dst1, 
++               unsigned long start_index,
+                unsigned long pitch_index)
+ {
+    /* Draw the penguin */
+@@ -102,14 +113,13 @@
+    int i, n, bpp = p->var.bits_per_pixel;
+    unsigned long null_bits = BITS_PER_LONG - bpp;
+    u32 *palette = (u32 *) p->pseudo_palette;
+-   u8 *src = image->data;
++   u8 *src = (u8 *) image->data;
+ 
+    dst2 = (unsigned long *) dst1;
+    for (i = image->height; i--; ) {
+-      n = image->width;
+       dst = (unsigned long *) dst1;
+-      shift = 0;
+-      val = 0;
++      n = image->width;
++      shift = val = 0;
+       
+       if (start_index) {
+          unsigned long start_mask = ~(SHIFT_HIGH(~0UL,
+@@ -152,8 +162,9 @@
+    }
+ }
+ 
+-static inline void slow_imageblit(struct fb_image *image, struct fb_info *p, 
+-              u8 *dst1, unsigned long fgcolor,
++static inline void slow_imageblit(const struct fb_image *image, 
++              struct fb_info *p, u8 *dst1, 
++              unsigned long fgcolor,
+               unsigned long bgcolor, 
+               unsigned long start_index,
+               unsigned long pitch_index)
+@@ -162,17 +173,17 @@
+    unsigned long *dst, *dst2, val, pitch = p->fix.line_length;
+    unsigned long null_bits = BITS_PER_LONG - bpp;
+    unsigned long spitch = (image->width+7)/8;
+-   u8 *src = image->data, *s;
++   const char *src = image->data, *s;
+    unsigned long i, j, l;
+    
+    dst2 = (unsigned long *) dst1;
+ 
+    for (i = image->height; i--; ) {
+-      shift = val = 0;
+-      l = 8;
+-      j = image->width;
+       dst = (unsigned long *) dst1;
++      j = image->width;
++      shift = val = 0;
+       s = src;
++      l = 8;
+ 
+       /* write leading bits */
+       if (start_index) {
+@@ -228,14 +239,14 @@
+  *           fix->line_legth is divisible by 4;
+  *           beginning and end of a scanline is dword aligned
+  */
+-static inline void fast_imageblit(struct fb_image *image, struct fb_info *p, 
+-              u8 *dst1, unsigned long fgcolor, 
+-              unsigned long bgcolor) 
++static inline void fast_imageblit(const struct fb_image *image, 
++              struct fb_info *p, u8 *dst1, 
++              u32 fgcolor, u32 bgcolor) 
+ {
+-   unsigned long fgx = fgcolor, bgx = bgcolor, bpp = p->var.bits_per_pixel;
+-   unsigned long ppw = BITS_PER_LONG/bpp, spitch = (image->width + 7)/8;
+-   unsigned long bit_mask, end_mask, eorx, shift;
+-   char *s = image->data, *src;
++   u32 fgx = fgcolor, bgx = bgcolor, bpp = p->var.bits_per_pixel;
++   u32 ppw = BITS_PER_LONG/bpp, spitch = (image->width + 7)/8;
++   u32 bit_mask, end_mask, eorx, shift;
++   const char *s = image->data, *src;
+    unsigned long *dst;
+    u32 *tab = NULL;
+    int i, j, k;
+@@ -265,11 +276,12 @@
+ 
+    for (i = image->height; i--; ) {
+       dst = (unsigned long *) dst1, shift = 8; src = s;
+-      
++      INIT_FASTPATH;
++   
+       for (j = k; j--; ) {
+          shift -= ppw;
+          end_mask = tab[(*src >> shift) & bit_mask];
+-         FB_WRITEL((end_mask & eorx)^bgx, dst++);
++         FASTPATH;
+          if (!shift) { shift = 8; src++; }      
+       }
+       dst1 += p->fix.line_length;
+@@ -277,10 +289,12 @@
+    }
+ }   
+    
+-void cfb_imageblit(struct fb_info *p, struct fb_image *image)
++void cfb_imageblit(struct fb_info *p, const struct fb_image *image)
+ {
+    unsigned long fgcolor, bgcolor, start_index, bitstart, pitch_index = 0;
+    unsigned long bpl = sizeof(unsigned long), bpp = p->var.bits_per_pixel;
++   u32 width = image->width, height = image->height; 
++   u32 dx = image->dx, dy = image->dy;
+    int x2, y2, vxres, vyres;
+    u8 *dst1;
+ 
+@@ -296,14 +310,14 @@
+ 
+    x2 = image->dx + image->width;
+    y2 = image->dy + image->height;
+-   image->dx = image->dx > 0 ? image->dx : 0;
+-   image->dy = image->dy > 0 ? image->dy : 0;
++   dx = image->dx > 0 ? image->dx : 0;
++   dy = image->dy > 0 ? image->dy : 0;
+    x2 = x2 < vxres ? x2 : vxres;
+    y2 = y2 < vyres ? y2 : vyres;
+-   image->width  = x2 - image->dx;
+-   image->height = y2 - image->dy;
++   width  = x2 - dx;
++   height = y2 - dy;
+ 
+-   bitstart = (image->dy * p->fix.line_length * 8) + (image->dx * bpp);
++   bitstart = (dy * p->fix.line_length * 8) + (dx * bpp);
+    start_index = bitstart & (BITS_PER_LONG - 1);
+    pitch_index = (p->fix.line_length & (bpl - 1)) * 8;
+ 
+@@ -314,7 +328,7 @@
+    if (p->fbops->fb_sync)
+       p->fbops->fb_sync(p);
+ 
+-   if (image->depth == 1) {
++   if (image->depth == 0) {
+       if (p->fix.visual == FB_VISUAL_TRUECOLOR ||
+           p->fix.visual == FB_VISUAL_DIRECTCOLOR) {
+          fgcolor = ((u32*)(p->pseudo_palette))[image->fg_color];
+@@ -325,13 +339,13 @@
+       }   
+       
+       if (BITS_PER_LONG % bpp == 0 && !start_index && !pitch_index && 
+-          ((image->width & (BITS_PER_LONG/bpp-1)) == 0) &&
++          ((width & (BITS_PER_LONG/bpp-1)) == 0) &&
+           bpp >= 8 && bpp <= 32)          
+          fast_imageblit(image, p, dst1, fgcolor, bgcolor);
+       else 
+-         slow_imageblit(image, p, dst1, fgcolor, bgcolor, start_index, pitch_index);
+-   }
+-   else if (image->depth == bpp) 
++         slow_imageblit(image, p, dst1, fgcolor, bgcolor,
++               start_index, pitch_index);
++   } else if (image->depth == bpp) 
+       color_imageblit(image, p, dst1, start_index, pitch_index);
+ }
+ 
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/console/fbcon.c fbdev-2.5/drivers/video/console/fbcon.c
+--- linus-2.5/drivers/video/console/fbcon.c   Wed Feb 12 09:12:10 2003
++++ fbdev-2.5/drivers/video/console/fbcon.c   Wed Feb 19 17:18:11 2003
+@@ -104,12 +104,9 @@
+ #  define DPRINTK(fmt, args...)
+ #endif
+ 
+-#define LOGO_H         80
+-#define LOGO_W         80
+-#define LOGO_LINE   (LOGO_W/8)
+-
+ struct display fb_display[MAX_NR_CONSOLES];
+ char con2fb_map[MAX_NR_CONSOLES];
++static int logo_height;
+ static int logo_lines;
+ static int logo_shown = -1;
+ /* Software scrollback */
+@@ -185,8 +182,6 @@
+ /*
+  *  Internal routines
+  */
+-
+-static int fbcon_changevar(int con);
+ static void fbcon_set_display(int con, int init, int logo);
+ static __inline__ int real_y(struct display *p, int ypos);
+ static void fbcon_vbl_handler(int irq, void *dummy, struct pt_regs *fp);
+@@ -283,19 +278,6 @@
+ 
+ __setup("fbcon=", fb_console_setup);
+ 
+-void gen_set_disp(int con, struct fb_info *info)
+-{
+-   struct display *display = fb_display + con;
+-
+-   display->can_soft_blank = info->fbops->fb_blank ? 1 : 0;
+-   if (info->var.accel_flags)
+-      display->scrollmode = SCROLL_YNOMOVE;
+-   else
+-      display->scrollmode = SCROLL_YREDRAW;
+-   fbcon_changevar(con);
+-   return;
+-}
+-
+ /**
+  *   set_con2fb_map - map console to frame buffer device
+  *   @unit: virtual console number to map
+@@ -303,43 +285,14 @@
+  *
+  *   Maps a virtual console @unit to a frame buffer device
+  *   @newidx.
+- *
+  */
+-
+ void set_con2fb_map(int unit, int newidx)
+ {
+-   int oldidx = con2fb_map[unit];
+-   struct fb_info *oldfb, *newfb;
+-   struct vc_data *vc;
+-   char *fontdata;
+-   int userfont;
++   struct vc_data *vc = vc_cons[unit].d;
+ 
+-   if (newidx != con2fb_map[unit]) {
+-      oldfb = registered_fb[oldidx];
+-      newfb = registered_fb[newidx];
+-      if (!try_module_get(newfb->fbops->owner))
+-         return;
+-      if (newfb->fbops->fb_open
+-          && newfb->fbops->fb_open(newfb, 0)) {
+-         module_put(newfb->fbops->owner);
+-         return;
+-      }
+-      if (oldfb->fbops->fb_release)
+-         oldfb->fbops->fb_release(oldfb, 0);
+-      module_put(oldfb->fbops->owner);
+-      vc = fb_display[unit].conp;
+-      fontdata = fb_display[unit].fontdata;
+-      userfont = fb_display[unit].userfont;
+-      con2fb_map[unit] = newidx;
+-
+-      fb_display[unit].conp = vc;
+-      fb_display[unit].fontdata = fontdata;
+-      fb_display[unit].userfont = userfont;
+-      fb_display[unit].fb_info = newfb;
+-      gen_set_disp(unit, newfb);
+-      /* tell console var has changed */
+-      fbcon_changevar(unit);
+-   }
++   con2fb_map[unit] = newidx;
++   fbcon_is_default = (vc->vc_sw == &fb_con) ? 1 : 0;
++   take_over_console(&fb_con, unit, unit, fbcon_is_default);
+ }
+ 
+ /*
+@@ -395,11 +348,11 @@
+    image.dx = xx * vc->vc_font.width;
+    image.dy = yy * vc->vc_font.height;
+    image.height = vc->vc_font.height;
+-   image.depth = 1;
++   image.depth = 0;
+ 
+    if (!(vc->vc_font.width & 7)) {
+       unsigned int pitch, cnt, i, j, k;
+-      unsigned int maxcnt = FB_PIXMAPSIZE/(vc->vc_font.height * width);
++      unsigned int maxcnt = FB_PIXMAPSIZE/cellsize;
+       char *src, *dst, *dst0;
+ 
+       image.data = pixmap;
+@@ -437,8 +390,6 @@
+          image.dx += vc->vc_font.width;
+       }   
+    }
+-   if (info->fbops->fb_sync)
+-      info->fbops->fb_sync(info);
+ }
+ 
+ void accel_clear_margins(struct vc_data *vc, struct display *p,
+@@ -560,7 +511,7 @@
+    cursor.image.height = height;
+    cursor.image.dx = xx * width;
+    cursor.image.dy = yy * height;
+-   cursor.image.depth = 1;
++   cursor.image.depth = 0;
+    cursor.image.data = image;
+    cursor.image.bg_color = bgcolor;
+    cursor.image.fg_color = fgcolor;
+@@ -739,14 +690,17 @@
+    /* on which frame buffer will we open this console? */
+    info = registered_fb[(int) con2fb_map[unit]];
+ 
+-   gen_set_disp(unit, info);
++   fb_display[unit].can_soft_blank = info->fbops->fb_blank ? 1 : 0;
++   if (info->var.accel_flags)
++      fb_display[unit].scrollmode = SCROLL_YNOMOVE;
++   else
++      fb_display[unit].scrollmode = SCROLL_YREDRAW;
++
+    fb_display[unit].conp = vc;
+    fb_display[unit].fb_info = info;
+-
+    fbcon_set_display(unit, init, !init);
+ }
+ 
+-
+ static void fbcon_deinit(struct vc_data *vc)
+ {
+    int unit = vc->vc_num;
+@@ -758,119 +712,6 @@
+ 
+ #define fontwidthvalid(p,w) ((p)->fontwidthmask & FONTWIDTH(w))
+ 
+-static int fbcon_changevar(int con)
+-{
+-   if (fb_display[con].conp) {
+-      struct display *p = &fb_display[con];
+-      struct fb_info *info = p->fb_info;
+-      struct vc_data *vc = p->conp;
+-      int nr_rows, nr_cols;
+-      int old_rows, old_cols;
+-      unsigned short *save = NULL, *q;
+-      int i, charcnt = 256;
+-      struct font_desc *font;
+-
+-      info->var.xoffset = info->var.yoffset = p->yscroll = 0;   /* reset wrap/pan */
+-
+-      for (i = 0; i < MAX_NR_CONSOLES; i++)
+-         if (i != con && fb_display[i].fb_info == info &&
+-                fb_display[i].conp && fb_display[i].fontdata)
+-               break;
+-
+-      fbcon_free_font(p);
+-      if (i < MAX_NR_CONSOLES) {
+-         struct display *q = &fb_display[i];
+-         struct vc_data *tmp = vc_cons[i].d;
+-         
+-         if (fontwidthvalid(p, vc->vc_font.width)) {
+-            /* If we are not the first console on this
+-               fb, copy the font from that console */
+-            tmp->vc_font.width = vc->vc_font.width;
+-            tmp->vc_font.height = vc->vc_font.height;
+-            p->fontdata = q->fontdata;
+-            p->userfont = q->userfont;
+-            if (p->userfont) {
+-               REFCOUNT(p->fontdata)++;
+-               charcnt = FNTCHARCNT(p->fontdata);
+-            }
+-            con_copy_unimap(con, i);
+-         }
+-      }
+-
+-      if (!p->fontdata) {
+-         if (!p->fontname[0] || !(font = find_font(p->fontname)))
+-                font = get_default_font(info->var.xres,
+-                           info->var.yres);
+-         vc->vc_font.width = font->width;
+-         vc->vc_font.height = font->height;
+-         p->fontdata = font->data;
+-      }
+-
+-      updatescrollmode(p, vc);
+-
+-      old_cols = vc->vc_cols;
+-      old_rows = vc->vc_rows;
+-
+-      nr_cols = info->var.xres / vc->vc_font.width;
+-      nr_rows = info->var.yres / vc->vc_font.height;
+-
+-      /*
+-        *  ++guenther: console.c:vc_allocate() relies on initializing
+-        *  vc_{cols,rows}, but we must not set those if we are only
+-        *  resizing the console.
+-        */
+-      p->vrows = info->var.yres_virtual / vc->vc_font.height;
+-      if ((info->var.yres % vc->vc_font.height) &&
+-              (info->var.yres_virtual % vc->vc_font.height <
+-                info->var.yres % vc->vc_font.height))
+-         p->vrows--;
+-      vc->vc_can_do_color = info->var.bits_per_pixel != 1;
+-      vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
+-      if (charcnt == 256) {
+-         vc->vc_hi_font_mask = 0;
+-         p->fgshift = 8;
+-         p->bgshift = 12;
+-         p->charmask = 0xff;
+-      } else {
+-         vc->vc_hi_font_mask = 0x100;
+-         if (vc->vc_can_do_color)
+-            vc->vc_complement_mask <<= 1;
+-         p->fgshift = 9;
+-         p->bgshift = 13;
+-         p->charmask = 0x1ff;
+-      }
+-
+-      if (vc->vc_cols != nr_cols || vc->vc_rows != nr_rows)
+-         vc_resize(con, nr_cols, nr_rows);
+-      else if (CON_IS_VISIBLE(vc) &&
+-          vt_cons[vc->vc_num]->vc_mode == KD_TEXT) {
+-         accel_clear_margins(vc, p, 0);
+-         update_screen(con);
+-      }
+-      if (save) {
+-         q = (unsigned short *) (vc->vc_origin +
+-                  vc->vc_size_row *
+-                  old_rows);
+-         scr_memcpyw(q, save, logo_lines * nr_cols * 2);
+-         vc->vc_y += logo_lines;
+-         vc->vc_pos += logo_lines * vc->vc_size_row;
+-         kfree(save);
+-      }
+-
+-      if (con == fg_console && softback_buf) {
+-         int l = fbcon_softback_size / vc->vc_size_row;
+-         if (l > 5)
+-            softback_end = softback_buf + l * vc->vc_size_row;
+-         else {
+-            /* Smaller scrollback makes no sense, and 0 would screw
+-               the operation totally */
+-            softback_top = 0;
+-         }
+-      }
+-   }   
+-   return 0;
+-}
+-
+ static __inline__ void updatescrollmode(struct display *p, struct vc_data *vc)
+ {
+    struct fb_info *info = p->fb_info;
+@@ -961,7 +802,9 @@
+       int cnt;
+       int step;
+ 
+-      logo_lines = (LOGO_H + vc->vc_font.height - 1) / vc->vc_font.height;
++      logo_height = fb_prepare_logo(info);
++      logo_lines = (logo_height + vc->vc_font.height - 1) /
++              vc->vc_font.height;
+       q = (unsigned short *) (vc->vc_origin +
+                vc->vc_size_row * old_rows);
+       step = logo_lines * old_cols;
+@@ -1247,7 +1090,6 @@
+       cursor_on = 1;
+       break;
+    }
+-
+ }
+ 
+ static void fbcon_vbl_handler(int irq, void *dummy, struct pt_regs *fp)
+@@ -1522,98 +1364,6 @@
+    }
+ }
+ 
+-/**
+- *   fbcon_redraw_clear - clear area of the screen
+- *   @vc: stucture pointing to current active virtual console
+- *   @p: display structure
+- *   @sy: starting Y coordinate
+- *   @sx: starting X coordinate
+- *   @height: height of area to clear
+- *   @width: width of area to clear
+- *
+- *   Clears a specified area of the screen.  All dimensions are in
+- *   pixels.
+- *
+- */
+-
+-void fbcon_redraw_clear(struct vc_data *vc, struct display *p, int sy,
+-         int sx, int height, int width)
+-{
+-   int x, y;
+-   for (y = 0; y < height; y++)
+-      for (x = 0; x < width; x++)
+-         fbcon_putc(vc, ' ', sy + y, sx + x);
+-}
+-
+-
+-/**
+- *   fbcon_redraw_bmove - copy area of screen to another area
+- *   @p: display structure
+- *   @sy: origin Y coordinate
+- *   @sx: origin X coordinate
+- *   @dy: destination Y coordinate
+- *   @dx: destination X coordinate
+- *   @h: height of area to copy
+- *   @w: width of area to copy
+- *
+- *   Copies an area of the screen to another area of the same screen.
+- *   All dimensions are in pixels.
+- *
+- *   Note that this function cannot be used together with ypan or
+- *   ywrap.
+- *
+- */
+-
+-void fbcon_redraw_bmove(struct vc_data *vc, struct display *p, int sy, int sx, int dy, int dx,
+-         int h, int w)
+-{
+-   if (sy != dy)
+-      panic("fbcon_redraw_bmove width sy != dy");
+-   /* h will be always 1, but it does not matter if we are more generic */
+-
+-   while (h-- > 0) {
+-      unsigned short *d = (unsigned short *)
+-          (vc->vc_origin + vc->vc_size_row * dy + dx * 2);
+-      unsigned short *s = d + (dx - sx);
+-      unsigned short *start = d;
+-      unsigned short *ls = d;
+-      unsigned short *le = d + w;
+-      unsigned short c;
+-      int x = dx;
+-      unsigned short attr = 1;
+-
+-      do {
+-         c = scr_readw(d);
+-         if (attr != (c & 0xff00)) {
+-            attr = c & 0xff00;
+-            if (d > start) {
+-               accel_putcs(vc, p, start,
+-                      d - start, dy, x);
+-               x += d - start;
+-               start = d;
+-            }
+-         }
+-         if (s >= ls && s < le && c == scr_readw(s)) {
+-            if (d > start) {
+-               accel_putcs(vc, p, start,
+-                      d - start, dy, x);
+-               x += d - start + 1;
+-               start = d + 1;
+-            } else {
+-               x++;
+-               start++;
+-            }
+-         }
+-         s++;
+-         d++;
+-      } while (d < le);
+-      if (d > start)
+-         accel_putcs(vc, p, start, d - start, dy, x);
+-      sy++;
+-      dy++;
+-   }
+-}
+-
+ static inline void fbcon_softback_note(struct vc_data *vc, int t,
+                    int count)
+ {
+@@ -1869,24 +1619,33 @@
+           width);
+ }
+ 
+-
+ static int fbcon_resize(struct vc_data *vc, unsigned int width, 
+          unsigned int height)
+ {
+    struct display *p = &fb_display[vc->vc_num];
+    struct fb_info *info = p->fb_info;
+    struct fb_var_screeninfo var = info->var;
+-   int err;
+-
+-   var.xres = width * vc->vc_font.width;
+-   var.yres = height * vc->vc_font.height;
+-   var.activate = FB_ACTIVATE_NOW;
+-
+-   err = fb_set_var(&var, info);
+-   return  (err || var.xres != info->var.xres ||
+-       var.yres != info->var.yres) ?
+-      -EINVAL : 0;
+-     
++   int err; int x_diff, y_diff;
++   int fw = vc->vc_font.width;
++   int fh = vc->vc_font.height;
++
++   var.xres = width * fw;
++   var.yres = height * fh;
++   x_diff = info->var.xres - var.xres;
++   y_diff = info->var.yres - var.yres;
++   if (x_diff < 0 || x_diff > fw ||
++      (y_diff < 0 || y_diff > fh)) {
++      var.activate = FB_ACTIVATE_TEST;
++      err = fb_set_var(&var, info);
++      if (err || width != var.xres/fw ||
++          height != var.yres/fh)
++         return -EINVAL;
++      DPRINTK("resize now %ix%i\n", var.xres, var.yres);
++      var.activate = FB_ACTIVATE_NOW;
++      fb_set_var(&var, info);
++      p->vrows = info->var.yres_virtual/fh;
++   }
++   return 0;
+ }
+ 
+ static int fbcon_switch(struct vc_data *vc)
+@@ -1946,7 +1705,8 @@
+       accel_clear_margins(vc, p, 0);
+    if (logo_shown == -2) {
+       logo_shown = fg_console;
+-      fb_show_logo(info);   /* This is protected above by initmem_freed */
++      /* This is protected above by initmem_freed */
++      fb_show_logo(info);
+       update_region(fg_console,
+                vc->vc_origin + vc->vc_size_row * vc->vc_top,
+                vc->vc_size_row * (vc->vc_bottom -
+@@ -2379,8 +2139,9 @@
+ static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos,
+              int *px, int *py)
+ {
+-   int x, y;
+    unsigned long ret;
++   int x, y;
++
+    if (pos >= vc->vc_origin && pos < vc->vc_scr_end) {
+       unsigned long offset = (pos - vc->vc_origin) / 2;
+ 
+@@ -2581,8 +2342,6 @@
+  */
+ 
+ EXPORT_SYMBOL(fb_display);
+-EXPORT_SYMBOL(fbcon_redraw_bmove);
+-EXPORT_SYMBOL(fbcon_redraw_clear);
+ EXPORT_SYMBOL(fb_con);
+ 
+ MODULE_LICENSE("GPL");
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/console/fbcon.h fbdev-2.5/drivers/video/console/fbcon.h
+--- linus-2.5/drivers/video/console/fbcon.h   Wed Feb 12 09:12:10 2003
++++ fbdev-2.5/drivers/video/console/fbcon.h   Wed Feb 19 17:18:11 2003
+@@ -119,7 +119,6 @@
+ /* Namespace consistency */
+ #define SCROLL_YNOPARTIAL   __SCROLL_YNOPARTIAL
+ 
+-extern void fbcon_redraw_clear(struct vc_data *, struct display *, int, int, int, int);
+-extern void fbcon_redraw_bmove(struct vc_data *, struct display *, int, int, int, int, int, int);
++extern int fb_console_init(void);
+ 
+ #endif /* _VIDEO_FBCON_H */
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/console/newport_con.c fbdev-2.5/drivers/video/console/newport_con.c
+--- linus-2.5/drivers/video/console/newport_con.c   Wed Feb 12 09:12:10 2003
++++ fbdev-2.5/drivers/video/console/newport_con.c   Wed Feb 19 17:18:11 2003
+@@ -26,13 +26,10 @@
+ #include <asm/page.h>
+ #include <asm/pgtable.h>
+ #include <video/newport.h>
+-#define INCLUDE_LINUX_LOGO_DATA
+-#include <asm/linux_logo.h>
+ 
++#include <linux/linux_logo.h>
+ #include <linux/font.h>
+ 
+-#define LOGO_W      80
+-#define LOGO_H      80
+ 
+ extern struct font_desc font_vga_8x16;
+ 
+@@ -98,30 +95,11 @@
+    }
+ }
+ 
+-static inline void newport_show_logo(void)
+-{
+-   unsigned long i;
+-
+-   for (i = 0; i < LINUX_LOGO_COLORS; i++) {
+-      newport_bfwait();
+-      newport_cmap_setaddr(npregs, i + 0x20);
+-      newport_cmap_setrgb(npregs,
+-                linux_logo_red[i],
+-                linux_logo_green[i],
+-                linux_logo_blue[i]);
+-   }
+-
+-   newport_wait();
+-   npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
+-             NPORT_DMODE0_CHOST);
+-
+-   npregs->set.xystarti = ((newport_xsize - LOGO_W) << 16) | (0);
+-   npregs->set.xyendi = ((newport_xsize - 1) << 16);
+-   newport_wait();
+-
+-   for (i = 0; i < LOGO_W * LOGO_H; i++)
+-      npregs->go.hostrw0 = linux_logo[i] << 24;
+-}
++#ifdef CONFIG_LOGO_SGI_CLUT224
++static void newport_show_logo(void);
++#else
++#define newport_show_logo()   do { } while (0)
++#endif
+ 
+ static inline void newport_clear_screen(int xstart, int ystart, int xend,
+                int yend, int ci)
+@@ -743,3 +721,38 @@
+    return 0;
+ }
+ #endif
++
++
++#ifdef CONFIG_LOGO_SGI_CLUT224
++
++#undef __initdata
++#define __initdata
++#include "../logo/logo_sgi_clut224.c"
++
++static void newport_show_logo(void)
++{
++   const struct linux_logo *logo = &logo_sgi_clut224;
++   const unsigned char *clut = logo->clut;
++   const unsigned char *data = logo->data;
++   unsigned long i;
++
++   for (i = 0; i < logo->clutsize; i++) {
++      newport_bfwait();
++      newport_cmap_setaddr(npregs, i + 0x20);
++      newport_cmap_setrgb(npregs, clut[0], clut[1], clut[2]);
++      clut += 3;
++   }
++
++   newport_wait();
++   npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
++             NPORT_DMODE0_CHOST);
++
++   npregs->set.xystarti = ((newport_xsize - logo->width) << 16) | (0);
++   npregs->set.xyendi = ((newport_xsize - 1) << 16);
++   newport_wait();
++
++   for (i = 0; i < logo->width*logo->height; i++)
++      npregs->go.hostrw0 = *data++ << 24;
++}
++#endif /* CONFIG_LOGO_SGI_CLUT224 */
++
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/console/vgacon.c fbdev-2.5/drivers/video/console/vgacon.c
+--- linus-2.5/drivers/video/console/vgacon.c   Wed Feb 12 09:12:10 2003
++++ fbdev-2.5/drivers/video/console/vgacon.c   Wed Feb 19 17:18:11 2003
+@@ -49,7 +49,7 @@
+ #include <linux/spinlock.h>
+ #include <linux/ioport.h>
+ #include <linux/init.h>
+-
++#include <video/vga.h>
+ #include <asm/io.h>
+ 
+ static spinlock_t vga_lock = SPIN_LOCK_UNLOCKED;
+@@ -66,16 +66,6 @@
+  */
+ #undef TRIDENT_GLITCH
+ 
+-#define dac_reg      0x3c8
+-#define dac_val      0x3c9
+-#define attrib_port   0x3c0
+-#define seq_port_reg   0x3c4
+-#define seq_port_val   0x3c5
+-#define gr_port_reg   0x3ce
+-#define gr_port_val   0x3cf
+-#define video_misc_rd   0x3cc
+-#define video_misc_wr   0x3c2
+-
+ /*
+  *  Interface used by the world
+  */
+@@ -87,36 +77,37 @@
+ static int vgacon_switch(struct vc_data *c);
+ static int vgacon_blank(struct vc_data *c, int blank);
+ static int vgacon_font_op(struct vc_data *c, struct console_font_op *op);
+-static int vgacon_set_palette(struct vc_data *c, unsigned char *table);
++static int vgacon_set_palette(struct vc_data *vc, unsigned char *table);
+ static int vgacon_scrolldelta(struct vc_data *c, int lines);
+ static int vgacon_set_origin(struct vc_data *c);
+ static void vgacon_save_screen(struct vc_data *c);
+-static int vgacon_scroll(struct vc_data *c, int t, int b, int dir, int lines);
+-static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity, u8 blink, u8 underline, u8 reverse);
+-static void vgacon_invert_region(struct vc_data *c, u16 *p, int count);
++static int vgacon_scroll(struct vc_data *c, int t, int b, int dir,
++          int lines);
++static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
++             u8 blink, u8 underline, u8 reverse);
++static void vgacon_invert_region(struct vc_data *c, u16 * p, int count);
+ static unsigned long vgacon_uni_pagedir[2];
+ 
+ 
+ /* Description of the hardware situation */
+-static unsigned long   vga_vram_base;      /* Base of video memory */
+-static unsigned long   vga_vram_end;      /* End of video memory */
+-static u16             vga_video_port_reg;   /* Video register select port */
+-static u16             vga_video_port_val;   /* Video register value port */
+-static unsigned int    vga_video_num_columns;   /* Number of text columns */
+-static unsigned int    vga_video_num_lines;   /* Number of text lines */
+-static int          vga_can_do_color = 0;   /* Do we support colors? */
+-static unsigned int    vga_default_font_height;   /* Height of default screen font */
+-static unsigned char   vga_video_type;      /* Card type */
+-static unsigned char   vga_hardscroll_enabled;
+-static unsigned char   vga_hardscroll_user_enable = 1;
+-static unsigned char   vga_font_is_default = 1;
+-static int          vga_vesa_blanked;
+-static int          vga_palette_blanked;
+-static int          vga_is_gfx;
+-static int          vga_512_chars;
+-static int          vga_video_font_height;
+-static unsigned int    vga_rolled_over = 0;
+-
++static unsigned long vga_vram_base;   /* Base of video memory */
++static unsigned long vga_vram_end;   /* End of video memory */
++static u16 vga_video_port_reg;   /* Video register select port */
++static u16 vga_video_port_val;   /* Video register value port */
++static unsigned int vga_video_num_columns;   /* Number of text columns */
++static unsigned int vga_video_num_lines;   /* Number of text lines */
++static int vga_can_do_color = 0;   /* Do we support colors? */
++static unsigned int vga_default_font_height;   /* Height of default screen font */
++static unsigned char vga_video_type;   /* Card type */
++static unsigned char vga_hardscroll_enabled;
++static unsigned char vga_hardscroll_user_enable = 1;
++static unsigned char vga_font_is_default = 1;
++static int vga_vesa_blanked;
++static int vga_palette_blanked;
++static int vga_is_gfx;
++static int vga_512_chars;
++static int vga_video_font_height;
++static unsigned int vga_rolled_over = 0;
+ 
+ static int __init no_scroll(char *str)
+ {
+@@ -147,7 +138,7 @@
+     * ddprintk might set the console position from interrupt
+     * handlers, thus the write has to be IRQ-atomic.
+     */
+-   spin_lock_irqsave(&vga_lock, flags);   
++   spin_lock_irqsave(&vga_lock, flags);
+ 
+ #ifndef SLOW_VGA
+    v1 = reg + (val & 0xff00);
+@@ -157,7 +148,7 @@
+ #else
+    outb_p(reg, vga_video_port_reg);
+    outb_p(val >> 8, vga_video_port_val);
+-   outb_p(reg+1, vga_video_port_reg);
++   outb_p(reg + 1, vga_video_port_reg);
+    outb_p(val & 0xff, vga_video_port_val);
+ #endif
+    spin_unlock_irqrestore(&vga_lock, flags);
+@@ -170,7 +161,7 @@
+    volatile u16 *p;
+ 
+    if (ORIG_VIDEO_ISVGA == VIDEO_TYPE_VLFB) {
+-   no_vga:
++         no_vga:
+ #ifdef CONFIG_DUMMY_CONSOLE
+       conswitchp = &dummy_con;
+       return conswitchp->con_startup();
+@@ -180,63 +171,67 @@
+    }
+ 
+    /* VGA16 modes are not handled by VGACON */
+-   if ((ORIG_VIDEO_MODE == 0x0D) || /* 320x200/4 */
+-       (ORIG_VIDEO_MODE == 0x0E) || /* 640x200/4 */
+-       (ORIG_VIDEO_MODE == 0x10) || /* 640x350/4 */
+-       (ORIG_VIDEO_MODE == 0x12) || /* 640x480/4 */
+-       (ORIG_VIDEO_MODE == 0x6A))   /* 800x600/4, 0x6A is very common */
++   if ((ORIG_VIDEO_MODE == 0x0D) ||   /* 320x200/4 */
++       (ORIG_VIDEO_MODE == 0x0E) ||   /* 640x200/4 */
++       (ORIG_VIDEO_MODE == 0x10) ||   /* 640x350/4 */
++       (ORIG_VIDEO_MODE == 0x12) ||   /* 640x480/4 */
++       (ORIG_VIDEO_MODE == 0x6A))   /* 800x600/4, 0x6A is very common */
+       goto no_vga;
+ 
+    vga_video_num_lines = ORIG_VIDEO_LINES;
+    vga_video_num_columns = ORIG_VIDEO_COLS;
+ 
+-   if (ORIG_VIDEO_MODE == 7)   /* Is this a monochrome display? */
+-   {
++   if (ORIG_VIDEO_MODE == 7) {   /* Is this a monochrome display? */
+       vga_vram_base = 0xb0000;
+-      vga_video_port_reg = 0x3b4;
+-      vga_video_port_val = 0x3b5;
+-      if ((ORIG_VIDEO_EGA_BX & 0xff) != 0x10)
+-      {
+-         static struct resource ega_console_resource = { "ega", 0x3B0, 0x3BF };
++      vga_video_port_reg = VGA_CRT_IM;
++      vga_video_port_val = VGA_CRT_DM;
++      if ((ORIG_VIDEO_EGA_BX & 0xff) != 0x10) {
++         static struct resource ega_console_resource =
++             { "ega", 0x3B0, 0x3BF };
+          vga_video_type = VIDEO_TYPE_EGAM;
+          vga_vram_end = 0xb8000;
+          display_desc = "EGA+";
+-         request_resource(&ioport_resource, &ega_console_resource);
+-      }
+-      else
+-      {
+-         static struct resource mda1_console_resource = { "mda", 0x3B0, 0x3BB };
+-         static struct resource mda2_console_resource = { "mda", 0x3BF, 0x3BF };
++         request_resource(&ioport_resource,
++                &ega_console_resource);
++      } else {
++         static struct resource mda1_console_resource =
++             { "mda", 0x3B0, 0x3BB };
++         static struct resource mda2_console_resource =
++             { "mda", 0x3BF, 0x3BF };
+          vga_video_type = VIDEO_TYPE_MDA;
+          vga_vram_end = 0xb2000;
+          display_desc = "*MDA";
+-         request_resource(&ioport_resource, &mda1_console_resource);
+-         request_resource(&ioport_resource, &mda2_console_resource);
++         request_resource(&ioport_resource,
++                &mda1_console_resource);
++         request_resource(&ioport_resource,
++                &mda2_console_resource);
+          vga_video_font_height = 14;
+       }
+-   }
+-   else            /* If not, it is color. */
+-   {
++   } else {
++      /* If not, it is color. */
+       vga_can_do_color = 1;
+       vga_vram_base = 0xb8000;
+-      vga_video_port_reg = 0x3d4;
+-      vga_video_port_val = 0x3d5;
+-      if ((ORIG_VIDEO_EGA_BX & 0xff) != 0x10)
+-      {
++      vga_video_port_reg = VGA_CRT_IC;
++      vga_video_port_val = VGA_CRT_DC;
++      if ((ORIG_VIDEO_EGA_BX & 0xff) != 0x10) {
+          int i;
+ 
+          vga_vram_end = 0xc0000;
+ 
+          if (!ORIG_VIDEO_ISVGA) {
+-            static struct resource ega_console_resource = { "ega", 0x3C0, 0x3DF };
++            static struct resource ega_console_resource
++                = { "ega", 0x3C0, 0x3DF };
+             vga_video_type = VIDEO_TYPE_EGAC;
+             display_desc = "EGA";
+-            request_resource(&ioport_resource, &ega_console_resource);
++            request_resource(&ioport_resource,
++                   &ega_console_resource);
+          } else {
+-            static struct resource vga_console_resource = { "vga+", 0x3C0, 0x3DF };
++            static struct resource vga_console_resource
++                = { "vga+", 0x3C0, 0x3DF };
+             vga_video_type = VIDEO_TYPE_VGAC;
+             display_desc = "VGA+";
+-            request_resource(&ioport_resource, &vga_console_resource);
++            request_resource(&ioport_resource,
++                   &vga_console_resource);
+ 
+ #ifdef VGA_CAN_DO_64KB
+             /*
+@@ -247,8 +242,8 @@
+              */
+             vga_vram_base = 0xa0000;
+             vga_vram_end = 0xb0000;
+-            outb_p (6, 0x3ce) ;
+-            outb_p (6, 0x3cf) ;
++            outb_p(6, 0x3ce);
++            outb_p(6, 0x3cf);
+ #endif
+ 
+             /*
+@@ -257,31 +252,31 @@
+              * DAC entries.
+              */
+ 
+-            for (i=0; i<16; i++) {
+-               inb_p (0x3da) ;
+-               outb_p (i, 0x3c0) ;
+-               outb_p (i, 0x3c0) ;
++            for (i = 0; i < 16; i++) {
++               inb_p(0x3da);
++               outb_p(i, 0x3c0);
++               outb_p(i, 0x3c0);
+             }
+-            outb_p (0x20, 0x3c0) ;
++            outb_p(0x20, 0x3c0);
+ 
+             /* now set the DAC registers back to their
+              * default values */
+ 
+-            for (i=0; i<16; i++) {
+-               outb_p (color_table[i], 0x3c8) ;
+-               outb_p (default_red[i], 0x3c9) ;
+-               outb_p (default_grn[i], 0x3c9) ;
+-               outb_p (default_blu[i], 0x3c9) ;
++            for (i = 0; i < 16; i++) {
++               outb_p(color_table[i], 0x3c8);
++               outb_p(default_red[i], 0x3c9);
++               outb_p(default_grn[i], 0x3c9);
++               outb_p(default_blu[i], 0x3c9);
+             }
+          }
+-      }
+-      else
+-      {
+-         static struct resource cga_console_resource = { "cga", 0x3D4, 0x3D5 };
++      } else {
++         static struct resource cga_console_resource =
++             { "cga", 0x3D4, 0x3D5 };
+          vga_video_type = VIDEO_TYPE_CGA;
+          vga_vram_end = 0xba000;
+          display_desc = "*CGA";
+-         request_resource(&ioport_resource, &cga_console_resource);
++         request_resource(&ioport_resource,
++                &cga_console_resource);
+          vga_video_font_height = 8;
+       }
+    }
+@@ -290,10 +285,10 @@
+    vga_vram_end = VGA_MAP_MEM(vga_vram_end);
+ 
+    /*
+-    *   Find out if there is a graphics card present.
+-    *   Are there smarter methods around?
++    *      Find out if there is a graphics card present.
++    *      Are there smarter methods around?
+     */
+-   p = (volatile u16 *)vga_vram_base;
++   p = (volatile u16 *) vga_vram_base;
+    saved1 = scr_readw(p);
+    saved2 = scr_readw(p + 1);
+    scr_writew(0xAA55, p);
+@@ -321,7 +316,7 @@
+       vga_video_font_height = ORIG_VIDEO_POINTS;
+       /* This may be suboptimal but is a safe bet - go with it */
+       video_scan_lines =
+-         vga_video_font_height * vga_video_num_lines;
++          vga_video_font_height * vga_video_num_lines;
+    }
+    video_font_height = vga_video_font_height;
+ 
+@@ -331,7 +326,7 @@
+ static void vgacon_init(struct vc_data *c, int init)
+ {
+    unsigned long p;
+-   
++
+    /* We cannot be loaded as a module, therefore init is always 1 */
+    c->vc_can_do_color = vga_can_do_color;
+    c->vc_cols = vga_video_num_columns;
+@@ -349,7 +344,7 @@
+ 
+ static inline void vga_set_mem_top(struct vc_data *c)
+ {
+-   write_vga(12, (c->vc_visible_origin-vga_vram_base)/2);
++   write_vga(12, (c->vc_visible_origin - vga_vram_base) / 2);
+ }
+ 
+ static void vgacon_deinit(struct vc_data *c)
+@@ -364,7 +359,8 @@
+    con_set_default_unimap(c->vc_num);
+ }
+ 
+-static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity, u8 blink, u8 underline, u8 reverse)
++static u8 vgacon_build_attr(struct vc_data *c, u8 color, u8 intensity,
++             u8 blink, u8 underline, u8 reverse)
+ {
+    u8 attr = color;
+ 
+@@ -375,7 +371,9 @@
+          attr = (attr & 0xf0) | c->vc_halfcolor;
+    }
+    if (reverse)
+-      attr = ((attr) & 0x88) | ((((attr) >> 4) | ((attr) << 4)) & 0x77);
++      attr =
++          ((attr) & 0x88) | ((((attr) >> 4) | ((attr) << 4)) &
++                   0x77);
+    if (blink)
+       attr ^= 0x80;
+    if (intensity == 2)
+@@ -389,14 +387,15 @@
+    return attr;
+ }
+ 
+-static void vgacon_invert_region(struct vc_data *c, u16 *p, int count)
++static void vgacon_invert_region(struct vc_data *c, u16 * p, int count)
+ {
+    int col = vga_can_do_color;
+ 
+    while (count--) {
+       u16 a = scr_readw(p);
+       if (col)
+-         a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) | (((a) & 0x0700) << 4);
++         a = ((a) & 0x88ff) | (((a) & 0x7000) >> 4) |
++             (((a) & 0x0700) << 4);
+       else
+          a ^= ((a & 0x0700) == 0x0100) ? 0x7000 : 0x7700;
+       scr_writew(a, p++);
+@@ -410,70 +409,84 @@
+    static int lastfrom, lastto;
+ 
+ #ifdef TRIDENT_GLITCH
+-   if (xpos<16) from--, to--;
++   if (xpos < 16)
++      from--, to--;
+ #endif
+ 
+-   if ((from == lastfrom) && (to == lastto)) return;
+-   lastfrom = from; lastto = to;
++   if ((from == lastfrom) && (to == lastto))
++      return;
++   lastfrom = from;
++   lastto = to;
+ 
+    spin_lock_irqsave(&vga_lock, flags);
+-   outb_p(0x0a, vga_video_port_reg);      /* Cursor start */
++   outb_p(0x0a, vga_video_port_reg);   /* Cursor start */
+    curs = inb_p(vga_video_port_val);
+-   outb_p(0x0b, vga_video_port_reg);      /* Cursor end */
++   outb_p(0x0b, vga_video_port_reg);   /* Cursor end */
+    cure = inb_p(vga_video_port_val);
+ 
+    curs = (curs & 0xc0) | from;
+    cure = (cure & 0xe0) | to;
+ 
+-   outb_p(0x0a, vga_video_port_reg);      /* Cursor start */
++   outb_p(0x0a, vga_video_port_reg);   /* Cursor start */
+    outb_p(curs, vga_video_port_val);
+-   outb_p(0x0b, vga_video_port_reg);      /* Cursor end */
++   outb_p(0x0b, vga_video_port_reg);   /* Cursor end */
+    outb_p(cure, vga_video_port_val);
+    spin_unlock_irqrestore(&vga_lock, flags);
+ }
+ 
+ static void vgacon_cursor(struct vc_data *c, int mode)
+ {
+-    if (c->vc_origin != c->vc_visible_origin)
+-   vgacon_scrolldelta(c, 0);
+-    switch (mode) {
++   if (c->vc_origin != c->vc_visible_origin)
++      vgacon_scrolldelta(c, 0);
++   switch (mode) {
+    case CM_ERASE:
+-       write_vga(14, (vga_vram_end - vga_vram_base - 1)/2);
+-       break;
++      write_vga(14, (vga_vram_end - vga_vram_base - 1) / 2);
++      break;
+ 
+    case CM_MOVE:
+    case CM_DRAW:
+-       write_vga(14, (c->vc_pos-vga_vram_base)/2);
+-       switch (c->vc_cursor_type & 0x0f) {
++      write_vga(14, (c->vc_pos - vga_vram_base) / 2);
++      switch (c->vc_cursor_type & 0x0f) {
+       case CUR_UNDERLINE:
+-         vgacon_set_cursor_size(c->vc_x, 
+-               video_font_height - (video_font_height < 10 ? 2 : 3),
+-               video_font_height - (video_font_height < 10 ? 1 : 2));
++         vgacon_set_cursor_size(c->vc_x,
++                      video_font_height -
++                      (video_font_height <
++                  10 ? 2 : 3),
++                      video_font_height -
++                      (video_font_height <
++                  10 ? 1 : 2));
+          break;
+       case CUR_TWO_THIRDS:
+-         vgacon_set_cursor_size(c->vc_x, 
+-                video_font_height / 3,
+-                video_font_height - (video_font_height < 10 ? 1 : 2));
++         vgacon_set_cursor_size(c->vc_x,
++                      video_font_height / 3,
++                      video_font_height -
++                      (video_font_height <
++                  10 ? 1 : 2));
+          break;
+       case CUR_LOWER_THIRD:
+-         vgacon_set_cursor_size(c->vc_x, 
+-                (video_font_height*2) / 3,
+-                video_font_height - (video_font_height < 10 ? 1 : 2));
++         vgacon_set_cursor_size(c->vc_x,
++                      (video_font_height * 2) / 3,
++                      video_font_height -
++                      (video_font_height <
++                  10 ? 1 : 2));
+          break;
+       case CUR_LOWER_HALF:
+-         vgacon_set_cursor_size(c->vc_x, 
+-                video_font_height / 2,
+-                video_font_height - (video_font_height < 10 ? 1 : 2));
++         vgacon_set_cursor_size(c->vc_x,
++                      video_font_height / 2,
++                      video_font_height -
++                      (video_font_height <
++                  10 ? 1 : 2));
+          break;
+       case CUR_NONE:
+          vgacon_set_cursor_size(c->vc_x, 31, 30);
+          break;
+-             default:
+-         vgacon_set_cursor_size(c->vc_x, 1, video_font_height);
++      default:
++         vgacon_set_cursor_size(c->vc_x, 1,
++                      video_font_height);
+          break;
+       }
+-       break;
+-    }
++      break;
++   }
+ }
+ 
+ static int vgacon_switch(struct vc_data *c)
+@@ -486,28 +499,30 @@
+    vga_video_num_columns = c->vc_cols;
+    vga_video_num_lines = c->vc_rows;
+    if (!vga_is_gfx)
+-      scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf, c->vc_screenbuf_size);
+-   return 0;   /* Redrawing not needed */
++      scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf,
++             c->vc_screenbuf_size);
++   return 0;      /* Redrawing not needed */
+ }
+ 
+-static void vga_set_palette(struct vc_data *c, unsigned char *table)
++static void vga_set_palette(struct vc_data *vc, unsigned char *table)
+ {
+-   int i, j ;
++   int i, j;
+ 
+-   for (i=j=0; i<16; i++) {
+-      outb_p (table[i], dac_reg) ;
+-      outb_p (c->vc_palette[j++]>>2, dac_val) ;
+-      outb_p (c->vc_palette[j++]>>2, dac_val) ;
+-      outb_p (c->vc_palette[j++]>>2, dac_val) ;
++   for (i = j = 0; i < 16; i++) {
++      vga_w(NULL, VGA_PEL_IW, table[i]);
++      vga_w(NULL, VGA_PEL_D, vc->vc_palette[j++] >> 2);
++      vga_w(NULL, VGA_PEL_D, vc->vc_palette[j++] >> 2);
++      vga_w(NULL, VGA_PEL_D, vc->vc_palette[j++] >> 2);
+    }
+ }
+ 
+-static int vgacon_set_palette(struct vc_data *c, unsigned char *table)
++static int vgacon_set_palette(struct vc_data *vc, unsigned char *table)
+ {
+ #ifdef CAN_LOAD_PALETTE
+-   if (vga_video_type != VIDEO_TYPE_VGAC || vga_palette_blanked || !CON_IS_VISIBLE(c))
++   if (vga_video_type != VIDEO_TYPE_VGAC || vga_palette_blanked
++       || !CON_IS_VISIBLE(vc))
+       return -EINVAL;
+-   vga_set_palette(c, table);
++   vga_set_palette(vc, table);
+    return 0;
+ #else
+    return -EINVAL;
+@@ -516,59 +531,57 @@
+ 
+ /* structure holding original VGA register settings */
+ static struct {
+-   unsigned char   SeqCtrlIndex;      /* Sequencer Index reg.   */
+-   unsigned char   CrtCtrlIndex;      /* CRT-Contr. Index reg.  */
+-   unsigned char   CrtMiscIO;      /* Miscellaneous register */
+-   unsigned char   HorizontalTotal;   /* CRT-Controller:00h */
+-   unsigned char   HorizDisplayEnd;   /* CRT-Controller:01h */
+-   unsigned char   StartHorizRetrace;   /* CRT-Controller:04h */
+-   unsigned char   EndHorizRetrace;   /* CRT-Controller:05h */
+-   unsigned char   Overflow;      /* CRT-Controller:07h */
+-   unsigned char   StartVertRetrace;   /* CRT-Controller:10h */
+-   unsigned char   EndVertRetrace;      /* CRT-Controller:11h */
+-   unsigned char   ModeControl;      /* CRT-Controller:17h */
+-   unsigned char   ClockingMode;      /* Seq-Controller:01h */
++   unsigned char SeqCtrlIndex;   /* Sequencer Index reg.   */
++   unsigned char CrtCtrlIndex;   /* CRT-Contr. Index reg.  */
++   unsigned char CrtMiscIO;   /* Miscellaneous register */
++   unsigned char HorizontalTotal;   /* CRT-Controller:00h */
++   unsigned char HorizDisplayEnd;   /* CRT-Controller:01h */
++   unsigned char StartHorizRetrace;   /* CRT-Controller:04h */
++   unsigned char EndHorizRetrace;   /* CRT-Controller:05h */
++   unsigned char Overflow;   /* CRT-Controller:07h */
++   unsigned char StartVertRetrace;   /* CRT-Controller:10h */
++   unsigned char EndVertRetrace;   /* CRT-Controller:11h */
++   unsigned char ModeControl;   /* CRT-Controller:17h */
++   unsigned char ClockingMode;   /* Seq-Controller:01h */
+ } vga_state;
+ 
+ static void vga_vesa_blank(int mode)
+ {
+    /* save original values of VGA controller registers */
+-   if(!vga_vesa_blanked) {
++   if (!vga_vesa_blanked) {
+       spin_lock_irq(&vga_lock);
+-      vga_state.SeqCtrlIndex = inb_p(seq_port_reg);
++      vga_state.SeqCtrlIndex = vga_r(NULL, VGA_SEQ_I);
+       vga_state.CrtCtrlIndex = inb_p(vga_video_port_reg);
+-      vga_state.CrtMiscIO = inb_p(video_misc_rd);
++      vga_state.CrtMiscIO = vga_r(NULL, VGA_MIS_R);
+       spin_unlock_irq(&vga_lock);
+ 
+-      outb_p(0x00,vga_video_port_reg);   /* HorizontalTotal */
++      outb_p(0x00, vga_video_port_reg);   /* HorizontalTotal */
+       vga_state.HorizontalTotal = inb_p(vga_video_port_val);
+-      outb_p(0x01,vga_video_port_reg);   /* HorizDisplayEnd */
++      outb_p(0x01, vga_video_port_reg);   /* HorizDisplayEnd */
+       vga_state.HorizDisplayEnd = inb_p(vga_video_port_val);
+-      outb_p(0x04,vga_video_port_reg);   /* StartHorizRetrace */
++      outb_p(0x04, vga_video_port_reg);   /* StartHorizRetrace */
+       vga_state.StartHorizRetrace = inb_p(vga_video_port_val);
+-      outb_p(0x05,vga_video_port_reg);   /* EndHorizRetrace */
++      outb_p(0x05, vga_video_port_reg);   /* EndHorizRetrace */
+       vga_state.EndHorizRetrace = inb_p(vga_video_port_val);
+-      outb_p(0x07,vga_video_port_reg);   /* Overflow */
++      outb_p(0x07, vga_video_port_reg);   /* Overflow */
+       vga_state.Overflow = inb_p(vga_video_port_val);
+-      outb_p(0x10,vga_video_port_reg);   /* StartVertRetrace */
++      outb_p(0x10, vga_video_port_reg);   /* StartVertRetrace */
+       vga_state.StartVertRetrace = inb_p(vga_video_port_val);
+-      outb_p(0x11,vga_video_port_reg);   /* EndVertRetrace */
++      outb_p(0x11, vga_video_port_reg);   /* EndVertRetrace */
+       vga_state.EndVertRetrace = inb_p(vga_video_port_val);
+-      outb_p(0x17,vga_video_port_reg);   /* ModeControl */
++      outb_p(0x17, vga_video_port_reg);   /* ModeControl */
+       vga_state.ModeControl = inb_p(vga_video_port_val);
+-      outb_p(0x01,seq_port_reg);      /* ClockingMode */
+-      vga_state.ClockingMode = inb_p(seq_port_val);
++      vga_state.ClockingMode = vga_rseq(NULL, VGA_SEQ_CLOCK_MODE);
+    }
+ 
+    /* assure that video is enabled */
+    /* "0x20" is VIDEO_ENABLE_bit in register 01 of sequencer */
+    spin_lock_irq(&vga_lock);
+-   outb_p(0x01,seq_port_reg);
+-   outb_p(vga_state.ClockingMode | 0x20,seq_port_val);
++   vga_wseq(NULL, VGA_SEQ_CLOCK_MODE, vga_state.ClockingMode | 0x20);
+ 
+    /* test for vertical retrace in process.... */
+    if ((vga_state.CrtMiscIO & 0x80) == 0x80)
+-      outb_p(vga_state.CrtMiscIO & 0xef,video_misc_wr);
++      vga_w(NULL, VGA_MIS_W, vga_state.CrtMiscIO & 0xEF);
+ 
+    /*
+     * Set <End of vertical retrace> to minimum (0) and
+@@ -576,12 +589,12 @@
+     * Result: turn off vertical sync (VSync) pulse.
+     */
+    if (mode & VESA_VSYNC_SUSPEND) {
+-      outb_p(0x10,vga_video_port_reg);   /* StartVertRetrace */
+-      outb_p(0xff,vga_video_port_val);    /* maximum value */
+-      outb_p(0x11,vga_video_port_reg);   /* EndVertRetrace */
+-      outb_p(0x40,vga_video_port_val);   /* minimum (bits 0..3)  */
+-      outb_p(0x07,vga_video_port_reg);   /* Overflow */
+-      outb_p(vga_state.Overflow | 0x84,vga_video_port_val); /* bits 9,10 of vert. retrace */
++      outb_p(0x10, vga_video_port_reg);   /* StartVertRetrace */
++      outb_p(0xff, vga_video_port_val);   /* maximum value */
++      outb_p(0x11, vga_video_port_reg);   /* EndVertRetrace */
++      outb_p(0x40, vga_video_port_val);   /* minimum (bits 0..3)  */
++      outb_p(0x07, vga_video_port_reg);   /* Overflow */
++      outb_p(vga_state.Overflow | 0x84, vga_video_port_val);   /* bits 9,10 of vert. retrace */
+    }
+ 
+    if (mode & VESA_HSYNC_SUSPEND) {
+@@ -590,15 +603,15 @@
+        *  <Start of horizontal Retrace> to maximum
+        * Result: turn off horizontal sync (HSync) pulse.
+        */
+-      outb_p(0x04,vga_video_port_reg);   /* StartHorizRetrace */
+-      outb_p(0xff,vga_video_port_val);   /* maximum */
+-      outb_p(0x05,vga_video_port_reg);   /* EndHorizRetrace */
+-      outb_p(0x00,vga_video_port_val);   /* minimum (0) */
++      outb_p(0x04, vga_video_port_reg);   /* StartHorizRetrace */
++      outb_p(0xff, vga_video_port_val);   /* maximum */
++      outb_p(0x05, vga_video_port_reg);   /* EndHorizRetrace */
++      outb_p(0x00, vga_video_port_val);   /* minimum (0) */
+    }
+ 
+    /* restore both index registers */
+-   outb_p(vga_state.SeqCtrlIndex,seq_port_reg);
+-   outb_p(vga_state.CrtCtrlIndex,vga_video_port_reg);
++   vga_w(NULL, VGA_SEQ_I, vga_state.SeqCtrlIndex);
++   outb_p(vga_state.CrtCtrlIndex, vga_video_port_reg);
+    spin_unlock_irq(&vga_lock);
+ }
+ 
+@@ -606,49 +619,49 @@
+ {
+    /* restore original values of VGA controller registers */
+    spin_lock_irq(&vga_lock);
+-   outb_p(vga_state.CrtMiscIO,video_misc_wr);
++   vga_w(NULL, VGA_MIS_W, vga_state.CrtMiscIO);
+ 
+-   outb_p(0x00,vga_video_port_reg);      /* HorizontalTotal */
+-   outb_p(vga_state.HorizontalTotal,vga_video_port_val);
+-   outb_p(0x01,vga_video_port_reg);      /* HorizDisplayEnd */
+-   outb_p(vga_state.HorizDisplayEnd,vga_video_port_val);
+-   outb_p(0x04,vga_video_port_reg);      /* StartHorizRetrace */
+-   outb_p(vga_state.StartHorizRetrace,vga_video_port_val);
+-   outb_p(0x05,vga_video_port_reg);      /* EndHorizRetrace */
+-   outb_p(vga_state.EndHorizRetrace,vga_video_port_val);
+-   outb_p(0x07,vga_video_port_reg);      /* Overflow */
+-   outb_p(vga_state.Overflow,vga_video_port_val);
+-   outb_p(0x10,vga_video_port_reg);      /* StartVertRetrace */
+-   outb_p(vga_state.StartVertRetrace,vga_video_port_val);
+-   outb_p(0x11,vga_video_port_reg);      /* EndVertRetrace */
+-   outb_p(vga_state.EndVertRetrace,vga_video_port_val);
+-   outb_p(0x17,vga_video_port_reg);      /* ModeControl */
+-   outb_p(vga_state.ModeControl,vga_video_port_val);
+-   outb_p(0x01,seq_port_reg);      /* ClockingMode */
+-   outb_p(vga_state.ClockingMode,seq_port_val);
++   outb_p(0x00, vga_video_port_reg);   /* HorizontalTotal */
++   outb_p(vga_state.HorizontalTotal, vga_video_port_val);
++   outb_p(0x01, vga_video_port_reg);   /* HorizDisplayEnd */
++   outb_p(vga_state.HorizDisplayEnd, vga_video_port_val);
++   outb_p(0x04, vga_video_port_reg);   /* StartHorizRetrace */
++   outb_p(vga_state.StartHorizRetrace, vga_video_port_val);
++   outb_p(0x05, vga_video_port_reg);   /* EndHorizRetrace */
++   outb_p(vga_state.EndHorizRetrace, vga_video_port_val);
++   outb_p(0x07, vga_video_port_reg);   /* Overflow */
++   outb_p(vga_state.Overflow, vga_video_port_val);
++   outb_p(0x10, vga_video_port_reg);   /* StartVertRetrace */
++   outb_p(vga_state.StartVertRetrace, vga_video_port_val);
++   outb_p(0x11, vga_video_port_reg);   /* EndVertRetrace */
++   outb_p(vga_state.EndVertRetrace, vga_video_port_val);
++   outb_p(0x17, vga_video_port_reg);   /* ModeControl */
++   outb_p(vga_state.ModeControl, vga_video_port_val);
++   /* ClockingMode */
++   vga_wseq(NULL, VGA_SEQ_CLOCK_MODE, vga_state.ClockingMode);
+ 
+    /* restore index/control registers */
+-   outb_p(vga_state.SeqCtrlIndex,seq_port_reg);
+-   outb_p(vga_state.CrtCtrlIndex,vga_video_port_reg);
++   vga_w(NULL, VGA_SEQ_I, vga_state.SeqCtrlIndex);
++   outb_p(vga_state.CrtCtrlIndex, vga_video_port_reg);
+    spin_unlock_irq(&vga_lock);
+ }
+ 
+-static void vga_pal_blank(void)
++static void vga_pal_blank(caddr_t regs)
+ {
+    int i;
+ 
+-   for (i=0; i<16; i++) {
+-      outb_p (i, dac_reg) ;
+-      outb_p (0, dac_val) ;
+-      outb_p (0, dac_val) ;
+-      outb_p (0, dac_val) ;
++   for (i = 0; i < 16; i++) {
++      vga_w(NULL, VGA_PEL_IW, i);
++      vga_w(NULL, VGA_PEL_D, 0);
++      vga_w(NULL, VGA_PEL_D, 0);
++      vga_w(NULL, VGA_PEL_D, 0);
+    }
+ }
+ 
+ static int vgacon_blank(struct vc_data *c, int blank)
+ {
+    switch (blank) {
+-   case 0:            /* Unblank */
++   case 0:      /* Unblank */
+       if (vga_vesa_blanked) {
+          vga_vesa_unblank();
+          vga_vesa_blanked = 0;
+@@ -661,22 +674,24 @@
+       vga_is_gfx = 0;
+       /* Tell console.c that it has to restore the screen itself */
+       return 1;
+-   case 1:            /* Normal blanking */
++   case 1:      /* Normal blanking */
+       if (vga_video_type == VIDEO_TYPE_VGAC) {
+-         vga_pal_blank();
++         vga_pal_blank(NULL);
+          vga_palette_blanked = 1;
+          return 0;
+       }
+       vgacon_set_origin(c);
+-      scr_memsetw((void *)vga_vram_base, BLANK, c->vc_screenbuf_size);
++      scr_memsetw((void *) vga_vram_base, BLANK,
++             c->vc_screenbuf_size);
+       return 1;
+-   case -1:         /* Entering graphic mode */
+-      scr_memsetw((void *)vga_vram_base, BLANK, c->vc_screenbuf_size);
++   case -1:      /* Entering graphic mode */
++      scr_memsetw((void *) vga_vram_base, BLANK,
++             c->vc_screenbuf_size);
+       vga_is_gfx = 1;
+       return 1;
+-   default:         /* VESA blanking */
++   default:      /* VESA blanking */
+       if (vga_video_type == VIDEO_TYPE_VGAC) {
+-         vga_vesa_blank(blank-1);
++         vga_vesa_blank(blank - 1);
+          vga_vesa_blanked = blank;
+       }
+       return 0;
+@@ -703,8 +718,7 @@
+ #define blackwmap 0xa0000
+ #define cmapsz 8192
+ 
+-static int
+-vgacon_do_font_op(char *arg, int set, int ch512)
++static int vgacon_do_font_op(char *arg, int set, int ch512)
+ {
+    int i;
+    char *charmap;
+@@ -713,28 +727,28 @@
+    int font_select = 0x00;
+ 
+    if (vga_video_type != VIDEO_TYPE_EGAM) {
+-      charmap = (char *)VGA_MAP_MEM(colourmap);
++      charmap = (char *) VGA_MAP_MEM(colourmap);
+       beg = 0x0e;
+ #ifdef VGA_CAN_DO_64KB
+       if (vga_video_type == VIDEO_TYPE_VGAC)
+          beg = 0x06;
+ #endif
+    } else {
+-      charmap = (char *)VGA_MAP_MEM(blackwmap);
++      charmap = (char *) VGA_MAP_MEM(blackwmap);
+       beg = 0x0a;
+    }
+-   
++
+ #ifdef BROKEN_GRAPHICS_PROGRAMS
+    /*
+     * All fonts are loaded in slot 0 (0:1 for 512 ch)
+     */
+ 
+    if (!arg)
+-      return -EINVAL;      /* Return to default font not supported */
++      return -EINVAL;   /* Return to default font not supported */
+ 
+    vga_font_is_default = 0;
+    font_select = ch512 ? 0x04 : 0x00;
+-#else   
++#else
+    /*
+     * The default font is kept in slot 0 and is never touched.
+     * A custom font is loaded in slot 2 (256 ch) or 2:3 (512 ch)
+@@ -743,38 +757,38 @@
+    if (set) {
+       vga_font_is_default = !arg;
+       if (!arg)
+-         ch512 = 0;      /* Default font is always 256 */
++         ch512 = 0;   /* Default font is always 256 */
+       font_select = arg ? (ch512 ? 0x0e : 0x0a) : 0x00;
+    }
+ 
+-   if ( !vga_font_is_default )
+-      charmap += 4*cmapsz;
++   if (!vga_font_is_default)
++      charmap += 4 * cmapsz;
+ #endif
+ 
+    spin_lock_irq(&vga_lock);
+-   outb_p( 0x00, seq_port_reg );   /* First, the sequencer */
+-   outb_p( 0x01, seq_port_val );   /* Synchronous reset */
+-   outb_p( 0x02, seq_port_reg );
+-   outb_p( 0x04, seq_port_val );   /* CPU writes only to map 2 */
+-   outb_p( 0x04, seq_port_reg );
+-   outb_p( 0x07, seq_port_val );   /* Sequential addressing */
+-   outb_p( 0x00, seq_port_reg );
+-   outb_p( 0x03, seq_port_val );   /* Clear synchronous reset */
+-
+-   outb_p( 0x04, gr_port_reg );    /* Now, the graphics controller */
+-   outb_p( 0x02, gr_port_val );    /* select map 2 */
+-   outb_p( 0x05, gr_port_reg );
+-   outb_p( 0x00, gr_port_val );    /* disable odd-even addressing */
+-   outb_p( 0x06, gr_port_reg );
+-   outb_p( 0x00, gr_port_val );    /* map start at A000:0000 */
++   /* First, the Sequencer */
++   vga_wseq(NULL, VGA_SEQ_RESET, 0x1);
++   /* CPU writes only to map 2 */
++   vga_wseq(NULL, VGA_SEQ_PLANE_WRITE, 0x04);   
++   /* Sequential addressing */
++   vga_wseq(NULL, VGA_SEQ_MEMORY_MODE, 0x07);   
++   /* Clear synchronous reset */
++   vga_wseq(NULL, VGA_SEQ_RESET, 0x03);
++
++   /* Now, the graphics controller, select map 2 */
++   vga_wgfx(NULL, VGA_GFX_PLANE_READ, 0x02);      
++   /* disable odd-even addressing */
++   vga_wgfx(NULL, VGA_GFX_MODE, 0x00);
++   /* map start at A000:0000 */
++   vga_wgfx(NULL, VGA_GFX_MISC, 0x00);
+    spin_unlock_irq(&vga_lock);
+-   
++
+    if (arg) {
+       if (set)
+-         for (i=0; i<cmapsz ; i++)
++         for (i = 0; i < cmapsz; i++)
+             vga_writeb(arg[i], charmap + i);
+       else
+-         for (i=0; i<cmapsz ; i++)
++         for (i = 0; i < cmapsz; i++)
+             arg[i] = vga_readb(charmap + i);
+ 
+       /*
+@@ -783,56 +797,57 @@
+        */
+ 
+       if (ch512) {
+-         charmap += 2*cmapsz;
++         charmap += 2 * cmapsz;
+          arg += cmapsz;
+          if (set)
+-            for (i=0; i<cmapsz ; i++)
+-               vga_writeb(arg[i], charmap+i);
++            for (i = 0; i < cmapsz; i++)
++               vga_writeb(arg[i], charmap + i);
+          else
+-            for (i=0; i<cmapsz ; i++)
+-               arg[i] = vga_readb(charmap+i);
++            for (i = 0; i < cmapsz; i++)
++               arg[i] = vga_readb(charmap + i);
+       }
+    }
+-   
+-   spin_lock_irq(&vga_lock);
+-   outb_p( 0x00, seq_port_reg );   /* First, the sequencer */
+-   outb_p( 0x01, seq_port_val );   /* Synchronous reset */
+-   outb_p( 0x02, seq_port_reg );
+-   outb_p( 0x03, seq_port_val );   /* CPU writes to maps 0 and 1 */
+-   outb_p( 0x04, seq_port_reg );
+-   outb_p( 0x03, seq_port_val );   /* odd-even addressing */
+-   if (set) {
+-      outb_p( 0x03, seq_port_reg ); /* Character Map Select */
+-      outb_p( font_select, seq_port_val );
+-   }
+-   outb_p( 0x00, seq_port_reg );
+-   outb_p( 0x03, seq_port_val );   /* clear synchronous reset */
+ 
+-   outb_p( 0x04, gr_port_reg );    /* Now, the graphics controller */
+-   outb_p( 0x00, gr_port_val );    /* select map 0 for CPU */
+-   outb_p( 0x05, gr_port_reg );
+-   outb_p( 0x10, gr_port_val );    /* enable even-odd addressing */
+-   outb_p( 0x06, gr_port_reg );
+-   outb_p( beg, gr_port_val );     /* map starts at b800:0 or b000:0 */
++   spin_lock_irq(&vga_lock);
++   /* First, the sequencer, Synchronous reset */
++   vga_wseq(NULL, VGA_SEQ_RESET, 0x01);   
++   /* CPU writes to maps 0 and 1 */
++   vga_wseq(NULL, VGA_SEQ_PLANE_WRITE, 0x03);
++   /* odd-even addressing */
++   vga_wseq(NULL, VGA_SEQ_MEMORY_MODE, 0x03);
++   /* Character Map Select */
++   if (set)
++      vga_wseq(NULL, VGA_SEQ_CHARACTER_MAP, font_select);
++   /* clear synchronous reset */
++   vga_wseq(NULL, VGA_SEQ_RESET, 0x03);
++
++   /* Now, the graphics controller, select map 0 for CPU */
++   vga_wgfx(NULL, VGA_GFX_PLANE_READ, 0x00);
++   /* enable even-odd addressing */
++   vga_wgfx(NULL, VGA_GFX_MODE, 0x10);
++   /* map starts at b800:0 or b000:0 */
++   vga_wgfx(NULL, VGA_GFX_MISC, beg);
+ 
+    /* if 512 char mode is already enabled don't re-enable it. */
+-   if ((set)&&(ch512!=vga_512_chars)) {   /* attribute controller */
+-      int i;
+-      for(i=0; i<MAX_NR_CONSOLES; i++) {
++   if ((set) && (ch512 != vga_512_chars)) {
++      int i;   
++      
++      /* attribute controller */
++      for (i = 0; i < MAX_NR_CONSOLES; i++) {
+          struct vc_data *c = vc_cons[i].d;
+          if (c && c->vc_sw == &vga_con)
+             c->vc_hi_font_mask = ch512 ? 0x0800 : 0;
+       }
+-      vga_512_chars=ch512;
++      vga_512_chars = ch512;
+       /* 256-char: enable intensity bit
+          512-char: disable intensity bit */
+-      inb_p( video_port_status );   /* clear address flip-flop */
+-      outb_p ( 0x12, attrib_port ); /* color plane enable register */
+-      outb_p ( ch512 ? 0x07 : 0x0f, attrib_port );
++      inb_p(video_port_status);   /* clear address flip-flop */
++      /* color plane enable register */
++      vga_wattr(NULL, VGA_ATC_PLANE_ENABLE, ch512 ? 0x07 : 0x0f);
+       /* Wilton (1987) mentions the following; I don't know what
+          it means, but it works, and it appears necessary */
+-      inb_p( video_port_status );
+-      outb_p ( 0x20, attrib_port );
++      inb_p(video_port_status);
++      vga_wattr(NULL, VGA_AR_ENABLE_DISPLAY, 0);   
+    }
+    spin_unlock_irq(&vga_lock);
+    return 0;
+@@ -841,8 +856,7 @@
+ /*
+  * Adjust the screen to fit a font of a certain height
+  */
+-static int
+-vgacon_adjust_height(unsigned fontheight)
++static int vgacon_adjust_height(unsigned fontheight)
+ {
+    unsigned char ovr, vde, fsr;
+    int rows, maxscan, i;
+@@ -852,8 +866,8 @@
+ 
+    vga_video_font_height = video_font_height = fontheight;
+ 
+-   rows = video_scan_lines/fontheight;   /* Number of video rows we end up with */
+-   maxscan = rows*fontheight - 1;      /* Scan lines to actually display-1 */
++   rows = video_scan_lines / fontheight;   /* Number of video rows we end up with */
++   maxscan = rows * fontheight - 1;   /* Scan lines to actually display-1 */
+ 
+    /* Reprogram the CRTC for the new font size
+       Note: the attempt to read the overflow register will fail
+@@ -866,26 +880,25 @@
+       are all don't care bits on EGA, so I guess it doesn't matter. */
+ 
+    spin_lock_irq(&vga_lock);
+-   outb_p( 0x07, vga_video_port_reg );      /* CRTC overflow register */
++   outb_p(0x07, vga_video_port_reg);   /* CRTC overflow register */
+    ovr = inb_p(vga_video_port_val);
+-   outb_p( 0x09, vga_video_port_reg );      /* Font size register */
++   outb_p(0x09, vga_video_port_reg);   /* Font size register */
+    fsr = inb_p(vga_video_port_val);
+    spin_unlock_irq(&vga_lock);
+ 
+-   vde = maxscan & 0xff;         /* Vertical display end reg */
+-   ovr = (ovr & 0xbd) +         /* Overflow register */
+-         ((maxscan & 0x100) >> 7) +
+-         ((maxscan & 0x200) >> 3);
+-   fsr = (fsr & 0xe0) + (fontheight-1);    /*  Font size register */
++   vde = maxscan & 0xff;   /* Vertical display end reg */
++   ovr = (ovr & 0xbd) +   /* Overflow register */
++       ((maxscan & 0x100) >> 7) + ((maxscan & 0x200) >> 3);
++   fsr = (fsr & 0xe0) + (fontheight - 1);   /*  Font size register */
+ 
+    spin_lock_irq(&vga_lock);
+-   outb_p( 0x07, vga_video_port_reg );      /* CRTC overflow register */
+-   outb_p( ovr, vga_video_port_val );
+-   outb_p( 0x09, vga_video_port_reg );      /* Font size */
+-   outb_p( fsr, vga_video_port_val );
+-   outb_p( 0x12, vga_video_port_reg );      /* Vertical display limit */
+-   outb_p( vde, vga_video_port_val );
+-   spin_unlock_irq(&vga_lock);   
++   outb_p(0x07, vga_video_port_reg);   /* CRTC overflow register */
++   outb_p(ovr, vga_video_port_val);
++   outb_p(0x09, vga_video_port_reg);   /* Font size */
++   outb_p(fsr, vga_video_port_val);
++   outb_p(0x12, vga_video_port_reg);   /* Vertical display limit */
++   outb_p(vde, vga_video_port_val);
++   spin_unlock_irq(&vga_lock);
+ 
+    for (i = 0; i < MAX_NR_CONSOLES; i++) {
+       struct vc_data *c = vc_cons[i].d;
+@@ -904,7 +917,8 @@
+       return -EINVAL;
+ 
+    if (op->op == KD_FONT_OP_SET) {
+-      if (op->width != 8 || (op->charcount != 256 && op->charcount != 512))
++      if (op->width != 8
++          || (op->charcount != 256 && op->charcount != 512))
+          return -EINVAL;
+       rc = vgacon_do_font_op(op->data, 1, op->charcount == 512);
+       if (!rc && !(op->flags & KD_FONT_FLAG_DONT_RECALC))
+@@ -913,7 +927,8 @@
+       op->width = 8;
+       op->height = vga_video_font_height;
+       op->charcount = vga_512_chars ? 512 : 256;
+-      if (!op->data) return 0;
++      if (!op->data)
++         return 0;
+       rc = vgacon_do_font_op(op->data, 0, 0);
+    } else
+       rc = -ENOSYS;
+@@ -931,21 +946,23 @@
+ 
+ static int vgacon_scrolldelta(struct vc_data *c, int lines)
+ {
+-   if (!lines)         /* Turn scrollback off */
++   if (!lines)      /* Turn scrollback off */
+       c->vc_visible_origin = c->vc_origin;
+    else {
+       int vram_size = vga_vram_end - vga_vram_base;
+       int margin = c->vc_size_row * 4;
+       int ul, we, p, st;
+ 
+-      if (vga_rolled_over > (c->vc_scr_end - vga_vram_base) + margin) {
++      if (vga_rolled_over >
++          (c->vc_scr_end - vga_vram_base) + margin) {
+          ul = c->vc_scr_end - vga_vram_base;
+          we = vga_rolled_over + c->vc_size_row;
+       } else {
+          ul = 0;
+          we = vram_size;
+       }
+-      p = (c->vc_visible_origin - vga_vram_base - ul + we) % we + lines * c->vc_size_row;
++      p = (c->vc_visible_origin - vga_vram_base - ul + we) % we +
++          lines * c->vc_size_row;
+       st = (c->vc_origin - vga_vram_base - ul + we) % we;
+       if (p < margin)
+          p = 0;
+@@ -982,46 +999,52 @@
+       c->vc_y = ORIG_Y;
+    }
+    if (!vga_is_gfx)
+-      scr_memcpyw((u16 *) c->vc_screenbuf, (u16 *) c->vc_origin, c->vc_screenbuf_size);
++      scr_memcpyw((u16 *) c->vc_screenbuf, (u16 *) c->vc_origin,
++             c->vc_screenbuf_size);
+ }
+ 
+-static int vgacon_scroll(struct vc_data *c, int t, int b, int dir, int lines)
++static int vgacon_scroll(struct vc_data *c, int t, int b, int dir,
++          int lines)
+ {
+    unsigned long oldo;
+    unsigned int delta;
+-   
++
+    if (t || b != c->vc_rows || vga_is_gfx)
+       return 0;
+ 
+    if (c->vc_origin != c->vc_visible_origin)
+       vgacon_scrolldelta(c, 0);
+ 
+-   if (!vga_hardscroll_enabled || lines >= c->vc_rows/2)
++   if (!vga_hardscroll_enabled || lines >= c->vc_rows / 2)
+       return 0;
+ 
+    oldo = c->vc_origin;
+    delta = lines * c->vc_size_row;
+    if (dir == SM_UP) {
+       if (c->vc_scr_end + delta >= vga_vram_end) {
+-         scr_memcpyw((u16 *)vga_vram_base,
+-                (u16 *)(oldo + delta),
++         scr_memcpyw((u16 *) vga_vram_base,
++                (u16 *) (oldo + delta),
+                 c->vc_screenbuf_size - delta);
+          c->vc_origin = vga_vram_base;
+          vga_rolled_over = oldo - vga_vram_base;
+       } else
+          c->vc_origin += delta;
+-      scr_memsetw((u16 *)(c->vc_origin + c->vc_screenbuf_size - delta), c->vc_video_erase_char, delta);
++      scr_memsetw((u16 *) (c->vc_origin + c->vc_screenbuf_size -
++                 delta), c->vc_video_erase_char,
++             delta);
+    } else {
+       if (oldo - delta < vga_vram_base) {
+-         scr_memmovew((u16 *)(vga_vram_end - c->vc_screenbuf_size + delta),
+-                 (u16 *)oldo,
++         scr_memmovew((u16 *) (vga_vram_end -
++                     c->vc_screenbuf_size +
++                     delta), (u16 *) oldo,
+                  c->vc_screenbuf_size - delta);
+          c->vc_origin = vga_vram_end - c->vc_screenbuf_size;
+          vga_rolled_over = 0;
+       } else
+          c->vc_origin -= delta;
+       c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size;
+-      scr_memsetw((u16 *)(c->vc_origin), c->vc_video_erase_char, delta);
++      scr_memsetw((u16 *) (c->vc_origin), c->vc_video_erase_char,
++             delta);
+    }
+    c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size;
+    c->vc_visible_origin = c->vc_origin;
+@@ -1043,24 +1066,24 @@
+ #define DUMMY (void *) vgacon_dummy
+ 
+ const struct consw vga_con = {
+-   .con_startup =      vgacon_startup,
+-   .con_init =      vgacon_init,
+-   .con_deinit =      vgacon_deinit,
+-   .con_clear =      DUMMY,
+-   .con_putc =      DUMMY,
+-   .con_putcs =      DUMMY,
+-   .con_cursor =      vgacon_cursor,
+-   .con_scroll =      vgacon_scroll,
+-   .con_bmove =      DUMMY,
+-   .con_switch =      vgacon_switch,
+-   .con_blank =      vgacon_blank,
+-   .con_font_op =      vgacon_font_op,
+-   .con_set_palette =   vgacon_set_palette,
+-   .con_scrolldelta =   vgacon_scrolldelta,
+-   .con_set_origin =   vgacon_set_origin,
+-   .con_save_screen =   vgacon_save_screen,
+-   .con_build_attr =   vgacon_build_attr,
+-   .con_invert_region =   vgacon_invert_region,
++   .con_startup = vgacon_startup,
++   .con_init = vgacon_init,
++   .con_deinit = vgacon_deinit,
++   .con_clear = DUMMY,
++   .con_putc = DUMMY,
++   .con_putcs = DUMMY,
++   .con_cursor = vgacon_cursor,
++   .con_scroll = vgacon_scroll,
++   .con_bmove = DUMMY,
++   .con_switch = vgacon_switch,
++   .con_blank = vgacon_blank,
++   .con_font_op = vgacon_font_op,
++   .con_set_palette = vgacon_set_palette,
++   .con_scrolldelta = vgacon_scrolldelta,
++   .con_set_origin = vgacon_set_origin,
++   .con_save_screen = vgacon_save_screen,
++   .con_build_attr = vgacon_build_attr,
++   .con_invert_region = vgacon_invert_region,
+ };
+ 
+ MODULE_LICENSE("GPL");
+diff -urN -X /home/jsimmons/dontdiff linus-2.5/drivers/video/fbmem.c fbdev-2.5/drivers/video/fbmem.c
+--- linus-2.5/drivers/video/fbmem.c   Wed Feb 12 09:12:09 2003
++++ fbdev-2.5/drivers/video/fbmem.c   Wed Feb 19 17:18:09 2003
+@@ -41,8 +41,6 @@
+ #include <asm/pgtable.h>
+ 
+ #include <linux/fb.h>
+-#define INCLUDE_LINUX_LOGO_DATA
+-#include <asm/linux_logo.h>
+ 
+ #ifdef CONFIG_FRAMEBUFFER_CONSOLE
+ #include "console/fbcon.h"
+@@ -365,21 +363,23 @@
+ static int ofonly __initdata = 0;
+ #endif
+ 
+-#define LOGO_H      80
+-#define LOGO_W      80
+-
+ static inline unsigned safe_shift(unsigned d, int n)
+ {
+    return n < 0 ? d >> -n : d << n;
+ }
+ 
+-static void __init fb_set_logocmap(struct fb_info *info)
++#ifdef CONFIG_FB_LOGO
++#include <linux/linux_logo.h>
++
++static void __init fb_set_logocmap(struct fb_info *info,
++               const struct linux_logo *logo)
+ {
+    struct fb_cmap palette_cmap;
+    u16 palette_green[16];
+    u16 palette_blue[16];
+    u16 palette_red[16];
+    int i, j, n;
++   const unsigned char *clut = logo->clut;
+ 
+    palette_cmap.start = 0;
+    palette_cmap.len = 16;
+@@ -388,34 +388,32 @@
+    palette_cmap.blue = palette_blue;
+    palette_cmap.transp = NULL;
+ 
+-   for (i = 0; i < LINUX_LOGO_COLORS; i += n) {
+-      n = LINUX_LOGO_COLORS - i;
++   for (i = 0; i < logo->clutsize; i += n) {
++      n = logo->clutsize - i;
+       /* palette_cmap provides space for only 16 colors at once */
+       if (n > 16)
+          n = 16;
+       palette_cmap.start = 32 + i;
+       palette_cmap.len = n;
+       for (j = 0; j < n; ++j) {
+-         palette_cmap.red[j] =
+-            (linux_logo_red[i + j] << 8) |
+-             linux_logo_red[i + j];
+-         palette_cmap.green[j] =
+-            (linux_logo_green[i + j] << 8) |
+-             linux_logo_green[i + j];
+-         palette_cmap.blue[j] =
+-            (linux_logo_blue[i + j] << 8) |
+-             linux_logo_blue[i + j];
++         palette_cmap.red[j] = clut[0] << 8 | clut[0];
++         palette_cmap.green[j] = clut[1] << 8 | clut[1];
++         palette_cmap.blue[j] = clut[2] << 8 | clut[2];
++         clut += 3;
+       }
+       fb_set_cmap(&palette_cmap, 1, info);
+    }
+ }
+ 
+-static void  __init fb_set_logo_truepalette(struct fb_info *info, u32 *palette)
++static void  __init fb_set_logo_truepalette(struct fb_info *info,
++                   const struct linux_logo *logo,
++                   u32 *palette)
+ {
+    unsigned char mask[9] = { 0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff };
+    unsigned char redmask, greenmask, bluemask;
+    int redshift, greenshift, blueshift;
+    int i;
++   const unsigned char *clut = logo->clut;
+ 
+    /*
+     * We have to create a temporary palette sinc