Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sgimips/gio general overhaul, in no particular order:
details: https://anonhg.NetBSD.org/src/rev/815b5da1e813
branches: trunk
changeset: 451228:815b5da1e813
user: macallan <macallan%NetBSD.org@localhost>
date: Fri May 10 23:21:42 2019 +0000
description:
general overhaul, in no particular order:
- use MIPS_PHYS_TO_KSEG1()
- get rid of duplicated rasops_allocattr() and _mapchar() methods
- use rasops_init()
- support fonts that aren't 8x16
- use fastclear mode for rectangle fills
- don't mess with XMAP9's config register
- initialize all 32 XMAP9 mode registers, just in case
- make newport_fill_rectangle() use x, y, wi, he like everyone else
- use R3G3B2 palette in preparation for alpha font support
diffstat:
sys/arch/sgimips/gio/newport.c | 306 +++++++++++++++++++++-------------------
1 files changed, 160 insertions(+), 146 deletions(-)
diffs (truncated from 549 to 300 lines):
diff -r 321ae3a3ce95 -r 815b5da1e813 sys/arch/sgimips/gio/newport.c
--- a/sys/arch/sgimips/gio/newport.c Fri May 10 22:54:51 2019 +0000
+++ b/sys/arch/sgimips/gio/newport.c Fri May 10 23:21:42 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: newport.c,v 1.19 2015/08/25 02:09:18 macallan Exp $ */
+/* $NetBSD: newport.c,v 1.20 2019/05/10 23:21:42 macallan Exp $ */
/*
* Copyright (c) 2003 Ilpo Ruotsalainen
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: newport.c,v 1.19 2015/08/25 02:09:18 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: newport.c,v 1.20 2019/05/10 23:21:42 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -73,7 +73,6 @@
int dc_font;
struct wsscreen_descr *dc_screen;
- struct wsdisplay_font *dc_fontdata;
int dc_mode;
struct vcons_data dc_vd;
};
@@ -87,13 +86,11 @@
/* textops */
static void newport_cursor(void *, int, int, int);
static void newport_cursor_dummy(void *, int, int, int);
-static int newport_mapchar(void *, int, unsigned int *);
static void newport_putchar(void *, int, int, u_int, long);
static void newport_copycols(void *, int, int, int, int);
static void newport_erasecols(void *, int, int, int, long);
static void newport_copyrows(void *, int, int, int);
static void newport_eraserows(void *, int, int, long);
-static int newport_allocattr(void *, int, int, int, long *);
static void newport_init_screen(void *, struct vcons_screen *, int, long *);
@@ -107,22 +104,10 @@
.mmap = newport_mmap,
};
-static struct wsdisplay_emulops newport_textops = {
- .cursor = newport_cursor_dummy,
- .mapchar = newport_mapchar,
- .putchar = newport_putchar,
- .copycols = newport_copycols,
- .erasecols = newport_erasecols,
- .copyrows = newport_copyrows,
- .eraserows = newport_eraserows,
- .allocattr = newport_allocattr
-};
-
static struct wsscreen_descr newport_screen = {
.name = "default",
.ncols = 160,
.nrows = 64,
- .textops = &newport_textops,
.fontwidth = 8,
.fontheight = 16,
.capabilities = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_REVERSE
@@ -141,11 +126,7 @@
static struct newport_devconfig newport_console_dc;
static int newport_is_console = 0;
-#define NEWPORT_ATTR_ENCODE(fg,bg) (((fg) << 8) | (bg))
-#define NEWPORT_ATTR_BG(a) ((a) & 0xff)
-#define NEWPORT_ATTR_FG(a) (((a) >> 8) & 0xff)
-
-extern const u_char rasops_cmap[768];
+uint8_t our_cmap[768];
/**** Low-level hardware register groveling functions ****/
static void
@@ -273,9 +254,19 @@
rex3_write(dc, REX3_REG_DCBDATA0, val << 24);
}
+static inline void
+xmap9_wait(struct newport_devconfig *dc)
+{
+ do {} while (xmap9_read(dc, XMAP9_DCBCRS_FIFOAVAIL) == 0);
+}
+
static void
xmap9_write_mode(struct newport_devconfig *dc, uint8_t index, uint32_t mode)
{
+ volatile uint32_t junk;
+ /* wait for FIFO if needed */
+ xmap9_wait(dc);
+
rex3_write(dc, REX3_REG_DCBMODE,
REX3_DCBMODE_DW_4 |
(NEWPORT_DCBADDR_XMAP_BOTH << REX3_DCBMODE_DCBADDR_SHIFT) |
@@ -284,30 +275,40 @@
(2 << REX3_DCBMODE_CSHOLD_SHIFT) |
(1 << REX3_DCBMODE_CSSETUP_SHIFT));
+ xmap9_wait(dc);
+
rex3_write(dc, REX3_REG_DCBDATA0, (index << 24) | mode);
+ junk = rex3_read(dc, REX3_REG_DCBDATA0);
+ __USE(junk);
}
/**** Helper functions ****/
static void
-newport_fill_rectangle(struct newport_devconfig *dc, int x1, int y1, int x2,
- int y2, uint8_t color)
+newport_fill_rectangle(struct newport_devconfig *dc, int x1, int y1, int wi,
+ int he, uint32_t color)
{
+ int x2 = x1 + wi - 1;
+ int y2 = y1 + he - 1;
+
rex3_wait_gfifo(dc);
rex3_write(dc, REX3_REG_DRAWMODE0, REX3_DRAWMODE0_OPCODE_DRAW |
REX3_DRAWMODE0_ADRMODE_BLOCK | REX3_DRAWMODE0_DOSETUP |
REX3_DRAWMODE0_STOPONX | REX3_DRAWMODE0_STOPONY);
+ rex3_write(dc, REX3_REG_CLIPMODE, 0x1e00);
rex3_write(dc, REX3_REG_DRAWMODE1,
- REX3_DRAWMODE1_PLANES_CI |
+ REX3_DRAWMODE1_PLANES_RGB |
REX3_DRAWMODE1_DD_DD8 |
REX3_DRAWMODE1_RWPACKED |
REX3_DRAWMODE1_HD_HD8 |
REX3_DRAWMODE1_COMPARE_LT |
REX3_DRAWMODE1_COMPARE_EQ |
REX3_DRAWMODE1_COMPARE_GT |
+ REX3_DRAWMODE1_RGBMODE |
+ REX3_DRAWMODE1_FASTCLEAR |
REX3_DRAWMODE1_LO_SRC);
rex3_write(dc, REX3_REG_WRMASK, 0xffffffff);
- rex3_write(dc, REX3_REG_COLORI, color);
+ rex3_write(dc, REX3_REG_COLORVRAM, color);
rex3_write(dc, REX3_REG_XYSTARTI, (x1 << REX3_XYSTARTI_XSHIFT) | y1);
rex3_write_go(dc, REX3_REG_XYENDI, (x2 << REX3_XYENDI_XSHIFT) | y2);
@@ -430,7 +431,7 @@
}
static void
-newport_setup_hw(struct newport_devconfig *dc)
+newport_setup_hw(struct newport_devconfig *dc, int depth)
{
uint16_t __unused(curp), tmp;
int i;
@@ -467,25 +468,74 @@
VC2_CONTROL_CURSORFUNC_ENABLE /*|
VC2_CONTROL_CURSOR_ENABLE*/);
+ /* disable all clipping */
+ rex3_write(dc, REX3_REG_CLIPMODE, 0x1e00);
+
/* Setup XMAP9s */
- xmap9_write(dc, XMAP9_DCBCRS_CONFIG,
- XMAP9_CONFIG_8BIT_SYSTEM | XMAP9_CONFIG_RGBMAP_CI);
-
xmap9_write(dc, XMAP9_DCBCRS_CURSOR_CMAP, 0);
- xmap9_write_mode(dc, 0,
- XMAP9_MODE_GAMMA_BYPASS |
- XMAP9_MODE_PIXSIZE_8BPP);
- xmap9_write(dc, XMAP9_DCBCRS_MODE_SELECT, 0);
+ if (depth == 8) {
+
+ for (i = 0; i < 32; i++) {
+ xmap9_write_mode(dc, i,
+ XMAP9_MODE_GAMMA_BYPASS |
+ XMAP9_MODE_PIXSIZE_8BPP | XMAP9_MODE_PIXMODE_RGB2);
+ }
+ xmap9_write(dc, XMAP9_DCBCRS_MODE_SELECT, 0);
+
+ /* Setup REX3 */
+ rex3_write(dc, REX3_REG_XYWIN, (4096 << 16) | 4096);
+ rex3_write(dc, REX3_REG_TOPSCAN, 0x3ff); /* XXX Why? XXX */
+
+ /* Setup CMAP */
+ uint8_t ctmp;
+ for (i = 0; i < 256; i++) {
+ ctmp = i & 0xe0;
+ /*
+ * replicate bits so 0xe0 maps to a red value of 0xff
+ * in order to make white look actually white
+ */
+ ctmp |= (ctmp >> 3) | (ctmp >> 6);
+ our_cmap[i * 3] = ctmp;
+
+ ctmp = (i & 0x1c) << 3;
+ ctmp |= (ctmp >> 3) | (ctmp >> 6);
+ our_cmap[i * 3 + 1] = ctmp;
- /* Setup REX3 */
- rex3_write(dc, REX3_REG_XYWIN, (4096 << 16) | 4096);
- rex3_write(dc, REX3_REG_TOPSCAN, 0x3ff); /* XXX Why? XXX */
+ ctmp = (i & 0x03) << 6;
+ ctmp |= ctmp >> 2;
+ ctmp |= ctmp >> 4;
+ our_cmap[i * 3 + 2] = ctmp;
+
+ newport_cmap_setrgb(dc, i, our_cmap[i * 3],
+ our_cmap[i * 3 + 1], our_cmap[i * 3 + 2]);
+ }
+ /* Write a ramp into RGB2 cmap */
+ for (i = 0; i < 256; i++)
+ newport_cmap_setrgb(dc, 0x1f00 + i, i, i, i);
+ } else {
+ uint8_t dcbcfg;
- /* Setup CMAP */
- for (i = 0; i < 256; i++)
- newport_cmap_setrgb(dc, i, rasops_cmap[i * 3],
- rasops_cmap[i * 3 + 1], rasops_cmap[i * 3 + 2]);
+ dcbcfg = xmap9_read(dc, XMAP9_DCBCRS_CONFIG);
+ aprint_debug("dcbcfg: %02x\n", dcbcfg);
+ dcbcfg &= 0x3c;
+ xmap9_write(dc, XMAP9_DCBCRS_CONFIG, dcbcfg | XMAP9_CONFIG_RGBMAP_2);
+
+ for (i = 0; i < 32; i++) {
+ xmap9_write_mode(dc, i,
+ XMAP9_MODE_GAMMA_BYPASS |
+ XMAP9_MODE_PIXSIZE_24BPP |
+ XMAP9_MODE_PIXMODE_RGB2);
+ }
+
+ /* Setup REX3 */
+ rex3_write(dc, REX3_REG_XYWIN, (4096 << 16) | 4096);
+ rex3_write(dc, REX3_REG_TOPSCAN, 0x3ff); /* XXX Why? XXX */
+
+ /* Write a ramp into RGB2 cmap */
+ for (i = 0; i < 256; i++)
+ newport_cmap_setrgb(dc, 0x1f00 + i, i, i, i);
+ }
}
/**** Attach routines ****/
@@ -504,11 +554,11 @@
return 1;
if (platform.badaddr(
- (void *)(ga->ga_ioh + NEWPORT_REX3_OFFSET + REX3_REG_XSTARTI),
+ (void *)MIPS_PHYS_TO_KSEG1(ga->ga_addr + NEWPORT_REX3_OFFSET + REX3_REG_XSTARTI),
sizeof(uint32_t)))
return 0;
if (platform.badaddr(
- (void *)(ga->ga_ioh + NEWPORT_REX3_OFFSET + REX3_REG_XSTART),
+ (void *)MIPS_PHYS_TO_KSEG1(ga->ga_addr + NEWPORT_REX3_OFFSET + REX3_REG_XSTART),
sizeof(uint32_t)))
return 0;
@@ -532,21 +582,18 @@
dc->dc_st = ga->ga_iot;
dc->dc_sh = ga->ga_ioh;
- wsfont_init();
-
- dc->dc_font = wsfont_find(NULL, 8, 16, 0, WSDISPLAY_FONTORDER_L2R,
- WSDISPLAY_FONTORDER_L2R, WSFONT_FIND_BITMAP);
- if (dc->dc_font < 0)
- panic("newport_attach_common: no suitable fonts");
-
- if (wsfont_lock(dc->dc_font, &dc->dc_fontdata))
- panic("newport_attach_common: unable to lock font data");
-
- newport_setup_hw(dc);
+ newport_setup_hw(dc, 8);
newport_get_resolution(dc);
newport_fill_rectangle(dc, 0, 0, dc->dc_xres, dc->dc_yres, 0);
+
+#ifdef NEWPORT_DEBUG
+ int i;
+ for (i = 0; i < 256; i++)
+ newport_fill_rectangle(dc, 10, i * 3 + 10, 500, 2, i);
+ delay(10000000);
+#endif
dc->dc_screen = &newport_screen;
dc->dc_mode = WSDISPLAYIO_MODE_EMUL;
@@ -588,8 +635,6 @@
1, &defattr);
sc->sc_dc->dc_screen->textops =
&newport_console_screen.scr_ri.ri_ops;
- memcpy(&newport_textops, &newport_console_screen.scr_ri.ri_ops,
- sizeof(struct wsdisplay_emulops));
vcons_replay_msgbuf(&newport_console_screen);
}
wa.scrdata = &newport_screenlist;
@@ -603,7 +648,7 @@
newport_cnattach(struct gio_attach_args *ga)
{
struct rasops_info *ri = &newport_console_screen.scr_ri;
- long defattr = NEWPORT_ATTR_ENCODE(WSCOL_WHITE, WSCOL_BLACK);
+ long defattr = 0x000f0000;
if (!newport_match(NULL, NULL, ga)) {
Home |
Main Index |
Thread Index |
Old Index