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