1 /* 2 * Copyright (c) 1991 University of Utah. 3 * Copyright (c) 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Systems Programming Group of the University of Utah Computer 8 * Science Department and Mark Davies of the Department of Computer 9 * Science, Victoria University of Wellington, New Zealand. 10 * 11 * %sccs.include.redist.c% 12 * 13 * from: Utah $Hdr: grf_hy.c 1.1 92/01/22$ 14 * 15 * @(#)grf_hy.c 7.2 (Berkeley) 10/11/92 16 */ 17 18 #include "grf.h" 19 #if NGRF > 0 20 21 /* 22 * Graphics routines for HYPERION frame buffer 23 */ 24 #include <sys/param.h> 25 #include <sys/errno.h> 26 27 #include <hp/dev/grfioctl.h> 28 #include <hp/dev/grfvar.h> 29 #include <hp300/dev/grf_hyreg.h> 30 31 #include <machine/cpu.h> 32 33 caddr_t badhyaddr = (caddr_t) -1; 34 35 /* 36 * Initialize hardware. 37 * Must fill in the grfinfo structure in g_softc. 38 * Returns 0 if hardware not present, non-zero ow. 39 */ 40 hy_init(gp, addr) 41 struct grf_softc *gp; 42 caddr_t addr; 43 { 44 register struct hyboxfb *hy = (struct hyboxfb *) addr; 45 struct grfinfo *gi = &gp->g_display; 46 int fboff; 47 extern caddr_t sctopa(), iomap(); 48 49 if (ISIIOVA(addr)) 50 gi->gd_regaddr = (caddr_t) IIOP(addr); 51 else 52 gi->gd_regaddr = sctopa(vatosc(addr)); 53 gi->gd_regsize = 0x20000; 54 gi->gd_fbwidth = (hy->fbwmsb << 8) | hy->fbwlsb; 55 gi->gd_fbheight = (hy->fbhmsb << 8) | hy->fbhlsb; 56 gi->gd_fbsize = (gi->gd_fbwidth * gi->gd_fbheight) >> 3; 57 fboff = (hy->fbomsb << 8) | hy->fbolsb; 58 gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16); 59 if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) { 60 /* 61 * For DIO II space the fbaddr just computed is the offset 62 * from the select code base (regaddr) of the framebuffer. 63 * Hence it is also implicitly the size of the register set. 64 */ 65 gi->gd_regsize = (int) gi->gd_fbaddr; 66 gi->gd_fbaddr += (int) gi->gd_regaddr; 67 gp->g_regkva = addr; 68 gp->g_fbkva = addr + gi->gd_regsize; 69 } else { 70 /* 71 * For DIO space we need to map the seperate framebuffer. 72 */ 73 gp->g_regkva = addr; 74 gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize); 75 } 76 gi->gd_dwidth = (hy->dwmsb << 8) | hy->dwlsb; 77 gi->gd_dheight = (hy->dhmsb << 8) | hy->dhlsb; 78 gi->gd_planes = hy->num_planes; 79 gi->gd_colors = 1 << gi->gd_planes; 80 81 return(1); 82 } 83 84 /* 85 * Change the mode of the display. 86 * Right now all we can do is grfon/grfoff. 87 * Return a UNIX error number or 0 for success. 88 * Function may not be needed anymore. 89 */ 90 hy_mode(gp, cmd) 91 struct grf_softc *gp; 92 { 93 int error = 0; 94 95 switch (cmd) { 96 case GM_GRFON: 97 case GM_GRFOFF: 98 break; 99 default: 100 error = EINVAL; 101 break; 102 } 103 return(error); 104 } 105 #endif 106