xref: /netbsd-src/sys/dev/ic/bt463.c (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1 /* $NetBSD: bt463.c,v 1.12 2005/12/11 12:21:26 christos 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@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.12 2005/12/11 12:21:26 christos 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(struct ramdac_cookie *);
95 int	bt463_set_cmap(struct ramdac_cookie *, struct wsdisplay_cmap *);
96 int	bt463_get_cmap(struct ramdac_cookie *, struct wsdisplay_cmap *);
97 int	bt463_set_cursor(struct ramdac_cookie *, struct wsdisplay_cursor *);
98 int	bt463_get_cursor(struct ramdac_cookie *, struct wsdisplay_cursor *);
99 int	bt463_set_curpos(struct ramdac_cookie *, struct wsdisplay_curpos *);
100 int	bt463_get_curpos(struct ramdac_cookie *, struct wsdisplay_curpos *);
101 int	bt463_get_curmax(struct ramdac_cookie *, struct wsdisplay_curpos *);
102 int	bt463_check_curcmap(struct ramdac_cookie *,
103 	    struct wsdisplay_cursor *cursorp);
104 void	bt463_set_curcmap(struct ramdac_cookie *,
105 	    struct wsdisplay_cursor *cursorp);
106 int	bt463_get_curcmap(struct ramdac_cookie *,
107 	    struct wsdisplay_cursor *cursorp);
108 
109 #ifdef BT463_DEBUG
110 int bt463_store(void *);
111 int bt463_debug(void *);
112 int bt463_readback(void *);
113 void	bt463_copyback(void *);
114 #endif
115 
116 struct ramdac_funcs bt463_funcsstruct = {
117 	"Bt463",
118 	bt463_register,
119 	bt463_init,
120 	bt463_set_cmap,
121 	bt463_get_cmap,
122 	bt463_set_cursor,
123 	bt463_get_cursor,
124 	bt463_set_curpos,
125 	bt463_get_curpos,
126 	bt463_get_curmax,
127 	bt463_check_curcmap,
128 	bt463_set_curcmap,
129 	bt463_get_curcmap,
130 	NULL,
131 };
132 
133 /*
134  * Private data.
135  */
136 struct bt463data {
137 	void            *cookie;        /* This is what is passed
138 					 * around, and is probably
139 					 * struct tga_devconfig *
140 					 */
141 
142 	int             (*ramdac_sched_update)(void *, void (*)(void *));
143 	void            (*ramdac_wr)(void *, u_int, u_int8_t);
144 	u_int8_t        (*ramdac_rd)(void *, u_int);
145 
146 	int	changed;			/* what changed; see below */
147 	char curcmap_r[2];			/* cursor colormap */
148 	char curcmap_g[2];
149 	char curcmap_b[2];
150 	char tmpcurcmap_r[2];			/* tmp cursor colormap */
151 	char tmpcurcmap_g[2];
152 	char tmpcurcmap_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(struct bt463data *, u_int16_t);
184 
185 void	bt463_update(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, 0x40);
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 	 * Initialize 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 	uint8_t r[BT463_NCMAP_ENTRIES];
366 	uint8_t g[BT463_NCMAP_ENTRIES];
367 	uint8_t b[BT463_NCMAP_ENTRIES];
368 	int s, error;
369 
370 	if (cmapp->index >= BT463_NCMAP_ENTRIES ||
371 	    cmapp->count > BT463_NCMAP_ENTRIES - cmapp->index)
372 		return (EINVAL);
373 
374 	index = cmapp->index;
375 	count = cmapp->count;
376 	error = copyin(cmapp->red, &r[index], count);
377 	if (error)
378 		return error;
379 	error = copyin(cmapp->green, &g[index], count);
380 	if (error)
381 		return error;
382 	error = copyin(cmapp->blue, &b[index], count);
383 	if (error)
384 		return error;
385 	s = spltty();
386 	memcpy(&data->cmap_r[index], &r[index], count);
387 	memcpy(&data->cmap_g[index], &g[index], count);
388 	memcpy(&data->cmap_b[index], &b[index], count);
389  	data->changed |= DATA_CMAP_CHANGED;
390 	data->ramdac_sched_update(data->cookie, bt463_update);
391 	splx(s);
392 	return (0);
393 }
394 
395 int
396 bt463_get_cmap(rc, cmapp)
397 	struct ramdac_cookie *rc;
398 	struct wsdisplay_cmap *cmapp;
399 {
400 	struct bt463data *data = (struct bt463data *)rc;
401 	u_int count, index;
402 	int error;
403 
404 	if (cmapp->index >= BT463_NCMAP_ENTRIES ||
405 	    cmapp->count > BT463_NCMAP_ENTRIES - cmapp->index)
406 		return (EINVAL);
407 
408 	count = cmapp->count;
409 	index = cmapp->index;
410 
411 	error = copyout(&data->cmap_r[index], cmapp->red, count);
412 	if (error)
413 		return (error);
414 	error = copyout(&data->cmap_g[index], cmapp->green, count);
415 	if (error)
416 		return (error);
417 	error = copyout(&data->cmap_b[index], cmapp->blue, count);
418 	return (error);
419 }
420 
421 int
422 bt463_check_curcmap(rc, cursorp)
423 	struct ramdac_cookie *rc;
424 	struct wsdisplay_cursor *cursorp;
425 {
426 	struct bt463data *data = (struct bt463data *)rc;
427 	int count, index, error;
428 
429 	if (cursorp->cmap.index > 2 ||
430 	    (cursorp->cmap.index + cursorp->cmap.count) > 2)
431 		return (EINVAL);
432 	count = cursorp->cmap.count;
433 	index = cursorp->cmap.index;
434 	error = copyin(cursorp->cmap.red, &data->tmpcurcmap_r[index], count);
435 	if (error)
436 		return error;
437 	error = copyin(cursorp->cmap.green, &data->tmpcurcmap_g[index], count);
438 	if (error)
439 		return error;
440 	error = copyin(cursorp->cmap.blue, &data->tmpcurcmap_b[index], count);
441 	if (error)
442 		return error;
443 	return (0);
444 }
445 
446 void
447 bt463_set_curcmap(rc, cursorp)
448 	struct ramdac_cookie *rc;
449 	struct wsdisplay_cursor *cursorp;
450 {
451 	struct bt463data *data = (struct bt463data *)rc;
452 	int count, index;
453 
454 	count = cursorp->cmap.count;
455 	index = cursorp->cmap.index;
456 	memcpy(&data->curcmap_r[index], &data->tmpcurcmap_r[index], count);
457 	memcpy(&data->curcmap_g[index], &data->tmpcurcmap_g[index], count);
458 	memcpy(&data->curcmap_b[index], &data->tmpcurcmap_b[index], count);
459 	data->changed |= DATA_CURCMAP_CHANGED;
460 	data->ramdac_sched_update(data->cookie, bt463_update);
461 }
462 
463 int
464 bt463_get_curcmap(rc, cursorp)
465 	struct ramdac_cookie *rc;
466 	struct wsdisplay_cursor *cursorp;
467 {
468 	struct bt463data *data = (struct bt463data *)rc;
469 	int error;
470 
471 	cursorp->cmap.index = 0;	/* DOCMAP */
472 	cursorp->cmap.count = 2;
473 	if (cursorp->cmap.red != NULL) {
474 		error = copyout(data->curcmap_r, cursorp->cmap.red, 2);
475 		if (error)
476 			return (error);
477 	}
478 	if (cursorp->cmap.green != NULL) {
479 		error = copyout(data->curcmap_g, cursorp->cmap.green, 2);
480 		if (error)
481 			return (error);
482 	}
483 	if (cursorp->cmap.blue != NULL) {
484 		error = copyout(data->curcmap_b, cursorp->cmap.blue, 2);
485 		if (error)
486 			return (error);
487 	}
488 	return (0);
489 }
490 
491 
492 /*****************************************************************************/
493 
494 /*
495  * Internal functions.
496  */
497 
498 #ifdef BT463_DEBUG
499 int bt463_store(void *v)
500 {
501 	struct bt463data *data = (struct bt463data *)v;
502 
503 	data->changed = DATA_ALL_CHANGED;
504 	data->ramdac_sched_update(data->cookie, bt463_update);
505 	printf("Scheduled bt463 store\n");
506 
507 	return 0;
508 }
509 
510 
511 int bt463_readback(void *v)
512 {
513 	struct bt463data *data = (struct bt463data *)v;
514 
515 	data->ramdac_sched_update(data->cookie, bt463_copyback);
516 	printf("Scheduled bt463 copyback\n");
517 	return 0;
518 }
519 
520 int
521 bt463_debug(v)
522 	void *v;
523 {
524 	struct bt463data *data = (struct bt463data *)v;
525 	int i;
526 	u_int8_t val;
527 
528 	printf("BT463 main regs:\n");
529 	for (i = 0x200; i < 0x20F; i ++) {
530 	  val = BTRREG(data, i);
531 	  printf("  $%04x %02x\n", i, val);
532 	}
533 
534 	printf("BT463 revision register:\n");
535 	  val = BTRREG(data, 0x220);
536 	  printf("  $%04x %02x\n", 0x220, val);
537 
538 	printf("BT463 window type table (from softc):\n");
539 
540 	for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
541 	  printf("%02x %06x\n", i, data->window_type[i]);
542 	}
543 
544 	return 0;
545 }
546 
547 void
548 bt463_copyback(p)
549 	 void *p;
550 {
551 	struct bt463data *data = (struct bt463data *)p;
552 	int i;
553 
554 		for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
555 			bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
556 			data->window_type[i] = (BTRNREG(data) & 0xff);        /* B0-7   */
557 			data->window_type[i] |= (BTRNREG(data) & 0xff) << 8;  /* B8-15  */
558 			data->window_type[i] |= (BTRNREG(data) & 0xff) << 16; /* B16-23 */
559 		}
560 }
561 #endif
562 
563 inline void
564 bt463_wraddr(data, ireg)
565 	struct bt463data *data;
566 	u_int16_t ireg;
567 {
568 	data->ramdac_wr(data->cookie, BT463_REG_ADDR_LOW, ireg & 0xff);
569 	data->ramdac_wr(data->cookie, BT463_REG_ADDR_HIGH, (ireg >> 8) & 0xff);
570 }
571 
572 void
573 bt463_update(p)
574 	void *p;
575 {
576 	struct bt463data *data = (struct bt463data *)p;
577 	int i, v;
578 
579 	if (console_data != NULL) {
580 		/* The cookie passed in from sched_update is incorrect. Use the
581 		 * right one.
582 		 */
583 		data = console_data;
584 	}
585 
586 	v = data->changed;
587 
588 	/* The Bt463 won't accept window type data except during a blanking
589 	 * interval, so we do this early in the interrupt.
590 	 * Blanking the screen might also be a good idea, but it can cause
591 	 * unpleasant flashing and is hard to do from this side of the
592 	 * ramdac interface.
593 	 */
594 	if (v & DATA_WTYPE_CHANGED) {
595 		/* spit out the window type data */
596 		for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
597 			bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
598 			BTWNREG(data, (data->window_type[i]) & 0xff);       /* B0-7   */
599 			BTWNREG(data, (data->window_type[i] >> 8) & 0xff);  /* B8-15   */
600 			BTWNREG(data, (data->window_type[i] >> 16) & 0xff); /* B16-23  */
601 		}
602 	}
603 
604 	if (v & DATA_CURCMAP_CHANGED) {
605 		bt463_wraddr(data, BT463_IREG_CURSOR_COLOR_0);
606 		/* spit out the cursor data */
607 		for (i = 0; i < 2; i++) {
608 			BTWNREG(data, data->curcmap_r[i]);
609 			BTWNREG(data, data->curcmap_g[i]);
610 			BTWNREG(data, data->curcmap_b[i]);
611 		}
612 	}
613 
614 	if (v & DATA_CMAP_CHANGED) {
615 		bt463_wraddr(data, BT463_IREG_CPALETTE_RAM);
616 		/* spit out the colormap data */
617 		for (i = 0; i < BT463_NCMAP_ENTRIES; i++) {
618 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
619 				data->cmap_r[i]);
620 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
621 				data->cmap_g[i]);
622 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
623 				data->cmap_b[i]);
624 		}
625 	}
626 
627 	data->changed = 0;
628 }
629 
630 int	bt463_set_cursor (rc, cur)
631 	struct ramdac_cookie *rc;
632 	struct wsdisplay_cursor *cur;
633 {
634 	struct bt463data *data = (struct bt463data *)rc;
635 	return tga_builtin_set_cursor(data->cookie, cur);
636 }
637 
638 int	bt463_get_cursor (rc, cur)
639 	struct ramdac_cookie *rc;
640 	struct wsdisplay_cursor *cur;
641 {
642 	struct bt463data *data = (struct bt463data *)rc;
643 	return tga_builtin_get_cursor(data->cookie, cur);
644 }
645 
646 int	bt463_set_curpos (rc, cur)
647 	struct ramdac_cookie *rc;
648 	struct wsdisplay_curpos *cur;
649 {
650 	struct bt463data *data = (struct bt463data *)rc;
651 	return tga_builtin_set_curpos(data->cookie, cur);
652 }
653 
654 int	bt463_get_curpos (rc, cur)
655 	struct ramdac_cookie *rc;
656 	struct wsdisplay_curpos *cur;
657 {
658 	struct bt463data *data = (struct bt463data *)rc;
659 	return tga_builtin_get_curpos(data->cookie, cur);
660 }
661 
662 int	bt463_get_curmax (rc, cur)
663 	struct ramdac_cookie *rc;
664 	struct wsdisplay_curpos *cur;
665 {
666 	struct bt463data *data = (struct bt463data *)rc;
667 	return tga_builtin_get_curmax(data->cookie, cur);
668 }
669