xref: /openbsd/sys/dev/ic/bt463.c (revision da5607f6)
1 /* $OpenBSD: bt463.c,v 1.14 2024/06/26 01:40:49 jsg Exp $ */
2 /* $NetBSD: bt463.c,v 1.2 2000/06/13 17:21:06 nathanw Exp $ */
3 
4 /*-
5  * Copyright (c) 1998 The NetBSD Foundation, Inc.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to The NetBSD Foundation
9  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
10  * NASA Ames Research Center.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
36  * All rights reserved.
37  *
38  * Author: Chris G. Demetriou
39  *
40  * Permission to use, copy, modify and distribute this software and
41  * its documentation is hereby granted, provided that both the copyright
42  * notice and this permission notice appear in all copies of the
43  * software, derivative works or modified versions, and any portions
44  * thereof, and that both notices appear in supporting documentation.
45  *
46  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
47  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
48  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
49  *
50  * Carnegie Mellon requests users of this software to return to
51  *
52  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
53  *  School of Computer Science
54  *  Carnegie Mellon University
55  *  Pittsburgh PA 15213-3890
56  *
57  * any improvements or extensions that they make and grant Carnegie the
58  * rights to redistribute these changes.
59  */
60 
61  /* This code was derived from and originally located in sys/dev/pci/
62   *	 NetBSD: tga_bt463.c,v 1.5 2000/03/04 10:27:59 elric Exp
63   */
64 
65 #include <sys/param.h>
66 #include <sys/systm.h>
67 #include <sys/device.h>
68 #include <sys/buf.h>
69 #include <sys/kernel.h>
70 #include <sys/malloc.h>
71 
72 #include <dev/pci/pcivar.h>
73 #include <dev/pci/tgareg.h>
74 #include <dev/pci/tgavar.h>
75 #include <dev/ic/bt463reg.h>
76 #include <dev/ic/bt463var.h>
77 
78 #include <dev/wscons/wsconsio.h>
79 
80 /*
81  * Functions exported via the RAMDAC configuration table.
82  */
83 void	bt463_init(struct ramdac_cookie *);
84 int	bt463_set_cmap(struct ramdac_cookie *,
85 	    struct wsdisplay_cmap *);
86 int	bt463_get_cmap(struct ramdac_cookie *,
87 	    struct wsdisplay_cmap *);
88 int	bt463_set_cursor(struct ramdac_cookie *,
89 	    struct wsdisplay_cursor *);
90 int	bt463_get_cursor(struct ramdac_cookie *,
91 	    struct wsdisplay_cursor *);
92 int	bt463_set_curpos(struct ramdac_cookie *,
93 	    struct wsdisplay_curpos *);
94 int	bt463_get_curpos(struct ramdac_cookie *,
95 	    struct wsdisplay_curpos *);
96 int	bt463_get_curmax(struct ramdac_cookie *,
97 	    struct wsdisplay_curpos *);
98 int	bt463_check_curcmap(struct ramdac_cookie *,
99 	    struct wsdisplay_cursor *cursorp);
100 void	bt463_set_curcmap(struct ramdac_cookie *,
101 	    struct wsdisplay_cursor *cursorp);
102 int	bt463_get_curcmap(struct ramdac_cookie *,
103 	    struct wsdisplay_cursor *cursorp);
104 
105 #ifdef BT463_DEBUG
106 int bt463_store(void *);
107 int bt463_debug(void *);
108 int bt463_readback(void *);
109 void	bt463_copyback(void *);
110 #endif
111 
112 struct ramdac_funcs bt463_funcsstruct = {
113 	"Bt463",
114 	bt463_register,
115 	bt463_init,
116 	bt463_set_cmap,
117 	bt463_get_cmap,
118 	bt463_set_cursor,
119 	bt463_get_cursor,
120 	bt463_set_curpos,
121 	bt463_get_curpos,
122 	bt463_get_curmax,
123 	bt463_check_curcmap,
124 	bt463_set_curcmap,
125 	bt463_get_curcmap,
126 	NULL,
127 };
128 
129 /*
130  * Private data.
131  */
132 struct bt463data {
133 	void            *cookie;        /* This is what is passed
134 					 * around, and is probably
135 					 * struct tga_devconfig *
136 					 */
137 
138 	int             (*ramdac_sched_update)(void *, void (*)(void *));
139 	void            (*ramdac_wr)(void *, u_int, u_int8_t);
140 	u_int8_t        (*ramdac_rd)(void *, u_int);
141 
142 	int	changed;			/* what changed; see below */
143 	char curcmap_r[2];			/* cursor colormap */
144 	char curcmap_g[2];
145 	char curcmap_b[2];
146 	char cmap_r[BT463_NCMAP_ENTRIES];	/* colormap */
147 	char cmap_g[BT463_NCMAP_ENTRIES];
148 	char cmap_b[BT463_NCMAP_ENTRIES];
149 	int window_type[16]; /* 16 24-bit window type table entries */
150 };
151 
152 /* When we're doing console initialization, there's no
153  * way to get our cookie back to the video card's softc
154  * before we call sched_update. So we stash it here,
155  * and bt463_update will look for it here first.
156  */
157 static struct bt463data *console_data;
158 
159 
160 #define BTWREG(data, addr, val) do { bt463_wraddr((data), (addr)); \
161 	(data)->ramdac_wr((data)->cookie, BT463_REG_IREG_DATA, (val)); } while (0)
162 #define BTWNREG(data, val) (data)->ramdac_wr((data)->cookie, \
163 	BT463_REG_IREG_DATA, (val))
164 #define BTRREG(data, addr) (bt463_wraddr((data), (addr)), \
165 	(data)->ramdac_rd((data)->cookie, BT463_REG_IREG_DATA))
166 #define BTRNREG(data) ((data)->ramdac_rd((data)->cookie, BT463_REG_IREG_DATA))
167 
168 #define	DATA_CURCMAP_CHANGED	0x01	/* cursor colormap changed */
169 #define	DATA_CMAP_CHANGED	0x02	/* colormap changed */
170 #define	DATA_WTYPE_CHANGED	0x04	/* window type table changed */
171 #define	DATA_ALL_CHANGED	0x07
172 
173 /*
174  * Internal functions.
175  */
176 inline void bt463_wraddr(struct bt463data *, u_int16_t);
177 
178 void	bt463_update(void *);
179 
180 
181 /*****************************************************************************/
182 
183 /*
184  * Functions exported via the RAMDAC configuration table.
185  */
186 
187 struct ramdac_funcs *
bt463_funcs(void)188 bt463_funcs(void)
189 {
190 	return &bt463_funcsstruct;
191 }
192 
193 struct ramdac_cookie *
bt463_register(v,sched_update,wr,rd)194 bt463_register(v, sched_update, wr, rd)
195 	void *v;
196 	int (*sched_update)(void *, void (*)(void *));
197 	void (*wr)(void *, u_int, u_int8_t);
198 	u_int8_t (*rd)(void *, u_int);
199 {
200 	struct bt463data *data;
201 	/*
202 	 * XXX -- comment out of date.  rcd.
203 	 * If we should allocate a new private info struct, do so.
204 	 * Otherwise, use the one we have (if it's there), or
205 	 * use the temporary one on the stack.
206 	 */
207 	data = malloc(sizeof *data, M_DEVBUF, M_WAITOK);
208 	/* XXX -- if !data */
209 	data->cookie = v;
210 	data->ramdac_sched_update = sched_update;
211 	data->ramdac_wr = wr;
212 	data->ramdac_rd = rd;
213 	return (struct ramdac_cookie *)data;
214 }
215 
216 /*
217  * This function exists solely to provide a means to init
218  * the RAMDAC without first registering.  It is useful for
219  * initializing the console early on.
220  */
221 void
bt463_cninit(v,sched_update,wr,rd)222 bt463_cninit(v, sched_update, wr, rd)
223 	void *v;
224 	int (*sched_update)(void *, void (*)(void *));
225 	void (*wr)(void *, u_int, u_int8_t);
226 	u_int8_t (*rd)(void *, u_int);
227 {
228 	struct bt463data tmp, *data = &tmp;
229 	data->cookie = v;
230 	data->ramdac_sched_update = sched_update;
231 	data->ramdac_wr = wr;
232 	data->ramdac_rd = rd;
233 	/* Set up console_data so that when bt463_update is called back,
234 	 * it can use the right information.
235 	 */
236 	console_data = data;
237 	bt463_init((struct ramdac_cookie *)data);
238 	console_data = NULL;
239 }
240 
241 void
bt463_init(rc)242 bt463_init(rc)
243 	struct ramdac_cookie *rc;
244 {
245 	struct bt463data *data = (struct bt463data *)rc;
246 
247 	int i;
248 
249 	/*
250 	 * Init the BT463 for normal operation.
251 	 */
252 
253 
254 	/*
255 	 * Setup:
256 	 * reg 0: 4:1 multiplexing, 25/75 blink.
257 	 * reg 1: Overlay mapping: mapped to common palette,
258 	 *        14 window type entries, 24-plane configuration mode,
259 	 *        4 overlay planes, underlays disabled, no cursor.
260 	 * reg 2: sync-on-green enabled, pedestal enabled.
261 	 */
262 
263 	BTWREG(data, BT463_IREG_COMMAND_0, 0x40);
264 	BTWREG(data, BT463_IREG_COMMAND_1, 0x48);
265 	BTWREG(data, BT463_IREG_COMMAND_2, 0xC0);
266 
267 	/*
268 	 * Initialize the read mask.
269 	 */
270 	bt463_wraddr(data, BT463_IREG_READ_MASK_P0_P7);
271 	for (i = 0; i < 4; i++)
272 		BTWNREG(data, 0xff);
273 
274 	/*
275 	 * Initialize the blink mask.
276 	 */
277 	bt463_wraddr(data, BT463_IREG_BLINK_MASK_P0_P7);
278 	for (i = 0; i < 4; i++)
279 		BTWNREG(data, 0);
280 
281 
282 	/*
283 	 * Clear test register
284 	 */
285 	BTWREG(data, BT463_IREG_TEST, 0);
286 
287 	/*
288 	 * Initialize the RAMDAC info struct to hold all of our
289 	 * data, and fill it in.
290 	 */
291 	data->changed = DATA_ALL_CHANGED;
292 
293 	/* initial cursor colormap: 0 is black, 1 is white */
294 	data->curcmap_r[0] = data->curcmap_g[0] = data->curcmap_b[0] = 0;
295 	data->curcmap_r[1] = data->curcmap_g[1] = data->curcmap_b[1] = 0xff;
296 
297 	/* Initial colormap: 0 is black, everything else is white */
298 	data->cmap_r[0] = data->cmap_g[0] = data->cmap_b[0] = 0;
299 	for (i = 1; i < 256; i++) {
300 		data->cmap_r[i] = rasops_cmap[3*i + 0];
301 		data->cmap_g[i] = rasops_cmap[3*i + 1];
302 		data->cmap_b[i] = rasops_cmap[3*i + 2];
303 	}
304 
305 	/* Initialize the window type table:
306 	 *
307 	 * Entry 0: 24-plane truecolor, overlays enabled, bypassed.
308 	 *
309 	 *  Lookup table bypass:      yes (    1 << 23 & 0x800000)  800000
310 	 *  Colormap address:       0x000 (0x000 << 17 & 0x7e0000)       0
311 	 *  Overlay mask:             0xf (  0xf << 13 & 0x01e000)   1e000
312 	 *  Overlay location:    P<27:24> (    0 << 12 & 0x001000)       0
313 	 *  Display mode:       Truecolor (    0 <<  9 & 0x000e00)     000
314 	 *  Number of planes:           8 (    8 <<  5 & 0x0001e0)     100
315 	 *  Plane shift:                0 (    0 <<  0 & 0x00001f)       0
316 	 *                                                        --------
317 	 *                                                        0x81e100
318 	 */
319 	data->window_type[0] = 0x81e100;
320 
321 	/* Entry 1: 8-plane pseudocolor in the bottom 8 bits,
322 	 *          overlays enabled, colormap starting at 0.
323 	 *
324 	 *  Lookup table bypass:       no (    0 << 23 & 0x800000)       0
325 	 *  Colormap address:       0x000 (0x000 << 17 & 0x7e0000)       0
326 	 *  Overlay mask:             0xf (  0xf << 13 & 0x01e000) 0x1e000
327 	 *  Overlay location:    P<27:24> (    0 << 12 & 0x001000)       0
328 	 *  Display mode:     Pseudocolor (    1 <<  9 & 0x000e00)   0x200
329 	 *  Number of planes:           8 (    8 <<  5 & 0x0001e0)   0x100
330 	 *  Plane shift:               16 ( 0x10 <<  0 & 0x00001f)      10
331 	 *                                                        --------
332 	 *                                                        0x01e310
333 	 */
334 	data->window_type[1] = 0x01e310;
335 
336 	/* The colormap interface to the world only supports one colormap,
337 	 * so having an entry for the 'alternate' colormap in the bt463
338 	 * probably isn't useful.
339 	 */
340 
341 	/* Fill the remaining table entries with clones of entry 0 until we
342 	 * figure out a better use for them.
343 	 */
344 
345 	for (i = 2; i < BT463_NWTYPE_ENTRIES; i++) {
346 		data->window_type[i] = 0x81e100;
347 	}
348 
349 	data->ramdac_sched_update(data->cookie, bt463_update);
350 
351 }
352 
353 int
bt463_set_cmap(rc,cmapp)354 bt463_set_cmap(rc, cmapp)
355 	struct ramdac_cookie *rc;
356 	struct wsdisplay_cmap *cmapp;
357 {
358 	struct bt463data *data = (struct bt463data *)rc;
359 	u_int count, index;
360 	int s, error;
361 
362 	index = cmapp->index;
363 	count = cmapp->count;
364 
365 	if (index >= BT463_NCMAP_ENTRIES || count > BT463_NCMAP_ENTRIES - index)
366 		return (EINVAL);
367 
368 	s = spltty();
369 
370 	if ((error = copyin(cmapp->red, &data->cmap_r[index], count)) != 0) {
371 		splx(s);
372 		return (error);
373 	}
374 	if ((error = copyin(cmapp->green, &data->cmap_g[index], count)) != 0) {
375 		splx(s);
376 		return (error);
377 	}
378 	if ((error = copyin(cmapp->blue, &data->cmap_b[index], count)) != 0) {
379 		splx(s);
380 		return (error);
381 	}
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
bt463_get_cmap(rc,cmapp)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 	u_int count, index;
398 	int error;
399 
400 	count = cmapp->count;
401 	index = cmapp->index;
402 
403 	if (index >= BT463_NCMAP_ENTRIES || count > BT463_NCMAP_ENTRIES - index)
404 		return (EINVAL);
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
bt463_check_curcmap(rc,cursorp)417 bt463_check_curcmap(rc, cursorp)
418 	struct ramdac_cookie *rc;
419 	struct wsdisplay_cursor *cursorp;
420 {
421 	u_int index, count;
422 	u_int8_t spare[2];
423 	int error;
424 
425 	index = cursorp->cmap.index;
426 	count = cursorp->cmap.count;
427 
428 	if (index >= 2 || count > 2 - index)
429 		return (EINVAL);
430 
431 	if ((error = copyin(&cursorp->cmap.red, &spare, count)) != 0)
432 		return (error);
433 	if ((error = copyin(&cursorp->cmap.green, &spare, count)) != 0)
434 		return (error);
435 	if ((error = copyin(&cursorp->cmap.blue, &spare, count)) != 0)
436 		return (error);
437 
438 	return (0);
439 }
440 
441 void
bt463_set_curcmap(rc,cursorp)442 bt463_set_curcmap(rc, cursorp)
443 	struct ramdac_cookie *rc;
444 	struct wsdisplay_cursor *cursorp;
445 {
446 	struct bt463data *data = (struct bt463data *)rc;
447 	int count, index;
448 
449 	/* can't fail; parameters have already been checked. */
450 	count = cursorp->cmap.count;
451 	index = cursorp->cmap.index;
452 	copyin(cursorp->cmap.red, &data->curcmap_r[index], count);
453 	copyin(cursorp->cmap.green, &data->curcmap_g[index], count);
454 	copyin(cursorp->cmap.blue, &data->curcmap_b[index], count);
455 	data->changed |= DATA_CURCMAP_CHANGED;
456 	data->ramdac_sched_update(data->cookie, bt463_update);
457 }
458 
459 int
bt463_get_curcmap(rc,cursorp)460 bt463_get_curcmap(rc, cursorp)
461 	struct ramdac_cookie *rc;
462 	struct wsdisplay_cursor *cursorp;
463 {
464 	struct bt463data *data = (struct bt463data *)rc;
465 	int error;
466 
467 	cursorp->cmap.index = 0;	/* DOCMAP */
468 	cursorp->cmap.count = 2;
469 	if (cursorp->cmap.red != NULL) {
470 		error = copyout(data->curcmap_r, cursorp->cmap.red, 2);
471 		if (error)
472 			return (error);
473 	}
474 	if (cursorp->cmap.green != NULL) {
475 		error = copyout(data->curcmap_g, cursorp->cmap.green, 2);
476 		if (error)
477 			return (error);
478 	}
479 	if (cursorp->cmap.blue != NULL) {
480 		error = copyout(data->curcmap_b, cursorp->cmap.blue, 2);
481 		if (error)
482 			return (error);
483 	}
484 	return (0);
485 }
486 
487 
488 /*****************************************************************************/
489 
490 /*
491  * Internal functions.
492  */
493 
494 #ifdef BT463_DEBUG
495 int
bt463_store(void * v)496 bt463_store(void *v)
497 {
498 	struct bt463data *data = (struct bt463data *)v;
499 
500 	data->changed = DATA_ALL_CHANGED;
501 	data->ramdac_sched_update(data->cookie, bt463_update);
502 	printf("Scheduled bt463 store\n");
503 
504 	return 0;
505 }
506 
507 
508 int
bt463_readback(void * v)509 bt463_readback(void *v)
510 {
511 	struct bt463data *data = (struct bt463data *)v;
512 
513 	data->ramdac_sched_update(data->cookie, bt463_copyback);
514 	printf("Scheduled bt463 copyback\n");
515 	return 0;
516 }
517 
518 int
bt463_debug(v)519 bt463_debug(v)
520 	void *v;
521 {
522 	struct bt463data *data = (struct bt463data *)v;
523 	int i;
524 	u_int8_t val;
525 
526 	printf("BT463 main regs:\n");
527 	for (i = 0x200; i < 0x20F; i ++) {
528 	  val = BTRREG(data, i);
529 	  printf("  $%04x %02x\n", i, val);
530 	}
531 
532 	printf("BT463 revision register:\n");
533 	  val = BTRREG(data, 0x220);
534 	  printf("  $%04x %02x\n", 0x220, val);
535 
536 	printf("BT463 window type table (from softc):\n");
537 
538 	for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
539 	  printf("%02x %06x\n", i, data->window_type[i]);
540 	}
541 
542 	return 0;
543 }
544 
545 void
bt463_copyback(p)546 bt463_copyback(p)
547 	 void *p;
548 {
549 	struct bt463data *data = (struct bt463data *)p;
550 	int i;
551 
552 		for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
553 			bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
554 			data->window_type[i] = (BTRNREG(data) & 0xff);        /* B0-7   */
555 			data->window_type[i] |= (BTRNREG(data) & 0xff) << 8;  /* B8-15  */
556 			data->window_type[i] |= (BTRNREG(data) & 0xff) << 16; /* B16-23 */
557 		}
558 }
559 #endif
560 
561 inline void
bt463_wraddr(data,ireg)562 bt463_wraddr(data, ireg)
563 	struct bt463data *data;
564 	u_int16_t ireg;
565 {
566 	data->ramdac_wr(data->cookie, BT463_REG_ADDR_LOW, ireg & 0xff);
567 	data->ramdac_wr(data->cookie, BT463_REG_ADDR_HIGH, (ireg >> 8) & 0xff);
568 }
569 
570 void
bt463_update(p)571 bt463_update(p)
572 	void *p;
573 {
574 	struct bt463data *data = (struct bt463data *)p;
575 	int i, v;
576 
577 	if (console_data != NULL) {
578 		/* The cookie passed in from sched_update is incorrect. Use the
579 		 * right one.
580 		 */
581 		data = console_data;
582 	}
583 
584 	v = data->changed;
585 
586 	/* The Bt463 won't accept window type data except during a blanking
587 	 * interval, so we do this early in the interrupt.
588 	 * Blanking the screen might also be a good idea, but it can cause
589 	 * unpleasant flashing and is hard to do from this side of the
590 	 * ramdac interface.
591 	 */
592 	if (v & DATA_WTYPE_CHANGED) {
593 		/* spit out the window type data */
594 		for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
595 			bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
596 			BTWNREG(data, (data->window_type[i]) & 0xff);       /* B0-7   */
597 			BTWNREG(data, (data->window_type[i] >> 8) & 0xff);  /* B8-15   */
598 			BTWNREG(data, (data->window_type[i] >> 16) & 0xff); /* B16-23  */
599 		}
600 	}
601 
602 	if (v & DATA_CURCMAP_CHANGED) {
603 		bt463_wraddr(data, BT463_IREG_CURSOR_COLOR_0);
604 		/* spit out the cursor data */
605 		for (i = 0; i < 2; i++) {
606 			BTWNREG(data, data->curcmap_r[i]);
607 			BTWNREG(data, data->curcmap_g[i]);
608 			BTWNREG(data, data->curcmap_b[i]);
609 		}
610 	}
611 
612 	if (v & DATA_CMAP_CHANGED) {
613 		bt463_wraddr(data, BT463_IREG_CPALETTE_RAM);
614 		/* spit out the colormap data */
615 		for (i = 0; i < BT463_NCMAP_ENTRIES; i++) {
616 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
617 				data->cmap_r[i]);
618 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
619 				data->cmap_g[i]);
620 			data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
621 				data->cmap_b[i]);
622 		}
623 	}
624 
625 	data->changed = 0;
626 }
627 
628 int
bt463_set_cursor(rc,cur)629 bt463_set_cursor (rc, cur)
630 	struct ramdac_cookie *rc;
631 	struct wsdisplay_cursor *cur;
632 {
633 	struct bt463data *data = (struct bt463data *)rc;
634 	return tga_builtin_set_cursor(data->cookie, cur);
635 }
636 
637 int
bt463_get_cursor(rc,cur)638 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 bt463_set_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_set_curpos(data->cookie, cur);
653 }
654 
655 int
bt463_get_curpos(rc,cur)656 bt463_get_curpos (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_curpos(data->cookie, cur);
662 }
663 
664 int
bt463_get_curmax(rc,cur)665 bt463_get_curmax (rc, cur)
666 	struct ramdac_cookie *rc;
667 	struct wsdisplay_curpos *cur;
668 {
669 	struct bt463data *data = (struct bt463data *)rc;
670 	return tga_builtin_get_curmax(data->cookie, cur);
671 }
672