Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64/dev split ffb_putchar() into a version for ...



details:   https://anonhg.NetBSD.org/src/rev/01588060133e
branches:  trunk
changeset: 780840:01588060133e
user:      macallan <macallan%NetBSD.org@localhost>
date:      Thu Aug 09 00:48:06 2012 +0000

description:
split ffb_putchar() into a version for mono fonts and one for anti-aliased
ones. While there use the blitter to draw the cursor and remove some waits
that are unnecessary now that characters are drawn by hardware.

diffstat:

 sys/arch/sparc64/dev/ffb.c    |  270 +++++++++++++++++++++++------------------
 sys/arch/sparc64/dev/ffbreg.h |    3 +-
 2 files changed, 153 insertions(+), 120 deletions(-)

diffs (truncated from 386 to 300 lines):

diff -r 9e8b70980808 -r 01588060133e sys/arch/sparc64/dev/ffb.c
--- a/sys/arch/sparc64/dev/ffb.c        Wed Aug 08 23:24:40 2012 +0000
+++ b/sys/arch/sparc64/dev/ffb.c        Thu Aug 09 00:48:06 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffb.c,v 1.51 2012/04/12 19:09:18 macallan Exp $        */
+/*     $NetBSD: ffb.c,v 1.52 2012/08/09 00:48:06 macallan Exp $        */
 /*     $OpenBSD: creator.c,v 1.20 2002/07/30 19:48:15 jason Exp $      */
 
 /*
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.51 2012/04/12 19:09:18 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.52 2012/08/09 00:48:06 macallan Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -127,6 +127,7 @@
 void   ffb_ras_eraserows(void *, int, int, long int);
 void   ffb_ras_do_cursor(struct rasops_info *);
 void   ffb_ras_fill(struct ffb_softc *);
+void   ffb_ras_invert(struct ffb_softc *);
 static void    ffb_ras_setfg(struct ffb_softc *, int32_t);
 static void    ffb_ras_setbg(struct ffb_softc *, int32_t);
 
@@ -135,7 +136,8 @@
 void   ffb_init_screen(void *, struct vcons_screen *, int, 
            long *);
 int    ffb_allocattr(void *, int, int, int, long *);
-void   ffb_putchar(void *, int, int, u_int, long);
+void   ffb_putchar_mono(void *, int, int, u_int, long);
+void   ffb_putchar_aa(void *, int, int, u_int, long);
 void   ffb_cursor(void *, int, int, int);
 
 /* frame buffer generic driver */   
@@ -738,6 +740,19 @@
 }
 
 void
+ffb_ras_invert(struct ffb_softc *sc)
+{
+       ffb_ras_fifo_wait(sc, 3);
+       FBC_WRITE(sc, FFB_FBC_PPC,
+           FBC_PPC_VCE_DIS | FBC_PPC_TBE_OPAQUE | FBC_PPC_ACE_DIS | 
+           FBC_PPC_APE_DIS | FBC_PPC_DCE_DIS | FBC_PPC_CS_CONST | 
+           FBC_PPC_ABE_DIS | FBC_PPC_XS_WID);
+       FBC_WRITE(sc, FFB_FBC_ROP, FBC_ROP_INVERT);
+       FBC_WRITE(sc, FFB_FBC_DRAWOP, FBC_DRAWOP_RECTANGLE);
+       SYNC;
+}
+
+void
 ffb_ras_copyrows(void *cookie, int src, int dst, int n)
 {
        struct rasops_info *ri = cookie;
@@ -966,7 +981,7 @@
        struct rasops_info *ri = cookie;
        struct vcons_screen *scr;
        struct ffb_softc *sc;
-       int x, y, wi, he, coffset;
+       int x, y, wi, he;
        
        if (cookie != NULL) {
                scr = ri->ri_hw;
@@ -976,43 +991,36 @@
                he = ri->ri_font->fontheight;
 
                if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
-                       x = ri->ri_ccol * wi + ri->ri_xorigin;
-                       y = ri->ri_crow * he + ri->ri_yorigin;
        
                        if (ri->ri_flg & RI_CURSOR) {
+
                                /* remove cursor */
-                               coffset = ri->ri_ccol + (ri->ri_crow *
-                                   ri->ri_cols);
-#ifdef WSDISPLAY_SCROLLSUPPORT
-                               coffset += scr->scr_offset_to_zero;
-#endif
-                               ffb_ras_wait(sc);
-                               ffb_putchar(cookie, ri->ri_crow, 
-                                   ri->ri_ccol, scr->scr_chars[coffset], 
-                                   scr->scr_attrs[coffset]);
+                               x = ri->ri_ccol * wi + ri->ri_xorigin;
+                               y = ri->ri_crow * he + ri->ri_yorigin;
+
+                               ffb_ras_invert(sc);
+                               ffb_ras_fifo_wait(sc, 4);
+                               FBC_WRITE(sc, FFB_FBC_BY, y);
+                               FBC_WRITE(sc, FFB_FBC_BX, x);
+                               FBC_WRITE(sc, FFB_FBC_BH, he);
+                               FBC_WRITE(sc, FFB_FBC_BW, wi);
+
                                ri->ri_flg &= ~RI_CURSOR;
                        }
                        ri->ri_crow = row;
                        ri->ri_ccol = col;
                        if (on)
                        {
-                               long attr, revattr;
                                x = ri->ri_ccol * wi + ri->ri_xorigin;
                                y = ri->ri_crow * he + ri->ri_yorigin;
-                               coffset = col + (row * ri->ri_cols);
-#ifdef WSDISPLAY_SCROLLSUPPORT
-                               coffset += scr->scr_offset_to_zero;
-#endif
-                               attr = scr->scr_attrs[coffset];
-#ifdef FFB_CURSOR_SWAP_COLOURS
-                               revattr=((attr >> 8 ) & 0x000f0000) | ((attr & 
-                                   0x000f0000)<<8) | (attr & 0x0000ffff);
-#else
-                               revattr = attr ^ 0xffff0000;
-#endif
-                               ffb_ras_wait(sc);
-                               ffb_putchar(cookie, ri->ri_crow, ri->ri_ccol,
-                                   scr->scr_chars[coffset], revattr);
+
+                               ffb_ras_invert(sc);
+                               ffb_ras_fifo_wait(sc, 4);
+                               FBC_WRITE(sc, FFB_FBC_BY, y);
+                               FBC_WRITE(sc, FFB_FBC_BX, x);
+                               FBC_WRITE(sc, FFB_FBC_BH, he);
+                               FBC_WRITE(sc, FFB_FBC_BW, wi);
+
                                ri->ri_flg |= RI_CURSOR;
                        }
                } else {
@@ -1023,8 +1031,9 @@
        }
 }
 
