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