Source-Changes-HG archive

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

[src/trunk]: src/sys/dev defopt RCONS_2BPP and RCONS_16BPP



details:   https://anonhg.NetBSD.org/src/rev/3862c6047672
branches:  trunk
changeset: 467655:3862c6047672
user:      dbj <dbj%NetBSD.org@localhost>
date:      Sat Mar 27 00:07:58 1999 +0000

description:
defopt RCONS_2BPP and RCONS_16BPP
add support for 16bpp framebuffers as found on color nexten.

diffstat:

 sys/dev/rcons/files.rcons   |    6 +-
 sys/dev/rcons/raster_op.c   |  225 ++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/wscons/files.wscons |    5 +-
 3 files changed, 228 insertions(+), 8 deletions(-)

diffs (truncated from 349 to 300 lines):

diff -r fa8f08190443 -r 3862c6047672 sys/dev/rcons/files.rcons
--- a/sys/dev/rcons/files.rcons Fri Mar 26 23:52:57 1999 +0000
+++ b/sys/dev/rcons/files.rcons Sat Mar 27 00:07:58 1999 +0000
@@ -1,7 +1,11 @@
-# $NetBSD: files.rcons,v 1.2 1996/04/11 21:54:38 cgd Exp $
+# $NetBSD: files.rcons,v 1.3 1999/03/27 00:07:58 dbj Exp $
 #
 # Configuration file for RASTER Console.
 #
+
+# rcons bit-depth options
+defopt opt_rcons.h RCONS_2BPP RCONS_16BPP
+
 file dev/rcons/raster_op.c     rasterconsole | raster
 file dev/rcons/raster_text.c   rasterconsole | raster
 file dev/rcons/rcons_kern.c    rasterconsole
diff -r fa8f08190443 -r 3862c6047672 sys/dev/rcons/raster_op.c
--- a/sys/dev/rcons/raster_op.c Fri Mar 26 23:52:57 1999 +0000
+++ b/sys/dev/rcons/raster_op.c Sat Mar 27 00:07:58 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: raster_op.c,v 1.6 1999/01/11 11:08:14 drochner Exp $ */
+/*     $NetBSD: raster_op.c,v 1.7 1999/03/27 00:07:59 dbj Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -51,18 +51,24 @@
  *       1-bit to 1-bit
  *       1-bit to 2-bits
  *       1-bit to 8-bits
+ *       1-bit to 16-bits
  *       2-bits to 2-bits
- *       2-bits to 8-bits
+ *       2-bits to 8-bits (not implemented)
+ *       2-bits to 16-bits (not implemented)
  *       8-bits to 8-bits
+ *       8-bits to 16-bits (not implemented)
+ *       16-bits to 16-bits
  *   no src required
  *       1-bit no-src
  *       2-bits no-src
  *       8-bits no-src
+ *       16-bits no-src
  */
 
 #include <sys/types.h>
 #ifdef _KERNEL
 #include <dev/rcons/raster.h>
+#include "opt_rcons.h"
 #else
 #include "raster.h"
 #endif
@@ -503,6 +509,9 @@
   0x0000c000, 0x00003000, 0x00000c00, 0x00000300,
   0x000000c0, 0x00000030, 0x0000000c, 0x00000003 };
 #endif /* RCONS_2BPP */
+#ifdef RCONS_16BPP
+static u_int32_t twobytemask[2] = { 0xffff0000, 0x0000ffff };
+#endif /* RCONS_16BPP */
 #else /*MSBYTE_FIRST*/
 static u_int32_t bytemask[4] = { 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 };
 #ifdef RCONS_2BPP
@@ -512,6 +521,9 @@
   0x00030000, 0x000c0000, 0x00300000, 0x00c00000,
   0x03000000, 0x0c000000, 0x30000000, 0xc0000000 };
 #endif /* RCONS_2BPP */
+#ifdef RCONS_16BPP
+static u_int32_t twobytemask[2] = { 0x0000ffff, 0xffff0000 };
+#endif /* RCONS_16BPP */
 #endif /*MSBYTE_FIRST*/
 
 
