Home | History | Annotate | Line # | Download | only in ic
      1 /* $NetBSD: bt463.c,v 1.18 2018/01/24 05:35:58 riastradh Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  * POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 /*
     34  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
     35  * All rights reserved.
     36  *
     37  * Author: Chris G. Demetriou
     38  *
     39  * Permission to use, copy, modify and distribute this software and
     40  * its documentation is hereby granted, provided that both the copyright
     41  * notice and this permission notice appear in all copies of the
     42  * software, derivative works or modified versions, and any portions
     43  * thereof, and that both notices appear in supporting documentation.
     44  *
     45  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     46  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     47  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     48  *
     49  * Carnegie Mellon requests users of this software to return to
     50  *
     51  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     52  *  School of Computer Science
     53  *  Carnegie Mellon University
     54  *  Pittsburgh PA 15213-3890
     55  *
     56  * any improvements or extensions that they make and grant Carnegie the
     57  * rights to redistribute these changes.
     58  */
     59 
     60  /* This code was derived from and originally located in sys/dev/pci/
     61   *	 NetBSD: tga_bt463.c,v 1.5 2000/03/04 10:27:59 elric Exp
     62   */
     63 
     64 #include <sys/cdefs.h>
     65 __KERNEL_RCSID(0, "$NetBSD: bt463.c,v 1.18 2018/01/24 05:35:58 riastradh Exp $");
     66 
     67 #include <sys/param.h>
     68 #include <sys/systm.h>
     69 #include <sys/device.h>
     70 #include <sys/buf.h>
     71 #include <sys/kernel.h>
     72 #include <sys/malloc.h>
     73 
     74 #include <dev/pci/pcivar.h>
     75 #include <dev/pci/tgareg.h>
     76 #include <dev/pci/tgavar.h>
     77 #include <dev/ic/bt463reg.h>
     78 #include <dev/ic/bt463var.h>
     79 
     80 #include <dev/wscons/wsconsio.h>
     81 
     82 /*
     83  * Functions exported via the RAMDAC configuration table.
     84  */
     85 void	bt463_init(struct ramdac_cookie *);
     86 int	bt463_set_cmap(struct ramdac_cookie *, struct wsdisplay_cmap *);
     87 int	bt463_get_cmap(struct ramdac_cookie *, struct wsdisplay_cmap *);
     88 int	bt463_set_cursor(struct ramdac_cookie *, struct wsdisplay_cursor *);
     89 int	bt463_get_cursor(struct ramdac_cookie *, struct wsdisplay_cursor *);
     90 int	bt463_set_curpos(struct ramdac_cookie *, struct wsdisplay_curpos *);
     91 int	bt463_get_curpos(struct ramdac_cookie *, struct wsdisplay_curpos *);
     92 int	bt463_get_curmax(struct ramdac_cookie *, struct wsdisplay_curpos *);
     93 int	bt463_check_curcmap(struct ramdac_cookie *,
     94 	    struct wsdisplay_cursor *cursorp);
     95 void	bt463_set_curcmap(struct ramdac_cookie *,
     96 	    struct wsdisplay_cursor *cursorp);
     97 int	bt463_get_curcmap(struct ramdac_cookie *,
     98 	    struct wsdisplay_cursor *cursorp);
     99 
    100 #ifdef BT463_DEBUG
    101 int bt463_store(void *);
    102 int bt463_debug(void *);
    103 int bt463_readback(void *);
    104 void	bt463_copyback(void *);
    105 #endif
    106 
    107 struct ramdac_funcs bt463_funcsstruct = {
    108 	"Bt463",
    109 	bt463_register,
    110 	bt463_init,
    111 	bt463_set_cmap,
    112 	bt463_get_cmap,
    113 	bt463_set_cursor,
    114 	bt463_get_cursor,
    115 	bt463_set_curpos,
    116 	bt463_get_curpos,
    117 	bt463_get_curmax,
    118 	bt463_check_curcmap,
    119 	bt463_set_curcmap,
    120 	bt463_get_curcmap,
    121 	NULL,
    122 };
    123 
    124 /*
    125  * Private data.
    126  */
    127 struct bt463data {
    128 	void            *cookie;        /* This is what is passed
    129 					 * around, and is probably
    130 					 * struct tga_devconfig *
    131 					 */
    132 
    133 	int             (*ramdac_sched_update)(void *, void (*)(void *));
    134 	void            (*ramdac_wr)(void *, u_int, u_int8_t);
    135 	u_int8_t        (*ramdac_rd)(void *, u_int);
    136 
    137 	int	changed;			/* what changed; see below */
    138 	char curcmap_r[2];			/* cursor colormap */
    139 	char curcmap_g[2];
    140 	char curcmap_b[2];
    141 	char tmpcurcmap_r[2];			/* tmp cursor colormap */
    142 	char tmpcurcmap_g[2];
    143 	char tmpcurcmap_b[2];
    144 	char cmap_r[BT463_NCMAP_ENTRIES];	/* colormap */
    145 	char cmap_g[BT463_NCMAP_ENTRIES];
    146 	char cmap_b[BT463_NCMAP_ENTRIES];
    147 	int window_type[16]; /* 16 24-bit window type table entries */
    148 };
    149 
    150 /* When we're doing console initialization, there's no
    151  * way to get our cookie back to the video card's softc
    152  * before we call sched_update. So we stash it here,
    153  * and bt463_update will look for it here first.
    154  */
    155 static struct bt463data *console_data;
    156 
    157 
    158 #define BTWREG(data, addr, val) do { bt463_wraddr((data), (addr)); \
    159 	(data)->ramdac_wr((data)->cookie, BT463_REG_IREG_DATA, (val)); } while (0)
    160 #define BTWNREG(data, val) (data)->ramdac_wr((data)->cookie, \
    161 	BT463_REG_IREG_DATA, (val))
    162 #define BTRREG(data, addr) (bt463_wraddr((data), (addr)), \
    163 	(data)->ramdac_rd((data)->cookie, BT463_REG_IREG_DATA))
    164 #define BTRNREG(data) ((data)->ramdac_rd((data)->cookie, BT463_REG_IREG_DATA))
    165 
    166 #define	DATA_CURCMAP_CHANGED	0x01	/* cursor colormap changed */
    167 #define	DATA_CMAP_CHANGED	0x02	/* colormap changed */
    168 #define	DATA_WTYPE_CHANGED	0x04	/* window type table changed */
    169 #define	DATA_ALL_CHANGED	0x07
    170 
    171 /*
    172  * Internal functions.
    173  */
    174 
    175 void	bt463_update(void *);
    176 
    177 static inline void
    178 bt463_wraddr(struct bt463data *data, u_int16_t ireg)
    179 {
    180 	data->ramdac_wr(data->cookie, BT463_REG_ADDR_LOW, ireg & 0xff);
    181 	data->ramdac_wr(data->cookie, BT463_REG_ADDR_HIGH, (ireg >> 8) & 0xff);
    182 }
    183 
    184 /*****************************************************************************/
    185 
    186 /*
    187  * Functions exported via the RAMDAC configuration table.
    188  */
    189 
    190 struct ramdac_funcs *
    191 bt463_funcs(void)
    192 {
    193 	return &bt463_funcsstruct;
    194 }
    195 
    196 struct ramdac_cookie *
    197 bt463_register(
    198 	void *v,
    199 	int (*sched_update)(void *, void (*)(void *)),
    200 	void (*wr)(void *, u_int, u_int8_t),
    201 	u_int8_t (*rd)(void *, u_int))
    202 {
    203 	struct bt463data *data;
    204 	/*
    205 	 * XXX -- comment out of date.  rcd.
    206 	 * If we should allocate a new private info struct, do so.
    207 	 * Otherwise, use the one we have (if it's there), or
    208 	 * use the temporary one on the stack.
    209 	 */
    210 	data = malloc(sizeof *data, M_DEVBUF, M_WAITOK);
    211 	/* XXX -- if !data */
    212 	data->cookie = v;
    213 	data->ramdac_sched_update = sched_update;
    214 	data->ramdac_wr = wr;
    215 	data->ramdac_rd = rd;
    216 	return (struct ramdac_cookie *)data;
    217 }
    218 
    219 /*
    220  * This function exists solely to provide a means to init
    221  * the RAMDAC without first registering.  It is useful for
    222  * initializing the console early on.
    223  */
    224 void
    225 bt463_cninit(
    226 	void *v,
    227 	int (*sched_update)(void *, void (*)(void *)),
    228 	void (*wr)(void *, u_int, u_int8_t),
    229 	u_int8_t (*rd)(void *, u_int))
    230 {
    231 	struct bt463data tmp, *data = &tmp;
    232 	data->cookie = v;
    233 	data->ramdac_sched_update = sched_update;
    234 	data->ramdac_wr = wr;
    235 	data->ramdac_rd = rd;
    236 	/* Set up console_data so that when bt463_update is called back,
    237 	 * it can use the right information.
    238 	 */
    239 	console_data = data;
    240 	bt463_init((struct ramdac_cookie *)data);
    241 	console_data = NULL;
    242 }
    243 
    244 void
    245 bt463_init(struct ramdac_cookie *rc)
    246 {
    247 	struct bt463data *data = (struct bt463data *)rc;
    248 
    249 	int i;
    250 
    251 	/*
    252 	 * Init the BT463 for normal operation.
    253 	 */
    254 
    255 
    256 	/*
    257 	 * Setup:
    258 	 * reg 0: 4:1 multiplexing, 25/75 blink.
    259 	 * reg 1: Overlay mapping: mapped to common palette,
    260 	 *        14 window type entries, 24-plane configuration mode,
    261 	 *        4 overlay planes, underlays disabled, no cursor.
    262 	 * reg 2: sync-on-green enabled, pedestal enabled.
    263 	 */
    264 
    265 	BTWREG(data, BT463_IREG_COMMAND_0, 0x40);
    266 	BTWREG(data, BT463_IREG_COMMAND_1, 0x48);
    267 	BTWREG(data, BT463_IREG_COMMAND_2, 0x40);
    268 
    269 	/*
    270 	 * Initialize the read mask.
    271 	 */
    272 	bt463_wraddr(data, BT463_IREG_READ_MASK_P0_P7);
    273 	for (i = 0; i < 4; i++)
    274 		BTWNREG(data, 0xff);
    275 
    276 	/*
    277 	 * Initialize the blink mask.
    278 	 */
    279 	bt463_wraddr(data, BT463_IREG_BLINK_MASK_P0_P7);
    280 	for (i = 0; i < 4; i++)
    281 		BTWNREG(data, 0);
    282 
    283 
    284 	/*
    285 	 * Clear test register
    286 	 */
    287 	BTWREG(data, BT463_IREG_TEST, 0);
    288 
    289 	/*
    290 	 * Initialize the RAMDAC info struct to hold all of our
    291 	 * data, and fill it in.
    292 	 */
    293 	data->changed = DATA_ALL_CHANGED;
    294 
    295 	/* initial cursor colormap: 0 is black, 1 is white */
    296 	data->curcmap_r[0] = data->curcmap_g[0] = data->curcmap_b[0] = 0;
    297 	data->curcmap_r[1] = data->curcmap_g[1] = data->curcmap_b[1] = 0xff;
    298 
    299 	/* Initial colormap: 0 is black, everything else is white */
    300 	data->cmap_r[0] = data->cmap_g[0] = data->cmap_b[0] = 0;
    301 	for (i = 1; i < 256; i++)
    302 		data->cmap_r[i] = data->cmap_g[i] = data->cmap_b[i] = 255;
    303 
    304 
    305 	/* Initialize the window type table:
    306 	 *
    307 	 * Entry 0: 24-plane truecolor, overlays enabled, bypassed.
    308 	 *
    309 	 *  Lookup table bypass:      yes (    1 << 23 & 0x800000)  800000
    310 	 *  Colormap address:       0x000 (0x000 << 17 & 0x7e0000)       0
    311 	 *  Overlay mask:             0xf (  0xf << 13 & 0x01e000)   1e000
    312 	 *  Overlay location:    P<27:24> (    0 << 12 & 0x001000)       0
    313 	 *  Display mode:       Truecolor (    0 <<  9 & 0x000e00)     000
    314 	 *  Number of planes:           8 (    8 <<  5 & 0x0001e0)     100
    315 	 *  Plane shift:                0 (    0 <<  0 & 0x00001f)       0
    316 	 *                                                        --------
    317 	 *                                                        0x81e100
    318 	 */
    319 	data->window_type[0] = 0x81e100;
    320 
    321 	/* Entry 1: 8-plane pseudocolor in the bottom 8 bits,
    322 	 *          overlays enabled, colormap starting at 0.
    323 	 *
    324 	 *  Lookup table bypass:       no (    0 << 23 & 0x800000)       0
    325 	 *  Colormap address:       0x000 (0x000 << 17 & 0x7e0000)       0
    326 	 *  Overlay mask:             0xf (  0xf << 13 & 0x01e000) 0x1e000
    327 	 *  Overlay location:    P<27:24> (    0 << 12 & 0x001000)       0
    328 	 *  Display mode:     Pseudocolor (    1 <<  9 & 0x000e00)   0x200
    329 	 *  Number of planes:           8 (    8 <<  5 & 0x0001e0)   0x100
    330 	 *  Plane shift:               16 ( 0x10 <<  0 & 0x00001f)      10
    331 	 *                                                        --------
    332 	 *                                                        0x01e310
    333 	 */
    334 	data->window_type[1] = 0x01e310;
    335 
    336 	/* The colormap interface to the world only supports one colormap,
    337 	 * so having an entry for the 'alternate' colormap in the bt463
    338 	 * probably isn't useful.
    339 	 */
    340 
    341 	/* Fill the remaining table entries with clones of entry 0 until we
    342 	 * figure out a better use for them.
    343 	 */
    344 
    345 	for (i = 2; i < BT463_NWTYPE_ENTRIES; i++) {
    346 		data->window_type[i] = 0x81e100;
    347 	}
    348 
    349 	data->ramdac_sched_update(data->cookie, bt463_update);
    350 
    351 }
    352 
    353 int
    354 bt463_set_cmap(struct ramdac_cookie *rc, struct wsdisplay_cmap *cmapp)
    355 {
    356 	struct bt463data *data = (struct bt463data *)rc;
    357 	u_int count, index;
    358 	uint8_t r[BT463_NCMAP_ENTRIES];
    359 	uint8_t g[BT463_NCMAP_ENTRIES];
    360 	uint8_t b[BT463_NCMAP_ENTRIES];
    361 	int s, error;
    362 
    363 	if (cmapp->index >= BT463_NCMAP_ENTRIES ||
    364 	    cmapp->count > BT463_NCMAP_ENTRIES - cmapp->index)
    365 		return (EINVAL);
    366 
    367 	index = cmapp->index;
    368 	count = cmapp->count;
    369 	error = copyin(cmapp->red, &r[index], count);
    370 	if (error)
    371 		return error;
    372 	error = copyin(cmapp->green, &g[index], count);
    373 	if (error)
    374 		return error;
    375 	error = copyin(cmapp->blue, &b[index], count);
    376 	if (error)
    377 		return error;
    378 	s = spltty();
    379 	memcpy(&data->cmap_r[index], &r[index], count);
    380 	memcpy(&data->cmap_g[index], &g[index], count);
    381 	memcpy(&data->cmap_b[index], &b[index], count);
    382  	data->changed |= DATA_CMAP_CHANGED;
    383 	data->ramdac_sched_update(data->cookie, bt463_update);
    384 	splx(s);
    385 	return (0);
    386 }
    387 
    388 int
    389 bt463_get_cmap(struct ramdac_cookie *rc, struct wsdisplay_cmap *cmapp)
    390 {
    391 	struct bt463data *data = (struct bt463data *)rc;
    392 	u_int count, index;
    393 	int error;
    394 
    395 	if (cmapp->index >= BT463_NCMAP_ENTRIES ||
    396 	    cmapp->count > BT463_NCMAP_ENTRIES - cmapp->index)
    397 		return (EINVAL);
    398 
    399 	count = cmapp->count;
    400 	index = cmapp->index;
    401 
    402 	error = copyout(&data->cmap_r[index], cmapp->red, count);
    403 	if (error)
    404 		return (error);
    405 	error = copyout(&data->cmap_g[index], cmapp->green, count);
    406 	if (error)
    407 		return (error);
    408 	error = copyout(&data->cmap_b[index], cmapp->blue, count);
    409 	return (error);
    410 }
    411 
    412 int
    413 bt463_check_curcmap(struct ramdac_cookie *rc, struct wsdisplay_cursor *cursorp)
    414 {
    415 	struct bt463data *data = (struct bt463data *)rc;
    416 	int count, index, error;
    417 
    418 	if (cursorp->cmap.index > 2 ||
    419 	    cursorp->cmap.count > 2 - cursorp->cmap.index)
    420 		return (EINVAL);
    421 	count = cursorp->cmap.count;
    422 	index = cursorp->cmap.index;
    423 	error = copyin(cursorp->cmap.red, &data->tmpcurcmap_r[index], count);
    424 	if (error)
    425 		return error;
    426 	error = copyin(cursorp->cmap.green, &data->tmpcurcmap_g[index], count);
    427 	if (error)
    428 		return error;
    429 	error = copyin(cursorp->cmap.blue, &data->tmpcurcmap_b[index], count);
    430 	if (error)
    431 		return error;
    432 	return (0);
    433 }
    434 
    435 void
    436 bt463_set_curcmap(struct ramdac_cookie *rc, struct wsdisplay_cursor *cursorp)
    437 {
    438 	struct bt463data *data = (struct bt463data *)rc;
    439 	int count, index;
    440 
    441 	count = cursorp->cmap.count;
    442 	index = cursorp->cmap.index;
    443 	memcpy(&data->curcmap_r[index], &data->tmpcurcmap_r[index], count);
    444 	memcpy(&data->curcmap_g[index], &data->tmpcurcmap_g[index], count);
    445 	memcpy(&data->curcmap_b[index], &data->tmpcurcmap_b[index], count);
    446 	data->changed |= DATA_CURCMAP_CHANGED;
    447 	data->ramdac_sched_update(data->cookie, bt463_update);
    448 }
    449 
    450 int
    451 bt463_get_curcmap(struct ramdac_cookie *rc, struct wsdisplay_cursor *cursorp)
    452 {
    453 	struct bt463data *data = (struct bt463data *)rc;
    454 	int error;
    455 
    456 	cursorp->cmap.index = 0;	/* DOCMAP */
    457 	cursorp->cmap.count = 2;
    458 	if (cursorp->cmap.red != NULL) {
    459 		error = copyout(data->curcmap_r, cursorp->cmap.red, 2);
    460 		if (error)
    461 			return (error);
    462 	}
    463 	if (cursorp->cmap.green != NULL) {
    464 		error = copyout(data->curcmap_g, cursorp->cmap.green, 2);
    465 		if (error)
    466 			return (error);
    467 	}
    468 	if (cursorp->cmap.blue != NULL) {
    469 		error = copyout(data->curcmap_b, cursorp->cmap.blue, 2);
    470 		if (error)
    471 			return (error);
    472 	}
    473 	return (0);
    474 }
    475 
    476 
    477 /*****************************************************************************/
    478 
    479 /*
    480  * Internal functions.
    481  */
    482 
    483 #ifdef BT463_DEBUG
    484 int bt463_store(void *v)
    485 {
    486 	struct bt463data *data = (struct bt463data *)v;
    487 
    488 	data->changed = DATA_ALL_CHANGED;
    489 	data->ramdac_sched_update(data->cookie, bt463_update);
    490 	printf("Scheduled bt463 store\n");
    491 
    492 	return 0;
    493 }
    494 
    495 
    496 int bt463_readback(void *v)
    497 {
    498 	struct bt463data *data = (struct bt463data *)v;
    499 
    500 	data->ramdac_sched_update(data->cookie, bt463_copyback);
    501 	printf("Scheduled bt463 copyback\n");
    502 	return 0;
    503 }
    504 
    505 int
    506 bt463_debug(void *v)
    507 {
    508 	struct bt463data *data = (struct bt463data *)v;
    509 	int i;
    510 	u_int8_t val;
    511 
    512 	printf("BT463 main regs:\n");
    513 	for (i = 0x200; i < 0x20F; i ++) {
    514 	  val = BTRREG(data, i);
    515 	  printf("  $%04x %02x\n", i, val);
    516 	}
    517 
    518 	printf("BT463 revision register:\n");
    519 	  val = BTRREG(data, 0x220);
    520 	  printf("  $%04x %02x\n", 0x220, val);
    521 
    522 	printf("BT463 window type table (from softc):\n");
    523 
    524 	for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
    525 	  printf("%02x %06x\n", i, data->window_type[i]);
    526 	}
    527 
    528 	return 0;
    529 }
    530 
    531 void
    532 bt463_copyback(void *p)
    533 {
    534 	struct bt463data *data = (struct bt463data *)p;
    535 	int i;
    536 
    537 		for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
    538 			bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
    539 			data->window_type[i] = (BTRNREG(data) & 0xff);        /* B0-7   */
    540 			data->window_type[i] |= (BTRNREG(data) & 0xff) << 8;  /* B8-15  */
    541 			data->window_type[i] |= (BTRNREG(data) & 0xff) << 16; /* B16-23 */
    542 		}
    543 }
    544 #endif
    545 
    546 void
    547 bt463_update(void *p)
    548 {
    549 	struct bt463data *data = (struct bt463data *)p;
    550 	int i, v;
    551 
    552 	if (console_data != NULL) {
    553 		/* The cookie passed in from sched_update is incorrect. Use the
    554 		 * right one.
    555 		 */
    556 		data = console_data;
    557 	}
    558 
    559 	v = data->changed;
    560 
    561 	/* The Bt463 won't accept window type data except during a blanking
    562 	 * interval, so we do this early in the interrupt.
    563 	 * Blanking the screen might also be a good idea, but it can cause
    564 	 * unpleasant flashing and is hard to do from this side of the
    565 	 * ramdac interface.
    566 	 */
    567 	if (v & DATA_WTYPE_CHANGED) {
    568 		/* spit out the window type data */
    569 		for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
    570 			bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
    571 			BTWNREG(data, (data->window_type[i]) & 0xff);       /* B0-7   */
    572 			BTWNREG(data, (data->window_type[i] >> 8) & 0xff);  /* B8-15   */
    573 			BTWNREG(data, (data->window_type[i] >> 16) & 0xff); /* B16-23  */
    574 		}
    575 	}
    576 
    577 	if (v & DATA_CURCMAP_CHANGED) {
    578 		bt463_wraddr(data, BT463_IREG_CURSOR_COLOR_0);
    579 		/* spit out the cursor data */
    580 		for (i = 0; i < 2; i++) {
    581 			BTWNREG(data, data->curcmap_r[i]);
    582 			BTWNREG(data, data->curcmap_g[i]);
    583 			BTWNREG(data, data->curcmap_b[i]);
    584 		}
    585 	}
    586 
    587 	if (v & DATA_CMAP_CHANGED) {
    588 		bt463_wraddr(data, BT463_IREG_CPALETTE_RAM);
    589 		/* spit out the colormap data */
    590 		for (i = 0; i < BT463_NCMAP_ENTRIES; i++) {
    591 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
    592 				data->cmap_r[i]);
    593 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
    594 				data->cmap_g[i]);
    595 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
    596 				data->cmap_b[i]);
    597 		}
    598 	}
    599 
    600 	data->changed = 0;
    601 }
    602 
    603 int
    604 bt463_set_cursor(
    605 	struct ramdac_cookie *rc,
    606 	struct wsdisplay_cursor *cur)
    607 {
    608 	struct bt463data *data = (struct bt463data *)rc;
    609 	return tga_builtin_set_cursor(data->cookie, cur);
    610 }
    611 
    612 int
    613 bt463_get_cursor(
    614 	struct ramdac_cookie *rc,
    615 	struct wsdisplay_cursor *cur)
    616 {
    617 	struct bt463data *data = (struct bt463data *)rc;
    618 	return tga_builtin_get_cursor(data->cookie, cur);
    619 }
    620 
    621 int
    622 bt463_set_curpos(
    623 	struct ramdac_cookie *rc,
    624 	struct wsdisplay_curpos *cur)
    625 {
    626 	struct bt463data *data = (struct bt463data *)rc;
    627 	return tga_builtin_set_curpos(data->cookie, cur);
    628 }
    629 
    630 int
    631 bt463_get_curpos(
    632 	struct ramdac_cookie *rc,
    633 	struct wsdisplay_curpos *cur)
    634 {
    635 	struct bt463data *data = (struct bt463data *)rc;
    636 	return tga_builtin_get_curpos(data->cookie, cur);
    637 }
    638 
    639 int
    640 bt463_get_curmax(
    641 	struct ramdac_cookie *rc,
    642 	struct wsdisplay_curpos *cur)
    643 {
    644 	struct bt463data *data = (struct bt463data *)rc;
    645 	return tga_builtin_get_curmax(data->cookie, cur);
    646 }
    647