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