xafb.c revision 1.1.10.3       1       1.1   tsubai /*	$NetBSD: xafb.c,v 1.1.10.3 2002/10/18 02:39:10 nathanw Exp $	*/
      2       1.1   tsubai 
      3       1.1   tsubai /*-
      4       1.1   tsubai  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
      5       1.1   tsubai  *
      6       1.1   tsubai  * Redistribution and use in source and binary forms, with or without
      7       1.1   tsubai  * modification, are permitted provided that the following conditions
      8       1.1   tsubai  * are met:
      9       1.1   tsubai  * 1. Redistributions of source code must retain the above copyright
     10       1.1   tsubai  *    notice, this list of conditions and the following disclaimer.
     11       1.1   tsubai  * 2. Redistributions in binary form must reproduce the above copyright
     12       1.1   tsubai  *    notice, this list of conditions and the following disclaimer in the
     13       1.1   tsubai  *    documentation and/or other materials provided with the distribution.
     14       1.1   tsubai  * 3. The name of the author may not be used to endorse or promote products
     15       1.1   tsubai  *    derived from this software without specific prior written permission.
     16       1.1   tsubai  *
     17       1.1   tsubai  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18       1.1   tsubai  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19       1.1   tsubai  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20       1.1   tsubai  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21       1.1   tsubai  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22       1.1   tsubai  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23       1.1   tsubai  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24       1.1   tsubai  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25       1.1   tsubai  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26       1.1   tsubai  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27       1.1   tsubai  */
     28       1.1   tsubai 
     29       1.1   tsubai /* "xa" frame buffer driver.  Currently supports 1280x1024x8 only. */
     30       1.1   tsubai 
     31       1.1   tsubai #include <sys/param.h>
     32       1.1   tsubai #include <sys/buf.h>
     33       1.1   tsubai #include <sys/device.h>
     34       1.1   tsubai #include <sys/ioctl.h>
     35       1.1   tsubai #include <sys/malloc.h>
     36       1.1   tsubai #include <sys/systm.h>
     37       1.1   tsubai 
     38       1.1   tsubai #include <uvm/uvm_extern.h>
     39       1.1   tsubai 
     40       1.1   tsubai #include <machine/adrsmap.h>
     41       1.1   tsubai #include <machine/apcall.h>
     42       1.1   tsubai 
     43       1.1   tsubai #include <dev/wscons/wsconsio.h>
     44       1.1   tsubai #include <dev/wscons/wsdisplayvar.h>
     45       1.1   tsubai #include <dev/rasops/rasops.h>
     46       1.1   tsubai 
     47       1.1   tsubai #include <newsmips/apbus/apbusvar.h>
     48       1.1   tsubai 
     49       1.1   tsubai struct xafb_reg {
     50       1.1   tsubai 	volatile u_int r0;
     51       1.1   tsubai 	volatile u_int index;
     52       1.1   tsubai 	volatile u_int r2;
     53       1.1   tsubai 	volatile u_int zero;
     54       1.1   tsubai 	volatile u_int r4;
     55       1.1   tsubai 	volatile u_int r5;
     56       1.1   tsubai 	volatile u_int r6;
     57       1.1   tsubai 	volatile u_int rgb;
     58       1.1   tsubai };
     59       1.1   tsubai 
     60       1.1   tsubai struct xafb_devconfig {
     61       1.1   tsubai 	volatile u_char *dc_fbbase;	/* VRAM base address */
     62       1.1   tsubai 	struct xafb_reg *dc_reg;	/* register address */
     63       1.1   tsubai 	struct rasops_info dc_ri;
     64       1.1   tsubai };
     65       1.1   tsubai 
     66       1.1   tsubai struct xafb_softc {
     67       1.1   tsubai 	struct device sc_dev;
     68       1.1   tsubai 	struct xafb_devconfig *sc_dc;
     69       1.1   tsubai 	int sc_nscreens;
     70       1.1   tsubai 	u_char sc_cmap_red[256];
     71       1.1   tsubai 	u_char sc_cmap_green[256];
     72       1.1   tsubai 	u_char sc_cmap_blue[256];
     73       1.1   tsubai };
     74       1.1   tsubai 
     75       1.1   tsubai int xafb_match __P((struct device *, struct cfdata *, void *));
     76       1.1   tsubai void xafb_attach __P((struct device *, struct device *, void *));
     77       1.1   tsubai 
     78       1.1   tsubai int xafb_common_init __P((struct xafb_devconfig *));
     79       1.1   tsubai int xafb_is_console __P((void));
     80       1.1   tsubai 
     81       1.1   tsubai int xafb_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
     82       1.1   tsubai paddr_t xafb_mmap __P((void *, off_t, int));
     83       1.1   tsubai int xafb_alloc_screen __P((void *, const struct wsscreen_descr *,
     84       1.1   tsubai 			   void **, int *, int *, long *));
     85       1.1   tsubai void xafb_free_screen __P((void *, void *));
     86       1.1   tsubai int xafb_show_screen __P((void *, void *, int,
     87       1.1   tsubai 			  void (*) (void *, int, int), void *));
     88       1.1   tsubai 
     89       1.1   tsubai int xafb_cnattach __P((void));
     90       1.1   tsubai int xafb_getcmap __P((struct xafb_softc *, struct wsdisplay_cmap *));
     91       1.1   tsubai int xafb_putcmap __P((struct xafb_softc *, struct wsdisplay_cmap *));
     92       1.1   tsubai 
     93       1.1   tsubai static __inline void xafb_setcolor(struct xafb_devconfig *, int, int, int, int);
     94       1.1   tsubai 
     95  1.1.10.3  nathanw CFATTACH_DECL(xafb, sizeof(struct xafb_softc),
     96  1.1.10.3  nathanw     xafb_match, xafb_attach, NULL, NULL);
     97       1.1   tsubai 
     98       1.1   tsubai struct xafb_devconfig xafb_console_dc;
     99       1.1   tsubai 
    100       1.1   tsubai struct wsdisplay_accessops xafb_accessops = {
    101       1.1   tsubai 	xafb_ioctl,
    102       1.1   tsubai 	xafb_mmap,
    103       1.1   tsubai 	xafb_alloc_screen,
    104       1.1   tsubai 	xafb_free_screen,
    105       1.1   tsubai 	xafb_show_screen,
    106       1.1   tsubai 	NULL	/* load_font */
    107       1.1   tsubai };
    108       1.1   tsubai 
    109       1.1   tsubai struct wsscreen_descr xafb_stdscreen = {
    110       1.1   tsubai 	"std",
    111       1.1   tsubai 	0, 0,
    112       1.1   tsubai 	0,
    113       1.1   tsubai 	0, 0,
    114       1.1   tsubai 	WSSCREEN_REVERSE
    115       1.1   tsubai };
    116       1.1   tsubai 
    117       1.1   tsubai const struct wsscreen_descr *xafb_scrlist[] = {
    118       1.1   tsubai 	&xafb_stdscreen
    119       1.1   tsubai };
    120       1.1   tsubai 
    121       1.1   tsubai struct wsscreen_list xafb_screenlist = {
    122       1.1   tsubai 	sizeof(xafb_scrlist) / sizeof(xafb_scrlist[0]), xafb_scrlist
    123       1.1   tsubai };
    124       1.1   tsubai 
    125       1.1   tsubai int
    126       1.1   tsubai xafb_match(parent, match, aux)
    127       1.1   tsubai 	struct device *parent;
    128       1.1   tsubai 	struct cfdata *match;
    129       1.1   tsubai 	void *aux;
    130       1.1   tsubai {
    131       1.1   tsubai 	struct apbus_attach_args *apa = aux;
    132       1.1   tsubai 
    133       1.1   tsubai 	if (strcmp(apa->apa_name, "xa") != 0)
    134       1.1   tsubai 		return 0;
    135       1.1   tsubai 
    136       1.1   tsubai 	return 1;
    137       1.1   tsubai }
    138       1.1   tsubai 
    139       1.1   tsubai void
    140       1.1   tsubai xafb_attach(parent, self, aux)
    141       1.1   tsubai 	struct device *parent, *self;
    142       1.1   tsubai 	void *aux;
    143       1.1   tsubai {
    144       1.1   tsubai 	struct xafb_softc *sc = (void *)self;
    145       1.1   tsubai 	struct apbus_attach_args *apa = aux;
    146       1.1   tsubai 	struct wsemuldisplaydev_attach_args wsa;
    147       1.1   tsubai 	struct xafb_devconfig *dc;
    148       1.1   tsubai 	struct rasops_info *ri;
    149       1.1   tsubai 	int console, i;
    150       1.1   tsubai 
    151       1.1   tsubai 	console = xafb_is_console();
    152       1.1   tsubai 
    153       1.1   tsubai 	if (console) {
    154       1.1   tsubai 		dc = &xafb_console_dc;
    155       1.1   tsubai 		ri = &dc->dc_ri;
    156       1.1   tsubai 		sc->sc_nscreens = 1;
    157       1.1   tsubai 	} else {
    158       1.1   tsubai 		dc = malloc(sizeof(struct xafb_devconfig), M_DEVBUF, M_WAITOK);
    159       1.1   tsubai 		bzero(dc, sizeof(struct xafb_devconfig));
    160       1.1   tsubai 
    161       1.1   tsubai 		dc->dc_fbbase = (void *)0xb0000000;		/* XXX */
    162       1.1   tsubai 		dc->dc_reg = (void *)(apa->apa_hwbase + 0x3000);
    163       1.1   tsubai 		if (xafb_common_init(dc) != 0) {
    164       1.1   tsubai 			printf(": couldn't initialize device\n");
    165       1.1   tsubai 			return;
    166       1.1   tsubai 		}
    167       1.1   tsubai 
    168       1.1   tsubai 		ri = &dc->dc_ri;
    169       1.1   tsubai 
    170       1.1   tsubai 		/* clear screen */
    171       1.1   tsubai 		(*ri->ri_ops.eraserows)(ri, 0, ri->ri_rows, 0);
    172       1.1   tsubai 	}
    173       1.1   tsubai 	sc->sc_dc = dc;
    174       1.1   tsubai 
    175       1.1   tsubai 	for (i = 0; i < 256; i++) {
    176       1.1   tsubai 		sc->sc_cmap_red[i] = i;
    177       1.1   tsubai 		sc->sc_cmap_green[i] = i;
    178       1.1   tsubai 		sc->sc_cmap_blue[i] = i;
    179       1.1   tsubai 	}
    180       1.1   tsubai 
    181       1.1   tsubai 	printf(": %d x %d, %dbpp\n", ri->ri_width, ri->ri_height, ri->ri_depth);
    182       1.1   tsubai 
    183       1.1   tsubai 	wsa.console = console;
    184       1.1   tsubai 	wsa.scrdata = &xafb_screenlist;
    185       1.1   tsubai 	wsa.accessops = &xafb_accessops;
    186       1.1   tsubai 	wsa.accesscookie = sc;
    187       1.1   tsubai 
    188       1.1   tsubai 	config_found(self, &wsa, wsemuldisplaydevprint);
    189       1.1   tsubai }
    190       1.1   tsubai 
    191       1.1   tsubai void
    192       1.1   tsubai xafb_setcolor(dc, index, r, g, b)
    193       1.1   tsubai 	struct xafb_devconfig *dc;
    194       1.1   tsubai 	int index, r, g, b;
    195       1.1   tsubai {
    196       1.1   tsubai 	volatile struct xafb_reg *reg = dc->dc_reg;
    197       1.1   tsubai 
    198       1.1   tsubai 	reg->index = index;
    199       1.1   tsubai 	reg->zero = 0;
    200       1.1   tsubai 	reg->rgb = r;
    201       1.1   tsubai 	reg->rgb = g;
    202       1.1   tsubai 	reg->rgb = b;
    203       1.1   tsubai }
    204       1.1   tsubai 
    205       1.1   tsubai int
    206       1.1   tsubai xafb_common_init(dc)
    207       1.1   tsubai 	struct xafb_devconfig *dc;
    208       1.1   tsubai {
    209       1.1   tsubai 	struct rasops_info *ri = &dc->dc_ri;
    210       1.1   tsubai 	int i;
    211       1.1   tsubai 
    212       1.1   tsubai 	for (i = 0; i < 256; i++)
    213       1.1   tsubai 		xafb_setcolor(dc, i, i, i, i);
    214       1.1   tsubai 
    215       1.1   tsubai 	/* initialize rasops */
    216       1.1   tsubai 	ri->ri_width = 1280;
    217       1.1   tsubai 	ri->ri_height = 1024;
    218       1.1   tsubai 	ri->ri_depth = 8;
    219       1.1   tsubai 	ri->ri_stride = 2048;
    220       1.1   tsubai 	ri->ri_bits = (void *)dc->dc_fbbase;
    221       1.1   tsubai 	ri->ri_flg = RI_FORCEMONO | RI_FULLCLEAR;
    222       1.1   tsubai 
    223       1.1   tsubai 	rasops_init(ri, 44, 100);
    224       1.1   tsubai 
    225       1.1   tsubai 	/* mono */
    226       1.1   tsubai 	ri->ri_devcmap[0] = 0;				/* bg */
    227       1.1   tsubai 	ri->ri_devcmap[1] = 0xffffffff;			/* fg */
    228       1.1   tsubai 
    229       1.1   tsubai 	xafb_stdscreen.nrows = ri->ri_rows;
    230       1.1   tsubai 	xafb_stdscreen.ncols = ri->ri_cols;
    231       1.1   tsubai 	xafb_stdscreen.textops = &ri->ri_ops;
    232       1.1   tsubai 	xafb_stdscreen.capabilities = ri->ri_caps;
    233       1.1   tsubai 
    234       1.1   tsubai 	return 0;
    235       1.1   tsubai }
    236       1.1   tsubai 
    237       1.1   tsubai int
    238       1.1   tsubai xafb_is_console()
    239       1.1   tsubai {
    240       1.1   tsubai 	volatile u_int *dipsw = (void *)NEWS5000_DIP_SWITCH;
    241       1.1   tsubai 
    242       1.1   tsubai 	if (*dipsw & 1)					/* XXX right? */
    243       1.1   tsubai 		return 1;
    244       1.1   tsubai 
    245       1.1   tsubai 	return 0;
    246       1.1   tsubai }
    247       1.1   tsubai 
    248       1.1   tsubai int
    249       1.1   tsubai xafb_ioctl(v, cmd, data, flag, p)
    250       1.1   tsubai 	void *v;
    251       1.1   tsubai 	u_long cmd;
    252       1.1   tsubai 	caddr_t data;
    253       1.1   tsubai 	int flag;
    254       1.1   tsubai 	struct proc *p;
    255       1.1   tsubai {
    256       1.1   tsubai 	struct xafb_softc *sc = v;
    257       1.1   tsubai 	struct xafb_devconfig *dc = sc->sc_dc;
    258       1.1   tsubai 	struct wsdisplay_fbinfo *wdf;
    259       1.1   tsubai 
    260       1.1   tsubai 	switch (cmd) {
    261       1.1   tsubai 	case WSDISPLAYIO_GTYPE:
    262       1.1   tsubai 		*(int *)data = WSDISPLAY_TYPE_UNKNOWN;	/* XXX */
    263       1.1   tsubai 		return 0;
    264       1.1   tsubai 
    265       1.1   tsubai 	case WSDISPLAYIO_GINFO:
    266       1.1   tsubai 		wdf = (void *)data;
    267       1.1   tsubai 		wdf->height = dc->dc_ri.ri_height;
    268       1.1   tsubai 		wdf->width = dc->dc_ri.ri_width;
    269       1.1   tsubai 		wdf->depth = dc->dc_ri.ri_depth;
    270       1.1   tsubai 		wdf->cmsize = 256;
    271       1.1   tsubai 		return 0;
    272       1.1   tsubai 
    273       1.1   tsubai 	case WSDISPLAYIO_GETCMAP:
    274       1.1   tsubai 		return xafb_getcmap(sc, (struct wsdisplay_cmap *)data);
    275       1.1   tsubai 
    276       1.1   tsubai 	case WSDISPLAYIO_PUTCMAP:
    277       1.1   tsubai 		return xafb_putcmap(sc, (struct wsdisplay_cmap *)data);
    278       1.1   tsubai 
    279       1.1   tsubai 	/* case WSDISPLAYIO_SVIDEO: */
    280       1.1   tsubai 	}
    281  1.1.10.1  nathanw 	return EPASSTHROUGH;
    282       1.1   tsubai }
    283       1.1   tsubai 
    284       1.1   tsubai paddr_t
    285       1.1   tsubai xafb_mmap(v, offset, prot)
    286       1.1   tsubai 	void *v;
    287       1.1   tsubai 	off_t offset;
    288       1.1   tsubai 	int prot;
    289       1.1   tsubai {
    290       1.1   tsubai 	struct xafb_softc *sc = v;
    291       1.1   tsubai 	struct xafb_devconfig *dc = sc->sc_dc;
    292       1.1   tsubai 	struct rasops_info *ri = &dc->dc_ri;
    293       1.1   tsubai 
    294       1.1   tsubai 	if (offset >= (ri->ri_stride * ri->ri_height) || offset < 0)
    295       1.1   tsubai 		return -1;
    296       1.1   tsubai 
    297       1.1   tsubai 	return mips_btop((int)dc->dc_fbbase + offset);
    298       1.1   tsubai }
    299       1.1   tsubai 
    300       1.1   tsubai int
    301       1.1   tsubai xafb_alloc_screen(v, scrdesc, cookiep, ccolp, crowp, attrp)
    302       1.1   tsubai 	void *v;
    303       1.1   tsubai 	const struct wsscreen_descr *scrdesc;
    304       1.1   tsubai 	void **cookiep;
    305       1.1   tsubai 	int *ccolp, *crowp;
    306       1.1   tsubai 	long *attrp;
    307       1.1   tsubai {
    308       1.1   tsubai 	struct xafb_softc *sc = v;
    309       1.1   tsubai 	struct rasops_info *ri = &sc->sc_dc->dc_ri;
    310       1.1   tsubai 	long defattr;
    311       1.1   tsubai 
    312       1.1   tsubai 	if (sc->sc_nscreens > 0)
    313       1.1   tsubai 		return ENOMEM;
    314       1.1   tsubai 
    315       1.1   tsubai 	*cookiep = ri;
    316       1.1   tsubai 	*ccolp = *crowp = 0;
    317  1.1.10.2  nathanw 	(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
    318       1.1   tsubai 	*attrp = defattr;
    319       1.1   tsubai 	sc->sc_nscreens++;
    320       1.1   tsubai 
    321       1.1   tsubai 	return 0;
    322       1.1   tsubai }
    323       1.1   tsubai 
    324       1.1   tsubai void
    325       1.1   tsubai xafb_free_screen(v, cookie)
    326       1.1   tsubai 	void *v;
    327       1.1   tsubai 	void *cookie;
    328       1.1   tsubai {
    329       1.1   tsubai 	struct xafb_softc *sc = v;
    330       1.1   tsubai 
    331       1.1   tsubai 	if (sc->sc_dc == &xafb_console_dc)
    332       1.1   tsubai 		panic("xafb_free_screen: console");
    333       1.1   tsubai 
    334       1.1   tsubai 	sc->sc_nscreens--;
    335       1.1   tsubai }
    336       1.1   tsubai 
    337       1.1   tsubai int
    338       1.1   tsubai xafb_show_screen(v, cookie, waitok, cb, cbarg)
    339       1.1   tsubai 	void *v;
    340       1.1   tsubai 	void *cookie;
    341       1.1   tsubai 	int waitok;
    342       1.1   tsubai 	void (*cb) __P((void *, int, int));
    343       1.1   tsubai 	void *cbarg;
    344       1.1   tsubai {
    345       1.1   tsubai 	return 0;
    346       1.1   tsubai }
    347       1.1   tsubai 
    348       1.1   tsubai int
    349       1.1   tsubai xafb_cnattach()
    350       1.1   tsubai {
    351       1.1   tsubai 	struct xafb_devconfig *dc = &xafb_console_dc;
    352       1.1   tsubai 	struct rasops_info *ri = &dc->dc_ri;
    353       1.1   tsubai 	long defattr;
    354       1.1   tsubai 	int crow = 0;
    355       1.1   tsubai 
    356       1.1   tsubai 	if (!xafb_is_console())
    357       1.1   tsubai 		return -1;
    358       1.1   tsubai 
    359       1.1   tsubai 	dc->dc_fbbase = (void *)0xb0000000;			/* XXX */
    360       1.1   tsubai 	dc->dc_reg = (void *)0xb4903000;			/* XXX */
    361       1.1   tsubai 	xafb_common_init(dc);
    362       1.1   tsubai 
    363       1.1   tsubai 	crow = 0;			/* XXX current cursor pos */
    364       1.1   tsubai 
    365  1.1.10.2  nathanw 	(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
    366       1.1   tsubai 	wsdisplay_cnattach(&xafb_stdscreen, &dc->dc_ri, 0, crow, defattr);
    367       1.1   tsubai 
    368       1.1   tsubai 	return 0;
    369       1.1   tsubai }
    370       1.1   tsubai 
    371       1.1   tsubai int
    372       1.1   tsubai xafb_getcmap(sc, cm)
    373       1.1   tsubai 	struct xafb_softc *sc;
    374       1.1   tsubai 	struct wsdisplay_cmap *cm;
    375       1.1   tsubai {
    376       1.1   tsubai 	u_int index = cm->index;
    377       1.1   tsubai 	u_int count = cm->count;
    378       1.1   tsubai 	int error;
    379       1.1   tsubai 
    380       1.1   tsubai 	if (index >= 256 || count > 256 || index + count > 256)
    381       1.1   tsubai 		return EINVAL;
    382       1.1   tsubai 
    383       1.1   tsubai 	error = copyout(&sc->sc_cmap_red[index],   cm->red,   count);
    384       1.1   tsubai 	if (error)
    385       1.1   tsubai 		return error;
    386       1.1   tsubai 	error = copyout(&sc->sc_cmap_green[index], cm->green, count);
    387       1.1   tsubai 	if (error)
    388       1.1   tsubai 		return error;
    389       1.1   tsubai 	error = copyout(&sc->sc_cmap_blue[index],  cm->blue,  count);
    390       1.1   tsubai 	if (error)
    391       1.1   tsubai 		return error;
    392       1.1   tsubai 
    393       1.1   tsubai 	return 0;
    394       1.1   tsubai }
    395       1.1   tsubai 
    396       1.1   tsubai int
    397       1.1   tsubai xafb_putcmap(sc, cm)
    398       1.1   tsubai 	struct xafb_softc *sc;
    399       1.1   tsubai 	struct wsdisplay_cmap *cm;
    400       1.1   tsubai {
    401       1.1   tsubai 	u_int index = cm->index;
    402       1.1   tsubai 	u_int count = cm->count;
    403       1.1   tsubai 	int i;
    404       1.1   tsubai 	u_char *r, *g, *b;
    405       1.1   tsubai 
    406       1.1   tsubai 	if (index >= 256 || count > 256 || index + count > 256)
    407       1.1   tsubai 		return EINVAL;
    408       1.1   tsubai 	if (!uvm_useracc(cm->red,   count, B_READ) ||
    409       1.1   tsubai 	    !uvm_useracc(cm->green, count, B_READ) ||
    410       1.1   tsubai 	    !uvm_useracc(cm->blue,  count, B_READ))
    411       1.1   tsubai 		return EFAULT;
    412       1.1   tsubai 	copyin(cm->red,   &sc->sc_cmap_red[index],   count);
    413       1.1   tsubai 	copyin(cm->green, &sc->sc_cmap_green[index], count);
    414       1.1   tsubai 	copyin(cm->blue,  &sc->sc_cmap_blue[index],  count);
    415       1.1   tsubai 
    416       1.1   tsubai 	r = &sc->sc_cmap_red[index];
    417       1.1   tsubai 	g = &sc->sc_cmap_green[index];
    418       1.1   tsubai 	b = &sc->sc_cmap_blue[index];
    419       1.1   tsubai 
    420       1.1   tsubai 	for (i = 0; i < count; i++)
    421       1.1   tsubai 		xafb_setcolor(sc->sc_dc, index++, *r++, *g++, *b++);
    422       1.1   tsubai 
    423       1.1   tsubai 	return 0;
    424       1.1   tsubai }
    425