Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/luna68k/dev Add preleminary support of 4bpp LUNA fr...



details:   https://anonhg.NetBSD.org/src/rev/a0d31b9dd7a3
branches:  trunk
changeset: 792278:a0d31b9dd7a3
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Dec 28 09:17:23 2013 +0000

description:
Add preleminary support of 4bpp LUNA framebuffer.

Changes details:
- prepare and switch 4bpp rasops functions that read/write all 4 planes
  and also handle both fg and bg colors
- make 1bpp ops use first plane on write rather than common bitmap plane
  (which is prepared for multiple plane write with raster ops)
- prepare 4bpp allocattr function to handle ANSI 16 color text
- split omrasops_init() function for each bpp
- move struct hwcmap from softc to hwdevconfig to sync palette values
  on initialization
- allow mmap(2) against all available planes

Now we can use ANSI 16 color text console and also can
demonstrate mlterm-fb with color sixel graphics and wallpaper.
XXX: Xserver needs much more work.

diffstat:

 sys/arch/luna68k/dev/lunafb.c      |  121 +++--
 sys/arch/luna68k/dev/omrasops.c    |  722 ++++++++++++++++++++++++++++++++----
 sys/arch/luna68k/dev/omrasopsvar.h |    5 +-
 3 files changed, 716 insertions(+), 132 deletions(-)

diffs (truncated from 1229 to 300 lines):

diff -r 4480a952933f -r a0d31b9dd7a3 sys/arch/luna68k/dev/lunafb.c
--- a/sys/arch/luna68k/dev/lunafb.c     Sat Dec 28 03:51:52 2013 +0000
+++ b/sys/arch/luna68k/dev/lunafb.c     Sat Dec 28 09:17:23 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.28 2013/12/14 19:51:13 tsutsui Exp $ */
+/* $NetBSD: lunafb.c,v 1.29 2013/12/28 09:17:23 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.28 2013/12/14 19:51:13 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.29 2013/12/28 09:17:23 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -82,16 +82,6 @@
 #define        OMFB_RAMDAC     0xC1100000      /* Bt454/Bt458 RAMDAC */
 #define        OMFB_SIZE       (0xB1300000 - 0xB1080000 + PAGE_SIZE)
 
-struct om_hwdevconfig {
-       int     dc_wid;                 /* width of frame buffer */
-       int     dc_ht;                  /* height of frame buffer */
-       int     dc_depth;               /* depth, bits per pixel */
-       int     dc_rowbytes;            /* bytes in a FB scan line */
-       int     dc_cmsize;              /* colormap size */
-       vaddr_t dc_videobase;           /* base of flat frame buffer */
-       struct rasops_info dc_ri;       /* raster blitter variables */
-};
-
 struct hwcmap {
 #define CMAP_SIZE 256
        uint8_t r[CMAP_SIZE];
@@ -99,10 +89,43 @@
        uint8_t b[CMAP_SIZE];
 };
 
+static const struct {
+       uint8_t r;
+       uint8_t g;
+       uint8_t b;
+} ansicmap[16] = {
+       {    0,    0,    0},
+       { 0x80,    0,    0},
+       {    0, 0x80,    0},
+       { 0x80, 0x80,    0},
+       {    0,    0, 0x80},
+       { 0x80,    0, 0x80},
+       {    0, 0x80, 0x80},
+       { 0xc0, 0xc0, 0xc0},
+       { 0x80, 0x80, 0x80},
+       { 0xff,    0,    0},
+       {    0, 0xff,    0},
+       { 0xff, 0xff,    0},
+       {    0,    0, 0xff},
+       { 0xff,    0, 0xff},
+       {    0, 0xff, 0xff},
+       { 0xff, 0xff, 0xff},
+};
+
+struct om_hwdevconfig {
+       int     dc_wid;                 /* width of frame buffer */
+       int     dc_ht;                  /* height of frame buffer */
+       int     dc_depth;               /* depth, bits per pixel */
+       int     dc_rowbytes;            /* bytes in a FB scan line */
+       int     dc_cmsize;              /* colormap size */
+       struct hwcmap dc_cmap;          /* software copy of colormap */
+       vaddr_t dc_videobase;           /* base of flat frame buffer */
+       struct rasops_info dc_ri;       /* raster blitter variables */
+};
+
 struct omfb_softc {
        device_t sc_dev;                /* base device */
        struct om_hwdevconfig *sc_dc;   /* device configuration */
-       struct hwcmap sc_cmap;          /* software copy of colormap */
        int nscreens;
 };
 
@@ -188,10 +211,6 @@
        aprint_normal(": %d x %d, %dbpp\n", sc->sc_dc->dc_wid, sc->sc_dc->dc_ht,
            sc->sc_dc->dc_depth);
 
