Commit aa5e715a authored by Richard Henderson's avatar Richard Henderson

[FB] Use u32 instead of unsigned long for cfbimgblt bit ops.

The code that maps bits to pixels is not prepared to handle
a 64-bit long.
parent acdc277a
...@@ -21,13 +21,13 @@ ...@@ -21,13 +21,13 @@
* *
* FIXME * FIXME
* The code for 24 bit is horrible. It copies byte by byte size instead of * The code for 24 bit is horrible. It copies byte by byte size instead of
* longs like the other sizes. Needs to be optimized. * words like the other sizes. Needs to be optimized.
* *
* Tony: * Tony:
* Incorporate mask tables similar to fbcon-cfb*.c in 2.4 API. This speeds * Incorporate mask tables similar to fbcon-cfb*.c in 2.4 API. This speeds
* up the code significantly. * up the code significantly.
* *
* Code for depths not multiples of BITS_PER_LONG is still kludgy, which is * Code for depths not multiples of BITS_PER_WORD is still kludgy, which is
* still processed a bit at a time. * still processed a bit at a time.
* *
* Also need to add code to deal with cards endians that are different than * Also need to add code to deal with cards endians that are different than
...@@ -48,7 +48,11 @@ ...@@ -48,7 +48,11 @@
#define DPRINTK(fmt, args...) #define DPRINTK(fmt, args...)
#endif #endif
static u32 cfb_tab8[] = { /* The following code can *not* handle a 64-bit long. */
#define WORD u32
#define BITS_PER_WORD 32
static WORD const cfb_tab8[] = {
#if defined(__BIG_ENDIAN) #if defined(__BIG_ENDIAN)
0x00000000,0x000000ff,0x0000ff00,0x0000ffff, 0x00000000,0x000000ff,0x0000ff00,0x0000ffff,
0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff, 0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,
...@@ -64,7 +68,7 @@ static u32 cfb_tab8[] = { ...@@ -64,7 +68,7 @@ static u32 cfb_tab8[] = {
#endif #endif
}; };
static u32 cfb_tab16[] = { static WORD const cfb_tab16[] = {
#if defined(__BIG_ENDIAN) #if defined(__BIG_ENDIAN)
0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff
#elif defined(__LITTLE_ENDIAN) #elif defined(__LITTLE_ENDIAN)
...@@ -74,11 +78,11 @@ static u32 cfb_tab16[] = { ...@@ -74,11 +78,11 @@ static u32 cfb_tab16[] = {
#endif #endif
}; };
static u32 cfb_tab32[] = { static WORD const cfb_tab32[] = {
0x00000000, 0xffffffff 0x00000000, 0xffffffff
}; };
#if BITS_PER_LONG == 32 #if BITS_PER_WORD == 32
#define FB_WRITEL fb_writel #define FB_WRITEL fb_writel
#define FB_READL fb_readl #define FB_READL fb_readl
#else #else
...@@ -87,7 +91,7 @@ static u32 cfb_tab32[] = { ...@@ -87,7 +91,7 @@ static u32 cfb_tab32[] = {
#endif #endif
#if defined (__BIG_ENDIAN) #if defined (__BIG_ENDIAN)
#define LEFT_POS(bpp) (BITS_PER_LONG - bpp) #define LEFT_POS(bpp) (BITS_PER_WORD - bpp)
#define NEXT_POS(pos, bpp) ((pos) -= (bpp)) #define NEXT_POS(pos, bpp) ((pos) -= (bpp))
#define SHIFT_HIGH(val, bits) ((val) >> (bits)) #define SHIFT_HIGH(val, bits) ((val) >> (bits))
#define SHIFT_LOW(val, bits) ((val) << (bits)) #define SHIFT_LOW(val, bits) ((val) << (bits))
...@@ -99,25 +103,25 @@ static u32 cfb_tab32[] = { ...@@ -99,25 +103,25 @@ static u32 cfb_tab32[] = {
#endif #endif
static inline void color_imageblit(struct fb_image *image, struct fb_info *p, u8 *dst1, static inline void color_imageblit(struct fb_image *image, struct fb_info *p, u8 *dst1,
unsigned long start_index, unsigned long pitch_index) WORD start_index, WORD pitch_index)
{ {
/* Draw the penguin */ /* Draw the penguin */
int i, n; int i, n;
unsigned long bitmask = SHIFT_LOW(~0UL, BITS_PER_LONG - p->var.bits_per_pixel); WORD bitmask = SHIFT_LOW(~0UL, BITS_PER_WORD - p->var.bits_per_pixel);
unsigned long *palette = (unsigned long *) p->pseudo_palette; u32 *palette = (u32 *) p->pseudo_palette;
unsigned long *dst, *dst2, color = 0, val, shift; WORD *dst, *dst2, color = 0, val, shift;
unsigned long null_bits = BITS_PER_LONG - p->var.bits_per_pixel; WORD null_bits = BITS_PER_WORD - p->var.bits_per_pixel;
u8 *src = image->data; u8 *src = image->data;
dst2 = (unsigned long *) dst1; dst2 = (WORD *) dst1;
for (i = image->height; i--; ) { for (i = image->height; i--; ) {
n = image->width; n = image->width;
dst = (unsigned long *) dst1; dst = (WORD *) dst1;
shift = 0; shift = 0;
val = 0; val = 0;
if (start_index) { if (start_index) {
unsigned long start_mask = ~(SHIFT_HIGH(~0UL, start_index)); WORD start_mask = ~(SHIFT_HIGH(~0UL, start_index));
val = FB_READL(dst) & start_mask; val = FB_READL(dst) & start_mask;
shift = start_index; shift = start_index;
...@@ -134,14 +138,14 @@ static inline void color_imageblit(struct fb_image *image, struct fb_info *p, u8 ...@@ -134,14 +138,14 @@ static inline void color_imageblit(struct fb_image *image, struct fb_info *p, u8
if (shift == null_bits) if (shift == null_bits)
val = 0; val = 0;
else else
val = SHIFT_LOW(color, BITS_PER_LONG - shift); val = SHIFT_LOW(color, BITS_PER_WORD - shift);
} }
shift += p->var.bits_per_pixel; shift += p->var.bits_per_pixel;
shift &= (BITS_PER_LONG - 1); shift &= (BITS_PER_WORD - 1);
src++; src++;
} }
if (shift) { if (shift) {
unsigned long end_mask = SHIFT_HIGH(~0UL, shift); WORD end_mask = SHIFT_HIGH(~0UL, shift);
FB_WRITEL((FB_READL(dst) & end_mask) | val, dst); FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
} }
...@@ -149,35 +153,35 @@ static inline void color_imageblit(struct fb_image *image, struct fb_info *p, u8 ...@@ -149,35 +153,35 @@ static inline void color_imageblit(struct fb_image *image, struct fb_info *p, u8
if (pitch_index) { if (pitch_index) {
dst2 += p->fix.line_length; dst2 += p->fix.line_length;
dst1 = (char *) dst2; dst1 = (char *) dst2;
(unsigned long) dst1 &= ~(sizeof(unsigned long) - 1); (size_t) dst1 &= ~(sizeof(WORD) - 1);
start_index += pitch_index; start_index += pitch_index;
start_index &= BITS_PER_LONG - 1; start_index &= BITS_PER_WORD - 1;
} }
} }
} }
static inline void slow_imageblit(struct fb_image *image, struct fb_info *p, u8 *dst1, static inline void slow_imageblit(struct fb_image *image, struct fb_info *p, u8 *dst1,
unsigned long fgcolor, unsigned long bgcolor, WORD fgcolor, WORD bgcolor,
unsigned long start_index, unsigned long pitch_index) WORD start_index, WORD pitch_index)
{ {
unsigned long i, j, l = 8; WORD i, j, l = 8;
unsigned long shift, color, bpp = p->var.bits_per_pixel; WORD shift, color, bpp = p->var.bits_per_pixel;
unsigned long *dst, *dst2, val, pitch = p->fix.line_length; WORD *dst, *dst2, val, pitch = p->fix.line_length;
unsigned long null_bits = BITS_PER_LONG - bpp; WORD null_bits = BITS_PER_WORD - bpp;
u8 *src = image->data; u8 *src = image->data;
dst2 = (unsigned long *) dst1; dst2 = (WORD *) dst1;
for (i = image->height; i--; ) { for (i = image->height; i--; ) {
shift = 0; shift = 0;
val = 0; val = 0;
j = image->width; j = image->width;
dst = (unsigned long *) dst1; dst = (WORD *) dst1;
/* write leading bits */ /* write leading bits */
if (start_index) { if (start_index) {
unsigned long start_mask = ~(SHIFT_HIGH(~0UL, start_index)); WORD start_mask = ~(SHIFT_HIGH(~0UL, start_index));
val = FB_READL(dst) & start_mask; val = FB_READL(dst) & start_mask;
shift = start_index; shift = start_index;
...@@ -196,15 +200,15 @@ static inline void slow_imageblit(struct fb_image *image, struct fb_info *p, u8 ...@@ -196,15 +200,15 @@ static inline void slow_imageblit(struct fb_image *image, struct fb_info *p, u8
if (shift == null_bits) if (shift == null_bits)
val = 0; val = 0;
else else
val = SHIFT_LOW(color, BITS_PER_LONG - shift); val = SHIFT_LOW(color, BITS_PER_WORD - shift);
} }
shift += bpp; shift += bpp;
shift &= (BITS_PER_LONG - 1); shift &= (BITS_PER_WORD - 1);
if (!l) { l = 8; src++; }; if (!l) { l = 8; src++; };
} }
/* write trailing bits */ /* write trailing bits */
if (shift) { if (shift) {
unsigned long end_mask = SHIFT_HIGH(~0UL, shift); WORD end_mask = SHIFT_HIGH(~0UL, shift);
FB_WRITEL((FB_READL(dst) & end_mask) | val, dst); FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
} }
...@@ -213,24 +217,24 @@ static inline void slow_imageblit(struct fb_image *image, struct fb_info *p, u8 ...@@ -213,24 +217,24 @@ static inline void slow_imageblit(struct fb_image *image, struct fb_info *p, u8
if (pitch_index) { if (pitch_index) {
dst2 += pitch; dst2 += pitch;
dst1 = (char *) dst2; dst1 = (char *) dst2;
(unsigned long) dst1 &= ~(sizeof(unsigned long) - 1); (size_t) dst1 &= ~(sizeof(WORD) - 1);
start_index += pitch_index; start_index += pitch_index;
start_index &= BITS_PER_LONG - 1; start_index &= BITS_PER_WORD - 1;
} }
} }
} }
static inline void fast_imageblit(struct fb_image *image, struct fb_info *p, u8 *dst1, static inline void fast_imageblit(struct fb_image *image, struct fb_info *p, u8 *dst1,
unsigned long fgcolor, unsigned long bgcolor) WORD fgcolor, WORD bgcolor)
{ {
int i, j, k, l = 8, n; int i, j, k, l = 8, n;
unsigned long bit_mask, end_mask, eorx; WORD bit_mask, end_mask, eorx;
unsigned long fgx = fgcolor, bgx = bgcolor, pad, bpp = p->var.bits_per_pixel; WORD fgx = fgcolor, bgx = bgcolor, pad, bpp = p->var.bits_per_pixel;
unsigned long tmp = (1 << bpp) - 1; WORD tmp = (1 << bpp) - 1;
unsigned long ppw = BITS_PER_LONG/bpp, ppos; WORD ppw = BITS_PER_WORD/bpp, ppos;
unsigned long *dst; WORD *dst;
u32 *tab = NULL; u32 *tab = NULL;
char *src = image->data; char *src = image->data;
...@@ -263,7 +267,7 @@ static inline void fast_imageblit(struct fb_image *image, struct fb_info *p, u8 ...@@ -263,7 +267,7 @@ static inline void fast_imageblit(struct fb_image *image, struct fb_info *p, u8
k = image->width/ppw; k = image->width/ppw;
for (i = image->height; i--; ) { for (i = image->height; i--; ) {
dst = (unsigned long *) dst1; dst = (WORD *) dst1;
for (j = k; j--; ) { for (j = k; j--; ) {
l -= ppw; l -= ppw;
...@@ -291,8 +295,8 @@ static inline void fast_imageblit(struct fb_image *image, struct fb_info *p, u8 ...@@ -291,8 +295,8 @@ static inline void fast_imageblit(struct fb_image *image, struct fb_info *p, u8
void cfb_imageblit(struct fb_info *p, struct fb_image *image) void cfb_imageblit(struct fb_info *p, struct fb_image *image)
{ {
int x2, y2, vxres, vyres; int x2, y2, vxres, vyres;
unsigned long fgcolor, bgcolor, start_index, bitstart, pitch_index = 0; WORD fgcolor, bgcolor, start_index, bitstart, pitch_index = 0;
unsigned long bpl = sizeof(unsigned long), bpp = p->var.bits_per_pixel; WORD bpl = sizeof(WORD), bpp = p->var.bits_per_pixel;
u8 *dst1; u8 *dst1;
vxres = p->var.xres_virtual; vxres = p->var.xres_virtual;
...@@ -315,7 +319,7 @@ void cfb_imageblit(struct fb_info *p, struct fb_image *image) ...@@ -315,7 +319,7 @@ void cfb_imageblit(struct fb_info *p, struct fb_image *image)
image->height = y2 - image->dy; image->height = y2 - image->dy;
bitstart = (image->dy * p->fix.line_length * 8) + (image->dx * bpp); bitstart = (image->dy * p->fix.line_length * 8) + (image->dx * bpp);
start_index = bitstart & (BITS_PER_LONG - 1); start_index = bitstart & (BITS_PER_WORD - 1);
pitch_index = (p->fix.line_length & (bpl - 1)) * 8; pitch_index = (p->fix.line_length & (bpl - 1)) * 8;
bitstart /= 8; bitstart /= 8;
...@@ -332,7 +336,7 @@ void cfb_imageblit(struct fb_info *p, struct fb_image *image) ...@@ -332,7 +336,7 @@ void cfb_imageblit(struct fb_info *p, struct fb_image *image)
bgcolor = image->bg_color; bgcolor = image->bg_color;
} }
if (BITS_PER_LONG % bpp == 0 && !start_index && !pitch_index && if (BITS_PER_WORD % bpp == 0 && !start_index && !pitch_index &&
bpp >= 8 && bpp <= 32 && (image->width & 7) == 0) bpp >= 8 && bpp <= 32 && (image->width & 7) == 0)
fast_imageblit(image, p, dst1, fgcolor, bgcolor); fast_imageblit(image, p, dst1, fgcolor, bgcolor);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment