Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/tc Preliminary import of 'SFB enhanced' text rendere...



details:   https://anonhg.NetBSD.org/src/rev/6ad49a0ec5e0
branches:  trunk
changeset: 477522:6ad49a0ec5e0
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Tue Oct 19 09:51:17 1999 +0000

description:
Preliminary import of 'SFB enhanced' text renderer with many caveats
to be corrected.  Text drawing is now improved significantly, but;
cursor is drawn incorrectly, copycols() trashes a screen, 'standout
(\033[7m)' results in lines reversed entirely until '\033[0m', and
possibly more issues.  Not multi-colour, 8bpp only this moment.  Costly
write memory barrier instrunctions should be eliminated using framebuffer
address aliasing technique for NetBSD/alpha.

diffstat:

 sys/dev/tc/sfb.c |  336 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 241 insertions(+), 95 deletions(-)

diffs (truncated from 552 to 300 lines):

diff -r b121becb9d39 -r 6ad49a0ec5e0 sys/dev/tc/sfb.c
--- a/sys/dev/tc/sfb.c  Tue Oct 19 09:29:46 1999 +0000
+++ b/sys/dev/tc/sfb.c  Tue Oct 19 09:51:17 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sfb.c,v 1.20 1999/10/08 02:08:15 nisimura Exp $ */
+/* $NetBSD: sfb.c,v 1.21 1999/10/19 09:51:17 nisimura Exp $ */
 
 /*
  * Copyright (c) 1998, 1999 Tohru Nishimura.  All rights reserved.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: sfb.c,v 1.20 1999/10/08 02:08:15 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sfb.c,v 1.21 1999/10/19 09:51:17 nisimura Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -187,7 +187,7 @@
        "std", 0, 0,
        &sfb_emulops,
        0, 0,
-       0
+       WSSCREEN_REVERSE
 };
 
 const struct wsscreen_descr *_sfb_scrlist[] = {
@@ -623,8 +623,8 @@
        *(u_int32_t *)(sfbasic + SFB_ASIC_VIDEO_VALID) = 0;
        *(u_int32_t *)(sfbasic + SFB_ASIC_PLANEMASK) = ~0;
        *(u_int32_t *)(sfbasic + SFB_ASIC_PIXELMASK) = ~0;
-       *(u_int32_t *)(sfbasic + SFB_ASIC_MODE) = 0;
-       *(u_int32_t *)(sfbasic + SFB_ASIC_ROP) = 3;
+       *(u_int32_t *)(sfbasic + SFB_ASIC_MODE) = 0; /* MODE_SIMPLE */
+       *(u_int32_t *)(sfbasic + SFB_ASIC_ROP) = 3;  /* ROP_COPY */
        
        *(u_int32_t *)(sfbasic + 0x180000) = 0; /* Bt459 reset */
 
@@ -682,9 +682,9 @@
        REG(vdac, bt_reg) = 0xff;       tc_wmb();
        REG(vdac, bt_reg) = 0xff;       tc_wmb();
 
-       REG(vdac, bt_reg) = 0;  tc_wmb();
-       REG(vdac, bt_reg) = 0;  tc_wmb();
-       REG(vdac, bt_reg) = 0;  tc_wmb();
+       REG(vdac, bt_reg) = 0;          tc_wmb();
+       REG(vdac, bt_reg) = 0;          tc_wmb();
+       REG(vdac, bt_reg) = 0;          tc_wmb();
 
        REG(vdac, bt_reg) = 0xff;       tc_wmb();
        REG(vdac, bt_reg) = 0xff;       tc_wmb();
@@ -856,11 +856,46 @@
 #define        MODE_TRANSPARENTLINE    6
 #define        MODE_COPY               7
 
+/* parameters for 8bpp configuration */
 #define        SFBALIGNMASK            0x7
 #define        SFBSTIPPLEALL1          0xffffffff
 #define        SFBSTIPPLEBITS          32
 #define        SFBSTIPPLEBITMASK       0x1f
 #define        SFBSTIPPLEBYTESDONE     32
+#define        SFBCOPYALL1             0xffffffff
+#define        SFBCOPYBITS             32
+#define        SFBCOPYBITMASK          0x1f
+#define        SFBCOPYBYTESDONE        32
+
+#ifdef pmax
+#define        WRITE_MB()
+#define        BUMP(p) (p)
+#endif
+
+#ifdef alpha
+#define        WRITE_MB() tc_wmb()
+#define        BUMP(p) ((p) = (caddr_t)(((long)(p) + 128) & ~0x400))
+#endif
+
+#define        SFBMODE(p, v) \
+               (*(u_int32_t *)(BUMP(p) + SFB_ASIC_MODE) = (v))
+#define        SFBROP(p, v) \
+               (*(u_int32_t *)(BUMP(p) + SFB_ASIC_ROP) = (v))
+#define        SFBPLANEMASK(p, v) \
+               (*(u_int32_t *)(BUMP(p) + SFB_ASIC_PLANEMASK) = (v))
+#define        SFBPIXELMASK(p, v) \
+               (*(u_int32_t *)(BUMP(p) + SFB_ASIC_PIXELMASK) = (v))
+#define        SFBADDRESS(p, v) \
+               (*(u_int32_t *)(BUMP(p) + SFB_ASIC_ADDRESS) = (v))
+#define        SFBSTART(p, v) \
+               (*(u_int32_t *)(BUMP(p) + SFB_ASIC_START) = (v))
+#define        SFBPIXELSHIFT(p, v) \
+               (*(u_int32_t *)(BUMP(p) + SFB_ASIC_PIXELSHIFT) = (v))
+#define        SFBFG(p, v) \
+               (*(u_int32_t *)(BUMP(p) + SFB_ASIC_FG) = (v))
+#define        SFBBG(p, v) \
+               (*(u_int32_t *)(BUMP(p) + SFB_ASIC_BG) = (v))
+
 
 /*
  * Paint (or unpaint) the cursor.
@@ -871,7 +906,10 @@
        int on, row, col;
 {
        struct rcons *rc = id;
-       int x, y;
+       struct raster *rap = rc->rc_sp;
+       caddr_t sfb, p;
+       int scanspan, height, width, align, x, y;
+       u_int32_t lmask, rmask;
 
        /* turn the cursor off */
        if (!on) {
@@ -889,11 +927,44 @@
 
        x = col * rc->rc_font->width + rc->rc_xorigin;
        y = row * rc->rc_font->height + rc->rc_yorigin;
+       scanspan = rap->linelongs * 4;
+       height = rc->rc_font->height;
 
-       raster_op(rc->rc_sp, x, y,
-           rc->rc_font->width, rc->rc_font->height,
-           RAS_INVERT,
-           (struct raster *) 0, 0, 0);
+       p = (caddr_t)rap->pixels + y * scanspan + x;
+       align = (long)p & SFBALIGNMASK;
+       p -= align;
+       width = rc->rc_font->width + align;
+       lmask = SFBSTIPPLEALL1 << align;
+       rmask = SFBSTIPPLEALL1 >> (-width & SFBSTIPPLEBITMASK);
+       sfb = rap->data;
+
+       SFBMODE(sfb, MODE_SIMPLE);
+       SFBPLANEMASK(sfb, 0x01010101);  /* LSB only */
+       SFBROP(sfb, 10);                /* ROP_INVERT */
+       if (width <= SFBSTIPPLEBITS) {
+               lmask = lmask & rmask;
+               while (height > 0) {
+                       SFBADDRESS(sfb, (long)p);
+                       SFBSTART(sfb, lmask);
+                       p += scanspan;
+                       height--;
+               }
+       }
+       else {
+               caddr_t q = p;
+               while (height > 0) {
+                       *(u_int32_t *)p = lmask;
+WRITE_MB();
+                       p += SFBSTIPPLEBYTESDONE;
+                       *(u_int32_t *)p = rmask;
+WRITE_MB();
+
+                       p = (q += scanspan);
+                       height--;
+               }
+       }
+       SFBPLANEMASK(sfb, ~0);          /* entire pixel */
+       SFBROP(sfb, 3);                 /* ROP_COPY */
 
        rc->rc_bits ^= RC_CURSOR;
 }
@@ -926,17 +997,66 @@
        long attr;
 {
        struct rcons *rc = id;
-       int x, y, op;
-       u_char help;
+       struct raster *rap = rc->rc_sp;
+       caddr_t sfb, p;
+       int scanspan, height, width, align, x, y;
+       u_int32_t lmask, rmask, glyph;
+       u_int32_t *g;
+
+if (uc < 0x20 || uc >= 127) return; /* XXX why \033 is creaping in !? XXX */
 
        x = col * rc->rc_font->width + rc->rc_xorigin;
-       y = row * rc->rc_font->height + rc->rc_font_ascent + rc->rc_yorigin;
+       y = row * rc->rc_font->height + rc->rc_yorigin;
+       scanspan = rap->linelongs * 4;
+       height = rc->rc_font->height;
+       g = rc->rc_font->chars[uc].r->pixels;
+
+       p = (caddr_t)rap->pixels + y * scanspan + x;
+       align = (long)p & SFBALIGNMASK;
+       p -= align;
+       width = rc->rc_font->width + align;
+       lmask = SFBSTIPPLEALL1 << align;
+       rmask = SFBSTIPPLEALL1 >> (-width & SFBSTIPPLEBITMASK);
+       sfb = rap->data;
+       attr = (attr != 0) ^ (rc->rc_bits & RC_INVERT);
 
-       op = RAS_SRC;
-       if ((attr != 0) ^ ((rc->rc_bits & RC_INVERT) != 0))
-               op = RAS_NOT(op);
-       help = uc & 0xff;
-       raster_textn(rc->rc_sp, x, y, op, rc->rc_font, &help, 1);
+       SFBMODE(sfb, MODE_OPAQUESTIPPLE);
+       SFBPLANEMASK(sfb, ~0);
+       SFBFG(sfb, (attr == 0) ? 0x01010101 : 0);
+       SFBBG(sfb, (attr == 0) ? 0 : 0x01010101);
+       if (width <= SFBSTIPPLEBITS) {
+               lmask = lmask & rmask;
+               while (height > 0) {
+                       glyph = *g;
+                       SFBPIXELMASK(sfb, lmask);
+                       SFBADDRESS(sfb, (long)p);
+                       SFBSTART(sfb, glyph << align);
+                       p += scanspan;
+                       g += 1;
+                       height--;
+               }
+       }
+       else {
+               caddr_t q = p;
+               while (height > 0) {
+                       glyph = *g;
+                       SFBPIXELMASK(sfb, lmask);
+WRITE_MB();
+                       *(u_int32_t *)p = glyph << align;
+WRITE_MB();
+                       p += SFBSTIPPLEBYTESDONE;
+                       SFBPIXELMASK(sfb, rmask);
+WRITE_MB();
+                       *(u_int32_t *)p = glyph >> (-width & SFBSTIPPLEBITMASK);
+WRITE_MB();
+
+                       p = (q += scanspan);
+                       g += 1;
+                       height--;
+               }
+       }
+       SFBMODE(sfb, MODE_SIMPLE);
+       SFBPIXELMASK(sfb, ~0);
 }
 
 /*
@@ -950,8 +1070,8 @@
        struct rcons *rc = id;
        struct raster *rap = rc->rc_sp;
        caddr_t sp, dp, basex, sfb;
-       int scanspan, height, width, aligns, alignd, w, y;
-       u_int32_t lmasks, rmasks, lmaskd, rmaskd;
+       int scanspan, height, width, align, shift, w, y;
+       u_int32_t lmask, rmask;
 
        scanspan = rap->linelongs * 4;
        y = rc->rc_yorigin + rc->rc_font->height * row;
@@ -960,31 +1080,28 @@
        w = rc->rc_font->width * ncols;
 
        dp = basex + rc->rc_font->width * dstcol;
-       alignd = (long)dp & SFBALIGNMASK;
-       dp -= alignd;
-       width = w + alignd;
-       lmaskd = SFBSTIPPLEALL1 << alignd;
-       rmaskd = SFBSTIPPLEALL1 >> (-width & SFBSTIPPLEBITMASK);
-
        sp = basex + rc->rc_font->width * srccol;
-       aligns = (long)sp & SFBALIGNMASK;
-       sp -= aligns;
-       width = w + aligns;
-       lmasks = SFBSTIPPLEALL1 << aligns;
-       rmasks = SFBSTIPPLEALL1 >> (-width & SFBSTIPPLEBITMASK);
 
-       width += (-width & SFBSTIPPLEBITMASK);
+       align = shift = (long)sp & SFBALIGNMASK;
+       sp -= align;
+       width = w + align;
+       align = (long)dp & SFBALIGNMASK;
+       dp -= align;
+       lmask = SFBCOPYALL1 << align;
+       rmask = SFBCOPYALL1 >> (-(w + align) & SFBCOPYBITMASK);
+       shift = align - shift; 
        sfb = rap->data;
-       *(u_int32_t *)(sfb + SFB_ASIC_MODE) = MODE_COPY;
-       *(u_int32_t *)(sfb + SFB_ASIC_PLANEMASK) = ~0;
-       *(u_int32_t *)(sfb + SFB_ASIC_PIXELSHIFT) = alignd - aligns;
 
-       if (width <= SFBSTIPPLEBITS) {
-               lmasks = lmasks & rmasks;
-               lmaskd = lmaskd & rmaskd;
+       SFBMODE(sfb, MODE_COPY);
+       SFBPLANEMASK(sfb, ~0);
+       SFBPIXELSHIFT(sfb, shift);
+       if (width <= SFBCOPYBITS) {
+               lmask = lmask & rmask;
                while (height > 0) {
-                       *(u_int32_t *)sp = lmasks;
-                       *(u_int32_t *)dp = lmaskd;
+                       *(u_int32_t *)sp = SFBCOPYALL1;
+WRITE_MB();
+                       *(u_int32_t *)dp = lmask;
+WRITE_MB();
                        sp += scanspan;
                        dp += scanspan;
                        height--;
@@ -996,20 +1113,26 @@
 
                w = width;
                while (height > 0) {
-                       *(u_int32_t *)sp = lmasks;
-                       *(u_int32_t *)dp = lmaskd;



Home | Main Index | Thread Index | Old Index