xref: /csrg-svn/sys/hp300/dev/grf_machdep.c (revision 65630)
153931Shibler /*
253931Shibler  * Copyright (c) 1991 University of Utah.
363151Sbostic  * Copyright (c) 1990, 1993
463151Sbostic  *	The Regents of the University of California.  All rights reserved.
553931Shibler  *
653931Shibler  * This code is derived from software contributed to Berkeley by
753931Shibler  * the Systems Programming Group of the University of Utah Computer
853931Shibler  * Science Department.
953931Shibler  *
1053931Shibler  * %sccs.include.redist.c%
1153931Shibler  *
1253931Shibler  * from: Utah $Hdr: grf_machdep.c 1.1 92/01/21
1353931Shibler  *
14*65630Sbostic  *	@(#)grf_machdep.c	8.2 (Berkeley) 01/12/94
1553931Shibler  */
1653931Shibler 
1753931Shibler /*
1853931Shibler  * Graphics display driver for the HP300/400 DIO/DIO-II based machines.
1953931Shibler  * This is the hardware-dependent configuration portion of the driver.
2053931Shibler  */
2153931Shibler 
2253931Shibler #include "grf.h"
2353931Shibler #if NGRF > 0
2453931Shibler 
2556507Sbostic #include <sys/param.h>
2653931Shibler 
2756507Sbostic #include <hp/dev/device.h>
2856507Sbostic #include <hp/dev/grfioctl.h>
2956507Sbostic #include <hp/dev/grfvar.h>
3056507Sbostic #include <hp/dev/grfreg.h>
3153931Shibler 
3253931Shibler int grfprobe();
3353931Shibler struct	driver grfdriver = { grfprobe, "grf" };
3453931Shibler 
3553931Shibler /*
3653931Shibler  * XXX called from ite console init routine.
3753931Shibler  * Does just what configure will do later but without printing anything.
3853931Shibler  */
grfconfig()3953931Shibler grfconfig()
4053931Shibler {
4153931Shibler 	register caddr_t addr;
4253931Shibler 	register struct hp_hw *hw;
4353931Shibler 	register struct hp_device *hd, *nhd;
4453931Shibler 
4553931Shibler 	for (hw = sc_table; hw->hw_type; hw++) {
4653931Shibler 	        if (!HW_ISDEV(hw, D_BITMAP))
4753931Shibler 			continue;
4853931Shibler 		/*
4953931Shibler 		 * Found one, now match up with a logical unit number
5053931Shibler 		 */
5153931Shibler 		nhd = NULL;
5253931Shibler 		addr = hw->hw_kva;
5353931Shibler 		for (hd = hp_dinit; hd->hp_driver; hd++) {
5453931Shibler 			if (hd->hp_driver != &grfdriver || hd->hp_alive)
5553931Shibler 				continue;
5653931Shibler 			/*
5753931Shibler 			 * Wildcarded.  If first, remember as possible match.
5853931Shibler 			 */
5953931Shibler 			if (hd->hp_addr == NULL) {
6053931Shibler 				if (nhd == NULL)
6153931Shibler 					nhd = hd;
6253931Shibler 				continue;
6353931Shibler 			}
6453931Shibler 			/*
6553931Shibler 			 * Not wildcarded.
6653931Shibler 			 * If exact match done searching, else keep looking.
6753931Shibler 			 */
6853931Shibler 			if (sctova(hd->hp_addr) == addr) {
6953931Shibler 				nhd = hd;
7053931Shibler 				break;
7153931Shibler 			}
7253931Shibler 		}
7353931Shibler 		/*
7453931Shibler 		 * Found a match, initialize
7553931Shibler 		 */
7653931Shibler 		if (nhd && grfinit(addr, nhd->hp_unit))
7753931Shibler 			nhd->hp_addr = addr;
7853931Shibler 	}
7953931Shibler }
8053931Shibler 
8153931Shibler /*
8253931Shibler  * Normal init routine called by configure() code
8353931Shibler  */
8453931Shibler grfprobe(hd)
8553931Shibler 	struct hp_device *hd;
8653931Shibler {
8753931Shibler 	struct grf_softc *gp = &grf_softc[hd->hp_unit];
8853931Shibler 
8953931Shibler 	if ((gp->g_flags & GF_ALIVE) == 0 &&
9053931Shibler 	    !grfinit(hd->hp_addr, hd->hp_unit))
9153931Shibler 		return(0);
9253931Shibler 	printf("grf%d: %d x %d ", hd->hp_unit,
9353931Shibler 	       gp->g_display.gd_dwidth, gp->g_display.gd_dheight);
9453931Shibler 	if (gp->g_display.gd_colors == 2)
9553931Shibler 		printf("monochrome");
9653931Shibler 	else
9753931Shibler 		printf("%d color", gp->g_display.gd_colors);
9853931Shibler 	printf(" %s display\n", gp->g_sw->gd_desc);
9953931Shibler 	return(1);
10053931Shibler }
10153931Shibler 
grfinit(addr,unit)10253931Shibler grfinit(addr, unit)
10353931Shibler 	caddr_t addr;
104*65630Sbostic 	int unit;
10553931Shibler {
10653931Shibler 	struct grf_softc *gp = &grf_softc[unit];
10753931Shibler 	register struct grfsw *gsw;
10853931Shibler 	struct grfreg *gr;
10953931Shibler 
11053931Shibler 	gr = (struct grfreg *) addr;
11153931Shibler 	if (gr->gr_id != GRFHWID)
11253931Shibler 		return(0);
11353931Shibler 	for (gsw = grfsw; gsw < &grfsw[ngrfsw]; gsw++)
11453931Shibler 		if (gsw->gd_hwid == gr->gr_id2)
11553931Shibler 			break;
11653931Shibler 	if (gsw < &grfsw[ngrfsw] && (*gsw->gd_init)(gp, addr)) {
11753931Shibler 		gp->g_sw = gsw;
11853931Shibler 		gp->g_display.gd_id = gsw->gd_swid;
11953931Shibler 		gp->g_flags = GF_ALIVE;
12053931Shibler 		return(1);
12153931Shibler 	}
12253931Shibler 	return(0);
12353931Shibler }
12453931Shibler #endif
125