-       /* WHITE on BLACK */
-       memset(&sc->sc_cmap, 255, sizeof(struct hwcmap));
-       sc->sc_cmap.r[0] = sc->sc_cmap.g[0] = sc->sc_cmap.b[0] = 0;
-
        waa.console = omfb_console;
        waa.scrdata = &omfb_screenlist;
        waa.accessops = &omfb_accessops;
@@ -271,7 +290,7 @@
        if (offset >= 0 && offset < OMFB_SIZE)
                cookie = m68k_btop(m68k_trunc_page(dc->dc_videobase) + offset);
 #else
-       if (offset >= 0 && offset < dc->dc_rowbytes * dc->dc_ht)
+       if (offset >= 0 && offset < dc->dc_rowbytes * dc->dc_ht * dc->dc_depth)
                cookie = m68k_btop(m68k_trunc_page(OMFB_FB_RADDR) + offset);
 #endif
 
@@ -288,13 +307,13 @@
        if (index >= cmsize || count > cmsize - index)
                return EINVAL;
 
-       error = copyout(&sc->sc_cmap.r[index], p->red, count);
+       error = copyout(&sc->sc_dc->dc_cmap.r[index], p->red, count);
        if (error)
                return error;
-       error = copyout(&sc->sc_cmap.g[index], p->green, count);
+       error = copyout(&sc->sc_dc->dc_cmap.g[index], p->green, count);
        if (error)
                return error;
-       error = copyout(&sc->sc_cmap.b[index], p->blue, count);
+       error = copyout(&sc->sc_dc->dc_cmap.b[index], p->blue, count);
        return error;
 }
 
@@ -319,24 +338,24 @@
        if (error)
                return error;
 
-       memcpy(&sc->sc_cmap.r[index], &cmap.r[index], count);
-       memcpy(&sc->sc_cmap.g[index], &cmap.g[index], count);
-       memcpy(&sc->sc_cmap.b[index], &cmap.b[index], count);
+       memcpy(&sc->sc_dc->dc_cmap.r[index], &cmap.r[index], count);
+       memcpy(&sc->sc_dc->dc_cmap.g[index], &cmap.g[index], count);
+       memcpy(&sc->sc_dc->dc_cmap.b[index], &cmap.b[index], count);
        if (hwplanemask == 0x0f) {
                struct bt454 *odac = (struct bt454 *)OMFB_RAMDAC;
                odac->bt_addr = index;
                for (i = index; i < index + count; i++) {
-                       odac->bt_cmap = sc->sc_cmap.r[i];
-                       odac->bt_cmap = sc->sc_cmap.g[i];
-                       odac->bt_cmap = sc->sc_cmap.b[i];
+                       odac->bt_cmap = sc->sc_dc->dc_cmap.r[i];
+                       odac->bt_cmap = sc->sc_dc->dc_cmap.g[i];
+                       odac->bt_cmap = sc->sc_dc->dc_cmap.b[i];
                }
        } else if (hwplanemask == 0xff) {
                struct bt458 *ndac = (struct bt458 *)OMFB_RAMDAC;
                ndac->bt_addr = index;
                for (i = index; i < index + count; i++) {
-                       ndac->bt_cmap = sc->sc_cmap.r[i];
-                       ndac->bt_cmap = sc->sc_cmap.g[i];
-                       ndac->bt_cmap = sc->sc_cmap.b[i];
+                       ndac->bt_cmap = sc->sc_dc->dc_cmap.r[i];
+                       ndac->bt_cmap = sc->sc_dc->dc_cmap.g[i];
+                       ndac->bt_cmap = sc->sc_dc->dc_cmap.b[i];
                }
        }
        return 0;
@@ -358,7 +377,7 @@
                break;
        default:
        case 0x0f:
-#if 0
+#if 1
                /*
                 * XXX
                 * experiment resulted in WHITE on SKYBLUE after Xorg server
@@ -389,28 +408,25 @@
                 */
                odac->bt_addr = 0;
                for (i = 0; i < 15; i++) {
-                       odac->bt_cmap = 0;
-                       odac->bt_cmap = 0;
-                       odac->bt_cmap = 0;
+                       odac->bt_cmap = dc->dc_cmap.r[i] = 0;
+                       odac->bt_cmap = dc->dc_cmap.g[i] = 0;
+                       odac->bt_cmap = dc->dc_cmap.b[i] = 0;
                }
                /*
                 * The B/W video connector is connected to IOG of Bt454,
                 * and IOR and IOB are unused.
                 */
