1*41480Smckusick /* 2*41480Smckusick * Copyright (c) 1988 University of Utah. 3*41480Smckusick * Copyright (c) 1990 The Regents of the University of California. 4*41480Smckusick * All rights reserved. 5*41480Smckusick * 6*41480Smckusick * This code is derived from software contributed to Berkeley by 7*41480Smckusick * the Systems Programming Group of the University of Utah Computer 8*41480Smckusick * Science Department. 9*41480Smckusick * 10*41480Smckusick * %sccs.include.redist.c% 11*41480Smckusick * 12*41480Smckusick * from: Utah $Hdr: grf_gb.c 1.13 89/04/11$ 13*41480Smckusick * 14*41480Smckusick * @(#)grf_gb.c 7.1 (Berkeley) 05/08/90 15*41480Smckusick */ 16*41480Smckusick 17*41480Smckusick #include "grf.h" 18*41480Smckusick #if NGRF > 0 19*41480Smckusick 20*41480Smckusick /* 21*41480Smckusick * Graphics routines for the Gatorbox. 22*41480Smckusick * 23*41480Smckusick * Note: In the context of this system, "gator" and "gatorbox" both refer to 24*41480Smckusick * HP 987x0 graphics systems. "Gator" is not used for high res mono. 25*41480Smckusick * (as in 9837 Gator systems) 26*41480Smckusick */ 27*41480Smckusick #include "param.h" 28*41480Smckusick #include "errno.h" 29*41480Smckusick 30*41480Smckusick #include "grfioctl.h" 31*41480Smckusick #include "grfvar.h" 32*41480Smckusick #include "grf_gbreg.h" 33*41480Smckusick 34*41480Smckusick #include "machine/cpu.h" 35*41480Smckusick 36*41480Smckusick #define CRTC_DATA_LENGTH 0x0e 37*41480Smckusick u_char crtc_init_data[CRTC_DATA_LENGTH] = { 38*41480Smckusick 0x29, 0x20, 0x23, 0x04, 0x30, 0x0b, 0x30, 39*41480Smckusick 0x30, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00 40*41480Smckusick }; 41*41480Smckusick 42*41480Smckusick /* 43*41480Smckusick * Initialize hardware. 44*41480Smckusick * Must point g_display at a grfinfo structure describing the hardware. 45*41480Smckusick * Returns 0 if hardware not present, non-zero ow. 46*41480Smckusick */ 47*41480Smckusick gb_init(gp, addr) 48*41480Smckusick struct grf_softc *gp; 49*41480Smckusick u_char *addr; 50*41480Smckusick { 51*41480Smckusick register struct gboxfb *gbp; 52*41480Smckusick struct grfinfo *gi = &gp->g_display; 53*41480Smckusick u_char *fbp, save; 54*41480Smckusick int fboff; 55*41480Smckusick 56*41480Smckusick gbp = (struct gboxfb *) addr; 57*41480Smckusick gi->gd_regaddr = (caddr_t) UNIOV(addr); 58*41480Smckusick gi->gd_regsize = 0x10000; 59*41480Smckusick gi->gd_fbwidth = 1024; /* XXX */ 60*41480Smckusick gi->gd_fbheight = 1024; /* XXX */ 61*41480Smckusick fboff = (gbp->fbomsb << 8) | gbp->fbolsb; 62*41480Smckusick gi->gd_fbaddr = (caddr_t) (*(addr + fboff) << 16); 63*41480Smckusick gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight; 64*41480Smckusick gi->gd_dwidth = 1024; /* XXX */ 65*41480Smckusick gi->gd_dheight = 768; /* XXX */ 66*41480Smckusick gi->gd_planes = 0; /* how do we do this? */ 67*41480Smckusick /* 68*41480Smckusick * The minimal register info here is from the Gatorbox X driver. 69*41480Smckusick */ 70*41480Smckusick fbp = (u_char *) IOV(gi->gd_fbaddr); 71*41480Smckusick gbp->write_protect = 0; 72*41480Smckusick gbp->interrupt = 4; /** fb_enable ? **/ 73*41480Smckusick gbp->rep_rule = 3; /* GXcopy */ 74*41480Smckusick gbp->blink1 = 0xff; 75*41480Smckusick gbp->blink2 = 0xff; 76*41480Smckusick 77*41480Smckusick gb_microcode(gbp); 78*41480Smckusick 79*41480Smckusick /* 80*41480Smckusick * Find out how many colors are available by determining 81*41480Smckusick * which planes are installed. That is, write all ones to 82*41480Smckusick * a frame buffer location, see how many ones are read back. 83*41480Smckusick */ 84*41480Smckusick save = *fbp; 85*41480Smckusick *fbp = 0xFF; 86*41480Smckusick gi->gd_colors = *fbp + 1; 87*41480Smckusick *fbp = save; 88*41480Smckusick return(1); 89*41480Smckusick } 90*41480Smckusick 91*41480Smckusick /* 92*41480Smckusick * Program the 6845. 93*41480Smckusick */ 94*41480Smckusick gb_microcode(gbp) 95*41480Smckusick register struct gboxfb *gbp; 96*41480Smckusick { 97*41480Smckusick register int i; 98*41480Smckusick 99*41480Smckusick for (i = 0; i < CRTC_DATA_LENGTH; i++) { 100*41480Smckusick gbp->crtc_address = i; 101*41480Smckusick gbp->crtc_data = crtc_init_data[i]; 102*41480Smckusick } 103*41480Smckusick } 104*41480Smckusick 105*41480Smckusick /* 106*41480Smckusick * Change the mode of the display. 107*41480Smckusick * Right now all we can do is grfon/grfoff. 108*41480Smckusick * Return a UNIX error number or 0 for success. 109*41480Smckusick */ 110*41480Smckusick gb_mode(gp, cmd) 111*41480Smckusick register struct grf_softc *gp; 112*41480Smckusick { 113*41480Smckusick struct gboxfb *gbp; 114*41480Smckusick int error = 0; 115*41480Smckusick 116*41480Smckusick gbp = (struct gboxfb *) IOV(gp->g_display.gd_regaddr); 117*41480Smckusick switch (cmd) { 118*41480Smckusick case GM_GRFON: 119*41480Smckusick gbp->sec_interrupt = 1; 120*41480Smckusick break; 121*41480Smckusick case GM_GRFOFF: 122*41480Smckusick break; 123*41480Smckusick default: 124*41480Smckusick error = EINVAL; 125*41480Smckusick break; 126*41480Smckusick } 127*41480Smckusick return(error); 128*41480Smckusick } 129*41480Smckusick 130*41480Smckusick #endif 131