home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / sys / hp300 / dev / grf_dv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-08  |  5.1 KB  |  193 lines

  1. /*
  2.  * Copyright (c) 1988 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.
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. Redistributions in binary form must reproduce the above copyright
  16.  *    notice, this list of conditions and the following disclaimer in the
  17.  *    documentation and/or other materials provided with the distribution.
  18.  * 3. All advertising materials mentioning features or use of this software
  19.  *    must display the following acknowledgement:
  20.  *    This product includes software developed by the University of
  21.  *    California, Berkeley and its contributors.
  22.  * 4. Neither the name of the University nor the names of its contributors
  23.  *    may be used to endorse or promote products derived from this software
  24.  *    without specific prior written permission.
  25.  *
  26.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  27.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  30.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36.  * SUCH DAMAGE.
  37.  *
  38.  * from: Utah $Hdr: grf_dv.c 1.10 91/04/02$
  39.  *
  40.  *    @(#)grf_dv.c    7.4 (Berkeley) 5/7/91
  41.  */
  42.  
  43. #include "grf.h"
  44. #if NGRF > 0
  45.  
  46. /*
  47.  * Graphics routines for the DaVinci, HP98730/98731 Graphics system.
  48.  */
  49. #include "sys/param.h"
  50. #include "sys/errno.h"
  51.  
  52. #include "grfioctl.h"
  53. #include "grfvar.h"
  54. #include "grf_dvreg.h"
  55.  
  56. #include "../include/cpu.h"
  57.  
  58. /*
  59.  * Initialize hardware.
  60.  * Must point g_display at a grfinfo structure describing the hardware.
  61.  * Returns 0 if hardware not present, non-zero ow.
  62.  */
  63. dv_init(gp, addr)
  64.     struct grf_softc *gp;
  65.     caddr_t addr;
  66. {
  67.     register struct dvboxfb *dbp;
  68.     struct grfinfo *gi = &gp->g_display;
  69.     int fboff;
  70.     extern caddr_t sctopa(), iomap();
  71.  
  72.     dbp = (struct dvboxfb *) addr;
  73.     if (ISIIOVA(addr))
  74.         gi->gd_regaddr = (caddr_t) IIOP(addr);
  75.     else
  76.         gi->gd_regaddr = sctopa(vatosc(addr));
  77.     gi->gd_regsize = 0x20000;
  78.     gi->gd_fbwidth = (dbp->fbwmsb << 8) | dbp->fbwlsb;
  79.     gi->gd_fbheight = (dbp->fbhmsb << 8) | dbp->fbhlsb;
  80.     gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight;
  81.     fboff = (dbp->fbomsb << 8) | dbp->fbolsb;
  82.     gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16);
  83.     if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) {
  84.         /*
  85.          * For DIO II space the fbaddr just computed is the offset
  86.          * from the select code base (regaddr) of the framebuffer.
  87.          * Hence it is also implicitly the size of the register set.
  88.          */
  89.         gi->gd_regsize = (int) gi->gd_fbaddr;
  90.         gi->gd_fbaddr += (int) gi->gd_regaddr;
  91.         gp->g_regkva = addr;
  92.         gp->g_fbkva = addr + gi->gd_regsize;
  93.     } else {
  94.         /*
  95.          * For DIO space we need to map the seperate framebuffer.
  96.          */
  97.         gp->g_regkva = addr;
  98.         gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize);
  99.     }
  100.     gi->gd_dwidth = (dbp->dwmsb << 8) | dbp->dwlsb;
  101.     gi->gd_dheight = (dbp->dwmsb << 8) | dbp->dwlsb;
  102.     gi->gd_planes = 0;    /* ?? */
  103.     gi->gd_colors = 256;
  104.  
  105.     dv_reset(dbp);
  106.     return(1);
  107. }
  108.  
  109. /*
  110.  *  Magic code herein.
  111.  */
  112. dv_reset(dbp)
  113.     register struct dvboxfb *dbp;
  114. {
  115.       dbp->reset = 0x80;
  116.     DELAY(100);
  117.  
  118.     dbp->interrupt = 0x04;
  119.     dbp->en_scan   = 0x01;
  120.     dbp->fbwen     = ~0;
  121.     dbp->opwen     = ~0;
  122.     dbp->fold      = 0x01;
  123.     dbp->drive     = 0x01;
  124.     dbp->rep_rule  = 0x33;
  125.     dbp->alt_rr    = 0x33;
  126.     dbp->zrr       = 0x33;
  127.  
  128.     dbp->fbvenp    = 0xFF;
  129.     dbp->dispen    = 0x01;
  130.     dbp->fbvens    = 0x0;
  131.     dbp->fv_trig   = 0x01;
  132.     DELAY(100);
  133.     dbp->vdrive    = 0x0;
  134.     dbp->zconfig   = 0x0;
  135.  
  136.     while (dbp->wbusy & 0x01)
  137.       DELAY(100);
  138.  
  139.     dbp->cmapbank = 0;
  140.  
  141.     dbp->red0   = 0;
  142.     dbp->red1   = 0;
  143.     dbp->green0 = 0;
  144.     dbp->green1 = 0;
  145.     dbp->blue0  = 0;
  146.     dbp->blue1  = 0;
  147.  
  148.     dbp->panxh   = 0;
  149.     dbp->panxl   = 0;
  150.     dbp->panyh   = 0;
  151.     dbp->panyl   = 0;
  152.     dbp->zoom    = 0;
  153.     dbp->cdwidth = 0x50;
  154.     dbp->chstart = 0x52;
  155.     dbp->cvwidth = 0x22;
  156.     dbp->pz_trig = 1;
  157. }
  158.  
  159. /*
  160.  * Change the mode of the display.
  161.  * Right now all we can do is grfon/grfoff.
  162.  * Return a UNIX error number or 0 for success.
  163.  */
  164. dv_mode(gp, cmd)
  165.     register struct grf_softc *gp;
  166. {
  167.     register struct dvboxfb *dbp;
  168.     int error = 0;
  169.  
  170.     dbp = (struct dvboxfb *) gp->g_regkva;
  171.     switch (cmd) {
  172.     case GM_GRFON:
  173.           dbp->dispen = 0x01;
  174.           break;
  175.     case GM_GRFOFF:
  176.         break;
  177.     case GM_GRFOVON:
  178.         dbp->opwen = 0xF;
  179.         dbp->drive = 0x10;
  180.         break;
  181.     case GM_GRFOVOFF:
  182.         dbp->opwen = 0;
  183.         dbp->drive = 0x01;
  184.         break;
  185.     default:
  186.         error = EINVAL;
  187.         break;
  188.     }
  189.     return(error);
  190. }
  191.  
  192. #endif
  193.