summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorEric Jackson <ericj@cvs.openbsd.org>2000-08-04 16:04:38 +0000
committerEric Jackson <ericj@cvs.openbsd.org>2000-08-04 16:04:38 +0000
commitdb378bbf96f01f94fecbe7ff4908ef99dbbd2a8d (patch)
tree02b2813698a6ab7a2c1e88d291895b70dcceed5c /sys/dev/ic
parentcd9fdc9b3a19df70fc87508b201a9b4c67ed8978 (diff)
rest of the work needed for tga2; from NetBSD
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/bt463.c671
-rw-r--r--sys/dev/ic/bt463var.h48
-rw-r--r--sys/dev/ic/bt485.c621
-rw-r--r--sys/dev/ic/bt485var.h48
-rw-r--r--sys/dev/ic/decmonitors.c129
-rw-r--r--sys/dev/ic/monitors.h56
-rw-r--r--sys/dev/ic/ramdac.h80
7 files changed, 1653 insertions, 0 deletions
diff --git a/sys/dev/ic/bt463.c b/sys/dev/ic/bt463.c
new file mode 100644
index 00000000000..32f9dda9080
--- /dev/null
+++ b/sys/dev/ic/bt463.c
@@ -0,0 +1,671 @@
+/* $NetBSD: bt463.c,v 1.2 2000/06/13 17:21:06 nathanw Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1995, 1996 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+ /* This code was derived from and originally located in sys/dev/pci/
+ * NetBSD: tga_bt463.c,v 1.5 2000/03/04 10:27:59 elric Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/buf.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+
+#include <vm/vm.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/tgareg.h>
+#include <dev/pci/tgavar.h>
+#include <dev/ic/bt463reg.h>
+#include <dev/ic/bt463var.h>
+
+#include <dev/wscons/wsconsio.h>
+
+/*
+ * Functions exported via the RAMDAC configuration table.
+ */
+void bt463_init __P((struct ramdac_cookie *));
+int bt463_set_cmap __P((struct ramdac_cookie *,
+ struct wsdisplay_cmap *));
+int bt463_get_cmap __P((struct ramdac_cookie *,
+ struct wsdisplay_cmap *));
+int bt463_set_cursor __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *));
+int bt463_get_cursor __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *));
+int bt463_set_curpos __P((struct ramdac_cookie *,
+ struct wsdisplay_curpos *));
+int bt463_get_curpos __P((struct ramdac_cookie *,
+ struct wsdisplay_curpos *));
+int bt463_get_curmax __P((struct ramdac_cookie *,
+ struct wsdisplay_curpos *));
+int bt463_check_curcmap __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *cursorp));
+void bt463_set_curcmap __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *cursorp));
+int bt463_get_curcmap __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *cursorp));
+
+#ifdef BT463_DEBUG
+int bt463_store __P((void *));
+int bt463_debug __P((void *));
+int bt463_readback __P((void *));
+void bt463_copyback __P((void *));
+#endif
+
+struct ramdac_funcs bt463_funcsstruct = {
+ "Bt463",
+ bt463_register,
+ bt463_init,
+ bt463_set_cmap,
+ bt463_get_cmap,
+ bt463_set_cursor,
+ bt463_get_cursor,
+ bt463_set_curpos,
+ bt463_get_curpos,
+ bt463_get_curmax,
+ bt463_check_curcmap,
+ bt463_set_curcmap,
+ bt463_get_curcmap,
+};
+
+/*
+ * Private data.
+ */
+struct bt463data {
+ void *cookie; /* This is what is passed
+ * around, and is probably
+ * struct tga_devconfig *
+ */
+
+ int (*ramdac_sched_update) __P((void *, void (*)(void *)));
+ void (*ramdac_wr) __P((void *, u_int, u_int8_t));
+ u_int8_t (*ramdac_rd) __P((void *, u_int));
+
+ int changed; /* what changed; see below */
+ char curcmap_r[2]; /* cursor colormap */
+ char curcmap_g[2];
+ char curcmap_b[2];
+ char cmap_r[BT463_NCMAP_ENTRIES]; /* colormap */
+ char cmap_g[BT463_NCMAP_ENTRIES];
+ char cmap_b[BT463_NCMAP_ENTRIES];
+ int window_type[16]; /* 16 24-bit window type table entries */
+};
+
+/* When we're doing console initialization, there's no
+ * way to get our cookie back to the video card's softc
+ * before we call sched_update. So we stash it here,
+ * and bt463_update will look for it here first.
+ */
+static struct bt463data *console_data;
+
+
+#define BTWREG(data, addr, val) do { bt463_wraddr((data), (addr)); \
+ (data)->ramdac_wr((data)->cookie, BT463_REG_IREG_DATA, (val)); } while (0)
+#define BTWNREG(data, val) (data)->ramdac_wr((data)->cookie, \
+ BT463_REG_IREG_DATA, (val))
+#define BTRREG(data, addr) (bt463_wraddr((data), (addr)), \
+ (data)->ramdac_rd((data)->cookie, BT463_REG_IREG_DATA))
+#define BTRNREG(data) ((data)->ramdac_rd((data)->cookie, BT463_REG_IREG_DATA))
+
+#define DATA_CURCMAP_CHANGED 0x01 /* cursor colormap changed */
+#define DATA_CMAP_CHANGED 0x02 /* colormap changed */
+#define DATA_WTYPE_CHANGED 0x04 /* window type table changed */
+#define DATA_ALL_CHANGED 0x07
+
+/*
+ * Internal functions.
+ */
+inline void bt463_wraddr __P((struct bt463data *, u_int16_t));
+
+void bt463_update __P((void *));
+
+
+/*****************************************************************************/
+
+/*
+ * Functions exported via the RAMDAC configuration table.
+ */
+
+struct ramdac_funcs *
+bt463_funcs(void)
+{
+ return &bt463_funcsstruct;
+}
+
+struct ramdac_cookie *
+bt463_register(v, sched_update, wr, rd)
+ void *v;
+ int (*sched_update)(void *, void (*)(void *));
+ void (*wr)(void *, u_int, u_int8_t);
+ u_int8_t (*rd)(void *, u_int);
+{
+ struct bt463data *data;
+ /*
+ * XXX -- comment out of date. rcd.
+ * If we should allocate a new private info struct, do so.
+ * Otherwise, use the one we have (if it's there), or
+ * use the temporary one on the stack.
+ */
+ data = malloc(sizeof *data, M_DEVBUF, M_WAITOK);
+ /* XXX -- if !data */
+ data->cookie = v;
+ data->ramdac_sched_update = sched_update;
+ data->ramdac_wr = wr;
+ data->ramdac_rd = rd;
+ return (struct ramdac_cookie *)data;
+}
+
+/*
+ * This function exists solely to provide a means to init
+ * the RAMDAC without first registering. It is useful for
+ * initializing the console early on.
+ */
+void
+bt463_cninit(v, sched_update, wr, rd)
+ void *v;
+ int (*sched_update)(void *, void (*)(void *));
+ void (*wr)(void *, u_int, u_int8_t);
+ u_int8_t (*rd)(void *, u_int);
+{
+ struct bt463data tmp, *data = &tmp;
+ data->cookie = v;
+ data->ramdac_sched_update = sched_update;
+ data->ramdac_wr = wr;
+ data->ramdac_rd = rd;
+ /* Set up console_data so that when bt463_update is called back,
+ * it can use the right information.
+ */
+ console_data = data;
+ bt463_init((struct ramdac_cookie *)data);
+ console_data = NULL;
+}
+
+void
+bt463_init(rc)
+ struct ramdac_cookie *rc;
+{
+ struct bt463data *data = (struct bt463data *)rc;
+
+ int i;
+
+ /*
+ * Init the BT463 for normal operation.
+ */
+
+
+ /*
+ * Setup:
+ * reg 0: 4:1 multiplexing, 25/75 blink.
+ * reg 1: Overlay mapping: mapped to common palette,
+ * 14 window type entries, 24-plane configuration mode,
+ * 4 overlay planes, underlays disabled, no cursor.
+ * reg 2: sync-on-green enabled, pedestal enabled.
+ */
+
+ BTWREG(data, BT463_IREG_COMMAND_0, 0x40);
+ BTWREG(data, BT463_IREG_COMMAND_1, 0x48);
+ BTWREG(data, BT463_IREG_COMMAND_2, 0xC0);
+
+ /*
+ * Initialize the read mask.
+ */
+ bt463_wraddr(data, BT463_IREG_READ_MASK_P0_P7);
+ for (i = 0; i < 4; i++)
+ BTWNREG(data, 0xff);
+
+ /*
+ * Initialize the blink mask.
+ */
+ bt463_wraddr(data, BT463_IREG_BLINK_MASK_P0_P7);
+ for (i = 0; i < 4; i++)
+ BTWNREG(data, 0);
+
+
+ /*
+ * Clear test register
+ */
+ BTWREG(data, BT463_IREG_TEST, 0);
+
+ /*
+ * Initalize the RAMDAC info struct to hold all of our
+ * data, and fill it in.
+ */
+ data->changed = DATA_ALL_CHANGED;
+
+ /* initial cursor colormap: 0 is black, 1 is white */
+ data->curcmap_r[0] = data->curcmap_g[0] = data->curcmap_b[0] = 0;
+ data->curcmap_r[1] = data->curcmap_g[1] = data->curcmap_b[1] = 0xff;
+
+ /* Initial colormap: 0 is black, everything else is white */
+ data->cmap_r[0] = data->cmap_g[0] = data->cmap_b[0] = 0;
+ for (i = 1; i < 256; i++)
+ data->cmap_r[i] = data->cmap_g[i] = data->cmap_b[i] = 255;
+
+
+ /* Initialize the window type table:
+ *
+ * Entry 0: 24-plane truecolor, overlays enabled, bypassed.
+ *
+ * Lookup table bypass: yes ( 1 << 23 & 0x800000) 800000
+ * Colormap address: 0x000 (0x000 << 17 & 0x7e0000) 0
+ * Overlay mask: 0xf ( 0xf << 13 & 0x01e000) 1e000
+ * Overlay location: P<27:24> ( 0 << 12 & 0x001000) 0
+ * Display mode: Truecolor ( 0 << 9 & 0x000e00) 000
+ * Number of planes: 8 ( 8 << 5 & 0x0001e0) 100
+ * Plane shift: 0 ( 0 << 0 & 0x00001f) 0
+ * --------
+ * 0x81e100
+ */
+ data->window_type[0] = 0x81e100;
+
+ /* Entry 1: 8-plane pseudocolor in the bottom 8 bits,
+ * overlays enabled, colormap starting at 0.
+ *
+ * Lookup table bypass: no ( 0 << 23 & 0x800000) 0
+ * Colormap address: 0x000 (0x000 << 17 & 0x7e0000) 0
+ * Overlay mask: 0xf ( 0xf << 13 & 0x01e000) 0x1e000
+ * Overlay location: P<27:24> ( 0 << 12 & 0x001000) 0
+ * Display mode: Pseudocolor ( 1 << 9 & 0x000e00) 0x200
+ * Number of planes: 8 ( 8 << 5 & 0x0001e0) 0x100
+ * Plane shift: 16 ( 0x10 << 0 & 0x00001f) 10
+ * --------
+ * 0x01e310
+ */
+ data->window_type[1] = 0x01e310;
+
+ /* The colormap interface to the world only supports one colormap,
+ * so having an entry for the 'alternate' colormap in the bt463
+ * probably isn't useful.
+ */
+
+ /* Fill the remaining table entries with clones of entry 0 until we
+ * figure out a better use for them.
+ */
+
+ for (i = 2; i < BT463_NWTYPE_ENTRIES; i++) {
+ data->window_type[i] = 0x81e100;
+ }
+
+ data->ramdac_sched_update(data->cookie, bt463_update);
+
+}
+
+int
+bt463_set_cmap(rc, cmapp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_cmap *cmapp;
+{
+ struct bt463data *data = (struct bt463data *)rc;
+ int count, index, s;
+
+ if ((u_int)cmapp->index >= BT463_NCMAP_ENTRIES ||
+ ((u_int)cmapp->index + (u_int)cmapp->count) > BT463_NCMAP_ENTRIES)
+ return (EINVAL);
+#if defined(UVM)
+ if (!uvm_useracc(cmapp->red, cmapp->count, B_READ) ||
+ !uvm_useracc(cmapp->green, cmapp->count, B_READ) ||
+ !uvm_useracc(cmapp->blue, cmapp->count, B_READ))
+ return (EFAULT);
+#else
+ if (!useracc(cmapp->red, cmapp->count, B_READ) ||
+ !useracc(cmapp->green, cmapp->count, B_READ) ||
+ !useracc(cmapp->blue, cmapp->count, B_READ))
+ return (EFAULT);
+#endif
+
+ s = spltty();
+
+ index = cmapp->index;
+ count = cmapp->count;
+ copyin(cmapp->red, &data->cmap_r[index], count);
+ copyin(cmapp->green, &data->cmap_g[index], count);
+ copyin(cmapp->blue, &data->cmap_b[index], count);
+
+ data->changed |= DATA_CMAP_CHANGED;
+
+ data->ramdac_sched_update(data->cookie, bt463_update);
+ splx(s);
+
+ return (0);
+}
+
+int
+bt463_get_cmap(rc, cmapp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_cmap *cmapp;
+{
+ struct bt463data *data = (struct bt463data *)rc;
+ int error, count, index;
+
+ if ((u_int)cmapp->index >= BT463_NCMAP_ENTRIES ||
+ ((u_int)cmapp->index + (u_int)cmapp->count) > BT463_NCMAP_ENTRIES)
+ return (EINVAL);
+
+ count = cmapp->count;
+ index = cmapp->index;
+
+ error = copyout(&data->cmap_r[index], cmapp->red, count);
+ if (error)
+ return (error);
+ error = copyout(&data->cmap_g[index], cmapp->green, count);
+ if (error)
+ return (error);
+ error = copyout(&data->cmap_b[index], cmapp->blue, count);
+ return (error);
+}
+
+int
+bt463_check_curcmap(rc, cursorp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_cursor *cursorp;
+{
+ int count;
+
+ if ((u_int)cursorp->cmap.index > 2 ||
+ ((u_int)cursorp->cmap.index +
+ (u_int)cursorp->cmap.count) > 2)
+ return (EINVAL);
+ count = cursorp->cmap.count;
+#if defined(UVM)
+ if (!uvm_useracc(cursorp->cmap.red, count, B_READ) ||
+ !uvm_useracc(cursorp->cmap.green, count, B_READ) ||
+ !uvm_useracc(cursorp->cmap.blue, count, B_READ))
+ return (EFAULT);
+#else
+ if (!useracc(cursorp->cmap.red, count, B_READ) ||
+ !useracc(cursorp->cmap.green, count, B_READ) ||
+ !useracc(cursorp->cmap.blue, count, B_READ))
+ return (EFAULT);
+#endif
+ return (0);
+}
+
+void
+bt463_set_curcmap(rc, cursorp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_cursor *cursorp;
+{
+ struct bt463data *data = (struct bt463data *)rc;
+ int count, index;
+
+ /* can't fail; parameters have already been checked. */
+ count = cursorp->cmap.count;
+ index = cursorp->cmap.index;
+ copyin(cursorp->cmap.red, &data->curcmap_r[index], count);
+ copyin(cursorp->cmap.green, &data->curcmap_g[index], count);
+ copyin(cursorp->cmap.blue, &data->curcmap_b[index], count);
+ data->changed |= DATA_CURCMAP_CHANGED;
+ data->ramdac_sched_update(data->cookie, bt463_update);
+}
+
+int
+bt463_get_curcmap(rc, cursorp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_cursor *cursorp;
+{
+ struct bt463data *data = (struct bt463data *)rc;
+ int error;
+
+ cursorp->cmap.index = 0; /* DOCMAP */
+ cursorp->cmap.count = 2;
+ if (cursorp->cmap.red != NULL) {
+ error = copyout(data->curcmap_r, cursorp->cmap.red, 2);
+ if (error)
+ return (error);
+ }
+ if (cursorp->cmap.green != NULL) {
+ error = copyout(data->curcmap_g, cursorp->cmap.green, 2);
+ if (error)
+ return (error);
+ }
+ if (cursorp->cmap.blue != NULL) {
+ error = copyout(data->curcmap_b, cursorp->cmap.blue, 2);
+ if (error)
+ return (error);
+ }
+ return (0);
+}
+
+
+/*****************************************************************************/
+
+/*
+ * Internal functions.
+ */
+
+#ifdef BT463_DEBUG
+int bt463_store(void *v)
+{
+ struct bt463data *data = (struct bt463data *)v;
+
+ data->changed = DATA_ALL_CHANGED;
+ data->ramdac_sched_update(data->cookie, bt463_update);
+ printf("Scheduled bt463 store\n");
+
+ return 0;
+}
+
+
+int bt463_readback(void *v)
+{
+ struct bt463data *data = (struct bt463data *)v;
+
+ data->ramdac_sched_update(data->cookie, bt463_copyback);
+ printf("Scheduled bt463 copyback\n");
+ return 0;
+}
+
+int
+bt463_debug(v)
+ void *v;
+{
+ struct bt463data *data = (struct bt463data *)v;
+ int i;
+ u_int8_t val;
+
+ printf("BT463 main regs:\n");
+ for (i = 0x200; i < 0x20F; i ++) {
+ val = BTRREG(data, i);
+ printf(" $%04x %02x\n", i, val);
+ }
+
+ printf("BT463 revision register:\n");
+ val = BTRREG(data, 0x220);
+ printf(" $%04x %02x\n", 0x220, val);
+
+ printf("BT463 window type table (from softc):\n");
+
+ for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
+ printf("%02x %06x\n", i, data->window_type[i]);
+ }
+
+ return 0;
+}
+
+void
+bt463_copyback(p)
+ void *p;
+{
+ struct bt463data *data = (struct bt463data *)p;
+ int i;
+
+ for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
+ bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
+ data->window_type[i] = (BTRNREG(data) & 0xff); /* B0-7 */
+ data->window_type[i] |= (BTRNREG(data) & 0xff) << 8; /* B8-15 */
+ data->window_type[i] |= (BTRNREG(data) & 0xff) << 16; /* B16-23 */
+ }
+}
+#endif
+
+inline void
+bt463_wraddr(data, ireg)
+ struct bt463data *data;
+ u_int16_t ireg;
+{
+ data->ramdac_wr(data->cookie, BT463_REG_ADDR_LOW, ireg & 0xff);
+ data->ramdac_wr(data->cookie, BT463_REG_ADDR_HIGH, (ireg >> 8) & 0xff);
+}
+
+void
+bt463_update(p)
+ void *p;
+{
+ struct bt463data *data = (struct bt463data *)p;
+ int i, v;
+
+ if (console_data != NULL) {
+ /* The cookie passed in from sched_update is incorrect. Use the
+ * right one.
+ */
+ data = console_data;
+ }
+
+ v = data->changed;
+
+ /* The Bt463 won't accept window type data except during a blanking
+ * interval, so we do this early in the interrupt.
+ * Blanking the screen might also be a good idea, but it can cause
+ * unpleasant flashing and is hard to do from this side of the
+ * ramdac interface.
+ */
+ if (v & DATA_WTYPE_CHANGED) {
+ /* spit out the window type data */
+ for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
+ bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
+ BTWNREG(data, (data->window_type[i]) & 0xff); /* B0-7 */
+ BTWNREG(data, (data->window_type[i] >> 8) & 0xff); /* B8-15 */
+ BTWNREG(data, (data->window_type[i] >> 16) & 0xff); /* B16-23 */
+ }
+ }
+
+ if (v & DATA_CURCMAP_CHANGED) {
+ bt463_wraddr(data, BT463_IREG_CURSOR_COLOR_0);
+ /* spit out the cursor data */
+ for (i = 0; i < 2; i++) {
+ BTWNREG(data, data->curcmap_r[i]);
+ BTWNREG(data, data->curcmap_g[i]);
+ BTWNREG(data, data->curcmap_b[i]);
+ }
+ }
+
+ if (v & DATA_CMAP_CHANGED) {
+ bt463_wraddr(data, BT463_IREG_CPALETTE_RAM);
+ /* spit out the colormap data */
+ for (i = 0; i < BT463_NCMAP_ENTRIES; i++) {
+ data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
+ data->cmap_r[i]);
+ data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
+ data->cmap_g[i]);
+ data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
+ data->cmap_b[i]);
+ }
+ }
+
+ data->changed = 0;
+}
+
+int bt463_set_cursor (rc, cur)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_cursor *cur;
+{
+ struct bt463data *data = (struct bt463data *)rc;
+ return tga_builtin_set_cursor(data->cookie, cur);
+}
+
+int bt463_get_cursor (rc, cur)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_cursor *cur;
+{
+ struct bt463data *data = (struct bt463data *)rc;
+ return tga_builtin_get_cursor(data->cookie, cur);
+}
+
+int bt463_set_curpos (rc, cur)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_curpos *cur;
+{
+ struct bt463data *data = (struct bt463data *)rc;
+ return tga_builtin_set_curpos(data->cookie, cur);
+}
+
+int bt463_get_curpos (rc, cur)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_curpos *cur;
+{
+ struct bt463data *data = (struct bt463data *)rc;
+ return tga_builtin_get_curpos(data->cookie, cur);
+}
+
+int bt463_get_curmax (rc, cur)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_curpos *cur;
+{
+ struct bt463data *data = (struct bt463data *)rc;
+ return tga_builtin_get_curmax(data->cookie, cur);
+}
diff --git a/sys/dev/ic/bt463var.h b/sys/dev/ic/bt463var.h
new file mode 100644
index 00000000000..a65b594a85a
--- /dev/null
+++ b/sys/dev/ic/bt463var.h
@@ -0,0 +1,48 @@
+/* $NetBSD: bt485var.h,v 1.1 2000/03/04 10:25:57 elric Exp $ */
+
+/*-
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Roland C. Dowdeswell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+struct ramdac_funcs *bt463_funcs(void);
+struct ramdac_cookie *bt463_register __P((void *,
+ int (*)(void *, void (*)(void *)),
+ void (*)(void *, u_int, u_int8_t),
+ u_int8_t (*)(void *, u_int)));
+void bt463_cninit __P((void *,
+ int (*)(void *, void (*)(void *)),
+ void (*)(void *, u_int, u_int8_t),
+ u_int8_t (*)(void *, u_int)));
diff --git a/sys/dev/ic/bt485.c b/sys/dev/ic/bt485.c
new file mode 100644
index 00000000000..1d0b5323f0f
--- /dev/null
+++ b/sys/dev/ic/bt485.c
@@ -0,0 +1,621 @@
+/* $NetBSD: bt485.c,v 1.2 2000/04/02 18:55:01 nathanw Exp $ */
+
+/*
+ * Copyright (c) 1995, 1996 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+ /* This code was derived from and originally located in sys/dev/pci/
+ * NetBSD: tga_bt485.c,v 1.4 1999/03/24 05:51:21 mrg Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/buf.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+
+#include <vm/vm.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/ic/bt485reg.h>
+#include <dev/ic/bt485var.h>
+#include <dev/ic/ramdac.h>
+
+#include <dev/wscons/wsconsio.h>
+
+/*
+ * Functions exported via the RAMDAC configuration table.
+ */
+void bt485_init __P((struct ramdac_cookie *));
+int bt485_set_cmap __P((struct ramdac_cookie *,
+ struct wsdisplay_cmap *));
+int bt485_get_cmap __P((struct ramdac_cookie *,
+ struct wsdisplay_cmap *));
+int bt485_set_cursor __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *));
+int bt485_get_cursor __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *));
+int bt485_set_curpos __P((struct ramdac_cookie *,
+ struct wsdisplay_curpos *));
+int bt485_get_curpos __P((struct ramdac_cookie *,
+ struct wsdisplay_curpos *));
+int bt485_get_curmax __P((struct ramdac_cookie *,
+ struct wsdisplay_curpos *));
+
+/* XXX const */
+struct ramdac_funcs bt485_funcsstruct = {
+ "Bt485",
+ bt485_register,
+ bt485_init,
+ bt485_set_cmap,
+ bt485_get_cmap,
+ bt485_set_cursor,
+ bt485_get_cursor,
+ bt485_set_curpos,
+ bt485_get_curpos,
+ bt485_get_curmax,
+ NULL, /* check_curcmap; not needed */
+ NULL, /* set_curcmap; not needed */
+ NULL, /* get_curcmap; not needed */
+};
+
+/*
+ * Private data.
+ */
+struct bt485data {
+ void *cookie; /* This is what is passed
+ * around, and is probably
+ * struct tga_devconfig *
+ */
+
+ int (*ramdac_sched_update) __P((void *, void (*)(void *)));
+ void (*ramdac_wr) __P((void *, u_int, u_int8_t));
+ u_int8_t (*ramdac_rd) __P((void *, u_int));
+
+ int changed; /* what changed; see below */
+ int curenb; /* cursor enabled */
+ struct wsdisplay_curpos curpos; /* current cursor position */
+ struct wsdisplay_curpos curhot; /* cursor hotspot */
+ char curcmap_r[2]; /* cursor colormap */
+ char curcmap_g[2];
+ char curcmap_b[2];
+ struct wsdisplay_curpos cursize; /* current cursor size */
+ char curimage[512]; /* cursor image data */
+ char curmask[512]; /* cursor mask data */
+ char cmap_r[256]; /* colormap */
+ char cmap_g[256];
+ char cmap_b[256];
+};
+
+#define DATA_ENB_CHANGED 0x01 /* cursor enable changed */
+#define DATA_CURCMAP_CHANGED 0x02 /* cursor colormap changed */
+#define DATA_CURSHAPE_CHANGED 0x04 /* cursor size, image, mask changed */
+#define DATA_CMAP_CHANGED 0x08 /* colormap changed */
+#define DATA_ALL_CHANGED 0x0f
+
+#define CURSOR_MAX_SIZE 64
+
+/*
+ * Internal functions.
+ */
+inline void bt485_wr_i __P((struct bt485data *, u_int8_t, u_int8_t));
+inline u_int8_t bt485_rd_i __P((struct bt485data *, u_int8_t));
+void bt485_update __P((void *));
+void bt485_update_curpos __P((struct bt485data *));
+
+/*****************************************************************************/
+
+/*
+ * Functions exported via the RAMDAC configuration table.
+ */
+
+struct ramdac_funcs *
+bt485_funcs(void)
+{
+ return &bt485_funcsstruct;
+}
+
+struct ramdac_cookie *
+bt485_register(v, sched_update, wr, rd)
+ void *v;
+ int (*sched_update)(void *, void (*)(void *));
+ void (*wr)(void *, u_int, u_int8_t);
+ u_int8_t (*rd)(void *, u_int);
+{
+ struct bt485data *data;
+ /*
+ * XXX -- comment out of date. rcd.
+ * If we should allocate a new private info struct, do so.
+ * Otherwise, use the one we have (if it's there), or
+ * use the temporary one on the stack.
+ */
+ data = malloc(sizeof *data, M_DEVBUF, M_WAITOK);
+ /* XXX -- if !data */
+ data->cookie = v;
+ data->ramdac_sched_update = sched_update;
+ data->ramdac_wr = wr;
+ data->ramdac_rd = rd;
+ return (struct ramdac_cookie *)data;
+}
+
+/*
+ * This function exists solely to provide a means to init
+ * the RAMDAC without first registering. It is useful for
+ * initializing the console early on.
+ */
+void
+bt485_cninit(v, sched_update, wr, rd)
+ void *v;
+ int (*sched_update)(void *, void (*)(void *));
+ void (*wr)(void *, u_int, u_int8_t);
+ u_int8_t (*rd)(void *, u_int);
+{
+ struct bt485data tmp, *data = &tmp;
+ data->cookie = v;
+ data->ramdac_sched_update = sched_update;
+ data->ramdac_wr = wr;
+ data->ramdac_rd = rd;
+ bt485_init((struct ramdac_cookie *)data);
+}
+
+void
+bt485_init(rc)
+ struct ramdac_cookie *rc;
+{
+ u_int8_t regval;
+ struct bt485data *data = (struct bt485data *)rc;
+ int i;
+
+ /*
+ * Init the BT485 for normal operation.
+ */
+
+ /*
+ * Allow indirect register access. (Actually, this is
+ * already enabled. In fact, if it is _disabled_, for
+ * some reason the monitor appears to lose sync!!! (?!?!)
+ */
+ regval = data->ramdac_rd(data->cookie, BT485_REG_COMMAND_0);
+ regval |= 0x80;
+ /*
+ * Set the RAMDAC to 8 bit resolution, rather than 6 bit
+ * resolution.
+ */
+ regval |= 0x02;
+ data->ramdac_wr(data->cookie, BT485_REG_COMMAND_0, regval);
+
+ /* Set the RAMDAC to 8BPP (no interestion options). */
+ data->ramdac_wr(data->cookie, BT485_REG_COMMAND_1, 0x40);
+
+ /* Disable the cursor (for now) */
+ regval = data->ramdac_rd(data->cookie, BT485_REG_COMMAND_2);
+ regval &= ~0x03;
+ regval |= 0x24;
+ data->ramdac_wr(data->cookie, BT485_REG_COMMAND_2, regval);
+
+ /* Use a 64x64x2 cursor */
+ regval = bt485_rd_i(data, BT485_IREG_COMMAND_3);
+ regval |= 0x04;
+ regval |= 0x08;
+ bt485_wr_i(data, BT485_IREG_COMMAND_3, regval);
+
+ /* Set the Pixel Mask to something useful */
+ data->ramdac_wr(data->cookie, BT485_REG_PIXMASK, 0xff);
+
+ /*
+ * Initalize the RAMDAC info struct to hold all of our
+ * data, and fill it in.
+ */
+ data->changed = DATA_ALL_CHANGED;
+
+ data->curenb = 0; /* cursor disabled */
+ data->curpos.x = data->curpos.y = 0; /* right now at 0,0 */
+ data->curhot.x = data->curhot.y = 0; /* hot spot at 0,0 */
+
+ /* initial cursor colormap: 0 is black, 1 is white */
+ data->curcmap_r[0] = data->curcmap_g[0] = data->curcmap_b[0] = 0;
+ data->curcmap_r[1] = data->curcmap_g[1] = data->curcmap_b[1] = 0xff;
+
+ /* initial cursor data: 64x64 block of white. */
+ data->cursize.x = data->cursize.y = 64;
+ for (i = 0; i < 512; i++)
+ data->curimage[i] = data->curmask[i] = 0xff;
+
+ /* Initial colormap: 0 is black, everything else is white */
+ data->cmap_r[0] = data->cmap_g[0] = data->cmap_b[0] = 0;
+ for (i = 1; i < 256; i++)
+ data->cmap_r[i] = data->cmap_g[i] = data->cmap_b[i] = 255;
+
+ bt485_update((void *)data);
+}
+
+int
+bt485_set_cmap(rc, cmapp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_cmap *cmapp;
+{
+ struct bt485data *data = (struct bt485data *)rc;
+ int count, index, s;
+
+ if ((u_int)cmapp->index >= 256 ||
+ ((u_int)cmapp->index + (u_int)cmapp->count) > 256)
+ return (EINVAL);
+#if defined(UVM)
+ if (!uvm_useracc(cmapp->red, cmapp->count, B_READ) ||
+ !uvm_useracc(cmapp->green, cmapp->count, B_READ) ||
+ !uvm_useracc(cmapp->blue, cmapp->count, B_READ))
+ return (EFAULT);
+#else
+ if (!useracc(cmapp->red, cmapp->count, B_READ) ||
+ !useracc(cmapp->green, cmapp->count, B_READ) ||
+ !useracc(cmapp->blue, cmapp->count, B_READ))
+ return (EFAULT);
+#endif
+
+ s = spltty();
+
+ index = cmapp->index;
+ count = cmapp->count;
+ copyin(cmapp->red, &data->cmap_r[index], count);
+ copyin(cmapp->green, &data->cmap_g[index], count);
+ copyin(cmapp->blue, &data->cmap_b[index], count);
+
+ data->changed |= DATA_CMAP_CHANGED;
+
+ data->ramdac_sched_update(data->cookie, bt485_update);
+ splx(s);
+
+ return (0);
+}
+
+int
+bt485_get_cmap(rc, cmapp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_cmap *cmapp;
+{
+ struct bt485data *data = (struct bt485data *)rc;
+ int error, count, index;
+
+ if ((u_int)cmapp->index >= 256 ||
+ ((u_int)cmapp->index + (u_int)cmapp->count) > 256)
+ return (EINVAL);
+
+ count = cmapp->count;
+ index = cmapp->index;
+
+ error = copyout(&data->cmap_r[index], cmapp->red, count);
+ if (error)
+ return (error);
+ error = copyout(&data->cmap_g[index], cmapp->green, count);
+ if (error)
+ return (error);
+ error = copyout(&data->cmap_b[index], cmapp->blue, count);
+ return (error);
+}
+
+int
+bt485_set_cursor(rc, cursorp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_cursor *cursorp;
+{
+ struct bt485data *data = (struct bt485data *)rc;
+ int count, index, v, s;
+
+ v = cursorp->which;
+
+ /*
+ * For DOCMAP and DOSHAPE, verify that parameters are OK
+ * before we do anything that we can't recover from.
+ */
+ if (v & WSDISPLAY_CURSOR_DOCMAP) {
+ if ((u_int)cursorp->cmap.index > 2 ||
+ ((u_int)cursorp->cmap.index +
+ (u_int)cursorp->cmap.count) > 2)
+ return (EINVAL);
+ count = cursorp->cmap.count;
+#if defined(UVM)
+ if (!uvm_useracc(cursorp->cmap.red, count, B_READ) ||
+ !uvm_useracc(cursorp->cmap.green, count, B_READ) ||
+ !uvm_useracc(cursorp->cmap.blue, count, B_READ))
+ return (EFAULT);
+#else
+ if (!useracc(cursorp->cmap.red, count, B_READ) ||
+ !useracc(cursorp->cmap.green, count, B_READ) ||
+ !useracc(cursorp->cmap.blue, count, B_READ))
+ return (EFAULT);
+#endif
+ }
+ if (v & WSDISPLAY_CURSOR_DOSHAPE) {
+ if ((u_int)cursorp->size.x > CURSOR_MAX_SIZE ||
+ (u_int)cursorp->size.y > CURSOR_MAX_SIZE)
+ return (EINVAL);
+ count = (CURSOR_MAX_SIZE / NBBY) * data->cursize.y;
+#if defined(UVM)
+ if (!uvm_useracc(cursorp->image, count, B_READ) ||
+ !uvm_useracc(cursorp->mask, count, B_READ))
+ return (EFAULT);
+#else
+ if (!useracc(cursorp->image, count, B_READ) ||
+ !useracc(cursorp->mask, count, B_READ))
+ return (EFAULT);
+#endif
+ }
+
+ if (v & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOCUR)) {
+ if (v & WSDISPLAY_CURSOR_DOPOS)
+ data->curpos = cursorp->pos;
+ if (v & WSDISPLAY_CURSOR_DOCUR)
+ data->curhot = cursorp->hot;
+ bt485_update_curpos(data);
+ }
+
+ s = spltty();
+
+ /* Parameters are OK; perform the requested operations. */
+ if (v & WSDISPLAY_CURSOR_DOCUR) {
+ data->curenb = cursorp->enable;
+ data->changed |= DATA_ENB_CHANGED;
+ }
+ if (v & WSDISPLAY_CURSOR_DOCMAP) {
+ count = cursorp->cmap.count;
+ index = cursorp->cmap.index;
+ copyin(cursorp->cmap.red, &data->curcmap_r[index], count);
+ copyin(cursorp->cmap.green, &data->curcmap_g[index], count);
+ copyin(cursorp->cmap.blue, &data->curcmap_b[index], count);
+ data->changed |= DATA_CURCMAP_CHANGED;
+ }
+ if (v & WSDISPLAY_CURSOR_DOSHAPE) {
+ data->cursize = cursorp->size;
+ count = (CURSOR_MAX_SIZE / NBBY) * data->cursize.y;
+ bzero(data->curimage, sizeof data->curimage);
+ bzero(data->curmask, sizeof data->curmask);
+ copyin(cursorp->image, data->curimage, count); /* can't fail */
+ copyin(cursorp->mask, data->curmask, count); /* can't fail */
+ data->changed |= DATA_CURSHAPE_CHANGED;
+ }
+
+ if (data->changed)
+ data->ramdac_sched_update(data->cookie, bt485_update);
+ splx(s);
+
+ return (0);
+}
+
+int
+bt485_get_cursor(rc, cursorp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_cursor *cursorp;
+{
+ struct bt485data *data = (struct bt485data *)rc;
+ int error, count;
+
+ /* we return everything they want */
+ cursorp->which = WSDISPLAY_CURSOR_DOALL;
+
+ cursorp->enable = data->curenb; /* DOCUR */
+ cursorp->pos = data->curpos; /* DOPOS */
+ cursorp->hot = data->curhot; /* DOHOT */
+
+ cursorp->cmap.index = 0; /* DOCMAP */
+ cursorp->cmap.count = 2;
+ if (cursorp->cmap.red != NULL) {
+ error = copyout(data->curcmap_r, cursorp->cmap.red, 2);
+ if (error)
+ return (error);
+ }
+ if (cursorp->cmap.green != NULL) {
+ error = copyout(data->curcmap_g, cursorp->cmap.green, 2);
+ if (error)
+ return (error);
+ }
+ if (cursorp->cmap.blue != NULL) {
+ error = copyout(data->curcmap_b, cursorp->cmap.blue, 2);
+ if (error)
+ return (error);
+ }
+
+ cursorp->size = data->cursize; /* DOSHAPE */
+ if (cursorp->image != NULL) {
+ count = (CURSOR_MAX_SIZE / NBBY) * data->cursize.y;
+ error = copyout(data->curimage, cursorp->image, count);
+ if (error)
+ return (error);
+ error = copyout(data->curmask, cursorp->mask, count);
+ if (error)
+ return (error);
+ }
+
+ return (0);
+}
+
+int
+bt485_set_curpos(rc, curposp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_curpos *curposp;
+{
+ struct bt485data *data = (struct bt485data *)rc;
+
+ data->curpos = *curposp;
+ bt485_update_curpos(data);
+
+ return (0);
+}
+
+int
+bt485_get_curpos(rc, curposp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_curpos *curposp;
+{
+ struct bt485data *data = (struct bt485data *)rc;
+
+ *curposp = data->curpos;
+ return (0);
+}
+
+int
+bt485_get_curmax(rc, curposp)
+ struct ramdac_cookie *rc;
+ struct wsdisplay_curpos *curposp;
+{
+
+ curposp->x = curposp->y = CURSOR_MAX_SIZE;
+ return (0);
+}
+
+/*****************************************************************************/
+
+/*
+ * Internal functions.
+ */
+
+inline void
+bt485_wr_i(data, ireg, val)
+ struct bt485data *data;
+ u_int8_t ireg;
+ u_int8_t val;
+{
+ data->ramdac_wr(data->cookie, BT485_REG_PCRAM_WRADDR, ireg);
+ data->ramdac_wr(data->cookie, BT485_REG_EXTENDED, val);
+}
+
+inline u_int8_t
+bt485_rd_i(data, ireg)
+ struct bt485data *data;
+ u_int8_t ireg;
+{
+ data->ramdac_wr(data->cookie, BT485_REG_PCRAM_WRADDR, ireg);
+ return (data->ramdac_rd(data->cookie, BT485_REG_EXTENDED));
+}
+
+void
+bt485_update(vp)
+ void *vp;
+{
+ struct bt485data *data = vp;
+ u_int8_t regval;
+ int count, i, v;
+
+ v = data->changed;
+ data->changed = 0;
+
+ if (v & DATA_ENB_CHANGED) {
+ regval = data->ramdac_rd(data->cookie, BT485_REG_COMMAND_2);
+ if (data->curenb)
+ regval |= 0x01;
+ else
+ regval &= ~0x03;
+ data->ramdac_wr(data->cookie, BT485_REG_COMMAND_2, regval);
+ }
+
+ if (v & DATA_CURCMAP_CHANGED) {
+ /* addr[9:0] assumed to be 0 */
+ /* set addr[7:0] to 1 */
+ data->ramdac_wr(data->cookie, BT485_REG_COC_WRADDR, 0x01);
+
+ /* spit out the cursor data */
+ for (i = 0; i < 2; i++) {
+ data->ramdac_wr(data->cookie, BT485_REG_COCDATA,
+ data->curcmap_r[i]);
+ data->ramdac_wr(data->cookie, BT485_REG_COCDATA,
+ data->curcmap_g[i]);
+ data->ramdac_wr(data->cookie, BT485_REG_COCDATA,
+ data->curcmap_b[i]);
+ }
+ }
+
+ if (v & DATA_CURSHAPE_CHANGED) {
+ count = (CURSOR_MAX_SIZE / NBBY) * data->cursize.y;
+
+ /*
+ * Write the cursor image data:
+ * set addr[9:8] to 0,
+ * set addr[7:0] to 0,
+ * spit it all out.
+ */
+ regval = bt485_rd_i(data, BT485_IREG_COMMAND_3);
+ regval &= ~0x03;
+ bt485_wr_i(data, BT485_IREG_COMMAND_3, regval);
+ data->ramdac_wr(data->cookie, BT485_REG_PCRAM_WRADDR, 0);
+ for (i = 0; i < count; i++)
+ data->ramdac_wr(data->cookie, BT485_REG_CURSOR_RAM,
+ data->curimage[i]);
+
+ /*
+ * Write the cursor mask data:
+ * set addr[9:8] to 2,
+ * set addr[7:0] to 0,
+ * spit it all out.
+ */
+ regval = bt485_rd_i(data, BT485_IREG_COMMAND_3);
+ regval &= ~0x03; regval |= 0x02;
+ bt485_wr_i(data, BT485_IREG_COMMAND_3, regval);
+ data->ramdac_wr(data->cookie, BT485_REG_PCRAM_WRADDR, 0);
+ for (i = 0; i < count; i++)
+ data->ramdac_wr(data->cookie, BT485_REG_CURSOR_RAM,
+ data->curmask[i]);
+
+ /* set addr[9:0] back to 0 */
+ regval = bt485_rd_i(data, BT485_IREG_COMMAND_3);
+ regval &= ~0x03;
+ bt485_wr_i(data, BT485_IREG_COMMAND_3, regval);
+ }
+
+ if (v & DATA_CMAP_CHANGED) {
+ /* addr[9:0] assumed to be 0 */
+ /* set addr[7:0] to 0 */
+ data->ramdac_wr(data->cookie, BT485_REG_PCRAM_WRADDR, 0x00);
+
+ /* spit out the cursor data */
+ for (i = 0; i < 256; i++) {
+ data->ramdac_wr(data->cookie, BT485_REG_PALETTE,
+ data->cmap_r[i]);
+ data->ramdac_wr(data->cookie, BT485_REG_PALETTE,
+ data->cmap_g[i]);
+ data->ramdac_wr(data->cookie, BT485_REG_PALETTE,
+ data->cmap_b[i]);
+ }
+ }
+}
+
+void
+bt485_update_curpos(data)
+ struct bt485data *data;
+{
+ void *cookie = data->cookie;
+ int s, x, y;
+
+ s = spltty();
+
+ x = data->curpos.x + CURSOR_MAX_SIZE - data->curhot.x;
+ y = data->curpos.y + CURSOR_MAX_SIZE - data->curhot.y;
+ data->ramdac_wr(cookie, BT485_REG_CURSOR_X_LOW, x & 0xff);
+ data->ramdac_wr(cookie, BT485_REG_CURSOR_X_HIGH, (x >> 8) & 0x0f);
+ data->ramdac_wr(cookie, BT485_REG_CURSOR_Y_LOW, y & 0xff);
+ data->ramdac_wr(cookie, BT485_REG_CURSOR_Y_HIGH, (y >> 8) & 0x0f);
+
+ splx(s);
+}
diff --git a/sys/dev/ic/bt485var.h b/sys/dev/ic/bt485var.h
new file mode 100644
index 00000000000..39893742c63
--- /dev/null
+++ b/sys/dev/ic/bt485var.h
@@ -0,0 +1,48 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Roland C. Dowdeswell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+struct ramdac_funcs *bt485_funcs(void);
+struct ramdac_cookie *bt485_register __P((void *,
+ int (*)(void *, void (*)(void *)),
+ void (*)(void *, u_int, u_int8_t),
+ u_int8_t (*)(void *, u_int)));
+void bt485_cninit __P((void *,
+ int (*)(void *, void (*)(void *)),
+ void (*)(void *, u_int, u_int8_t),
+ u_int8_t (*)(void *, u_int)));
diff --git a/sys/dev/ic/decmonitors.c b/sys/dev/ic/decmonitors.c
new file mode 100644
index 00000000000..4fcb1df4c7b
--- /dev/null
+++ b/sys/dev/ic/decmonitors.c
@@ -0,0 +1,129 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Roland C. Dowdeswell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <dev/ic/monitors.h>
+
+#define MHz * 1000000
+#define KHz * 1000
+
+struct monitor decmonitors[] = {
+ /* 0x0: 1280 x 1024 @ 72Hz */
+ { 1280, 32, 160, 232,
+ 1024, 3, 3, 33,
+ 130808 KHz },
+
+ /* 0x1: 1280 x 1024 @ 66Hz */
+ { 1280, 32, 160, 232,
+ 1024, 3, 3, 33,
+ 119840 KHz },
+
+ /* 0x2: 1280 x 1024 @ 60Hz */
+ { 1280, 44, 184, 200,
+ 1024, 3, 3, 26,
+ 108180 KHz },
+
+ /* 0x3: 1152 x 900 @ 72Hz */
+ { 1152, 64, 112, 176,
+ 900, 6, 10, 44,
+ 103994 KHz },
+
+ /* 0x4: 1600 x 1200 @ 65Hz */
+ { 1600, 32, 192, 336,
+ 1200, 1, 3, 46,
+ 175 MHz },
+
+ /* 0x5: 1024 x 768 @ 70Hz */
+ { 1024, 24, 136, 144,
+ 768, 3, 6, 29,
+ 75 MHz },
+
+ /* 0x6: 1024 x 768 @ 72Hz */
+ { 1024, 16, 128, 128,
+ 768, 1, 6, 22,
+ 74 MHz },
+
+ /* 0x7: 1024 x 864 @ 60Hz */
+ { 1024, 12, 128, 116,
+ 864, 0, 3, 34,
+ 69 MHz },
+
+ /* 0x8: 1024 x 768 @ 60Hz */
+ { 1024, 56, 64, 200,
+ 768, 7, 9, 26,
+ 65 MHz },
+
+ /* 0x9: 800 x 600 @ 72Hz */
+ { 800, 56, 120, 64,
+ 600, 37, 6, 23,
+ 50 MHz },
+
+ /* 0xa: 800 x 600 @ 60Hz */
+ { 800, 40, 128, 88,
+ 600, 1, 4, 23,
+ 40 MHz },
+
+ /* 0xb: 640 x 480 @ 72Hz */
+ { 640, 24, 40, 128,
+ 480, 9, 3, 28,
+ 31500 KHz },
+
+ /* 0xc: 640 x 480 @ 60Hz */
+ { 640, 16, 96, 48,
+ 480, 10, 2, 33,
+ 25175 KHz },
+
+ /* 0xd: 1280 x 1024 @ 75Hz */
+ { 1280, 16, 144, 248,
+ 1024, 1, 3, 38,
+ 135 MHz },
+
+ /* 0xe: 1280 x 1024 @ 60Hz */
+ { 1280, 19, 163, 234,
+ 1024, 6, 7, 44,
+ 110 MHz },
+
+ /* 0xf: 1600 x 1200 @ 75Hz */
+ /* XXX -- this one's weird. rcd */
+ { 1600, 32, 192, 336,
+ 1200, 1, 3, 46,
+ 202500 KHz }
+};
+
+#undef MHz
+#undef KHz
diff --git a/sys/dev/ic/monitors.h b/sys/dev/ic/monitors.h
new file mode 100644
index 00000000000..0615002385d
--- /dev/null
+++ b/sys/dev/ic/monitors.h
@@ -0,0 +1,56 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Roland C. Dowdeswell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DEV_IC_MONITORS_H
+#define _DEV_IC_MONITORS_H
+
+#include <sys/types.h>
+
+struct monitor {
+ u_int16_t cols; /* Columns */
+ u_int16_t hfp; /* Horizontal Front Porch */
+ u_int16_t hsync; /* Horizontal Sync */
+ u_int16_t hbp; /* Horizontal Back Porch */
+ u_int16_t rows; /* Rows */
+ u_int16_t vfp; /* Vertical Front Porch */
+ u_int16_t vsync; /* Vertical Sync */
+ u_int16_t vbp; /* Vertical Back Porch */
+ u_int32_t dotclock; /* Dot Clock */
+};
+
+#endif
diff --git a/sys/dev/ic/ramdac.h b/sys/dev/ic/ramdac.h
new file mode 100644
index 00000000000..5f9f57afbb7
--- /dev/null
+++ b/sys/dev/ic/ramdac.h
@@ -0,0 +1,80 @@
+/* $NetBSD: ramdac.h,v 1.1 2000/03/04 10:23:39 elric Exp $ */
+
+/*-
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Roland C. Dowdeswell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DEV_IC_RAMDAC_H
+#define _DEV_IC_RAMDAC_H
+
+#include <dev/rcons/raster.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wscons_raster.h>
+
+struct ramdac_cookie;
+
+struct ramdac_funcs {
+ char *ramdac_name;
+ struct ramdac_cookie *(*ramdac_register) __P((void *,
+ int (*)(void *, void (*)(void *)),
+ void (*)(void *, u_int, u_int8_t),
+ u_int8_t (*)(void *, u_int)));
+ void (*ramdac_init) __P((struct ramdac_cookie *));
+
+ int (*ramdac_set_cmap) __P((struct ramdac_cookie *,
+ struct wsdisplay_cmap *));
+ int (*ramdac_get_cmap) __P((struct ramdac_cookie *,
+ struct wsdisplay_cmap *));
+ int (*ramdac_set_cursor) __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *));
+ int (*ramdac_get_cursor) __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *));
+ int (*ramdac_set_curpos) __P((struct ramdac_cookie *,
+ struct wsdisplay_curpos *));
+ int (*ramdac_get_curpos) __P((struct ramdac_cookie *,
+ struct wsdisplay_curpos *));
+ int (*ramdac_get_curmax) __P((struct ramdac_cookie *,
+ struct wsdisplay_curpos *));
+
+ /* Only called from the TGA built-in cursor handling code. */
+ int (*ramdac_check_curcmap) __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *));
+ void (*ramdac_set_curcmap) __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *));
+ int (*ramdac_get_curcmap) __P((struct ramdac_cookie *,
+ struct wsdisplay_cursor *));
+};
+
+#endif