summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-08-06 15:04:23 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-08-06 15:04:23 +0000
commitd96598e887c131b0c998a828c237d992881de300 (patch)
tree5d8f8926bc3f49f37adfc2d281a0660dca947477 /sys
parent706547ad2527901200aed09697612fc8a19f5801 (diff)
Replace magic numbers with adequate #defines, support vsync disabling in the
burner routine, and do the colormap updates during vertical retrace, instead of using a fixed delay.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/vax/vsa/lcg.c49
-rw-r--r--sys/arch/vax/vsa/lcgreg.h38
2 files changed, 70 insertions, 17 deletions
diff --git a/sys/arch/vax/vsa/lcg.c b/sys/arch/vax/vsa/lcg.c
index bc2f956257b..f422a4e86fe 100644
--- a/sys/arch/vax/vsa/lcg.c
+++ b/sys/arch/vax/vsa/lcg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lcg.c,v 1.7 2006/08/05 22:04:53 miod Exp $ */
+/* $OpenBSD: lcg.c,v 1.8 2006/08/06 15:04:22 miod Exp $ */
/*
* Copyright (c) 2006 Miodrag Vallat.
*
@@ -529,9 +529,12 @@ lcg_burner(void *v, u_int on, u_int flags)
vidcfg = lcg_read_reg(ss, LCG_REG_VIDEO_CONFIG);
if (on)
- vidcfg |= 1 << 1;
- else
- vidcfg &= ~(1 << 1);
+ vidcfg |= VIDEO_ENABLE_VIDEO | VIDEO_SYNC_ENABLE;
+ else {
+ vidcfg &= ~VIDEO_ENABLE_VIDEO;
+ if (flags & WSDISPLAY_BURN_VBLANK)
+ vidcfg &= ~VIDEO_SYNC_ENABLE;
+ }
lcg_write_reg(ss, LCG_REG_VIDEO_CONFIG, vidcfg);
}
@@ -621,13 +624,13 @@ lcg_putcmap(struct lcg_screen *ss, struct wsdisplay_cmap *cm)
/* Fill the given colormap (LUT) entry. */
#define lcg_set_lut_entry(lutptr, cmap, idx, shift) \
do { \
- (lutptr)++; \
+ *(lutptr)++ = LUT_ADRS_REG; \
*(lutptr)++ = (idx); \
- *(lutptr)++ = 1; \
+ *(lutptr)++ = LUT_COLOR_AUTOINC; \
*(lutptr)++ = (*(cmap)++) >> (shift); \
- *(lutptr)++ = 1; \
+ *(lutptr)++ = LUT_COLOR_AUTOINC; \
*(lutptr)++ = (*(cmap)++) >> (shift); \
- *(lutptr)++ = 1; \
+ *(lutptr)++ = LUT_COLOR_AUTOINC; \
*(lutptr)++ = (*(cmap)++) >> (shift); \
} while (0)
@@ -640,7 +643,6 @@ lcg_loadcmap(struct lcg_screen *ss, int from, int count)
u_int32_t vidcfg;
/* partial updates ignored for now */
- vidcfg = lcg_read_reg(ss, LCG_REG_VIDEO_CONFIG);
cmap = ss->ss_cmap;
lutptr = ss->ss_lut;
if (ss->ss_depth == 8) {
@@ -652,16 +654,31 @@ lcg_loadcmap(struct lcg_screen *ss, int from, int count)
lcg_set_lut_entry(lutptr, cmap, i, 4);
}
}
- vidcfg &= ~((1 << 5) | (3 << 8) | (1 << 11));
- if (ss->ss_width == 1280) /* XXX is this right? */
- vidcfg |= (0 << 5) | (2 << 8) | (0 << 11);
+
+ /*
+ * Wait for retrace
+ */
+ while (((vidcfg = lcg_read_reg(ss, LCG_REG_VIDEO_CONFIG)) &
+ VIDEO_VSTATE) != VIDEO_VSYNC)
+ DELAY(1);
+
+ vidcfg &= ~(VIDEO_SHIFT_SEL | VIDEO_MEM_REFRESH_SEL_MASK |
+ VIDEO_LUT_SHIFT_SEL);
+ /* Do full loads if width is 1024 or 2048, split loads otherwise. */
+ if (ss->ss_width == 1024 || ss->ss_width == 2048)
+ vidcfg |= VIDEO_SHIFT_SEL | (1 << VIDEO_MEM_REFRESH_SEL_SHIFT) |
+ VIDEO_LUT_SHIFT_SEL;
else
- vidcfg |= (1 << 5) | (1 << 8) | (1 << 11);
+ vidcfg |= (2 << VIDEO_MEM_REFRESH_SEL_SHIFT);
+ vidcfg |= VIDEO_LUT_LOAD_SIZE; /* 2KB lut */
lcg_write_reg(ss, LCG_REG_VIDEO_CONFIG, vidcfg);
- lcg_write_reg(ss, LCG_REG_LUT_CONSOLE_SEL, 1);
+ lcg_write_reg(ss, LCG_REG_LUT_CONSOLE_SEL, LUT_SEL_COLOR);
lcg_write_reg(ss, LCG_REG_LUT_COLOR_BASE_W, LCG_LUT_OFFSET);
- DELAY(1000); /* XXX should wait on a status bit */
- lcg_write_reg(ss, LCG_REG_LUT_CONSOLE_SEL, 0);
+ /* Wait for end of retrace */
+ while (((vidcfg = lcg_read_reg(ss, LCG_REG_VIDEO_CONFIG)) &
+ VIDEO_VSTATE) == VIDEO_VSYNC)
+ DELAY(1);
+ lcg_write_reg(ss, LCG_REG_LUT_CONSOLE_SEL, LUT_SEL_CONSOLE);
}
void
diff --git a/sys/arch/vax/vsa/lcgreg.h b/sys/arch/vax/vsa/lcgreg.h
index 2ba55951aee..aa0a2aeeb50 100644
--- a/sys/arch/vax/vsa/lcgreg.h
+++ b/sys/arch/vax/vsa/lcgreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lcgreg.h,v 1.1 2006/07/24 20:35:08 miod Exp $ */
+/* $OpenBSD: lcgreg.h,v 1.2 2006/08/06 15:04:22 miod Exp $ */
/* $NetBSD: lcgreg.h,v 1.4 2005/12/11 12:19:34 christos Exp $ */
/*-
@@ -53,6 +53,34 @@
/* Video Control Registers
*/
#define LCG_REG_VIDEO_CONFIG 0x001e00
+#define VIDEO_VSTATE 0xc0000000
+#define VIDEO_VFRONT_PORCH 0x00000000
+#define VIDEO_VSYNC 0x40000000
+#define VIDEO_VBACK_PORCH 0x80000000
+#define VIDEO_VACTIVE 0xc0000000
+#define VIDEO_HSTATE 0x30000000
+#define VIDEO_HFRONT_PORCH 0x00000000
+#define VIDEO_HSYNC 0x10000000
+#define VIDEO_HBACK_PORCH 0x20000000
+#define VIDEO_HACTIVE 0x30000000
+#define VIDEO_CONSOLE_LUT 0x02000000
+#define VIDEO_CONTROL_LUT 0x01000000
+#define VIDEO_CURSOR_ACTIVE 0x00400000
+#define VIDEO_CURSOR_SCANLINE 0x003f0000
+#define VIDEO_RESET 0x00008000
+#define VIDEO_LUT_LOAD_SIZE 0x00002000
+#define VIDEO_SYNC_ENABLE 0x00001000
+#define VIDEO_LUT_SHIFT_SEL 0x00000800
+#define VIDEO_CLOCK_SEL 0x00000400
+#define VIDEO_MEM_REFRESH_SEL_MASK 0x00000300
+#define VIDEO_MEM_REFRESH_SEL_SHIFT 8
+#define VIDEO_REFRESH_SEL 0x000000c0
+#define VIDEO_SHIFT_SEL 0x00000020
+#define VIDEO_CURSOR_PIN_TYPE 0x00000010
+#define VIDEO_LUT_LOAD_ENABLE 0x00000008
+#define VIDEO_CURSOR_ENABLE 0x00000004
+#define VIDEO_ENABLE_VIDEO 0x00000002
+#define VIDEO_TIMING_ENABLE 0x00000001
#define LCG_REG_VIDEO_HTIMING 0x001e10
#define LCG_REG_VIDEO_VTIMING 0x001e14
#define LCG_REG_VIDEO_TIMING 0x001e18
@@ -70,6 +98,8 @@
#define LCG_REG_CURSOR_X 0x000e84
#define LCG_REG_CURSOR_Y 0x000e84
#define LCG_REG_LUT_CONSOLE_SEL 0x000ee0
+#define LUT_SEL_CONSOLE 0x00
+#define LUT_SEL_COLOR 0x01
#define LCG_REG_LUT_COLOR_BASE_W 0x0006e4
#define LCG_REG_LUT_COLOR_BASE_R 0x0006e4
#define LCG_REG_LUT_CONTROL_BASE 0x000ee8
@@ -189,3 +219,9 @@
#define LCG_REG_DEST_WIDTH0 0x000494
#define LCG_REG_TILE_ROTATION 0x000660
#define LCG_REG_TILE_WIDTH 0x000668
+
+/*
+ * LUT data bits
+ */
+#define LUT_ADRS_REG 0x00 /* write to address register */
+#define LUT_COLOR_AUTOINC 0x01 /* write to LUT and autoincremen */