home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / sys / hp300 / dev / ite_dv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-08  |  6.2 KB  |  247 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: ite_dv.c 1.7 91/01/21$
  39.  *
  40.  *    @(#)ite_dv.c    7.5 (Berkeley) 5/7/91
  41.  */
  42.  
  43. #include "ite.h"
  44. #if NITE > 0
  45.  
  46. #include "param.h"
  47. #include "conf.h"
  48. #include "proc.h"
  49. #include "ioctl.h"
  50. #include "tty.h"
  51. #include "systm.h"
  52.  
  53. #include "itevar.h"
  54. #include "itereg.h"
  55. #include "grf_dvreg.h"
  56.  
  57. #include "machine/cpu.h"
  58.  
  59. /* XXX */
  60. #include "grfioctl.h"
  61. #include "grfvar.h"
  62.  
  63. #define REGBASE        ((struct dvboxfb *)(ip->regbase))
  64. #define WINDOWMOVER    dvbox_windowmove
  65.  
  66. dvbox_init(ip)
  67.     struct ite_softc *ip;
  68. {
  69.     int i;
  70.     
  71.     /* XXX */
  72.     if (ip->regbase == 0) {
  73.         struct grf_softc *gp = &grf_softc[ip - ite_softc];
  74.         ip->regbase = gp->g_regkva;
  75.         ip->fbbase = gp->g_fbkva;
  76.     }
  77.  
  78.     dv_reset(REGADDR);
  79.  
  80.     /*
  81.      * Turn on frame buffer, turn on overlay planes, set replacement
  82.      * rule, enable top overlay plane writes for ite, disable all frame
  83.      * buffer planes, set byte per pixel, and display frame buffer 0.
  84.      * Lastly, turn on the box.
  85.      */
  86.     REGBASE->interrupt = 0x04;
  87.     REGBASE->drive     = 0x10;        
  88.      REGBASE->rep_rule  = RR_COPY << 4 | RR_COPY;
  89.     REGBASE->opwen     = 0x01;
  90.     REGBASE->fbwen     = 0x0;
  91.     REGBASE->fold      = 0x01;
  92.     REGBASE->vdrive    = 0x0;
  93.     REGBASE->dispen    = 0x01;
  94.  
  95.     /*
  96.      * Video enable top overlay plane.
  97.      */
  98.     REGBASE->opvenp = 0x01;
  99.     REGBASE->opvens = 0x01;
  100.  
  101.     /*
  102.      * Make sure that overlay planes override frame buffer planes.
  103.      */
  104.     REGBASE->ovly0p  = 0x0;
  105.     REGBASE->ovly0s  = 0x0;
  106.     REGBASE->ovly1p  = 0x0;
  107.     REGBASE->ovly1s  = 0x0;
  108.     REGBASE->fv_trig = 0x1;
  109.     DELAY(100);
  110.  
  111.     /*
  112.      * Setup the overlay colormaps. Need to set the 0,1 (black/white)
  113.      * color for both banks.
  114.      */
  115.  
  116.     for (i = 0; i <= 1; i++) {
  117.         REGBASE->cmapbank = i;
  118.         REGBASE->rgb[0].red   = 0x00;
  119.         REGBASE->rgb[0].green = 0x00;
  120.         REGBASE->rgb[0].blue  = 0x00;
  121.         REGBASE->rgb[1].red   = 0xFF;
  122.         REGBASE->rgb[1].green = 0xFF;
  123.         REGBASE->rgb[1].blue  = 0xFF;
  124.     }
  125.     REGBASE->cmapbank = 0;
  126.     
  127.     db_waitbusy(REGADDR);
  128.  
  129.     ite_devinfo(ip);
  130.     ite_fontinit(ip);
  131.  
  132.     /*
  133.      * Clear the (visible) framebuffer.
  134.      */
  135.     dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
  136.     db_waitbusy(REGADDR);
  137.  
  138.     /*
  139.      * Stash the inverted cursor.
  140.      */
  141.     dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
  142.              ip->cblanky, ip->cblankx, ip->ftheight,
  143.              ip->ftwidth, RR_COPYINVERTED);
  144. }
  145.  
  146. dvbox_deinit(ip)
  147.     struct ite_softc *ip;
  148. {
  149.     dvbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
  150.     db_waitbusy(REGADDR);
  151.  
  152.        ip->flags &= ~ITE_INITED;
  153. }
  154.  
  155. dvbox_putc(ip, c, dy, dx, mode)
  156.     register struct ite_softc *ip;
  157.         register int dy, dx;
  158.     int c, mode;
  159. {
  160.         register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
  161.     
  162.     dvbox_windowmove(ip, charY(ip, c), charX(ip, c),
  163.              dy * ip->ftheight, dx * ip->ftwidth,
  164.              ip->ftheight, ip->ftwidth, wrr);
  165. }
  166.  
  167. dvbox_cursor(ip, flag)
  168.     register struct ite_softc *ip;
  169.         register int flag;
  170. {
  171.     if (flag == DRAW_CURSOR)
  172.         draw_cursor(ip)
  173.     else if (flag == MOVE_CURSOR) {
  174.         erase_cursor(ip)
  175.         draw_cursor(ip)
  176.     }
  177.     else
  178.         erase_cursor(ip)
  179. }
  180.  
  181. dvbox_clear(ip, sy, sx, h, w)
  182.     struct ite_softc *ip;
  183.     register int sy, sx, h, w;
  184. {
  185.     dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
  186.              sy * ip->ftheight, sx * ip->ftwidth, 
  187.              h  * ip->ftheight, w  * ip->ftwidth,
  188.              RR_CLEAR);
  189. }
  190.  
  191. dvbox_scroll(ip, sy, sx, count, dir)
  192.         register struct ite_softc *ip;
  193.         register int sy, count;
  194.         int dir, sx;
  195. {
  196.     register int dy;
  197.     register int dx = sx;
  198.     register int height = 1;
  199.     register int width = ip->cols;
  200.  
  201.     dvbox_cursor(ip, ERASE_CURSOR);
  202.  
  203.     if (dir == SCROLL_UP) {
  204.         dy = sy - count;
  205.         height = ip->rows - sy;
  206.     }
  207.     else if (dir == SCROLL_DOWN) {
  208.         dy = sy + count;
  209.         height = ip->rows - dy - 1;
  210.     }
  211.     else if (dir == SCROLL_RIGHT) {
  212.         dy = sy;
  213.         dx = sx + count;
  214.         width = ip->cols - dx;
  215.     }
  216.     else {
  217.         dy = sy;
  218.         dx = sx - count;
  219.         width = ip->cols - sx;
  220.     }        
  221.  
  222.     dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
  223.              dy * ip->ftheight, dx * ip->ftwidth,
  224.              height * ip->ftheight,
  225.              width  * ip->ftwidth, RR_COPY);
  226. }
  227.  
  228. dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
  229.     struct ite_softc *ip;
  230.     int sy, sx, dy, dx, h, w, func;
  231. {
  232.     register struct dvboxfb *dp = REGBASE;
  233.     if (h == 0 || w == 0)
  234.         return;
  235.     
  236.     db_waitbusy(REGADDR);
  237.     dp->rep_rule = func << 4 | func;
  238.     dp->source_y = sy;
  239.     dp->source_x = sx;
  240.     dp->dest_y   = dy;
  241.     dp->dest_x   = dx;
  242.     dp->wheight  = h;
  243.     dp->wwidth   = w;
  244.     dp->wmove    = 1;
  245. }
  246. #endif
  247.