From: James S. <jsi...@us...> - 2002-05-10 16:27:26
|
Update of /cvsroot/linuxconsole/ruby/linux/drivers/video In directory usw-pr-cvs1:/tmp/cvs-serv30693 Modified Files: cfbcopyarea.c cfbfillrect.c cfbimgblt.c Log Message: Updates and fixes for the soft accel functions. Index: cfbcopyarea.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/video/cfbcopyarea.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- cfbcopyarea.c 23 Mar 2002 00:22:58 -0000 1.6 +++ cfbcopyarea.c 10 May 2002 16:27:23 -0000 1.7 @@ -26,19 +26,21 @@ #include <linux/slab.h> #include <asm/types.h> #include <asm/io.h> +#include <video/fbcon.h> -void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area) +void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area) { - unsigned long start_index, end_index, start_mask, end_mask, last, tmp, height; - int x2, y2, n, j, lineincr, shift, shift_right, shift_left, old_dx, old_dy; - int linesize = p->fix.line_length, bpl = sizeof(unsigned long); + int x2, y2, lineincr, shift, shift_right, shift_left, old_dx, old_dy; + int n, j, linesize = p->fix.line_length, bpl = sizeof(unsigned long); + unsigned long start_index, end_index, start_mask, end_mask, last; unsigned long *dst = NULL, *src = NULL; - char *src1,*dst1; - + char *src1, *dst1; + int tmp, height; + /* clip the destination */ old_dx = area->dx; old_dy = area->dy; - + /* * We could use hardware clipping but on many cards you get around * hardware clipping by writing to framebuffer directly. @@ -51,54 +53,56 @@ y2 = y2 < p->var.yres_virtual ? y2 : p->var.yres_virtual; area->width = x2 - area->dx; area->height = y2 - area->dy; - + /* update sx1,sy1 */ area->sx += (area->dx - old_dx); area->sy += (area->dy - old_dy); - + height = area->height; /* the source must be completely inside the virtual screen */ if (area->sx < 0 || area->sy < 0 || - (area->sx + area->width) > p->var.xres_virtual || - (area->sy + area->height) > p->var.yres_virtual) + (area->sx + area->width) > p->var.xres_virtual || + (area->sy + area->height) > p->var.yres_virtual) return; - - if (area->dy < area->sy || (area->dy == area->sy && area->dx < area->sx)) { + + if (area->dy < area->sy + || (area->dy == area->sy && area->dx < area->sx)) { /* start at the top */ - src1 = p->screen_base + area->sy * linesize + - ((area->sx * p->var.bits_per_pixel) >> 3); + src1 = p->screen_base + area->sy * linesize + + ((area->sx * p->var.bits_per_pixel) >> 3); dst1 = p->screen_base + area->dy * linesize + - ((area->dx * p->var.bits_per_pixel) >> 3); + ((area->dx * p->var.bits_per_pixel) >> 3); lineincr = linesize; } else { /* start at the bottom */ - src1 = p->screen_base + (area->sy + area->height-1)*linesize + - (((area->sx + area->width - 1) * p->var.bits_per_pixel) >> 3); - dst1 = p->screen_base + (area->dy + area->height-1)*linesize + - (((area->dx + area->width - 1) * p->var.bits_per_pixel) >> 3); + src1 = p->screen_base + (area->sy + area->height-1) * linesize + + (((area->sx + area->width - 1) * p->var.bits_per_pixel) >> 3); + dst1 = p->screen_base + (area->dy + area->height-1) * linesize + + (((area->dx + area->width - 1) * p->var.bits_per_pixel) >> 3); lineincr = -linesize; } - + if ((BITS_PER_LONG % p->var.bits_per_pixel) == 0) { - int ppw = BITS_PER_LONG/p->var.bits_per_pixel; - int n = ((area->width * p->var.bits_per_pixel) >> 3); + int ppw = BITS_PER_LONG / p->var.bits_per_pixel; + int n = ((area->width * p->var.bits_per_pixel) >> 3); - start_index = ((unsigned long) src1 & (bpl-1)); - end_index = ((unsigned long) (src1 + n) & (bpl-1)); - shift = ((unsigned long)dst1 & (bpl-1)) - ((unsigned long) src1 & (bpl-1)); + start_index = ((unsigned long) src1 & (bpl - 1)); + end_index = ((unsigned long) (src1 + n) & (bpl - 1)); + shift = ((unsigned long) dst1 & (bpl - 1)) - + ((unsigned long) src1 & (bpl - 1)); start_mask = end_mask = 0; - - if (start_index) { + + if (start_index) { start_mask = -1 >> (start_index << 3); n -= (bpl - start_index); } - + if (end_index) { end_mask = -1 << ((bpl - end_index) << 3); n -= end_index; - } - n = n/bpl; + } + n = n / bpl; if (n <= 0) { if (start_mask) { @@ -114,12 +118,16 @@ if (shift) { if (shift > 0) { /* dest is over to right more */ - shift_right = shift * p->var.bits_per_pixel; - shift_left = (ppw - shift) * p->var.bits_per_pixel; + shift_right = + shift * p->var.bits_per_pixel; + shift_left = + (ppw - shift) * p->var.bits_per_pixel; } else { /* source is to the right more */ - shift_right = (ppw + shift) * p->var.bits_per_pixel; - shift_left = -shift * p->var.bits_per_pixel; + shift_right = + (ppw + shift) * p->var.bits_per_pixel; + shift_left = + -shift * p->var.bits_per_pixel; } /* general case, positive increment */ if (lineincr > 0) { @@ -137,8 +145,7 @@ dst++; tmp = fb_readl(src); src++; - fb_writel((last << shift_left) | - (tmp >> shift_right),dst); + fb_writel((last << shift_left) | (tmp >> shift_right), dst); last = tmp; src++; } @@ -162,8 +169,7 @@ dst--; tmp = fb_readl(src); src--; - fb_writel((tmp << shift_left) | - (last >> shift_right),dst); + fb_writel((tmp << shift_left) | (last >> shift_right), dst); last = tmp; src--; } @@ -175,24 +181,24 @@ } else { /* no shift needed */ if (lineincr > 0) { - /* positive increment */ + /* positive increment */ do { dst = (unsigned long *) (dst1 - start_index); src = (unsigned long *) (src1 - start_index); - - if (start_mask) + + if (start_mask) fb_writel(fb_readl(src) | start_mask, dst); - - for (j = 0; j < n; j++) { - fb_writel(fb_readl(src), dst); + + for (j = 0; j < n; j++) { + fb_writel(fb_readl(src), dst); dst++; src++; } - + if (end_mask) - fb_writel(fb_readl(src) | end_mask,dst); - src1 += lineincr; - dst1 += lineincr; + fb_writel(fb_readl(src) | end_mask, dst); + src1 += lineincr; + dst1 += lineincr; } while (--height); } else { /* negative increment */ @@ -202,8 +208,8 @@ if (start_mask) fb_writel(fb_readl(src) | start_mask, dst); - for (j = 0; j < n; j++) { - fb_writel(fb_readl(src), dst); + for (j = 0; j < n; j++) { + fb_writel(fb_readl(src), dst); dst--; src--; } Index: cfbfillrect.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/video/cfbfillrect.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- cfbfillrect.c 6 May 2002 19:04:28 -0000 1.10 +++ cfbfillrect.c 10 May 2002 16:27:23 -0000 1.11 @@ -22,17 +22,18 @@ #include <asm/types.h> #include <video/fbcon.h> -void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect) +void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect) { unsigned long start_index, end_index, start_mask = 0, end_mask = 0; unsigned long height, ppw, fg, fgcolor; int i, n, x2, y2, linesize = p->fix.line_length; - int bpl = sizeof(unsigned long); + int bpl = sizeof(unsigned long); unsigned long *dst; - char *dst1; + char *dst1; + + if (!rect->width || !rect->height) + return; - if (!rect->width || !rect->height) return; - /* We could use hardware clipping but on many cards you get around * hardware clipping by writing to framebuffer directly. */ x2 = rect->dx + rect->width; @@ -42,79 +43,84 @@ rect->width = x2 - rect->dx; height = y2 - rect->dy; - /* Size of the scanline in bytes */ - n = (rect->width * (p->var.bits_per_pixel >> 3)); - ppw = BITS_PER_LONG/p->var.bits_per_pixel; + /* Size of the scanline in bytes */ + n = (rect->width * (p->var.bits_per_pixel >> 3)); + ppw = BITS_PER_LONG / p->var.bits_per_pixel; - dst1 = p->screen_base + (rect->dy * linesize) + (rect->dx * (p->var.bits_per_pixel >> 3)); - start_index = ((unsigned long) dst1 & (bpl-1)); - end_index = ((unsigned long)(dst1 + n) & (bpl-1)); + dst1 = p->screen_base + (rect->dy * linesize) + + (rect->dx * (p->var.bits_per_pixel >> 3)); + start_index = ((unsigned long) dst1 & (bpl - 1)); + end_index = ((unsigned long) (dst1 + n) & (bpl - 1)); - if (p->fix.visual == FB_VISUAL_TRUECOLOR) - fg = fgcolor = ((u32 *)(p->pseudo_palette))[rect->color]; - else + if (p->fix.visual == FB_VISUAL_TRUECOLOR) + fg = fgcolor = ((u32 *) (p->pseudo_palette))[rect->color]; + else fg = fgcolor = rect->color; - - for (i = 0; i < ppw-1; i++) { + + for (i = 0; i < ppw - 1; i++) { fg <<= p->var.bits_per_pixel; - fg |= fgcolor; + fg |= fgcolor; } if (start_index) { start_mask = fg << (start_index << 3); n -= (bpl - start_index); } - + if (end_index) { end_mask = fg >> ((bpl - end_index) << 3); n -= end_index; } - n = n/bpl; + n = n / bpl; if (n <= 0) { if (start_mask) { - if (end_mask) + if (end_mask) end_mask &= start_mask; - else + else end_mask = start_mask; start_mask = 0; } - n = 0; + n = 0; } if ((BITS_PER_LONG % p->var.bits_per_pixel) == 0) { switch (rect->rop) { - case ROP_COPY: + case ROP_COPY: do { /* Word align to increases performace :-) */ dst = (unsigned long *) (dst1 - start_index); - + if (start_mask) { #if BITS_PER_LONG == 32 - fb_writel(fb_readl(dst) | start_mask, dst); + fb_writel(fb_readl(dst) | + start_mask, dst); #else - fb_writeq(fb_readq(dst) | start_mask, dst); + fb_writeq(fb_readq(dst) | + start_mask, dst); #endif dst++; } - - for ( i=0; i < n; i++) { + + for (i = 0; i < n; i++) { #if BITS_PER_LONG == 32 fb_writel(fg, dst); #else fb_writeq(fg, dst); #endif - dst++; + dst++; } if (end_mask) #if BITS_PER_LONG == 32 - fb_writel(fb_readl(dst) | end_mask, dst); + fb_writel(fb_readl(dst) | end_mask, + dst); #else - fb_writeq(fb_readq(dst) | end_mask, dst); + fb_writeq(fb_readq(dst) | end_mask, + dst); #endif - dst1+=linesize; + dst1 += linesize; } while (--height); break; case ROP_XOR: @@ -123,30 +129,34 @@ if (start_mask) { #if BITS_PER_LONG == 32 - fb_writel(fb_readl(dst) ^ start_mask, dst); + fb_writel(fb_readl(dst) ^ + start_mask, dst); #else - fb_writeq(fb_readq(dst) ^ start_mask, dst); + fb_writeq(fb_readq(dst) ^ + start_mask, dst); #endif dst++; } - for( i=0; i < n; i++) { + for (i = 0; i < n; i++) { #if BITS_PER_LONG == 32 - fb_writel(fb_readl(dst) ^ fg, dst); + fb_writel(fb_readl(dst) ^ fg, dst); #else - fb_writeq(fb_readq(dst) ^ fg, dst); + fb_writeq(fb_readq(dst) ^ fg, dst); #endif dst++; } - + if (end_mask) { #if BITS_PER_LONG == 32 - fb_writel(fb_readl(dst) ^ end_mask, dst); + fb_writel(fb_readl(dst) ^ end_mask, + dst); #else - fb_writeq(fb_readq(dst) ^ end_mask, dst); + fb_writeq(fb_readq(dst) ^ end_mask, + dst); #endif } - dst1+=linesize; + dst1 += linesize; } while (--height); break; } @@ -156,38 +166,44 @@ end_mask = fg << (end_index * p->var.bits_per_pixel); /* start_mask =& PFILL24(x1,fg); end_mask_or = end_mask & PFILL24(x1+width-1,fg); */ - - n = (rect->width - start_index - end_index)/ppw; - + + n = (rect->width - start_index - end_index) / ppw; + switch (rect->rop) { - case ROP_COPY: + case ROP_COPY: do { - dst = (unsigned long *)dst1; - if (start_mask) *dst |= start_mask; - if ((start_index + rect->width) > ppw) dst++; + dst = (unsigned long *) dst1; + if (start_mask) + *dst |= start_mask; + if ((start_index + rect->width) > ppw) + dst++; /* XXX: slow */ - for (i = 0;i < n; i++) { + for (i = 0; i < n; i++) { *dst++ = fg; } - if (end_mask) *dst |= end_mask; - dst1+=linesize; + if (end_mask) + *dst |= end_mask; + dst1 += linesize; } while (--height); break; case ROP_XOR: do { - dst = (unsigned long *)dst1; - if (start_mask) *dst ^= start_mask; - if ((start_mask + rect->width) > ppw) dst++; - - for( i = 0; i < n; i++) { - *dst++ ^= fg; /* PFILL24(fg,x1+i); */ + dst = (unsigned long *) dst1; + if (start_mask) + *dst ^= start_mask; + if ((start_mask + rect->width) > ppw) + dst++; + + for (i = 0; i < n; i++) { + *dst++ ^= fg; /* PFILL24(fg,x1+i); */ } - if (end_mask) *dst ^= end_mask; - dst1+=linesize; + if (end_mask) + *dst ^= end_mask; + dst1 += linesize; } while (--height); break; - } + } } - return; + return; } Index: cfbimgblt.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/video/cfbimgblt.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- cfbimgblt.c 23 Mar 2002 00:22:58 -0000 1.10 +++ cfbimgblt.c 10 May 2002 16:27:23 -0000 1.11 @@ -31,6 +31,8 @@ #include <linux/fb.h> #include <asm/types.h> +#include <video/fbcon.h> + #define DEBUG #ifdef DEBUG @@ -43,11 +45,11 @@ { int ppw, shift, shift_right, shift_left, x2, y2, n, i, j, k, l = 7; unsigned long tmp = ~0 << (BITS_PER_LONG - p->var.bits_per_pixel); - unsigned long fgx, bgx, fgcolor, bgcolor, eorx; + unsigned long fgx, bgx, fgcolor, bgcolor, eorx; unsigned long end_index, end_mask, mask; unsigned long *dst = NULL; - u8 *dst1, *src; - + u8 *dst1, src; + /* * We could use hardware clipping but on many cards you get around hardware * clipping by writing to framebuffer directly like we are doing here. @@ -58,48 +60,58 @@ image->dy = image->dy > 0 ? image->dy : 0; x2 = x2 < p->var.xres_virtual ? x2 : p->var.xres_virtual; y2 = y2 < p->var.yres_virtual ? y2 : p->var.yres_virtual; - image->width = x2 - image->dx; + image->width = x2 - image->dx; image->height = y2 - image->dy; - - dst1 = p->screen_base + image->dy * p->fix.line_length + - ((image->dx * p->var.bits_per_pixel) >> 3); - - ppw = BITS_PER_LONG/p->var.bits_per_pixel; - src = image->data; + dst1 = p->screen_base + image->dy * p->fix.line_length + + ((image->dx * p->var.bits_per_pixel) >> 3); - if (p->fix.visual == FB_VISUAL_TRUECOLOR) { - fgx = fgcolor = ((u32 *)(p->pseudo_palette))[image->fg_color]; - bgx = bgcolor = ((u32 *)(p->pseudo_palette))[image->bg_color]; - } else { - fgx = fgcolor = image->fg_color; - bgx = bgcolor = image->bg_color; - } - - for (i = 0; i < ppw-1; i++) { - fgx <<= p->var.bits_per_pixel; - bgx <<= p->var.bits_per_pixel; - fgx |= fgcolor; - bgx |= bgcolor; - } - eorx = fgx ^ bgx; - l = 7; + ppw = BITS_PER_LONG / p->var.bits_per_pixel; - for (i = 0; i < image->height; i++) { - dst = (unsigned long *) dst1; - - for (j = image->width/ppw; j > 0; j--) { - mask = 0; - - for (k = ppw; k > 0; k--) { - if (test_bit(l, src)) - mask |= (tmp >> (p->var.bits_per_pixel*(k-1))); - l--; + src = image->data; + + n = ((image->width + 7) >> 3); + pad = n - image->width; + + if (image->depth == 1) { + if (p->fix.visual == FB_VISUAL_TRUECOLOR) { + fgx = fgcolor = + ((u32 *) (p->pseudo_palette))[image->fg_color]; + bgx = bgcolor = + ((u32 *) (p->pseudo_palette))[image->bg_color]; + } else { + fgx = fgcolor = image->fg_color; + bgx = bgcolor = image->bg_color; + } + + for (i = 0; i < ppw - 1; i++) { + fgx <<= p->var.bits_per_pixel; + bgx <<= p->var.bits_per_pixel; + fgx |= fgcolor; + bgx |= bgcolor; + } + eorx = fgx ^ bgx; + + for (i = 0; i < image->height; i++) { + dst = (unsigned long *) dst1; + + if (ppw >= image->width) { + for (j = image->width / ppw; j > 0; j--) { + mask = 0; + + for (k = ppw; k > 0; k--) { + if (test_bit(l, src)) + mask |= (tmp >> (p->var.bits_per_pixel * (k - 1))); + l--; + if (l < 0) { l = 7; src++; } + } + fb_writel((mask & eorx) ^ bgx, dst); + dst++; + } + l = -pad; if (l < 0) { l = 7; src++; } + dst1 += p->fix.line_length; } - fb_writel((mask & eorx)^bgx, dst); - dst++; } - dst1 += p->fix.line_length; - } + } } |