cfb_{copyarea,fillrect}()

3 messages, 2 authors, 2002-07-05 · open the first message on its own page

cfb_{copyarea,fillrect}()

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2002-07-02 11:39:26

	Hi,

This (untested) patch replaces the #if/#else/#endif clutter in cfb_fillrect()
with one #if/#else/#endif clause at the top of the file.

It also adds 64-bit support to cfb_copyarea().

Other comments/notes:

  - Shouldn't cfb_fillrect() use the pseudo_palette in DIRECTCOLOR mode?

  - I think the cfb_*() routines can easily be modified to work for bpp < 8,
    and for bpp == 24:
      o initialize src/dst indices to be bit indices instead of byte indices
      o remove shifts by 3
      o n is number of bits to copy/fill

  - I think that line length is not guaranteed to be a multiple of
    sizeof(unsigned long). Hence a different start/end mask per line is
    possible as well.

James: keep up the great work!
--- linux-2.5.24/drivers/video/cfbcopyarea.c	Fri Jun  7 11:06:41 2002
+++ linux-geert-2.5.24/drivers/video/cfbcopyarea.c	Wed Jun 26 04:04:09 2002
@@ -28,6 +28,14 @@
 #include <asm/io.h>
 #include <video/fbcon.h>
 
+#if BITS_PER_LONG == 32
+#define FB_READ		fb_readl
+#define FB_WRITE	fb_writel
+#else
+#define FB_READ		fb_readq
+#define FB_WRITE	fb_writeq
+#endif
+
 void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area)
 {
 	int x2, y2, lineincr, shift, shift_right, shift_left, old_dx, old_dy;
@@ -137,19 +145,19 @@
 					dst = (unsigned long *) dst1;
 					src = (unsigned long *) src1;
 
-					last = (fb_readl(src) & start_mask);
+					last = (FB_READ(src) & start_mask);
 
 					if (shift > 0)
-						fb_writel(fb_readl(dst) | (last >> shift_right), dst);
+						FB_WRITE(FB_READ(dst) | (last >> shift_right), dst);
 					for (j = 0; j < n; j++) {
 						dst++;
-						tmp = fb_readl(src);
+						tmp = FB_READ(src);
 						src++;
-						fb_writel((last << shift_left) | (tmp >> shift_right), dst);
+						FB_WRITE((last << shift_left) | (tmp >> shift_right), dst);
 						last = tmp;
 						src++;
 					}
-					fb_writel(fb_readl(dst) | (last << shift_left), dst);
+					FB_WRITE(FB_READ(dst) | (last << shift_left), dst);
 					src1 += lineincr;
 					dst1 += lineincr;
 				} while (--height);
@@ -161,19 +169,19 @@
 					dst = (unsigned long *) dst1;
 					src = (unsigned long *) src1;
 
-					last = (fb_readl(src) & end_mask);
+					last = (FB_READ(src) & end_mask);
 
 					if (shift < 0)
-						fb_writel(fb_readl(dst) | (last >> shift_right), dst);
+						FB_WRITE(FB_READ(dst) | (last >> shift_right), dst);
 					for (j = 0; j < n; j++) {
 						dst--;
-						tmp = fb_readl(src);
+						tmp = FB_READ(src);
 						src--;
-						fb_writel((tmp << shift_left) | (last >> shift_right), dst);
+						FB_WRITE((tmp << shift_left) | (last >> shift_right), dst);
 						last = tmp;
 						src--;
 					}
-					fb_writel(fb_readl(dst) | (last >> shift_right), dst);
+					FB_WRITE(FB_READ(dst) | (last >> shift_right), dst);
 					src1 += lineincr;
 					dst1 += lineincr;
 				} while (--height);
@@ -187,16 +195,16 @@
 					src = (unsigned long *) (src1 - start_index);
 
 					if (start_mask)
-						fb_writel(fb_readl(src) | start_mask, dst);
+						FB_WRITE(FB_READ(src) | start_mask, dst);
 
 					for (j = 0; j < n; j++) {
-						fb_writel(fb_readl(src), dst);
+						FB_WRITE(FB_READ(src), dst);
 						dst++;
 						src++;
 					}
 
 					if (end_mask)
-						fb_writel(fb_readl(src) | end_mask, dst);
+						FB_WRITE(FB_READ(src) | end_mask, dst);
 					src1 += lineincr;
 					dst1 += lineincr;
 				} while (--height);
@@ -207,9 +215,9 @@
 					src = (unsigned long *) src1;
 
 					if (start_mask)
-						fb_writel(fb_readl(src) | start_mask, dst);
+						FB_WRITE(FB_READ(src) | start_mask, dst);
 					for (j = 0; j < n; j++) {
-						fb_writel(fb_readl(src), dst);
+						FB_WRITE(FB_READ(src), dst);
 						dst--;
 						src--;
 					}
--- linux-2.5.24/drivers/video/cfbfillrect.c	Thu May 30 08:10:36 2002
+++ linux-geert-2.5.24/drivers/video/cfbfillrect.c	Wed Jun 26 03:59:45 2002
@@ -22,6 +22,14 @@
 #include <asm/types.h>
 #include <video/fbcon.h>
 
