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