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_rb.c 1.10 89/04/11$ 13*41480Smckusick * 14*41480Smckusick * @(#)grf_rb.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 Renaissance, HP98720 Graphics system. 22*41480Smckusick */ 23*41480Smckusick #include "param.h" 24*41480Smckusick #include "errno.h" 25*41480Smckusick 26*41480Smckusick #include "grfioctl.h" 27*41480Smckusick #include "grfvar.h" 28*41480Smckusick #include "grf_rbreg.h" 29*41480Smckusick 30*41480Smckusick #include "machine/cpu.h" 31*41480Smckusick 32*41480Smckusick #ifdef notyet 33*41480Smckusick static short rb_microcode[] = { 34*41480Smckusick 0x5efe, 0x8a38, 0x0000, 0x0000, 0x0f00, 0, 0, 0, 35*41480Smckusick 0x3efe, 0x8a38, 0x0000, 0x7003, 0xf706, 0, 0, 0, 36*41480Smckusick 0x1efe, 0x8a38, 0x0000, 0x0000, 0x0000, 0, 0, 0, 37*41480Smckusick 0x3efe, 0x8a38, 0x0000, 0x7003, 0xfc06, 0, 0, 0, 38*41480Smckusick 0x1efe, 0x8a38, 0x0000, 0x0000, 0x0000, 0, 0, 0, 39*41480Smckusick 0x3efe, 0x8a38, 0x0004, 0x40f7, 0xa006, 0, 0, 0, 40*41480Smckusick 0x9efe, 0x8a38, 0x0000, 0x0000, 0x0000, 0, 0, 0, 41*41480Smckusick 0x1efe, 0x8a38, 0x0000, 0x0000, 0x0000 42*41480Smckusick }; 43*41480Smckusick #endif 44*41480Smckusick 45*41480Smckusick /* 46*41480Smckusick * Initialize hardware. 47*41480Smckusick * Must point g_display at a grfinfo structure describing the hardware. 48*41480Smckusick * Returns 0 if hardware not present, non-zero ow. 49*41480Smckusick */ 50*41480Smckusick rb_init(gp, addr) 51*41480Smckusick struct grf_softc *gp; 52*41480Smckusick u_char *addr; 53*41480Smckusick { 54*41480Smckusick register struct rboxfb *rbp; 55*41480Smckusick struct grfinfo *gi = &gp->g_display; 56*41480Smckusick int fboff; 57*41480Smckusick 58*41480Smckusick rbp = (struct rboxfb *) addr; 59*41480Smckusick gi->gd_regaddr = (caddr_t) UNIOV(addr); 60*41480Smckusick gi->gd_regsize = 0x20000; 61*41480Smckusick gi->gd_fbwidth = (rbp->fbwmsb << 8) | rbp->fbwlsb; 62*41480Smckusick gi->gd_fbheight = (rbp->fbhmsb << 8) | rbp->fbhlsb; 63*41480Smckusick fboff = (rbp->fbomsb << 8) | rbp->fbolsb; 64*41480Smckusick gi->gd_fbaddr = (caddr_t) (*(addr + fboff) << 16); 65*41480Smckusick gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight; 66*41480Smckusick gi->gd_dwidth = (rbp->dwmsb << 8) | rbp->dwlsb; 67*41480Smckusick gi->gd_dheight = (rbp->dwmsb << 8) | rbp->dwlsb; 68*41480Smckusick gi->gd_planes = 0; /* ?? */ 69*41480Smckusick gi->gd_colors = 256; 70*41480Smckusick return(1); 71*41480Smckusick } 72*41480Smckusick 73*41480Smckusick #ifdef notyet 74*41480Smckusick /* 75*41480Smckusick * Download the microcode to the rbox. 76*41480Smckusick */ 77*41480Smckusick rb_download_microcode(regbase) 78*41480Smckusick caddr_t regbase; 79*41480Smckusick { 80*41480Smckusick register short *rb_microcode_ptr = rb_microcode; 81*41480Smckusick register short *rb_cntlstore_ptr = (short *)((char *)regbase + 0xC000); 82*41480Smckusick register int i; 83*41480Smckusick 84*41480Smckusick /* 85*41480Smckusick * Reset and halt transform engine 86*41480Smckusick */ 87*41480Smckusick *((char *)regbase + 0x8002) = 0x00a0; 88*41480Smckusick *((char *)regbase + 0x8002) = 0x0020; 89*41480Smckusick *((char *)regbase + 0x8002) = 0x0080; 90*41480Smckusick 91*41480Smckusick /* 92*41480Smckusick * Select the first bank of control store. 93*41480Smckusick */ 94*41480Smckusick *((char *)regbase + 0x8007) = 0x0; 95*41480Smckusick 96*41480Smckusick /* 97*41480Smckusick * Write the microcode into the control store address space. 98*41480Smckusick */ 99*41480Smckusick for (i = 0; i < sizeof(rb_microcode) / sizeof(rb_microcode[0]); i++) 100*41480Smckusick *rb_cntlstore_ptr++ = *rb_microcode_ptr++; 101*41480Smckusick 102*41480Smckusick /* 103*41480Smckusick * Start microcode execution. 104*41480Smckusick */ 105*41480Smckusick *(short *)((char *)regbase + 0x8002) = 0x2000; 106*41480Smckusick *(short *)((char *)regbase + 0x8002) = 0x0; 107*41480Smckusick 108*41480Smckusick /* 109*41480Smckusick * wait for renaissance to finish up. 110*41480Smckusick */ 111*41480Smckusick for (i = 0; i < 1000; i++) { 112*41480Smckusick if (*((char *)regbase + 0x8012) < 0) 113*41480Smckusick continue; 114*41480Smckusick } 115*41480Smckusick } 116*41480Smckusick #endif 117*41480Smckusick 118*41480Smckusick /* 119*41480Smckusick * Change the mode of the display. 120*41480Smckusick * Right now all we can do is grfon/grfoff. 121*41480Smckusick * Return a UNIX error number or 0 for success. 122*41480Smckusick */ 123*41480Smckusick rb_mode(gp, cmd) 124*41480Smckusick register struct grf_softc *gp; 125*41480Smckusick { 126*41480Smckusick register struct rboxfb *rbp; 127*41480Smckusick int error = 0; 128*41480Smckusick 129*41480Smckusick rbp = (struct rboxfb *) IOV(gp->g_display.gd_regaddr); 130*41480Smckusick switch (cmd) { 131*41480Smckusick /* 132*41480Smckusick * The minimal register info here is from the Renaissance X driver. 133*41480Smckusick */ 134*41480Smckusick case GM_GRFON: 135*41480Smckusick case GM_GRFOFF: 136*41480Smckusick break; 137*41480Smckusick case GM_GRFOVON: 138*41480Smckusick rbp->write_enable = 0; 139*41480Smckusick rbp->opwen = 0xF; 140*41480Smckusick rbp->drive = 0x10; 141*41480Smckusick break; 142*41480Smckusick case GM_GRFOVOFF: 143*41480Smckusick rbp->opwen = 0; 144*41480Smckusick rbp->write_enable = 0xffffffff; 145*41480Smckusick rbp->drive = 0x01; 146*41480Smckusick break; 147*41480Smckusick default: 148*41480Smckusick error = EINVAL; 149*41480Smckusick break; 150*41480Smckusick } 151*41480Smckusick return(error); 152*41480Smckusick } 153*41480Smckusick 154*41480Smckusick #endif 155