Home | History | Annotate | Line # | Download | only in dev
fb.c revision 1.22
      1  1.22      jmmv /*	$NetBSD: fb.c,v 1.22 2006/04/12 19:38:23 jmmv Exp $	*/
      2   1.5    tsubai 
      3   1.5    tsubai /*-
      4   1.5    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.5    tsubai  * 3. The name of the author may not be used to endorse or promote products
     15   1.5    tsubai  *    derived from this software without specific prior written permission.
     16   1.1    tsubai  *
     17   1.5    tsubai  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18   1.5    tsubai  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19   1.5    tsubai  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20   1.5    tsubai  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21   1.5    tsubai  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22   1.5    tsubai  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23   1.5    tsubai  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24   1.5    tsubai  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25   1.5    tsubai  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26   1.5    tsubai  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27   1.1    tsubai  */
     28  1.17     lukem 
     29  1.17     lukem #include <sys/cdefs.h>
     30  1.22      jmmv __KERNEL_RCSID(0, "$NetBSD: fb.c,v 1.22 2006/04/12 19:38:23 jmmv Exp $");
     31   1.1    tsubai 
     32   1.1    tsubai #include <sys/param.h>
     33   1.1    tsubai #include <sys/device.h>
     34   1.5    tsubai #include <sys/ioctl.h>
     35   1.5    tsubai #include <sys/malloc.h>
     36   1.1    tsubai #include <sys/systm.h>
     37   1.1    tsubai 
     38   1.5    tsubai #include <uvm/uvm_extern.h>
     39   1.5    tsubai 
     40   1.5    tsubai #include <machine/adrsmap.h>
     41  1.16   tsutsui 
     42  1.16   tsutsui #include <newsmips/dev/hbvar.h>
     43   1.1    tsubai 
     44   1.5    tsubai #include <dev/wscons/wsconsio.h>
     45   1.5    tsubai #include <dev/wscons/wsdisplayvar.h>
     46   1.5    tsubai #include <dev/rasops/rasops.h>
     47   1.5    tsubai 
     48   1.5    tsubai struct fb_devconfig {
     49   1.5    tsubai 	u_char *dc_fbbase;		/* VRAM base address */
     50   1.5    tsubai 	struct rasops_info dc_ri;
     51   1.5    tsubai };
     52   1.1    tsubai 
     53   1.1    tsubai struct fb_softc {
     54   1.1    tsubai 	struct device sc_dev;
     55   1.5    tsubai 	struct fb_devconfig *sc_dc;
     56   1.5    tsubai 	int sc_nscreens;
     57   1.1    tsubai };
     58   1.1    tsubai 
     59   1.5    tsubai int fb_match(struct device *, struct cfdata *, void *);
     60   1.5    tsubai void fb_attach(struct device *, struct device *, void *);
     61   1.5    tsubai 
     62   1.5    tsubai int fb_common_init(struct fb_devconfig *);
     63   1.5    tsubai int fb_is_console(void);
     64   1.5    tsubai 
     65  1.22      jmmv int fb_ioctl(void *, void *, u_long, caddr_t, int, struct lwp *);
     66  1.22      jmmv paddr_t fb_mmap(void *, void *, off_t, int);
     67   1.5    tsubai int fb_alloc_screen(void *, const struct wsscreen_descr *, void **, int *,
     68  1.19   tsutsui     int *, long *);
     69   1.5    tsubai void fb_free_screen(void *, void *);
     70   1.5    tsubai int fb_show_screen(void *, void *, int, void (*)(void *, int, int), void *);
     71   1.5    tsubai 
     72   1.5    tsubai void fb_cnattach(void);
     73   1.5    tsubai 
     74   1.9      matt static void fb253_init(void);
     75   1.1    tsubai 
     76  1.14   thorpej CFATTACH_DECL(fb, sizeof(struct fb_softc),
     77  1.14   thorpej     fb_match, fb_attach, NULL, NULL);
     78   1.5    tsubai 
     79   1.5    tsubai struct fb_devconfig fb_console_dc;
     80   1.5    tsubai 
     81   1.5    tsubai struct wsdisplay_accessops fb_accessops = {
     82   1.5    tsubai 	fb_ioctl,
     83   1.5    tsubai 	fb_mmap,
     84   1.5    tsubai 	fb_alloc_screen,
     85   1.5    tsubai 	fb_free_screen,
     86   1.5    tsubai 	fb_show_screen,
     87   1.5    tsubai 	NULL	/* load_font */
     88   1.5    tsubai };
     89   1.5    tsubai 
     90   1.5    tsubai struct wsscreen_descr fb_stdscreen = {
     91   1.5    tsubai 	"std",
     92   1.5    tsubai 	0, 0,
     93   1.5    tsubai 	0,
     94   1.5    tsubai 	0, 0,
     95   1.5    tsubai 	WSSCREEN_REVERSE
     96   1.1    tsubai };
     97   1.1    tsubai 
     98   1.5    tsubai const struct wsscreen_descr *fb_scrlist[] = {
     99   1.5    tsubai 	&fb_stdscreen
    100   1.5    tsubai };
    101   1.5    tsubai 
    102   1.5    tsubai struct wsscreen_list fb_screenlist = {
    103   1.5    tsubai 	sizeof(fb_scrlist) / sizeof(fb_scrlist[0]), fb_scrlist
    104   1.5    tsubai };
    105   1.1    tsubai 
    106   1.5    tsubai #define NWB253_VRAM   ((u_char *) 0x88000000)
    107   1.5    tsubai #define NWB253_CTLREG ((u_short *)0xb8ff0000)
    108   1.5    tsubai #define NWB253_CRTREG ((u_short *)0xb8fe0000)
    109   1.1    tsubai 
    110  1.20   tsutsui static const char *devname[8] = { "NWB-512", "NWB-518", "NWE-501" }; /* XXX ? */
    111   1.5    tsubai 
    112   1.5    tsubai int
    113  1.19   tsutsui fb_match(struct device *parent, struct cfdata *match, void *aux)
    114   1.1    tsubai {
    115  1.16   tsutsui 	struct hb_attach_args *ha = aux;
    116   1.1    tsubai 
    117  1.16   tsutsui 	if (strcmp(ha->ha_name, "fb") != 0)
    118   1.1    tsubai 		return 0;
    119   1.1    tsubai 
    120  1.16   tsutsui 	if (hb_badaddr(NWB253_CTLREG, 2) || hb_badaddr(NWB253_CRTREG, 2))
    121   1.5    tsubai 		return 0;
    122   1.5    tsubai 	if ((*(volatile u_short *)NWB253_CTLREG & 7) != 4)
    123   1.1    tsubai 		return 0;
    124   1.1    tsubai 
    125   1.1    tsubai 	return 1;
    126   1.1    tsubai }
    127   1.1    tsubai 
    128   1.5    tsubai void
    129  1.19   tsutsui fb_attach(struct device *parent, struct device *self, void *aux)
    130   1.1    tsubai {
    131   1.5    tsubai 	struct fb_softc *sc = (void *)self;
    132   1.5    tsubai 	struct wsemuldisplaydev_attach_args waa;
    133   1.5    tsubai 	struct fb_devconfig *dc;
    134   1.5    tsubai 	struct rasops_info *ri;
    135   1.5    tsubai 	int console;
    136   1.5    tsubai 	volatile u_short *ctlreg = NWB253_CTLREG;
    137   1.5    tsubai 	int id;
    138   1.5    tsubai 
    139   1.5    tsubai 	console = fb_is_console();
    140   1.5    tsubai 
    141   1.5    tsubai 	if (console) {
    142   1.5    tsubai 		dc = &fb_console_dc;
    143   1.5    tsubai 		ri = &dc->dc_ri;
    144   1.5    tsubai 		sc->sc_nscreens = 1;
    145   1.5    tsubai 	} else {
    146  1.19   tsutsui 		dc = malloc(sizeof(struct fb_devconfig), M_DEVBUF,
    147  1.19   tsutsui 		    M_WAITOK|M_ZERO);
    148   1.5    tsubai 
    149   1.5    tsubai 		dc->dc_fbbase = NWB253_VRAM;
    150   1.5    tsubai 		fb_common_init(dc);
    151   1.5    tsubai 		ri = &dc->dc_ri;
    152   1.5    tsubai 
    153   1.5    tsubai 		/* clear screen */
    154   1.5    tsubai 		(*ri->ri_ops.eraserows)(ri, 0, ri->ri_rows, 0);
    155   1.5    tsubai 
    156   1.8    tsubai 		fb253_init();
    157   1.5    tsubai 	}
    158   1.5    tsubai 	sc->sc_dc = dc;
    159   1.5    tsubai 
    160   1.5    tsubai 	id = (*ctlreg >> 8) & 0xf;
    161   1.5    tsubai 	printf(": %s, %d x %d, %dbpp\n", devname[id],
    162   1.5    tsubai 	    ri->ri_width, ri->ri_height, ri->ri_depth);
    163   1.5    tsubai 
    164   1.5    tsubai 	waa.console = console;
    165   1.5    tsubai 	waa.scrdata = &fb_screenlist;
    166   1.5    tsubai 	waa.accessops = &fb_accessops;
    167   1.5    tsubai 	waa.accesscookie = sc;
    168   1.1    tsubai 
    169   1.5    tsubai 	config_found(self, &waa, wsemuldisplaydevprint);
    170   1.1    tsubai }
    171   1.1    tsubai 
    172   1.1    tsubai int
    173  1.19   tsutsui fb_common_init(struct fb_devconfig *dc)
    174   1.1    tsubai {
    175   1.5    tsubai 	struct rasops_info *ri = &dc->dc_ri;
    176   1.5    tsubai 	volatile u_short *ctlreg = NWB253_CTLREG;
    177   1.5    tsubai 	int id;
    178   1.5    tsubai 	int width, height, xoff, yoff, cols, rows;
    179   1.5    tsubai 
    180   1.5    tsubai 	id = (*ctlreg >> 8) & 0xf;
    181   1.5    tsubai 
    182   1.5    tsubai 	/* initialize rasops */
    183   1.5    tsubai 	switch (id) {
    184   1.5    tsubai 	case 0:
    185   1.5    tsubai 		width = 816;
    186   1.5    tsubai 		height = 1024;
    187   1.5    tsubai 		break;
    188   1.5    tsubai 	case 1:
    189   1.5    tsubai 	case 2:
    190  1.18       dsl 	default:
    191   1.5    tsubai 		width = 1024;
    192   1.5    tsubai 		height = 768;
    193   1.5    tsubai 		break;
    194   1.1    tsubai 	}
    195   1.1    tsubai 
    196   1.5    tsubai 	ri->ri_width = width;
    197   1.5    tsubai 	ri->ri_height = height;
    198   1.5    tsubai 	ri->ri_depth = 1;
    199   1.5    tsubai 	ri->ri_stride = 2048 / 8;
    200   1.5    tsubai 	ri->ri_bits = dc->dc_fbbase;
    201   1.5    tsubai 	ri->ri_flg = RI_FULLCLEAR;
    202   1.5    tsubai 
    203   1.5    tsubai 	rasops_init(ri, 24, 80);
    204   1.5    tsubai 	rows = (height - 2) / ri->ri_font->fontheight;
    205   1.5    tsubai 	cols = ((width - 2) / ri->ri_font->fontwidth) & ~7;
    206   1.5    tsubai 	xoff = ((width - cols * ri->ri_font->fontwidth) / 2 / 8) & ~3;
    207   1.5    tsubai 	yoff = (height - rows * ri->ri_font->fontheight) / 2;
    208   1.5    tsubai 	rasops_reconfig(ri, rows, cols);
    209  1.15   tsutsui 
    210   1.5    tsubai 	ri->ri_xorigin = xoff;
    211   1.5    tsubai 	ri->ri_yorigin = yoff;
    212   1.5    tsubai 	ri->ri_bits = dc->dc_fbbase + xoff + ri->ri_stride * yoff;
    213  1.15   tsutsui 
    214   1.5    tsubai 	fb_stdscreen.nrows = ri->ri_rows;
    215   1.5    tsubai 	fb_stdscreen.ncols = ri->ri_cols;
    216   1.5    tsubai 	fb_stdscreen.textops = &ri->ri_ops;
    217   1.5    tsubai 	fb_stdscreen.capabilities = ri->ri_caps;
    218   1.1    tsubai 
    219   1.1    tsubai 	return 0;
    220   1.1    tsubai }
    221   1.1    tsubai 
    222   1.1    tsubai int
    223  1.19   tsutsui fb_is_console(void)
    224   1.1    tsubai {
    225   1.5    tsubai 	volatile u_int *dipsw = (void *)DIP_SWITCH;
    226   1.1    tsubai 
    227   1.5    tsubai 	if (*dipsw & 7)					/* XXX right? */
    228   1.5    tsubai 		return 1;
    229   1.1    tsubai 
    230   1.1    tsubai 	return 0;
    231   1.1    tsubai }
    232   1.1    tsubai 
    233   1.1    tsubai int
    234  1.22      jmmv fb_ioctl(void *v, void *vs, u_long cmd, caddr_t data, int flag, struct lwp *l)
    235   1.1    tsubai {
    236   1.5    tsubai 	struct fb_softc *sc = v;
    237   1.5    tsubai 	struct fb_devconfig *dc = sc->sc_dc;
    238   1.5    tsubai 	struct wsdisplay_fbinfo *wdf;
    239   1.1    tsubai 
    240   1.5    tsubai 	switch (cmd) {
    241   1.5    tsubai 	case WSDISPLAYIO_GTYPE:
    242   1.5    tsubai 		*(int *)data = WSDISPLAY_TYPE_UNKNOWN;	/* XXX */
    243   1.5    tsubai 		return 0;
    244   1.1    tsubai 
    245   1.5    tsubai 	case WSDISPLAYIO_GINFO:
    246   1.5    tsubai 		wdf = (void *)data;
    247   1.5    tsubai 		wdf->height = dc->dc_ri.ri_height;
    248   1.5    tsubai 		wdf->width = dc->dc_ri.ri_width;
    249   1.5    tsubai 		wdf->depth = dc->dc_ri.ri_depth;
    250   1.5    tsubai 		wdf->cmsize = 2;
    251   1.5    tsubai 		return 0;
    252   1.1    tsubai 
    253   1.5    tsubai 	case WSDISPLAYIO_SVIDEO:
    254   1.5    tsubai 		if (*(int *)data == WSDISPLAYIO_VIDEO_OFF) {
    255   1.5    tsubai 			volatile u_short *ctlreg = NWB253_CTLREG;
    256   1.5    tsubai 			*ctlreg = 0;			/* stop crtc */
    257   1.8    tsubai 		} else
    258   1.8    tsubai 			fb253_init();
    259   1.5    tsubai 		return 0;
    260   1.1    tsubai 
    261   1.5    tsubai 	case WSDISPLAYIO_GETCMAP:
    262   1.5    tsubai 	case WSDISPLAYIO_PUTCMAP:
    263  1.11   thorpej 		break;
    264   1.1    tsubai 	}
    265  1.10    atatat 	return EPASSTHROUGH;
    266   1.1    tsubai }
    267   1.1    tsubai 
    268   1.4    simonb paddr_t
    269  1.22      jmmv fb_mmap(void *v, void *vs, off_t offset, int prot)
    270   1.1    tsubai {
    271   1.5    tsubai 	struct fb_softc *sc = v;
    272   1.5    tsubai 	struct fb_devconfig *dc = sc->sc_dc;
    273   1.1    tsubai 
    274   1.6    tsubai 	if (offset >= 2048 * 2048 / 8 || offset < 0)
    275   1.1    tsubai 		return -1;
    276   1.1    tsubai 
    277   1.5    tsubai 	return mips_btop((int)dc->dc_fbbase + offset);
    278   1.5    tsubai }
    279   1.1    tsubai 
    280   1.5    tsubai int
    281  1.19   tsutsui fb_alloc_screen(void *v, const struct wsscreen_descr *scrdesc, void **cookiep,
    282  1.19   tsutsui     int *ccolp, int *crowp, long *attrp)
    283   1.5    tsubai {
    284   1.5    tsubai 	struct fb_softc *sc = v;
    285   1.5    tsubai 	struct rasops_info *ri = &sc->sc_dc->dc_ri;
    286   1.5    tsubai 	long defattr;
    287   1.5    tsubai 
    288   1.5    tsubai 	if (sc->sc_nscreens > 0)
    289   1.5    tsubai 		return ENOMEM;
    290   1.5    tsubai 
    291   1.5    tsubai 	*cookiep = ri;
    292   1.5    tsubai 	*ccolp = *crowp = 0;
    293  1.12  junyoung 	(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
    294   1.5    tsubai 	*attrp = defattr;
    295   1.5    tsubai 	sc->sc_nscreens++;
    296   1.1    tsubai 
    297   1.5    tsubai 	return 0;
    298   1.1    tsubai }
    299   1.1    tsubai 
    300   1.5    tsubai void
    301  1.19   tsutsui fb_free_screen(void *v, void *cookie)
    302   1.1    tsubai {
    303   1.5    tsubai 	struct fb_softc *sc = v;
    304   1.5    tsubai 
    305   1.5    tsubai 	if (sc->sc_dc == &fb_console_dc)
    306   1.5    tsubai 		panic("fb_free_screen: console");
    307   1.5    tsubai 
    308   1.5    tsubai 	sc->sc_nscreens--;
    309   1.1    tsubai }
    310   1.1    tsubai 
    311   1.5    tsubai int
    312  1.19   tsutsui fb_show_screen(void *v, void *cookie, int waitok, void (*cb)(void *, int, int),
    313  1.19   tsutsui     void *cbarg)
    314   1.1    tsubai {
    315  1.19   tsutsui 
    316   1.5    tsubai 	return 0;
    317   1.1    tsubai }
    318   1.1    tsubai 
    319   1.5    tsubai void
    320  1.19   tsutsui fb_cnattach(void)
    321   1.1    tsubai {
    322   1.5    tsubai 	struct fb_devconfig *dc = &fb_console_dc;
    323   1.5    tsubai 	struct rasops_info *ri = &dc->dc_ri;
    324   1.5    tsubai 	long defattr;
    325   1.5    tsubai 
    326   1.5    tsubai 	if (!fb_is_console())
    327   1.5    tsubai 		return;
    328   1.5    tsubai 
    329   1.5    tsubai 	dc->dc_fbbase = NWB253_VRAM;
    330   1.5    tsubai 	fb_common_init(dc);
    331   1.5    tsubai 
    332  1.12  junyoung 	(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
    333   1.5    tsubai 	wsdisplay_cnattach(&fb_stdscreen, ri, 0, ri->ri_rows - 1, defattr);
    334   1.5    tsubai }
    335   1.5    tsubai 
    336  1.19   tsutsui static const uint8_t
    337   1.5    tsubai nwp512_data1[] = {
    338   1.5    tsubai 	0x00, 0x44,
    339   1.5    tsubai 	0x01, 0x33,
    340   1.5    tsubai 	0x02, 0x3c,
    341   1.5    tsubai 	0x03, 0x38,
    342   1.5    tsubai 	0x04, 0x84,
    343   1.5    tsubai 	0x05, 0x03,
    344   1.5    tsubai 	0x06, 0x80,
    345   1.5    tsubai 	0x07, 0x80,
    346   1.5    tsubai 	0x08, 0x10,
    347   1.5    tsubai 	0x09, 0x07,
    348   1.5    tsubai 	0x0a, 0x20,
    349   1.5    tsubai 	0x0c, 0x00,
    350   1.5    tsubai 	0x0d, 0x00,
    351   1.5    tsubai 	0x1b, 0x03
    352   1.5    tsubai };
    353   1.1    tsubai 
    354  1.19   tsutsui static const uint8_t
    355   1.5    tsubai nwp512_data2[] = {
    356   1.5    tsubai 	0x1e, 0x08,
    357   1.5    tsubai 	0x20, 0x08,
    358   1.5    tsubai 	0x21, 0x0d
    359   1.5    tsubai };
    360   1.1    tsubai 
    361  1.19   tsutsui static const uint8_t
    362   1.5    tsubai nwp518_data1[] = {
    363   1.5    tsubai 	0x00, 0x52,
    364   1.5    tsubai 	0x01, 0x40,
    365   1.5    tsubai 	0x02, 0x4a,
    366   1.5    tsubai 	0x03, 0x49,
    367   1.5    tsubai 	0x04, 0x63,
    368   1.5    tsubai 	0x05, 0x02,
    369   1.5    tsubai 	0x06, 0x60,
    370   1.5    tsubai 	0x07, 0x60,
    371   1.5    tsubai 	0x08, 0x10,
    372   1.5    tsubai 	0x09, 0x07,
    373   1.5    tsubai 	0x0a, 0x20,
    374   1.5    tsubai 	0x0c, 0x00,
    375   1.5    tsubai 	0x0d, 0x00,
    376   1.5    tsubai 	0x1b, 0x04
    377   1.5    tsubai };
    378   1.1    tsubai 
    379  1.19   tsutsui static const uint8_t
    380   1.5    tsubai nwp518_data2[] = {
    381   1.5    tsubai 	0x1e, 0x08,
    382   1.5    tsubai 	0x20, 0x00,
    383   1.5    tsubai 	0x21, 0x00
    384   1.5    tsubai };
    385   1.1    tsubai 
    386  1.19   tsutsui static const uint8_t
    387   1.5    tsubai nwe501_data1[] = {
    388   1.5    tsubai 	0x00, 0x4b,
    389   1.5    tsubai 	0x01, 0x40,
    390   1.5    tsubai 	0x02, 0x4a,
    391   1.5    tsubai 	0x03, 0x43,
    392   1.5    tsubai 	0x04, 0x64,
    393   1.5    tsubai 	0x05, 0x02,
    394   1.5    tsubai 	0x06, 0x60,
    395   1.5    tsubai 	0x07, 0x60,
    396   1.5    tsubai 	0x08, 0x10,
    397   1.5    tsubai 	0x09, 0x07,
    398   1.5    tsubai 	0x0a, 0x20,
    399   1.5    tsubai 	0x0c, 0x00,
    400   1.5    tsubai 	0x0d, 0x00,
    401   1.5    tsubai 	0x1b, 0x04
    402   1.5    tsubai };
    403   1.1    tsubai 
    404  1.19   tsutsui static const uint8_t
    405   1.5    tsubai nwe501_data2[] = {
    406   1.5    tsubai 	0x1e, 0x08,
    407   1.5    tsubai 	0x20, 0x00,
    408   1.5    tsubai 	0x21, 0x00
    409   1.5    tsubai };
    410   1.1    tsubai 
    411  1.19   tsutsui static const uint8_t
    412   1.5    tsubai *crtc_data[3][2] = {
    413   1.5    tsubai 	{ nwp512_data1, nwp512_data2 },
    414   1.5    tsubai 	{ nwp518_data1, nwp518_data2 },
    415   1.5    tsubai 	{ nwe501_data1, nwe501_data2 }
    416   1.5    tsubai };
    417   1.1    tsubai 
    418   1.1    tsubai static void
    419   1.9      matt fb253_init(void)
    420   1.1    tsubai {
    421   1.5    tsubai 	volatile u_short *ctlreg = NWB253_CTLREG;
    422   1.5    tsubai 	volatile u_short *crtreg = NWB253_CRTREG;
    423   1.8    tsubai 	int id = (*ctlreg >> 8) & 0xf;
    424  1.19   tsutsui 	const uint8_t *p;
    425   1.5    tsubai 	int i;
    426   1.5    tsubai 
    427   1.5    tsubai 	*ctlreg = 0;			/* stop crtc */
    428   1.5    tsubai 	delay(10);
    429   1.5    tsubai 
    430   1.5    tsubai 	/* initialize crtc without R3{0,1,2} */
    431   1.5    tsubai 	p = crtc_data[id][0];
    432   1.5    tsubai 	for (i = 0; i < 28; i++) {
    433   1.5    tsubai 		*crtreg++ = *p++;
    434   1.5    tsubai 		delay(10);
    435   1.5    tsubai 	}
    436   1.5    tsubai 
    437   1.5    tsubai 	*ctlreg = 0x02;			/* start crtc */
    438   1.5    tsubai 	delay(10);
    439   1.5    tsubai 
    440   1.5    tsubai 	/* set crtc control reg */
    441   1.5    tsubai 	p = crtc_data[id][1];
    442   1.5    tsubai 	for (i = 0; i < 6; i++) {
    443   1.5    tsubai 		*crtreg++ = *p++;
    444   1.5    tsubai 		delay(10);
    445   1.5    tsubai 	}
    446   1.5    tsubai }
    447   1.5    tsubai 
    448   1.5    tsubai #if 0
    449   1.5    tsubai static struct wsdisplay_font newsrom8x16;
    450   1.5    tsubai static struct wsdisplay_font newsrom12x24;
    451   1.5    tsubai static char fontarea16[96][32];
    452   1.5    tsubai static char fontarea24[96][96];
    453   1.5    tsubai 
    454   1.5    tsubai void
    455  1.19   tsutsui initfont(struct rasops_info *ri)
    456   1.5    tsubai {
    457   1.5    tsubai 	int c, x;
    458   1.5    tsubai 
    459   1.5    tsubai 	for (c = 0; c < 96; c++) {
    460   1.5    tsubai 		x = ((c & 0x1f) | ((c & 0xe0) << 2)) << 7;
    461  1.19   tsutsui 		memcpy(fontarea16 + c, (char *)0xb8e00000 + x + 96, 32);
    462  1.19   tsutsui 		memcpy(fontarea24 + c, (char *)0xb8e00000 + x, 96);
    463   1.5    tsubai 	}
    464   1.5    tsubai 
    465   1.5    tsubai 	newsrom8x16.name = "rom8x16";
    466   1.5    tsubai 	newsrom8x16.firstchar = 32;
    467   1.5    tsubai 	newsrom8x16.numchars = 96;
    468   1.5    tsubai 	newsrom8x16.encoding = WSDISPLAY_FONTENC_ISO;
    469   1.5    tsubai 	newsrom8x16.fontwidth = 8;
    470   1.5    tsubai 	newsrom8x16.fontheight = 16;
    471   1.5    tsubai 	newsrom8x16.stride = 2;
    472   1.5    tsubai 	newsrom8x16.bitorder = WSDISPLAY_FONTORDER_L2R;
    473   1.5    tsubai 	newsrom8x16.byteorder = WSDISPLAY_FONTORDER_L2R;
    474   1.5    tsubai 	newsrom8x16.data = fontarea16;
    475   1.5    tsubai 
    476   1.5    tsubai 	newsrom12x24.name = "rom12x24";
    477   1.5    tsubai 	newsrom12x24.firstchar = 32;
    478   1.5    tsubai 	newsrom12x24.numchars = 96;
    479   1.5    tsubai 	newsrom12x24.encoding = WSDISPLAY_FONTENC_ISO;
    480   1.5    tsubai 	newsrom12x24.fontwidth = 12;
    481   1.5    tsubai 	newsrom12x24.fontheight = 24;
    482   1.5    tsubai 	newsrom12x24.stride = 4;
    483   1.5    tsubai 	newsrom12x24.bitorder = WSDISPLAY_FONTORDER_L2R;
    484   1.5    tsubai 	newsrom12x24.byteorder = WSDISPLAY_FONTORDER_L2R;
    485   1.5    tsubai 	newsrom12x24.data = fontarea24;
    486   1.5    tsubai 
    487   1.5    tsubai 	ri->ri_font = &newsrom8x16;
    488   1.5    tsubai 	ri->ri_font = &newsrom12x24;
    489   1.5    tsubai 	ri->ri_wsfcookie = -1;		/* not using wsfont */
    490   1.1    tsubai }
    491   1.5    tsubai #endif
    492