+/* mono bitmap font */
 void
-ffb_putchar(void *cookie, int row, int col, u_int c, long attr)
+ffb_putchar_mono(void *cookie, int row, int col, u_int c, long attr)
 {
        struct rasops_info *ri = cookie;
        struct vcons_screen *scr = ri->ri_hw;
@@ -1032,7 +1041,7 @@
        struct ffb_softc *sc = scr->scr_cookie;
        void *data;
        uint32_t fg, bg;
-       int uc, i;
+       int i;
        int x, y, wi, he;
        
        if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL)
@@ -1049,102 +1058,122 @@
        x = ri->ri_xorigin + col * wi;
        y = ri->ri_yorigin + row * he;
 
-       uc = c - font->firstchar;
-       data = (uint8_t *)font->data + uc * ri->ri_fontscale;
+       data = WSFONT_GLYPH(c, font);
 
-       if (font->stride < wi) {
-               /* mono bitmap font */
-               ffb_ras_setbg(sc, bg);
-               ffb_ras_setfg(sc, fg);
-               ffb_ras_fifo_wait(sc, 4);
-               FBC_WRITE(sc, FFB_FBC_ROP, FBC_ROP_NEW);
-               FBC_WRITE(sc, FFB_FBC_FONTXY, (y << 16) | x);
-               FBC_WRITE(sc, FFB_FBC_FONTW, wi);
-               FBC_WRITE(sc, FFB_FBC_PPC,
-                   FBC_PPC_VCE_DIS | FBC_PPC_TBE_OPAQUE | FBC_PPC_ACE_DIS | 
-                   FBC_PPC_APE_DIS | FBC_PPC_DCE_DIS | FBC_PPC_CS_CONST | 
-                   FBC_PPC_ABE_DIS | FBC_PPC_XS_WID);
+       ffb_ras_setbg(sc, bg);
+       ffb_ras_setfg(sc, fg);
+       ffb_ras_fifo_wait(sc, 4);
+       FBC_WRITE(sc, FFB_FBC_ROP, FBC_ROP_NEW);
+       FBC_WRITE(sc, FFB_FBC_FONTXY, (y << 16) | x);
+       FBC_WRITE(sc, FFB_FBC_FONTW, wi);
+       FBC_WRITE(sc, FFB_FBC_PPC,
+           FBC_PPC_VCE_DIS | FBC_PPC_TBE_OPAQUE | FBC_PPC_ACE_DIS | 
+           FBC_PPC_APE_DIS | FBC_PPC_DCE_DIS | FBC_PPC_CS_CONST | 
+           FBC_PPC_ABE_DIS | FBC_PPC_XS_WID);
 
-               switch (font->stride) {
-                       case 1: {
-                               uint8_t *data8 = data;
-                               uint32_t reg;
-                               for (i = 0; i < he; i++) {
-                                       reg = *data8;
-                                       FBC_WRITE(sc, FFB_FBC_FONT, reg << 24);
-                                       data8++;
-                               }
-                               break;
+       switch (font->stride) {
+               case 1: {
+                       uint8_t *data8 = data;
+                       uint32_t reg;
+                       for (i = 0; i < he; i++) {
+                               reg = *data8;
+                               FBC_WRITE(sc, FFB_FBC_FONT, reg << 24);
+                               data8++;
+                       }
+                       break;
+               }
+               case 2: {
+                       uint16_t *data16 = data;
+                       uint32_t reg;
+                       for (i = 0; i < he; i++) {
+                               reg = *data16;
+                               FBC_WRITE(sc, FFB_FBC_FONT, reg << 16);
+                               data16++;
                        }
-                       case 2: {
-                               uint16_t *data16 = data;
-                               uint32_t reg;
-                               for (i = 0; i < he; i++) {
-                                       reg = *data16;
-                                       FBC_WRITE(sc, FFB_FBC_FONT, reg << 16);
-                                       data16++;
-                               }
-                               break;
-                       }
+                       break;
                }
-       } else {
-               /* alpha font */
-               volatile uint32_t *dest, *ddest;
-               uint32_t alpha = 0x80;
-               uint8_t *data8 = data;
-               int j;
+       }
+}
+
+/* alpha font */
+void
+ffb_putchar_aa(void *cookie, int row, int col, u_int c, long attr)
+{
+       struct rasops_info *ri = cookie;
+       struct vcons_screen *scr = ri->ri_hw;
+       struct wsdisplay_font *font = PICK_FONT(ri, c);
+       struct ffb_softc *sc = scr->scr_cookie;
+       volatile uint32_t *dest, *ddest;
+       uint8_t *data8;
+       uint32_t fg, bg;
+       int i;
+       int x, y, wi, he;
+       uint32_t alpha = 0x80;
+       int j;
+       
+       if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL)
+               return;
 
-               /* first we erase the background */
-               ffb_ras_fill(sc);
-               ffb_ras_setfg(sc, bg);
-               ffb_ras_fifo_wait(sc, 4);
-               FBC_WRITE(sc, FFB_FBC_BY, y);
-               FBC_WRITE(sc, FFB_FBC_BX, x);
-               FBC_WRITE(sc, FFB_FBC_BH, he);
-               FBC_WRITE(sc, FFB_FBC_BW, wi);
+       wi = font->fontwidth;
+       he = font->fontheight;
+
+       if (!CHAR_IN_FONT(c, font))
+               return;
+
+       bg = ri->ri_devcmap[(attr >> 16) & 0xf];
+       fg = ri->ri_devcmap[(attr >> 24) & 0xf];
+       x = ri->ri_xorigin + col * wi;
+       y = ri->ri_yorigin + row * he;
+
+       data8 = WSFONT_GLYPH(c, font);
 
-               /* if we draw a space we're done */
-               if (c == ' ') return;
+       /* first we erase the background */
+       ffb_ras_fill(sc);
+       ffb_ras_setfg(sc, bg);
+       ffb_ras_fifo_wait(sc, 4);
+       FBC_WRITE(sc, FFB_FBC_BY, y);
+       FBC_WRITE(sc, FFB_FBC_BX, x);
+       FBC_WRITE(sc, FFB_FBC_BH, he);
+       FBC_WRITE(sc, FFB_FBC_BW, wi);
 
-               /* now enable alpha blending */
-               ffb_ras_setfg(sc, fg);
-               ffb_ras_fifo_wait(sc, 2);
-               FBC_WRITE(sc, FFB_FBC_ROP, FBC_ROP_NEW);
+       /* if we draw a space we're done */
+       if (c == ' ') return;
+
+       /* now enable alpha blending */
+       ffb_ras_setfg(sc, fg);
+       ffb_ras_fifo_wait(sc, 2);
+       FBC_WRITE(sc, FFB_FBC_ROP, FBC_ROP_NEW);
 
-               FBC_WRITE(sc, FFB_FBC_PPC,
-                   FBC_PPC_VCE_DIS | FBC_PPC_TBE_OPAQUE | FBC_PPC_ACE_DIS | 
-                   FBC_PPC_APE_DIS | FBC_PPC_DCE_DIS | FBC_PPC_CS_CONST | 
-                   FBC_PPC_ABE_ENA | FBC_PPC_XS_VAR);
-               /*
-                * we have to wait for both the rectangle drawing op above and
-                * the FFB_FBC_PPC write to finish before mucking around in
-                * the SFB aperture



Home | Main Index | Thread Index | Old Index