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 @@
*
* FIXME
* 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:
* Incorporate mask tables similar to fbcon-cfb*.c in 2.4 API. This speeds
* 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.
*
* Also need to add code to deal with cards endians that are different than
......@@ -48,7 +48,11 @@
#define DPRINTK(fmt, args...)
#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)
0x00000000,0x000000ff,0x0000ff00,0x0000ffff,
0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,
......@@ -64,7 +68,7 @@ static u32 cfb_tab8[] = {
#endif
};
static u32 cfb_tab16[] = {
static WORD const cfb_tab16[] = {
#if defined(__BIG_ENDIAN)
0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff
#elif defined(__LITTLE_ENDIAN)
......@@ -74,11 +78,11 @@ static u32 cfb_tab16[] = {
#endif
};
static u32 cfb_tab32[] = {
static WORD const cfb_tab32[] = {
0x00000000, 0xffffffff
};
#if BITS_PER_LONG == 32
#if BITS_PER_WORD == 32
#define FB_WRITEL fb_writel
#define FB_READL fb_readl
#else
......@@ -87,7 +91,7 @@ static u32 cfb_tab32[] = {
#endif
#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 SHIFT_HIGH(val, bits) ((val) >> (bits))
#define SHIFT_LOW(val, bits) ((val) << (bits))
......@@ -99,25 +103,25 @@ static u32 cfb_tab32[] = {
#endif
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 */
int i, n;
unsigned long bitmask = SHIFT_LOW(~0UL, BITS_PER_LONG - p->var.bits_per_pixel);
unsigned long *palette = (unsigned long *) p->pseudo_palette;
unsigned long *dst, *dst2, color = 0, val, shift;
unsigned long null_bits = BITS_PER_LONG - p->var.bits_per_pixel;
WORD bitmask = SHIFT_LOW(~0UL, BITS_PER_WORD - p->var.bits_per_pixel);
u32 *palette = (u32 *) p->pseudo_palette;
WORD *dst, *dst2, color = 0, val, shift;
WORD null_bits = BITS_PER_WORD - p->var.bits_per_pixel;
u8 *src = image->data;
dst2 = (unsigned long *) dst1;
dst2 = (WORD *) dst1;
for (i = image->height; i--; ) {
n = image->width;
dst = (unsigned long *) dst1;
dst = (WORD *) dst1;
shift = 0;
val = 0;
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;
shift = start_index;
......@@ -134,14 +138,14 @@ static inline void color_imageblit(struct fb_image *image, struct fb_info *p, u8
if (shift == null_bits)
val = 0;
else
val = SHIFT_LOW(color, BITS_PER_LONG - shift);
val = SHIFT_LOW(color, BITS_PER_WORD - shift);
}
shift += p->var.bits_per_pixel;
shift &= (BITS_PER_LONG - 1);
shift &= (BITS_PER_WORD - 1);
src++;
}
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);
}
......@@ -149,35 +153,35 @@ static inline void color_imageblit(struct fb_image *image, struct fb_info *p, u8
if (pitch_index) {
dst2 += p->fix.line_length;
dst1 = (char *) dst2;
(unsigned long) dst1 &= ~(sizeof(unsigned long) - 1);
(size_t) dst1 &= ~(sizeof(WORD) - 1);
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,
unsigned long fgcolor, unsigned long bgcolor,
unsigned long start_index, unsigned long pitch_index)
WORD fgcolor, WORD bgcolor,
WORD start_index, WORD pitch_index)
{
unsigned long i, j, l = 8;
unsigned long shift, color, bpp = p->var.bits_per_pixel;
unsigned long *dst, *dst2, val, pitch = p->fix.line_length;
unsigned long null_bits = BITS_PER_LONG - bpp;
WORD i, j, l = 8;
WORD shift, color, bpp = p->var.bits_per_pixel;
WORD *dst, *dst2, val, pitch = p->fix.line_length;
WORD null_bits = BITS_PER_WORD - bpp;
u8 *src = image->data;
dst2 = (unsigned long *) dst1;
dst2 = (WORD *) dst1;
for (i = image->height; i--; ) {
shift = 0;
val = 0;
j = image->width;
dst = (unsigned long *) dst1;
dst = (WORD *) dst1;
/* write leading bits */
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;
shift = start_index;
......@@ -196,15 +200,15 @@ static inline void slow_imageblit(struct fb_image *image, struct fb_info *p, u8
if (shift == null_bits)
val = 0;
else
val = SHIFT_LOW(color, BITS_PER_LONG - shift);
val = SHIFT_LOW(color, BITS_PER_WORD - shift);
}
shift += bpp;
shift &= (BITS_PER_LONG - 1);
shift &= (BITS_PER_WORD - 1);
if (!l) { l = 8; src++; };
}
/* write trailing bits */
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);
}
......@@ -213,24 +217,24 @@ static inline void slow_imageblit(struct fb_image *image, struct fb_info *p, u8
if (pitch_index) {
dst2 += pitch;
dst1 = (char *) dst2;
(unsigned long) dst1 &= ~(sizeof(unsigned long) - 1);
(size_t) dst1 &= ~(sizeof(WORD) - 1);
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,
unsigned long fgcolor, unsigned long bgcolor)
WORD fgcolor, WORD bgcolor)
{
int i, j, k, l = 8, n;
unsigned long bit_mask, end_mask, eorx;
unsigned long fgx = fgcolor, bgx = bgcolor, pad, bpp = p->var.bits_per_pixel;
unsigned long tmp = (1 << bpp) - 1;
unsigned long ppw = BITS_PER_LONG/bpp, ppos;
unsigned long *dst;
WORD bit_mask, end_mask, eorx;
WORD fgx = fgcolor, bgx = bgcolor, pad, bpp = p->var.bits_per_pixel;
WORD tmp = (1 << bpp) - 1;
WORD ppw = BITS_PER_WORD/bpp, ppos;
WORD *dst;
u32 *tab = NULL;
char *src = image->data;
......@@ -263,7 +267,7 @@ static inline void fast_imageblit(struct fb_image *image, struct fb_info *p, u8
k = image->width/ppw;
for (i = image->height; i--; ) {
dst = (unsigned long *) dst1;
dst = (WORD *) dst1;
for (j = k; j--; ) {
l -= ppw;
......@@ -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)
{
int x2, y2, vxres, vyres;
unsigned long fgcolor, bgcolor, start_index, bitstart, pitch_index = 0;
unsigned long bpl = sizeof(unsigned long), bpp = p->var.bits_per_pixel;
WORD fgcolor, bgcolor, start_index, bitstart, pitch_index = 0;
WORD bpl = sizeof(WORD), bpp = p->var.bits_per_pixel;
u8 *dst1;
vxres = p->var.xres_virtual;
......@@ -315,7 +319,7 @@ void cfb_imageblit(struct fb_info *p, struct fb_image *image)
image->height = y2 - image->dy;
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;
bitstart /= 8;
......@@ -332,7 +336,7 @@ void cfb_imageblit(struct fb_info *p, struct fb_image *image)
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)
fast_imageblit(image, p, dst1, fgcolor, bgcolor);
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