Source-Changes-HG archive

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

[src/netbsd-6]: src/sys/arch/luna68k/dev Pull up following revision(s) (reque...



details:   https://anonhg.NetBSD.org/src/rev/8fb0af3a5f4b
branches:  netbsd-6
changeset: 776545:8fb0af3a5f4b
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Jan 12 12:25:03 2014 +0000

description:
Pull up following revision(s) (requested by tsutsui in ticket #1005):
        sys/arch/luna68k/dev/omrasops.c: revision 1.15
        sys/arch/luna68k/dev/omrasops.c: revision 1.16
        sys/arch/luna68k/dev/lunafb.c: revision 1.27
        sys/arch/luna68k/dev/lunafb.c: revision 1.28
        sys/arch/luna68k/dev/lunafb.c: revision 1.29
        sys/arch/luna68k/dev/lunafb.c: revision 1.30
        sys/arch/luna68k/dev/omrasopsvar.h: revision 1.2
        sys/arch/luna68k/dev/omrasops.c: revision 1.14
Properly initialize the palette for while on black even on 1bpp framebuffer.
Preparing for demonstration in Open Source Conference 2013 Kyoto.
Fix off by one in copyrows() backward case.
Make omrasops copycols() op work even if columns are not 32 bit aligned.
This means command line editing works properly in any cases.
The bitcopy strategies for 1bpp copycols() op are taken from
recently fixed MI sys/dev/rasops/rasops_bitops.h.
GETBITS() and PUTBITS() m68k asm macro are taken from hp300.
Tested on both 1bpp (on LUNA-II) and 4bpp (on LUNA) framebuffers.
Initialize capabilities in struct wsscreen_descr per omrasops settings.
Now REVERSE characters are drawn properly.
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.
Pull a fix of Bt458 (8bpp framebuffer) initialization from OpenBSD/luna88k.
http://marc.info/?l=openbsd-cvs&m=138838884202196
> Correct initialization of Bt458, used in LUNA's 8bpp frame buffer.
>
> According to the manual, the address register does not automatically
> increment when we access to the control registers.  Also we disable
> overlay planes, because we do not use them.

diffstat:

 sys/arch/luna68k/dev/lunafb.c      |  142 ++++--
 sys/arch/luna68k/dev/omrasops.c    |  850 ++++++++++++++++++++++++++++++++----
 sys/arch/luna68k/dev/omrasopsvar.h |    5 +-
 3 files changed, 836 insertions(+), 161 deletions(-)

diffs (truncated from 1369 to 300 lines):

diff -r 44b5c3cd862d -r 8fb0af3a5f4b sys/arch/luna68k/dev/lunafb.c
--- a/sys/arch/luna68k/dev/lunafb.c     Sun Jan 12 12:21:16 2014 +0000
+++ b/sys/arch/luna68k/dev/lunafb.c     Sun Jan 12 12:25:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.25.8.1 2012/07/25 21:30:35 martin Exp $ */
+/* $NetBSD: lunafb.c,v 1.25.8.2 2014/01/12 12:25:03 bouyer 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.25.8.1 2012/07/25 21:30:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.25.8.2 2014/01/12 12:25:03 bouyer 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
@@ -379,34 +398,57 @@
        dc->dc_videobase = paddr;
 
        /* WHITE on BLACK */
-       if (hwplanemask == 0x0f) {
-               /* XXX Need Bt454 more initialization */
+       if (hwplanemask == 0x01) {
                struct bt454 *odac = (struct bt454 *)OMFB_RAMDAC;
+
+               /*
+                * On 1bpp framebuffer, only plane P0 has framebuffer memory
+                * and other planes seems pulled up, i.e. always 1.
+                * Set white only for a palette (P0,P1,P2,P3) = (1,1,1,1).
+                */
                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 < 15; i++) {
+                       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 = 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;
+               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;
 
+               /* Initialize the Bt458 */
                ndac->bt_addr = 0x04;
                ndac->bt_ctrl = 0xff; /* all planes will be read */
+               ndac->bt_addr = 0x05;
                ndac->bt_ctrl = 0x00; /* all planes have non-blink */
-               ndac->bt_ctrl = 0x43; /* pallete enabled, ovly plane */
+               ndac->bt_addr = 0x06;
+               ndac->bt_ctrl = 0x40; /* pallete enabled, ovly plane disabled */
+               ndac->bt_addr = 0x07;
                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;
                }
        }
 
@@ -435,11 +477,15 @@
                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;
        omfb_stdscreen.textops = &ri->ri_ops;
+       omfb_stdscreen.capabilities = ri->ri_caps;
        omfb_stdscreen.fontwidth = ri->ri_font->fontwidth;
        omfb_stdscreen.fontheight = ri->ri_font->fontheight;
 }
diff -r 44b5c3cd862d -r 8fb0af3a5f4b sys/arch/luna68k/dev/omrasops.c
--- a/sys/arch/luna68k/dev/omrasops.c   Sun Jan 12 12:21:16 2014 +0000
+++ b/sys/arch/luna68k/dev/omrasops.c   Sun Jan 12 12:25:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omrasops.c,v 1.11.8.1 2012/07/25 21:30:35 martin Exp $ */
+/* $NetBSD: omrasops.c,v 1.11.8.2 2014/01/12 12:25:03 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,14 +31,14 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.11.8.1 2012/07/25 21:30:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.11.8.2 2014/01/12 12:25:03 bouyer Exp $");
 
 /*
  * Designed speficically for 'm68k bitorder';
  *     - most significant byte is stored at lower address,
  *     - most significant bit is displayed at left most on screen.
  * Implementation relies on;
- *     - every memory references is done in aligned 32bit chunk,
+ *     - first column is at 32bit aligned address,
  *     - font glyphs are stored in 32bit padded.
  */
 
@@ -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);



Home | Main Index | Thread Index | Old Index