Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / drivers / video / cfbimgblt.c
index 31da88e..51d3538 100644 (file)
@@ -29,7 +29,6 @@
  *  Also need to add code to deal with cards endians that are different than
  *  the native cpu endians. I also need to deal with MSB position in the word.
  */
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/string.h>
 #include <linux/fb.h>
@@ -76,37 +75,28 @@ static u32 cfb_tab32[] = {
 #define FB_WRITEL fb_writel
 #define FB_READL  fb_readl
 
-#if defined (__BIG_ENDIAN)
-#define LEFT_POS(bpp)          (32 - bpp)
-#define SHIFT_HIGH(val, bits)  ((val) >> (bits))
-#define SHIFT_LOW(val, bits)   ((val) << (bits))
-#else
-#define LEFT_POS(bpp)          (0)
-#define SHIFT_HIGH(val, bits)  ((val) << (bits))
-#define SHIFT_LOW(val, bits)   ((val) >> (bits))
-#endif
-
 static inline void color_imageblit(const struct fb_image *image, 
-                                  struct fb_info *p, u8 *dst1, 
+                                  struct fb_info *p, u8 __iomem *dst1, 
                                   u32 start_index,
                                   u32 pitch_index)
 {
        /* Draw the penguin */
-       u32 *dst, *dst2, color = 0, val, shift;
+       u32 __iomem *dst, *dst2;
+       u32 color = 0, val, shift;
        int i, n, bpp = p->var.bits_per_pixel;
        u32 null_bits = 32 - bpp;
        u32 *palette = (u32 *) p->pseudo_palette;
        const u8 *src = image->data;
 
-       dst2 = (u32 *) dst1;
+       dst2 = (u32 __iomem *) dst1;
        for (i = image->height; i--; ) {
                n = image->width;
-               dst = (u32 *) dst1;
+               dst = (u32 __iomem *) dst1;
                shift = 0;
                val = 0;
                
                if (start_index) {
-                       u32 start_mask = ~(SHIFT_HIGH(~(u32)0, start_index));
+                       u32 start_mask = ~(FB_SHIFT_HIGH(~(u32)0, start_index));
                        val = FB_READL(dst) & start_mask;
                        shift = start_index;
                }
@@ -116,27 +106,27 @@ static inline void color_imageblit(const struct fb_image *image,
                                color = palette[*src];
                        else
                                color = *src;
-                       color <<= LEFT_POS(bpp);
-                       val |= SHIFT_HIGH(color, shift);
+                       color <<= FB_LEFT_POS(bpp);
+                       val |= FB_SHIFT_HIGH(color, shift);
                        if (shift >= null_bits) {
                                FB_WRITEL(val, dst++);
        
                                val = (shift == null_bits) ? 0 : 
-                                       SHIFT_LOW(color, 32 - shift);
+                                       FB_SHIFT_LOW(color, 32 - shift);
                        }
                        shift += bpp;
                        shift &= (32 - 1);
                        src++;
                }
                if (shift) {
-                       u32 end_mask = SHIFT_HIGH(~(u32)0, shift);
+                       u32 end_mask = FB_SHIFT_HIGH(~(u32)0, shift);
 
                        FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
                }
                dst1 += p->fix.line_length;
                if (pitch_index) {
                        dst2 += p->fix.line_length;
-                       dst1 = (u8 *)((long)dst2 & ~(sizeof(u32) - 1));
+                       dst1 = (u8 __iomem *)((long __force)dst2 & ~(sizeof(u32) - 1));
 
                        start_index += pitch_index;
                        start_index &= 32 - 1;
@@ -145,30 +135,33 @@ static inline void color_imageblit(const struct fb_image *image,
 }
 
 static inline void slow_imageblit(const struct fb_image *image, struct fb_info *p, 
-                                 u8 *dst1, u32 fgcolor,
+                                 u8 __iomem *dst1, u32 fgcolor,
                                  u32 bgcolor, 
                                  u32 start_index,
                                  u32 pitch_index)
 {
        u32 shift, color = 0, bpp = p->var.bits_per_pixel;
-       u32 *dst, *dst2, val, pitch = p->fix.line_length;
+       u32 __iomem *dst, *dst2;
+       u32 val, pitch = p->fix.line_length;
        u32 null_bits = 32 - bpp;
        u32 spitch = (image->width+7)/8;
        const u8 *src = image->data, *s;
        u32 i, j, l;
        
-       dst2 = (u32 *) dst1;
+       dst2 = (u32 __iomem *) dst1;
+       fgcolor <<= FB_LEFT_POS(bpp);
+       bgcolor <<= FB_LEFT_POS(bpp);
 
        for (i = image->height; i--; ) {
                shift = val = 0;
                l = 8;
                j = image->width;
-               dst = (u32 *) dst1;
+               dst = (u32 __iomem *) dst1;
                s = src;
 
                /* write leading bits */
                if (start_index) {
-                       u32 start_mask = ~(SHIFT_HIGH(~(u32)0, start_index));
+                       u32 start_mask = ~(FB_SHIFT_HIGH(~(u32)0,start_index));
                        val = FB_READL(dst) & start_mask;
                        shift = start_index;
                }
@@ -176,14 +169,13 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
                while (j--) {
                        l--;
                        color = (*s & (1 << l)) ? fgcolor : bgcolor;
-                       color <<= LEFT_POS(bpp);
-                       val |= SHIFT_HIGH(color, shift);
+                       val |= FB_SHIFT_HIGH(color, shift);
                        
                        /* Did the bitshift spill bits to the next long? */
                        if (shift >= null_bits) {
                                FB_WRITEL(val, dst++);
                                val = (shift == null_bits) ? 0 :
-                                        SHIFT_LOW(color,32 - shift);
+                                       FB_SHIFT_LOW(color,32 - shift);
                        }
                        shift += bpp;
                        shift &= (32 - 1);
@@ -192,7 +184,7 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
 
                /* write trailing bits */
                if (shift) {
-                       u32 end_mask = SHIFT_HIGH(~(u32)0, shift);
+                       u32 end_mask = FB_SHIFT_HIGH(~(u32)0, shift);
 
                        FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
                }
@@ -201,7 +193,7 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
                src += spitch;  
                if (pitch_index) {
                        dst2 += pitch;
-                       dst1 = (u8 *)((long)dst2 & ~(sizeof(u32) - 1));
+                       dst1 = (u8 __iomem *)((long __force)dst2 & ~(sizeof(u32) - 1));
                        start_index += pitch_index;
                        start_index &= 32 - 1;
                }
@@ -218,14 +210,14 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
  *           beginning and end of a scanline is dword aligned
  */
 static inline void fast_imageblit(const struct fb_image *image, struct fb_info *p, 
-                                 u8 *dst1, u32 fgcolor, 
+                                 u8 __iomem *dst1, u32 fgcolor, 
                                  u32 bgcolor) 
 {
        u32 fgx = fgcolor, bgx = bgcolor, bpp = p->var.bits_per_pixel;
        u32 ppw = 32/bpp, spitch = (image->width + 7)/8;
        u32 bit_mask, end_mask, eorx, shift;
        const char *s = image->data, *src;
-       u32 *dst;
+       u32 __iomem *dst;
        u32 *tab = NULL;
        int i, j, k;
                
@@ -237,6 +229,7 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info *
                tab = cfb_tab16;
                break;
        case 32:
+       default:
                tab = cfb_tab32;
                break;
        }
@@ -253,7 +246,7 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info *
        k = image->width/ppw;
 
        for (i = image->height; i--; ) {
-               dst = (u32 *) dst1, shift = 8; src = s;
+               dst = (u32 __iomem *) dst1, shift = 8; src = s;
                
                for (j = k; j--; ) {
                        shift -= ppw;
@@ -270,33 +263,13 @@ void cfb_imageblit(struct fb_info *p, const struct fb_image *image)
 {
        u32 fgcolor, bgcolor, start_index, bitstart, pitch_index = 0;
        u32 bpl = sizeof(u32), bpp = p->var.bits_per_pixel;
-       u32 width = image->width, height = image->height; 
+       u32 width = image->width;
        u32 dx = image->dx, dy = image->dy;
-       int x2, y2, vxres, vyres;
-       u8 *dst1;
+       u8 __iomem *dst1;
 
        if (p->state != FBINFO_STATE_RUNNING)
                return;
 
-       vxres = p->var.xres_virtual;
-       vyres = p->var.yres_virtual;
-       /* 
-        * We could use hardware clipping but on many cards you get around
-        * hardware clipping by writing to framebuffer directly like we are
-        * doing here. 
-        */
-       if (image->dx > vxres || image->dy > vyres)
-               return;
-
-       x2 = image->dx + image->width;
-       y2 = image->dy + image->height;
-       dx = image->dx > 0 ? image->dx : 0;
-       dy = image->dy > 0 ? image->dy : 0;
-       x2 = x2 < vxres ? x2 : vxres;
-       y2 = y2 < vyres ? y2 : vyres;
-       width  = x2 - dx;
-       height = y2 - dy;
-
        bitstart = (dy * p->fix.line_length * 8) + (dx * bpp);
        start_index = bitstart & (32 - 1);
        pitch_index = (p->fix.line_length & (bpl - 1)) * 8;
@@ -325,7 +298,7 @@ void cfb_imageblit(struct fb_info *p, const struct fb_image *image)
                else 
                        slow_imageblit(image, p, dst1, fgcolor, bgcolor,
                                        start_index, pitch_index);
-       } else if (image->depth <= bpp) 
+       } else
                color_imageblit(image, p, dst1, start_index, pitch_index);
 }