Home | History | Annotate | Line # | Download | only in ic
bt463.c revision 1.16
      1 /* $NetBSD: bt463.c,v 1.16 2012/02/12 16:34:11 matt 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.16 2012/02/12 16:34:11 matt 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 inline void bt463_wraddr(struct bt463data *, u_int16_t);
    175 
    176 void	bt463_update(void *);
    177 
    178 
    179 /*****************************************************************************/
    180 
    181 /*
    182  * Functions exported via the RAMDAC configuration table.
    183  */
    184 
    185 struct ramdac_funcs *
    186 bt463_funcs(void)
    187 {
    188 	return &bt463_funcsstruct;
    189 }
    190 
    191 struct ramdac_cookie *
    192 bt463_register(
    193 	void *v,
    194 	int (*sched_update)(void *, void (*)(void *)),
    195 	void (*wr)(void *, u_int, u_int8_t),
    196 	u_int8_t (*rd)(void *, u_int))
    197 {
    198 	struct bt463data *data;
    199 	/*
    200 	 * XXX -- comment out of date.  rcd.
    201 	 * If we should allocate a new private info struct, do so.
    202 	 * Otherwise, use the one we have (if it's there), or
    203 	 * use the temporary one on the stack.
    204 	 */
    205 	data = malloc(sizeof *data, M_DEVBUF, M_WAITOK);
    206 	/* XXX -- if !data */
    207 	data->cookie = v;
    208 	data->ramdac_sched_update = sched_update;
    209 	data->ramdac_wr = wr;
    210 	data->ramdac_rd = rd;
    211 	return (struct ramdac_cookie *)data;
    212 }
    213 
    214 /*
    215  * This function exists solely to provide a means to init
    216  * the RAMDAC without first registering.  It is useful for
    217  * initializing the console early on.
    218  */
    219 void
    220 bt463_cninit(
    221 	void *v,
    222 	int (*sched_update)(void *, void (*)(void *)),
    223 	void (*wr)(void *, u_int, u_int8_t),
    224 	u_int8_t (*rd)(void *, u_int))
    225 {
    226 	struct bt463data tmp, *data = &tmp;
    227 	data->cookie = v;
    228 	data->ramdac_sched_update = sched_update;
    229 	data->ramdac_wr = wr;
    230 	data->ramdac_rd = rd;
    231 	/* Set up console_data so that when bt463_update is called back,
    232 	 * it can use the right information.
    233 	 */
    234 	console_data = data;
    235 	bt463_init((struct ramdac_cookie *)data);
    236 	console_data = NULL;
    237 }
    238 
    239 void
    240 bt463_init(struct ramdac_cookie *rc)
    241 {
    242 	struct bt463data *data = (struct bt463data *)rc;
    243 
    244 	int i;
    245 
    246 	/*
    247 	 * Init the BT463 for normal operation.
    248 	 */
    249 
    250 
    251 	/*
    252 	 * Setup:
    253 	 * reg 0: 4:1 multiplexing, 25/75 blink.
    254 	 * reg 1: Overlay mapping: mapped to common palette,
    255 	 *        14 window type entries, 24-plane configuration mode,
    256 	 *        4 overlay planes, underlays disabled, no cursor.
    257 	 * reg 2: sync-on-green enabled, pedestal enabled.
    258 	 */
    259 
    260 	BTWREG(data, BT463_IREG_COMMAND_0, 0x40);
    261 	BTWREG(data, BT463_IREG_COMMAND_1, 0x48);
    262 	BTWREG(data, BT463_IREG_COMMAND_2, 0x40);
    263 
    264 	/*
    265 	 * Initialize the read mask.
    266 	 */
    267 	bt463_wraddr(data, BT463_IREG_READ_MASK_P0_P7);
    268 	for (i = 0; i < 4; i++)
    269 		BTWNREG(data, 0xff);
    270 
    271 	/*
    272 	 * Initialize the blink mask.
    273 	 */
    274 	bt463_wraddr(data, BT463_IREG_BLINK_MASK_P0_P7);
    275 	for (i = 0; i < 4; i++)
    276 		BTWNREG(data, 0);
    277 
    278 
    279 	/*
    280 	 * Clear test register
    281 	 */
    282 	BTWREG(data, BT463_IREG_TEST, 0);
    283 
    284 	/*
    285 	 * Initialize the RAMDAC info struct to hold all of our
    286 	 * data, and fill it in.
    287 	 */
    288 	data->changed = DATA_ALL_CHANGED;
    289 
    290 	/* initial cursor colormap: 0 is black, 1 is white */
    291 	data->curcmap_r[0] = data->curcmap_g[0] = data->curcmap_b[0] = 0;
    292 	data->curcmap_r[1] = data->curcmap_g[1] = data->curcmap_b[1] = 0xff;
    293 
    294 	/* Initial colormap: 0 is black, everything else is white */
    295 	data->cmap_r[0] = data->cmap_g[0] = data->cmap_b[0] = 0;
    296 	for (i = 1; i < 256; i++)
    297 		data->cmap_r[i] = data->cmap_g[i] = data->cmap_b[i] = 255;
    298 
    299 
    300 	/* Initialize the window type table:
    301 	 *
    302 	 * Entry 0: 24-plane truecolor, overlays enabled, bypassed.
    303 	 *
    304 	 *  Lookup table bypass:      yes (    1 << 23 & 0x800000)  800000
    305 	 *  Colormap address:       0x000 (0x000 << 17 & 0x7e0000)       0
    306 	 *  Overlay mask:             0xf (  0xf << 13 & 0x01e000)   1e000
    307 	 *  Overlay location:    P<27:24> (    0 << 12 & 0x001000)       0
    308 	 *  Display mode:       Truecolor (    0 <<  9 & 0x000e00)     000
    309 	 *  Number of planes:           8 (    8 <<  5 & 0x0001e0)     100
    310 	 *  Plane shift:                0 (    0 <<  0 & 0x00001f)       0
    311 	 *                                                        --------
    312 	 *                                                        0x81e100
    313 	 */
    314 	data->window_type[0] = 0x81e100;
    315 
    316 	/* Entry 1: 8-plane pseudocolor in the bottom 8 bits,
    317 	 *          overlays enabled, colormap starting at 0.
    318 	 *
    319 	 *  Lookup table bypass:       no (    0 << 23 & 0x800000)       0
    320 	 *  Colormap address:       0x000 (0x000 << 17 & 0x7e0000)       0
    321 	 *  Overlay mask:             0xf (  0xf << 13 & 0x01e000) 0x1e000
    322 	 *  Overlay location:    P<27:24> (    0 << 12 & 0x001000)       0
    323 	 *  Display mode:     Pseudocolor (    1 <<  9 & 0x000e00)   0x200
    324 	 *  Number of planes:           8 (    8 <<  5 & 0x0001e0)   0x100
    325 	 *  Plane shift:               16 ( 0x10 <<  0 & 0x00001f)      10
    326 	 *                                                        --------
    327 	 *                                                        0x01e310
    328 	 */
    329 	data->window_type[1] = 0x01e310;
    330 
    331 	/* The colormap interface to the world only supports one colormap,
    332 	 * so having an entry for the 'alternate' colormap in the bt463
    333 	 * probably isn't useful.
    334 	 */
    335 
    336 	/* Fill the remaining table entries with clones of entry 0 until we
    337 	 * figure out a better use for them.
    338 	 */
    339 
    340 	for (i = 2; i < BT463_NWTYPE_ENTRIES; i++) {
    341 		data->window_type[i] = 0x81e100;
    342 	}
    343 
    344 	data->ramdac_sched_update(data->cookie, bt463_update);
    345 
    346 }
    347 
    348 int
    349 bt463_set_cmap(struct ramdac_cookie *rc, struct wsdisplay_cmap *cmapp)
    350 {
    351 	struct bt463data *data = (struct bt463data *)rc;
    352 	u_int count, index;
    353 	uint8_t r[BT463_NCMAP_ENTRIES];
    354 	uint8_t g[BT463_NCMAP_ENTRIES];
    355 	uint8_t b[BT463_NCMAP_ENTRIES];
    356 	int s, error;
    357 
    358 	if (cmapp->index >= BT463_NCMAP_ENTRIES ||
    359 	    cmapp->count > BT463_NCMAP_ENTRIES - cmapp->index)
    360 		return (EINVAL);
    361 
    362 	index = cmapp->index;
    363 	count = cmapp->count;
    364 	error = copyin(cmapp->red, &r[index], count);
    365 	if (error)
    366 		return error;
    367 	error = copyin(cmapp->green, &g[index], count);
    368 	if (error)
    369 		return error;
    370 	error = copyin(cmapp->blue, &b[index], count);
    371 	if (error)
    372 		return error;
    373 	s = spltty();
    374 	memcpy(&data->cmap_r[index], &r[index], count);
    375 	memcpy(&data->cmap_g[index], &g[index], count);
    376 	memcpy(&data->cmap_b[index], &b[index], count);
    377  	data->changed |= DATA_CMAP_CHANGED;
    378 	data->ramdac_sched_update(data->cookie, bt463_update);
    379 	splx(s);
    380 	return (0);
    381 }
    382 
    383 int
    384 bt463_get_cmap(struct ramdac_cookie *rc, struct wsdisplay_cmap *cmapp)
    385 {
    386 	struct bt463data *data = (struct bt463data *)rc;
    387 	u_int count, index;
    388 	int error;
    389 
    390 	if (cmapp->index >= BT463_NCMAP_ENTRIES ||
    391 	    cmapp->count > BT463_NCMAP_ENTRIES - cmapp->index)
    392 		return (EINVAL);
    393 
    394 	count = cmapp->count;
    395 	index = cmapp->index;
    396 
    397 	error = copyout(&data->cmap_r[index], cmapp->red, count);
    398 	if (error)
    399 		return (error);
    400 	error = copyout(&data->cmap_g[index], cmapp->green, count);
    401 	if (error)
    402 		return (error);
    403 	error = copyout(&data->cmap_b[index], cmapp->blue, count);
    404 	return (error);
    405 }
    406 
    407 int
    408 bt463_check_curcmap(struct ramdac_cookie *rc, struct wsdisplay_cursor *cursorp)
    409 {
    410 	struct bt463data *data = (struct bt463data *)rc;
    411 	int count, index, error;
    412 
    413 	if (cursorp->cmap.index > 2 ||
    414 	    (cursorp->cmap.index + cursorp->cmap.count) > 2)
    415 		return (EINVAL);
    416 	count = cursorp->cmap.count;
    417 	index = cursorp->cmap.index;
    418 	error = copyin(cursorp->cmap.red, &data->tmpcurcmap_r[index], count);
    419 	if (error)
    420 		return error;
    421 	error = copyin(cursorp->cmap.green, &data->tmpcurcmap_g[index], count);
    422 	if (error)
    423 		return error;
    424 	error = copyin(cursorp->cmap.blue, &data->tmpcurcmap_b[index], count);
    425 	if (error)
    426 		return error;
    427 	return (0);
    428 }
    429 
    430 void
    431 bt463_set_curcmap(struct ramdac_cookie *rc, struct wsdisplay_cursor *cursorp)
    432 {
    433 	struct bt463data *data = (struct bt463data *)rc;
    434 	int count, index;
    435 
    436 	count = cursorp->cmap.count;
    437 	index = cursorp->cmap.index;
    438 	memcpy(&data->curcmap_r[index], &data->tmpcurcmap_r[index], count);
    439 	memcpy(&data->curcmap_g[index], &data->tmpcurcmap_g[index], count);
    440 	memcpy(&data->curcmap_b[index], &data->tmpcurcmap_b[index], count);
    441 	data->changed |= DATA_CURCMAP_CHANGED;
    442 	data->ramdac_sched_update(data->cookie, bt463_update);
    443 }
    444 
    445 int
    446 bt463_get_curcmap(struct ramdac_cookie *rc, struct wsdisplay_cursor *cursorp)
    447 {
    448 	struct bt463data *data = (struct bt463data *)rc;
    449 	int error;
    450 
    451 	cursorp->cmap.index = 0;	/* DOCMAP */
    452 	cursorp->cmap.count = 2;
    453 	if (cursorp->cmap.red != NULL) {
    454 		error = copyout(data->curcmap_r, cursorp->cmap.red, 2);
    455 		if (error)
    456 			return (error);
    457 	}
    458 	if (cursorp->cmap.green != NULL) {
    459 		error = copyout(data->curcmap_g, cursorp->cmap.green, 2);
    460 		if (error)
    461 			return (error);
    462 	}
    463 	if (cursorp->cmap.blue != NULL) {
    464 		error = copyout(data->curcmap_b, cursorp->cmap.blue, 2);
    465 		if (error)
    466 			return (error);
    467 	}
    468 	return (0);
    469 }
    470 
    471 
    472 /*****************************************************************************/
    473 
    474 /*
    475  * Internal functions.
    476  */
    477 
    478 #ifdef BT463_DEBUG
    479 int bt463_store(void *v)
    480 {
    481 	struct bt463data *data = (struct bt463data *)v;
    482 
    483 	data->changed = DATA_ALL_CHANGED;
    484 	data->ramdac_sched_update(data->cookie, bt463_update);
    485 	printf("Scheduled bt463 store\n");
    486 
    487 	return 0;
    488 }
    489 
    490 
    491 int bt463_readback(void *v)
    492 {
    493 	struct bt463data *data = (struct bt463data *)v;
    494 
    495 	data->ramdac_sched_update(data->cookie, bt463_copyback);
    496 	printf("Scheduled bt463 copyback\n");
    497 	return 0;
    498 }
    499 
    500 int
    501 bt463_debug(void *v)
    502 {
    503 	struct bt463data *data = (struct bt463data *)v;
    504 	int i;
    505 	u_int8_t val;
    506 
    507 	printf("BT463 main regs:\n");
    508 	for (i = 0x200; i < 0x20F; i ++) {
    509 	  val = BTRREG(data, i);
    510 	  printf("  $%04x %02x\n", i, val);
    511 	}
    512 
    513 	printf("BT463 revision register:\n");
    514 	  val = BTRREG(data, 0x220);
    515 	  printf("  $%04x %02x\n", 0x220, val);
    516 
    517 	printf("BT463 window type table (from softc):\n");
    518 
    519 	for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
    520 	  printf("%02x %06x\n", i, data->window_type[i]);
    521 	}
    522 
    523 	return 0;
    524 }
    525 
    526 void
    527 bt463_copyback(void *p)
    528 {
    529 	struct bt463data *data = (struct bt463data *)p;
    530 	int i;
    531 
    532 		for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
    533 			bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
    534 			data->window_type[i] = (BTRNREG(data) & 0xff);        /* B0-7   */
    535 			data->window_type[i] |= (BTRNREG(data) & 0xff) << 8;  /* B8-15  */
    536 			data->window_type[i] |= (BTRNREG(data) & 0xff) << 16; /* B16-23 */
    537 		}
    538 }
    539 #endif
    540 
    541 inline void
    542 bt463_wraddr(struct bt463data *data, u_int16_t ireg)
    543 {
    544 	data->ramdac_wr(data->cookie, BT463_REG_ADDR_LOW, ireg & 0xff);
    545 	data->ramdac_wr(data->cookie, BT463_REG_ADDR_HIGH, (ireg >> 8) & 0xff);
    546 }
    547 
    548 void
    549 bt463_update(void *p)
    550 {
    551 	struct bt463data *data = (struct bt463data *)p;
    552 	int i, v;
    553 
    554 	if (console_data != NULL) {
    555 		/* The cookie passed in from sched_update is incorrect. Use the
    556 		 * right one.
    557 		 */
    558 		data = console_data;
    559 	}
    560 
    561 	v = data->changed;
    562 
    563 	/* The Bt463 won't accept window type data except during a blanking
    564 	 * interval, so we do this early in the interrupt.
    565 	 * Blanking the screen might also be a good idea, but it can cause
    566 	 * unpleasant flashing and is hard to do from this side of the
    567 	 * ramdac interface.
    568 	 */
    569 	if (v & DATA_WTYPE_CHANGED) {
    570 		/* spit out the window type data */
    571 		for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
    572 			bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
    573 			BTWNREG(data, (data->window_type[i]) & 0xff);       /* B0-7   */
    574 			BTWNREG(data, (data->window_type[i] >> 8) & 0xff);  /* B8-15   */
    575 			BTWNREG(data, (data->window_type[i] >> 16) & 0xff); /* B16-23  */
    576 		}
    577 	}
    578 
    579 	if (v & DATA_CURCMAP_CHANGED) {
    580 		bt463_wraddr(data, BT463_IREG_CURSOR_COLOR_0);
    581 		/* spit out the cursor data */
    582 		for (i = 0; i < 2; i++) {
    583 			BTWNREG(data, data->curcmap_r[i]);
    584 			BTWNREG(data, data->curcmap_g[i]);
    585 			BTWNREG(data, data->curcmap_b[i]);
    586 		}
    587 	}
    588 
    589 	if (v & DATA_CMAP_CHANGED) {
    590 		bt463_wraddr(data, BT463_IREG_CPALETTE_RAM);
    591 		/* spit out the colormap data */
    592 		for (i = 0; i < BT463_NCMAP_ENTRIES; i++) {
    593 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
    594 				data->cmap_r[i]);
    595 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
    596 				data->cmap_g[i]);
    597 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
    598 				data->cmap_b[i]);
    599 		}
    600 	}
    601 
    602 	data->changed = 0;
    603 }
    604 
    605 int
    606 bt463_set_cursor(
    607 	struct ramdac_cookie *rc,
    608 	struct wsdisplay_cursor *cur)
    609 {
    610 	struct bt463data *data = (struct bt463data *)rc;
    611 	return tga_builtin_set_cursor(data->cookie, cur);
    612 }
    613 
    614 int
    615 bt463_get_cursor(
    616 	struct ramdac_cookie *rc,
    617 	struct wsdisplay_cursor *cur)
    618 {
    619 	struct bt463data *data = (struct bt463data *)rc;
    620 	return tga_builtin_get_cursor(data->cookie, cur);
    621 }
    622 
    623 int
    624 bt463_set_curpos(
    625 	struct ramdac_cookie *rc,
    626 	struct wsdisplay_curpos *cur)
    627 {
    628 	struct bt463data *data = (struct bt463data *)rc;
    629 	return tga_builtin_set_curpos(data->cookie, cur);
    630 }
    631 
    632 int
    633 bt463_get_curpos(
    634 	struct ramdac_cookie *rc,
    635 	struct wsdisplay_curpos *cur)
    636 {
    637 	struct bt463data *data = (struct bt463data *)rc;
    638 	return tga_builtin_get_curpos(data->cookie, cur);
    639 }
    640 
    641 int
    642 bt463_get_curmax(
    643 	struct ramdac_cookie *rc,
    644 	struct wsdisplay_curpos *cur)
    645 {
    646 	struct bt463data *data = (struct bt463data *)rc;
    647 	return tga_builtin_get_curmax(data->cookie, cur);
    648 }
    649