home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / macII / macIIMono.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-31  |  6.7 KB  |  216 lines

  1. /************************************************************ 
  2. Copyright 1988 by Apple Computer, Inc, Cupertino, California
  3.             All Rights Reserved
  4.  
  5. Permission to use, copy, modify, and distribute this software
  6. for any purpose and without fee is hereby granted, provided
  7. that the above copyright notice appear in all copies.
  8.  
  9. APPLE MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS,
  10. OR IMPLIED, WITH RESPECT TO THIS SOFTWARE, ITS QUALITY,
  11. PERFORMANCE, MERCHANABILITY, OR FITNESS FOR A PARTICULAR
  12. PURPOSE. AS A RESULT, THIS SOFTWARE IS PROVIDED "AS IS,"
  13. AND YOU THE USER ARE ASSUMING THE ENTIRE RISK AS TO ITS
  14. QUALITY AND PERFORMANCE. IN NO EVENT WILL APPLE BE LIABLE 
  15. FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  16. DAMAGES RESULTING FROM ANY DEFECT IN THE SOFTWARE.
  17.  
  18. THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE
  19. AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR
  20. IMPLIED.
  21.  
  22. ************************************************************/
  23. /*-
  24.  * macIIMono.c --
  25.  *    Functions for handling the macII video board with 1 bit/pixel.
  26.  *
  27.  * Copyright (c) 1987 by the Regents of the University of California
  28.  * Copyright (c) 1987 by Adam de Boor, UC Berkeley
  29.  *
  30.  * Permission to use, copy, modify, and distribute this
  31.  * software and its documentation for any purpose and without
  32.  * fee is hereby granted, provided that the above copyright
  33.  * notice appear in all copies.  The University of California
  34.  * makes no representations about the suitability of this
  35.  * software for any purpose.  It is provided "as is" without
  36.  * express or implied warranty.
  37.  *
  38.  *
  39.  */
  40.  
  41. /************************************************************
  42. Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
  43.  
  44.                     All Rights Reserved
  45.  
  46. Permission  to  use,  copy,  modify,  and  distribute   this
  47. software  and  its documentation for any purpose and without
  48. fee is hereby granted, provided that the above copyright no-
  49. tice  appear  in all copies and that both that copyright no-
  50. tice and this permission notice appear in  supporting  docu-
  51. mentation,  and  that the names of Sun or MIT not be used in
  52. advertising or publicity pertaining to distribution  of  the
  53. software  without specific prior written permission. Sun and
  54. M.I.T. make no representations about the suitability of this
  55. software for any purpose. It is provided "as is" without any
  56. express or implied warranty.
  57.  
  58. SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
  59. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
  60. NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
  61. ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  62. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
  63. PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
  64. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
  65. THE USE OR PERFORMANCE OF THIS SOFTWARE.
  66.  
  67. ********************************************************/
  68.  
  69. #include    "macII.h"
  70. #include    "resource.h"
  71.  
  72. /*-
  73.  *-----------------------------------------------------------------------
  74.  * macIIMonoSaveScreen --
  75.  *    Disable the video on the frame buffer to save the screen.
  76.  *
  77.  * Results:
  78.  *    None.
  79.  *
  80.  * Side Effects:
  81.  *    Video enable state changes.
  82.  *
  83.  *-----------------------------------------------------------------------
  84.  */
  85. static Bool
  86. macIIMonoSaveScreen (pScreen, on)
  87.     ScreenPtr      pScreen;
  88.     int          on;
  89. {
  90.     if (on == SCREEN_SAVER_FORCER)
  91.     SetTimeSinceLastInputEvent ();
  92.     return FALSE;
  93. }
  94.  
  95. /*-
  96.  *-----------------------------------------------------------------------
  97.  * macIIMonoInit --
  98.  *    Initialize the macII framebuffer
  99.  *
  100.  * Results:
  101.  *    None
  102.  *
  103.  * Side Effects:
  104.  *    Most of the elements of the ScreenRec are filled in.  The
  105.  *    video is enabled for the frame buffer...
  106.  *
  107.  *-----------------------------------------------------------------------
  108.  */
  109. /*ARGSUSED*/
  110. Bool
  111. macIIMonoInit (index, pScreen, argc, argv)
  112.     int              index;        /* The index of pScreen in the ScreenInfo */
  113.     ScreenPtr      pScreen;      /* The Screen to initialize */
  114.     int              argc;            /* The number of the Server's arguments. */
  115.     char          **argv;       /* The arguments themselves. Don't change! */
  116. {
  117.     ColormapPtr pColormap;
  118.     PixmapPtr   pPixmap;
  119.  
  120.     pScreen->SaveScreen = macIIMonoSaveScreen;
  121.     pScreen->whitePixel = 0;
  122.     pScreen->blackPixel = 1;
  123.  
  124.     if (!mfbScreenInit(pScreen,
  125.                macIIFbs[index].fb,
  126.                macIIFbs[index].info.v_right -
  127.                macIIFbs[index].info.v_left,
  128.                macIIFbs[index].info.v_bottom -
  129.                macIIFbs[index].info.v_top, 
  130.                macIIFbs[index].info.v_hres >> 16, 
  131.                macIIFbs[index].info.v_vres >> 16,
  132.                    macIIFbs[index].info.v_rowbytes * 8))
  133.     {
  134.     return (FALSE);
  135.     }
  136.  
  137.     return (macIIScreenInit(pScreen) && mfbCreateDefColormap(pScreen));
  138. }
  139.  
  140. /*-
  141.  *-----------------------------------------------------------------------
  142.  * macIIMonoProbe --
  143.  *    Attempt to find and initialize a macII framebuffer
  144.  *
  145.  * Results:
  146.  *    None
  147.  *
  148.  * Side Effects:
  149.  *    Memory is allocated for the frame buffer and the buffer is mapped. 
  150.  *
  151.  *-----------------------------------------------------------------------
  152.  */
  153.  
  154. Bool
  155. macIIMonoProbe(pScreenInfo, index, fbNum, argc, argv)
  156.     ScreenInfo      *pScreenInfo;    /* The screenInfo struct */
  157.     int              index;        /* The index of pScreen in the ScreenInfo */
  158.     int              fbNum;        /* Index into the macIIFbData array */
  159.     int              argc;            /* The number of the Server's arguments. */
  160.     char          **argv;       /* The arguments themselves. Don't change! */
  161. {
  162.     int         i, oldNumScreens;
  163.  
  164.     if (macIIFbData[fbNum].probeStatus == probedAndFailed) {
  165.     return FALSE;
  166.     }
  167.  
  168.     if (macIIFbData[fbNum].probeStatus == neverProbed) {
  169.     int         fd;
  170.     fbtype fbType;
  171.  
  172.     if ((fd = macIIOpenFrameBuffer(FBTYPE_MACII, &fbType, index, fbNum,
  173.                      argc, argv)) < 0) {
  174.         macIIFbData[fbNum].probeStatus = probedAndFailed;
  175.         return FALSE;
  176.     }
  177.  
  178.     {
  179.         static char *video_virtaddr = (char *) (120 * 1024 * 1024);
  180.         struct video_map vmap;
  181.         struct strioctl ctl; /* Streams ioctl control structure */
  182.  
  183.         /* map frame buffer to next 8MB segment boundary above 128M */
  184.         video_virtaddr = video_virtaddr + (8 * 1024 * 1024); 
  185.             vmap.map_physnum = 0;
  186.             vmap.map_virtaddr = video_virtaddr;
  187.  
  188.         ctl.ic_cmd = VIDEO_MAP;
  189.         ctl.ic_timout = -1;
  190.         ctl.ic_len = sizeof(vmap);
  191.         ctl.ic_dp = (char *)&vmap;
  192.         if (ioctl(fd, I_STR, &ctl) == -1) {
  193.             FatalError ("ioctl I_STR VIDEO_MAP failed");
  194.             (void) close (fd);
  195.             return (FALSE);
  196.         }
  197.  
  198.             macIIFbs[index].fb = 
  199.             (pointer)(video_virtaddr + fbType.v_baseoffset); 
  200.         (void) close(fd);
  201.     }
  202.  
  203.     macIIFbs[index].info = fbType;
  204.     macIIFbData[fbNum].probeStatus = probedAndSucceeded;
  205.  
  206.     }
  207.  
  208.     /*
  209.      * If we've ever successfully probed this device, do the following.
  210.      */
  211.     oldNumScreens = pScreenInfo->numScreens;
  212.     i = AddScreen(macIIMonoInit, argc, argv);
  213.     return (i >= oldNumScreens);
  214. }
  215.  
  216.