Module Name: src Committed By: tsutsui Date: Sat Oct 4 16:58:17 UTC 2014
Modified Files: src/sys/arch/luna68k/dev: lunafb.c omrasops.c omrasopsvar.h Log Message: Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k. http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2 >> Use raster(logic) operation, or ROP, function on LUNA frame buffer. >> It makes 4bpp wscons putchar ~20% faster. This Makes 4bpp wscons putchar ~30% on LUNA-II. Also use the similar ROP in 1bpp putchar and cursor functions and the 1bpp putchar is also ~5% faster. While here, reduce diffs from OpenBSD a bit. Tested on all 1bpp/4bpp/8bpp framebuffers. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/arch/luna68k/dev/lunafb.c cvs rdiff -u -r1.18 -r1.19 src/sys/arch/luna68k/dev/omrasops.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/luna68k/dev/omrasopsvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/luna68k/dev/lunafb.c diff -u src/sys/arch/luna68k/dev/lunafb.c:1.35 src/sys/arch/luna68k/dev/lunafb.c:1.36 --- src/sys/arch/luna68k/dev/lunafb.c:1.35 Fri Jul 25 16:40:12 2014 +++ src/sys/arch/luna68k/dev/lunafb.c Sat Oct 4 16:58:17 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: lunafb.c,v 1.35 2014/07/25 16:40:12 tsutsui Exp $ */ +/* $NetBSD: lunafb.c,v 1.36 2014/10/04 16:58:17 tsutsui Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.35 2014/07/25 16:40:12 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.36 2014/10/04 16:58:17 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -75,11 +75,8 @@ struct bt458 { }; #define OMFB_RFCNT 0xB1000000 /* video h-origin/v-origin */ -#define OMFB_PLANEMASK 0xB1040000 /* planemask register */ -#define OMFB_FB_WADDR 0xB1080008 /* common plane */ -#define OMFB_FB_RADDR 0xB10C0008 /* plane #0 */ -#define OMFB_ROPFUNC 0xB12C0000 /* ROP function code */ #define OMFB_RAMDAC 0xC1100000 /* Bt454/Bt458 RAMDAC */ + #define OMFB_SIZE (0xB1300000 - 0xB1080000 + PAGE_SIZE) struct hwcmap { Index: src/sys/arch/luna68k/dev/omrasops.c diff -u src/sys/arch/luna68k/dev/omrasops.c:1.18 src/sys/arch/luna68k/dev/omrasops.c:1.19 --- src/sys/arch/luna68k/dev/omrasops.c:1.18 Sun Sep 28 05:00:56 2014 +++ src/sys/arch/luna68k/dev/omrasops.c Sat Oct 4 16:58:17 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: omrasops.c,v 1.18 2014/09/28 05:00:56 tsutsui Exp $ */ +/* $NetBSD: omrasops.c,v 1.19 2014/10/04 16:58:17 tsutsui Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.18 2014/09/28 05:00:56 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.19 2014/10/04 16:58:17 tsutsui Exp $"); /* * Designed speficically for 'm68k bitorder'; @@ -78,13 +78,6 @@ static int omrasops_init(struct rasops_i #define ALIGNMASK (0x1f) #define BYTESDONE (4) -#define W(p) (*(uint32_t *)(p)) -#define R(p) (*(uint32_t *)((uint8_t *)(p) + 0x40000)) -#define P0(p) (*(uint32_t *)((uint8_t *)(p) + 0x40000)) -#define P1(p) (*(uint32_t *)((uint8_t *)(p) + 0x80000)) -#define P2(p) (*(uint32_t *)((uint8_t *)(p) + 0xc0000)) -#define P3(p) (*(uint32_t *)((uint8_t *)(p) + 0x100000)) - /* * macros to handle unaligned bit copy ops. * See src/sys/dev/rasops/rasops_mask.h for MI version. @@ -96,13 +89,13 @@ static int omrasops_init(struct rasops_i #define FASTGETBITS(psrc, x, w, dst) \ asm("bfextu %3{%1:%2},%0" \ : "=d" (dst) \ - : "di" (x), "di" (w), "o" ((uint32_t *)(psrc))) + : "di" (x), "di" (w), "o" (*(uint32_t *)(psrc))) /* luna68k version PUTBITS() that puts w bits from bit x at pdst memory */ /* XXX this macro assumes (x + w) <= 32 to handle unaligned residual bits */ #define FASTPUTBITS(src, x, w, pdst) \ asm("bfins %3,%0{%1:%2}" \ - : "+o" ((uint32_t *)(pdst)) \ + : "+o" (*(uint32_t *)(pdst)) \ : "di" (x), "di" (w), "d" (src) \ : "memory" ); @@ -137,16 +130,23 @@ om1_putchar(void *cookie, int row, int s rmask = ALL1BITS << (-width & ALIGNMASK); if (width <= BLITWIDTH) { lmask &= rmask; + /* set lmask as ROP mask value, with THROUGH mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = lmask; + while (height > 0) { glyph = 0; for (i = ri->ri_font->stride; i != 0; i--) glyph = (glyph << 8) | *fb++; glyph <<= (4 - ri->ri_font->stride) * NBBY; glyph = (glyph >> align) ^ inverse; - P0(p) = (P0(p) & ~lmask) | (glyph & lmask); + + *W(p) = glyph; + p += scanspan; height--; } + /* reset mask value */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS; } else { uint8_t *q = p; uint32_t lhalf, rhalf; @@ -157,14 +157,26 @@ om1_putchar(void *cookie, int row, int s glyph = (glyph << 8) | *fb++; glyph <<= (4 - ri->ri_font->stride) * NBBY; lhalf = (glyph >> align) ^ inverse; - P0(p) = (P0(p) & ~lmask) | (lhalf & lmask); + /* set lmask as ROP mask value, with THROUGH mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = + lmask; + + *W(p) = lhalf; + p += BYTESDONE; + rhalf = (glyph << (BLITWIDTH - align)) ^ inverse; - P0(p) = (rhalf & rmask) | (P0(p) & ~rmask); + /* set rmask as ROP mask value, with THROUGH mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = + rmask; + + *W(p) = rhalf; p = (q += scanspan); height--; } + /* reset mask value */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS; } } @@ -201,8 +213,15 @@ om4_putchar(void *cookie, int row, int s width = ri->ri_font->fontwidth + align; lmask = ALL1BITS >> align; rmask = ALL1BITS << (-width & ALIGNMASK); + + /* select all planes for later ROP function target */ + *(volatile uint32_t *)OMFB_PLANEMASK = 0xff; + if (width <= BLITWIDTH) { lmask &= rmask; + /* set lmask as ROP mask value, with THROUGH mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = lmask; + while (height > 0) { glyph = 0; for (i = ri->ri_font->stride; i != 0; i--) @@ -210,21 +229,25 @@ om4_putchar(void *cookie, int row, int s glyph <<= (4 - ri->ri_font->stride) * NBBY; glyph = (glyph >> align); glyphbg = glyph ^ ALL1BITS; + fgpat = glyph & fgmask0; bgpat = glyphbg & bgmask0; - P0(p) = (P0(p) & ~lmask) | ((fgpat | bgpat) & lmask); + *P0(p) = (fgpat | bgpat); fgpat = glyph & fgmask1; bgpat = glyphbg & bgmask1; - P1(p) = (P1(p) & ~lmask) | ((fgpat | bgpat) & lmask); + *P1(p) = (fgpat | bgpat); fgpat = glyph & fgmask2; bgpat = glyphbg & bgmask2; - P2(p) = (P2(p) & ~lmask) | ((fgpat | bgpat) & lmask); + *P2(p) = (fgpat | bgpat); fgpat = glyph & fgmask3; bgpat = glyphbg & bgmask3; - P3(p) = (P3(p) & ~lmask) | ((fgpat | bgpat) & lmask); + *P3(p) = (fgpat | bgpat); + p += scanspan; height--; } + /* reset mask value */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS; } else { uint8_t *q = p; uint32_t lhalf, rhalf; @@ -237,38 +260,52 @@ om4_putchar(void *cookie, int row, int s glyph <<= (4 - ri->ri_font->stride) * NBBY; lhalf = (glyph >> align); lhalfbg = lhalf ^ ALL1BITS; + /* set lmask as ROP mask value, with THROUGH mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = + lmask; + fgpat = lhalf & fgmask0; bgpat = lhalfbg & bgmask0; - P0(p) = (P0(p) & ~lmask) | ((fgpat | bgpat) & lmask); + *P0(p) = (fgpat | bgpat); fgpat = lhalf & fgmask1; bgpat = lhalfbg & bgmask1; - P1(p) = (P1(p) & ~lmask) | ((fgpat | bgpat) & lmask); + *P1(p) = (fgpat | bgpat); fgpat = lhalf & fgmask2; bgpat = lhalfbg & bgmask2; - P2(p) = (P2(p) & ~lmask) | ((fgpat | bgpat) & lmask); + *P2(p) = (fgpat | bgpat); fgpat = lhalf & fgmask3; bgpat = lhalfbg & bgmask3; - P3(p) = (P3(p) & ~lmask) | ((fgpat | bgpat) & lmask); + *P3(p) = (fgpat | bgpat); + p += BYTESDONE; + rhalf = (glyph << (BLITWIDTH - align)); rhalfbg = rhalf ^ ALL1BITS; + /* set rmask as ROP mask value, with THROUGH mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = + rmask; + fgpat = rhalf & fgmask0; bgpat = rhalfbg & bgmask0; - P0(p) = ((fgpat | bgpat) & rmask) | (P0(p) & ~rmask); + *P0(p) = (fgpat | bgpat); fgpat = rhalf & fgmask1; bgpat = rhalfbg & bgmask1; - P1(p) = ((fgpat | bgpat) & rmask) | (P1(p) & ~rmask); + *P1(p) = (fgpat | bgpat); fgpat = rhalf & fgmask2; bgpat = rhalfbg & bgmask2; - P2(p) = ((fgpat | bgpat) & rmask) | (P2(p) & ~rmask); + *P2(p) = (fgpat | bgpat); fgpat = rhalf & fgmask3; bgpat = rhalfbg & bgmask3; - P3(p) = ((fgpat | bgpat) & rmask) | (P3(p) & ~rmask); + *P3(p) = (fgpat | bgpat); p = (q += scanspan); height--; } + /* reset mask value */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS; } + /* select plane #0 only; XXX need this ? */ + *(volatile uint32_t *)OMFB_PLANEMASK = 0x01; } static void @@ -295,22 +332,22 @@ om1_erasecols(void *cookie, int row, int lmask &= rmask; fill &= lmask; while (height > 0) { - P0(p) = (P0(p) & ~lmask) | fill; + *P0(p) = (*P0(p) & ~lmask) | fill; p += scanspan; height--; } } else { uint8_t *q = p; while (height > 0) { - P0(p) = (P0(p) & ~lmask) | (fill & lmask); + *P0(p) = (*P0(p) & ~lmask) | (fill & lmask); width -= 2 * BLITWIDTH; while (width > 0) { p += BYTESDONE; - P0(p) = fill; + *P0(p) = fill; width -= BLITWIDTH; } p += BYTESDONE; - P0(p) = (fill & rmask) | (P0(p) & ~rmask); + *P0(p) = (fill & rmask) | (*P0(p) & ~rmask); p = (q += scanspan); width = w + align; @@ -350,34 +387,34 @@ om4_erasecols(void *cookie, int row, int fill2 &= lmask; fill3 &= lmask; while (height > 0) { - P0(p) = (P0(p) & ~lmask) | fill0; - P1(p) = (P1(p) & ~lmask) | fill1; - P2(p) = (P2(p) & ~lmask) | fill2; - P3(p) = (P3(p) & ~lmask) | fill3; + *P0(p) = (*P0(p) & ~lmask) | fill0; + *P1(p) = (*P1(p) & ~lmask) | fill1; + *P2(p) = (*P2(p) & ~lmask) | fill2; + *P3(p) = (*P3(p) & ~lmask) | fill3; p += scanspan; height--; } } else { uint8_t *q = p; while (height > 0) { - P0(p) = (P0(p) & ~lmask) | (fill0 & lmask); - P1(p) = (P1(p) & ~lmask) | (fill1 & lmask); - P2(p) = (P2(p) & ~lmask) | (fill2 & lmask); - P3(p) = (P3(p) & ~lmask) | (fill3 & lmask); + *P0(p) = (*P0(p) & ~lmask) | (fill0 & lmask); + *P1(p) = (*P1(p) & ~lmask) | (fill1 & lmask); + *P2(p) = (*P2(p) & ~lmask) | (fill2 & lmask); + *P3(p) = (*P3(p) & ~lmask) | (fill3 & lmask); width -= 2 * BLITWIDTH; while (width > 0) { p += BYTESDONE; - P0(p) = fill0; - P1(p) = fill1; - P2(p) = fill2; - P3(p) = fill3; + *P0(p) = fill0; + *P1(p) = fill1; + *P2(p) = fill2; + *P3(p) = fill3; width -= BLITWIDTH; } p += BYTESDONE; - P0(p) = (fill0 & rmask) | (P0(p) & ~rmask); - P1(p) = (fill1 & rmask) | (P1(p) & ~rmask); - P2(p) = (fill2 & rmask) | (P2(p) & ~rmask); - P3(p) = (fill3 & rmask) | (P3(p) & ~rmask); + *P0(p) = (fill0 & rmask) | (*P0(p) & ~rmask); + *P1(p) = (fill1 & rmask) | (*P1(p) & ~rmask); + *P2(p) = (fill2 & rmask) | (*P2(p) & ~rmask); + *P3(p) = (fill3 & rmask) | (*P3(p) & ~rmask); p = (q += scanspan); width = w + align; @@ -405,15 +442,15 @@ om1_eraserows(void *cookie, int startrow rmask = ALL1BITS << (-width & ALIGNMASK); q = p; while (height > 0) { - P0(p) = fill; /* always aligned */ + *P0(p) = fill; /* always aligned */ width -= 2 * BLITWIDTH; while (width > 0) { p += BYTESDONE; - P0(p) = fill; + *P0(p) = fill; width -= BLITWIDTH; } p += BYTESDONE; - P0(p) = (fill & rmask) | (P0(p) & ~rmask); + *P0(p) = (fill & rmask) | (*P0(p) & ~rmask); p = (q += scanspan); width = w; height--; @@ -443,24 +480,24 @@ om4_eraserows(void *cookie, int startrow rmask = ALL1BITS << (-width & ALIGNMASK); q = p; while (height > 0) { - P0(p) = fill0; /* always aligned */ - P1(p) = fill1; - P2(p) = fill2; - P3(p) = fill3; + *P0(p) = fill0; /* always aligned */ + *P1(p) = fill1; + *P2(p) = fill2; + *P3(p) = fill3; width -= 2 * BLITWIDTH; while (width > 0) { p += BYTESDONE; - P0(p) = fill0; - P1(p) = fill1; - P2(p) = fill2; - P3(p) = fill3; + *P0(p) = fill0; + *P1(p) = fill1; + *P2(p) = fill2; + *P3(p) = fill3; width -= BLITWIDTH; } p += BYTESDONE; - P0(p) = (fill0 & rmask) | (P0(p) & ~rmask); - P1(p) = (fill1 & rmask) | (P1(p) & ~rmask); - P2(p) = (fill2 & rmask) | (P2(p) & ~rmask); - P3(p) = (fill3 & rmask) | (P3(p) & ~rmask); + *P0(p) = (fill0 & rmask) | (*P0(p) & ~rmask); + *P1(p) = (fill1 & rmask) | (*P1(p) & ~rmask); + *P2(p) = (fill2 & rmask) | (*P2(p) & ~rmask); + *P3(p) = (fill3 & rmask) | (*P3(p) & ~rmask); p = (q += scanspan); width = w; height--; @@ -490,15 +527,15 @@ om1_copyrows(void *cookie, int srcrow, i rmask = ALL1BITS << (-width & ALIGNMASK); q = p; while (height > 0) { - P0(p + offset) = P0(p); /* always aligned */ + *P0(p + offset) = *P0(p); /* always aligned */ width -= 2 * BLITWIDTH; while (width > 0) { p += BYTESDONE; - P0(p + offset) = P0(p); + *P0(p + offset) = *P0(p); width -= BLITWIDTH; } p += BYTESDONE; - P0(p + offset) = (P0(p) & rmask) | (P0(p + offset) & ~rmask); + *P0(p + offset) = (*P0(p) & rmask) | (*P0(p + offset) & ~rmask); p = (q += scanspan); width = w; @@ -529,24 +566,24 @@ om4_copyrows(void *cookie, int srcrow, i rmask = ALL1BITS << (-width & ALIGNMASK); q = p; while (height > 0) { - P0(p + offset) = P0(p); /* always aligned */ - P1(p + offset) = P1(p); - P2(p + offset) = P2(p); - P3(p + offset) = P3(p); + *P0(p + offset) = *P0(p); /* always aligned */ + *P1(p + offset) = *P1(p); + *P2(p + offset) = *P2(p); + *P3(p + offset) = *P3(p); width -= 2 * BLITWIDTH; while (width > 0) { p += BYTESDONE; - P0(p + offset) = P0(p); - P1(p + offset) = P1(p); - P2(p + offset) = P2(p); - P3(p + offset) = P3(p); + *P0(p + offset) = *P0(p); + *P1(p + offset) = *P1(p); + *P2(p + offset) = *P2(p); + *P3(p + offset) = *P3(p); width -= BLITWIDTH; } p += BYTESDONE; - P0(p + offset) = (P0(p) & rmask) | (P0(p + offset) & ~rmask); - P1(p + offset) = (P1(p) & rmask) | (P1(p + offset) & ~rmask); - P2(p + offset) = (P2(p) & rmask) | (P2(p + offset) & ~rmask); - P3(p + offset) = (P3(p) & rmask) | (P3(p + offset) & ~rmask); + *P0(p + offset) = (*P0(p) & rmask) | (*P0(p + offset) & ~rmask); + *P1(p + offset) = (*P1(p) & rmask) | (*P1(p + offset) & ~rmask); + *P2(p + offset) = (*P2(p) & rmask) | (*P2(p + offset) & ~rmask); + *P3(p + offset) = (*P3(p) & rmask) | (*P3(p + offset) & ~rmask); p = (q += scanspan); width = w; @@ -628,7 +665,7 @@ om1_copycols(void *cookie, int startrow, for (cnt = full; cnt; cnt--) { GETBITS(P0(sp), sboff, 32, tmp); - P0(dp) = tmp; + *P0(dp) = tmp; sp += BYTESDONE; dp += BYTESDONE; } @@ -666,7 +703,7 @@ om1_copycols(void *cookie, int startrow, sp -= BYTESDONE; dp -= BYTESDONE; GETBITS(P0(sp), sboff, 32, tmp); - P0(dp) = tmp; + *P0(dp) = tmp; } if (lmask != 0) { @@ -770,13 +807,13 @@ om4_copycols(void *cookie, int startrow, for (cnt = full; cnt; cnt--) { GETBITS(P0(sp), sboff, 32, tmp); - P0(dp) = tmp; + *P0(dp) = tmp; GETBITS(P1(sp), sboff, 32, tmp); - P1(dp) = tmp; + *P1(dp) = tmp; GETBITS(P2(sp), sboff, 32, tmp); - P2(dp) = tmp; + *P2(dp) = tmp; GETBITS(P3(sp), sboff, 32, tmp); - P3(dp) = tmp; + *P3(dp) = tmp; sp += BYTESDONE; dp += BYTESDONE; } @@ -826,13 +863,13 @@ om4_copycols(void *cookie, int startrow, sp -= BYTESDONE; dp -= BYTESDONE; GETBITS(P0(sp), sboff, 32, tmp); - P0(dp) = tmp; + *P0(dp) = tmp; GETBITS(P1(sp), sboff, 32, tmp); - P1(dp) = tmp; + *P1(dp) = tmp; GETBITS(P2(sp), sboff, 32, tmp); - P2(dp) = tmp; + *P2(dp) = tmp; GETBITS(P3(sp), sboff, 32, tmp); - P3(dp) = tmp; + *P3(dp) = tmp; } if (lmask != 0) { @@ -891,7 +928,7 @@ om1_cursor(void *cookie, int on, int row struct rasops_info *ri = cookie; uint8_t *p; int scanspan, startx, height, width, align, y; - uint32_t lmask, rmask, image; + uint32_t lmask, rmask; if (!on) { /* make sure it's on */ @@ -918,25 +955,35 @@ om1_cursor(void *cookie, int on, int row rmask = ALL1BITS << (-width & ALIGNMASK); if (width <= BLITWIDTH) { lmask &= rmask; + /* set lmask as ROP mask value, with INV2 mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = lmask; + while (height > 0) { - image = P0(p); - P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask); + *P0(p) = ALL1BITS; p += scanspan; height--; } + /* reset mask value */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS; } else { uint8_t *q = p; while (height > 0) { - image = P0(p); - P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask); + /* set lmask as ROP mask value, with INV2 mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = lmask; + *W(p) = ALL1BITS; + p += BYTESDONE; - image = P0(p); - P0(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask); + + /* set lmask as ROP mask value, with INV2 mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = rmask; + *W(p) = ALL1BITS; p = (q += scanspan); height--; } + /* reset mask value */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS; } ri->ri_flg ^= RI_CURSOR; } @@ -947,7 +994,7 @@ om4_cursor(void *cookie, int on, int row struct rasops_info *ri = cookie; uint8_t *p; int scanspan, startx, height, width, align, y; - uint32_t lmask, rmask, image; + uint32_t lmask, rmask; if (!on) { /* make sure it's on */ @@ -972,46 +1019,45 @@ om4_cursor(void *cookie, int on, int row width = ri->ri_font->fontwidth + align; lmask = ALL1BITS >> align; rmask = ALL1BITS << (-width & ALIGNMASK); + + /* select all planes for later ROP function target */ + *(volatile uint32_t *)OMFB_PLANEMASK = 0xff; + if (width <= BLITWIDTH) { lmask &= rmask; + /* set lmask as ROP mask value, with INV2 mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = lmask; + while (height > 0) { - image = P0(p); - P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask); - image = P1(p); - P1(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask); - image = P2(p); - P2(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask); - image = P3(p); - P3(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask); + *W(p) = ALL1BITS; p += scanspan; height--; } + /* reset mask value */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS; } else { uint8_t *q = p; while (height > 0) { - image = P0(p); - P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask); - image = P1(p); - P1(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask); - image = P2(p); - P2(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask); - image = P3(p); - P3(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask); + /* set lmask as ROP mask value, with INV2 mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = lmask; + *W(p) = ALL1BITS; + p += BYTESDONE; - image = P0(p); - P0(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask); - image = P1(p); - P1(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask); - image = P2(p); - P2(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask); - image = P3(p); - P3(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask); + + /* set rmask as ROP mask value, with INV2 mode */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = rmask; + *W(p) = ALL1BITS; p = (q += scanspan); height--; } + /* reset mask value */ + ((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS; } + /* select plane #0 only; XXX need this ? */ + *(volatile uint32_t *)OMFB_PLANEMASK = 0x01; + ri->ri_flg ^= RI_CURSOR; } Index: src/sys/arch/luna68k/dev/omrasopsvar.h diff -u src/sys/arch/luna68k/dev/omrasopsvar.h:1.2 src/sys/arch/luna68k/dev/omrasopsvar.h:1.3 --- src/sys/arch/luna68k/dev/omrasopsvar.h:1.2 Sat Dec 28 09:17:23 2013 +++ src/sys/arch/luna68k/dev/omrasopsvar.h Sat Oct 4 16:58:17 2014 @@ -1,30 +1,69 @@ -/* $NetBSD: omrasopsvar.h,v 1.2 2013/12/28 09:17:23 tsutsui Exp $ */ +/* $NetBSD: omrasopsvar.h,v 1.3 2014/10/04 16:58:17 tsutsui Exp $ */ +/* + * Copyright (c) 2013 Kenji Aoyama + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Base addresses of LUNA's frame buffer + * XXX: We consider only 1bpp and 4bpp for now + */ -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. +#define OMFB_PLANEMASK 0xB1040000 /* BMSEL register */ +#define OMFB_FB_WADDR 0xB1080008 /* common plane */ +#define OMFB_FB_RADDR 0xB10C0008 /* plane #0 */ +#define OMFB_ROPFUNC 0xB12C0000 /* common ROP function */ + +/* + * Helper macros + */ +#define W(addr) ((uint32_t *)(addr)) +#define R(addr) ((uint32_t *)((uint8_t *)(addr) + 0x40000)) +#define P0(addr) ((uint32_t *)((uint8_t *)(addr) + 0x40000)) +#define P1(addr) ((uint32_t *)((uint8_t *)(addr) + 0x80000)) +#define P2(addr) ((uint32_t *)((uint8_t *)(addr) + 0xC0000)) +#define P3(addr) ((uint32_t *)((uint8_t *)(addr) + 0x100000)) + +/* + * ROP function * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * LUNA's frame buffer uses Hitach HM53462 video RAM, which has raster + * (logic) operation, or ROP, function. To use ROP function on LUNA, write + * a 32bit `mask' value to the specified address corresponding to each ROP + * logic. * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * D: the data writing to the video RAM + * M: the data already stored on the video RAM */ +/* operation index the video RAM contents will be */ +#define ROP_ZERO 0 /* all 0 */ +#define ROP_AND1 1 /* D & M */ +#define ROP_AND2 2 /* ~D & M */ +/* Not used on LUNA 3 */ +#define ROP_AND3 4 /* D & ~M */ +#define ROP_THROUGH 5 /* D */ +#define ROP_EOR 6 /* (~D & M) | (D & ~M) */ +#define ROP_OR1 7 /* D | M */ +#define ROP_NOR 8 /* ~D | ~M */ +#define ROP_ENOR 9 /* (D & M) | (~D & ~M) */ +#define ROP_INV1 10 /* ~D */ +#define ROP_OR2 11 /* ~D | M */ +#define ROP_INV2 12 /* ~M */ +#define ROP_OR3 13 /* D | ~M */ +#define ROP_NAND 14 /* ~D | ~M */ +#define ROP_ONE 15 /* all 1 */ + int omrasops1_init(struct rasops_info *, int, int); int omrasops4_init(struct rasops_info *, int, int);