fb: add hooks to handle KDB enter/exit
[sfrench/cifs-2.6.git] / drivers / video / cfbimgblt.c
index 261004473c8e76b8e446317a7dfec8bbb9342517..baed57d3cfff38e53a9ea37fff3b82e943ba77cd 100644 (file)
 #include <linux/string.h>
 #include <linux/fb.h>
 #include <asm/types.h>
+#include "fb_draw.h"
 
 #define DEBUG
 
 #ifdef DEBUG
-#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt,__FUNCTION__,## args)
+#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt,__func__,## args)
 #else
 #define DPRINTK(fmt, args...)
 #endif
 
-static const u32 cfb_tab8[] = {
-#if defined(__BIG_ENDIAN)
+static const u32 cfb_tab8_be[] = {
     0x00000000,0x000000ff,0x0000ff00,0x0000ffff,
     0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,
     0xff000000,0xff0000ff,0xff00ff00,0xff00ffff,
     0xffff0000,0xffff00ff,0xffffff00,0xffffffff
-#elif defined(__LITTLE_ENDIAN)
+};
+
+static const u32 cfb_tab8_le[] = {
     0x00000000,0xff000000,0x00ff0000,0xffff0000,
     0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00,
     0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff,
     0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff
-#else
-#error FIXME: No endianness??
-#endif
 };
 
-static const u32 cfb_tab16[] = {
-#if defined(__BIG_ENDIAN)
+static const u32 cfb_tab16_be[] = {
     0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff
-#elif defined(__LITTLE_ENDIAN)
+};
+
+static const u32 cfb_tab16_le[] = {
     0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff
-#else
-#error FIXME: No endianness??
-#endif
 };
 
 static const u32 cfb_tab32[] = {
@@ -87,6 +84,7 @@ static inline void color_imageblit(const struct fb_image *image,
        u32 null_bits = 32 - bpp;
        u32 *palette = (u32 *) p->pseudo_palette;
        const u8 *src = image->data;
+       u32 bswapmask = fb_compute_bswapmask(p);
 
        dst2 = (u32 __iomem *) dst1;
        for (i = image->height; i--; ) {
@@ -96,7 +94,8 @@ static inline void color_imageblit(const struct fb_image *image,
                val = 0;
                
                if (start_index) {
-                       u32 start_mask = ~(FB_SHIFT_HIGH(~(u32)0, start_index));
+                       u32 start_mask = ~fb_shifted_pixels_mask_u32(p,
+                                               start_index, bswapmask);
                        val = FB_READL(dst) & start_mask;
                        shift = start_index;
                }
@@ -106,20 +105,21 @@ static inline void color_imageblit(const struct fb_image *image,
                                color = palette[*src];
                        else
                                color = *src;
-                       color <<= FB_LEFT_POS(bpp);
-                       val |= FB_SHIFT_HIGH(color, shift);
+                       color <<= FB_LEFT_POS(p, bpp);
+                       val |= FB_SHIFT_HIGH(p, color, shift ^ bswapmask);
                        if (shift >= null_bits) {
                                FB_WRITEL(val, dst++);
        
                                val = (shift == null_bits) ? 0 : 
-                                       FB_SHIFT_LOW(color, 32 - shift);
+                                       FB_SHIFT_LOW(p, color, 32 - shift);
                        }
                        shift += bpp;
                        shift &= (32 - 1);
                        src++;
                }
                if (shift) {
-                       u32 end_mask = FB_SHIFT_HIGH(~(u32)0, shift);
+                       u32 end_mask = fb_shifted_pixels_mask_u32(p, shift,
+                                               bswapmask);
 
                        FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
                }
@@ -147,10 +147,11 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
        u32 spitch = (image->width+7)/8;
        const u8 *src = image->data, *s;
        u32 i, j, l;
-       
+       u32 bswapmask = fb_compute_bswapmask(p);
+
        dst2 = (u32 __iomem *) dst1;
-       fgcolor <<= FB_LEFT_POS(bpp);
-       bgcolor <<= FB_LEFT_POS(bpp);
+       fgcolor <<= FB_LEFT_POS(p, bpp);
+       bgcolor <<= FB_LEFT_POS(p, bpp);
 
        for (i = image->height; i--; ) {
                shift = val = 0;
@@ -161,7 +162,8 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
 
                /* write leading bits */
                if (start_index) {
-                       u32 start_mask = ~(FB_SHIFT_HIGH(~(u32)0,start_index));
+                       u32 start_mask = ~fb_shifted_pixels_mask_u32(p,
+                                               start_index, bswapmask);
                        val = FB_READL(dst) & start_mask;
                        shift = start_index;
                }
@@ -169,13 +171,13 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
                while (j--) {
                        l--;
                        color = (*s & (1 << l)) ? fgcolor : bgcolor;
-                       val |= FB_SHIFT_HIGH(color, shift);
+                       val |= FB_SHIFT_HIGH(p, color, shift ^ bswapmask);
                        
                        /* Did the bitshift spill bits to the next long? */
                        if (shift >= null_bits) {
                                FB_WRITEL(val, dst++);
                                val = (shift == null_bits) ? 0 :
-                                       FB_SHIFT_LOW(color,32 - shift);
+                                       FB_SHIFT_LOW(p, color, 32 - shift);
                        }
                        shift += bpp;
                        shift &= (32 - 1);
@@ -184,7 +186,8 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
 
                /* write trailing bits */
                if (shift) {
-                       u32 end_mask = FB_SHIFT_HIGH(~(u32)0, shift);
+                       u32 end_mask = fb_shifted_pixels_mask_u32(p, shift,
+                                               bswapmask);
 
                        FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
                }
@@ -220,13 +223,13 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info *
        u32 __iomem *dst;
        const u32 *tab = NULL;
        int i, j, k;
-               
+
        switch (bpp) {
        case 8:
-               tab = cfb_tab8;
+               tab = fb_be_math(p) ? cfb_tab8_be : cfb_tab8_le;
                break;
        case 16:
-               tab = cfb_tab16;
+               tab = fb_be_math(p) ? cfb_tab16_be : cfb_tab16_le;
                break;
        case 32:
        default: