7060924 Desire to have a SunVTS testing suite for the Matrox graphics in the Sparc T5.
--- a/open-src/app/gfx-utils/sun-src/Makefile Fri Feb 24 15:11:25 2012 -0800
+++ b/open-src/app/gfx-utils/sun-src/Makefile Fri Feb 24 16:15:46 2012 -0800
@@ -1,6 +1,6 @@
# Makefile for gfx-util sub-modules
#
-# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@@ -30,7 +30,8 @@
fbconfig \
fbconf_xorg \
vts/ast \
- vts/efb
+ vts/efb \
+ vts/mga
# Dependencies needed for parallel make:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/app/gfx-utils/sun-src/vts/mga/Makefile Fri Feb 24 16:15:46 2012 -0800
@@ -0,0 +1,33 @@
+#
+# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+#
+# Target device
+#
+DEV = MGA
+Dev = mga
+
+DEV_CSRCS = dma.c
+DEV_OBJS = dma.o
+
+include ../Makefile.common
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/app/gfx-utils/sun-src/vts/mga/chip.c Fri Feb 24 16:15:46 2012 -0800
@@ -0,0 +1,316 @@
+/*
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "libvtsSUNWmga.h"
+
+/*
+ * mga_test_chip()
+ *
+ * Test Chip, functional tests.
+ */
+
+return_packet *
+mga_test_chip(
+ register int const fd)
+{
+ static return_packet rp;
+
+ memset(&rp, 0, sizeof (return_packet));
+
+ if (gfx_vts_debug_mask & GRAPHICS_VTS_CHIP_OFF) {
+ return (&rp);
+ }
+
+ TraceMessage(VTS_DEBUG, "mga_test_chip",
+ "mga_test_chip running\n");
+
+ mga_block_signals();
+
+ mga_lock_display();
+
+ chip_test(&rp, fd);
+
+ mga_unlock_display();
+
+ mga_restore_signals();
+
+ TraceMessage(VTS_DEBUG, "mga_test_chip",
+ "mga_test_chip completed\n");
+
+ return (&rp);
+
+} /* mga_test_chip() */
+
+
+int
+chip_test(
+ register return_packet *const rp,
+ register int const fd)
+{
+ register uint_t black;
+ register uint_t white;
+
+ memset(&mga_info, 0, sizeof (mga_info));
+ mga_info.mga_fd = fd;
+
+ if (mga_map_mem(rp, GRAPHICS_ERR_CHIP) != 0) {
+ close(fd);
+ return (-1);
+ }
+
+ if (mga_init_info(rp, GRAPHICS_ERR_CHIP) != 0) {
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ /* We need to be in mga mode. */
+
+ if (!mga_mgamode()) {
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (0);
+ }
+
+ if (!mga_init_graphics()) {
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (0);
+ }
+
+ mga_save_palet();
+ mga_set_palet();
+
+ /* Clear screen black */
+
+ black = mga_color(0x00, 0x00, 0x00);
+ if (!mga_fill_solid_rect(0, 0,
+ mga_info.mga_width, mga_info.mga_height, black)) {
+ mga_restore_palet();
+ mga_finish_graphics();
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ if (!mga_wait_idle()) {
+ mga_restore_palet();
+ mga_finish_graphics();
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ /* line test */
+
+ if (!draw_lines(mga_info.mga_width, mga_info.mga_height)) {
+ mga_restore_palet();
+ mga_finish_graphics();
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ if (!mga_wait_idle()) {
+ mga_restore_palet();
+ mga_finish_graphics();
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ if (mga_sleep(2)) {
+ mga_restore_palet();
+ mga_finish_graphics();
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ /* fill rectangle test */
+
+ if (!draw_cascaded_box(mga_info.mga_width, mga_info.mga_height)) {
+ mga_restore_palet();
+ mga_finish_graphics();
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ if (!mga_wait_idle()) {
+ mga_restore_palet();
+ mga_finish_graphics();
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ if (mga_sleep(2)) {
+ mga_restore_palet();
+ mga_finish_graphics();
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ /* Clear screen white */
+
+ white = mga_color(0xff, 0xff, 0xff);
+ if (!mga_fill_solid_rect(0, 0,
+ mga_info.mga_width, mga_info.mga_height, white)) {
+ mga_restore_palet();
+ mga_finish_graphics();
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ if (!mga_wait_idle()) {
+ mga_restore_palet();
+ mga_finish_graphics();
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ mga_sleep(2);
+
+ mga_restore_palet();
+ mga_finish_graphics();
+
+ if (mga_unmap_mem(rp, GRAPHICS_ERR_CHIP) != 0) {
+ close(fd);
+ return (-1);
+ }
+
+ if (close(fd) != 0) {
+ gfx_vts_set_message(rp, 1, GRAPHICS_ERR_CHIP,
+ "error closing device\n");
+ return (-1);
+ }
+
+ return (0);
+}
+
+
+int
+draw_lines(
+ register unsigned int const width,
+ register unsigned int const height)
+{
+ register unsigned int x1;
+ register unsigned int y1;
+ register unsigned int x2;
+ register unsigned int y2;
+ register unsigned int color;
+ register unsigned int lineon;
+ register unsigned int const numlines = 128;
+
+ for (lineon = 0; lineon < numlines; lineon++) {
+ color = mga_color(0xaf, lineon, lineon);
+
+ x1 = (unsigned int)((width * lineon) / numlines);
+ x2 = x1;
+ y1 = 0;
+ y2 = height;
+
+ if (!mga_draw_solid_line(x1, y1, x2, y2, color))
+ return (0);
+ }
+
+ for (lineon = 0; lineon < numlines; lineon++) {
+ color = mga_color(0xaf, lineon, lineon);
+
+ x1 = 0;
+ x2 = width;
+ y1 = (unsigned int)((height * lineon) / numlines);
+ y2 = y1;
+
+ if (!mga_draw_solid_line(x1, y1, x2, y2, color))
+ return (0);
+ }
+ return (1);
+}
+
+int
+draw_cascaded_box(
+ register unsigned int const width,
+ register unsigned int const height)
+{
+ register unsigned int x1;
+ register unsigned int y1;
+ register unsigned int x2;
+ register unsigned int y2;
+ register unsigned int color;
+ register unsigned int recton;
+ register unsigned int const numrects = 256;
+
+ for (recton = 0; recton < numrects; recton++) {
+
+ x1 = (unsigned int)((width * recton) / 512);
+ x2 = width - x1;
+
+ y1 = (unsigned int)((height * recton) / 512);
+ y2 = height - y1;
+
+ color = mga_color(recton, recton, recton);
+
+ if (!box(x1, y1, x2, y2, color))
+ return (0);
+ }
+
+ return (1);
+}
+
+
+int
+box(
+ register int const srcx1,
+ register int const srcy1,
+ register int const srcx2,
+ register int const srcy2,
+ register unsigned int const color)
+{
+ register int x1;
+ register int y1;
+ register int x2;
+ register int y2;
+
+ if (srcx1 <= srcx2) {
+ x1 = srcx1;
+ x2 = srcx2;
+ } else {
+ x1 = srcx2;
+ x2 = srcx1;
+ }
+
+ if (srcy1 <= srcy2) {
+ y1 = srcy1;
+ y2 = srcy2;
+ } else {
+ y1 = srcy2;
+ y2 = srcy1;
+ }
+
+ return (mga_fill_solid_rect(x1, y1, x2, y2, color));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/app/gfx-utils/sun-src/vts/mga/dma.c Fri Feb 24 16:15:46 2012 -0800
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "libvtsSUNWmga.h" /* Common VTS library definitions */
+
+
+return_packet *
+mga_test_dma(
+ register int const fd)
+{
+ static return_packet rp;
+
+ memset(&rp, 0, sizeof (return_packet));
+
+ TraceMessage(VTS_DEBUG, "mga_test_dma",
+ "mga_test_dma running\n");
+
+ mga_block_signals();
+
+ mga_lock_display();
+
+ dma_test(&rp, fd);
+
+ TraceMessage(VTS_DEBUG, "mga_test_dma",
+ "mga_dma_memory completed\n");
+
+ mga_unlock_display();
+
+ mga_restore_signals();
+
+ return (&rp);
+}
+
+
+int
+dma_test(
+ register return_packet *const rp,
+ register int const fd)
+{
+ register int y;
+ register int height;
+ register int maxwidth;
+ register int maxheight;
+ register uint32_t fg;
+ register uint32_t bg;
+
+ memset(&mga_info, 0, sizeof (mga_info));
+ mga_info.mga_fd = fd;
+
+ if (mga_map_mem(rp, GRAPHICS_ERR_DMA) != 0) {
+ close(fd);
+ return (-1);
+ }
+
+ if (mga_init_info(rp, GRAPHICS_ERR_DMA) != 0) {
+ mga_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ close(fd);
+ return (-1);
+ }
+
+ /* We need to be in mga mode. */
+
+ if (!mga_mgamode()) {
+ mga_unmap_mem(NULL, GRAPHICS_ERR_DMA);
+ close(fd);
+ return (0);
+ }
+
+ if (!mga_init_graphics()) {
+ mga_unmap_mem(NULL, GRAPHICS_ERR_DMA);
+ close(fd);
+ return (0);
+ }
+
+ mga_save_palet();
+ mga_set_palet();
+
+ fg = mga_color(0xff, 0x00, 0x00);
+ bg = mga_color(0xff, 0xff, 0xff);
+
+ /* Do pattern fill */
+
+ /*
+ * Can only transfer 0x40000 (262144) pixels, probably due
+ * to limit of the ar0 register.
+ */
+
+ maxwidth = (mga_info.mga_width + 31) / 32 * 32;
+ if (maxwidth == 0)
+ maxheight = MGA_AR0_MASK + 1;
+ else
+ maxheight = (MGA_AR0_MASK + 1) / maxwidth;
+
+ for (y = 0; y < mga_info.mga_height; y += height) {
+ if (y + maxheight > mga_info.mga_height)
+ height = mga_info.mga_height - y;
+ else
+ height = maxheight;
+
+ if (!mga_fill_pattern_rect(0, y,
+ mga_info.mga_width, y + height,
+ fg, bg, 0x77ddbbee77ddbbee)) {
+ mga_restore_palet();
+ mga_finish_graphics();
+ mga_unmap_mem(NULL, GRAPHICS_ERR_DMA);
+ close(fd);
+ return (-1);
+ }
+
+ }
+
+ mga_sleep(2);
+
+ mga_restore_palet();
+ mga_finish_graphics();
+
+ if (mga_unmap_mem(rp, GRAPHICS_ERR_DMA) != 0) {
+ close(fd);
+ return (-1);
+ }
+
+ if (close(fd) != 0) {
+ gfx_vts_set_message(rp, 1, GRAPHICS_ERR_DMA,
+ "error closing device\n");
+ return (-1);
+ }
+
+ return (0);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/app/gfx-utils/sun-src/vts/mga/libvtsSUNWmga.c Fri Feb 24 16:15:46 2012 -0800
@@ -0,0 +1,712 @@
+/*
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "libvtsSUNWmga.h" /* VTS library definitions for mga device */
+
+mga_info_t mga_info;
+
+mga_xw_t mga_xw;
+
+static gfxtest_info *tests_info;
+
+/* Declarations needed for get_tests() */
+
+static unsigned int mga_mask_list[] = {
+ GRAPHICS_TEST_OPEN,
+ GRAPHICS_TEST_DMA,
+ GRAPHICS_TEST_MEM,
+ GRAPHICS_TEST_CHIP,
+};
+
+static unsigned int mga_mesg_list[] = {
+ GRAPHICS_TEST_OPEN_MESG,
+ GRAPHICS_TEST_DMA_MESG,
+ GRAPHICS_TEST_MEM_MESG,
+ GRAPHICS_TEST_CHIP_MESG,
+};
+
+static gfxtest_function mga_test_list[] = {
+ mga_test_open,
+ mga_test_dma,
+ mga_test_memory,
+ mga_test_chip
+};
+
+
+/* *** PUBLIC *** */
+
+/* These library functions are public and are expected to exist */
+
+int
+get_tests(
+ register gfxtest_info *const tests)
+{
+ /*
+ * Set the gfx_vts_debug_mask bits according to environment variables
+ */
+ gfx_vts_set_debug_mask();
+
+ /*
+ * Construct the list of tests to be performed
+ */
+ tests->count = sizeof (mga_test_list) / sizeof (gfxtest_function);
+ tests->this_test_mask = (int *)malloc(sizeof (mga_mask_list));
+ tests->this_test_mesg = (int *)malloc(sizeof (mga_mesg_list));
+ tests->this_test_function =
+ (gfxtest_function *)malloc(sizeof (mga_test_list));
+
+ if ((tests->this_test_mask == NULL) ||
+ (tests->this_test_mesg == NULL) ||
+ (tests->this_test_function == NULL)) {
+ gfx_vts_free_tests(tests);
+ return (GRAPHICS_ERR_MALLOC_FAIL);
+ }
+
+ tests->connection_test_function = mga_test_open;
+
+ memcpy(tests->this_test_mask, mga_mask_list, sizeof (mga_mask_list));
+ memcpy(tests->this_test_mesg, mga_mesg_list, sizeof (mga_mesg_list));
+ memcpy(tests->this_test_function, mga_test_list,
+ sizeof (mga_test_list));
+
+ tests_info = tests;
+ return (0);
+
+} /* get_tests() */
+
+
+int
+cleanup_tests(
+ register gfxtest_info *const tests)
+{
+
+ TraceMessage(VTS_DEBUG, "cleanup_tests",
+ "call cleanup_tests\n");
+ gfx_vts_free_tests(tests);
+
+ return (0);
+} /* cleanup_tests() */
+
+
+void
+mga_block_signals(
+ void)
+{
+ sigset_t newprocmask;
+
+ sigemptyset(&newprocmask);
+ sigaddset(&newprocmask, SIGHUP);
+ sigaddset(&newprocmask, SIGINT);
+ sigaddset(&newprocmask, SIGTERM);
+ sigaddset(&newprocmask, SIGALRM);
+
+ sigprocmask(SIG_BLOCK, &newprocmask, &mga_xw.xw_procmask);
+}
+
+
+void
+mga_restore_signals(
+ void)
+{
+ sigprocmask(SIG_SETMASK, &mga_xw.xw_procmask, (sigset_t *) NULL);
+}
+
+
+int
+mga_lock_display(
+ void)
+{
+ if (gfx_vts_debug_mask & GRAPHICS_VTS_SLOCK_OFF) {
+ TraceMessage(VTS_DEBUG, "mga_lock_display",
+ "mga_lock_display() DISABLED\n");
+ return (0);
+ }
+
+ if (!mga_open_display()) {
+ return (0);
+ }
+
+ mga_create_cursor();
+
+ mga_create_window();
+
+ /* Disable server from handling any requests */
+ mga_grab_server();
+
+ /* Gain control of keyboard */
+ mga_grab_keyboard();
+
+ /* Gain control of pointer */
+ mga_grab_pointer();
+
+ mga_disable_screensaver();
+
+ mga_disable_dpms();
+
+ XMapRaised(mga_xw.xw_display, mga_xw.xw_window);
+
+ TraceMessage(VTS_DEBUG, "mga_lock_display",
+ "XMapRaised(display, 0x%lx)\n",
+ (unsigned long) mga_xw.xw_window);
+
+ return (1);
+
+} /* mga_lock_display() */
+
+int
+mga_unlock_display(
+ void)
+{
+ if (mga_xw.xw_display == NULL)
+ return (0);
+
+ XUnmapWindow(mga_xw.xw_display, mga_xw.xw_window);
+
+ TraceMessage(VTS_DEBUG, "mga_unlock_display",
+ "XUnmapWindow(display, 0x%lx)\n",
+ (unsigned long) mga_xw.xw_window);
+
+ mga_restore_dpms();
+
+ mga_restore_screensaver();
+
+ mga_ungrab_pointer();
+
+ mga_ungrab_keyboard();
+
+ mga_ungrab_server();
+
+ return (1);
+}
+
+
+int
+mga_open_display(
+ void)
+{
+ if (mga_xw.xw_dispname == NULL)
+ mga_xw.xw_dispname = ":0.0";
+
+ if (mga_xw.xw_display == NULL) {
+ mga_xw.xw_display = XOpenDisplay(mga_xw.xw_dispname);
+
+ if (mga_xw.xw_display == NULL) {
+ TraceMessage(VTS_DEBUG, "mga_open_display",
+ "XOpenDisplay(\"%s\") = NULL\n"
+ "Assuming no window system.\n",
+ mga_xw.xw_dispname);
+
+ return (0);
+ }
+
+ TraceMessage(VTS_DEBUG, "mga_open_display",
+ "XOpenDisplay(\"%s\") = 0x%p\n"
+ "Assuming a window system.\n",
+ mga_xw.xw_dispname, mga_xw.xw_display);
+ }
+
+ /* Tell server to report events as they occur */
+ XSynchronize(mga_xw.xw_display, True);
+
+ TraceMessage(VTS_DEBUG, "mga_open_display",
+ "XSynchronize(display, True).\n");
+
+ return (1);
+}
+
+
+int
+mga_create_cursor(
+ void)
+{
+ register Window const root = RootWindow(mga_xw.xw_display,
+ mga_xw.xw_screen);
+ register Pixmap emptypixmap;
+ XColor dummy_color = {0, 0, 0, 0, 0, 0};
+
+ if (mga_xw.xw_cursor != 0)
+ return (0);
+
+ emptypixmap = XCreateBitmapFromData(mga_xw.xw_display, root, "", 1, 1);
+
+ mga_xw.xw_cursor = XCreatePixmapCursor(mga_xw.xw_display,
+ emptypixmap, emptypixmap, &dummy_color, &dummy_color, 0, 0);
+
+ TraceMessage(VTS_DEBUG, "mga_create_cursor",
+ "XCreatePixmapCursor(display, 0x%lx, 0x%lx, &dummy_color, "
+ "&dummy_color, 0, 0) = 0x%lx\n",
+ (unsigned long) emptypixmap, (unsigned long) emptypixmap,
+ (unsigned long) mga_xw.xw_cursor);
+
+ XFreePixmap(mga_xw.xw_display, emptypixmap);
+
+ return (1);
+}
+
+
+int
+mga_create_window(
+ void)
+{
+ register Window const root = RootWindow(mga_xw.xw_display,
+ mga_xw.xw_screen);
+ register int const width = DisplayWidth(mga_xw.xw_display,
+ mga_xw.xw_screen);
+ register int const height = DisplayHeight(mga_xw.xw_display,
+ mga_xw.xw_screen);
+ XSetWindowAttributes xswa;
+
+ if (mga_xw.xw_window != NULL)
+ return (0);
+
+ memset(&xswa, 0, sizeof (xswa));
+ xswa.cursor = mga_xw.xw_cursor;
+ xswa.background_pixmap = None;
+ xswa.override_redirect = True;
+ xswa.backing_store = NotUseful;
+ xswa.save_under = False;
+ xswa.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask;
+
+ mga_xw.xw_window = XCreateWindow(mga_xw.xw_display,
+ root, 0, 0, width, height,
+ 0, CopyFromParent, InputOutput, CopyFromParent,
+ CWBackPixmap | CWOverrideRedirect | CWBackingStore |
+ CWSaveUnder | CWEventMask | CWCursor, &xswa);
+
+ TraceMessage(VTS_DEBUG, "mga_create_window",
+ "XCreateWindow(display, 0x%lx, %d, %d, %d, %d, "
+ "%d, %d, %d, %d, 0x%lx, &xswa) = 0x%lx\n",
+ (unsigned long) root, 0, 0, width, height,
+ 0, CopyFromParent, InputOutput, CopyFromParent,
+ (unsigned long) (CWBackPixmap | CWOverrideRedirect |
+ CWBackingStore | CWSaveUnder | CWEventMask | CWCursor),
+ (unsigned long) mga_xw.xw_window);
+
+ return (1);
+}
+
+
+int
+mga_grab_server(
+ void)
+{
+ if (mga_xw.xw_grab_server == True)
+ return (0);
+
+ mga_xw.xw_grab_server = XGrabServer(mga_xw.xw_display);
+
+ TraceMessage(VTS_DEBUG, "mga_grab_server",
+ "XGrabServer(display)\n");
+
+ return (1);
+}
+
+
+int
+mga_ungrab_server(
+ void)
+{
+ if (mga_xw.xw_grab_server != True)
+ return (0);
+
+ mga_xw.xw_grab_server = !XUngrabServer(mga_xw.xw_display);
+
+ TraceMessage(VTS_DEBUG, "mga_ungrab_server",
+ "XUngrabServer(display)\n");
+
+ return (1);
+}
+
+
+int
+mga_grab_keyboard(
+ void)
+{
+ register int status;
+
+ if (mga_xw.xw_grab_keyboard == True)
+ return (0);
+
+ status = XGrabKeyboard(mga_xw.xw_display, mga_xw.xw_window,
+ False, GrabModeAsync, GrabModeAsync, CurrentTime);
+ mga_xw.xw_grab_keyboard = status == GrabSuccess;
+
+ TraceMessage(VTS_DEBUG, "mga_grab_keyboard",
+ "XGrabKeyboard(display, 0x%lx, %d, %d, %d, %ld) = %d\n",
+ (unsigned long) mga_xw.xw_window,
+ False, GrabModeAsync, GrabModeAsync, CurrentTime,
+ status);
+
+ if (status != GrabSuccess) {
+ TraceMessage(VTS_DEBUG, "mga_grab_keyboard",
+ "Cannot gain control of keyboard\n");
+ return (-1);
+
+ } else {
+ return (1);
+ }
+}
+
+
+int
+mga_ungrab_keyboard(
+ void)
+{
+ register int status;
+
+ if (mga_xw.xw_grab_keyboard != True)
+ return (0);
+
+ status = XUngrabKeyboard(mga_xw.xw_display, CurrentTime);
+
+ mga_xw.xw_grab_keyboard = False;
+
+ TraceMessage(VTS_DEBUG, "mga_ungrab_keyboard",
+ "XGrabKeyboard(display, %ld) = %d\n",
+ CurrentTime, status);
+
+ return (1);
+}
+
+
+int
+mga_grab_pointer(
+ void)
+{
+ register int status;
+
+ if (mga_xw.xw_grab_pointer == True)
+ return (0);
+
+ status = XGrabPointer(mga_xw.xw_display, mga_xw.xw_window,
+ False, ResizeRedirectMask, GrabModeAsync, GrabModeAsync,
+ None, mga_xw.xw_cursor, CurrentTime);
+
+ mga_xw.xw_grab_pointer = status == GrabSuccess;
+
+ TraceMessage(VTS_DEBUG, "mga_grab_pointer",
+ "XGrabPointer(display, 0x%lx, %d, 0x%lx, %d, %d, "
+ "%d, %d, %ld) = %d\n",
+ (unsigned long) mga_xw.xw_window,
+ False, ResizeRedirectMask,
+ GrabModeAsync, GrabModeAsync,
+ None, None, CurrentTime,
+ status);
+
+ if (status != GrabSuccess) {
+ TraceMessage(VTS_DEBUG, "mga_grab_pointer",
+ "Cannot gain control of pointer\n");
+ return (-1);
+
+ } else {
+ return (1);
+ }
+}
+
+
+int
+mga_ungrab_pointer(
+ void)
+{
+ register int status;
+
+ if (mga_xw.xw_grab_pointer != True)
+ return (0);
+
+ status = XUngrabPointer(mga_xw.xw_display, CurrentTime);
+
+ mga_xw.xw_grab_pointer = False;
+
+ TraceMessage(VTS_DEBUG, "mga_ungrab_pointer",
+ "XGrabPointer(display, %ld) = %d\n",
+ CurrentTime, status);
+
+ return (1);
+}
+
+
+int
+mga_disable_screensaver(
+ void)
+{
+ XGetScreenSaver(mga_xw.xw_display,
+ &mga_xw.xw_ss_timeout,
+ &mga_xw.xw_ss_interval,
+ &mga_xw.xw_ss_prefer_blanking,
+ &mga_xw.xw_ss_allow_exposures);
+
+ mga_xw.xw_ss_saved = True;
+
+ TraceMessage(VTS_DEBUG, "mga_disable_screensaver",
+ "XGetScreenSaver(display) = %d, %d, %d, %d\n",
+ mga_xw.xw_ss_timeout,
+ mga_xw.xw_ss_interval,
+ mga_xw.xw_ss_prefer_blanking,
+ mga_xw.xw_ss_allow_exposures);
+
+ /* Reset the screen saver to reset its time. */
+
+ XResetScreenSaver(mga_xw.xw_display);
+
+ mga_xw.xw_ss_disabled = True;
+
+ XSetScreenSaver(mga_xw.xw_display,
+ DisableScreenSaver,
+ mga_xw.xw_ss_interval,
+ mga_xw.xw_ss_prefer_blanking,
+ mga_xw.xw_ss_allow_exposures);
+
+ TraceMessage(VTS_DEBUG, "mga_disable_screensaver",
+ "XSetScreenSaver(display, %d, %d, %d, %d)\n",
+ DisableScreenSaver,
+ mga_xw.xw_ss_interval,
+ mga_xw.xw_ss_prefer_blanking,
+ mga_xw.xw_ss_allow_exposures);
+
+ return (1);
+}
+
+
+int
+mga_restore_screensaver(
+ void)
+{
+ if (mga_xw.xw_ss_saved != True ||
+ mga_xw.xw_ss_disabled != True) {
+ mga_xw.xw_ss_disabled = False;
+ mga_xw.xw_ss_saved = False;
+ return (0);
+
+ } else {
+ XSetScreenSaver(mga_xw.xw_display,
+ mga_xw.xw_ss_timeout,
+ mga_xw.xw_ss_interval,
+ mga_xw.xw_ss_prefer_blanking,
+ mga_xw.xw_ss_allow_exposures);
+
+ mga_xw.xw_ss_disabled = False;
+
+ TraceMessage(VTS_DEBUG, "mga_restore_screensaver",
+ "XSetScreenSaver(display, %d, %d, %d, %d)\n",
+ mga_xw.xw_ss_timeout,
+ mga_xw.xw_ss_interval,
+ mga_xw.xw_ss_prefer_blanking,
+ mga_xw.xw_ss_allow_exposures);
+
+ mga_xw.xw_ss_saved = False;
+
+ return (1);
+ }
+}
+
+
+int
+mga_disable_dpms(
+ void)
+{
+ /* Disable the X Display Power Management Signaling. */
+
+ int status;
+ int dpms_error = 0;
+ int dpms_event = 0;
+
+ status = DPMSQueryExtension(mga_xw.xw_display,
+ &dpms_event, &dpms_error);
+
+ TraceMessage(VTS_DEBUG, "mga_disable_dpms",
+ "DPMSQueryExtension(display) = %d, %d, %d\n",
+ status,
+ dpms_event,
+ dpms_error);
+
+ if (status != True)
+ return (-1);
+
+ mga_xw.xw_dpms_saved = DPMSInfo(mga_xw.xw_display,
+ &mga_xw.xw_dpms_power, &mga_xw.xw_dpms_state);
+
+ TraceMessage(VTS_DEBUG, "mga_disable_dpms",
+ "DPMSInfo(display) = %d, %d, %d\n",
+ mga_xw.xw_dpms_saved,
+ mga_xw.xw_dpms_power,
+ mga_xw.xw_dpms_state);
+
+ if (mga_xw.xw_dpms_saved != True ||
+ mga_xw.xw_dpms_state != True)
+ return (0);
+
+ else {
+ mga_xw.xw_dpms_disabled = True;
+
+ DPMSDisable(mga_xw.xw_display);
+
+ TraceMessage(VTS_DEBUG, "mga_disable_dpms",
+ "DPMSDisable(display)\n");
+
+ return (1);
+ }
+}
+
+
+int
+mga_restore_dpms(
+ void)
+{
+ /* Restore the X Display Power Management Signaling. */
+
+ if (mga_xw.xw_dpms_saved != True ||
+ mga_xw.xw_dpms_disabled != True) {
+ mga_xw.xw_dpms_disabled = False;
+ mga_xw.xw_dpms_saved = False;
+ return (0);
+
+ } else {
+ DPMSEnable(mga_xw.xw_display);
+
+ mga_xw.xw_dpms_disabled = False;
+
+ TraceMessage(VTS_DEBUG, "mga_restore_dpms",
+ "DPMSEnable(display)\n");
+
+ mga_xw.xw_dpms_saved = False;
+
+ return (1);
+ }
+}
+
+
+int
+mga_sleep(
+ unsigned int const seconds)
+{
+ register int signo;
+ struct sigaction oldhup;
+ struct sigaction oldint;
+ struct sigaction oldalrm;
+ struct sigaction oldterm;
+ struct sigaction newsigact;
+ sigset_t oldprocmask;
+
+ /*
+ * Allow a SIGHUP, SIGINT, SIGALRM, or SIGTERM to interrupt our
+ * sleep. These signals should already be masked from a
+ * call to mga_block_signals.
+ */
+
+ /* Save the current signals. */
+
+ sigaction(SIGHUP, NULL, &oldhup);
+ sigaction(SIGINT, NULL, &oldint);
+ sigaction(SIGALRM, NULL, &oldalrm);
+ sigaction(SIGTERM, NULL, &oldterm);
+
+ /* Setup up new signal action. */
+
+ newsigact.sa_handler = mga_signal_routine;
+ sigemptyset(&newsigact.sa_mask);
+ newsigact.sa_flags = 0;
+
+ signo = sigsetjmp(mga_xw.xw_sigjmpbuf, 1);
+ if (!signo) {
+ /* First time goes here. */
+
+ /* Set signal routines. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &newsigact, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &newsigact, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &newsigact, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &newsigact, NULL);
+
+ /* Unmask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &mga_xw.xw_procmask, &oldprocmask);
+
+ sleep(seconds);
+
+ /* Mask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &oldprocmask, NULL);
+
+ /* Restore the signals. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &oldhup, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &oldint, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &oldalrm, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &oldterm, NULL);
+ }
+
+ else {
+ /* We come here from the siglongjmp in mga_signal_routine. */
+
+ /* Mask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &oldprocmask, NULL);
+
+ /* Restore the signals. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &oldhup, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &oldint, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &oldalrm, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &oldterm, NULL);
+
+ /* Cause us to get the signal, when we unmask the signals. */
+
+ kill(getpid(), signo);
+ }
+ return (signo);
+}
+
+
+void
+mga_signal_routine(
+ register int const signo)
+{
+ siglongjmp(mga_xw.xw_sigjmpbuf, signo);
+}
+
+
+void
+graphicstest_finish(
+ register int const flag)
+{
+
+ TraceMessage(VTS_DEBUG, "graphicstest_finish",
+ "call graphicstest_finish\n");
+
+ cleanup_tests(tests_info);
+
+ exit(0);
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/app/gfx-utils/sun-src/vts/mga/libvtsSUNWmga.h Fri Feb 24 16:15:46 2012 -0800
@@ -0,0 +1,380 @@
+/*
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _LIBVTSSUNWMGA_H
+#define _LIBVTSSUNWMGA_H
+
+
+#include <sys/types.h>
+#include <sys/param.h> /* MAXPATHLEN */
+#include <errno.h>
+#include <memory.h>
+#include <pwd.h> /* getpwuid() */
+#include <signal.h>
+#include <stdio.h> /* snprintf() */
+#include <stdlib.h> /* exit(), malloc() */
+#include <string.h> /* strcat(), strcpy() */
+#include <unistd.h> /* sleep() */
+#include <signal.h>
+#include <setjmp.h>
+#include <stropts.h> /* ioctl() */
+#include <sys/fbio.h>
+#include <sys/mman.h>
+#include <sys/systeminfo.h> /* sysinfo() */
+#include <sys/pci.h>
+#include <sys/time.h>
+#include <sys/visual_io.h>
+#include <X11/Xmd.h>
+#include <X11/Xlib.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/dpms.h>
+#include "libvtsSUNWxfb.h" /* Common VTS library definitions */
+#undef Status
+#define Status pciStatus
+#include "gfx_common.h"
+#undef Status
+#define Status int
+#include "graphicstest.h"
+#include "gfx_vts.h" /* VTS Graphics Test common routines */
+
+#include "mga.h"
+
+#define VIS_TEXT 0 /* Use text mode when displaying data */
+#define VIS_PIXEL 1 /* Use pixel mode when displaying data */
+
+typedef struct mga_info {
+ char const *mga_name;
+ int mga_fd;
+ uint16_t mga_vendor;
+ uint16_t mga_device;
+ int mga_mode;
+ uint_t mga_width;
+ uint_t mga_height;
+ uint_t mga_depth;
+ uint_t mga_hz;
+ uint_t mga_pixelsize;
+ uint_t mga_linesize;
+ uint32_t mga_opmode;
+ offset_t mga_fb_addr;
+ size_t mga_fb_size;
+ char *mga_fb_ptr;
+ size_t mga_fb_real_size;
+ offset_t mga_control_addr;
+ size_t mga_control_size;
+ mga_t volatile *mga_control_ptr;
+ offset_t mga_iload_addr;
+ size_t mga_iload_size;
+ char volatile *mga_iload_ptr;
+ int mga_palet_changed;
+ uchar_t mga_red[256];
+ uchar_t mga_green[256];
+ uchar_t mga_blue[256];
+ } mga_info_t;
+
+typedef struct mga_xw_struct {
+ sigset_t xw_procmask;
+ sigjmp_buf xw_sigjmpbuf;
+ char const *xw_dispname;
+ Display *xw_display;
+ int xw_screen;
+ Window xw_window;
+ Cursor xw_cursor;
+ Bool xw_grab_server;
+ Bool xw_grab_keyboard;
+ Bool xw_grab_pointer;
+ Bool xw_ss_saved;
+ Bool xw_ss_disabled;
+ int xw_ss_timeout;
+ int xw_ss_interval;
+ int xw_ss_prefer_blanking;
+ int xw_ss_allow_exposures;
+ Status xw_dpms_saved;
+ CARD16 xw_dpms_power;
+ BOOL xw_dpms_state;
+ Bool xw_dpms_disabled;
+ } mga_xw_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* chip.c */
+
+extern return_packet *mga_test_chip(
+ register int const fd);
+
+extern int chip_test(
+ return_packet *const rp,
+ int const fd);
+
+extern int draw_cascaded_box(
+ unsigned int const width,
+ unsigned int const height);
+
+extern int draw_lines(
+ unsigned int const width,
+ unsigned int const height);
+
+extern int box(
+ int const srcx1,
+ int const srcy1,
+ int const srcx2,
+ int const srcy2,
+ unsigned int const color);
+
+/* dma.c */
+
+extern return_packet *mga_test_dma(
+ register int const fd);
+
+extern int dma_test(
+ return_packet *const rp,
+ int const fd);
+
+/* mapper.c */
+
+extern return_packet *mga_test_open(
+ int const fd);
+
+extern int map_me(
+ return_packet *const rp,
+ int const fd);
+
+extern int mga_test_status(
+ return_packet *const rp,
+ int const test);
+
+extern int mga_test_cursor(
+ return_packet *const rp,
+ int const test);
+
+extern int mga_test_dac(
+ return_packet *const rp,
+ int const test);
+
+/* memory.c */
+
+extern return_packet *mga_test_memory(
+ int const fd);
+
+extern int memory_test(
+ return_packet *const rp,
+ int const fd);
+
+extern void check_plane(
+ int const num_planes,
+ int const access_mode,
+ int const fb_pitch,
+ int const fb_height,
+ int const fb_width,
+ int const bytepp,
+ caddr_t const base);
+
+extern void init_data(
+ int const num_planes);
+
+extern u_int test_data(
+ void);
+
+extern boolean_t write_read(
+ int const xoff,
+ int const yoff,
+ boolean_t const complement,
+ int const access_mode,
+ boolean_t const pass,
+ int const fb_pitch,
+ int const bytepp,
+ caddr_t const base);
+
+/* tools.c */
+
+extern int mga_map_mem(
+ return_packet *const rp,
+ int const test);
+
+extern int mga_get_pci_info(
+ void);
+
+extern int mga_map_fb(
+ void);
+
+extern int mga_map_control(
+ void);
+
+extern int mga_map_iload(
+ void);
+
+extern int mga_init_info(
+ return_packet *const rp,
+ int const test);
+
+extern size_t mga_get_fb_size(
+ void);
+
+extern int mga_get_screen_size(
+ void);
+
+extern int mga_mgamode(
+ void);
+
+extern void mga_save_palet(
+ void);
+
+extern int mga_set_palet(
+ void);
+
+extern int mga_restore_palet(
+ void);
+
+extern uint_t mga_color(
+ uint_t const red,
+ uint_t const green,
+ uint_t const blue);
+
+extern int mga_init_graphics(
+ void);
+
+extern void mga_finish_graphics(
+ void);
+
+extern int mga_fill_solid_rect(
+ int const x1,
+ int const y1,
+ int const x2,
+ int const y2,
+ uint_t const color);
+
+extern int mga_fill_pattern_rect(
+ int const x1,
+ int const y1,
+ int const x2,
+ int const y2,
+ uint_t const bg,
+ uint_t const fg,
+ uint64_t const pat);
+
+extern int mga_draw_solid_line(
+ int const x1,
+ int const y1,
+ int const x2,
+ int const y2,
+ uint_t const color);
+
+extern int mga_wait_fifo(
+ int const fifocount);
+
+extern int mga_wait_idle(
+ void);
+
+extern int mga_unmap_mem(
+ return_packet *const rp,
+ int const test);
+
+extern int mga_unmap_fb(
+ void);
+
+extern int mga_unmap_control(
+ void);
+
+extern int mga_unmap_iload(
+ void);
+
+extern uint32_t mga_get_uint32(
+ uint32_t volatile const *const uint32ptr);
+
+extern void mga_put_uint32(
+ uint32_t volatile *const uint32ptr,
+ uint32_t const value);
+
+/* libvtsSUNWmga.c */
+
+extern mga_info_t mga_info;
+
+extern mga_xw_t mga_xw;
+
+extern void mga_block_signals(
+ void);
+
+extern void mga_restore_signals(
+ void);
+
+extern int mga_lock_display(
+ void);
+
+extern int mga_unlock_display(
+ void);
+
+extern int mga_open_display(
+ void);
+
+extern int mga_create_cursor(
+ void);
+
+extern int mga_create_window(
+ void);
+
+extern int mga_grab_server(
+ void);
+
+extern int mga_ungrab_server(
+ void);
+
+extern int mga_grab_keyboard(
+ void);
+
+extern int mga_ungrab_keyboard(
+ void);
+
+extern int mga_grab_pointer(
+ void);
+
+extern int mga_ungrab_pointer(
+ void);
+
+extern int mga_disable_screensaver(
+ void);
+
+extern int mga_restore_screensaver(
+ void);
+
+extern int mga_disable_dpms(
+ void);
+
+extern int mga_restore_dpms(
+ void);
+
+extern int mga_sleep(
+ unsigned int const seconds);
+
+extern void mga_signal_routine(
+ int const signo);
+
+extern void graphicstest_finish(
+ int const flag);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBVTSSUNWMGA_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/app/gfx-utils/sun-src/vts/mga/mapfile Fri Feb 24 16:15:46 2012 -0800
@@ -0,0 +1,46 @@
+#
+# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+#
+# MAPFILE HEADER START
+#
+# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
+# Object versioning must comply with the rules detailed in
+#
+# usr/src/lib/README.mapfiles
+#
+# You should not be making modifications here until you've read the most current
+# copy of that file. If you need help, contact a gatekeeper for guidance.
+#
+# MAPFILE HEADER END
+#
+
+$mapfile_version 2
+
+SYMBOL_VERSION SUNW_1.1 {
+ global:
+ get_tests;
+ cleanup_tests;
+ local:
+ *;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/app/gfx-utils/sun-src/vts/mga/mapper.c Fri Feb 24 16:15:46 2012 -0800
@@ -0,0 +1,348 @@
+/*
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "libvtsSUNWmga.h" /* Common VTS library definitions */
+
+/*
+ * mga_test_open()
+ *
+ * This test will open the device, read and write some registers
+ * after mmaping in the register and frame buffer spaces.
+ */
+
+return_packet *
+mga_test_open(
+ register int const fd)
+{
+ static return_packet rp;
+ int rc = 0;
+ struct vis_identifier vis_identifier;
+
+ memset(&rp, 0, sizeof (return_packet));
+
+ if (gfx_vts_check_fd(fd, &rp)) {
+ return (&rp);
+ }
+
+ TraceMessage(VTS_TEST_STATUS, "mga_test_open",
+ "check_fd passed.\n");
+
+ rc = ioctl(fd, VIS_GETIDENTIFIER, &vis_identifier);
+
+ TraceMessage(VTS_TEST_STATUS, "mga_test_open",
+ "rc = %d\n", rc);
+
+ if (rc != 0) {
+ gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
+ return (&rp);
+ }
+
+ if (strcmp(vis_identifier.name, "SUNWmga") != 0 &&
+ strcmp(vis_identifier.name, "ORCLmga") != 0) {
+ gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
+ return (&rp);
+ }
+
+ mga_block_signals();
+
+ mga_lock_display();
+
+ map_me(&rp, fd);
+
+ mga_unlock_display();
+
+ mga_restore_signals();
+
+ TraceMessage(VTS_DEBUG, "mga_test_open",
+ "Open completed OK\n");
+
+ return (&rp);
+
+}
+
+
+int
+map_me(
+ register return_packet *const rp,
+ register int const fd)
+{
+ memset(&mga_info, 0, sizeof (mga_info));
+ mga_info.mga_fd = fd;
+
+ if (mga_map_mem(rp, GRAPHICS_ERR_OPEN) != 0) {
+ close(fd);
+ return (-1);
+ }
+
+ if (mga_init_info(rp, GRAPHICS_ERR_OPEN) != 0) {
+ mga_unmap_mem(NULL, GRAPHICS_ERR_OPEN);
+ close(fd);
+ return (-1);
+ }
+
+ if (mga_test_status(rp, GRAPHICS_ERR_OPEN) != 0) {
+ mga_unmap_mem(NULL, GRAPHICS_ERR_OPEN);
+ close(fd);
+ return (-1);
+ }
+
+ if (!mga_test_cursor(rp, GRAPHICS_ERR_OPEN)) {
+ mga_unmap_mem(NULL, GRAPHICS_ERR_OPEN);
+ close(fd);
+ return (-1);
+ }
+
+ if (!mga_test_dac(rp, GRAPHICS_ERR_OPEN)) {
+ mga_unmap_mem(NULL, GRAPHICS_ERR_OPEN);
+ close(fd);
+ return (-1);
+ }
+
+ if (mga_unmap_mem(rp, GRAPHICS_ERR_OPEN) != 0) {
+ close(fd);
+ return (-1);
+ }
+
+ if (close(fd) != 0) {
+ gfx_vts_set_message(rp, 1, GRAPHICS_ERR_OPEN,
+ "error closing device\n");
+ return (-1);
+ }
+
+ return (0);
+}
+
+
+#define STATUS_XOR_VALUE MGA_STATUS_SWFLAG_MASK
+
+int
+mga_test_status(
+ register return_packet *const rp,
+ register int const test)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register uint32_t save_status;
+ register uint32_t new_status;
+
+ /*
+ * Test the software bits of the status register.
+ * Complement the bits, and see if they read back
+ * complemented.
+ */
+
+ /* Save the original status. */
+
+ save_status = mga_get_uint32(&mgaptr->mga_status);
+
+ /* Write the status with the software bits complemented. */
+
+ mga_put_uint32(&mgaptr->mga_status, save_status ^ STATUS_XOR_VALUE);
+
+ /* Get the new status. */
+
+ new_status = mga_get_uint32(&mgaptr->mga_status);
+
+ /* Restore the old status. */
+
+ mga_put_uint32(&mgaptr->mga_status, save_status);
+
+ /* Check if the software bits did complement. */
+
+ if ((save_status & MGA_STATUS_SWFLAG_MASK) !=
+ ((new_status ^ STATUS_XOR_VALUE) & MGA_STATUS_SWFLAG_MASK)) {
+ printf("status 0x%08lx 0x%08lx 0x%08lx\n",
+ (ulong_t) save_status, (ulong_t) new_status,
+ (ulong_t) save_status ^ STATUS_XOR_VALUE);
+
+ gfx_vts_set_message(rp, 1, test, "status test failed");
+ return (0);
+ }
+
+ return (1);
+}
+
+#define MGA_XOR_CURSOR_LOC_HIGH 0x38
+#define MGA_XOR_CURSOR_LOC_LOW 0xf1
+
+int
+mga_test_cursor(
+ register return_packet *const rp,
+ register int const test)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register uint8_t save_crtc_index;
+ register uint8_t save_cursor_loc_low;
+ register uint8_t save_cursor_loc_high;
+ register uint8_t new_cursor_loc_low;
+ register uint8_t new_cursor_loc_high;
+
+ /*
+ * Test the software bits of the crtc cursor registers.
+ * Complement the bits, and see if they read back
+ * complemented.
+ */
+
+ /* Save the index. */
+
+ save_crtc_index = mgaptr->mga_crtc_index;
+
+ /* Save the cursor location. */
+
+ mgaptr->mga_crtc_index = MGA_CRTC_CURSOR_LOC_LOW;
+ save_cursor_loc_low = mgaptr->mga_crtc_data;
+ mgaptr->mga_crtc_index = MGA_CRTC_CURSOR_LOC_HIGH;
+ save_cursor_loc_high = mgaptr->mga_crtc_data;
+
+ /* Write the cursor location with the bits complemented. */
+
+ mgaptr->mga_crtc_data = save_cursor_loc_high ^
+ MGA_XOR_CURSOR_LOC_HIGH;
+ mgaptr->mga_crtc_index = MGA_CRTC_CURSOR_LOC_LOW;
+ mgaptr->mga_crtc_data = save_cursor_loc_low ^
+ MGA_XOR_CURSOR_LOC_LOW;
+
+ /* Read back the new cursor location. */
+
+ new_cursor_loc_low = mgaptr->mga_crtc_data;
+ mgaptr->mga_crtc_index = MGA_CRTC_CURSOR_LOC_HIGH;
+ new_cursor_loc_high = mgaptr->mga_crtc_data;
+
+ /* Restore the old cursor location, */
+
+ mgaptr->mga_crtc_index = MGA_CRTC_CURSOR_LOC_LOW;
+ mgaptr->mga_crtc_data = save_cursor_loc_low;
+ mgaptr->mga_crtc_index = MGA_CRTC_CURSOR_LOC_HIGH;
+ mgaptr->mga_crtc_data = save_cursor_loc_high;
+
+ /* Restore the index */
+
+ mgaptr->mga_crtc_index = save_crtc_index;
+
+ if (save_cursor_loc_low !=
+ (new_cursor_loc_low ^ MGA_XOR_CURSOR_LOC_LOW) ||
+ save_cursor_loc_high !=
+ (new_cursor_loc_high ^ MGA_XOR_CURSOR_LOC_HIGH)) {
+ printf("loc 0x%02x 0x%02x 0x%02x, 0x%02x 0x%02x 0x%02x\n",
+ save_cursor_loc_low, new_cursor_loc_low,
+ new_cursor_loc_low ^ MGA_XOR_CURSOR_LOC_LOW,
+ save_cursor_loc_high, new_cursor_loc_high,
+ new_cursor_loc_high ^ MGA_XOR_CURSOR_LOC_HIGH);
+
+ gfx_vts_set_message(rp, 1, test, "cursor test failed");
+ return (0);
+ }
+
+ return (1);
+}
+
+
+#define RED_XOR_VALUE 0x11
+#define GREEN_XOR_VALUE 0x22
+#define BLUE_XOR_VALUE 0x44
+
+int
+mga_test_dac(
+ register return_packet *const rp,
+ register int const test)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register uint8_t save_palwtadd;
+ register uint8_t save_xcurcol15red;
+ register uint8_t save_xcurcol15green;
+ register uint8_t save_xcurcol15blue;
+ register uint8_t new_xcurcol15red;
+ register uint8_t new_xcurcol15green;
+ register uint8_t new_xcurcol15blue;
+
+ /*
+ * Test the dac by modifying cursor color 15. Complement
+ * some of the bits, and see if they read back
+ * complemented.
+ *
+ */
+
+ /* Save the original dac index. */
+
+ save_palwtadd = mgaptr->mga_palwtadd;
+
+ /* Save cursor 15 red/green/blue palet values. */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15RED;
+ save_xcurcol15red = mgaptr->mga_x_datareg;
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15GREEN;
+ save_xcurcol15green = mgaptr->mga_x_datareg;
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15BLUE;
+ save_xcurcol15blue = mgaptr->mga_x_datareg;
+
+ /* Set cursor 15 red/green/blue values to the complement. */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15GREEN;
+ mgaptr->mga_x_datareg = save_xcurcol15green ^ GREEN_XOR_VALUE;
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15BLUE;
+ mgaptr->mga_x_datareg = save_xcurcol15blue ^ BLUE_XOR_VALUE;
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15RED;
+ mgaptr->mga_x_datareg = save_xcurcol15red ^ RED_XOR_VALUE;
+
+ /* Get the new cursor 15 red/green/blue palet values. */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15BLUE;
+ new_xcurcol15blue = mgaptr->mga_x_datareg;
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15GREEN;
+ new_xcurcol15green = mgaptr->mga_x_datareg;
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15RED;
+ new_xcurcol15red = mgaptr->mga_x_datareg;
+
+ /* Restore the original cursor 15 red/green/blue palet values. */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15RED;
+ mgaptr->mga_x_datareg = save_xcurcol15red;
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15GREEN;
+ mgaptr->mga_x_datareg = save_xcurcol15green;
+ mgaptr->mga_palwtadd = MGA_XDATA_XCURCOL15BLUE;
+ mgaptr->mga_x_datareg = save_xcurcol15blue;
+
+ /* Restore the original dac index. */
+
+ mgaptr->mga_palwtadd = save_palwtadd;
+
+ /* Check if the software bits did complement. */
+
+ if (save_xcurcol15red != (new_xcurcol15red ^ RED_XOR_VALUE) ||
+ save_xcurcol15green != (new_xcurcol15green ^ GREEN_XOR_VALUE) ||
+ save_xcurcol15blue != (new_xcurcol15blue ^ BLUE_XOR_VALUE)) {
+ printf("red 0x%02x 0x%02x 0x%02x, "
+ "green 0x%02x 0x%02x 0x%02x, "
+ "blue 0x%02x 0x%02x 0x%02x\n",
+ save_xcurcol15red, new_xcurcol15red,
+ new_xcurcol15red ^ RED_XOR_VALUE,
+ save_xcurcol15green, new_xcurcol15green,
+ new_xcurcol15green ^ GREEN_XOR_VALUE,
+ save_xcurcol15blue, new_xcurcol15blue,
+ new_xcurcol15blue ^BLUE_XOR_VALUE);
+
+ gfx_vts_set_message(rp, 1, test, "dac test failed");
+ return (0);
+ }
+
+ return (1);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/app/gfx-utils/sun-src/vts/mga/memory.c Fri Feb 24 16:15:46 2012 -0800
@@ -0,0 +1,435 @@
+/*
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "libvtsSUNWmga.h" /* Common VTS library definitions */
+
+typedef union MemType {
+ uint64_t val[8];
+ uint32_t word[16];
+ uint16_t halfwd[32];
+ uint8_t byte[64];
+} MemType;
+
+static const int access_mode[] = {
+ 1, 2, 4, 8, 0
+};
+
+static MemType data[32 * 8];
+static MemType cdata[32 * 8];
+static MemType rdval[4];
+
+/*
+ * mga_test_memory()
+ *
+ * This test will open the device and read and write to all memory
+ * addresses.
+ */
+
+return_packet *
+mga_test_memory(
+ register int const fd)
+{
+ static return_packet rp;
+
+ memset(&rp, 0, sizeof (return_packet));
+
+ if (gfx_vts_debug_mask & GRAPHICS_VTS_MEM_OFF) {
+ return (&rp);
+ }
+
+ TraceMessage(VTS_DEBUG, "mga_test_memory",
+ "mga_test_memory running\n");
+
+ mga_block_signals();
+
+ mga_lock_display();
+
+ memory_test(&rp, fd);
+
+ TraceMessage(VTS_DEBUG, "mga_test_memory",
+ "mga_test_memory completed\n");
+
+ mga_unlock_display();
+
+ mga_restore_signals();
+
+ return (&rp);
+}
+
+
+int
+memory_test(
+ register return_packet *const rp,
+ register int const fd)
+{
+ register size_t i;
+ register int signo;
+ struct sigaction oldhup;
+ struct sigaction oldint;
+ struct sigaction oldalrm;
+ struct sigaction oldterm;
+ struct sigaction newsigact;
+ sigset_t oldprocmask;
+
+ memset(&mga_info, 0, sizeof (mga_info));
+ mga_info.mga_fd = fd;
+
+ if (mga_map_mem(rp, GRAPHICS_ERR_MEMORY_MSG) != 0) {
+ close(fd);
+ return (-1);
+ }
+
+ if (mga_init_info(rp, GRAPHICS_ERR_MEMORY_MSG) != 0) {
+ mga_unmap_mem(NULL, GRAPHICS_ERR_MEMORY_MSG);
+ close(fd);
+ return (-1);
+ }
+
+ mga_save_palet();
+ mga_set_palet();
+
+ /*
+ * Allow a SIGHUP, SIGINT, SIGALRM, or SIGTERM to interrupt our
+ * memory_test. These signals should already be masked from a
+ * call to mga_block_signals.
+ */
+
+ /* Save the current signals. */
+
+ sigaction(SIGHUP, NULL, &oldhup);
+ sigaction(SIGINT, NULL, &oldint);
+ sigaction(SIGALRM, NULL, &oldalrm);
+ sigaction(SIGTERM, NULL, &oldterm);
+
+ /* Setup up new signal action. */
+
+ newsigact.sa_handler = mga_signal_routine;
+ sigemptyset(&newsigact.sa_mask);
+ newsigact.sa_flags = 0;
+
+ signo = sigsetjmp(mga_xw.xw_sigjmpbuf, 1);
+ if (!signo) {
+ /* First time goes here. */
+
+ /* Set signal routines. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &newsigact, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &newsigact, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &newsigact, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &newsigact, NULL);
+
+ /* Unmask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &mga_xw.xw_procmask, &oldprocmask);
+
+ for (i = 0; access_mode[i] != 0; i++) {
+ check_plane(mga_info.mga_depth, access_mode[i],
+ mga_info.mga_linesize / mga_info.mga_pixelsize,
+ mga_info.mga_height,
+ mga_info.mga_width, mga_info.mga_pixelsize,
+ mga_info.mga_fb_ptr);
+ }
+
+ /* Mask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &oldprocmask, NULL);
+
+ /* Restore the signals. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &oldhup, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &oldint, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &oldalrm, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &oldterm, NULL);
+ }
+
+ else {
+ /* We come here from the siglongjmp in mga_signal_routine. */
+
+ /* Mask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &oldprocmask, NULL);
+
+ /* Restore the signals. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &oldhup, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &oldint, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &oldalrm, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &oldterm, NULL);
+
+ /* Cause us to get the signal, when we unmask the signals. */
+
+ kill(getpid(), signo);
+ }
+
+ mga_restore_palet();
+
+ if (mga_unmap_mem(rp, GRAPHICS_ERR_MEMORY_MSG) != 0) {
+ close(fd);
+ return (-1);
+ }
+
+
+ if (close(fd) != 0) {
+ gfx_vts_set_message(rp, 1, GRAPHICS_ERR_MEMORY_MSG,
+ "error closing device\n");
+ return (-1);
+ }
+
+ return (0);
+}
+
+
+void
+check_plane(
+ register int const num_planes,
+ register int const access_mode,
+ register int const fb_pitch,
+ register int const fb_height,
+ register int const fb_width,
+ register int const bytepp,
+ register caddr_t const base)
+{
+ register int x;
+ register int y;
+ register int complement;
+
+ /* Set up raster for this plane group */
+
+ init_data(num_planes);
+
+ /* Cover each 64x64 chunk of screen space */
+
+ y = 0;
+ while (y < fb_height) {
+ x = 0;
+ while (x < fb_width) {
+ if (x + 63 > fb_width) x = fb_width - 64;
+ if (y + 63 > fb_height) y = fb_height - 64;
+
+ /* Do each chunk twice - once normal, once complement */
+
+ for (complement = B_FALSE;
+ complement <= B_TRUE;
+ complement++) {
+ write_read(x, y,
+ (boolean_t)complement,
+ access_mode,
+ B_TRUE,
+ fb_pitch,
+ bytepp,
+ base) ||
+ write_read(x, y,
+ (boolean_t)complement,
+ access_mode,
+ B_FALSE,
+ fb_pitch,
+ bytepp,
+ base);
+ }
+
+ /* Move over one 64x64 chunk */
+
+ x += 64;
+ }
+
+ /* Move down one 64x64 chunk */
+
+ y += 64;
+ }
+}
+
+
+void
+init_data(
+ register int const num_planes)
+{
+ register int i;
+ register int j;
+
+ /* Get memory to store data */
+
+ /* Write data to memory */
+
+ for (i = 0; i < num_planes * 8; i++) {
+ for (j = 0; j < 8; j++) {
+
+ /* Figure out the value to write */
+
+ data[i].val[j] = ((unsigned long long)
+ test_data() << 32) | test_data();
+ cdata[i].val[j] = ~data[i].val[j];
+ }
+ }
+}
+
+
+u_int
+test_data(
+ void)
+{
+ register u_int ret;
+
+ ret = (u_int)mrand48();
+ return (ret);
+}
+
+
+boolean_t
+write_read(
+ register int const xoff,
+ register int const yoff,
+ register boolean_t const complement,
+ register int const access_mode,
+ register boolean_t const pass,
+ register int const fb_pitch,
+ register int const bytepp,
+ register caddr_t const base)
+{
+ register MemType *const dp = complement ? cdata : data;
+ register int const pitch = fb_pitch;
+ register int x;
+ register int y;
+ register int i;
+ register caddr_t mem_addr;
+ register int subscr = 0;
+
+ /* Write Data to Screen */
+
+ for (y = yoff; y < yoff + 64; y++) {
+ for (x = xoff * bytepp, i = 0;
+ x < ((xoff + 64) *bytepp);
+ x += access_mode, i++) {
+ mem_addr = (y*pitch*bytepp) + x + base;
+
+ /* Check which access mode to use for write */
+
+ switch (access_mode) {
+ case 8: /* long long (8-byte) access mode */
+ *(uint64_t volatile *)mem_addr =
+ dp[subscr].val[i];
+ break;
+
+ case 4: /* word (4-byte) access mode */
+ *(uint32_t volatile *)mem_addr =
+ dp[subscr].word[i];
+ break;
+
+ case 2: /* short (2-byte) access mode */
+ *(uint16_t volatile *)mem_addr =
+ dp[subscr].halfwd[i];
+ break;
+
+ default: /* default to byte access */
+ *(uint8_t volatile *)mem_addr =
+ dp[subscr].byte[i];
+ break;
+ }
+ }
+ subscr++;
+ }
+
+ /* Read the Data From the Screen */
+
+ for (y = yoff; y < yoff + 64; y++) {
+ for (x = xoff * bytepp, i = 0;
+ x < ((xoff + 64) * bytepp);
+ x += access_mode, i++) {
+ mem_addr = (y*pitch*bytepp) + x + base;
+
+ switch (access_mode) {
+ case 8: /* long long (8-byte) access mode */
+ rdval[0].val[i] =
+ *(uint64_t volatile const *)mem_addr;
+ break;
+
+ case 4: /* word (4-byte) access mode */
+ rdval[0].word[i] =
+ *(uint32_t volatile const *)mem_addr;
+ break;
+
+ case 2: /* short (2-byte) access mode */
+ rdval[0].halfwd[i] =
+ *(uint16_t volatile const *)mem_addr;
+ break;
+
+ default: /* default to byte access */
+ rdval[0].byte[i] =
+ *(uint8_t volatile const *)mem_addr;
+ break;
+ }
+ }
+
+ /* TODO: verification */
+
+ if (memcmp(rdval, dp[subscr].byte, 64 * bytepp) != 0) {
+ switch (access_mode) {
+ case 8: /* long long (8-byte) access mode */
+ for (i = 0; i < (8 * bytepp); i++) {
+ if (rdval[0].val[i] != dp[subscr].val[i]) {
+ return (B_FALSE);
+ }
+ }
+ break;
+
+ case 4: /* word (4-byte) access mode */
+ for (i = 0; i < (16 * bytepp); i++) {
+ if (rdval[0].word[i] != dp[subscr].word[i]) {
+ return (B_FALSE);
+ }
+ }
+ break;
+
+ case 2: /* short (2-byte) access mode */
+ for (i = 0; i < (32 * bytepp); i++) {
+ if (rdval[0].halfwd[i] != dp[subscr].halfwd[i]) {
+ return (B_FALSE);
+ }
+ }
+ break;
+
+ default: /* default to byte access */
+ for (i = 0; i < (64 * bytepp); i++) {
+ if (rdval[0].byte[i] != dp[subscr].byte[i]) {
+ return (B_FALSE);
+ }
+ }
+ break;
+ }
+ }
+ subscr++;
+ }
+
+ return (B_TRUE);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/app/gfx-utils/sun-src/vts/mga/mga.h Fri Feb 24 16:15:46 2012 -0800
@@ -0,0 +1,2781 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _MGA_H
+#define _MGA_H
+
+/* BEGIN CSTYLED */
+
+ /* MGA PCI Specific Registers */
+
+#define MGAPCI_AGP_CMD 0xf8
+#define MGAPCI_AGP_IDENT 0xf0
+#define MGAPCI_AGP_STS 0xf4
+#define MGAPCI_FB_BASE 0x10
+#define MGAPCI_CONTROL_BASE 0x14
+#define MGAPCI_ILOAD_BASE 0x18
+#define MGAPCI_MGA_DATA 0x48
+#define MGAPCI_MGA_INDEX 0x44
+#define MGAPCI_OPTION 0x40
+#define MGAPCI_OPTION2 0x50
+#define MGAPCI_PMCSR 0xe0
+#define MGAPCI_PMIDENT 0xdc
+#define MGAPCI_SUBSYSID 0x4c
+
+#define MGAREG_FB 1
+#define MGAREG_CONTROL 2
+#define MGAREG_ILOAD 3
+#define MGAREG_ROM 4
+
+#define MGASIZE_FB 0x01000000
+#define MGASIZE_CONTROL 0x4000
+#define MGASIZE_ILOAD 0x00800000
+#define MGASIZE_ROM 0x10000
+
+ /* MGA PCI AGP Command 0xf8 */
+
+#define MGAPCI_AGPCMD_RQ_DEPTH_MASK 0x1f000000
+#define MGAPCI_AGPCMD_RQ_DEPTH_SHIFT 24
+#define MGAPCI_AGPCMD_SBA_ENABLE 0x00000200
+#define MGAPCI_AGPCMD_AGP_ENABLE 0x00000100
+#define MGAPCI_AGPCMD_DATA_RATE_MASK 0x00000007
+#define MGAPCI_AGPCMD_DATA_RATE_1 0x00000001
+#define MGAPCI_AGPCMD_DATA_RATE_2 0x00000002
+
+ /* MGA PCI AGP Capability Identifier 0xf0 */
+
+#define MGAPCI_AGPIDENT_AGP_REV_MASK 0x00ff0000
+#define MGAPCI_AGPIDENT_AGP_REV_SHIFT 16
+#define MGAPCI_AGPIDENT_AGP_NEXT_MASK 0x0000ff00
+#define MGAPCI_AGPIDENT_AGP_CAP_ID_MASK 0x000000ff
+#define MGAPCI_AGPIDENT_AGP_CAP_ID 0x00000002
+
+ /* MGA PCI AGP Status 0xf4 */
+
+#define MGAPCI_AGPSTS_RQ_MASK 0xff000000
+#define MGAPCI_AGPSTS_RQ_SHIFT 24
+#define MGAPCI_AGPSTS_SBA_CAP 0x00000200
+#define MGAPCI_AGPSTS_RATE_CAP_MASK 0x00000003
+
+ /* MGA PCI Vendor and Device 0x00 */
+
+#define MGAPCI_VENDOR_MATROX 0x102b
+
+#define MGAPCI_DEVICE_MGA_G200 0x0520
+#define MGAPCI_DEVICE_MGA_G200AGP 0x0521
+#define MGAPCI_DEVICE_MGA_G200E 0x0522
+
+ /* MGA PCI Indirect Access Data 0x48 */
+
+ /* MGA PCI Indirect Access Index 0x44 */
+
+#define MGAPCI_INDEX_MASK 0x00003ffc
+#define MGAPCI_INDEX_SHIFT 2
+
+ /* MGA PCI Option 0x40 */
+
+#define MGAPCI_OPTION_POWERPC 0x80000000
+#define MGAPCI_OPTION_BIOSEN 0x40000000
+#define MGAPCI_OPTION_NORETRY 0x20000000
+#define MGAPCI_OPTION_ENHMEMACC 0x04000000
+#define MGAPCI_OPTION_RFHCNT_MASK 0x001f8000
+#define MGAPCI_OPTION_RFHCNT_SHIFT 15
+#define MGAPCI_OPTION_HARDPWMSK 0x00004000
+#define MGAPCI_OPTION_MEMCONFIG_MASK 0x00001c00
+#define MGAPCI_OPTION_MEMORG_MASK 0x00001800
+#define MGAPCI_OPTION_MEMORG_2_128K_32 0x00000000
+#define MGAPCI_OPTION_MEMORG_2_256K_32 0x00000800
+#define MGAPCI_OPTION_MEMORG_2_512K_16 0x00001000
+#define MGAPCI_OPTION_MEMORG_4_128K_32 0x00001800
+#define MGAPCI_OPTION_MEMBANK_MASK 0x00000400
+#define MGAPCI_OPTION_MEMBANK_ONE_BANK 0x00000000
+#define MGAPCI_OPTION_MEMBANK_TWO_BANKS 0x00000400
+#define MGAPCI_OPTION_VGAIOEN 0x00000100
+#define MGAPCI_OPTION_PLLSEL 0x00000040
+#define MGAPCI_OPTION_SYSPLLPDN 0x00000020
+#define MGAPCI_OPTION_MCLKDIV 0x00000010
+#define MGAPCI_OPTION_GCLKDIV 0x00000008
+#define MGAPCI_OPTION_SYSCLKDIS 0x00000004
+#define MGAPCI_OPTION_SYSCLKSL_MASK 0x00000003
+#define MGAPCI_OPTION_SYSCLKSL_PCI 0x00000000
+#define MGAPCI_OPTION_SYSCLKSL_PLL 0x00000001
+#define MGAPCI_OPTION_SYSCLKSL_MCLK 0x00000002
+
+ /* MGA PCI Option2 0x50 */
+
+#define MGAPCI_OPTION2_MODCLKP_MASK 0x00380000
+#define MGAPCI_OPTION2_MODCLKP_SHIFT 19
+#define MGAPCI_OPTION2_WCLKDIV 0x00020000
+#define MGAPCI_OPTION2_NOWCLKDIV 0x00010000
+#define MGAPCI_OPTION2_NOMCLKDIV 0x00008000
+#define MGAPCI_OPTION2_NOGCLKDIV 0x00004000
+#define MGAPCI_OPTION2_MBUFTYPE1 0x00002000
+#define MGAPCI_OPTION2_MBUFTYPE0 0x00001000
+#define MGAPCI_OPTION2_EEPROMWT 0x00000100
+
+ /* MGA PCI Power Management Control Status 0xe0 */
+
+#define MGAPCI_PMCSR_POWER_MASK 0x00000003
+#define MGAPCI_PMCSR_POWER_D0 0x00000000
+#define MGAPCI_PMCSR_POWER_D3 0x00000003
+
+ /* MGA PCI Power Management Identifier 0xdc */
+
+#define MGAPCI_PMIDENT_D2_SUP 0x04000000
+#define MGAPCI_PMIDENT_D1_SUP 0x02000000
+#define MGAPCI_PMIDENT_DSI 0x00200000
+#define MGAPCI_PMIDENT_PM_VERSION 0x00070000
+#define MGAPCI_PMIDENT_PM_NEXT_MASK 0x0000ff00
+#define MGAPCI_PMIDENT_PM_CAP_ID_MASK 0x000000ff
+#define MGAPCI_PMIDENT_PM_CAP_ID 0x00000001
+
+ /* MGA PCI Subsysid 0x4c */
+
+#define MGAPCI_SUBSYSID_SUBSYSVID 0xffff0000
+#define MGAPCI_SUSSYSID_SUBSYSVID_SHIFT 16
+#define MGAPCI_SUBSYSID_SUBSYSID 0x0000ffff
+
+ /* MGA Memory */
+
+#define MGA_AGP_PLL 0x1e4c
+#define MGA_ALPHACTRL 0x2c7c
+#define MGA_ALPHASTART 0x2c70
+#define MGA_ALPHAXINC 0x2c74
+#define MGA_ALPHAYINC 0x2c78
+#define MGA_AR0 0x1c60
+#define MGA_AR1 0x1c64
+#define MGA_AR2 0x1c68
+#define MGA_AR3 0x1c6c
+#define MGA_AR4 0x1c70
+#define MGA_AR5 0x1c74
+#define MGA_AR6 0x1c78
+#define MGA_BCOL 0x1c20
+#define MGA_BESA1CORG 0x3d10
+#define MGA_BESA1ORG 0x3d00
+#define MGA_BESA2CORG 0x3d14
+#define MGA_BESA2ORG 0x3d04
+#define MGA_BESB1CORG 0x3d18
+#define MGA_BESB1ORG 0x3d08
+#define MGA_BESB2CORG 0x3d1c
+#define MGA_BESB2ORG 0x3d0c
+#define MGA_BESCTL 0x3d20
+#define MGA_BESGLOBCTL 0x3dc0
+#define MGA_BESHCOORD 0x3d28
+#define MGA_BESHISCAL 0x3d30
+#define MGA_BESHSRCEND 0x3d3c
+#define MGA_BESHSRCLST 0x3d50
+#define MGA_BESHSRCST 0x3d38
+#define MGA_BESPITCH 0x3d24
+#define MGA_BESSTATUS 0x3dc4
+#define MGA_BESV1SRCLST 0x3d54
+#define MGA_BESV2SRCLST 0x3d58
+#define MGA_BESV1WGHT 0x3d48
+#define MGA_BESV2WGHT 0x3d4c
+#define MGA_BESVCOORD 0x3d2c
+#define MGA_BESVISCAL 0x3d34
+#define MGA_CODECADDR 0x3e44
+#define MGA_CODECCTL 0x3e40
+#define MGA_CODECHARDPTR 0x3e4c
+#define MGA_CODECHOSTPTR 0x3e48
+#define MGA_CODECLCODE 0x3e50
+#define MGA_CXBNDRY 0x1c80
+#define MGA_CXLEFT 0x1ca0
+#define MGA_CXRIGHT 0x1ca4
+#define MGA_DMAWIN 0x0000
+#define MGA_DMAMAP30 0x1e30
+#define MGA_DMAMAP74 0x1e34
+#define MGA_DMAMAPB8 0x1e38
+#define MGA_DMAMAPFC 0x1e3c
+#define MGA_DMAPAD 0x1c54
+#define MGA_DR0_Z32_LSB 0x2c50
+#define MGA_DR0_Z32_MSB 0x2c54
+#define MGA_DR2_Z32_LSB 0x2c60
+#define MGA_DR2_Z32_MSB 0x2c64
+#define MGA_DR3_Z32_LSB 0x2c68
+#define MGA_DR3_Z32_MSB 0x2c6c
+#define MGA_DR0 0x1cc0
+#define MGA_DR2 0x1cc8
+#define MGA_DR3 0x1ccc
+#define MGA_DR4 0x1cd0
+#define MGA_DR6 0x1cd8
+#define MGA_DR7 0x1cdc
+#define MGA_DR8 0x1ce0
+#define MGA_DR10 0x1ce8
+#define MGA_DR11 0x1cec
+#define MGA_DR12 0x1cf0
+#define MGA_DR14 0x1cf8
+#define MGA_DR15 0x1cfc
+#define MGA_DRAW_AR0 0x1d60
+#define MGA_DRAW_AR1 0x1d64
+#define MGA_DRAW_AR2 0x1d68
+#define MGA_DRAW_AR3 0x1d6c
+#define MGA_DRAW_AR4 0x1d70
+#define MGA_DRAW_AR5 0x1d74
+#define MGA_DRAW_AR6 0x1d78
+#define MGA_DRAW_BCOL 0x1d20
+#define MGA_DRAW_CXBNDRY 0x1d80
+#define MGA_DRAW_CXLEFT 0x1da0
+#define MGA_DRAW_CXRIGHT 0x1da4
+#define MGA_DRAW_DMAPAD 0x1d54
+#define MGA_DRAW_DWGCTL 0x1d00
+#define MGA_DRAW_FCOL 0x1d24
+#define MGA_DRAW_FXBNDRY 0x1d84
+#define MGA_DRAW_FXLEFT 0x1da8
+#define MGA_DRAW_FXRIGHT 0x1dac
+#define MGA_DRAW_LEN 0x1d5c
+#define MGA_DRAW_MACCESS 0x1d04
+#define MGA_DRAW_MCTLWTST 0x1d08
+#define MGA_DRAW_PAT0 0x1d10
+#define MGA_DRAW_PAT1 0x1d14
+#define MGA_DRAW_PITCH 0x1d8c
+#define MGA_DRAW_PLNWT 0x1d1c
+#define MGA_DRAW_SGN 0x1d58
+#define MGA_DRAW_SHIFT 0x1d50
+#define MGA_DRAW_SRC0 0x1d30
+#define MGA_DRAW_SRC1 0x1d34
+#define MGA_DRAW_SRC2 0x1d38
+#define MGA_DRAW_SRC3 0x1d3c
+#define MGA_DRAW_XDST 0x1db0
+#define MGA_DRAW_XYEND 0x1d44
+#define MGA_DRAW_XYSTRT 0x1d40
+#define MGA_DRAW_YBOT 0x1d9c
+#define MGA_DRAW_YDST 0x1d90
+#define MGA_DRAW_YDSTLEN 0x1d88
+#define MGA_DRAW_YDSTORG 0x1d94
+#define MGA_DRAW_YTOP 0x1d98
+#define MGA_DRAW_ZORG 0x1d0c
+#define MGA_DSTORG 0x2cb8
+#define MGA_DWG_INDIR_WT 0x1e80
+#define MGA_DWG_INDIR_WT0 0x1e80
+#define MGA_DWG_INDIR_WT1 0x1e84
+#define MGA_DWG_INDIR_WT2 0x1e88
+#define MGA_DWG_INDIR_WT3 0x1e8c
+#define MGA_DWG_INDIR_WT4 0x1e90
+#define MGA_DWG_INDIR_WT5 0x1e94
+#define MGA_DWG_INDIR_WT6 0x1e98
+#define MGA_DWG_INDIR_WT7 0x1e9c
+#define MGA_DWG_INDIR_WT8 0x1ea0
+#define MGA_DWG_INDIR_WT9 0x1ea4
+#define MGA_DWG_INDIR_WTA 0x1ea8
+#define MGA_DWG_INDIR_WTB 0x1eac
+#define MGA_DWG_INDIR_WTC 0x1eb0
+#define MGA_DWG_INDIR_WTD 0x1eb4
+#define MGA_DWG_INDIR_WTE 0x1eb8
+#define MGA_DWG_INDIR_WTF 0x1ebc
+#define MGA_DWGCTL 0x1c00
+#define MGA_DWGSYNC 0x2c4c
+#define MGA_FCOL 0x1c24
+#define MGA_FIFOSTATUS 0x1e10
+#define MGA_FOGCOL 0x1cf4
+#define MGA_FOGSTART 0x1cc4
+#define MGA_FOGXINC 0x1cd4
+#define MGA_FOGYINC 0x1ce4
+#define MGA_FXBNDRY 0x1c84
+#define MGA_FXLEFT 0x1ca8
+#define MGA_FXRIGHT 0x1cac
+#define MGA_ICLEAR 0x1e18
+#define MGA_IEN 0x1e1c
+#define MGA_LEN 0x1c5c
+#define MGA_MACCESS 0x1c04
+#define MGA_MCTLWTST 0x1c08
+#define MGA_MEMRDBK 0x1e44
+#define MGA_MODELREV 0x1e24
+#define MGA_OPMODE 0x1e54
+#define MGA_PAT0 0x1c10
+#define MGA_PAT1 0x1c14
+#define MGA_PITCH 0x1c8c
+#define MGA_PLNWT 0x1c1c
+#define MGA_PRIMADDRESS 0x1e58
+#define MGA_PRIMEND 0x1e5c
+#define MGA_PRIMPTR 0x1e50
+#define MGA_RST 0x1e40
+#define MGA_SECADDRESS 0x2c40
+#define MGA_SECEND 0x2c44
+#define MGA_SETUPADDRESS 0x2cd0
+#define MGA_SETUPEND 0x2cd4
+#define MGA_SGN 0x1c58
+#define MGA_SHIFT 0x1c50
+#define MGA_SOFTRAP 0x2c48
+#define MGA_SPECBSTART 0x2c98
+#define MGA_SPECBXINC 0x2c9c
+#define MGA_SPECBYINC 0x2ca0
+#define MGA_SPECGSTART 0x2c8c
+#define MGA_SPECGXINC 0x2c90
+#define MGA_SPECGYINC 0x2c94
+#define MGA_SPECRSTART 0x2c80
+#define MGA_SPECRXINC 0x2c84
+#define MGA_SPECRYINC 0x2c88
+#define MGA_SRC0 0x1c30
+#define MGA_SRC1 0x1c34
+#define MGA_SRC2 0x1c38
+#define MGA_SRC3 0x1c3c
+#define MGA_SRCORG 0x2cb4
+#define MGA_STATUS 0x1e14
+#define MGA_TEST0 0x1e48
+#define MGA_TEXBORDERCOL 0x2c5c
+#define MGA_TEXCTL 0x2c30
+#define MGA_TEXCTL2 0x2c3c
+#define MGA_TEXFILTER 0x2c58
+#define MGA_TEXHEIGHT 0x2c2c
+#define MGA_TEXORG 0x2c24
+#define MGA_TEXORG1 0x2ca4
+#define MGA_TEXORG2 0x2ca8
+#define MGA_TEXORG3 0x2cac
+#define MGA_TEXORG4 0x2cb0
+#define MGA_TEXTRANS 0x2c34
+#define MGA_TEXTRANSHIGH 0x2c38
+#define MGA_TEXWIDTH 0x2c28
+#define MGA_TMR0 0x2c00
+#define MGA_TMR1 0x2c04
+#define MGA_TMR2 0x2c08
+#define MGA_TMR3 0x2c0c
+#define MGA_TMR4 0x2c10
+#define MGA_TMR5 0x2c14
+#define MGA_TMR6 0x2c18
+#define MGA_TMR7 0x2c1c
+#define MGA_TMR8 0x2c20
+#define MGA_VBIADDR0 0x3e08
+#define MGA_VBIADDR1 0x3e0c
+#define MGA_VCOUNT 0x1e20
+#define MGA_VICLEAR 0x3e34
+#define MGA_VIEN 0x3e38
+#define MGA_VINADDR0 0x3e10
+#define MGA_VINADDR1 0x3e14
+#define MGA_VINCTL 0x3e1c
+#define MGA_VINCTL0 0x3e00
+#define MGA_VINCTL1 0x3e04
+#define MGA_VINNEXTWIN 0x3e18
+#define MGA_VSTATUS 0x3e30
+#define MGA_WCODEADDR 0x1e6c
+#define MGA_WFLAG 0x1dc4
+#define MGA_WFLAGNB 0x1e64
+#define MGA_WGETMSB 0x1dc8
+#define MGA_WIADDR 0x1dc0
+#define MGA_WIADDRNB 0x1e60
+#define MGA_WIMEMADDR 0x1e68
+#define MGA_WIMEMDATA 0x2000
+#define MGA_WMISC 0x1e70
+#define MGA_WR 0x2d00
+#define MGA_WVRTXSZ 0x1dcc
+#define MGA_XDST 0x1cb0
+#define MGA_XYEND 0x1c44
+#define MGA_XYSTRT 0x1c40
+#define MGA_YBOT 0x1c9c
+#define MGA_YDST 0x1c90
+#define MGA_YDSTLEN 0x1c88
+#define MGA_YDSTORG 0x1c94
+#define MGA_YTOP 0x1c98
+#define MGA_ZORG 0x1c0c
+
+ /* MGA AGP PLL 0x1e4c */
+
+#define MGA_AGP_PLL_AGP2XPLLEN 0x00000001
+
+ /* MGA Alpha Control 0x2c7c (wo) */
+
+#define MGA_ALPHACTRL_ALPHASEL_MASK 0x03000000
+#define MGA_ALPHACTRL_ALPHASEL_TEXTURE 0x00000000
+#define MGA_ALPHACTRL_ALPHASEL_DIFFUSED 0x01000000
+#define MGA_ALPHACTRL_ALPHASEL_MODULATED 0x02000000
+#define MGA_ALPHACTRL_ALPHASEL_TRANSPARENCY 0x03000000
+
+#define MGA_ALPHACTRL_ATREF_MASK 0x00ff0000
+#define MGA_ALPHACTRL_ATREF_SHIFT 16
+
+#define MGA_ALPHACTRL_ATMODE_MASK 0x0000e000
+#define MGA_ALPHACTRL_ATMODE_NOACMP 0x00000000
+#define MGA_ALPHACTRL_ATMODE_AE 0x00004000
+#define MGA_ALPHACTRL_ATMODE_ANE 0x00006000
+#define MGA_ALPHACTRL_ATMODE_ALT 0x00008000
+#define MGA_ALPHACTRL_ATMODE_ALTE 0x0000a000
+#define MGA_ALPHACTRL_ATMODE_AGT 0x0000c000
+#define MGA_ALPHACTRL_ATMODE_AGTE 0x0000e000
+
+#define MGA_ALPHACTRL_ATEN 0x00001000
+
+#define MGA_ALPHACTRL_ASTIPPLE 0x00000800
+
+#define MGA_ALPHACTRL_ALPHAMODE_MASK 0x00000300
+#define MGA_ALPHACTRL_ALPHAMODE_FCOL 0x00000000
+#define MGA_ALPHACTRL_ALPHAMODE_ALPHA_CHANNEL 0x00000100
+#define MGA_ALPHACTRL_ALPHAMODE_VIDEO_ALPHA 0x00000200
+
+#define MGA_ALPHACTRL_DSTBLENDF_MASK 0x000000f0
+#define MGA_ALPHACTRL_DSTBLENDF_ZERO 0x00000000
+#define MGA_ALPHACTRL_DSTBLENDF_ONE 0x00000010
+#define MGA_ALPHACTRL_DSTBLENDF_SRC_COLOR 0x00000020
+#define MGA_ALPHACTRL_DSTBLENDF_ONE_MINUS_SRC_COLOR 0x00000030
+#define MGA_ALPHACTRL_DSTBLENDF_SRC_ALPHA 0x00000040
+#define MGA_ALPHACTRL_DSTBLENDF_ONE_MINUS_SRC_ALPHA 0x00000050
+#define MGA_ALPHACTRL_DSTBLENDF_DST_ALPHA 0x00000060
+#define MGA_ALPHACTRL_DSTBLENDF_ONE_MINUS_DST_ALPHA 0x00000070
+
+#define MGA_ALPHACTRL_SRCBLENDF_MASK 0x0000000f
+#define MGA_ALPHACTRL_SRCBLENDF_ZERO 0x00000000
+#define MGA_ALPHACTRL_SRCBLENDF_ONE 0x00000001
+#define MGA_ALPHACTRL_SRCBLENDF_DST_COLOR 0x00000002
+#define MGA_ALPHACTRL_SRCBLENDF_ONE_MINUS_DST_COLOR 0x00000003
+#define MGA_ALPHACTRL_SRCBLENDF_SRC_ALPHA 0x00000004
+#define MGA_ALPHACTRL_SRCBLENDF_ONE_MINUS_SRC_ALPHA 0x00000005
+#define MGA_ALPHACTRL_SRCBLENDF_DST_ALPHA 0x00000006
+#define MGA_ALPHACTRL_SRCBLENDF_ONE_MINUS_DST_ALPHA 0x00000007
+#define MGA_ALPHACTRL_SRCBLENDF_SRC_ALPHA_SATURATE 0x00000008
+
+ /* MGA Alpha Start 0x2c70 (wo) */
+
+#define MGA_ALPHASTART_MASK 0x00ffffff
+
+ /* MGA Alpha Xinc 0x2c74 (wo) */
+
+#define MGA_ALPHAXINC_MASK 0x00ffffff
+
+ /* MGA Alpha Yinc 0x2c78 (wo) */
+
+#define MGA_ALPHAYINC_MASK 0x00ffffff
+
+ /* MGA Address 0 0x1c60 (wo), 0x1d60 (wo) */
+
+#define MGA_AR0_MASK 0x0003ffff
+
+ /* MGA Address 1 0x1c64 (wo), 0x1d64 (wo) */
+
+#define MGA_AR1_MASK 0x00ffffff
+
+ /* MGA Address 2 0x1c68 (wo), 0x1d68 (wo) */
+
+#define MGA_AR2_MASK 0x0003ffff
+
+ /* MGA Address 3 0x1c6c (wo), 0x1d6c (wo) */
+
+#define MGA_AR3_MASK 0x00ffffff
+#define MGA_AR3_SPAGE_MASK 0x07000000
+#define MGA_AR3_SPAGE_SHIFT 24
+
+ /* MGA Address 4 0x1c70 (wo), 0x1d70 (wo) */
+
+#define MGA_AR4_MASK 0x0003ffff
+
+ /* MGA Address 5 0x1c74 (wo), 0x1d74 (wo) */
+
+#define MGA_AR5_MASK 0x0003ffff
+
+ /* MGA Address 6 0x1c78 (wo), 0x1d78 (wo) */
+
+#define MGA_AR6_MASK 0x0003ffff
+
+ /* MGA Background Color 0x1c20 (wo), 0x1d20 (wo) */
+
+ /* MGA Backend Scaler Buffer A Field 1 Chroma Origin 0x3d10 (wo) */
+
+ /* MGA Backend Scaler Buffer A Field 1 Origin 0x3d00 (wo) */
+
+ /* MGA Backend Scaler Buffer A Field 2 Chroma Origin 0x3d14 (wo) */
+
+ /* MGA Backend Scaler Buffer A Field 2 Origin 0x3d04 (wo) */
+
+ /* MGA Backend Scaler Buffer B Field 1 Chroma Origin 0x3d18 (wo) */
+
+ /* MGA Backend Scaler Buffer B Field 1 Origin 0x3d08 (wo) */
+
+ /* MGA Backend Scaler Buffer B Field 2 Chroma Origin 0x3d1c (wo) */
+
+ /* MGA Backend Scaler Buffer B Field 2 Origin 0x3d0c (wo) */
+
+#define MGA_BESCORG_MASK 0x00ffffff
+
+#define MGA_BESORG_MASK 0x00ffffff
+
+ /* MGA Backend Scaler Control 0x3d20 */
+
+#define MGA_BESCTL_BESFSEL_MASK 0x06000000
+#define MGA_BESCTL_BESFSEL_BUF_A_FIELD_1 0x00000000
+#define MGA_BESCTL_BESFSEL_BUF_A_FIELD_2 0x02000000
+#define MGA_BESCTL_BESFSEL_BUF_B_FIELD_1 0x04000000
+#define MGA_BESCTL_BESFSEL_BUF_B_FIELD_2 0x06000000
+#define MGA_BESCTL_BESFSELM 0x01000000
+#define MGA_BESCTL_BESBLANK 0x00200000
+#define MGA_BESCTL_BESBWEN 0x00100000
+#define MGA_BESCTL_BESHMIR 0x00080000
+#define MGA_BESCTL_BESDITH 0x00040000
+#define MGA_BESCTL_BES420PL 0x00020000
+#define MGA_BESCTL_BESCUPS 0x00010000
+#define MGA_BESCTL_BESHFIXC 0x00001000
+#define MGA_BESCTL_BESVFEN 0x00000800
+#define MGA_BESCTL_BESHFEN 0x00000400
+#define MGA_BESCTL_BESV2SRCSTP 0x00000080
+#define MGA_BESCTL_BESV1SRCSTP 0x00000040
+#define MGA_BESCTL_BESEN 0x00000001
+
+ /* MGA Backend Scaler Global Control 0x3dc0 */
+
+#define MGA_BESGLOBCTL_BESVCNT_MASK 0x0fff0000
+#define MGA_BESGLOBCTL_BESVCNT_SHIFT 16
+#define MGA_BESGLOBCTL_BESREGHUP 0x00000008
+#define MGA_BESGLOBCTL_BESCORDER 0x00000004
+#define MGA_BESGLOBCTL_BESHZOOMF 0x00000002
+#define MGA_BESGLOBCTL_BESHZOOM 0x00000001
+
+ /* MGA Backend Scaler Horiz Coordinates 0x3d28 */
+
+#define MGA_BESHCOORD_BESLEFT_MASK 0x07ff0000
+#define MGA_BESHCOORD_BESLEFT_SHIFT 16
+#define MGA_BESHCOORD_BESRIGHT_MASK 0x000007ff
+
+ /* MGA Backend Scaler Horiz Inv Scaling Factor 0x3d30 (wo) */
+
+#define MGA_BESHISCAL_MASK 0x001ffffc
+#define MGA_BESHISCAL_SHIFT 2
+
+ /* MGA Backend Scaler Horiz Source Ending 0x3d3c (wo) */
+
+#define MGA_BESHSRCEND_MASK 0x03fffffc
+#define MGA_BESHSRCEND_SHIFT 2
+
+ /* MGA Backend Scaler Horiz Source Last 0x3d50 (wo) */
+
+#define MGA_BESHSRCLST_MASK 0x03ff0000
+#define MGA_BESHSRCLST_SHIFT 16
+
+ /* MGA Backend Scaler Horiz Source Start 0x3d38 (wo) */
+
+#define MGA_BESHSRCST_MASK 0x03fffffc
+#define MGA_BESHSRCST_SHIFT 2
+
+ /* MGA Backend Scaler Pitch 0x3d24 (wo) */
+
+#define MGA_BESPITCH_MASK 0x00000fff
+
+ /* MGA Backend Scaler Status 0x3dc4 (ro) */
+
+#define MGA_BESSTAT_MASK 0x00000003
+#define MGA_BESSTAT_A1 0x00000000
+#define MGA_BESSTAT_A2 0x00000001
+#define MGA_BESSTAT_B1 0x00000002
+#define MGA_BESSTAT_B2 0x00000003
+
+ /* MGA Backend Scaler Field 1 Vert Source Last Pos 0x3d54 (wo) */
+
+#define MGA_BESV1SRCLST_MASK 0x000003ff
+
+ /* MGA Backend Scaler Field 2 Vert Source Last Pos 0x3d58 (wo) */
+
+#define MGA_BESV2SRCLST_MASK 0x000003ff
+
+ /* MGA Backend Scaler Field 1 Vert Weight Start 0x3d48 (wo) */
+
+#define MGA_BESV1WGHT_BES1WGHTS 0x00010000
+#define MGA_BESV1WGHT_BESV1WGHT_MASK 0x0000fffc
+#define MGA_BESV1WGHT_BESV1WGTH_SHIFT 2
+
+ /* MGA Backend Scaler Field 2 Vert Weight Start 0x3d4c (wo) */
+
+#define MGA_BESV2WGHT_BES2WGHTS 0x00010000
+#define MGA_BESV2WGHT_BESV2WGHT_MASK 0x0000fffc
+#define MGA_BESV2WGHT_BESV2WGTH_SHIFT 2
+
+ /* MGA Backend Scaler Vertical Coordinates 0x3d2c (wo) */
+
+#define MGA_BESVCOORD_BESTOP_MASK 0x07ff0000
+#define MGA_BESVCOORD_BESTOP_SHIFT 16
+#define MGA_BESVCOORD_BESBOT_MASK 0x000007ff
+
+ /* MGA Backend Scaler Vertical Inverse Scaling Factor 0x3d34 (wo) */
+
+#define MGA_BESVISCAL_MASK 0x001ffffc
+#define MGA_BESVISCAL_SHIFT 2
+
+ /* MGA Codec Buffer Start Address 0x3e44 (wo) */
+
+#define MGA_CODECADDR_CODECSTART_MASK 0x00fffffc
+#define MGA_CODECADDR_CODECSTART_SHIFT 2
+#define MGA_CODECADDR_CODECBUFSIZE 0x00000001
+
+ /* MGA Codec Control 0x3e40 (wo) */
+
+#define MGA_CODECCTL_CODECMISCCTL_MASK 0xff000000
+#define MGA_CODECCTL_CODECMISCCTL_SHIFT 24
+#define MGA_CODECCTL_CODECRWIDTH_MASK 0x00003000
+#define MGA_CODECCTL_CODECRWIDTH_SHIFT 12
+#define MGA_CODECCTL_CODECFIFOADDR_MASK 0x00000700
+#define MGA_CODECCTL_CODECFIFOADDR_SHIFT 8
+#define MGA_CODECCTL_CODECTRANSEN 0x00000040
+#define MGA_CODECCTL_STOPCODEC 0x00000020
+#define MGA_CODECCTL_VMIMODE 0x00000010
+#define MGA_CODECCTL_CODECDATAIN 0x00000008
+#define MGA_CODECCTL_CMDEXECTRIG 0x00000004
+#define MGA_CODECCTL_CODECMODE 0x00000002
+#define MGA_CODECCTL_CODECEN 0x00000001
+
+ /* MGA Codec Hard Pointer 0x3e4c (ro) */
+
+#define MGA_CODECHARDPTR_MASK 0x0000ffff
+
+ /* MGA Codec Host Pointer 0x3e48 (wo) */
+
+#define MGA_CODECHOSTPTR_MASK 0x0000ffff
+
+ /* MGA Codec Lcode Pointer 0x3e50 (ro) */
+
+#define MGA_CODECLCODE_MASK 0x0000ffff
+
+ /* MGA Clipper X Boundary 0x1c80 (wo), 0x1d80 (wo) */
+
+#define MGA_CXBNDRY_CXRIGHT_MASK 0x0fff0000
+#define MGA_CXBNDRY_CXRIGHT_SHIFT 16
+#define MGA_CXBNDRY_CXLEFT_MASK 0x00000fff
+
+ /* MGA Clipper X Minimum Boundary 0x1ca0 (wo), 0x1da0 (wo) */
+
+#define MGA_CXLEFT_MASK 0x00000fff
+
+ /* MGA Clipper X Maximum Boundary 0x1ca4 (wo), 0x1da4 (wo) */
+
+#define MGA_CXRIGHT_MASK 0x00000fff
+
+ /* MGA DMA Map 3 to 0 0x1e30 */
+
+#define MGA_DMAMAP30_MAP_REG3_MASK 0xff000000
+#define MGA_DMAMAP30_MAP_REG3_SHIFT 24
+#define MGA_DMAMAP30_MAP_REG2_MASK 0x00ff0000
+#define MGA_DMAMAP30_MAP_REG2_SHIFT 16
+#define MGA_DMAMAP30_MAP_REG1_MASK 0x0000ff00
+#define MGA_DMAMAP30_MAP_REG1_SHIFT 8
+#define MGA_DMAMAP30_MAP_REG0_MASK 0x000000ff
+
+ /* MGA DMA Map 7 to 4 0x1e34 */
+
+#define MGA_DMAMAP74_MAP_REG7_MASK 0xff000000
+#define MGA_DMAMAP74_MAP_REG7_SHIFT 24
+#define MGA_DMAMAP74_MAP_REG6_MASK 0x00ff0000
+#define MGA_DMAMAP74_MAP_REG6_SHIFT 16
+#define MGA_DMAMAP74_MAP_REG5_MASK 0x0000ff00
+#define MGA_DMAMAP74_MAP_REG5_SHIFT 8
+#define MGA_DMAMAP74_MAP_REG4_MASK 0x000000ff
+
+ /* MGA DMA Map B to 8 0x1e38 */
+
+#define MGA_DMAMAPB8_MAP_REGB_MASK 0xff000000
+#define MGA_DMAMAPB8_MAP_REGB_SHIFT 24
+#define MGA_DMAMAPB8_MAP_REGA_MASK 0x00ff0000
+#define MGA_DMAMAPB8_MAP_REGA_SHIFT 16
+#define MGA_DMAMAPB8_MAP_REG9_MASK 0x0000ff00
+#define MGA_DMAMAPB8_MAP_REG9_SHIFT 8
+#define MGA_DMAMAPB8_MAP_REG8_MASK 0x000000ff
+
+ /* MGA DMA Map F to C 0x1e3c */
+
+#define MGA_DMAMAPFC_MAP_REGF_MASK 0xff000000
+#define MGA_DMAMAPFC_MAP_REGF_SHIFT 24
+#define MGA_DMAMAPFC_MAP_REGE_MASK 0x00ff0000
+#define MGA_DMAMAPFC_MAP_REGE_SHIFT 16
+#define MGA_DMAMAPFC_MAP_REGD_MASK 0x0000ff00
+#define MGA_DMAMAPFC_MAP_REGD_SHIFT 8
+#define MGA_DMAMAPFC_MAP_REGC_MASK 0x000000ff
+
+ /* MGA DMA Padding 0x1c54 (wo), 0x1d54 (wo) */
+
+ /* MGA Extended Data ALU 0 Low 0x2c50 (wo) */
+
+ /* MGA Extended Data ALU 0 High 0x2c54 (wo) */
+
+#define MGA_DR0_Z32MSB_MASK 0x0000ffff
+
+ /* MGA Extended Data ALU 2 Low 0x2c60 (wo) */
+
+ /* MGA Extended Data ALU 2 High 0x2c64 (wo) */
+
+#define MGA_DR2_Z32MSB_MASK 0x0000ffff
+
+ /* MGA Extended Data ALU 3 Low 0x2c68 (wo) */
+
+ /* MGA Extended Data ALU 3 High 0x2c6c (wo) */
+
+#define MGA_DR3_Z32MSB_MASK 0x0000ffff
+
+ /* MGA Data ALU 0 0x1cc0 (wo) */
+
+ /* MGA Data ALU 2 0x1cc8 (wo) */
+
+ /* MGA Data ALU 3 0x1ccc (wo) */
+
+ /* MGA Data ALU 4 0x1cd0 (wo) */
+
+#define MGA_DR4_MASK 0x00ffffff
+
+ /* MGA Data ALU 6 0x1cd8 (wo) */
+
+#define MGA_DR6_MASK 0x00ffffff
+
+ /* MGA Data ALU 7 0x1cdc (wo) */
+
+#define MGA_DR7_MASK 0x00ffffff
+
+ /* MGA Data ALU 8 0x1ce0 (wo) */
+
+#define MGA_DR8_MASK 0x00ffffff
+
+ /* MGA Data ALU 10 0x1ce8 (wo) */
+
+#define MGA_DR10_MASK 0x00ffffff
+
+ /* MGA Data ALU 11 0x1cec (wo) */
+
+#define MGA_DR11_MASK 0x00ffffff
+
+ /* MGA Data ALU 12 0x1cf0 (wo) */
+
+#define MGA_DR12_MASK 0x00ffffff
+
+ /* MGA Data ALU 14 0x1cf8 (wo) */
+
+#define MGA_DR14_MASK 0x00ffffff
+
+ /* MGA Data ALU 15 0x1cfc (wo) */
+
+#define MGA_DR15_MASK 0x00ffffff
+
+ /* MGA Destination Origin 0x2cb8 (wo) */
+
+#define MGA_DSTORG_MASK 0xfffffff8
+#define MGA_DSTORG_SHIFT 3
+#define MGA_DSTORG_DSTACC 0x00000002
+#define MGA_DSTORG_DSTMAP 0x00000001
+
+ /* MGA Drawing Register Indirect Write 0 0x1e80 (wo) */
+ /* MGA Drawing Register Indirect Write 1 0x1e84 (wo) */
+ /* MGA Drawing Register Indirect Write 2 0x1e88 (wo) */
+ /* MGA Drawing Register Indirect Write 3 0x1e8c (wo) */
+ /* MGA Drawing Register Indirect Write 4 0x1e90 (wo) */
+ /* MGA Drawing Register Indirect Write 5 0x1e94 (wo) */
+ /* MGA Drawing Register Indirect Write 6 0x1e98 (wo) */
+ /* MGA Drawing Register Indirect Write 7 0x1e9c (wo) */
+ /* MGA Drawing Register Indirect Write 8 0x1ea0 (wo) */
+ /* MGA Drawing Register Indirect Write 9 0x1ea4 (wo) */
+ /* MGA Drawing Register Indirect Write A 0x1ea8 (wo) */
+ /* MGA Drawing Register Indirect Write B 0x1eac (wo) */
+ /* MGA Drawing Register Indirect Write C 0x1eb0 (wo) */
+ /* MGA Drawing Register Indirect Write D 0x1eb4 (wo) */
+ /* MGA Drawing Register Indirect Write E 0x1eb8 (wo) */
+ /* MGA Drawing Register Indirect Write F 0x1ebc (wo) */
+
+ /* MGA Drawing Control 0x1c00 (wo), 0x1d00 (wo) */
+
+#define MGA_DWGCTL_CLIPDIS 0x80000000
+#define MGA_DWGCTL_TRANSC 0x40000000
+#define MGA_DWGCTL_PATTERN 0x20000000
+#define MGA_DWGCTL_BLTMOD_MASK 0x1e000000
+#define MGA_DWGCTL_BLTMOD_BMONOLEF 0x00000000
+#define MGA_DWGCTL_BLTMOD_BPLAN 0x02000000
+#define MGA_DWGCTL_BLTMOD_BFCOL 0x04000000
+#define MGA_DWGCTL_BLTMOD_BU32BGR 0x06000000
+#define MGA_DWGCTL_BLTMOD_BMONOWF 0x08000000
+#define MGA_DWGCTL_BLTMOD_BU32RGB 0x0e000000
+#define MGA_DWGCTL_BLTMOD_BU24BGR 0x16000000
+#define MGA_DWGCTL_BLTMOD_BU24RGB 0x1e000000
+#define MGA_DWGCTL_TRANS_MASK 0x00f00000
+#define MGA_DWGCTL_TRANS_SHIFT 20
+#define MGA_DWGCTL_BOP_MASK 0x000f0000
+#define MGA_DWGCTL_BOP_CLEAR 0x00000000
+#define MGA_DWGCTL_BOP_NOR 0x00010000
+#define MGA_DWGCTL_BOP_ANDINVERTED 0x00020000
+#define MGA_DWGCTL_BOP_COPYINVERTED 0x00030000
+#define MGA_DWGCTL_BOP_ANDREVERSE 0x00040000
+#define MGA_DWGCTL_BOP_INVERT 0x00050000
+#define MGA_DWGCTL_BOP_XOR 0x00060000
+#define MGA_DWGCTL_BOP_NAND 0x00070000
+#define MGA_DWGCTL_BOP_AND 0x00080000
+#define MGA_DWGCTL_BOP_EQUIV 0x00090000
+#define MGA_DWGCTL_BOP_NOOP 0x000a0000
+#define MGA_DWGCTL_BOP_ORINVERTED 0x000b0000
+#define MGA_DWGCTL_BOP_COPY 0x000c0000
+#define MGA_DWGCTL_BOP_ORREVERSE 0x000d0000
+#define MGA_DWGCTL_BOP_OR 0x000e0000
+#define MGA_DWGCTL_BOP_SET 0x000f0000
+#define MGA_DWGCTL_SHFTZERO 0x00004000
+#define MGA_DWGCTL_SGNZERO 0x00002000
+#define MGA_DWGCTL_ARZERO 0x00001000
+#define MGA_DWGCTL_SOLID 0x00000800
+#define MGA_DWGCTL_ZMODE_MASK 0x00000700
+#define MGA_DWGCTL_ZMODE_NOZCMP 0x00000000
+#define MGA_DWGCTL_ZMODE_ZE 0x00000200
+#define MGA_DWGCTL_ZMODE_ZNE 0x00000300
+#define MGA_DWGCTL_ZMODE_ZLT 0x00000400
+#define MGA_DWGCTL_ZMODE_ZLTE 0x00000500
+#define MGA_DWGCTL_ZMODE_ZGT 0x00000600
+#define MGA_DWGCTL_ZMODE_ZGTE 0x00000700
+#define MGA_DWGCTL_LINEAR 0x00000080
+#define MGA_DWGCTL_ATYPE_MASK 0x00000070
+#define MGA_DWGCTL_ATYPE_RPL 0x00000000
+#define MGA_DWGCTL_ATYPE_RSTR 0x00000010
+#define MGA_DWGCTL_ATYPE_ZI 0x00000030
+#define MGA_DWGCTL_ATYPE_BLK 0x00000040
+#define MGA_DWGCTL_ATYPE_I 0x00000070
+#define MGA_DWGCTL_OPCOD_MASK 0x0000000f
+#define MGA_DWGCTL_OPCOD_LINE_OPEN 0x00000000
+#define MGA_DWGCTL_OPCOD_AUTOLINE_OPEN 0x00000001
+#define MGA_DWGCTL_OPCOD_LINE_CLOSE 0x00000002
+#define MGA_DWGCTL_OPCOD_AUTOLINE_CLOSE 0x00000003
+#define MGA_DWGCTL_OPCOD_TRAP 0x00000004
+#define MGA_DWGCTL_OPCOD_TEXTURE_TRAP 0x00000006
+#define MGA_DWGCTL_OPCOD_BITBLT 0x00000008
+#define MGA_DWGCTL_OPCOD_ILOAD 0x00000009
+
+ /* MGA Drawing Synchronization 0x2c4c */
+
+#define MGA_DWGSYNC_MASK 0xfffffffc
+
+ /* MGA Foreground Color 0x1c24 (wo), 0x1d24 (wo) */
+
+ /* MGA Fifo Status 0x1e10 (ro) */
+
+#define MGA_FIFOSTATUS_BEMPTY 0x00000200
+#define MGA_FIFOSTATUS_BFULL 0x00000100
+#define MGA_FIFOSTATUS_FIFOCOUNT_MASK 0x0000007f
+
+ /* MGA Fog Color 0x1cf4 (wo) */
+
+#define MGA_FOGCOL_MASK 0x00ffffff
+
+ /* MGA Fog Startr 0x1cc4 (wo) */
+
+#define MGA_FOGSTART_MASK 0x00ffffff
+
+ /* MGA Fog X Increment 0x1cd4 (wo) */
+
+#define MGA_FOGXINC_MASK 0x00ffffff
+
+ /* MGA Fog Y Increment 0x1ce4 (wo) */
+
+#define MGA_FOGYINC_MASK 0x00ffffff
+
+ /* MGA Fog X Address Boundary 0x1c84 (wo), 0x1d84 (wo) */
+
+#define MGA_FXBNDRY_FXRIGHT_MASK 0xffff0000
+#define MGA_FXBNDRY_FXRIGHT_SHIFT 16
+#define MGA_FXBNDRY_FXLEFT_MASK 0x0000ffff
+
+ /* MGA Fox X Address Left 0x1ca8 (wo), 0x1da8 (wo) */
+
+#define MGA_FXLEFT_MASK 0x0000ffff
+
+ /* MGA Fox X Address Right 0x1cac (wo), 0x1dac (wo) */
+
+#define MGA_FXRIGHT_MASK 0x0000ffff
+
+ /* MGA Interrupt Clear 0x1e18 (wo) */
+
+#define MGA_ICLEAR_WCICLR 0x00000100
+#define MGA_ICLEAR_WICLR 0x00000080
+#define MGA_ICLEAR_VLINEICLR 0x00000020
+#define MGA_ICLEAR_PICKICLR 0x00000004
+#define MGA_ICLEAR_SOFTRAPICLR 0x00000001
+
+ /* MGA Interrupt Enable 0x1e1c */
+
+#define MGA_IEN_WCIEN 0x00000100
+#define MGA_IEN_WIEN 0x00000080
+#define MGA_IEN_EXTIEN 0x00000040
+#define MGA_IEN_VLINEIEN 0x00000020
+#define MGA_IEN_PICKIEN 0x00000004
+#define MGA_IEN_SOFTRAPIEN 0x00000001
+
+ /* MGA Length 0x1c5c (wo), 0x1d5c (wo) */
+
+#define MGA_LENGTH_MASK 0x0000ffff
+
+ /* MGA Memory Access 0x1c04 (wo), 0x1d04 (wo) */
+
+#define MGA_MACCESS_DIT555 0x80000000
+#define MGA_MACCESS_NODITHER 0x40000000
+#define MGA_MACCESS_TLUTLOAD 0x20000000
+#define MGA_MACCESS_FOGEN 0x04000000
+#define MGA_MACCESS_MEMRESET 0x00008000
+#define MGA_MACCESS_ZWIDTH 0x00000008
+#define MGA_MACCESS_PWIDTH_MASK 0x00000003
+#define MGA_MACCESS_PWIDTH_PW8 0x00000000
+#define MGA_MACCESS_PWIDTH_PW16 0x00000001
+#define MGA_MACCESS_PWIDTH_PW32 0x00000002
+#define MGA_MACCESS_PWIDTH_PW24 0x00000003
+
+ /* MGA Memory Control Wait State 0x1c08 (wo) */
+
+#define MGA_MCTLWTST_BPLDELAY_MASK 0xe0000000
+#define MGA_MCTLWTST_BPLDELAY_SHIFT 29
+#define MGA_MCTLWTST_BPLDELAY_1_CYCLE 0x00000000
+#define MGA_MCTLWTST_BPLDELAY_2_CYCLES 0x20000000
+#define MGA_MCTLWTST_BPLDELAY_3_CYCLES 0x40000000
+#define MGA_MCTLWTST_BPLDELAY_4_CYCLES 0x60000000
+#define MGA_MCTLWTST_BPLDELAY_5_CYCLES 0x80000000
+#define MGA_MCTLWTST_BPLDELAY_6_CYCLES 0xa0000000
+#define MGA_MCTLWTST_BWCDELAY_MASK 0x0c000000
+#define MGA_MCTLWTST_BWCDELAY_SHIFT 26
+#define MGA_MCTLWTST_BWCDELAY_1_CYCLE 0x00000000
+#define MGA_MCTLWTST_BWCDELAY_2_CYCLES 0x04000000
+#define MGA_MCTLWTST_SMRDELAY_MASK 0x01800000
+#define MGA_MCTLWTST_SMRDELAY_SHIFT 23
+#define MGA_MCTLWTST_SMRDELAY_1_CYCLE 0x00000000
+#define MGA_MCTLWTST_SMRDELAY_2_CYCLES 0x00800000
+#define MGA_MCTLWTST_RDDELAY 0x00200000
+#define MGA_MCTLWTST_RDDELAY_SHIFT 21
+#define MGA_MCTLWTST_WRDELAY_MASK 0x000c0000
+#define MGA_MCTLWTST_WRDELAY_SHIFT 18
+#define MGA_MCTLWTST_WRDELAY_1_CYCLE 0x00000000
+#define MGA_MCTLWTST_WRDELAY_2_CYCLES 0x00040000
+#define MGA_MCTLWTST_RPDELAY_MASK 0x0000c000
+#define MGA_MCTLWTST_RPDELAY_SHIFT 14
+#define MGA_MCTLWTST_RPDELAY_2_CYCLES 0x00000000
+#define MGA_MCTLWTST_RPDELAY_3_CYCLES 0x00004000
+#define MGA_MCTLWTST_RPDELAY_4_CYCLES 0x00008000
+#define MGA_MCTLWTST_RPDELAY_5_CYCLES 0x0000c000
+#define MGA_MCTLWTST_RASMIN_MASK 0x00001c00
+#define MGA_MCTLWTST_RASMIN_SHIFT 10
+#define MGA_MCTLWTST_RASMIN_3_CYCLES 0x00000000
+#define MGA_MCTLWTST_RASMIN_4_CYCLES 0x00000400
+#define MGA_MCTLWTST_RASMIN_5_CYCLES 0x00000800
+#define MGA_MCTLWTST_RASMIN_6_CYCLES 0x00000c00
+#define MGA_MCTLWTST_RASMIN_7_CYCLES 0x00001000
+#define MGA_MCTLWTST_RASMIN_8_CYCLES 0x00001400
+#define MGA_MCTLWTST_RASMIN_9_CYCLES 0x00001800
+#define MGA_MCTLWTST_RASMIN_10_CYCLES 0x00001c00
+#define MGA_MCTLWTST_RCDDELAY_MASK 0x00000180
+#define MGA_MCTLWTST_RCDDELAY_SHIFT 7
+#define MGA_MCTLWTST_RCDDELAY_2_CYCLES 0x00000000
+#define MGA_MCTLWTST_RCDDELAY_3_CYCLES 0x00000080
+#define MGA_MCTLWTST_RCDDELAY_4_CYCLES 0x00000100
+#define MGA_MCTLWTST_RRDDELAY_MASK 0x00000030
+#define MGA_MCTLWTST_RRDDELAY_SHIFT 4
+#define MGA_MCTLWTST_RRDDELAY_1_CYCLE 0x00000000
+#define MGA_MCTLWTST_RRDDELAY_2_CYCLES 0x00000010
+#define MGA_MCTLWTST_RRDDELAY_3_CYCLES 0x00000020
+#define MGA_MCTLWTST_CASLNTCY_MASK 0x00000007
+#define MGA_MCTLWTST_CASLNTCY_2_CYCLES 0x00000000
+#define MGA_MCTLWTST_CASLNTCY_3_CYCLES 0x00000001
+#define MGA_MCTLWTST_CASLNTCY_4_CYCLES 0x00000002
+#define MGA_MCTLWTST_CASLNTCY_5_CYCLES 0x00000003
+
+ /* MGA Memory Read Back 0x1e44 */
+
+#define MGA_MEMRDBK_MRSOPCOD_MASK 0x1e000000
+#define MGA_MEMRDBK_MRSOPCOD_SHIFT 25
+#define MGA_MEMRDBK_STRMFCTL_MASK 0x00c00000
+#define MGA_MEMRDBK_STRMFCTL_DONTBLOCK 0x00000000
+#define MGA_MEMRDBK_STRMFCTL_TWOCMDS 0x00400000
+#define MGA_MEMRDBK_STRMFCTL_ONECMD 0x00800000
+#define MGA_MEMRDBK_MCLKBRD1_MASK 0x000001e0
+#define MGA_MEMRDBK_MCLKBRD1_SHIFT 5
+#define MGA_MEMRDBK_MCLKBRD0_MASK 0x0000000f
+
+ /* MGA Operating Mode 0x1e54 */
+
+#define MGA_OPMODE_DIRDATASIZ_MASK 0x00030000
+#define MGA_OPMODE_DIRDATASIZ_8BPP 0x00000000
+#define MGA_OPMODE_DIRDATASIZ_16BPP 0x00010000
+#define MGA_OPMODE_DIRDATASIZ_32BPP 0x00020000
+#define MGA_OPMODE_DIRDATASIZ_SHIFT 16
+#define MGA_OPMODE_DMADATASIZ_MASK 0x00000300
+#define MGA_OPMODE_DMADATASIZ_8BPP 0x00000000
+#define MGA_OPMODE_DMADATASIZ_16BPP 0x00000100
+#define MGA_OPMODE_DMADATASIZ_32BPP 0x00000200
+#define MGA_OPMODE_DMADATASIZ_SHIFT 8
+#define MGA_OPMODE_DMAMOD_MASK 0x0000000c
+#define MGA_OPMODE_DMAMOD_WRITE 0x00000000
+#define MGA_OPMODE_DMAMOD_BLIT 0x00000004
+#define MGA_OPMODE_DMAMOD_VECTOR 0x00000008
+#define MGA_OPMODE_DMAMOD_VERTEX 0x0000000c
+
+ /* MGA Pattern 0 0x1c10 (wo), 0x1d10 (wo) */
+ /* MGA Pattern 1 0x1c14 (wo), 0x1d14 (wo) */
+
+#define MGA_PITCH_YLIN 0x00008000
+#define MGA_PITCH_IY_MASK 0x00001fff
+
+ /* MGA Plane Write Mask 0x1c1c (wo), 0x1d1c (wo) */
+
+ /* MGA Primary DMA Current Address 0x1e58 */
+
+#define MGA_PRIMADDRESS_MASK 0xfffffffc
+#define MGA_PRIMADDRESS_PRIMOD_MASK 0x00000003
+#define MGA_PRIMADDRESS_PRIMOD_WRITE 0x00000000
+#define MGA_PRIMADDRESS_PRIMOD_BLIT 0x00000001
+#define MGA_PRIMADDRESS_PRIMOD_VECTOR 0x00000002
+#define MGA_PRIMADDRESS_PRIMOD_VERTEX 0x00000003
+
+ /* MGA Primary DMA End Address 0x1e5c */
+
+#define MGA_PRIMEND_MASK 0xfffffffc
+#define MGA_PRIMEND_PAGPXFER 0x00000002
+#define MGA_PRIMEND_PRIMNOSTART 0x00000001
+
+ /* MGA Primary List Status Fetch Pointer 0x1e50 */
+
+#define MGA_PRIMPTR_MASK 0xfffffff8
+#define MGA_PRIMPTR_PRIMPTREN1 0x00000002
+#define MGA_PRIMPTR_PRIMPTREN0 0x00000001
+
+ /* MGA Reset 0x1e40 */
+
+#define MGA_RESET_DUMMY_RST_MASK 0xffff8000
+#define MGA_RESET_DUMMY_RST_SHIFT 15
+#define MGA_RESET_POWERMDIR 0x00000100
+#define MGA_RESET_SOFTEXTRST 0x00000002
+#define MGA_RESET_SOFTRESET 0x00000001
+
+ /* MGA Secondary DMA Current Address 0x2c40 */
+
+#define MGA_SECADDRESS_MASK 0xfffffffc
+#define MGA_SECADDRESS_SECMOD_MASK 0x00000003
+#define MGA_SECADDRESS_SECMOD_WRITE 0x00000000
+#define MGA_SECADDRESS_SECMOD_BLIT 0x00000001
+#define MGA_SECADDRESS_SECMOD_VECTOR 0x00000002
+#define MGA_SECADDRESS_SECMOD_VERTEX 0x00000003
+
+ /* MGA Secondary DMA End Address 0x2c44 */
+
+#define MGA_SECEND_MASK 0xfffffffc
+#define MGA_SECEND_SAGPXFER 0x00000002
+
+ /* MGA Setup DMA Current Address 0x2cd0 */
+
+#define MGA_SETUPADDRESS_MASK 0xfffffffc
+#define MGA_SETUPADDRESS_SETUPMOD_MASK 0x00000003
+#define MGA_SETUPADDRESS_SETUPMOD_SETUP 0x00000000
+
+ /* MGA Setup DMA End Address 0x2cd4 */
+
+#define MGA_SETUPEND_MASK 0xfffffffc
+#define MGA_SETUPEND_SETUPAGPXFER 0x00000002
+
+ /* MGA Sign 0x1c58 (wo), 0x1d58 (wo) */
+
+#define MGA_SGN_ERRORINIT 0x80000000
+#define MGA_SGN_BRKLEFT 0x00000100
+#define MGA_SGN_SDXR 0x00000020
+#define MGA_SGN_SDY 0x00000004
+#define MGA_SGN_SDXL 0x00000002
+#define MGA_SGN_SDYDXL 0x00000001
+#define MGA_SGN_SCANLEFT 0x00000001
+
+ /* MGA Shifter Control 0x1c50 (wo), 0x1d50 (wo) */
+
+#define MGA_SHIFT_STYLELEN_MASK 0x007f0000
+#define MGA_SHIFT_STYLELEN_SHIFT 16
+#define MGA_SHIFT_FUNOFF_MASK 0x003f0000
+#define MGA_SHIFT_FUNOFF_SHIFT 16
+#define MGA_SHIFT_FUNCNT_MASK 0x0000007f
+#define MGA_SHIFT_Y_OFF_MASK 0x00000070
+#define MGA_SHIFT_Y_OFF_SHIFT 4
+#define MGA_SHIFT_X_OFF_MASK 0x0000000f
+
+ /* MGA Soft Trap Handle 0x2c48 */
+
+#define MGA_SOFTRAP_MASK 0xfffffffc
+
+ /* MGA Specular Lighting Blue Start 0x2c98 */
+ /* MGA Specular Lighting Blue X Increment 0x2c9c */
+ /* MGA Specular Lighting Blue Y Increment 0x2ca0 */
+ /* MGA Specular Lighting Green Start 0x2c8c */
+ /* MGA Specular Lighting Green X Increment 0x2c90 */
+ /* MGA Specular Lighting Green Y Increment 0x2c94 */
+ /* MGA Specular Lighting Red Start 0x2c80 */
+ /* MGA Specular Lighting Red X Increment 0x2c84 */
+ /* MGA Specular Lighting Red Y Increment 0x2c88 */
+
+#define MGA_SPECSTART_MASK 0x00ffffff
+
+#define MGA_SPECXINC_MASK 0x00ffffff
+
+#define MGA_SPECYINC_MASK 0x00ffffff
+
+ /* MGA Source 0 0x1c30 (wo), 0x1d30 (wo) */
+ /* MGA Source 1 0x1c34 (wo), 0x1d34 (wo) */
+ /* MGA Source 2 0x1c38 (wo), 0x1d38 (wo) */
+ /* MGA Source 3 0x1c3c (wo), 0x1d3c (wo) */
+
+ /* MGA Source Origin 0x2cb4 (wo) */
+
+#define MGA_SRCORG_MASK 0xfffffff8
+#define MGA_SRCORG_SRCACC 0x00000002
+#define MGA_SRCORG_SRCMAP 0x00000001
+
+ /* MGA Status 0x1e14 */
+
+#define MGA_STATUS_SWFLAG_MASK 0xf0000000
+#define MGA_STATUS_SWFLAG_SHIFT 28
+#define MGA_STATUS_WBUSY 0x00040000
+#define MGA_STATUS_ENDPRDMASTS 0x00020000
+#define MGA_STATUS_DSTENGSTS 0x00010000
+#define MGA_STATUS_WCPEN 0x00000100
+#define MGA_STATUS_WPEN 0x00000080
+#define MGA_STATUS_EXTPEN 0x00000040
+#define MGA_STATUS_VLINEPEN 0x00000020
+#define MGA_STATUS_VSYNCPEN 0x00000010
+#define MGA_STATUS_VSYNCSTS 0x00000008
+#define MGA_STATUS_PICKPEN 0x00000004
+#define MGA_STATUS_SOFTRAPEN 0x00000001
+
+ /* MGA Test 0 0x1e48 */
+
+#define MGA_TEST0_BIOSBOOT 0x80000000
+#define MGA_TEST0_RINGCNTCLKSL 0x40000000
+#define MGA_TEST0_RINGCNT_MASK 0x3ffc0000
+#define MGA_TEST0_RINGCNT_SHIFT 18
+#define MGA_TEST0_RINGCNTEN 0x00020000
+#define MGA_TEST0_TCLKSEL_MASK 0x0001c000
+#define MGA_TEST0_TCLKSEL_PIXPLL 0x00000000
+#define MGA_TEST0_TCLKSEL_PIXPLL_DIV4 0x00004000
+#define MGA_TEST0_TCLKSEL_SYSPLL 0x00008000
+#define MGA_TEST0_TCLKSEL_SYSPLL_DIV4 0x0000c000
+#define MGA_TEST0_TCLKSEL_AGPPLL 0x00010000
+#define MGA_TEST0_TCLKSEL_AGPPLL_DIV4 0x00014000
+#define MGA_TEST0_TMODE_MASK 0x00003800
+#define MGA_TEST0_TMODE_NORMAL 0x00000000
+#define MGA_TEST0_TMODE_OBSERVE 0x00000800
+#define MGA_TEST0_TMODE_SELFTEST 0x00001000
+#define MGA_TEST0_HITEN 0x00000400
+#define MGA_TEST0_APLLBYP 0x00000200
+#define MGA_TEST0_RINGEN 0x00000100
+#define MGA_TEST0_BESRAMTSTPASS 0x00000040
+#define MGA_TEST0_LUTTSTPASS 0x00000020
+#define MGA_TEST0_TLUTTSTPASS 0x00000010
+#define MGA_TEST0_TCACHETSTPASS 0x00000008
+#define MGA_TEST0_WRAMTSTPASS 0x00000004
+#define MGA_TEST0_RAMTSTDONE 0x00000002
+#define MGA_TEST0_RAMTSTEN 0x00000001
+
+ /* MGA Texture Border Color 0x2c5c (wo) */
+
+ /* MGA Texture Map Control 0x2c30 (wo) */
+
+#define MGA_TEXCTL_ITRANS 0x80000000
+#define MGA_TEXCTL_STRANS 0x40000000
+#define MGA_TEXCTL_TMODULATE 0x20000000
+#define MGA_TEXCTL_CLAMPU 0x10000000
+#define MGA_TEXCTL_CLAMPV 0x08000000
+#define MGA_TEXCTL_TAMASK 0x04000000
+#define MGA_TEXCTL_TAKEY 0x02000000
+#define MGA_TEXCTL_DECACLKEY 0x01000000
+#define MGA_TEXCTL_AZEROEXTEND 0x00800000
+#define MGA_TEXCTL_OWALPHA 0x00400000
+#define MGA_TEXCTL_TPITCHEXT_MASK 0x000ffe00
+#define MGA_TEXCTL_TPITCHEXT_SHIFT 9
+#define MGA_TEXCTL_TPITCH_MASK 0x00070000
+#define MGA_TEXCTL_TPITCH_SHIFT 16
+#define MGA_TEXCTL_TPICHLIN 0x00000100
+#define MGA_TEXCTL_PALSEL_MASK 0x00000070
+#define MGA_TEXCTL_PALSEL_SHIFT 4
+#define MGA_TEXCTL_TFORMAT_MASK 0x0000000f
+#define MGA_TEXCTL_TFORMAT_TW4 0x00000000
+#define MGA_TEXCTL_TFORMAT_TW8 0x00000001
+#define MGA_TEXCTL_TFORMAT_TW15 0x00000002
+#define MGA_TEXCTL_TFORMAT_TW16 0x00000003
+#define MGA_TEXCTL_TFORMAT_TW12 0x00000004
+#define MGA_TEXCTL_TFORMAT_TW32 0x00000006
+#define MGA_TEXCTL_TFORMAT_TW422 0x0000000a
+
+ /* MGA Texture Map Control 2 0x2c3c (wo) */
+
+#define MGA_TEXCTL2_SPECEN 0x00000040
+#define MGA_TEXCTL2_BORDEREN 0x00000020
+#define MGA_TEXCTL2_CKSTRANSDIS 0x00000010
+#define MGA_TEXCTL2_DECALDIS 0x00000004
+#define MGA_TEXCTL2_IDECAL 0x00000002
+#define MGA_TEXCTL2_DECALBLEND 0x00000041
+
+ /* MGA Texture Filtering 0x2c58 (wo) */
+
+#define MGA_TEXFILTER_MAPNB_MASK 0xe0000000
+#define MGA_TEXFILTER_MAPNB_SHIFT 29
+#define MGA_TEXFILTER_FTHRES_MASK 0x1fe00000
+#define MGA_TEXFILTER_FTHRES_SHIFT 21
+#define MGA_TEXFILTER_FILTERALPHA 0x00100000
+#define MGA_TEXFILTER_AVGSTRIDE 0x00080000
+#define MGA_TEXFILTER_MAGFILTER_MASK 0x000000f0
+#define MGA_TEXFILTER_MAGFILTER_NEAREST 0x00000000
+#define MGA_TEXFILTER_MAGFILTER_BILIN 0x00000020
+#define MGA_TEXFILTER_MAGFILTER_CNST 0x00000030
+#define MGA_TEXFILTER_MINFILTER_MASK 0x0000000f
+#define MGA_TEXFILTER_MINFILTER_NEAREST 0x00000000
+#define MGA_TEXFILTER_MINFILTER_BILIN 0x00000002
+#define MGA_TEXFILTER_MINFILTER_CNST 0x00000003
+#define MGA_TEXFILTER_MINFILTER_MM1S 0x00000008
+#define MGA_TEXFILTER_MINFILTER_MM2S 0x00000009
+#define MGA_TEXFILTER_MINFILTER_MM4S 0x0000000a
+#define MGA_TEXFILTER_MINFILTER_MM8S 0x0000000c
+
+ /* MGA Texture Height 0x2c2c (wo) */
+
+#define MGA_TEXHEIGHT_THMASK_MASK 0x1ffc0000
+#define MGA_TEXHEIGHT_THMASK_SHIFT 18
+#define MGA_TEXHEIGHT_RFH_MASK 0x00007e00
+#define MGA_TEXHEIGHT_RFH_SHIFT 9
+#define MGA_TEXHEIGHT_TH_MASK 0x0000003f
+
+ /* MGA Texture Origin 0x2c24 (wo) */
+
+ /* MGA Texture Origin 1 0x2ca4 (wo) */
+
+ /* MGA Texture Origin 2 0x2ca8 (wo) */
+
+ /* MGA Texture Origin 3 0x2cac (wo) */
+
+ /* MGA Texture Origin 4 0x2cb0 (wo) */
+
+ /* MGA Texture Transparency 0x2c34 (wo) */
+
+#define MGA_TEXORG_MASK 0xffffffe0
+#define MGA_TEXORG_SHIFT 5
+#define MGA_TEXORG_TEXORGACC 0x00000002
+#define MGA_TEXORG_TEXORGMAP 0x00000001
+
+#define MGA_TEXTRANS_TKMASK_MASK 0xffff0000
+#define MGA_TEXTRANS_TKMASK_SHIFT 16
+#define MGA_TEXTRANS_TCKEY_MASK 0x0000ffff
+
+ /* MGA Texture Transparency High 0x2c38 (wo) */
+
+#define MGA_TEXTRANSHIGH_TKMASKH_MASK 0xffff0000
+#define MGA_TEXTRANSHIGH_TKMASKH_SHIFT 16
+#define MGA_TEXTRANSHIGH_TCKEYH_MASK 0x0000ffff
+
+ /* MGA Texture Width 0x2c28 (wo) */
+
+#define MGA_TEXWIDTH_TWMASK_MASK 0x1ffc0000
+#define MGA_TEXWIDTH_TWMASK_SHIFT 18
+#define MGA_TEXWIDTH_RFW_MASK 0x00007e00
+#define MGA_TEXWIDTH_RFW_SHIFT 9
+#define MGA_TEXWIDTH_TW_MASK 0x0000003f
+
+ /* MGA Texture Mapping ALU 0 0x2c00 (wo) */
+ /* MGA Texture Mapping ALU 1 0x2c04 (wo) */
+ /* MGA Texture Mapping ALU 2 0x2c08 (wo) */
+ /* MGA Texture Mapping ALU 3 0x2c0c (wo) */
+ /* MGA Texture Mapping ALU 4 0x2c10 (wo) */
+ /* MGA Texture Mapping ALU 5 0x2c14 (wo) */
+ /* MGA Texture Mapping ALU 6 0x2c18 (wo) */
+ /* MGA Texture Mapping ALU 7 0x2c1c (wo) */
+ /* MGA Texture Mapping ALU 8 0x2c20 (wo) */
+
+ /* MGA VBI Address Window 0 0x3e08 (wo) */
+ /* MGA VBI Address Window 1 0x3e0c (wo) */
+
+#define MGA_VBIADDR_MASK 0x00ffffff
+
+ /* MGA Vertical Count 0x1e20 (ro) */
+
+#define MGA_VCOUNT_MASK 0x00000fff
+
+ /* MGA Video Interrupt Clear 0x3e34 (wo) */
+
+#define MGA_VICLEAR_DCMPEOIICLR 0x00000008
+#define MGA_VICLEAR_BLVLIICLR 0x00000004
+#define MGA_VICLEAR_CMDCMPLICLR 0x00000002
+#define MGA_VICLEAR_VINVSYNCICLR 0x00000001
+
+ /* MGA Video Interrupt Enable 0x3e38 */
+
+#define MGA_VIEN_DCMPEOIIEN 0x00000008
+#define MGA_VIEN_BLVLIEN 0x00000004
+#define MGA_VIEN_CMDCMPLIEN 0x00000002
+#define MGA_VIEN_VINVSYNCIEN 0x00000001
+
+ /* MGA Video Input Address Window 0 0x3e10 (wo) */
+ /* MGA Video Input Address Window 1 0x3e14 (wo) */
+
+#define MGA_VINADDR_MASK 0x00ffffff
+
+ /* MGA Video Input Control 0x3e1c (wo) */
+
+#define MGA_VINCTL_RPVALIDEN 0x01000000
+#define MGA_VINCTL_VBITASKEN 0x00010000
+#define MGA_VINCTL_VBIF1CNT_MASK 0x0000f000
+#define MGA_VINCTL_VBIF1CNT_SHIFT 12
+#define MGA_VINCTL_VBIF0CNT_MASK 0x00000f00
+#define MGA_VINCTL_VBIF0CNT_SHIFT 8
+#define MGA_VINCTL_VINEN 0x00000001
+
+ /* MGA Video Input Control Window 0 0x3e00 (wo) */
+ /* MGA Video Input Control Window 1 0x3e04 (wo) */
+
+#define MGA_VINCTL_VINPITCH_MASK 0x00000ff8
+#define MGA_VINCTL_VINPITCH_SHIFT 3
+#define MGA_VINCTL_VBICAP_MASK 0x00000006
+#define MGA_VINCTL_VBICAP_NO 0x00000000
+#define MGA_VINCTL_VBICAP_RAW 0x00000002
+#define MGA_VINCTL_VBICAP_SLICED 0x00000006
+#define MGA_VINCTL_VBICAP 0x00000001
+
+ /* MGA Video Input Next Window 0x3e18 (wo) */
+
+#define MGA_VINNEXTWIN_AUTOVINNEXTWIN 0x00000002
+#define MGA_VINNEXTWIN_VINNEXTWIN 0x00000001
+
+ /* MGA Video Status 0x3e30 (ro) */
+
+#define MGA_VSTATUS_CODEC_STALLED 0x00001000
+#define MGA_VSTATUS_SLCVBICAPD 0x00000800
+#define MGA_VSTATUS_RAWVBICAPD 0x00000400
+#define MGA_VSTATUS_VINCAPD 0x00000200
+#define MGA_VSTATUS_VINFIELDDETD 0x00000100
+#define MGA_VSTATUS_DCMPEOIPEN 0x00000008
+#define MGA_VSTATUS_BLVLPEN 0x00000004
+#define MGA_VSTATUS_CMDCMPLPEN 0x00000002
+#define MGA_VSTATUS_VINVSYNCPEN 0x00000001
+
+ /* MGA WARP Microcode Address 0x1e6c (ro) */
+
+#define MGA_WCODEADDR_MASK 0xffffff00
+
+ /* MGA WARP Flags 0x1dc4 (wo), 0x1e64 (wo) */
+
+#define MGA_WFLAG_WPRGFLAG_MASK 0xffff0000
+#define MGA_WFLAG_WALUCFGFLAG_MASK 0x0000ff00
+#define MGA_WFLAG_WALUCFGFLAG_H 0x00004000
+#define MGA_WFLAG_WALUCFGFLAG_M 0x00002000
+#define MGA_WFLAG_WALUCFGFLAG_T 0x00001000
+#define MGA_WFLAG_WALUCFGFLAG_U 0x00000800
+#define MGA_WFLAG_WALUCFGFLAG_S 0x00000400
+#define MGA_WFLAG_WALUCFGFLAG_R 0x00000200
+#define MGA_WFLAG_WALUCFGFLAG_L 0x00000100
+#define MGA_WFLAG_WALUSTSFLAG_MASK 0x000000ff
+#define MGA_WFLAG_WALUSTSFLAG_H 0x00000040
+#define MGA_WFLAG_WALUSTSFLAG_M 0x00000020
+#define MGA_WFLAG_WALUSTSFLAG_T 0x00000010
+#define MGA_WFLAG_WALUSTSFLAG_U 0x00000008
+#define MGA_WFLAG_WALUSTSFLAG_S 0x00000004
+#define MGA_WFLAG_WALUSTSFLAG_R 0x00000002
+#define MGA_WFLAG_WALUSTSFLAG_L 0x00000001
+
+ /* MGA WARP GetMSB Value */
+
+#define MGA_WGETMSB_WGETMSBMAX_MASK 0x00001f00
+#define MGA_WGETMSB_WGETMSBMAX_SHIFT 8
+#define MGA_WGETMSB_WGETMSBMIN_MASK 0x0000001f
+
+ /* MGA WARP Instruction Address 0x1dc0, 0x1e60 */
+
+#define MGA_WIADDR_MASK 0xfffffff8
+#define MGA_WIADDR_WAGP 0x00000004
+#define MGA_WIADDR_WMODE_MASK 0x00000003
+#define MGA_WIADDR_WMODE_SUSPEND 0x00000000
+#define MGA_WIADDR_WMODE_RESUME 0x00000001
+#define MGA_WIADDR_WMODE_JUMP 0x00000002
+#define MGA_WIADDR_WMODE_START 0x00000003
+
+ /* MGA WARP Instruction Memory Address 0x1e68 (wo) */
+
+#define MGA_WIMEMADDR_MASK 0x000000ff
+
+ /* MGA WARP Miscellaneous 0x1e70 */
+
+#define MGA_WMISC_WCACHEFLUSH 0x00000008
+#define MGA_WMISC_WMASTER 0x00000002
+#define MGA_WMISC_WUCODECACHE 0x00000001
+
+ /* MGA WARP Vertex Size 0x1dcc (wo) */
+
+#define MGA_WVRTXSZ_MASK 0x0000003f
+
+ /* MGA X Destination Address 0x1cb0 (wo), 0x1db0 (wo) */
+
+#define MGA_XDST_MASK 0x0000ffff
+
+ /* MGA XY End Address 0x1c44 (wo), 0x1d44 (wo) */
+
+#define MGA_XYEND_Y_END_MASK 0xffff0000
+#define MGA_XYEND_Y_END_SHIFT 16
+#define MGA_XYEND_X_END_MASK 0x0000ffff
+
+ /* MGA XY Start Address 0x1c40 (wo), 0x1d40 (wo) */
+
+#define MGA_XYSTRT_Y_END_MASK 0xffff0000
+#define MGA_XYSTRT_Y_END_SHIFT 16
+#define MGA_XYSTRT_X_END_MASK 0x0000ffff
+
+ /* MGA Y Bottom Boundary 0x1c9c (wo), 0x1d9c (wo) */
+
+#define MGA_YBOT_MASK 0x00ffffff
+
+ /* MGA Y Destination 0x1c90 (wo), 0x1d90 (wo) */
+
+#define MGA_YDST_SELLIN_MASK 0xe0000000
+#define MGA_YDST_SELLIN_SHIFT 29
+#define MGA_YDST_MASK 0x007fffff
+
+ /* MGA Y Destination and Length 0x1c88 (wo), 0x1d88 (wo) */
+
+#define MGA_YDSTLEN_YVAL_MASK 0xffff0000
+#define MGA_YDSTLEN_YVAL_SHIFT 16
+#define MGA_YDSTLEN_LENGTH_MASK 0x0000ffff
+
+ /* MGA Y Destination Origin 0x1c94 (wo), 0x1d94 (wo) */
+
+#define MGA_YDSTORG_MASK 0x00ffffff
+
+ /* MGA Y Top Boundary 0x1c98 (wo), 0x1d98 (wo) */
+
+#define MGA_YTOP_MASK 0x00ffffff
+
+ /* MGA Z-Depth Origin 0x1c0c (wo), 0x1d0c (wo) */
+
+#define MGA_ZORG_MASK 0xfffffffc
+#define MGA_ZORG_ZORGACC 0x00000002
+#define MGA_ZORG_ZORGMAP 0x00000001
+
+ /* MGA DAC Cursor position 0x3c0c */
+
+#define MGA_CURPOS_CURPOSY_MASK 0x0fff0000
+#define MGA_CURPOS_CURPOSY_SHIFT 16
+#define MGA_CURPOS_CURPOSX_MASK 0x00000fff
+
+ /* MGA DAC Palette Ram Data 0x3c01 */
+
+ /* MGA DAC Palette Ram Read Address 0x3c03 */
+
+ /* MGA DAC Palette Ram Write Address 0x3c00 */
+
+ /* MGA DAC Pixel Read Mask 0x3c02 */
+
+ /* MGA DAC Indexed Data 0x3c0a */
+
+#define MGA_XDATA_XCURADDL 0x04
+#define MGA_XDATA_XCURADDH 0x05
+#define MGA_XDATA_XCURCTRL 0x06
+#define MGA_XDATA_XCURCOL0RED 0x08
+#define MGA_XDATA_XCURCOL0GREEN 0x09
+#define MGA_XDATA_XCURCOL0BLUE 0x0a
+#define MGA_XDATA_XCURCOL1RED 0x0c
+#define MGA_XDATA_XCURCOL1GREEN 0x0d
+#define MGA_XDATA_XCURCOL1BLUE 0x0e
+#define MGA_XDATA_XCURCOL2RED 0x10
+#define MGA_XDATA_XCURCOL2GREEN 0x11
+#define MGA_XDATA_XCURCOL2BLUE 0x12
+#define MGA_XDATA_XVREFCTRL 0x18
+#define MGA_XDATA_XMULCTRL 0x19
+#define MGA_XDATA_XPIXCLKCTRL 0x1a
+#define MGA_XDATA_XGENCTRL 0x1d
+#define MGA_XDATA_XMISCCTRL 0x1e
+#define MGA_XDATA_XGENIOCTRL 0x2a
+#define MGA_XDATA_XGENIODATA 0x2b
+#define MGA_XDATA_XSYSPLLM 0x2c
+#define MGA_XDATA_XSYSPLLN 0x2d
+#define MGA_XDATA_XSYSPLLP 0x2e
+#define MGA_XDATA_XSYSPLLSTAT 0x2f
+#define MGA_XDATA_XZOOMCTRL 0x38
+#define MGA_XDATA_XSENSETEST 0x3a
+#define MGA_XDATA_XCRCREML 0x3c
+#define MGA_XDATA_XCRCREMH 0x3d
+#define MGA_XDATA_XCRCBITSEL 0x3e
+#define MGA_XDATA_XCOLMSK 0x40
+#define MGA_XDATA_XCOLKEY 0x42
+#define MGA_XDATA_XPIXPLLAM 0x44
+#define MGA_XDATA_XPIXPLLAN 0x45
+#define MGA_XDATA_XPIXPLLAP 0x46
+#define MGA_XDATA_XPIXPLLBM 0x48
+#define MGA_XDATA_XPIXPLLBN 0x49
+#define MGA_XDATA_XPIXPLLBP 0x4a
+#define MGA_XDATA_XPIXPLLCM 0x4c
+#define MGA_XDATA_XPIXPLLCN 0x4d
+#define MGA_XDATA_XPIXPLLCP 0x4e
+#define MGA_XDATA_XPIXPLLSTAT 0x4f
+#define MGA_XDATA_XKEYOPMODE 0x51
+#define MGA_XDATA_XCOLMSK0RED 0x52
+#define MGA_XDATA_XCOLMSK0GREEN 0x53
+#define MGA_XDATA_XCOLMSK0BLUE 0x54
+#define MGA_XDATA_XCOLKEY0RED 0x55
+#define MGA_XDATA_XCOLKEY0GREEN 0x56
+#define MGA_XDATA_XCOLKEY0BLUE 0x57
+#define MGA_XDATA_XCURCOL3RED 0x60
+#define MGA_XDATA_XCURCOL3GREEN 0x61
+#define MGA_XDATA_XCURCOL3BLUE 0x62
+#define MGA_XDATA_XCURCOL4RED 0x63
+#define MGA_XDATA_XCURCOL4GREEN 0x64
+#define MGA_XDATA_XCURCOL4BLUE 0x65
+#define MGA_XDATA_XCURCOL5RED 0x66
+#define MGA_XDATA_XCURCOL5GREEN 0x67
+#define MGA_XDATA_XCURCOL5BLUE 0x68
+#define MGA_XDATA_XCURCOL6RED 0x69
+#define MGA_XDATA_XCURCOL6GREEN 0x6a
+#define MGA_XDATA_XCURCOL6BLUE 0x6b
+#define MGA_XDATA_XCURCOL7RED 0x6c
+#define MGA_XDATA_XCURCOL7GREEN 0x6d
+#define MGA_XDATA_XCURCOL7BLUE 0x6e
+#define MGA_XDATA_XCURCOL8RED 0x6f
+#define MGA_XDATA_XCURCOL8GREEN 0x70
+#define MGA_XDATA_XCURCOL8BLUE 0x71
+#define MGA_XDATA_XCURCOL9RED 0x72
+#define MGA_XDATA_XCURCOL9GREEN 0x73
+#define MGA_XDATA_XCURCOL9BLUE 0x74
+#define MGA_XDATA_XCURCOL10RED 0x75
+#define MGA_XDATA_XCURCOL10GREEN 0x76
+#define MGA_XDATA_XCURCOL10BLUE 0x77
+#define MGA_XDATA_XCURCOL11RED 0x78
+#define MGA_XDATA_XCURCOL11GREEN 0x79
+#define MGA_XDATA_XCURCOL11BLUE 0x7a
+#define MGA_XDATA_XCURCOL12RED 0x7b
+#define MGA_XDATA_XCURCOL12GREEN 0x7c
+#define MGA_XDATA_XCURCOL12BLUE 0x7d
+#define MGA_XDATA_XCURCOL13RED 0x7e
+#define MGA_XDATA_XCURCOL13GREEN 0x7f
+#define MGA_XDATA_XCURCOL13BLUE 0x80
+#define MGA_XDATA_XCURCOL14RED 0x81
+#define MGA_XDATA_XCURCOL14GREEN 0x82
+#define MGA_XDATA_XCURCOL14BLUE 0x83
+#define MGA_XDATA_XCURCOL15RED 0x84
+#define MGA_XDATA_XCURCOL15GREEN 0x85
+#define MGA_XDATA_XCURCOL15BLUE 0x86
+
+ /* MGA I/O Registers */
+
+#define MGAIO_ATTR_DATA 0x03c1
+#define MGAIO_ATTR_INDEX 0x03c0
+#define MGAIO_MONO_CRTC_DATA 0x03b5
+#define MGAIO_MONO_CRTC_INDEX 0x03b4
+#define MGAIO_COLOR_CRTC_DATA 0x03d5
+#define MGAIO_COLOR_CRTC_INDEX 0x03d4
+#define MGAIO_CRTCEXT_DATA 0x03df
+#define MGAIO_CRTCEXT_INDEX 0x03de
+#define MGAIO_DAC_STATUS 0x03c7
+#define MGAIO_FEAT_READ 0x03ca
+#define MGAIO_MONO_FEAT_WRITE 0x03ba
+#define MGAIO_COLOR_FEAT_WRITE 0x03da
+#define MGAIO_GCTL_DATA 0x03cf
+#define MGAIO_GCTL_INDEX 0x03ce
+#define MGAIO_INPUT_STATUS0 0x03c2
+#define MGAIO_MONO_INPUT_STATUS1 0x03ba
+#define MGAIO_COLOR_INPUT_STATUS1 0x03da
+#define MGAIO_MISCOUT_READ 0x03cc
+#define MGAIO_MISCOUT_WRITE 0x03c2
+#define MGAIO_PALETTE_DATA 0x03c9
+#define MGAIO_PALETTE_READ_ADDRESS 0x03c7
+#define MGAIO_PALETTE_WRITE_ADDRESS 0x03c8
+#define MGAIO_PIXEL_READ_MASK 0x03c6
+#define MGAIO_SEQ_DATA 0x03c5
+#define MGAIO_SEQ_INDEX 0x03c4
+
+#define MGA_ATTR_INDEX 0x1fc0
+#define MGA_ATTR_DATA 0x1fc1
+#define MGA_CACHEFLUSH 0x1fff
+#define MGA_CRTC_INDEX 0x1fd4
+#define MGA_CRTC_DATA 0x1fd5
+#define MGA_CRTCEXT_DATA 0x1fdf
+#define MGA_CRTCEXT_INDEX 0x1fde
+#define MGA_CURPOSXL 0x3c0c
+#define MGA_CURPOSXH 0x3c0d
+#define MGA_CURPOSYL 0x3c0e
+#define MGA_CURPOSYH 0x3c0f
+#define MGA_DACSTATUS 0x1fc7
+#define MGA_FEAT_READ 0x1fca
+#define MGA_FEAT_WRITE 0x1fda
+#define MGA_GCTL_DATA 0x1fcf
+#define MGA_GCTL_INDEX 0x1fce
+#define MGA_INSTS0 0x1fc2
+#define MGA_INSTS1 0x1fda
+#define MGA_MISCOUT_READ 0x1fcc
+#define MGA_MISCOUT_WRITE 0x1fc2
+#define MGA_SEQ_DATA 0x1fc5
+#define MGA_SEQ_INDEX 0x1fc4
+#define MGA_PALDATA 0x3c01
+#define MGA_PALRDADD 0x3c03
+#define MGA_PALWTADD 0x3c00
+#define MGA_PIXRDMSK 0x3c02
+#define MGA_X_DATAREG 0x3c0a
+
+ /* MGA I/O Attribute Controller Index 0x03c0 */
+
+#define MGA_ATTR_PAS 0x20
+#define MGA_ATTR_INDEX_MASK 0x1f
+#define MGA_ATTR_INDEX_COUNT 0x20
+#define MGA_ATTR_PALETTE_ENTRY_0 0x00
+#define MGA_ATTR_PALETTE_ENTRY_1 0x01
+#define MGA_ATTR_PALETTE_ENTRY_2 0x02
+#define MGA_ATTR_PALETTE_ENTRY_3 0x03
+#define MGA_ATTR_PALETTE_ENTRY_4 0x04
+#define MGA_ATTR_PALETTE_ENTRY_5 0x05
+#define MGA_ATTR_PALETTE_ENTRY_6 0x06
+#define MGA_ATTR_PALETTE_ENTRY_7 0x07
+#define MGA_ATTR_PALETTE_ENTRY_8 0x08
+#define MGA_ATTR_PALETTE_ENTRY_9 0x09
+#define MGA_ATTR_PALETTE_ENTRY_A 0x0a
+#define MGA_ATTR_PALETTE_ENTRY_B 0x0b
+#define MGA_ATTR_PALETTE_ENTRY_C 0x0c
+#define MGA_ATTR_PALETTE_ENTRY_D 0x0d
+#define MGA_ATTR_PALETTE_ENTRY_E 0x0e
+#define MGA_ATTR_PALETTE_ENTRY_F 0x0f
+#define MGA_ATTR_MODE_CONTROL 0x10
+#define MGA_ATTR_OVERSCAN_COLOR 0x11
+#define MGA_ATTR_COLOR_PLANE_ENABLE 0x12
+#define MGA_ATTR_HORIZ_PEL_PANNING 0x13
+#define MGA_ATTR_COLOR_SELECT 0x14
+
+ /* MGA I/O ATTR00 - ATTR0F Attribute Palette */
+
+#define MGA_ATTR_PALET_DATA_MASK 0x3f
+
+ /* MGA I/O ATTR10 Attribute Mode Control */
+
+#define MGA_ATTR_MODE_CTRL_P5P4 0x80
+#define MGA_ATTR_MODE_CTRL_PELWIDTH 0x40
+#define MGA_ATTR_MODE_CTRL_PANCOMP 0x20
+#define MGA_ATTR_MODE_CTRL_BLINKEN 0x08
+#define MGA_ATTR_MODE_CTRL_LGREN 0x04
+#define MGA_ATTR_MODE_CTRL_MONO 0x02
+#define MGA_ATTR_MODE_CTRL_ATCGRMODE 0x01
+
+ /* MGA I/O ATTR11 Overscan Color */
+
+ /* MGA I/O ATTR12 Color Plane Enable */
+
+#define MGA_ATTR_COLOR_PLANE_VIDSTMX 0x30
+#define MGA_ATTR_COLOR_PLANE_VIDSTMX_SHIFT 4
+#define MGA_ATTR_COLOR_PLANE_COLPLEN 0x0f
+
+ /* MGA I/O ATTR13 Horizontal Pel Panning */
+
+#define MGA_ATTR_HORIZ_PEL_HPELCNT 0x0f
+
+ /* MGA I/O ATTR14 Color Select */
+
+#define MGA_ATTR_COLOR_SELECT_COLSEL76 0x0c
+#define MGA_ATTR_COLOR_SELECT_COLSEL76_SHIFT 2
+#define MGA_ATTR_COLOR_SELECT_COLSEL54 0x03
+
+ /* MGA I/O CRTC Registers 0x03[bd]4 */
+
+#define MGA_CRTC_INDEX_MASK 0x3f
+#define MGA_CRTC_INDEX_COUNT 0x40
+#define MGA_CRTC_HORIZ_TOTAL 0x00
+#define MGA_CRTC_HORIZ_DISPLAY_END 0x01
+#define MGA_CRTC_START_HORIZ_BLANK 0x02
+#define MGA_CRTC_END_HORIZ_BLANK 0x03
+#define MGA_CRTC_START_HORIZ_RETRACE 0x04
+#define MGA_CRTC_END_HORIZ_RETRACE 0x05
+#define MGA_CRTC_VERT_TOTAL 0x06
+#define MGA_CRTC_OVERFLOW 0x07
+#define MGA_CRTC_PRESET_ROW_SCAN 0x08
+#define MGA_CRTC_MAXIMUM_SCAN_LINE 0x09
+#define MGA_CRTC_CURSOR_START 0x0a
+#define MGA_CRTC_CURSOR_END 0x0b
+#define MGA_CRTC_START_ADDR_HIGH 0x0c
+#define MGA_CRTC_START_ADDR_LOW 0x0d
+#define MGA_CRTC_CURSOR_LOC_HIGH 0x0e
+#define MGA_CRTC_CURSOR_LOC_LOW 0x0f
+#define MGA_CRTC_VERT_RETRACE_START 0x10
+#define MGA_CRTC_VERT_RETRACE_END 0x11
+#define MGA_CRTC_VERT_DISPLAY_END 0x12
+#define MGA_CRTC_OFFSET 0x13
+#define MGA_CRTC_UNDERLINE_LOCATION 0x14
+#define MGA_CRTC_START_VERT_BLANK 0x15
+#define MGA_CRTC_END_VERT_BLANK 0x16
+#define MGA_CRTC_MODE_CONTROL 0x17
+#define MGA_CRTC_LINE_COMPARE 0x18
+#define MGA_CRTC_CPU_READ_LATCH 0x22
+#define MGA_CRTC_ATTR_SELECT 0x24
+#define MGA_CRTC_ATTR_ADDRESS 0x26
+
+ /* MGA I/O CRTC0 Horizontal Total */
+
+ /* MGA I/O CRTC1 Horizontal Display Enable End */
+
+ /* MGA I/O CRTC2 Start Horizontal Blanking */
+
+ /* MGA I/O CRTC3 End Horizontal Blanking */
+
+#define MGA_CRTC_END_HBLANK_COMPAT_READ 0x80
+#define MGA_CRTC_END_HBLANK_HDISPSKEW 0x60
+#define MGA_CRTC_END_HBLANK_HDISKSKEW_SHIFT 6
+#define MGA_CRTC_END_HBLANK_HBLKEND 0x1f
+
+ /* MGA I/I CRTC4 Start Horizontal Retrace Pulse */
+
+ /* MGA I/O CRTC5 End Horizontal Retrace */
+
+#define MGA_CRTC_END_HRETRACE_HBLKEND5 0x80
+#define MGA_CRTC_END_HRETRACE_HBLKEND5_SHIFT 7
+#define MGA_CRTC_END_HRETRACE_HSYNCDEL 0x60
+#define MGA_CRTC_END_HRETRACE_HSYNCDEL_SHIFT 4
+#define MGA_CRTC_END_HRETRACE_HSYNCEND 0x1f
+
+ /* MGA I/O CRTC6 Vertical Total */
+
+ /* MGA I/O CRTC7 Overflow */
+
+#define MGA_CRTC_OVERFLOW_VSYNCSTR9 0x80
+#define MGA_CRTC_OVERFLOW_VSYNCSTR9_SHIFT 7
+#define MGA_CRTC_OVERFLOW_VDISPEND9 0x40
+#define MGA_CRTC_OVERFLOW_VDISPEND9_SHIFT 6
+#define MGA_CRTC_OVERFLOW_VTOTAL9 0x20
+#define MGA_CRTC_OVERFLOW_VTOTAL9_SHIFT 5
+#define MGA_CRTC_OVERFLOW_LINECOMP8 0x10
+#define MGA_CRTC_OVERFLOW_LINECOMP8_SHIFT 4
+#define MGA_CRTC_OVERFLOW_VBLKSTR8 0x08
+#define MGA_CRTC_OVERFLOW_VBLKSTR8_SHIFT 3
+#define MGA_CRTC_OVERFLOW_VSYNCSTR8 0x04
+#define MGA_CRTC_OVERFLOW_VSYNCSTR8_SHIFT 2
+#define MGA_CRTC_OVERFLOW_VDISPEND8 0x02
+#define MGA_CRTC_OVERFLOW_VDISPEND8_SHIFT 1
+#define MGA_CRTC_OVERFLOW_VTOTAL8 0x01
+
+ /* MGA I/O CRTC8 Preset Row Scan */
+
+#define MGA_CRTC_PRESET_ROW_BYTEPAN 0x60
+#define MGA_CRTC_PRESET_ROW_BYTEPAN_SHIFT 5
+#define MGA_CRTC_PRESET_ROW_PROWSCAN 0x1f
+
+ /* MGA I/O CRTC9 Maximum Scan Line */
+
+#define MGA_CRTC_MAX_SCAN_LINE_CONV2T4 0x80
+#define MGA_CRTC_MAX_SCAN_LINE_LINECOMP9 0x40
+#define MGA_CRTC_MAX_SCAN_LINE_LINECOMP9_SHIFT 6
+#define MGA_CRTC_MAX_SCAN_LINE_VBLKSTR9 0x20
+#define MGA_CRTC_MAX_SCAN_LINE_VBLKSTR9_SHIFT 5
+#define MGA_CRTC_MAX_SCAN_LINE_MAXSCAN 0x1f
+
+ /* MGA I/O CRTCA Cursor Start */
+
+#define MGA_CRTC_CURSOR_START_CUROFF 0x20
+#define MGA_CRTC_CURSOR_START_CURROWSTR 0x1f
+
+ /* MGA I/O CRTCB Cursor End */
+
+#define MGA_CRTC_CURSOR_END_CURSKEW 0x60
+#define MGA_CRTC_CURSOR_END_CURSKEW_SHIFT 5
+#define MGA_CRTC_CURSOR_END_CURROWEND 0x1f
+
+ /* MGA I/O CRTCC Start Address High */
+
+ /* MGA I/O CRTCD Start Address Low */
+
+ /* MGA I/O CRTCE Cursor Location High */
+
+ /* MGA I/O CRTCF Cursor Location Low */
+
+ /* MGA I/O CRTC10 Vertical Retrace Start */
+
+ /* MGA I/O CRTC11 Vertical Retrace End */
+
+#define MGA_CRTC_VRETRACE_END_CRTCPROTECT 0x80
+#define MGA_CRTC_VRETRACE_END_SEL5RFS 0x40
+#define MGA_CRTC_VRETRACE_END_VINTEN 0x20
+#define MGA_CRTC_VRETRACE_END_VINTCLR 0x10
+#define MGA_CRTC_VRETRACE_END_VSYNCEND 0x0f
+
+ /* MGA I/O CRTC12 Vertical Display Enable End */
+
+ /* MGA I/O CRTC13 Offset */
+
+ /* MGA I/O CRTC14 Underline Location */
+
+#define MGA_CRTC_UNDER_LOC_DWORD 0x40
+#define MGA_CRTC_UNDER_LOC_COUNT4 0x20
+#define MGA_CRTC_UNDER_LOC_UNDROW 0x1f
+
+ /* MGA I/O CRTC15 Start Vertical Blank */
+
+ /* MGA I/O CRTC16 End Vertical Blank */
+
+ /* MGA I/O CRTC17 CRTC Mode Control */
+
+#define MGA_CRTC_MODE_CTRL_CRTCRSTN 0x80
+#define MGA_CRTC_MODE_CTRL_WBMODE 0x40
+#define MGA_CRTC_MODE_CTRL_ADDWRAP 0x20
+#define MGA_CRTC_MODE_CTRL_COUNT2 0x08
+#define MGA_CRTC_MODE_CTRL_HSYNCSEL 0x04
+#define MGA_CRTC_MODE_CTRL_SELROWCAN 0x02
+#define MGA_CRTC_MODE_CTRL_CMS 0x01
+
+ /* MGA I/O CRTC18 Line Compare */
+
+ /* MGA I/O CRTC22 Cpu Read Latch */
+
+ /* MGA I/O CRTC24 Attributes Address/Data Select */
+
+#define MGA_CRTC_ATTR_SELECT_ATTRADSEL 0x80
+
+ /* MGA I/O CRTC26 Attributes Address */
+
+#define MGA_CRTC_ATTR_ADDR_PAS 0x20
+#define MGA_CRTC_ATTR_ADDR_ATTRX 0x1f
+
+ /* MGA I/O CRTCEXT Registers 0x03de */
+
+#define MGA_CRTCEXT_INDEX_MASK 0x07
+#define MGA_CRTCEXT_INDEX_COUNT 0x08
+#define MGA_CRTCEXT_ADDR_GEN_EXT 0x00
+#define MGA_CRTCEXT_HOR_COUNT_EXT 0x01
+#define MGA_CRTCEXT_VERT_COUNT_EXT 0x02
+#define MGA_CRTCEXT_MISC 0x03
+#define MGA_CRTCEXT_MEM_PAGE 0x04
+#define MGA_CRTCEXT_HOR_VIDEO_HALF 0x05
+#define MGA_CRTCEXT_PRIORITY_REQ 0x06
+#define MGA_CRTCEXT_REQ_CONTROL 0x07
+
+ /* MGA I/O CRTCEXT0 Address Generator Extensions */
+
+#define MGA_CRTCEXT_ADDR_GEN_INTERLACE 0x80
+#define MGA_CRTCEXT_ADDR_GEN_STARTADD20 0x40
+#define MGA_CRTCEXT_ADDR_GEN_STARTADD20_SHIFT 6
+#define MGA_CRTCEXT_ADDR_GEN_OFFSET9 0x20
+#define MGA_CRTCEXT_ADDR_GEN_OFFSET8 0x10
+#define MGA_CRTCEXT_ADDR_GEN_OFFSET8_9 0x30
+#define MGA_CRTCEXT_ADDR_GEN_OFFSET8_9_SHIFT 4
+#define MGA_CRTCEXT_ADDR_GEN_STARTADD19 0x08
+#define MGA_CRTCEXT_ADDR_GEN_STARTADD18 0x04
+#define MGA_CRTCEXT_ADDR_GEN_STARTADD17 0x02
+#define MGA_CRTCEXT_ADDR_GEN_STARTADD16 0x01
+#define MGA_CRTCEXT_ADDR_GEN_STARTADD16_19 0x0f
+
+ /* MGA I/O CRTCEXT1 Horizontal Counter Extensions */
+
+#define MGA_CRTCEXT_HCOUNT_VRSTEN 0x80
+#define MGA_CRTCEXT_HCOUNT_HBLKEND6 0x40
+#define MGA_CRTCEXT_HCOUNT_HBLKEND6_SHIFT 6
+#define MGA_CRTCEXT_HCOUNT_VSYNCOFF 0x20
+#define MGA_CRTCEXT_HCOUNT_HSYNCOFF 0x10
+#define MGA_CRTCEXT_HCOUNT_HRSTEN 0x08
+#define MGA_CRTCEXT_HCOUNT_HSYNCSTR8 0x04
+#define MGA_CRTCEXT_HCOUNT_HSYNCSTR8_SHIFT 2
+#define MGA_CRTCEXT_HCOUNT_HBLKSTR8 0x02
+#define MGA_CRTCEXT_HCOUNT_HBLKSTR8_SHIFT 1
+#define MGA_CRTCEXT_HCOUNT_HTOTAL8 0x01
+
+ /* MGA I/O CRTCEXT2 Vertical Counter Extensions */
+
+#define MGA_CRTCEXT_VCOUNT_LINECOMP10 0x80
+#define MGA_CRTCEXT_VCOUNT_LINECOMP10_SHIFT 7
+#define MGA_CRTCEXT_VCOUNT_VSYNCSTR11 0x40
+#define MGA_CRTCEXT_VCOUNT_VSYNCSTR10 0x20
+#define MGA_CRTCEXT_VCOUNT_VSYNCSTR10_11 0x60
+#define MGA_CRTCEXT_VCOUNT_VSYNCSTR10_11_SHIFT 5
+#define MGA_CRTCEXT_VCOUNT_VBLKSTR11 0x10
+#define MGA_CRTCEXT_VCOUNT_VBLKSTR10 0x08
+#define MGA_CRTCEXT_VCOUNT_VBLKSTR10_11 0x18
+#define MGA_CRTCEXT_VCOUNT_VBLKSTR10_11_SHIFT 3
+#define MGA_CRTCEXT_VCOUNT_VDISPEND10 0x04
+#define MGA_CRTCEXT_VCOUNT_VDISPEND10_SHIFT 2
+#define MGA_CRTCEXT_VCOUNT_VTOTAL11 0x02
+#define MGA_CRTCEXT_VCOUNT_VTOTAL10 0x01
+#define MGA_CRTCEXT_VCOUNT_VTOTAL10_11 0x03
+
+ /* MGA I/O CRTCEXT3 Miscellaneous */
+
+#define MGA_CRTCEXT_MISC_MGAMODE 0x80
+#define MGA_CRTCEXT_MISC_CSYNCEN 0x40
+#define MGA_CRTCEXT_MISC_SLOW256 0x20
+#define MGA_CRTCEXT_MISC_SCALE_MASK 0x07
+#define MGA_CRTCEXT_MISC_SCALE_1 0x00
+#define MGA_CRTCEXT_MISC_SCALE_2 0x01
+#define MGA_CRTCEXT_MISC_SCALE_3 0x02
+#define MGA_CRTCEXT_MISC_SCALE_4 0x03
+#define MGA_CRTCEXT_MISC_SCALE_6 0x05
+#define MGA_CRTCEXT_MISC_SCALE_8 0x07
+
+ /* MGA I/O CRTCEXT4 Memory Page */
+
+ /* MGA I/O CRTCEXT5 Horizontal Video Half Count */
+
+ /* MGA I/O CRTCEXT6 Priority Request Control */
+
+#define MGA_CRTCEXT_PRI_REQ_MAXHIPRI 0x70
+#define MGA_CRTCEXT_PRI_REQ_MAXHIPRI_SHIFT 4
+#define MGA_CRTCEXT_PRI_REQ_MAXHIPRI_OFFSET 1
+#define MGA_CRTCEXT_PRI_REQ_HIPRILVL 0x07
+#define MGA_CRTCEXT_PRI_REQ_HIPRILVL_OFFSET 1
+
+ /* MGA I/O CRTCEXT7 Request Control */
+
+#define MGA_CRTCEXT_REQ_CTRL_MTXECOGENSTS1 0x80
+#define MGA_CRTCEXT_REQ_CTRL_MTXECOGENSTS2 0x40
+#define MGA_CRTCEXT_REQ_CTRL_CRTCBLK0 0x01
+
+ /* MGA I/O DAC Status 0x03c7 */
+
+#define MGA_DACSTAT_DSTS_MASK 0x03
+#define MGA_DACSTAT_DSTS_WRITE 0x00
+#define MGA_DACSTAT_DSTS_READ 0x03
+
+ /* MGA I/O Feature Control 0x03ca (read), 0x03[bd]a (write) */
+
+#define MGA_FEATCONT_FEATCB1 0x02
+#define MGA_FEATCONT_FEATCB0 0x01
+
+ /* MGA I/O Graphics Controller 0x03ce */
+
+#define MGA_GCTL_INDEX_MASK 0x0f
+#define MGA_GCTL_INDEX_COUNT 0x10
+#define MGA_GCTL_SET_RESET 0x00
+#define MGA_GCTL_ENABLE_SET_RESET 0x01
+#define MGA_GCTL_COLOR_COMPARE 0x02
+#define MGA_GCTL_DATA_ROTATE 0x03
+#define MGA_GCTL_READ_MAP_SELECT 0x04
+#define MGA_GCTL_GRAPHIC_MODE 0x05
+#define MGA_GCTL_MISCELLANEOUS 0x06
+#define MGA_GCTL_COLOR_DONT_CARE 0x07
+#define MGA_GCTL_BIT_MASK 0x08
+
+ /* MGA I/O GCTL0 Graphics Controller Set/Reset */
+
+#define MGA_GCTL_SET_RESET_SETRST 0x0f
+
+ /* MGA I/O GCTL1 Graphics Controller Enable Set/Reset */
+
+#define MGA_GCTL_ENABLE_SET_RESET_SETRSTEN 0x0f
+
+ /* MGA I/O GCTL2 Color Compare */
+
+#define MGA_GCTL_COLOR_COMPARE_REFCOL 0x0f
+
+ /* MGA I/O GCTL3 Data Rotate */
+
+#define MGA_GCTL_DATAROT_FUNSEL_MASK 0x18
+#define MGA_GCTL_DATAROT_FUNSEL_SOURCE 0x00
+#define MGA_GCTL_DATAROT_FUNSEL_AND 0x08
+#define MGA_GCTL_DATAROT_FUNSEL_OR 0x10
+#define MGA_GCTL_DATAROT_FUNSEL_XOR 0x18
+#define MGA_GCTL_DATAROT_ROT 0x07
+
+ /* MGA I/O GCTL4 Read Map Select */
+
+#define MGA_GCTL_READMAP_RDMAPSL 0x03
+
+ /* MGA I/O GCTL5 Graphics Mode */
+
+#define MGA_GCTL_GRMODE_MODE256 0x40
+#define MGA_GCTL_GRMODE_SRINTMD 0x20
+#define MGA_GCTL_GRMODE_GCODDEVMD 0x10
+#define MGA_GCTL_GRMODE_RDMODE 0x08
+#define MGA_GCTL_GRMODE_WRMODE_MASK 0x03
+#define MGA_GCTL_GRMODE_WRMODE_ROTATED 0x00
+#define MGA_GCTL_GRMODE_WRMODE_DIRECT 0x01
+#define MGA_GCTL_GRMODE_WRMODE_REPLICATED 0x02
+#define MGA_GCTL_GRMODE_WRMODE_EXPANDED 0x03
+
+ /* MGA I/O GCTRL6 Miscellaneous */
+
+#define MGA_GCTL_MISC_MEMMAPSL_MASK 0x0c
+#define MGA_GCTL_MISC_MEMMAPSL_A0000_BF000 0x00
+#define MGA_GCTL_MISC_MEMMAPSL_A0000_AF000 0x04
+#define MGA_GCTL_MISC_MEMMAPSL_B0000_B7000 0x08
+#define MGA_GCTL_MISC_MEMMAPSL_B8000_BF000 0x0c
+#define MGA_GCTL_MISC_CHAIN 0x02
+#define MGA_GCTL_MISC_GCGRMODE 0x01
+
+ /* MGA I/O GCTRL7 Color Don't Care */
+
+#define MGA_GCTL_COLDC_COLCOMPEN 0x0f
+
+ /* MGA I/O GCRTL8 Bit Mask */
+
+ /* MGA I/O Input Status 0 0x03c2 (Read) */
+
+#define MGA_INPSTAT0_CRTCINTCRT 0x80
+#define MGA_INPSTAT0_FEATIN0_1 0x60
+#define MGA_INPSTAT0_FEATIN1 0x40
+#define MGA_INPSTAT0_FEATIN0 0x20
+#define MGA_INPSTAT0_SWITCHSNS 0x10
+
+ /* MGA I/O Input Status 1 0x03[bd]a */
+
+#define MGA_INPSTAT1_DIAG_MASK 0x30
+#define MGA_INPSTAT1_VRETRACE 0x08
+#define MGA_INPSTAT1_HRETRACE 0x01
+
+ /* MGA I/O Miscellaneous Output 0x03c2 (Write), 0x03cc (Read) */
+
+#define MGA_MISCOUT_VSYNCPOL 0x80
+#define MGA_MISCOUT_HSYNCPOL 0x40
+#define MGA_MISCOUT_HPGODDEV 0x20
+#define MGA_MISCOUT_CLKSEL_MASK 0x0c
+#define MGA_MISCOUT_CLKSEL_25MHZ 0x00
+#define MGA_MISCOUT_CLKSEL_28MHZ 0x04
+#define MGA_MISCOUT_CLKSEL_MGAPIXEL0 0x08
+#define MGA_MISCOUT_CLKSEL_MGAPIXEL1 0x0c
+#define MGA_MISCOUT_RAMMAPEN 0x02
+#define MGA_MISCOUT_IOADDSEL 0x01
+
+ /* MGA I/O Sequencer Registers 0x03c4 */
+
+#define MGA_SEQ_INDEX_MASK 0x07
+#define MGA_SEQ_INDEX_COUNT 0x08
+#define MGA_SEQ_RESET 0x00
+#define MGA_SEQ_CLOCKING_MODE 0x01
+#define MGA_SEQ_MAP_MASK 0x02
+#define MGA_SEQ_CHARACTER_MAP_SELECT 0x03
+#define MGA_SEQ_MEMORY_MODE 0x04
+
+ /* MGA I/O SEQ0 Reset */
+
+#define MGA_SEQ_RESET_SYNCRST 0x02
+#define MGA_SEQ_RESET_ASYNCRST 0x01
+
+ /* MGA I/O SEQ1 Clocking Mode */
+
+#define MGA_SEQ_CLOCK_MODE_SCROFF 0x20
+#define MGA_SEQ_CLOCK_MODE_SHIFTFOUR 0x10
+#define MGA_SEQ_CLOCK_MODE_DOTCLKRT 0x08
+#define MGA_SEQ_CLOCK_MODE_SHFTLDRT 0x04
+#define MGA_SEQ_CLOCK_MODE_DOTMODE 0x01
+
+ /* MGA I/O SEQ2 Map Mask */
+
+#define MGA_SEQ_MAP_MASK_PLWREN 0x0f
+
+ /* MGA I/O SEQ3 Character Map Select */
+
+#define MGA_SEQ_CHARMAP_MAPASEL2 0x20
+#define MGA_SEQ_CHARMAP_MAPASEL2_SHIFT 5
+#define MGA_SEQ_CHARMAP_MAPBSEL2 0x10
+#define MGA_SEQ_CHARMAP_MAPBSEL2_SHIFT 4
+#define MGA_SEQ_CHARMAP_MAPASEL0_1 0x0c
+#define MGA_SEQ_CHARMAP_MAPASEL0_1_SHIFT 2
+#define MGA_SEQ_CHARMAP_MAPBSEL0_1 0x03
+
+ /* MGA I/O SEQ4 Memory Mode */
+
+#define MGA_SEQ_MEMMODE_CHAIN4 0x08
+#define MGA_SEQ_MEMMODE_SEQODDEVMD 0x04
+#define MGA_SEQ_MEMMODE_MEMSZ256 0x02
+
+ /* MGA DAC Color Key 0x42 */
+
+ /* MGA DAC Color Key 0 r/g/b 0x55, 0x56, 0x57 */
+
+ /* MGA DAC Color Key Mask 0x40 */
+
+ /* MGA DAC Color Mask 0 r/g/b 0x52, 0x53, 0x54 */
+
+ /* MGA DAC CRC Bit Select 0x3e */
+
+#define MGA_XCRCBITSEL_CRCSEL_MASK 0x1f
+#define MGA_XCRCBITSEL_BLUE_BASE 0x00
+#define MGA_XCRCBITSEL_GREEN_BASE 0x08
+#define MGA_XCRCBITSEL_RED_BASE 0x10
+
+ /* MGA DAC CRC Remainder High 0x3d */
+
+ /* MGA DAC CRC Remainder Low 0x3c */
+
+ /* MGA DAC Cursor Base Address High 0x05 */
+
+#define MGA_XCURADDH_MASK 0x3f
+
+ /* MGA DAC Cursor Base Address Low 0x04 */
+
+#define MGA_XCURADDR_SHIFT 10
+
+ /* MGA DAC Cursor Color 0 r/g/b 0x08, 0x09, 0x0a */
+ /* MGA DAC Cursor Color 1 r/g/b 0x0c, 0x0d, 0x0e */
+ /* MGA DAC Cursor Color 2 r/g/b 0x10, 0x11, 0x12 */
+ /* MGA DAC Cursor Color 3 r/g/b 0x60, 0x61, 0x62 */
+ /* MGA DAC Cursor Color 4 r/g/b 0x63, 0x64, 0x65 */
+ /* MGA DAC Cursor Color 5 r/g/b 0x66, 0x67, 0x68 */
+ /* MGA DAC Cursor Color 6 r/g/b 0x69, 0x6a, 0x6b */
+ /* MGA DAC Cursor Color 7 r/g/b 0x6c, 0x6d, 0x6e */
+ /* MGA DAC Cursor Color 8 r/g/b 0x6f, 0x70, 0x71 */
+ /* MGA DAC Cursor Color 9 r/g/b 0x72, 0x73, 0x74 */
+ /* MGA DAC Cursor Color 10 r/g/b 0x75, 0x76, 0x77 */
+ /* MGA DAC Cursor Color 11 r/g/b 0x78, 0x79, 0x7a */
+ /* MGA DAC Cursor Color 12 r/g/b 0x7b, 0x7c, 0x7d */
+ /* MGA DAC Cursor Color 13 r/g/b 0x7e, 0x7f, 0x80 */
+ /* MGA DAC Cursor Color 14 r/g/b 0x81, 0x82, 0x83 */
+ /* MGA DAC Cursor Color 15 r/g/b 0x84, 0x85, 0x86 */
+
+ /* MGA DAC Cursor Control 0x06 */
+
+#define MGA_XCURCTRL_CURMODE_MASK 0x07
+#define MGA_XCURCTRL_CURMODE_DISABLED 0x00
+#define MGA_XCURCTRL_CURMODE_THREE_COLOR 0x01
+#define MGA_XCURCTRL_CURMODE_XGA 0x02
+#define MGA_XCURCTRL_CURMODE_XWINDOWS 0x03
+#define MGA_XCURCTRL_CURMODE_PALETTIZED 0x04
+
+ /* MGA DAC General Control 0x1d */
+
+#define MGA_XGENCTRL_IOGSYNCDIS 0x20
+#define MGA_XGENCTRL_PEDON 0x10
+#define MGA_XGENCTRL_ALPHAEN 0x02
+
+ /* MGA DAC General Purpose I/O Control 0x2a */
+
+#define MGA_XGENIOCTRL_MISCOE_MASK 0x70
+#define MGA_XGENIOCTRL_MISCOE_SHIFT 4
+#define MGA_XGENIOCTRL_DDCOE_MASK 0x0f
+
+ /* MGA DAC General Purpose I/O Data 0x2b */
+
+#define MGA_XGENIODATA_MISCDATA_MASK 0x70
+#define MGA_XGENIODATA_MISCDATA_SHIFT 4
+#define MGA_XGENIODATA_DDCDATA_MASK 0x0f
+
+ /* MGA DAC Keying Operating Mode 0x51 */
+
+#define MGA_XKEYOPMODE_COLKEYEN0 0x01
+
+ /* MGA DAC Miscellaneous Control 0x1e */
+
+#define MGA_XMISCCTRL_VDOUTSEL_MASK 0x60
+#define MGA_XMISCCTRL_VDOUTSEL_PIXEL 0x00
+#define MGA_XMISCCTRL_VDOUTSEL_BYTE 0x40
+#define MGA_XMISCCTRL_RAMCS 0x10
+#define MGA_XMISCCTRL_VGA8DAC 0x08
+#define MGA_XMISCCTRL_MFCSEL_MASK 0x06
+#define MGA_XMISCCTRL_MFCSEL_MAFC 0x02
+#define MGA_XMISCCTRL_MFCSEL_PANEL_LINK 0x04
+#define MGA_XMISCCTRL_MFCSEL_DISABLE 0x06
+#define MGA_XMISCCTRL_DACPDN 0x01
+
+ /* MGA DAC Multiplex Control 0x19 */
+
+#define MGA_XMULCTRL_DEPTH_MASK 0x07
+#define MGA_XMULCTRL_DEPTH_8BPP 0x00
+#define MGA_XMULCTRL_DEPTH_15BPP_1BPP_OVERLAY 0x01
+#define MGA_XMULCTRL_DEPTH_16BPP 0x02
+#define MGA_XMULCTRL_DEPTH_24BPP 0x03
+#define MGA_XMULCTRL_DEPTH_32BPP_8BPP_OVERLAY 0x04
+#define MGA_XMULCTRL_DEPTH_32BPP_8BPP_UNUSED 0x07
+
+ /* MGA DAC Pixel Clock Control 0x1a */
+
+#define MGA_XPIXCLKCTRL_VGAPLLAUTOKILLDJ 0x80
+#define MGA_XPIXCLKCTRL_PIX_STBY 0x08
+#define MGA_XPIXCLKCTRL_PIXCLKDIS 0x04
+#define MGA_XPIXCLKCTRL_PIXCLKSL_MASK 0x03
+#define MGA_XPIXCLKCTRL_PIXCLKSL_PCI 0x00
+#define MGA_XPIXCLKCTRL_PIXCLKSL_PIXEL 0x01
+#define MGA_XPIXCLKCTRL_PIXCLKSL_EXTERNAL 0x02
+
+ /* MGA DAC Pixel PLL M Value 0x44, 0x48, 0x4c */
+
+#define MGA_XPIXPLLM_MASK 0x1f
+#define MGA_XPIXPLLM_MIN 1
+#define MGA_XPIXPLLM_MAX 31
+
+ /* MGA Dac Pixel PLL N Value 0x45, 0x49, 0x4d */
+
+#define MGA_XPIXPLLN_MIN_G200 1
+#define MGA_XPIXPLLN_MAX_G200 127
+#define MGA_XPIXPLLN_MIN_G200E 16
+#define MGA_XPIXPLLN_MAX_G200E 255
+
+ /* MGA DAC Pixel PLL P Value 0x46, 0x4a, 0x4e */
+
+#define MGA_XPIXPLLP_PIXPLLP_MASK 0x07
+#define MGA_XPIXPLLP_PIXPLLP_DIV1 0x00
+#define MGA_XPIXPLLP_PIXPLLP_DIV2 0x01
+#define MGA_XPIXPLLP_PIXPLLP_DIV4 0x03
+#define MGA_XPIXPLLP_PIXPLLP_DIV8 0x07
+#define MGA_XPIXPLLP_PIXPLLS_MASK 0x18
+#define MGA_XPIXPLLP_PIXPLLS_50MHZ_100MHZ 0x00
+#define MGA_XPIXPLLP_PIXPLLS_100MHZ_140MHZ 0x08
+#define MGA_XPIXPLLP_PIXPLLS_140MHZ_180MHZ 0x10
+#define MGA_XPIXPLLP_PIXPLLS_180MHZ_250MHZ 0x18
+#define MGA_XPIXPLLP_MIN_VCO 50000000
+#define MGA_XPIXPLLP_MIN_VCO_G200E 1000000
+#define MGA_XPIXPLLP_S0_MIN_VCO 50000000
+#define MGA_XPIXPLLP_S0_MAX_VCO 100000000
+#define MGA_XPIXPLLP_S1_MIN_VCO 100000000
+#define MGA_XPIXPLLP_S1_MAX_VCO 140000000
+#define MGA_XPIXPLLP_S2_MIN_VCO 140000000
+#define MGA_XPIXPLLP_S2_MAX_VCO 180000000
+#define MGA_XPIXPLLP_S3_MIN_VCO 180000000
+#define MGA_XPIXPLLP_S3_MAX_VCO 250000000
+#define MGA_XPIXPLLP_MAX_VCO 250000000
+#define MGA_XPIXPLLPA_REFCLK 25172000
+#define MGA_XPIXPLLPB_REFCLK 28361000
+#define MGA_XPIXPLLPC_REFCLK_G200 14318000
+#define MGA_XPIXPLLPC_REFCLK_G200E 25000000
+
+ /* MGA DAC Pixel PLL Status 0x4f (ro) */
+
+#define MGA_XPIXPLLSTAT_PIXLOCK 0x40
+
+ /* MGA DAC Sense Test 0x3a */
+
+#define MGA_XSENSETEST_SENSEPDN 0x80
+#define MGA_XSENSETEST_RCOMP 0x04
+#define MGA_XSENSETEST_GCOMP 0x02
+#define MGA_XSENSETEST_BCOMP 0x01
+
+ /* MGA DAC SYSPLL M Value 0x2c */
+
+#define MGA_XSYSPLLM_MASK 0x1f
+#define MGA_XSYSPLLM_MIN 1
+#define MGA_XSYSPLLM_MAX 31
+
+ /* MGA DAC SYSPLL N Value 0x2d */
+
+#define MGA_XSYSPLLN_MIN_G200 1
+#define MGA_XSYSPLLN_MAX_G200 127
+#define MGA_XSYSPLLN_MIN_G200E 16
+#define MGA_XSYSPLLN_MAX_G200E 255
+
+ /* MGA DAC SYSPLL P Value 0x2e */
+
+#define MGA_XSYSPLLP_SYSPLLS_MASK 0x18
+#define MGA_XSYSPLLP_SYSPLLS_50MHZ_100MHZ 0x00
+#define MGA_XSYSPLLP_SYSPLLS_100MHZ_140MHZ 0x08
+#define MGA_XSYSPLLP_SYSPLLS_140MHZ_180MHZ 0x10
+#define MGA_XSYSPLLP_SYSPLLS_180MHZ_250MHZ 0x18
+#define MGA_XSYSPLLP_SYSPLLP_MASK 0x07
+#define MGA_XSYSPLLP_SYSPLLP_DIV1 0x00
+#define MGA_XSYSPLLP_SYSPLLP_DIV2 0x01
+#define MGA_XSYSPLLP_SYSPLLP_DIV4 0x03
+#define MGA_XSYSPLLP_SYSPLLP_DIV8 0x07
+#define MGA_XSYSPLLP_MIN_VCO 50000
+#define MGA_XSYSPLLP_MIN_VCO_G200E 1000
+#define MGA_XSYSPLLP_S0_MIN_VCO 50000000
+#define MGA_XSYSPLLP_S0_MAX_VCO 100000000
+#define MGA_XSYSPLLP_S1_MIN_VCO 100000000
+#define MGA_XSYSPLLP_S1_MAX_VCO 140000000
+#define MGA_XSYSPLLP_S2_MIN_VCO 140000000
+#define MGA_XSYSPLLP_S2_MAX_VCO 180000000
+#define MGA_XSYSPLLP_S3_MIN_VCO 180000000
+#define MGA_XSYSPLLP_S3_MAX_VCO 250000000
+#define MGA_XSYSPLLP_MAX_VCO 250000000
+#define MGA_XSYSPLLP_REFCLK_G200 14318000
+#define MGA_XSYSPLLP_REFCLK_G200E 14318000
+
+ /* MGA DAC SYSPLL Status 0x2f (ro) */
+
+#define MGA_XSYSPLLSTAT_SYSLOCK 0x40
+
+ /* MGA DAC Voltage Reference Control 0x18 */
+
+#define MGA_XVREFCTRL_DACBGEN 0x20
+#define MGA_XVREFCTRL_DACBGPDN 0x10
+#define MGA_XVREFCTRL_PIXPLLBGEN 0x08
+#define MGA_XVREFCTRL_PIXPLLBGPDN 0x04
+#define MGA_XVREFCTRL_SYSPLLBGEN 0x02
+#define MGA_XVREFCTRL_SYSPLLBGPDN 0x01
+
+ /* MGA Dac Zoom Control 0x38 */
+
+#define MGA_XZOOMCTRL_HZOOM_MASK 0x03
+#define MGA_XZOOMCTRL_HZOOM_1X 0x00
+#define MGA_XZOOMCTRL_HZOOM_2X 0x01
+#define MGA_XZOOMCTRL_HZOOM_4X 0x03
+
+ /* MGA Indexes */
+
+#define MGAINDEX_DWGCTL 0x00
+#define MGAINDEX_MACCESS 0x01
+#define MGAINDEX_MCTLWTST 0x02
+#define MGAINDEX_ZORG 0x03
+#define MGAINDEX_PAT0 0x04
+#define MGAINDEX_PAT1 0x05
+#define MGAINDEX_PLNWT 0x07
+#define MGAINDEX_BCOL 0x08
+#define MGAINDEX_FCOL 0x09
+#define MGAINDEX_SRC0 0x0c
+#define MGAINDEX_SRC1 0x0d
+#define MGAINDEX_SRC2 0x0e
+#define MGAINDEX_SRC3 0x0f
+#define MGAINDEX_XYSTRT 0x10
+#define MGAINDEX_XYEND 0x11
+#define MGAINDEX_SHIFT 0x14
+#define MGAINDEX_DMAPAD 0x15
+#define MGAINDEX_SGN 0x16
+#define MGAINDEX_LEN 0x17
+#define MGAINDEX_AR0 0x18
+#define MGAINDEX_AR1 0x19
+#define MGAINDEX_AR2 0x1a
+#define MGAINDEX_AR3 0x1b
+#define MGAINDEX_AR4 0x1c
+#define MGAINDEX_AR5 0x1d
+#define MGAINDEX_AR6 0x1e
+#define MGAINDEX_CXBNDRY 0x20
+#define MGAINDEX_FXBNDRY 0x21
+#define MGAINDEX_YDSTLEN 0x22
+#define MGAINDEX_PITCH 0x23
+#define MGAINDEX_YDST 0x24
+#define MGAINDEX_YDSTORG 0x25
+#define MGAINDEX_YTOP 0x26
+#define MGAINDEX_YBOT 0x27
+#define MGAINDEX_CXLEFT 0x28
+#define MGAINDEX_CXRIGHT 0x29
+#define MGAINDEX_FXLEFT 0x2a
+#define MGAINDEX_FXRIGHT 0x2b
+#define MGAINDEX_XDST 0x2c
+#define MGAINDEX_DR0 0x30
+#define MGAINDEX_FOGSTART 0x31
+#define MGAINDEX_DR2 0x32
+#define MGAINDEX_DR3 0x33
+#define MGAINDEX_DR4 0x34
+#define MGAINDEX_FOGXINC 0x35
+#define MGAINDEX_DR6 0x36
+#define MGAINDEX_DR7 0x37
+#define MGAINDEX_DR8 0x38
+#define MGAINDEX_FOGYINC 0x39
+#define MGAINDEX_DR10 0x3a
+#define MGAINDEX_DR11 0x3b
+#define MGAINDEX_DR12 0x3c
+#define MGAINDEX_FOGCOL 0x3d
+#define MGAINDEX_DR14 0x3e
+#define MGAINDEX_DR15 0x3f
+#define MGAINDEX_DRAW_DWGCTL 0x40
+#define MGAINDEX_DRAW_MACCESS 0x41
+#define MGAINDEX_DRAW_MCTLWTST 0x42
+#define MGAINDEX_DRAW_ZORG 0x43
+#define MGAINDEX_DRAW_PAT0 0x44
+#define MGAINDEX_DRAW_PAT1 0x45
+#define MGAINDEX_DRAW_PLNWT 0x47
+#define MGAINDEX_DRAW_BCOL 0x48
+#define MGAINDEX_DRAW_FCOL 0x49
+#define MGAINDEX_DRAW_SRC0 0x4c
+#define MGAINDEX_DRAW_SRC1 0x4d
+#define MGAINDEX_DRAW_SRC2 0x4e
+#define MGAINDEX_DRAW_SRC3 0x4f
+#define MGAINDEX_DRAW_XYSTRT 0x50
+#define MGAINDEX_DRAW_XYEND 0x51
+#define MGAINDEX_DRAW_SHIFT 0x54
+#define MGAINDEX_DRAW_DMAPAD 0x55
+#define MGAINDEX_DRAW_SGN 0x56
+#define MGAINDEX_DRAW_LEN 0x57
+#define MGAINDEX_DRAW_AR0 0x58
+#define MGAINDEX_DRAW_AR1 0x59
+#define MGAINDEX_DRAW_AR2 0x5a
+#define MGAINDEX_DRAW_AR3 0x5b
+#define MGAINDEX_DRAW_AR4 0x5c
+#define MGAINDEX_DRAW_AR5 0x5d
+#define MGAINDEX_DRAW_AR6 0x5e
+#define MGAINDEX_DRAW_CXBNDRY 0x60
+#define MGAINDEX_DRAW_FXBNDRY 0x61
+#define MGAINDEX_DRAW_YDSTLEN 0x62
+#define MGAINDEX_DRAW_PITCH 0x63
+#define MGAINDEX_DRAW_YDST 0x64
+#define MGAINDEX_DRAW_YDSTORG 0x65
+#define MGAINDEX_DRAW_YTOP 0x66
+#define MGAINDEX_DRAW_YBOT 0x67
+#define MGAINDEX_DRAW_CXLEFT 0x68
+#define MGAINDEX_DRAW_CXRIGHT 0x69
+#define MGAINDEX_DRAW_FXLEFT 0x6a
+#define MGAINDEX_DRAW_FXRIGHT 0x6b
+#define MGAINDEX_DRAW_XDST 0x6c
+#define MGAINDEX_WIADDR 0x70
+#define MGAINDEX_WFLAG 0x71
+#define MGAINDEX_WGETMSB 0x72
+#define MGAINDEX_WVRTXSZ 0x73
+#define MGAINDEX_TMR0 0x80
+#define MGAINDEX_TMR1 0x81
+#define MGAINDEX_TMR2 0x82
+#define MGAINDEX_TMR3 0x83
+#define MGAINDEX_TMR4 0x84
+#define MGAINDEX_TMR5 0x85
+#define MGAINDEX_TMR6 0x86
+#define MGAINDEX_TMR7 0x87
+#define MGAINDEX_TMR8 0x88
+#define MGAINDEX_TEXORG 0x89
+#define MGAINDEX_TEXWIDTH 0x8a
+#define MGAINDEX_TEXHEIGHT 0x8b
+#define MGAINDEX_TEXCTL 0x8c
+#define MGAINDEX_TEXTRANS 0x8d
+#define MGAINDEX_TEXTRANSHIGH 0x8e
+#define MGAINDEX_TEXCTL2 0x8f
+#define MGAINDEX_SECADDRESS 0x90
+#define MGAINDEX_SECEND 0x91
+#define MGAINDEX_SOFTRAP 0x92
+#define MGAINDEX_DWGSYNC 0x93
+#define MGAINDEX_DR0_Z32_LSB 0x94
+#define MGAINDEX_DR0_Z32_MSB 0x95
+#define MGAINDEX_TEXFILTER 0x96
+#define MGAINDEX_TEXBORDERCOL 0x97
+#define MGAINDEX_DR2_Z32_LSB 0x98
+#define MGAINDEX_DR2_Z32_MSB 0x99
+#define MGAINDEX_DR3_Z32_LSB 0x9a
+#define MGAINDEX_DR3_Z32_MSB 0x9b
+#define MGAINDEX_ALPHASTART 0x9c
+#define MGAINDEX_ALPHAXINC 0x9d
+#define MGAINDEX_ALPHAYINC 0x9e
+#define MGAINDEX_ALPHACTRL 0x9f
+#define MGAINDEX_SPECRSTART 0xa0
+#define MGAINDEX_SPECRXINC 0xa1
+#define MGAINDEX_SPECRYINC 0xa2
+#define MGAINDEX_SPECGSTART 0xa3
+#define MGAINDEX_SPECGXINC 0xa4
+#define MGAINDEX_SPECGYINC 0xa5
+#define MGAINDEX_SPECBSTART 0xa6
+#define MGAINDEX_SPECBXINC 0xa7
+#define MGAINDEX_SPECBYINC 0xa8
+#define MGAINDEX_TEXORG1 0xa9
+#define MGAINDEX_TEXORG2 0xaa
+#define MGAINDEX_TEXORG3 0xab
+#define MGAINDEX_TEXORG4 0xac
+#define MGAINDEX_SRCORG 0xad
+#define MGAINDEX_DSTORG 0xae
+#define MGAINDEX_SETUPADDRESS 0xb4
+#define MGAINDEX_SETUPEND 0xb5
+#define MGAINDEX_WR 0xc0
+
+typedef struct mga_struct {
+ uint8_t mga_dmawin[0x1c00]; /* 0x0000 */
+ uint32_t mga_dwgctl; /* 0x1c00 */
+ uint32_t mga_maccess; /* 0x1c04 */
+ uint32_t mga_mctlwtst; /* 0x1c08 */
+ uint32_t mga_zorg; /* 0x1c0c */
+ uint32_t mga_pat0; /* 0x1c10 */
+ uint32_t mga_pat1; /* 0x1c14 */
+ uint32_t mga_reserved_0x1c18; /* 0x1c18 */
+ uint32_t mga_plnwt; /* 0x1c1c */
+ uint32_t mga_bcol; /* 0x1c20 */
+ uint32_t mga_fcol; /* 0x1c24 */
+ uint32_t mga_reserved_0x1c28; /* 0x1c28 */
+ uint32_t mga_reserved_0x1c2c; /* 0x1c2c */
+ uint32_t mga_src0; /* 0x1c30 */
+ uint32_t mga_src1; /* 0x1c34 */
+ uint32_t mga_src2; /* 0x1c38 */
+ uint32_t mga_src3; /* 0x1c3c */
+ uint32_t mga_xystrt; /* 0x1c40 */
+ uint32_t mga_xyend; /* 0x1c44 */
+ uint32_t mga_reserved_0x1c48; /* 0x1c48 */
+ uint32_t mga_reserved_0x1c4c; /* 0x1c4c */
+ uint32_t mga_shift; /* 0x1c50 */
+ uint32_t mga_dmapad; /* 0x1c54 */
+ uint32_t mga_sgn; /* 0x1c58 */
+ uint32_t mga_len; /* 0x1c5c */
+ uint32_t mga_ar0; /* 0x1c60 */
+ uint32_t mga_ar1; /* 0x1c64 */
+ uint32_t mga_ar2; /* 0x1c68 */
+ uint32_t mga_ar3; /* 0x1c6c */
+ uint32_t mga_ar4; /* 0x1c70 */
+ uint32_t mga_ar5; /* 0x1c74 */
+ uint32_t mga_ar6; /* 0x1c78 */
+ uint32_t mga_reserved_0x1c7c; /* 0x1c7c */
+ uint32_t mga_cxbndry; /* 0x1c80 */
+ uint32_t mga_fxbndry; /* 0x1c84 */
+ uint32_t mga_ydstlen; /* 0x1c88 */
+ uint32_t mga_pitch; /* 0x1c8c */
+ uint32_t mga_ydst; /* 0x1c90 */
+ uint32_t mga_ydstorg; /* 0x1c94 */
+ uint32_t mga_ytop; /* 0x1c98 */
+ uint32_t mga_ybot; /* 0x1c9c */
+ uint32_t mga_cxleft; /* 0x1ca0 */
+ uint32_t mga_cxright; /* 0x1ca4 */
+ uint32_t mga_fxleft; /* 0x1ca8 */
+ uint32_t mga_fxright; /* 0x1cac */
+ uint32_t mga_xdst; /* 0x1cb0 */
+ uint32_t mga_reserved_0x1cb4; /* 0x1cb4 */
+ uint32_t mga_reserved_0x1cb8; /* 0x1cb8 */
+ uint32_t mga_reserved_0x1cbc; /* 0x1cbc */
+ uint32_t mga_dr0; /* 0x1cc0 */
+ uint32_t mga_fogstart; /* 0x1cc4 */
+ uint32_t mga_dr2; /* 0x1cc8 */
+ uint32_t mga_dr3; /* 0x1ccc */
+ uint32_t mga_dr4; /* 0x1cd0 */
+ uint32_t mga_fogxinc; /* 0x1cd4 */
+ uint32_t mga_dr6; /* 0x1cd8 */
+ uint32_t mga_dr7; /* 0x1cdc */
+ uint32_t mga_dr8; /* 0x1ce0 */
+ uint32_t mga_fogyinc; /* 0x1ce4 */
+ uint32_t mga_dr10; /* 0x1ce8 */
+ uint32_t mga_dr11; /* 0x1cec */
+ uint32_t mga_dr12; /* 0x1cf0 */
+ uint32_t mga_fogcol; /* 0x1cf4 */
+ uint32_t mga_dr14; /* 0x1cf8 */
+ uint32_t mga_dr15; /* 0x1cfc */
+ uint32_t mga_draw_dwgctl; /* 0x1d00 */
+ uint32_t mga_draw_maccess; /* 0x1d04 */
+ uint32_t mga_reserved_0x1d08; /* 0x1d08 */
+ uint32_t mga_draw_zorg; /* 0x1d0c */
+ uint32_t mga_draw_pat0; /* 0x1d10 */
+ uint32_t mga_draw_pat1; /* 0x1d14 */
+ uint32_t mga_reserved_0x1d18; /* 0x1d18 */
+ uint32_t mga_draw_plnwt; /* 0x1d1c */
+ uint32_t mga_draw_bcol; /* 0x1d20 */
+ uint32_t mga_draw_fcol; /* 0x1d24 */
+ uint32_t mga_reserved_0x1d28; /* 0x1d28 */
+ uint32_t mga_reserved_0x1d2c; /* 0x1d2c */
+ uint32_t mga_draw_src0; /* 0x1d30 */
+ uint32_t mga_draw_src1; /* 0x1d34 */
+ uint32_t mga_draw_src2; /* 0x1d38 */
+ uint32_t mga_draw_src3; /* 0x1d3c */
+ uint32_t mga_draw_xystrt; /* 0x1d40 */
+ uint32_t mga_draw_xyend; /* 0x1d44 */
+ uint32_t mga_reserved_0x1d48; /* 0x1d48 */
+ uint32_t mga_reserved_0x1d4c; /* 0x1d4c */
+ uint32_t mga_draw_shift; /* 0x1d50 */
+ uint32_t mga_draw_dmapad; /* 0x1d54 */
+ uint32_t mga_draw_sgn; /* 0x1d58 */
+ uint32_t mga_draw_len; /* 0x1d5c */
+ uint32_t mga_draw_ar0; /* 0x1d60 */
+ uint32_t mga_draw_ar1; /* 0x1d64 */
+ uint32_t mga_draw_ar2; /* 0x1d68 */
+ uint32_t mga_draw_ar3; /* 0x1d6c */
+ uint32_t mga_draw_ar4; /* 0x1d70 */
+ uint32_t mga_draw_ar5; /* 0x1d74 */
+ uint32_t mga_draw_ar6; /* 0x1d78 */
+ uint32_t mga_reserved_0x1d7c; /* 0x1d7c */
+ uint32_t mga_draw_cxbndry; /* 0x1d80 */
+ uint32_t mga_draw_fxbndry; /* 0x1d84 */
+ uint32_t mga_draw_ydstlen; /* 0x1d88 */
+ uint32_t mga_draw_pitch; /* 0x1d8c */
+ uint32_t mga_draw_ydst; /* 0x1d90 */
+ uint32_t mga_draw_ydstorg; /* 0x1d94 */
+ uint32_t mga_draw_ytop; /* 0x1d98 */
+ uint32_t mga_draw_ybot; /* 0x1d9c */
+ uint32_t mga_draw_cxleft; /* 0x1da0 */
+ uint32_t mga_draw_cxright; /* 0x1da4 */
+ uint32_t mga_draw_fxleft; /* 0x1da8 */
+ uint32_t mga_draw_fxright; /* 0x1dac */
+ uint32_t mga_draw_xdst; /* 0x1db0 */
+ uint32_t mga_reserved_0x1db4; /* 0x1db4 */
+ uint32_t mga_reserved_0x1db8; /* 0x1db8 */
+ uint32_t mga_reserved_0x1dbc; /* 0x1dbc */
+ uint32_t mga_wiaddr; /* 0x1dc0 */
+ uint32_t mga_wflag; /* 0x1dc4 */
+ uint32_t mga_wgetmsb; /* 0x1dc8 */
+ uint32_t mga_wvrtxsz; /* 0x1dcc */
+ uint8_t mga_reserved_0x1dd0[0x1e00 - 0x1dd0]; /* 0x1dd0 */
+ uint32_t mga_reserved_0x1e00; /* 0x1e00 */
+ uint32_t mga_reserved_0x1e04; /* 0x1e04 */
+ uint32_t mga_reserved_0x1e08; /* 0x1e08 */
+ uint32_t mga_reserved_0x1e0c; /* 0x1e0c */
+ uint32_t mga_fifostatus; /* 0x1e10 */
+ uint32_t mga_status; /* 0x1e14 */
+ uint32_t mga_iclear; /* 0x1e18 */
+ uint32_t mga_ien; /* 0x1e1c */
+ uint32_t mga_vcount; /* 0x1e20 */
+ uint32_t mga_modelrev; /* 0x1e24 */
+ uint32_t mga_reserved_0x1e28; /* 0x1e28 */
+ uint32_t mga_reserved_0x1e2c; /* 0x1e2c */
+ uint32_t mga_dmamap30; /* 0x1e30 */
+ uint32_t mga_dmamap74; /* 0x1e34 */
+ uint32_t mga_dmamapb8; /* 0x1e38 */
+ uint32_t mga_dmamapfc; /* 0x1e3c */
+ uint32_t mga_rst; /* 0x1e40 */
+ uint32_t mga_memrdbk; /* 0x1e44 */
+ uint32_t mga_test0; /* 0x1e48 */
+ uint32_t mga_agp_pll; /* 0x1e4c */
+ uint32_t mga_primptr; /* 0x1e50 */
+ uint32_t mga_opmode; /* 0x1e54 */
+ uint32_t mga_primaddress; /* 0x1e58 */
+ uint32_t mga_primend; /* 0x1e5c */
+ uint32_t mga_wiaddrnb; /* 0x1e60 */
+ uint32_t mga_wflagnb; /* 0x1e64 */
+ uint32_t mga_wimemaddr; /* 0x1e68 */
+ uint32_t mga_wcodeaddr; /* 0x1e6c */
+ uint32_t mga_wmisc; /* 0x1e70 */
+ uint32_t mga_reserved_0x1e74; /* 0x1e74 */
+ uint32_t mga_reserved_0x1e78; /* 0x1e78 */
+ uint32_t mga_reserved_0x1e7c; /* 0x1e7c */
+ uint32_t mga_dwg_indir_wt[0x10]; /* 0x1e80 */
+ uint8_t mga_reserved_0x1ec0[0x1fc0 - 0x1ec0]; /* 0x1ec0 */
+ uint8_t mga_attr_index; /* 0x1fc0 */
+ uint8_t mga_attr_data; /* 0x1fc1 */
+ uint8_t mga_insts0; /* 0x1fc2 */
+ uint8_t mga_reserved_0x1fc3; /* 0x1fc3 */
+ uint8_t mga_seq_index; /* 0x1fc4 */
+ uint8_t mga_seq_data; /* 0x1fc5 */
+ uint8_t mga_reserved_0x1fc6; /* 0x1fc6 */
+ uint8_t mga_dacstatus; /* 0x1fc7 */
+ uint8_t mga_reserved_0x1fc8; /* 0x1fc8 */
+ uint8_t mga_reserved_0x1fc9; /* 0x1fc9 */
+ uint8_t mga_feat_read; /* 0x1fca */
+ uint8_t mga_reserved_0x1fcb; /* 0x1fcb */
+ uint8_t mga_miscout_read; /* 0x1fcc */
+ uint8_t mga_reserved_0x1fcd; /* 0x1fcd */
+ uint8_t mga_gctl_index; /* 0x1fce */
+ uint8_t mga_gctl_data; /* 0x1fcf */
+ uint8_t mga_reserved_0x1fd0; /* 0x1fd0 */
+ uint8_t mga_reserved_0x1fd1; /* 0x1fd1 */
+ uint8_t mga_reserved_0x1fd2; /* 0x1fd2 */
+ uint8_t mga_reserved_0x1fd3; /* 0x1fd3 */
+ uint8_t mga_crtc_index; /* 0x1fd4 */
+ uint8_t mga_crtc_data; /* 0x1fd5 */
+ uint8_t mga_reserved_0x1fd6; /* 0x1fd6 */
+ uint8_t mga_reserved_0x1fd7; /* 0x1fd7 */
+ uint8_t mga_reserved_0x1fd8; /* 0x1fd8 */
+ uint8_t mga_reserved_0x1fd9; /* 0x1fd9 */
+ uint8_t mga_insts1; /* 0x1fda */
+ uint8_t mga_reserved_0x1fdb; /* 0x1fdb */
+ uint8_t mga_reserved_0x1fdc; /* 0x1fdc */
+ uint8_t mga_reserved_0x1fdd; /* 0x1fdd */
+ uint8_t mga_crtcext_index; /* 0x1fde */
+ uint8_t mga_crtcext_data; /* 0x1fdf */
+ uint8_t mga_reserved_0x1fe0[0x1fff - 0x1fe0]; /* 0x1fe0 */
+ uint8_t mga_cacheflush; /* 0x1fff */
+ uint32_t mga_wimemdata[0x20]; /* 0x2000 */
+ uint8_t mga_reserved_0x2080[0x2c00 - 0x2080]; /* 0x2080 */
+ uint32_t mga_tmr0; /* 0x2c00 */
+ uint32_t mga_tmr1; /* 0x2c04 */
+ uint32_t mga_tmr2; /* 0x2c08 */
+ uint32_t mga_tmr3; /* 0x2c0c */
+ uint32_t mga_tmr4; /* 0x2c10 */
+ uint32_t mga_tmr5; /* 0x2c14 */
+ uint32_t mga_tmr6; /* 0x2c18 */
+ uint32_t mga_tmr7; /* 0x2c1c */
+ uint32_t mga_tmr8; /* 0x2c20 */
+ uint32_t mga_texorg; /* 0x2c24 */
+ uint32_t mga_texwidth; /* 0x2c28 */
+ uint32_t mga_texheight; /* 0x2c2c */
+ uint32_t mga_texctl; /* 0x2c30 */
+ uint32_t mga_textrans; /* 0x2c34 */
+ uint32_t mga_textranshigh; /* 0x2c38 */
+ uint32_t mga_texctl2; /* 0x2c3c */
+ uint32_t mga_secaddress; /* 0x2c40 */
+ uint32_t mga_secend; /* 0x2c44 */
+ uint32_t mga_softrap; /* 0x2c48 */
+ uint32_t mga_dwgsync; /* 0x2c4c */
+ uint32_t mga_dr0_z32_lsb; /* 0x2c50 */
+ uint32_t mga_dr0_z32_msb; /* 0x2c54 */
+ uint32_t mga_texfilter; /* 0x2c58 */
+ uint32_t mga_texbordercol; /* 0x2c5c */
+ uint32_t mga_dr2_z32_lsb; /* 0x2c60 */
+ uint32_t mga_dr2_z32_msb; /* 0x2c64 */
+ uint32_t mga_dr3_z32_lsb; /* 0x2c68 */
+ uint32_t mga_dr3_z32_msb; /* 0x2c6c */
+ uint32_t mga_alphastart; /* 0x2c70 */
+ uint32_t mga_alphaxinc; /* 0x2c74 */
+ uint32_t mga_alphayinc; /* 0x2c78 */
+ uint32_t mga_alphactrl; /* 0x2c7c */
+ uint32_t mga_specrstart; /* 0x2c80 */
+ uint32_t mga_specrxinc; /* 0x2c84 */
+ uint32_t mga_specryinc; /* 0x2c88 */
+ uint32_t mga_specgstart; /* 0x2c8c */
+ uint32_t mga_specgxinc; /* 0x2c90 */
+ uint32_t mga_specgyinc; /* 0x2c94 */
+ uint32_t mga_specbstart; /* 0x2c98 */
+ uint32_t mga_specbxinc; /* 0x2c9c */
+ uint32_t mga_specbyinc; /* 0x2ca0 */
+ uint32_t mga_texorg1; /* 0x2ca4 */
+ uint32_t mga_texorg2; /* 0x2ca8 */
+ uint32_t mga_texorg3; /* 0x2cac */
+ uint32_t mga_texorg4; /* 0x2cb0 */
+ uint32_t mga_srcorg; /* 0x2cb4 */
+ uint32_t mga_dstorg; /* 0x2cb8 */
+ uint32_t mga_reserved_0x2cbc; /* 0x2cbc */
+ uint32_t mga_reserved_0x2cc0; /* 0x2cc0 */
+ uint32_t mga_reserved_0x2cc4; /* 0x2cc4 */
+ uint32_t mga_reserved_0x2cc8; /* 0x2cc8 */
+ uint32_t mga_reserved_0x2ccc; /* 0x2ccc */
+ uint32_t mga_setupaddress; /* 0x2cd0 */
+ uint32_t mga_setupend; /* 0x2cd4 */
+ uint8_t mga_reserved_0x2cd8[0x2d00 - 0x2cd8]; /* 0x2cd8 */
+ uint32_t mga_wr[64]; /* 0x2d00 */
+ uint8_t mga_reserved_0x2e00[0x3c00 - 0x2e00]; /* 0x2e00 */
+ uint8_t mga_palwtadd; /* 0x3c00 */
+ uint8_t mga_paldata; /* 0x3c01 */
+ uint8_t mga_pixrdmsk; /* 0x3c02 */
+ uint8_t mga_palrdadd; /* 0x3c03 */
+ uint8_t mga_reserved_0x3c04; /* 0x3c04 */
+ uint8_t mga_reserved_0x3c05; /* 0x3c05 */
+ uint8_t mga_reserved_0x3c06; /* 0x3c06 */
+ uint8_t mga_reserved_0x3c07; /* 0x3c07 */
+ uint8_t mga_reserved_0x3c08; /* 0x3c08 */
+ uint8_t mga_reserved_0x3c09; /* 0x3c09 */
+ uint8_t mga_x_datareg; /* 0x3c0a */
+ uint8_t mga_reserved_0x3c0b; /* 0x3c0b */
+ uint8_t mga_curposxl; /* 0x3c0c */
+ uint8_t mga_curposxh; /* 0x3c0d */
+ uint8_t mga_curposyl; /* 0x3c0e */
+ uint8_t mga_curposyh; /* 0x3c0f */
+ uint8_t mga_reserved_0x3c10[0x3d00 - 0x3c10]; /* 0x3c10 */
+ uint32_t mga_besa1org; /* 0x3d00 */
+ uint32_t mga_besa2org; /* 0x3d04 */
+ uint32_t mga_besb1org; /* 0x3d08 */
+ uint32_t mga_besb2org; /* 0x3d0c */
+ uint32_t mga_besa1corg; /* 0x3d10 */
+ uint32_t mga_besa2corg; /* 0x3d14 */
+ uint32_t mga_besb1corg; /* 0x3d18 */
+ uint32_t mga_besb2corg; /* 0x3d1c */
+ uint32_t mga_besctl; /* 0x3d20 */
+ uint32_t mga_bespitch; /* 0x3d24 */
+ uint32_t mga_beshcoord; /* 0x3d28 */
+ uint32_t mga_besvcoord; /* 0x3d2c */
+ uint32_t mga_beshiscal; /* 0x3d30 */
+ uint32_t mga_besviscal; /* 0x3d34 */
+ uint32_t mga_beshsrcst; /* 0x3d38 */
+ uint32_t mga_beshsrcend; /* 0x3d3c */
+ uint32_t mga_reserved_0x3d40; /* 0x3d40 */
+ uint32_t mga_reserved_0x3d44; /* 0x3d44 */
+ uint32_t mga_besv1wght; /* 0x3d48 */
+ uint32_t mga_besv2wght; /* 0x3d4c */
+ uint32_t mga_beshsrclst; /* 0x3d50 */
+ uint32_t mga_besv1srclst; /* 0x3d54 */
+ uint32_t mga_besv2srclst; /* 0x3d58 */
+ uint8_t mga_reserved_0x3d5c[0x3dc0 - 0x3d5c]; /* 0x3d5c */
+ uint32_t mga_besglobctl; /* 0x3dc0 */
+ uint32_t mga_besstatus; /* 0x3dc4 */
+ uint8_t mga_reserved_0x3dc8[0x3e00 - 0x3dc8]; /* 0x3dc8 */
+ uint32_t mga_vinctl0; /* 0x3e00 */
+ uint32_t mga_vinctl1; /* 0x3e04 */
+ uint32_t mga_vbiaddr0; /* 0x3e08 */
+ uint32_t mga_vbiaddr1; /* 0x3e0c */
+ uint32_t mga_vinaddr0; /* 0x3e10 */
+ uint32_t mga_vinaddr1; /* 0x3e14 */
+ uint32_t mga_vinnextwin; /* 0x3e18 */
+ uint32_t mga_vinctl; /* 0x3e1c */
+ uint32_t mga_reserved_0x3e20; /* 0x3e20 */
+ uint32_t mga_reserved_0x3e24; /* 0x3e24 */
+ uint32_t mga_reserved_0x3e28; /* 0x3e28 */
+ uint32_t mga_reserved_0x3e2c; /* 0x3e2c */
+ uint32_t mga_vstatus; /* 0x3e30 */
+ uint32_t mga_viclear; /* 0x3e34 */
+ uint32_t mga_vien; /* 0x3e38 */
+ uint32_t mga_reserved_0x3e3c; /* 0x3e3c */
+ uint32_t mga_codecctl; /* 0x3e40 */
+ uint32_t mga_codecaddr; /* 0x3e44 */
+ uint32_t mga_codechostptr; /* 0x3e48 */
+ uint32_t mga_codechardptr; /* 0x3e4c */
+ uint32_t mga_codeclcode; /* 0x3e50 */
+ uint8_t mga_reserved_0x3e54[0x4000 - 0x3e54]; /* 0x3e54 */
+ } mga_t; /* 0x4000 */
+
+#define mga_miscout_write mga_insts0 /* 0x1fc2 */
+#define mga_feat_write mga_insts1 /* 0x1fda */
+#define mga_dwg_indir_wt0 mga_dwg_indir_wt[0x0] /* 0x1e80 */
+#define mga_dwg_indir_wt1 mga_dwg_indir_wt[0x1] /* 0x1e84 */
+#define mga_dwg_indir_wt2 mga_dwg_indir_wt[0x2] /* 0x1e88 */
+#define mga_dwg_indir_wt3 mga_dwg_indir_wt[0x3] /* 0x1e8c */
+#define mga_dwg_indir_wt4 mga_dwg_indir_wt[0x4] /* 0x1e90 */
+#define mga_dwg_indir_wt5 mga_dwg_indir_wt[0x5] /* 0x1e94 */
+#define mga_dwg_indir_wt6 mga_dwg_indir_wt[0x6] /* 0x1e98 */
+#define mga_dwg_indir_wt7 mga_dwg_indir_wt[0x7] /* 0x1e9c */
+#define mga_dwg_indir_wt8 mga_dwg_indir_wt[0x8] /* 0x1ea0 */
+#define mga_dwg_indir_wt9 mga_dwg_indir_wt[0x9] /* 0x1ea4 */
+#define mga_dwg_indir_wta mga_dwg_indir_wt[0xa] /* 0x1ea8 */
+#define mga_dwg_indir_wtb mga_dwg_indir_wt[0xb] /* 0x1eac */
+#define mga_dwg_indir_wtc mga_dwg_indir_wt[0xc] /* 0x1eb0 */
+#define mga_dwg_indir_wtd mga_dwg_indir_wt[0xd] /* 0x1eb4 */
+#define mga_dwg_indir_wte mga_dwg_indir_wt[0xe] /* 0x1eb8 */
+#define mga_dwg_indir_wtf mga_dwg_indir_wt[0xf] /* 0x1ebc */
+
+#define MGAG200_REFRESH_MIN_HZ 66146 /* back solved: 0x22 for 144MHz */
+
+ /* 144.0Mhz memory clock */
+#define MGAG200_DEFAULT_MCLK_HZ 144000000
+
+#define MGA_SYNC_XTAG 0x275f4200
+
+#define MGA_FB_OFFSET 0x00000000
+#define MGA_CONTROL_OFFSET 0x10000000
+#define MGA_ILOAD_OFFSET 0x20000000
+#define MGA_ROM_OFFSET 0x30000000
+#define MGA_LAST_OFFSET 0x40000000
+
+#define MGA_EDID_CLOCK_MASK 0x02
+#define MGA_EDID_DATA_MASK 0x01
+
+#define MGA_FB_STEP (16 * 1024)
+
+/* END CSTYLED */
+
+#endif /* _MGA_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/app/gfx-utils/sun-src/vts/mga/tools.c Fri Feb 24 16:15:46 2012 -0800
@@ -0,0 +1,1088 @@
+/*
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "libvtsSUNWmga.h" /* Common VTS library definitions */
+
+hrtime_t mga_loop_time = (hrtime_t) 10 * NANOSEC; /* time to busy wait */
+
+#if !defined(_BIG_ENDIAN)
+int mga_big_endian = 0;
+#else /* defined(_BIG_ENDIAN) */
+int mga_big_endian = 1;
+#endif /* defined(_BIG_ENDIAN) */
+
+int
+mga_map_mem(
+ register return_packet *const rp,
+ register int const test)
+{
+ if (mga_get_pci_info() != 0) {
+ gfx_vts_set_message(rp, 1, test, "get pci info failed");
+ return (-1);
+ }
+
+ if (mga_map_fb() != 0) {
+ gfx_vts_set_message(rp, 1, test, "map framebuffer failed");
+ return (-1);
+ }
+
+ if (mga_map_control() != 0) {
+ gfx_vts_set_message(rp, 1, test, "map control failed");
+ return (-1);
+ }
+
+ if (mga_map_iload() != 0) {
+ gfx_vts_set_message(rp, 1, test, "map iload failed");
+ return (-1);
+ }
+
+ return (0);
+}
+
+int
+mga_get_pci_info(
+ void)
+{
+ struct gfx_pci_cfg pciconfig;
+
+ if (ioctl(mga_info.mga_fd, GFX_IOCTL_GET_PCI_CONFIG,
+ &pciconfig) != 0)
+ return (-1);
+
+ mga_info.mga_vendor = pciconfig.VendorID;
+ mga_info.mga_device = pciconfig.DeviceID;
+
+ mga_info.mga_fb_addr = pciconfig.bar[0] & PCI_BASE_M_ADDR_M;
+ mga_info.mga_fb_size = MGASIZE_FB;
+
+ mga_info.mga_control_addr = pciconfig.bar[1] & PCI_BASE_M_ADDR_M;
+ mga_info.mga_control_size = MGASIZE_CONTROL;
+
+ mga_info.mga_iload_addr = pciconfig.bar[2] & PCI_BASE_M_ADDR_M;
+ mga_info.mga_iload_size = MGASIZE_ILOAD;
+
+ if (gfx_vts_debug_mask & VTS_DEBUG) {
+ printf("mga_vendor = 0x%04x, mga_device = 0x%04x\n",
+ mga_info.mga_vendor, mga_info.mga_device);
+ printf("fb_addr = 0x%08llx, mga_fb_size = 0x%08lx\n",
+ (unsigned long long) mga_info.mga_fb_addr,
+ (unsigned long) mga_info.mga_fb_size);
+ printf("control_addr = 0x%08llx, mga_control_size = 0x%08lx\n",
+ (unsigned long long) mga_info.mga_control_addr,
+ (unsigned long) mga_info.mga_control_size);
+ printf("iload_addr = 0x%08llx, mga_iload_size = 0x%08lx\n",
+ (unsigned long long) mga_info.mga_iload_addr,
+ (unsigned long) mga_info.mga_iload_size);
+ }
+
+ return (0);
+}
+
+int
+mga_map_fb(
+ void)
+{
+ register void *ptr;
+
+ if (mga_info.mga_fb_ptr == NULL) {
+ ptr = mmap(NULL, mga_info.mga_fb_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ mga_info.mga_fd, mga_info.mga_fb_addr);
+
+ if (ptr == MAP_FAILED)
+ return (-1);
+
+ mga_info.mga_fb_ptr = (char *) ptr;
+ }
+
+ if (gfx_vts_debug_mask & VTS_DEBUG)
+ printf("mga_fb_ptr = 0x%llx\n",
+ (unsigned long long) mga_info.mga_fb_ptr);
+
+ return (0);
+}
+
+int
+mga_map_control(
+ void)
+{
+ register void *ptr;
+
+ if (mga_info.mga_control_ptr == NULL) {
+ ptr = mmap(NULL, mga_info.mga_control_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ mga_info.mga_fd, mga_info.mga_control_addr);
+
+ if (ptr == MAP_FAILED)
+ return (-1);
+ }
+
+ mga_info.mga_control_ptr = (mga_t volatile *) ptr;
+
+ if (gfx_vts_debug_mask & VTS_DEBUG)
+ printf("mga_control_ptr = 0x%llx\n",
+ (unsigned long long) mga_info.mga_control_ptr);
+
+ return (0);
+}
+
+int
+mga_map_iload(
+ void)
+{
+ register void *ptr;
+
+ if (mga_info.mga_iload_ptr == NULL) {
+ ptr = mmap(NULL, mga_info.mga_iload_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ mga_info.mga_fd, mga_info.mga_iload_addr);
+
+ if (ptr == MAP_FAILED)
+ return (-1);
+ }
+
+ mga_info.mga_iload_ptr = (char volatile *) ptr;
+
+ if (gfx_vts_debug_mask & VTS_DEBUG)
+ printf("mga_iload_ptr = 0x%llx\n",
+ (unsigned long long) mga_info.mga_iload_ptr);
+
+ return (0);
+}
+
+int
+mga_init_info(
+ register return_packet *const rp,
+ register int const test)
+{
+ register mga_t volatile *mgaptr;
+
+ if (mga_get_fb_size() == 0) {
+ gfx_vts_set_message(rp, 1, test, "get fb size failed");
+ return (-1);
+ }
+
+ if (mga_get_screen_size() == 0) {
+ gfx_vts_set_message(rp, 1, test, "get resolution failed");
+ return (-1);
+ }
+
+ mgaptr = mga_info.mga_control_ptr;
+ mga_info.mga_opmode = mga_get_uint32(&mgaptr->mga_opmode);
+
+ return (0);
+}
+
+#define MGA_FB_STEP (16 * 1024)
+
+size_t
+mga_get_fb_size(
+ void)
+{
+ register uint32_t volatile *fbptr;
+ register size_t offset;
+ register uint32_t word;
+
+ for (offset = 0, fbptr = (uint32_t volatile *) mga_info.mga_fb_ptr;
+ offset < mga_info.mga_fb_size;
+ offset += MGA_FB_STEP, fbptr += MGA_FB_STEP / sizeof (uint32_t)) {
+ word = *fbptr;
+ *fbptr = ~word;
+ if (*fbptr != ~word) {
+ *fbptr = word;
+ break;
+ }
+ *fbptr = word;
+ if (*fbptr != word)
+ break;
+ }
+
+ mga_info.mga_fb_real_size = offset;
+
+ if (gfx_vts_debug_mask & VTS_DEBUG)
+ printf("mga_fb_real_size = %lu\n", (unsigned long) offset);
+
+ return (offset);
+}
+
+
+int
+mga_get_screen_size(
+ void)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register uint8_t save_crtc_index;
+ register uint8_t save_crtcext_index;
+ register uint8_t save_palwtadd;
+ register uint8_t save_gctl_index;
+ register uint8_t miscout;
+ register uint8_t horiz_total;
+ register uint8_t horiz_display_end;
+ register uint8_t vert_total;
+ register uint8_t vert_display_end;
+ register uint8_t overflow;
+ register uint8_t offset;
+ register uint8_t addr_gen_ext;
+ register uint8_t hor_counter_ext;
+ register uint8_t vert_counter_ext;
+ register uint8_t xmulctrl;
+ register uint8_t misc;
+ register uint8_t graphic_mode;
+ register uint8_t miscellaneous;
+ register uint32_t freq;
+ register uint8_t m;
+ register uint8_t n;
+ register uint8_t p;
+ register uint_t mode;
+ register uint_t width;
+ register uint_t height;
+ register uint_t depth;
+ register uint_t pixelsize;
+ register uint_t pclk;
+ register uint_t htotal;
+ register uint_t vtotal;
+ register uint_t hz;
+ register uint_t pitch;
+
+ /* Get the miscellaneous output register */
+
+ miscout = mgaptr->mga_miscout_read;
+
+ /* Save the crtc index. */
+
+ save_crtc_index = mgaptr->mga_crtc_index;
+
+ /* Get the horizontal total */
+
+ mgaptr->mga_crtc_index = MGA_CRTC_HORIZ_TOTAL;
+ horiz_total = mgaptr->mga_crtc_data;
+
+ /* Get the horizontal display end. */
+
+ mgaptr->mga_crtc_index = MGA_CRTC_HORIZ_DISPLAY_END;
+ horiz_display_end = mgaptr->mga_crtc_data;
+
+ /* Get the vertical total */
+
+ mgaptr->mga_crtc_index = MGA_CRTC_VERT_TOTAL;
+ vert_total = mgaptr->mga_crtc_data;
+
+ /* Get the vertical display end. */
+
+ mgaptr->mga_crtc_index = MGA_CRTC_VERT_DISPLAY_END;
+ vert_display_end = mgaptr->mga_crtc_data;
+
+ /* Get the overflow */
+
+ mgaptr->mga_crtc_index = MGA_CRTC_OVERFLOW;
+ overflow = mgaptr->mga_crtc_data;
+
+ /* Get the offset */
+
+ mgaptr->mga_crtc_index = MGA_CRTC_OFFSET;
+ offset = mgaptr->mga_crtc_data;
+
+ /* Restore the crtc index. */
+
+ mgaptr->mga_crtc_index = save_crtc_index;
+
+ /* Save the crtcext index. */
+
+ save_crtcext_index = mgaptr->mga_crtcext_index;
+
+ /* Get the address generator extensions */
+
+ mgaptr->mga_crtcext_index = MGA_CRTCEXT_ADDR_GEN_EXT;
+ addr_gen_ext = mgaptr->mga_crtcext_data;
+
+ /* Get the horizontal counter extensions */
+
+ mgaptr->mga_crtcext_index = MGA_CRTCEXT_HOR_COUNT_EXT;
+ hor_counter_ext = mgaptr->mga_crtcext_data;
+
+ /* Get the vertical counter extensions */
+
+ mgaptr->mga_crtcext_index = MGA_CRTCEXT_VERT_COUNT_EXT;
+ vert_counter_ext = mgaptr->mga_crtcext_data;
+
+ /* Get the miscellaneous register */
+
+ mgaptr->mga_crtcext_index = MGA_CRTCEXT_MISC;
+ misc = mgaptr->mga_crtcext_data;
+
+ /* Restore the crtcext index. */
+
+ mgaptr->mga_crtcext_index = save_crtcext_index;
+
+ /* Save the dac index. */
+
+ save_palwtadd = mgaptr->mga_palwtadd;
+
+ /* Get the multiplex control. */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XMULCTRL;
+ xmulctrl = mgaptr->mga_x_datareg;
+
+ /* Get the appropriate clock values */
+
+ switch (miscout & MGA_MISCOUT_CLKSEL_MASK) {
+ case MGA_MISCOUT_CLKSEL_25MHZ: /* 0x00 */
+ freq = MGA_XPIXPLLPA_REFCLK;
+
+ /* Get pixpllam register */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XPIXPLLAM;
+ m = mgaptr->mga_x_datareg;
+
+ /* Get pixpllan register */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XPIXPLLAN;
+ n = mgaptr->mga_x_datareg;
+
+ /* Get pixpllap register */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XPIXPLLAP;
+ p = mgaptr->mga_x_datareg;
+ break;
+
+ case MGA_MISCOUT_CLKSEL_28MHZ: /* 0x04 */
+ freq = MGA_XPIXPLLPB_REFCLK;
+
+ /* Get pixpllbm register */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XPIXPLLBM;
+ m = mgaptr->mga_x_datareg;
+
+ /* Get pixpllbn register */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XPIXPLLBN;
+ n = mgaptr->mga_x_datareg;
+
+ /* Get pixpllbp register */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XPIXPLLBP;
+ p = mgaptr->mga_x_datareg;
+ break;
+
+ case MGA_MISCOUT_CLKSEL_MGAPIXEL0: /* 0x08 */
+ case MGA_MISCOUT_CLKSEL_MGAPIXEL1: /* 0x0c */
+ freq = MGA_XPIXPLLPC_REFCLK_G200E;
+
+ /* Get pixpllcm register */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XPIXPLLCM;
+ m = mgaptr->mga_x_datareg;
+
+ /* Get pixpllcn register */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XPIXPLLCN;
+ n = mgaptr->mga_x_datareg;
+
+ /* Get pixpllcp register */
+
+ mgaptr->mga_palwtadd = MGA_XDATA_XPIXPLLCP;
+ p = mgaptr->mga_x_datareg;
+ break;
+ }
+
+ /* Restore the dac index. */
+
+ mgaptr->mga_palwtadd = save_palwtadd;
+
+ /* Save the gctl index. */
+
+ save_gctl_index = mgaptr->mga_gctl_index;
+
+ /* Get the graphic mode register. */
+
+ mgaptr->mga_gctl_index = MGA_GCTL_GRAPHIC_MODE;
+ graphic_mode = mgaptr->mga_gctl_data;
+
+ /* Get the miscellaneous register */
+
+ mgaptr->mga_gctl_index = MGA_GCTL_MISCELLANEOUS;
+ miscellaneous = mgaptr->mga_gctl_data;
+
+ /* Restore the gctl index. */
+
+ mgaptr->mga_gctl_index = save_gctl_index;
+
+ /* Compute the width. */
+
+ width = ((uint_t) horiz_display_end + 1) * 8;
+
+ /* Compute the height. */
+
+ height = (uint_t) vert_display_end;
+ height |= (((uint_t) overflow >>
+ MGA_CRTC_OVERFLOW_VDISPEND8_SHIFT) & 1) << 8;
+ height |= (((uint_t) overflow >>
+ MGA_CRTC_OVERFLOW_VDISPEND9_SHIFT) & 1) << 9;
+ height |= (((uint_t) vert_counter_ext >>
+ MGA_CRTCEXT_VCOUNT_VDISPEND10_SHIFT) & 1) << 10;
+ height++;
+
+ if (addr_gen_ext & MGA_CRTCEXT_ADDR_GEN_INTERLACE)
+ height *= 2;
+
+ if (!(misc & MGA_CRTCEXT_MISC_MGAMODE)) {
+ if (!(miscellaneous & MGA_GCTL_MISC_GCGRMODE)) {
+ mode = VIS_TEXT;
+ depth = 4;
+ width /= 8;
+ height /= 16;
+ pixelsize = 2;
+
+ } else {
+ mode = VIS_PIXEL;
+ if (!(graphic_mode & MGA_GCTL_GRMODE_MODE256))
+ depth = 4;
+ else
+ depth = 8;
+ pixelsize = 1;
+ }
+
+ } else {
+ mode = VIS_PIXEL;
+
+ /* Compute the depth. */
+
+ switch (xmulctrl & MGA_XMULCTRL_DEPTH_MASK) {
+ case MGA_XMULCTRL_DEPTH_8BPP: /* 0x00 */
+ depth = 8;
+ pixelsize = 1;
+ break;
+
+ case MGA_XMULCTRL_DEPTH_15BPP_1BPP_OVERLAY: /* 0x01 */
+ depth = 15;
+ pixelsize = 2;
+ break;
+
+ case MGA_XMULCTRL_DEPTH_16BPP: /* 0x02 */
+ depth = 16;
+ pixelsize = 2;
+ break;
+
+ case MGA_XMULCTRL_DEPTH_24BPP: /* 0x03 */
+ depth = 24;
+ pixelsize = 3;
+ break;
+
+ case MGA_XMULCTRL_DEPTH_32BPP_8BPP_OVERLAY: /* 0x04 */
+ case MGA_XMULCTRL_DEPTH_32BPP_8BPP_UNUSED: /* 0x07 */
+ depth = 32;
+ pixelsize = 4;
+ break;
+
+ default:
+ return (0);
+ }
+ }
+
+ pclk = (unsigned long long) freq *
+ (unsigned long long) (n + 1) /
+ (unsigned long long) ((m & MGA_XPIXPLLM_MASK) + 1) /
+ (unsigned long long) ((p & MGA_XPIXPLLP_PIXPLLP_MASK) + 1);
+
+ htotal = ((horiz_total |
+ ((hor_counter_ext & MGA_CRTCEXT_HCOUNT_HTOTAL8) << 8)) + 5) * 8;
+
+ vtotal = (vert_total |
+ ((overflow & MGA_CRTC_OVERFLOW_VTOTAL8) << 8) |
+ (((overflow >> MGA_CRTC_OVERFLOW_VTOTAL9_SHIFT) & 1) << 9) |
+ ((vert_counter_ext & MGA_CRTCEXT_VCOUNT_VTOTAL10_11) << 10)) + 2;
+
+ hz = (pclk + (htotal * vtotal / 2)) / (htotal * vtotal);
+
+ pitch = ((((addr_gen_ext & MGA_CRTCEXT_ADDR_GEN_OFFSET8_9) >>
+ MGA_CRTCEXT_ADDR_GEN_OFFSET8_9_SHIFT) << 8) + offset) * 8 * 2;
+
+ mga_info.mga_mode = mode;
+ mga_info.mga_width = width;
+ mga_info.mga_height = height;
+ mga_info.mga_depth = depth;
+ mga_info.mga_hz = hz;
+ mga_info.mga_pixelsize = pixelsize;
+ mga_info.mga_linesize = pitch;
+
+ return (1);
+}
+
+
+int
+mga_mgamode(
+ void)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register uint8_t crtcext_index;
+ register uint8_t misc;
+
+ /* Save the crtcext index. */
+
+ crtcext_index = mgaptr->mga_crtcext_index;
+
+ /* Get the miscellaneous register */
+
+ mgaptr->mga_crtcext_index = MGA_CRTCEXT_MISC;
+ misc = mgaptr->mga_crtcext_data;
+
+ /* Restore the crtcext index. */
+
+ mgaptr->mga_crtcext_index = crtcext_index;
+
+ if (!(misc & MGA_CRTCEXT_MISC_MGAMODE))
+ return (0);
+ else
+ return (1);
+}
+
+int
+mga_init_graphics(
+ void)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register uint32_t maccess;
+ register uint32_t opmode = MGA_OPMODE_DIRDATASIZ_8BPP;
+ static short endian = 1;
+
+ if (!mga_wait_fifo(11))
+ return (0);
+
+ switch (mga_info.mga_depth) {
+ case 8:
+ maccess = MGA_MACCESS_PWIDTH_PW8;
+ break;
+
+ case 15:
+ case 16:
+ maccess = MGA_MACCESS_PWIDTH_PW16;
+ if (!*(char const *)&endian) /* big endian */
+ opmode = MGA_OPMODE_DIRDATASIZ_16BPP;
+ break;
+
+ case 24:
+ maccess = MGA_MACCESS_PWIDTH_PW24;
+ break;
+
+ case 32:
+ maccess = MGA_MACCESS_PWIDTH_PW32;
+ if (!*(char const *)&endian) /* big endian */
+ opmode = MGA_OPMODE_DIRDATASIZ_32BPP;
+ break;
+ }
+
+ mga_put_uint32(&mgaptr->mga_maccess, maccess);
+ mga_put_uint32(&mgaptr->mga_opmode, opmode);
+ mga_put_uint32(&mgaptr->mga_pitch, mga_info.mga_linesize /
+ mga_info.mga_pixelsize);
+ mga_put_uint32(&mgaptr->mga_dstorg, 0);
+ mga_put_uint32(&mgaptr->mga_ydstorg, 0);
+ mga_put_uint32(&mgaptr->mga_cxbndry, (mga_info.mga_width - 1) << 16);
+ mga_put_uint32(&mgaptr->mga_ytop, 0);
+ mga_put_uint32(&mgaptr->mga_ybot, (mga_info.mga_height - 1) *
+ mga_info.mga_linesize);
+ mga_put_uint32(&mgaptr->mga_plnwt, 0xffffffff);
+ mga_put_uint32(&mgaptr->mga_fcol, 0);
+ mga_put_uint32(&mgaptr->mga_bcol, 0xffffffff);
+
+ return (1);
+}
+
+
+void
+mga_save_palet(
+ void)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register uint_t coloron;
+ register uint8_t const save_palrdadd = mgaptr->mga_palrdadd;
+
+ mgaptr->mga_palrdadd = 0;
+
+ for (coloron = 0; coloron < 256; coloron++) {
+ mga_info.mga_red[coloron] = mgaptr->mga_paldata;
+ mga_info.mga_green[coloron] = mgaptr->mga_paldata;
+ mga_info.mga_blue[coloron] = mgaptr->mga_paldata;
+ }
+
+ mgaptr->mga_palrdadd = save_palrdadd;
+}
+
+
+int
+mga_set_palet(
+ void)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register uint_t coloron;
+ register uint8_t save_palwtadd;
+ uchar_t new_red[256];
+ uchar_t new_green[256];
+ uchar_t new_blue[256];
+
+ switch (mga_info.mga_depth) {
+ case 8: /* 3, 3, 2 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red[coloron] =
+ (uint8_t)(((coloron >> 5) & 0x7) * 255 / 7);
+ new_green[coloron] =
+ (uint8_t)(((coloron >> 2) & 0x7) * 255 / 7);
+ new_blue[coloron] =
+ (uint8_t)((coloron & 0x3) * 255 / 3);
+ }
+ break;
+
+ case 15: /* 5, 5, 5 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red[coloron] =
+ (uint8_t)((coloron & 0x1f) * 255 / 31);
+ new_green[coloron] =
+ (uint8_t)((coloron & 0x1f) * 255 / 31);
+ new_blue[coloron] =
+ (uint8_t)((coloron & 0x1f) * 255 / 31);
+ }
+ break;
+
+ case 16: /* 5, 6, 5 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red[coloron] =
+ (uint8_t)((coloron & 0x1f) * 255 / 31);
+ new_green[coloron] =
+ (uint8_t)((coloron & 0x3f) * 255 / 63);
+ new_blue[coloron] =
+ (uint8_t)((coloron & 0x1f) * 255 / 31);
+ }
+ break;
+
+ default: /* 8, 8, 8 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red[coloron] = (uint8_t) coloron;
+ new_green[coloron] = (uint8_t) coloron;
+ new_blue[coloron] = (uint8_t) coloron;
+ }
+ break;
+ }
+
+ /* Don't set the palet if it matches what we will set. */
+
+ for (coloron = 0; coloron < 256; coloron++) {
+ if ((mga_info.mga_red[coloron] != new_red[coloron]) ||
+ (mga_info.mga_green[coloron] != new_green[coloron]) ||
+ (mga_info.mga_blue[coloron] != new_blue[coloron]))
+ break;
+ }
+
+ if (coloron == 256)
+ return (0);
+
+ mga_info.mga_palet_changed = 1;
+ save_palwtadd = mgaptr->mga_palwtadd;
+
+ mgaptr->mga_palwtadd = 0;
+
+ for (coloron = 0; coloron < 256; coloron++) {
+ mgaptr->mga_paldata = new_red[coloron];
+ mgaptr->mga_paldata = new_green[coloron];
+ mgaptr->mga_paldata = new_blue[coloron];
+ }
+
+ mgaptr->mga_palwtadd = save_palwtadd;
+ return (1);
+}
+
+
+int
+mga_restore_palet(
+ void)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register uint_t coloron;
+ register uint8_t save_palwtadd;
+
+ if (!mga_info.mga_palet_changed)
+ return (0);
+
+ save_palwtadd = mgaptr->mga_palwtadd;
+
+ mgaptr->mga_palwtadd = 0;
+
+ for (coloron = 0; coloron < 256; coloron++) {
+ mgaptr->mga_paldata = mga_info.mga_red[coloron];
+ mgaptr->mga_paldata = mga_info.mga_green[coloron];
+ mgaptr->mga_paldata = mga_info.mga_blue[coloron];
+ }
+
+ mgaptr->mga_palwtadd = save_palwtadd;
+
+ mga_info.mga_palet_changed = 0;
+ return (1);
+}
+
+
+uint_t
+mga_color(
+ register uint_t const red,
+ register uint_t const green,
+ register uint_t const blue)
+{
+ register uint_t value;
+
+ switch (mga_info.mga_depth) {
+ case 8: /* 3, 3, 2 */
+ value = ((red >> 5) & 0x7) << 5;
+ value |= ((green >> 5) & 0x7) << 2;
+ value |= (blue >> 6) & 0x3;
+ break;
+
+ case 15: /* 5, 5, 5 */
+ value = ((red >> 3) & 0x1f) << 10;
+ value |= ((green >> 3) & 0x1f) << 5;
+ value |= (blue >> 3) & 0x1f;
+ break;
+
+ case 16: /* 5, 6, 5 */
+ value = ((red >> 3) & 0x1f) << 11;
+ value |= ((green >> 2) & 0x3f) << 5;
+ value |= (blue >> 3) & 0x1f;
+ break;
+
+ default: /* 8, 8, 8 */
+ value = (red & 0xff) << 16;
+ value |= (green & 0xff) << 8;
+ value |= blue & 0xff;
+ break;
+ }
+
+ return (value);
+}
+
+void
+mga_finish_graphics(
+ void)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+
+ mga_put_uint32(&mgaptr->mga_opmode, mga_info.mga_opmode);
+}
+
+
+int
+mga_fill_solid_rect(
+ register int const x1,
+ register int const y1,
+ register int const x2,
+ register int const y2,
+ register uint_t const fg)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+
+ if (!mga_wait_fifo(5))
+ return (0);
+
+ mga_put_uint32(&mgaptr->mga_fcol, fg);
+ mga_put_uint32(&mgaptr->mga_plnwt, 0xffffffff);
+ mga_put_uint32(&mgaptr->mga_dwgctl,
+ MGA_DWGCTL_BOP_COPY | MGA_DWGCTL_SHFTZERO |
+ MGA_DWGCTL_SGNZERO | MGA_DWGCTL_ARZERO |
+ MGA_DWGCTL_SOLID | MGA_DWGCTL_ZMODE_NOZCMP |
+ MGA_DWGCTL_ATYPE_RPL | MGA_DWGCTL_OPCOD_TRAP);
+ mga_put_uint32(&mgaptr->mga_fxbndry,
+ (x2 << 16) | (x1 & 0xffff));
+ mga_put_uint32(&mgaptr->mga_draw_ydstlen,
+ (y1 << 16) | ((y2 - y1) & 0xffff));
+
+ return (1);
+}
+
+
+int
+mga_fill_pattern_rect(
+ register int const x1,
+ register int const y1,
+ register int const x2,
+ register int const y2,
+ register uint_t const bg,
+ register uint_t const fg,
+ register uint64_t const pat)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register int const width = x2 - x1;
+ register int const height = y2 - y1;
+ register int x;
+ register int y;
+ register uint32_t value;
+ register uint32_t iloadon = 0;
+ register uint32_t volatile *iloadptr =
+ (uint32_t volatile *) mga_info.mga_iload_ptr;
+ register int status;
+
+ if (!mga_wait_fifo(11))
+ return (0);
+
+ mga_put_uint32(&mgaptr->mga_opmode, MGA_OPMODE_DIRDATASIZ_8BPP |
+ MGA_OPMODE_DMADATASIZ_8BPP | MGA_OPMODE_DMAMOD_BLIT);
+ mga_put_uint32(&mgaptr->mga_plnwt, 0xffffffff);
+ mga_put_uint32(&mgaptr->mga_shift, 0);
+ mga_put_uint32(&mgaptr->mga_bcol, bg);
+ mga_put_uint32(&mgaptr->mga_fcol, fg);
+ mga_put_uint32(&mgaptr->mga_dwgctl,
+ MGA_DWGCTL_BLTMOD_BMONOLEF | MGA_DWGCTL_BOP_COPY |
+ MGA_DWGCTL_SHFTZERO | MGA_DWGCTL_SGNZERO |
+ MGA_DWGCTL_ZMODE_NOZCMP | MGA_DWGCTL_LINEAR |
+ MGA_DWGCTL_ATYPE_RSTR | MGA_DWGCTL_OPCOD_ILOAD);
+ mga_put_uint32(&mgaptr->mga_ar0, ((width + 31) / 32 * 32) *
+ height - 1);
+ mga_put_uint32(&mgaptr->mga_ar3, 0);
+ mga_put_uint32(&mgaptr->mga_ar5, (width + 31) / 32);
+ mga_put_uint32(&mgaptr->mga_fxbndry,
+ ((x2 - 1) << 16) | (x1 & 0xffff));
+ mga_put_uint32(&mgaptr->mga_draw_ydstlen,
+ (y1 << 16) | (height & 0xffff));
+
+ for (y = 0; y < height; y++) {
+ value = 0;
+
+ for (x = 0; x < width; x++) {
+ value |= ((pat >> (((y + y1) & 7) * 8 +
+ ((x + x1) & 7))) & 1) << (x & 0x1f);
+
+ if ((x & 0x1f) == 0x1f || x == width - 1) {
+ mga_put_uint32(iloadptr, value);
+
+ iloadon += sizeof (uint32_t);
+ if (iloadon < mga_info.mga_iload_size)
+ iloadptr++;
+ else {
+ iloadon = 0;
+ iloadptr = (uint32_t volatile *)
+ mga_info.mga_iload_ptr;
+ }
+ value = 0;
+ }
+ }
+ }
+
+ status = mga_wait_idle();
+ return (status);
+}
+
+
+int
+mga_draw_solid_line(
+ register int const x1,
+ register int const y1,
+ register int const x2,
+ register int const y2,
+ register uint_t const fg)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+
+ if (!mga_wait_fifo(5))
+ return (0);
+
+ mga_put_uint32(&mgaptr->mga_fcol, fg);
+ mga_put_uint32(&mgaptr->mga_plnwt, 0xffffffff);
+ mga_put_uint32(&mgaptr->mga_dwgctl,
+ MGA_DWGCTL_BOP_COPY | MGA_DWGCTL_SOLID |
+ MGA_DWGCTL_ZMODE_NOZCMP | MGA_DWGCTL_ATYPE_RPL |
+ MGA_DWGCTL_OPCOD_AUTOLINE_CLOSE);
+ mga_put_uint32(&mgaptr->mga_xystrt, x1 | (y1 << 16));
+ mga_put_uint32(&mgaptr->mga_draw_xyend, x2 | (y2 << 16));
+
+ return (1);
+}
+
+
+int
+mga_wait_fifo(
+ register int const fifocount)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register uint32_t fifostatus;
+ register hrtime_t starttime;
+ register hrtime_t curtime;
+ register hrtime_t endtime;
+ register ulong_t count = 0;
+
+ starttime = gethrtime();
+ endtime = starttime + mga_loop_time;
+
+ do {
+ count++;
+ fifostatus = mga_get_uint32(&mgaptr->mga_fifostatus);
+ if ((fifostatus & MGA_FIFOSTATUS_FIFOCOUNT_MASK) >= fifocount)
+ break;
+ curtime = gethrtime();
+ } while (curtime < endtime);
+
+ if ((fifostatus & MGA_FIFOSTATUS_FIFOCOUNT_MASK) < fifocount) {
+ count++;
+ fifostatus = mga_get_uint32(&mgaptr->mga_fifostatus);
+ }
+
+ if ((fifostatus & MGA_FIFOSTATUS_FIFOCOUNT_MASK) < fifocount)
+ return (0);
+
+ return (1);
+}
+
+
+int
+mga_wait_idle(
+ void)
+{
+ register mga_t volatile *const mgaptr = mga_info.mga_control_ptr;
+ register uint32_t fifostatus;
+ register hrtime_t starttime;
+ register hrtime_t curtime;
+ register hrtime_t endtime;
+ register ulong_t count = 0;
+
+ starttime = gethrtime();
+ endtime = starttime + mga_loop_time;
+
+ do {
+ count++;
+ fifostatus = mga_get_uint32(&mgaptr->mga_fifostatus);
+ if (fifostatus & MGA_FIFOSTATUS_BEMPTY)
+ break;
+ curtime = gethrtime();
+ } while (curtime < endtime);
+
+ if (!(fifostatus & MGA_FIFOSTATUS_BEMPTY)) {
+ count++;
+ fifostatus = mga_get_uint32(&mgaptr->mga_fifostatus);
+ }
+
+ if (!(fifostatus & MGA_FIFOSTATUS_BEMPTY))
+ return (0);
+
+ return (1);
+}
+
+
+int
+mga_unmap_mem(
+ register return_packet *const rp,
+ register int const test)
+{
+ if (mga_unmap_fb() != 0) {
+ gfx_vts_set_message(rp, 1, test, "unmap framebuffer failed");
+ return (-1);
+ }
+
+ if (mga_unmap_control() != 0) {
+ gfx_vts_set_message(rp, 1, test, "unmap control failed");
+ return (-1);
+ }
+
+ if (mga_unmap_iload() != 0) {
+ gfx_vts_set_message(rp, 1, test, "unmap iload failed");
+ return (-1);
+ }
+
+ return (0);
+}
+
+int
+mga_unmap_fb(
+ void)
+{
+ register int status;
+
+ if (mga_info.mga_fb_ptr == NULL)
+ return (0);
+
+ status = munmap((char *) mga_info.mga_fb_ptr, mga_info.mga_fb_size);
+ mga_info.mga_fb_ptr = NULL;
+
+ return (status);
+}
+
+
+int
+mga_unmap_control(
+ void)
+{
+ register int status;
+
+ if (mga_info.mga_control_ptr == NULL)
+ return (0);
+
+ status = munmap((char *) mga_info.mga_control_ptr,
+ mga_info.mga_control_size);
+ mga_info.mga_control_ptr = NULL;
+
+ return (status);
+}
+
+
+int
+mga_unmap_iload(
+ void)
+{
+ register int status;
+
+ if (mga_info.mga_iload_ptr == NULL)
+ return (0);
+
+ status = munmap((char *) mga_info.mga_iload_ptr,
+ mga_info.mga_iload_size);
+ mga_info.mga_iload_ptr = NULL;
+
+ return (status);
+}
+
+uint32_t
+mga_get_uint32(
+ register uint32_t volatile const *const uint32ptr)
+{
+ register uint32_t value = *uint32ptr;
+
+ if (!mga_big_endian)
+ return (value);
+
+ else
+ return (((value & 0xff) << 24) |
+ ((value & 0xff00) << 8) |
+ ((value & 0xff0000) >> 8) |
+ ((value & 0xff000000) >> 24));
+}
+
+void
+mga_put_uint32(
+ register uint32_t volatile *const uint32ptr,
+ register uint32_t const value)
+{
+ register uint32_t newvalue;
+
+ if (!mga_big_endian)
+ newvalue = value;
+ else
+ newvalue = ((value & 0xff) << 24) |
+ ((value & 0xff00) << 8) |
+ ((value & 0xff0000) >> 8) |
+ ((value & 0xff000000) >> 24);
+
+ *uint32ptr = newvalue;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkg/manifests/system-graphics-sunvts-sunvts-mga.p5m Fri Feb 24 16:15:46 2012 -0800
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+set name=pkg.fmri value=pkg:/system/graphics/sunvts/sunvts-mga@$(OSPKGVERS)
+set name=pkg.summary value="MGA Graphics Diagnostics Software"
+set name=pkg.description \
+ value="Plugins for Oracle VTS diagnostics software for MGA graphics"
+set name=variant.arch value=sparc
+file path=usr/lib/sparcv9/libvtsSUNWmga.so.1
+
+# Requires kernel driver for mgafb
+# depend type=require fmri=pkg:/driver/graphics/mga