home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / IBMGPMI / S3864ICD.C < prev    next >
C/C++ Source or Header  |  1995-04-14  |  29KB  |  784 lines

  1. /*DDK*************************************************************************/
  2. /*                                                                           */
  3. /* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
  4. /*                                                                           */
  5. /*    The following IBM OS/2 WARP source code is provided to you solely for  */
  6. /*    the purpose of assisting you in your development of OS/2 WARP device   */
  7. /*    drivers. You may use this code in accordance with the IBM License      */
  8. /*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
  9. /*    Copyright statement may not be removed.                                */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12. /**************************************************************************
  13.  *
  14.  * SOURCE FILE NAME = s3864icd.c
  15.  *
  16.  * DESCRIPTIVE NAME = Chip specific PMI functions
  17.  *
  18.  *
  19.  * VERSION = V2.1
  20.  *
  21.  * DATE
  22.  *
  23.  * DESCRIPTION PMI-file handler - Exported entry points
  24.  *
  25.  * FUNCTIONS
  26.  *
  27.  * DEPENDENCIES:
  28.  *
  29.  * NOTES
  30.  *
  31.  * STRUCTURES
  32.  *
  33.  * EXTERNAL REFERENCES
  34.  *
  35.  * EXTERNAL FUNCTIONS
  36.  *
  37. */
  38.  
  39. #pragma langlvl(extended)
  40. #define CHIPS_ALREADY_DEFINED
  41. #include "ipmitype.h"
  42. #include <conio.h>
  43. /*****************************************************************************
  44.  *
  45.  *  FUNCTION NAME:      pfnSetS3864ICD()
  46.  *
  47.  *  DESCRIPTIVE NAME:   Program the clock related registers based on the input data.
  48.  *
  49.  *  FUNCTION:
  50.  *
  51.  *  INPUT:              PVIDEO_ADAPTER - Pointer to current state of the adapter/mode
  52.  *                      PREGS- Pointer to current register state
  53.  *
  54.  *  EXIT:               APIRET - return code
  55.  *
  56.  *  NOTES:              Program the S3864 adapters with ICD2061 clock chip
  57.  *
  58.  *  INTERNAL REFERENCES:
  59.  *    ROUTINES:
  60.  *
  61.  *  EXTERNAL REFERENCES:
  62.  *    ROUTINES:
  63.  ****************************************************************************/
  64. APIRET EXPENTRY  pfnSetS3864ICD(PVIDEO_ADAPTER pAdapter,PREGS pRegs)
  65. {
  66.   ULONG ClockSerialData;
  67.   ULONG rc = NO_ERROR;
  68.   USHORT crtcport = (_inp(0x3cc) & 0x01) ? 0x3D4 : 0x3B4;
  69.   BYTE r0;
  70.   USHORT i, j;
  71.  
  72.   if (!(pAdapter->ModeInfo.usType & MODE_FLAG_GRAPHICS))
  73.   {
  74.     if (pAdapter->ModeInfo.usBytesPerScanLine == 132)
  75.       ClockSerialData = 0x05170A0;
  76.     else
  77.       return (ERROR_REFRESH_NOT_SUPPORTED);
  78.   }
  79.   else              /* graphics mode */
  80.   {
  81.     _outp(crtcport, 0x11);
  82.     r0 = _inp(crtcport+1);
  83.     _outp(crtcport+1, (r0 & 0x7F));
  84.  
  85.     _outp(crtcport, 0x42);
  86.     r0 = _inp(crtcport+1);
  87.     _outp(crtcport+1, (r0 & 0xdf));       /* set interlace off */
  88.  
  89.     switch(pAdapter->ModeInfo.usXResolution)
  90.     {
  91.       case 640:
  92.          _outpw(crtcport, 0x3e07);
  93.          _outpw(crtcport, 0x8013);
  94.  
  95.          switch(pAdapter->ModeInfo.bBitsPerPixel)
  96.          {
  97.             case 8:
  98.             case 4:
  99.                _outpw(crtcport, 0x4f01);
  100.                switch(pAdapter->ModeInfo.bVrtRefresh)
  101.                {
  102.                   case 75:
  103.                     _outpw(crtcport, 0x6400);
  104.                     _outpw(crtcport, 0x4f02);
  105.                     _outpw(crtcport, 0x8003);
  106.                     _outpw(crtcport, 0x5204);
  107.                     _outpw(crtcport, 0x1a05);
  108.                     _outpw(crtcport, 0xf206);
  109.                     _outpw(crtcport, 0x1f07);
  110.                     _outpw(crtcport, 0xe010);
  111.                     _outpw(crtcport, 0x8311);
  112.                     _outpw(crtcport, 0xdf15);
  113.                     _outpw(crtcport, 0x0016);
  114.                     _outpw(crtcport, 0x5e3b);
  115.                     ClockSerialData =0x049D8B5;
  116.                     break;
  117.  
  118.                   case 72:
  119.                     _outpw(crtcport, 0x6300);
  120.                     _outpw(crtcport, 0x5002);
  121.                     _outpw(crtcport, 0x8603);
  122.                     _outpw(crtcport, 0x5404);
  123.                     _outpw(crtcport, 0x9905);
  124.                     _outpw(crtcport, 0x0606);
  125.                     _outpw(crtcport, 0xe910);
  126.                     _outpw(crtcport, 0x8c11);
  127.                     _outpw(crtcport, 0xe015);
  128.                     _outpw(crtcport, 0x0616);
  129.                     _outpw(crtcport, 0x5e3b);
  130.                     ClockSerialData =0x049D8B5;
  131.                     break;
  132.  
  133.                   case 60:
  134.                   default:
  135.                     _outpw(crtcport, 0x5f00);
  136.                     _outpw(crtcport, 0x5002);
  137.                     _outpw(crtcport, 0x8203);
  138.                     _outpw(crtcport, 0x5404);
  139.                     _outpw(crtcport, 0x8005);
  140.                     _outpw(crtcport, 0x0b06);
  141.                     _outpw(crtcport, 0xea10);
  142.                     _outpw(crtcport, 0x8c11);
  143.                     _outpw(crtcport, 0xe715);
  144.                     _outpw(crtcport, 0x0416);
  145.                     _outpw(crtcport, 0x5a3b);
  146.                     ClockSerialData =0x041A8BC;
  147.                     break;
  148.                }
  149.                break;
  150.  
  151.             case 16:
  152.                _outpw(crtcport, 0x9f01);
  153.                switch(pAdapter->ModeInfo.bVrtRefresh)
  154.                {
  155.                   case 75:
  156.                     _outpw(crtcport, 0xcd00);
  157.                     _outpw(crtcport, 0xa002);
  158.                     _outpw(crtcport, 0x9003);
  159.                     _outpw(crtcport, 0xa604);
  160.                     _outpw(crtcport, 0x1205);
  161.                     _outpw(crtcport, 0xf206);
  162.                     _outpw(crtcport, 0x1f07);
  163.                     _outpw(crtcport, 0xe010);
  164.                     _outpw(crtcport, 0x8311);
  165.                     _outpw(crtcport, 0xdf15);
  166.                     _outpw(crtcport, 0x0016);
  167.                     ClockSerialData =0x049D8B5;
  168.                     break;
  169.  
  170.                   case 72:
  171.                     _outpw(crtcport, 0xcb00);
  172.                     _outpw(crtcport, 0xa002);
  173.                     _outpw(crtcport, 0x8e03);
  174.                     _outpw(crtcport, 0xa704);
  175.                     _outpw(crtcport, 0x1105);
  176.                     _outpw(crtcport, 0x0606);
  177.                     _outpw(crtcport, 0xe910);
  178.                     _outpw(crtcport, 0x8c11);
  179.                     _outpw(crtcport, 0xe015);
  180.                     _outpw(crtcport, 0x0616);
  181.                     ClockSerialData =0x049D8B5;
  182.                     break;
  183.  
  184.                   case 60:
  185.                   default:
  186.                     _outpw(crtcport, 0xc100);
  187.                     _outpw(crtcport, 0xa202);
  188.                     _outpw(crtcport, 0x8203);
  189.                     _outpw(crtcport, 0xa404);
  190.                     _outpw(crtcport, 0x1c05);
  191.                     _outpw(crtcport, 0x0c06);
  192.                     _outpw(crtcport, 0xea10);
  193.                     _outpw(crtcport, 0x8c11);
  194.                     _outpw(crtcport, 0xa013);
  195.                     _outpw(crtcport, 0xe715);
  196.                     _outpw(crtcport, 0x0516);
  197.                     ClockSerialData =0x041A8BC;
  198.                     break;
  199.                }
  200.                break;
  201.  
  202.             case 24:
  203.                if (pAdapter->ModeInfo.bVrtRefresh == 60)
  204.                   ClockSerialData = 0x04FAC28;
  205.                else
  206.                   rc = ERROR_REFRESH_NOT_SUPPORTED;
  207.                break;
  208.  
  209.             case 32:
  210.                _outpw(crtcport, 0x3f01);
  211.  
  212.                switch(pAdapter->ModeInfo.bVrtRefresh)
  213.                {
  214.                   case 75:
  215.                     _outpw(crtcport, 0xa900);
  216.                     _outpw(crtcport, 0x4002);
  217.                     _outpw(crtcport, 0x8003);
  218.                     _outpw(crtcport, 0x4a04);
  219.                     _outpw(crtcport, 0x9905);
  220.                     _outpw(crtcport, 0x0606);
  221.                     _outpw(crtcport, 0xea10);
  222.                     _outpw(crtcport, 0x8c11);
  223.                     _outpw(crtcport, 0xe715);
  224.                     _outpw(crtcport, 0x0316);
  225.                     _outpw(crtcport, 0x8a3b);
  226.                     _outpw(crtcport, 0x7f5d);
  227.                     ClockSerialData =0x04B4423;
  228.                     break;
  229.  
  230.                   case 72:
  231.                     _outpw(crtcport, 0xa900);
  232.                     _outpw(crtcport, 0x4002);
  233.                     _outpw(crtcport, 0x8303);
  234.                     _outpw(crtcport, 0x4d04);
  235.                     _outpw(crtcport, 0x8205);
  236.                     _outpw(crtcport, 0x0506);
  237.                     _outpw(crtcport, 0xe810);
  238.                     _outpw(crtcport, 0x8b11);
  239.                     _outpw(crtcport, 0x0013);
  240.                     _outpw(crtcport, 0xdf15);
  241.                     _outpw(crtcport, 0x0516);
  242.                     _outpw(crtcport, 0x933b);
  243.                     _outpw(crtcport, 0x5f5d);
  244.                     ClockSerialData =0x04B4423;
  245.                     break;
  246.  
  247.                   case 60:
  248.                   default:
  249.                     _outpw(crtcport, 0x8900);
  250.                     _outpw(crtcport, 0x4002);
  251.                     _outpw(crtcport, 0x8903);
  252.                     _outpw(crtcport, 0x4904);
  253.                     _outpw(crtcport, 0x1605);
  254.                     _outpw(crtcport, 0x0b06);
  255.                     _outpw(crtcport, 0xea10);
  256.                     _outpw(crtcport, 0x8c11);
  257.                     _outpw(crtcport, 0x0013);
  258.                     _outpw(crtcport, 0xe715);
  259.                     _outpw(crtcport, 0x0316);
  260.                     _outpw(crtcport, 0x8a3b);
  261.                     _outpw(crtcport, 0x7f5d);
  262.                     ClockSerialData =0x041AC3D;
  263.                     break;
  264.                }
  265.                break;
  266.          }
  267.          break;
  268.  
  269.       case 800:
  270.          switch(pAdapter->ModeInfo.bBitsPerPixel)
  271.          {
  272.             case 8:
  273.             case 4:
  274.               _outpw(crtcport, 0x6402);
  275.               _outpw(crtcport, 0xf007);
  276.               _outpw(crtcport, 0x5715);
  277.  
  278.               switch(pAdapter->ModeInfo.bVrtRefresh)
  279.               {
  280.                  case 75:
  281.                    _outpw(crtcport, 0x8100);
  282.                    _outpw(crtcport, 0x8403);
  283.                    _outpw(crtcport, 0x6704);
  284.                    _outpw(crtcport, 0x1105);
  285.                    _outpw(crtcport, 0x6d06);
  286.                    _outpw(crtcport, 0xe007);
  287.                    _outpw(crtcport, 0x5810);
  288.                    _outpw(crtcport, 0x8b11);
  289.                    _outpw(crtcport, 0x0016);
  290.                    _outpw(crtcport, 0x783b);
  291.                    ClockSerialData =0x041AC3D;
  292.                    break;
  293.  
  294.                  case 72:
  295.                    _outpw(crtcport, 0x7d00);
  296.                    _outpw(crtcport, 0x8003);
  297.                    _outpw(crtcport, 0x6c04);
  298.                    _outpw(crtcport, 0x1b05);
  299.                    _outpw(crtcport, 0x9806);
  300.                    _outpw(crtcport, 0x7c10);
  301.                    _outpw(crtcport, 0xa211);
  302.                    _outpw(crtcport, 0x9816);
  303.                    _outpw(crtcport, 0x783b);
  304.                    ClockSerialData =0x041AC3D;
  305.                    break;
  306.  
  307.                  case 60:
  308.                    _outpw(crtcport, 0x7f00);
  309.                    _outpw(crtcport, 0x8203);
  310.                    _outpw(crtcport, 0x6a04);
  311.                    _outpw(crtcport, 0x1a05);
  312.                    _outpw(crtcport, 0x7406);
  313.                    _outpw(crtcport, 0x5810);
  314.                    _outpw(crtcport, 0x8c11);
  315.                    _outpw(crtcport, 0x7316);
  316.                    _outpw(crtcport, 0x7a3b);
  317.                    ClockSerialData =0x05170A0;
  318.                    break;                       /* @V3.0YEE01 */
  319.  
  320.                  case 56:
  321.                  default:
  322.                    _outpw(crtcport, 0x8800);
  323.                    _outpw(crtcport, 0x6602);
  324.                    _outpw(crtcport, 0x8a03);
  325.                    _outpw(crtcport, 0x6b04);
  326.                    _outpw(crtcport, 0x1505);
  327.                    _outpw(crtcport, 0x7706);
  328.                    _outpw(crtcport, 0x5c10);
  329.                    _outpw(crtcport, 0x8e11);
  330.                    _outpw(crtcport, 0x5c15);
  331.                    _outpw(crtcport, 0x7416);
  332.                    _outpw(crtcport, 0x833b);
  333.  
  334.                    if (pAdapter->ModeInfo.bBitsPerPixel == 4)
  335.                      _outpw(crtcport, 0x7b3b);
  336.                    ClockSerialData =0x05170A0;
  337.                    break;
  338.               }
  339.               break;
  340.  
  341.             case 16:
  342.               switch(pAdapter->ModeInfo.bVrtRefresh)
  343.               {
  344.                  case 75:
  345.                    _outpw(crtcport, 0x0600);
  346.                    _outpw(crtcport, 0x8803);
  347.                    _outpw(crtcport, 0xcd04);
  348.                    _outpw(crtcport, 0x0105);
  349.                    _outpw(crtcport, 0x6d06);
  350.                    _outpw(crtcport, 0x5810);
  351.                    _outpw(crtcport, 0x8b11);
  352.                    _outpw(crtcport, 0x0016);
  353.                    _outpw(crtcport, 0xe317);
  354.                    _outpw(crtcport, 0xf83b);
  355.                    _outpw(crtcport, 0x015d);
  356.                    ClockSerialData =0x041AC3D;
  357.                    break;
  358.  
  359.                  case 72:
  360.                    _outpw(crtcport, 0xff00);
  361.                    _outpw(crtcport, 0x8203);
  362.                    _outpw(crtcport, 0xd604);
  363.                    _outpw(crtcport, 0x1405);
  364.                    _outpw(crtcport, 0x9806);
  365.                    _outpw(crtcport, 0x7d10);
  366.                    _outpw(crtcport, 0x8311);
  367.                    _outpw(crtcport, 0x9816);
  368.                    _outpw(crtcport, 0xa317);
  369.                    _outpw(crtcport, 0xf83b);
  370.                    _outpw(crtcport, 0x005d);
  371.                    ClockSerialData =0x041AC3D;
  372.                    break;
  373.  
  374.                  case 60:
  375.                  default:
  376.                    _outpw(crtcport, 0x0300);
  377.                    _outpw(crtcport, 0x8603);
  378.                    _outpw(crtcport, 0xd304);
  379.                    _outpw(crtcport, 0x1305);
  380.                    _outpw(crtcport, 0x7d06);
  381.                    _outpw(crtcport, 0x5810);
  382.                    _outpw(crtcport, 0x8c11);
  383.                    _outpw(crtcport, 0x7316);
  384.                    _outpw(crtcport, 0xa317);
  385.                    _outpw(crtcport, 0xfa3b);
  386.                    _outpw(crtcport, 0x015d);
  387.                    ClockSerialData =0x05170A0;
  388.                    break;
  389.               }
  390.               break;
  391.  
  392.             case 32:
  393.               switch(pAdapter->ModeInfo.bVrtRefresh)
  394.               {
  395.                  case 75:
  396.                    ClockSerialData =0x057801C;
  397.                    break;
  398.  
  399.                  case 72:
  400.                    ClockSerialData =0x057801C;
  401.                    break;
  402.  
  403.                  case 60:
  404.                  default:
  405.                    ClockSerialData =0x051D82B;
  406.                    break;
  407.               }
  408.               break;
  409.          }
  410.          break;
  411.  
  412.       case 1024:
  413.          /*
  414.          ** horizontal total, horizontal blanking start, end, retrace start,
  415.          ** VGA and extended bits fixed up in appropriate refresh case.
  416.          */
  417.  
  418.          switch(pAdapter->ModeInfo.bBitsPerPixel)
  419.          {
  420.             case 4:
  421.               _outpw(crtcport, 0x8002);
  422.               _outpw(crtcport, 0x6009);
  423.               _outpw(crtcport, 0xff12);
  424.               _outpw(crtcport, 0xe317);
  425.               _outpw(crtcport, 0x9d3b);
  426.  
  427.               switch(pAdapter->ModeInfo.bVrtRefresh)
  428.               {
  429.                  case 75:
  430.                    _outpw(crtcport, 0xa200);
  431.                    _outpw(crtcport, 0x8403);
  432.                    _outpw(crtcport, 0x8204);
  433.                    _outpw(crtcport, 0x8e05);
  434.                    _outpw(crtcport, 0x1e06);
  435.                    _outpw(crtcport, 0xfd07);
  436.                    _outpw(crtcport, 0x0110);
  437.                    _outpw(crtcport, 0x8411);    //destroying bit 6 setting.
  438.                    _outpw(crtcport, 0x0015);
  439.                    _outpw(crtcport, 0x0016);
  440.                    _outpw(crtcport, 0xeb17);
  441.                    ClockSerialData =0x0517020;
  442.                    break;
  443.  
  444.                  case 70:
  445.                    _outpw(crtcport, 0xa100);
  446.                    _outpw(crtcport, 0x8403);
  447.                    _outpw(crtcport, 0x8404);
  448.                    _outpw(crtcport, 0x9505);
  449.                    _outpw(crtcport, 0x2406);
  450.                    _outpw(crtcport, 0xf507);
  451.                    _outpw(crtcport, 0x0210);
  452.                    _outpw(crtcport, 0x8811);
  453.                    _outpw(crtcport, 0xff15);
  454.                    _outpw(crtcport, 0x2416);
  455.                    ClockSerialData =0x04FAC28;
  456.                    break;
  457.  
  458.                  case 60:
  459.                    _outpw(crtcport, 0xa300);
  460.                    _outpw(crtcport, 0x8603);
  461.                    _outpw(crtcport, 0x8404);
  462.                    _outpw(crtcport, 0x9505);
  463.                    _outpw(crtcport, 0x2506);
  464.                    _outpw(crtcport, 0xf507);
  465.                    _outpw(crtcport, 0x0210);
  466.                    _outpw(crtcport, 0x8711);
  467.                    _outpw(crtcport, 0xff15);
  468.                    _outpw(crtcport, 0x2116);
  469.                    ClockSerialData =0x04B4423;
  470.                    break;
  471.  
  472.                  case 43:                   //interlace
  473.                  default:
  474.                    _outpw(crtcport, 0x9900);
  475.                    _outpw(crtcport, 0x7f02);
  476.                    _outpw(crtcport, 0x9c03);
  477.                    _outpw(crtcport, 0x8304);
  478.                    _outpw(crtcport, 0x1905);
  479.                    _outpw(crtcport, 0x9706);
  480.                    _outpw(crtcport, 0x1f07);
  481.                    _outpw(crtcport, 0x4009);
  482.                    _outpw(crtcport, 0x8110);
  483.                    _outpw(crtcport, 0x8311);
  484.                    _outpw(crtcport, 0x7f12);
  485.                    _outpw(crtcport, 0x8015);
  486.                    _outpw(crtcport, 0x9616);
  487.                    _outpw(crtcport, 0x943b);
  488.  
  489.                    _outp(crtcport,0x42);
  490.                    r0 = _inp(crtcport+1);
  491.                    _outp(crtcport+1, ((r0 & 0xdf) | 0x20));
  492.  
  493.                    ClockSerialData =0x0550894;
  494.                    break;
  495.               }
  496.               break;
  497.  
  498.             case 8:
  499.               _outpw(crtcport, 0x8002);
  500.               _outpw(crtcport, 0x6009);
  501.               _outpw(crtcport, 0xff12);
  502.               _outpw(crtcport, 0xe317);
  503.               _outpw(crtcport, 0x1067);
  504.  
  505.               switch(pAdapter->ModeInfo.bVrtRefresh)
  506.               {
  507.                  case 75:
  508.                    _outpw(crtcport, 0xa200);
  509.                    _outpw(crtcport, 0x8403);
  510.                    _outpw(crtcport, 0x8204);
  511.                    _outpw(crtcport, 0x8e05);
  512.                    _outpw(crtcport, 0x1e06);
  513.                    _outpw(crtcport, 0xfd07);
  514.                    _outpw(crtcport, 0x0110);
  515.                    _outpw(crtcport, 0x8411);    //destroying bit 6 setting.
  516.                    _outpw(crtcport, 0x0015);
  517.                    _outpw(crtcport, 0x0016);
  518.                    _outpw(crtcport, 0xeb17);
  519.                    _outpw(crtcport, 0x9a3b); //program 5d bit 6 also.
  520.                    ClockSerialData =0x05170A0;
  521.                    break;
  522.  
  523.                  case 70:
  524.                    _outpw(crtcport, 0xa100);
  525.                    _outpw(crtcport, 0x8403);
  526.                    _outpw(crtcport, 0x8404);
  527.                    _outpw(crtcport, 0x9505);
  528.                    _outpw(crtcport, 0x2406);
  529.                    _outpw(crtcport, 0xf507);
  530.                    _outpw(crtcport, 0x0210);
  531.                    _outpw(crtcport, 0x8811);
  532.                    _outpw(crtcport, 0xff15);
  533.                    _outpw(crtcport, 0x2416);
  534.                    _outpw(crtcport, 0x9a3b);
  535.                    ClockSerialData =0x04FACA8;
  536.                    break;
  537.  
  538.                  case 60:
  539.                    _outpw(crtcport, 0xa300);
  540.                    _outpw(crtcport, 0x8603);
  541.                    _outpw(crtcport, 0x8404);
  542.                    _outpw(crtcport, 0x9505);
  543.                    _outpw(crtcport, 0x2506);
  544.                    _outpw(crtcport, 0xf507);
  545.                    _outpw(crtcport, 0x0210);
  546.                    _outpw(crtcport, 0x8711);
  547.                    _outpw(crtcport, 0xff15);
  548.                    _outpw(crtcport, 0x2116);
  549.                    _outpw(crtcport, 0x9e3b);
  550.                    ClockSerialData =0x04B44A3;
  551.                    break;
  552.  
  553.                  case 43:                   //interlace
  554.                  default:
  555.                    _outpw(crtcport, 0x9900);
  556.                    _outpw(crtcport, 0x7f02);
  557.                    _outpw(crtcport, 0x9c03);
  558.                    _outpw(crtcport, 0x8304);
  559.                    _outpw(crtcport, 0x1905);
  560.                    _outpw(crtcport, 0x9706);
  561.                    _outpw(crtcport, 0x1f07);
  562.                    _outpw(crtcport, 0x4009);
  563.                    _outpw(crtcport, 0x8110);
  564.                    _outpw(crtcport, 0x8311);
  565.                    _outpw(crtcport, 0x7f12);
  566.                    _outpw(crtcport, 0x8015);
  567.                    _outpw(crtcport, 0x9616);
  568.                    _outpw(crtcport, 0x943b);
  569.                    _outpw(crtcport, 0x0067);
  570.  
  571.                    _outp(crtcport,0x42);
  572.                    r0 = _inp(crtcport+1);
  573.                    _outp(crtcport+1, ((r0 & 0xdf) | 0x20));
  574.  
  575.                    ClockSerialData =0x0550894;
  576.                    break;
  577.  
  578.               }
  579.               break;
  580.  
  581.             case 16:
  582.               _outpw(crtcport, 0x4700);
  583.               _outpw(crtcport, 0x8a03);
  584.               _outpw(crtcport, 0x0504);
  585.               _outpw(crtcport, 0x0105);
  586.               _outpw(crtcport, 0x6009);
  587.               _outpw(crtcport, 0xff12);
  588.               _outpw(crtcport, 0x423b);
  589.               _outpw(crtcport, 0x555d);
  590.  
  591.               switch(pAdapter->ModeInfo.bVrtRefresh)
  592.               {
  593.                  case 75:
  594.                    _outpw(crtcport, 0x1e06);
  595.                    _outpw(crtcport, 0xfd07);
  596.                    _outpw(crtcport, 0x0110);
  597.                    _outpw(crtcport, 0x8411);
  598.                    _outpw(crtcport, 0x0015);
  599.                    _outpw(crtcport, 0x0016);
  600.                    _outpw(crtcport, 0xeb17);
  601.                    _outpw(crtcport, 0x2854);
  602.                    ClockSerialData =0x0517020;
  603.                    break;
  604.  
  605.                  case 70:
  606.                    _outpw(crtcport, 0x2406);
  607.                    _outpw(crtcport, 0xf507);
  608.                    _outpw(crtcport, 0x0210);
  609.                    _outpw(crtcport, 0x8811);
  610.                    _outpw(crtcport, 0xff15);
  611.                    _outpw(crtcport, 0x2416);
  612.                    _outpw(crtcport, 0xe317);
  613.                    _outpw(crtcport, 0x2854);
  614.                    ClockSerialData =0x04FAC28;
  615.                    break;
  616.  
  617.                  case 60:
  618.                    _outpw(crtcport, 0x2506);
  619.                    _outpw(crtcport, 0xf507);
  620.                    _outpw(crtcport, 0x0210);
  621.                    _outpw(crtcport, 0x8711);
  622.                    _outpw(crtcport, 0xff12);
  623.                    _outpw(crtcport, 0xff15);
  624.                    _outpw(crtcport, 0x2116);
  625.                    _outpw(crtcport, 0xe317);
  626.                    _outpw(crtcport, 0x4854);
  627.                    ClockSerialData =0x04B4423;
  628.                    break;
  629.  
  630.                  case 43:
  631.                  default:
  632.                    _outpw(crtcport, 0x3800);
  633.                    _outpw(crtcport, 0x8003);
  634.                    _outpw(crtcport, 0x0304);
  635.                    _outpw(crtcport, 0x0f05);
  636.                    _outpw(crtcport, 0x9706);
  637.                    _outpw(crtcport, 0x1f07);
  638.                    _outpw(crtcport, 0x4009);
  639.                    _outpw(crtcport, 0x8510);
  640.                    _outpw(crtcport, 0x8c11);
  641.                    _outpw(crtcport, 0x7f12);
  642.                    _outpw(crtcport, 0x8015);
  643.                    _outpw(crtcport, 0x9616);
  644.                    _outpw(crtcport, 0xa317);
  645.                    _outpw(crtcport, 0x313b);
  646.                    _outpw(crtcport, 0x7854);
  647.                    _outpw(crtcport, 0x755d);
  648.  
  649.                    _outp(crtcport,0x42);
  650.                    r0 = _inp(crtcport+1);
  651.                    _outp(crtcport+1, ((r0 & 0xdf) | 0x20));
  652.  
  653.                    ClockSerialData =0x0550894;
  654.                    break;
  655.  
  656.               }
  657.               break;
  658.          }
  659.          break;
  660.  
  661.       case 1152:
  662.          if (pAdapter->ModeInfo.bVrtRefresh == 60)
  663.             ClockSerialData = 0x0517020;
  664.          else
  665.             rc = ERROR_REFRESH_NOT_SUPPORTED;
  666.          break;
  667.  
  668.       case 1280:
  669.          switch(pAdapter->ModeInfo.bBitsPerPixel)
  670.          {
  671.             case 8:
  672.               _outpw(crtcport, 0xa002);
  673.               _outpw(crtcport, 0x0015);
  674.               _outpw(crtcport, 0xc73b);
  675.               _outpw(crtcport, 0x555e);
  676.               _outpw(crtcport, 0x1067);
  677. //            _outpw(crtcport, 0xfc68);
  678.  
  679.               switch(pAdapter->ModeInfo.bVrtRefresh)
  680.               {
  681.                  case 75:
  682.                    _outpw(crtcport, 0xcf00);
  683.                    _outpw(crtcport, 0x9203);
  684.                    _outpw(crtcport, 0xa304);
  685.                    _outpw(crtcport, 0x1505);
  686.                    _outpw(crtcport, 0x2806);
  687.                    _outpw(crtcport, 0x5a07);
  688.                    _outpw(crtcport, 0x6009);
  689.                    _outpw(crtcport, 0x0010);
  690.                    _outpw(crtcport, 0x8311);
  691.                    _outpw(crtcport, 0xff15);
  692.                    _outpw(crtcport, 0x2816);
  693.                    _outpw(crtcport, 0x3854);
  694.                    ClockSerialData =0x04D8028;
  695.                    break;
  696.  
  697.                  case 72:
  698.                  case 60:
  699.                    _outpw(crtcport, 0xcc00);
  700.                    _outpw(crtcport, 0x8e03);
  701.                    _outpw(crtcport, 0xa504);
  702.                    _outpw(crtcport, 0x1905);
  703.                    _outpw(crtcport, 0x3306);
  704.                    _outpw(crtcport, 0x5207);
  705.                    _outpw(crtcport, 0x4009);
  706.                    _outpw(crtcport, 0x0510);
  707.                    _outpw(crtcport, 0x8c11);
  708.                    _outpw(crtcport, 0x3116);
  709.                    _outpw(crtcport, 0x3854);
  710.                    ClockSerialData =0x04B4423;
  711.  
  712.                    if (pAdapter->ModeInfo.bVrtRefresh == 60)
  713.                    {
  714.                       _outpw(crtcport, 0x5054);
  715.                       ClockSerialData =0x045D83D;       /*            */
  716.                    }
  717.                    break;
  718.  
  719.                  case 45:
  720.                  default:
  721.                    _outpw(crtcport, 0xc000);
  722.                    _outpw(crtcport, 0x9f02);
  723.                    _outpw(crtcport, 0x8303);
  724.                    _outpw(crtcport, 0xa404);
  725.                    _outpw(crtcport, 0x1f05);
  726.                    _outpw(crtcport, 0x1806);
  727.                    _outpw(crtcport, 0xb207);
  728.                    _outpw(crtcport, 0x6009);
  729.                    _outpw(crtcport, 0x0110);
  730.                    _outpw(crtcport, 0x8511);
  731.                    _outpw(crtcport, 0x1816);
  732.                    _outpw(crtcport, 0xbb3b);
  733.                    _outpw(crtcport, 0xa854);
  734.                    _outpw(crtcport, 0x005e);
  735.                    _outpw(crtcport, 0x0067);
  736. //                 _outpw(crtcport, 0xff68);
  737.  
  738.                    _outp(crtcport,0x42);
  739.                    r0 = _inp(crtcport+1);
  740.                    _outp(crtcport+1, ((r0 & 0xdf) | 0x20));
  741.  
  742.                    ClockSerialData =0x04FAC28;
  743.                    break;
  744.  
  745.               }
  746.               break;
  747.          }
  748.          break;
  749.  
  750.       case 1600:
  751.          if (pAdapter->ModeInfo.bVrtRefresh == 60)
  752.             ClockSerialData = 0x04FAC28;
  753.          else
  754.             rc = ERROR_REFRESH_NOT_SUPPORTED;
  755.          break;
  756.     }
  757.   }               /* end MODE_FLAG_GRAPHICS test   */
  758.   if (!rc)
  759.   {
  760.      /***   wait on vertical retrace twice  ***/
  761.      /***   due to some timing problem ??   ***/
  762.      for (j=0; j<2; j++)
  763.      {
  764.        i = 0;
  765.        r0 = _inp(crtcport+6);
  766.        while (((r0 & 0x08) == 0x08) && (i < 65535))
  767.        {
  768.          r0 = _inp(crtcport+6);
  769.        }                           /* vert retrace off */
  770.  
  771.        for (i=0; i<65535; i++)
  772.        {
  773.          r0 = _inp(crtcport+6);
  774.          if ((r0 & 0x08) == 0x08)
  775.             break;
  776.        }                           /* vert retrace on  */
  777.      }                             /* end 2x vertical retrace */
  778.  
  779.      SETNUMBER9CLK(ClockSerialData);
  780.   }
  781.  
  782.   return rc;
  783. }
  784.