@@ -731,7 +743,7 @@
                }
           }
 #endif /* RCONS_2BPP */
-       else
+       else if ( dst->depth == 8 )
            {
            /* One to eight, using the color in the rop.  This could
            ** probably be sped up by handling each four-bit source nybble
@@ -801,6 +813,78 @@
                dstlin += dst->linelongs;
                }
            }
+#ifdef RCONS_16BPP
+       else
+           {
+           /* One to sixteen, using the color in the rop.  This could
+           ** probably be sped up by handling each four-bit source nybble
+           ** as a group, indexing into a 16-element runtime-constructed
+           ** table of longwords.
+           */
+           u_int32_t* srclin1;
+           u_int32_t* dstlin1;
+           u_int32_t* srclin2;
+           u_int32_t* srclin;
+           u_int32_t* dstlin;
+           register u_int32_t* srclong;
+           register u_int32_t* dstlong;
+           register u_int32_t color, dl;
+           register int srcbit, dstbyte, i;
+
+           color = RAS_GETCOLOR( rop );
+           if ( color == 0 )
+               color = 255;
+
+           /* Make 32 bits of color so we can do the ROP without shifting. */
+           color |= ( color << 16 );
+
+           /* Don't have to worry about overlapping blits here. */
+           srclin1 = RAS_ADDR( src, sx, sy );
+           srclin2 = srclin1 + h * src->linelongs;
+           dstlin1 = RAS_ADDR( dst, dx, dy );
+           srclin = srclin1;
+           dstlin = dstlin1;
+           while ( srclin != srclin2 )
+               {
+               srclong = srclin;
+               srcbit = sx & 31;
+               dstlong = dstlin;
+               dstbyte = dx & 1;
+               i = w;
+
+               /* WARNING: this code is KNOWN TO FAIL on Sun 3's / CG2's. */
+               ROP_SRCDSTCOLOR(
+               /*op*/  op,
+               /*pre*/ while ( i > 0 )
+                           {
+                           dl = *dstlong;,
+               /*s*/       *srclong & raster_bitmask[srcbit],
+               /*d*/       dl,
+               /*c*/       color,
+               /*pst*/     *dstlong = ( *dstlong & ~twobytemask[dstbyte] ) |
+                                      ( dl & twobytemask[dstbyte] );
+                           if ( srcbit == 31 )
+                               {
+                               srcbit = 0;
+                               ++srclong;
+                               }
+                           else
+                               ++srcbit;
+                           if ( dstbyte == 1 )
+                               {
+                               dstbyte = 0;
+                               ++dstlong;
+                               }
+                           else
+                               ++dstbyte;
+                           --i;
+                           } )
+
+               srclin += src->linelongs;
+               dstlin += dst->linelongs;
+               }
+           }
+#endif /* RCONS_16BPP */
        }
 #ifdef RCONS_2BPP
     else if ( src->depth == 2 ) 
@@ -827,7 +911,7 @@
            }
 #endif /* RCONS_2BPP */
 
-    else
+    else if ( src->depth == 8 )
        {
        /* Eight to eight blit. */
        u_int32_t* srclin1;
@@ -863,7 +947,30 @@
            src, srclin1, srcleftignore, srcrightignore, srclongs,
            dst, dstlin1, dstleftignore, dstrightignore, dstlongs, h, op );
        }
+#ifdef RCONS_16BPP
+    else
+        {
+       /* Sixteen to sixteen blit. */
+           u_int32_t* srclin1;
+           u_int32_t* dstlin1;
+           int srcleftignore, srcrightignore, srclongs;
+           int dstleftignore, dstrightignore, dstlongs;
 
+           srclin1 = RAS_ADDR( src, sx, sy );
+           dstlin1 = RAS_ADDR( dst, dx, dy );
+
+           srcleftignore = ( sx & 1 ) * 16;
+           srclongs = ( srcleftignore + w * 16 + 31 ) >> 5;
+           srcrightignore = ( srclongs * 32 - w * 16 - srcleftignore ) & 31;
+           dstleftignore = ( dx & 1 ) * 16;
+           dstlongs = ( dstleftignore + w * 16 + 31 ) >> 5;
+           dstrightignore = ( dstlongs * 32 - w * 16 - dstleftignore ) & 31;
+
+           return raster_blit(
+               src, srclin1, srcleftignore, srcrightignore, srclongs,
+               dst, dstlin1, dstleftignore, dstrightignore, dstlongs, h, op );
+       }
+#endif /* RCONS_16BPP */
     return 0;
     }
 