+#if BITS_PER_LONG == 32
+#define FB_READ		fb_readl
+#define FB_WRITE	fb_writel
+#else
+#define FB_READ		fb_readq
+#define FB_WRITE	fb_writeq
+#endif
+
 void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect)
 {
 	unsigned long start_index, end_index, start_mask = 0, end_mask = 0;
@@ -93,33 +101,18 @@
 				dst = (unsigned long *) (dst1 - start_index);
 
 				if (start_mask) {
-#if BITS_PER_LONG == 32
-					fb_writel(fb_readl(dst) |
-						  start_mask, dst);
-#else
-					fb_writeq(fb_readq(dst) |
-						  start_mask, dst);
-#endif
+					FB_WRITE(FB_READ(dst) | start_mask,
+						 dst);
 					dst++;
 				}
 
 				for (i = 0; i < n; i++) {
-#if BITS_PER_LONG == 32
-					fb_writel(fg, dst);
-#else
-					fb_writeq(fg, dst);
-#endif
+					FB_WRITE(fg, dst);
 					dst++;
 				}
 
 				if (end_mask)
-#if BITS_PER_LONG == 32
-					fb_writel(fb_readl(dst) | end_mask,
-						  dst);
-#else
-					fb_writeq(fb_readq(dst) | end_mask,
-						  dst);
-#endif
+					FB_WRITE(FB_READ(dst) | end_mask, dst);
 				dst1 += linesize;
 			} while (--height);
 			break;
@@ -128,33 +121,18 @@
 				dst = (unsigned long *) (dst1 - start_index);
 
 				if (start_mask) {
-#if BITS_PER_LONG == 32
-					fb_writel(fb_readl(dst) ^
-						  start_mask, dst);
-#else
-					fb_writeq(fb_readq(dst) ^
-						  start_mask, dst);
-#endif
+					FB_WRITE(FB_READ(dst) ^ start_mask,
+						 dst);
 					dst++;
 				}
 
 				for (i = 0; i < n; i++) {
-#if BITS_PER_LONG == 32
-					fb_writel(fb_readl(dst) ^ fg, dst);
-#else
-					fb_writeq(fb_readq(dst) ^ fg, dst);
-#endif
+					FB_WRITE(FB_READ(dst) ^ fg, dst);
 					dst++;
 				}
 
 				if (end_mask) {
-#if BITS_PER_LONG == 32
-					fb_writel(fb_readl(dst) ^ end_mask,
-						  dst);
-#else
-					fb_writeq(fb_readq(dst) ^ end_mask,
-						  dst);
-#endif
+					FB_WRITE(FB_READ(dst) ^ end_mask, dst);
 				}
 				dst1 += linesize;
 			} while (--height);
Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

Re: cfb_{copyarea,fillrect}()

From: James Simmons <hidden>
Date: 2002-07-05 03:39:40

It also adds 64-bit support to cfb_copyarea().
Thanks. Added to BK tree.
Other comments/notes:

  - Shouldn't cfb_fillrect() use the pseudo_palette in DIRECTCOLOR mode?
??? I thought you had to go threw the DAC to get values.
  - I think the cfb_*() routines can easily be modified to work for bpp < 8,
    and for bpp == 24:
It doesn't work for bpp < 4 for you? It should work for those as well. Bpp
24 is a bit more trick if we want to do word align access to the
framebuffer.
      o initialize src/dst indices to be bit indices instead of byte indices
      o remove shifts by 3
      o n is number of bits to copy/fill
Hm. I have to work up so psuedo code to try that idea out.
  - I think that line length is not guaranteed to be a multiple of
    sizeof(unsigned long). Hence a different start/end mask per line is
    possible as well.
Missed that one.



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Caffeinated soap. No kidding.
http://thinkgeek.com/sf

Re: cfb_{copyarea,fillrect}()

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2002-07-05 07:42:17

On Thu, 4 Jul 2002, James Simmons wrote:
quoted
Other comments/notes:
  - Shouldn't cfb_fillrect() use the pseudo_palette in DIRECTCOLOR mode?
??? I thought you had to go threw the DAC to get values.
Yes, but you have to do that for _each_ color component. So you have to use
pixel value (i, i, i), not (0, 0, i) (depending on the order of the components)
like the current code does.
quoted
  - I think the cfb_*() routines can easily be modified to work for bpp < 8,
    and for bpp == 24:
It doesn't work for bpp < 4 for you? It should work for those as well. Bpp
Note that I didn't try that.
24 is a bit more trick if we want to do word align access to the
framebuffer.
quoted
      o initialize src/dst indices to be bit indices instead of byte indices
      o remove shifts by 3
      o n is number of bits to copy/fill
Hm. I have to work up so psuedo code to try that idea out.
The main idea is to do an optimized bitcopy, not a bytecopy. Then it works for
all values of bpp:

    void bitcpy(unsigned long *dst, int dst_idx, unsigned long *src,
		int src_idx, int nbits);

{dst,src}_idx are bit indices (0 == MSB, 31 or 63 = LSB), nbits is the number
of bits to copy.

The same is true for fillrect, there you want an optimized bitset().

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Bringing you mounds of caffeinated joy.
http://thinkgeek.com/sf
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help