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