@@ -990,7 +1097,7 @@
 
 #ifdef BCOPY_FASTER
        /* Special-case full-width clears. */
-       if ( op == RAS_CLEAR && dst->width == w && dst->linelongs == w >> 5 )
+       if ( op == RAS_CLEAR && dst->width == w && dst->linelongs == w >> 4 )
            {
            bzero( (char*) dstlin1, h * dst->linelongs * sizeof(u_int32_t) );
            return 0;
@@ -1080,7 +1187,7 @@
            }
        }
 #endif /* RCONS_2BPP */
-    else
+    else if ( dst->depth == 8)
        {
        /* Eight-bit no-src blit. */
        register u_int32_t color;
@@ -1184,6 +1291,112 @@
                }
            }
        }
+#ifdef RCONS_16BPP
+    else 
+       {
+       /* Sixteen-bit no-src blit. */
+       register u_int32_t color;
+       u_int32_t* dstlin1;
+       u_int32_t* dstlin2;
+       u_int32_t* dstlin;
+       int dstleftignore, dstrightignore, dstlongs;
+       u_int32_t dl, lm, nlm, rm, nrm;
+       register u_int32_t* dstlong2;
+       register u_int32_t* dstlong;
+
+       dstlin1 = RAS_ADDR( dst, dx, dy );
+
+#ifdef BCOPY_FASTER
+       /* Special-case full-width clears. */
+       if ( op == RAS_CLEAR && dst->width == w && dst->linelongs == w >> 1 )
+           {
+           bzero( (char*) dstlin1, h * dst->linelongs * sizeof(u_int32_t) );
+           return 0;
+           }
+#endif /*BCOPY_FASTER*/
+
+       color = RAS_GETCOLOR( rop );
+       if ( color == 0 )
+               color = 255; /* XXX */
+
+       /* Make 32 bits of color so we can do the ROP without shifting. */
+       color |= ( color << 16 );
+
+       dstleftignore = ( dx & 1 ) * 16;
+       dstlongs = ( dstleftignore + w * 16 + 31 ) >> 5;
+       dstrightignore = ( dstlongs * 32 - w * 8 - dstleftignore ) & 31;
+
+       dstlin2 = dstlin1 + h * dst->linelongs;
+       dstlin = dstlin1;
+
+       if ( dstlongs == 1 )
+           {
+           /* It fits into a single longword. */
+           lm = leftmask[dstleftignore] | rightmask[dstrightignore];
+           nlm = ~lm;
+           while ( dstlin != dstlin2 )
+               {
+               ROP_DSTCOLOR(
+               /*op*/  op,
+               /*pre*/ dl = *dstlin;,
+               /*d*/   dl,
+               /*c*/   color,
+               /*pst*/ *dstlin = ( *dstlin & lm ) | ( dl & nlm ); )
+
+               dstlin += dst->linelongs;
+               }
+           }
+       else
+           {
+           lm = leftmask[dstleftignore];
+           rm = rightmask[dstrightignore];
+           nrm = ~rm;
+           nlm = ~lm;
+           while ( dstlin != dstlin2 )
+               {
+               dstlong = dstlin;
+               dstlong2 = dstlong + dstlongs;
+               if ( dstrightignore != 0 )
+                   --dstlong2;
+
+               /* Leading edge. */
+               if ( dstleftignore != 0 )
+                   {
+                   ROP_DSTCOLOR(
+                   /*op*/  op,
+                   /*pre*/ dl = *dstlong;,
+                   /*d*/   dl,
+                   /*c*/   color,
+                   /*pst*/ *dstlong = ( *dstlong & lm ) | ( dl & nlm ); )
+                   ++dstlong;
+                   }



Home | Main Index | Thread Index | Old Index