-               odac->bt_cmap = 0;
-               odac->bt_cmap = 255;
-               odac->bt_cmap = 0;
+               odac->bt_cmap = dc->dc_cmap.r[15] = 0;
+               odac->bt_cmap = dc->dc_cmap.g[15] = 255;
+               odac->bt_cmap = dc->dc_cmap.b[15] = 0;
        } else if (hwplanemask == 0x0f) {
                struct bt454 *odac = (struct bt454 *)OMFB_RAMDAC;
 
                odac->bt_addr = 0;
-               odac->bt_cmap = 0;
-               odac->bt_cmap = 0;
-               odac->bt_cmap = 0;
-               for (i = 1; i < 16; i++) {
-                       odac->bt_cmap = 255;
-                       odac->bt_cmap = 255;
-                       odac->bt_cmap = 255;
+               for (i = 0; i < 16; i++) {
+                       odac->bt_cmap = dc->dc_cmap.r[i] = ansicmap[i].r;
+                       odac->bt_cmap = dc->dc_cmap.g[i] = ansicmap[i].g;
+                       odac->bt_cmap = dc->dc_cmap.b[i] = ansicmap[i].b;
                }
        } else if (hwplanemask == 0xff) {
                struct bt458 *ndac = (struct bt458 *)OMFB_RAMDAC;
@@ -421,13 +437,13 @@
                ndac->bt_ctrl = 0x43; /* pallete enabled, ovly plane */
                ndac->bt_ctrl = 0x00; /* no test mode */
                ndac->bt_addr = 0;
-               ndac->bt_cmap = 0;
-               ndac->bt_cmap = 0;
-               ndac->bt_cmap = 0;
+               ndac->bt_cmap = dc->dc_cmap.r[0] = 0;
+               ndac->bt_cmap = dc->dc_cmap.g[0] = 0;
+               ndac->bt_cmap = dc->dc_cmap.b[0] = 0;
                for (i = 1; i < 256; i++) {
-                       ndac->bt_cmap = 255;
-                       ndac->bt_cmap = 255;
-                       ndac->bt_cmap = 255;
+                       ndac->bt_cmap = dc->dc_cmap.r[i] = 255;
+                       ndac->bt_cmap = dc->dc_cmap.g[i] = 255;
+                       ndac->bt_cmap = dc->dc_cmap.b[i] = 255;
                }
        }
 
@@ -456,7 +472,10 @@
                ri->ri_flg |= RI_NO_AUTO;
        ri->ri_hw = dc;
 
-       omrasops_init(ri, 34, 80);
+       if (bpp == 4)
+               omrasops4_init(ri, 34, 80);
+       else
+               omrasops1_init(ri, 34, 80);
 
        omfb_stdscreen.nrows = ri->ri_rows;
        omfb_stdscreen.ncols = ri->ri_cols;
diff -r 4480a952933f -r a0d31b9dd7a3 sys/arch/luna68k/dev/omrasops.c
--- a/sys/arch/luna68k/dev/omrasops.c   Sat Dec 28 03:51:52 2013 +0000
+++ b/sys/arch/luna68k/dev/omrasops.c   Sat Dec 28 09:17:23 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omrasops.c,v 1.15 2013/12/14 19:27:41 tsutsui Exp $ */
+/* $NetBSD: omrasops.c,v 1.16 2013/12/28 09:17:23 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.15 2013/12/14 19:27:41 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.16 2013/12/28 09:17:23 tsutsui Exp $");
 
 /*
  * Designed speficically for 'm68k bitorder';
@@ -53,14 +53,23 @@
 #include <arch/luna68k/dev/omrasopsvar.h>
 
 /* wscons emulator operations */
-static void    om_cursor(void *, int, int, int);
+static void    om1_cursor(void *, int, int, int);
+static void    om4_cursor(void *, int, int, int);
 static int     om_mapchar(void *, int, unsigned int *);
-static void    om_putchar(void *, int, int, u_int, long);
-static void    om_copycols(void *, int, int, int, int);
-static void    om_copyrows(void *, int, int, int num);
-static void    om_erasecols(void *, int, int, int, long);
-static void    om_eraserows(void *, int, int, long);
-static int     om_allocattr(void *, int, int, int, long *);
+static void    om1_putchar(void *, int, int, u_int, long);
+static void    om4_putchar(void *, int, int, u_int, long);
+static void    om1_copycols(void *, int, int, int, int);
+static void    om4_copycols(void *, int, int, int, int);
+static void    om1_copyrows(void *, int, int, int num);
+static void    om4_copyrows(void *, int, int, int num);
+static void    om1_erasecols(void *, int, int, int, long);
+static void    om4_erasecols(void *, int, int, int, long);
+static void    om1_eraserows(void *, int, int, long);
+static void    om4_eraserows(void *, int, int, long);
+static int     om1_allocattr(void *, int, int, int, long *);
+static int     om4_allocattr(void *, int, int, int, long *);
+
+static int     omrasops_init(struct rasops_info *, int, int);
 
 #define        ALL1BITS        (~0U)
 #define        ALL0BITS        (0U)
@@ -70,6 +79,10 @@
 
 #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.
@@ -82,19 +95,15 @@
 #define        FASTGETBITS(psrc, x, w, dst)                                    \
        asm("bfextu %3{%1:%2},%0"                                       \
            : "=d" (dst)                                                \
-           : "di" (x), "di" (w), "o" R(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 */



Home | Main Index | Thread Index | Old Index