Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

242 lines
8.1 KiB

  1. /*/****************************************************************************
  2. * name: GetMGAConfiguration
  3. *
  4. * description: This function will read the strappings of the specified MGA
  5. * device from the Titan DSTi1-0 registers (with the PATCH).
  6. * Also this function will return a DAC id and some other
  7. * relevent informations.
  8. *
  9. * designed: Bart Simpson, february 10, 1993
  10. * last modified: $Author: ctoutant $, $Date: 94/06/14 13:05:50 $
  11. *
  12. * version: $Id: GETCFG.C 1.17 94/06/14 13:05:50 ctoutant Exp $
  13. *
  14. * parameters: _Far BYTE *pMGA, DWORD* DST1, DWORD* DST0, DWORD* Info
  15. * modifies: *DST1, *DST0, *Info
  16. * calls: -
  17. * returns: DST0, DST1, Info
  18. *
  19. *
  20. * NOTE: DST1, DST0 are in Titan format.
  21. *
  22. * Info is 0x uuuu uuuu uuuu uuuu uuuu uuuu uuuu dddd
  23. *
  24. * dddd : 2 MSB are DAC extended id
  25. * 2 LSB are DAC DUBIC id
  26. *
  27. * 0000 : BT481
  28. * 0100 : BT482
  29. * 1000 : ATT
  30. * 1100 : Sierra
  31. *
  32. * 0001 : ViewPoint
  33. *
  34. * 0010 : BT484
  35. * 0110 : BT485
  36. *
  37. * 0111 : PX2085
  38. *
  39. * 0011 : Chameleon
  40. *
  41. ******************************************************************************/
  42. #define DEBUG_OUTPUT 0
  43. #include "switches.h"
  44. #include "g3dstd.h"
  45. #include "caddi.h"
  46. #include "def.h"
  47. #include "mga.h"
  48. #include "global.h"
  49. #include "proto.h"
  50. #include "mgai.h"
  51. #if DEBUG_OUTPUT
  52. extern VOID printf();
  53. #endif
  54. #ifdef WINDOWS_NT
  55. #if defined(ALLOC_PRAGMA)
  56. #pragma alloc_text(PAGE,GetMGAConfiguration)
  57. #endif
  58. #if defined(ALLOC_PRAGMA)
  59. #pragma data_seg("PAGE")
  60. #endif
  61. #include "video.h"
  62. #endif /* #ifdef WINDOWS_NT */
  63. VOID GetMGAConfiguration(volatile BYTE _Far *pDevice, DWORD *DST0, DWORD *DST1, DWORD *Info)
  64. {
  65. DWORD TmpDword;
  66. BYTE reg0, TmpByte, TmpByte1, TmpByte2, FifoCount;
  67. BYTE DacDetected;
  68. static DWORD DST0Cache, DST1Cache, InfoCache;
  69. static BOOL CacheFlag=FALSE;
  70. if (0)
  71. {
  72. *DST0 = DST0Cache;
  73. *DST1 = DST1Cache;
  74. *Info = InfoCache;
  75. }
  76. else
  77. {
  78. { DWORD Opmode, SrcPage;
  79. /*** Apply the patch procedure to get the straps in the DST1 and DST0 ***/
  80. /** Wait until the FIFO is empty, Then we're sure that the Titan
  81. *** is ready to process the DATA transfers.
  82. **/
  83. FifoCount = 0;
  84. while (FifoCount < 32)
  85. mgaReadBYTE(*(pDevice + TITAN_OFFSET+TITAN_FIFOSTATUS),FifoCount);
  86. /* Wait for the drawing engine to be idle */
  87. mgaPollBYTE(*(pDevice + TITAN_OFFSET + TITAN_STATUS + 2),0x00,0x01);
  88. mgaReadDWORD(*(pDevice + TITAN_OFFSET + TITAN_OPMODE), Opmode);
  89. mgaReadDWORD(*(pDevice + TITAN_OFFSET + TITAN_SRCPAGE), SrcPage);
  90. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_OPMODE), Opmode & ~((DWORD)TITAN_FBM_M | (DWORD)TITAN_PSEUDODMA_M));
  91. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_MCTLWTST), 0xffffffff);
  92. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_SRCPAGE), 0x00f80000);
  93. mgaReadDWORD(*(pDevice + SRC_WIN_OFFSET), TmpDword);
  94. mgaReadDWORD(*(pDevice + SRC_WIN_OFFSET), TmpDword);
  95. mgaReadDWORD(*(pDevice + SRC_WIN_OFFSET), TmpDword);
  96. mgaReadDWORD(*(pDevice + SRC_WIN_OFFSET), TmpDword);
  97. mgaReadDWORD(*(pDevice + SRC_WIN_OFFSET), TmpDword);
  98. mgaReadDWORD(*(pDevice + SRC_WIN_OFFSET), TmpDword);
  99. mgaReadDWORD(*(pDevice + SRC_WIN_OFFSET), TmpDword);
  100. mgaReadDWORD(*(pDevice + SRC_WIN_OFFSET), TmpDword);
  101. TmpDword = TmpDword;
  102. mgaReadDWORD(*(pDevice + TITAN_OFFSET + TITAN_DST0), (*DST0));
  103. mgaReadDWORD(*(pDevice + TITAN_OFFSET + TITAN_DST1), (*DST1));
  104. /*** Reset Opmode with pseudo-dma off first and then to its previous state ***/
  105. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_OPMODE), Opmode & ~((DWORD)TITAN_PSEUDODMA_M));
  106. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_OPMODE), Opmode);
  107. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_MCTLWTST), GetMGAMctlwtst(*DST0, *DST1));
  108. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_SRCPAGE), SrcPage);
  109. }
  110. #if DEBUG_OUTPUT
  111. printf ("DST0=%lx, DST1=%lx\n", *DST0, *DST1);
  112. #endif
  113. /** Because the Titan DSTi0-1 spec has changed after the binding
  114. *** developpement (i.e. the rambank[0] bit has moved from bit 0 of DST0
  115. *** to bit 3 of DST1) we duplicate the DST1[3] to DST0[24] because the
  116. *** binding has nothing to do with the new VGA BANK 0 bit
  117. **/
  118. /*** Clear bit rambank 0 ***/
  119. (*DST0) &= ~((DWORD)0x1 << TITAN_DST0_RAMBANK_A);
  120. /*** DUPLICATE ***/
  121. (*DST0) |= ((((*DST1) & (DWORD)TITAN_DST1_RAMBANK0_M) >> TITAN_DST1_RAMBANK0_A) << TITAN_DST0_RAMBANK_A);
  122. /***** DETECT DAC TYPE *****/
  123. mgaReadBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), TmpByte2);
  124. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX),VPOINT_ID);
  125. mgaReadBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), TmpByte);
  126. if (TmpByte == 0x20)
  127. DacDetected = (BYTE)Info_Dac_ViewPoint;
  128. else
  129. {
  130. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX),TmpByte2);
  131. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX),TVP3026_ID);
  132. mgaReadBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), TmpByte);
  133. if (TmpByte == 0x26)
  134. DacDetected = (BYTE)Info_Dac_TVP3026;
  135. else
  136. {
  137. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_WADR_PAL), 0x00);
  138. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_PIX_RD_MSK), 0xff);
  139. mgaReadBYTE(*(pDevice + RAMDAC_OFFSET + BT485_STATUS), TmpByte);
  140. if ((TmpByte & (BYTE)ATT20C505_ID_M) == (BYTE)ATT20C505_ID)
  141. DacDetected = (BYTE)Info_Dac_ATT2050;
  142. else
  143. {
  144. /*** BEN TEST SPECIAL NE VEUT PAS ENTRER DANS CE IF ***/
  145. if ((TmpByte & (BYTE)BT485_ID_M) == (BYTE)0x77)
  146. /* if ((TmpByte & (BYTE)BT485_ID_M) == (BYTE)BT485_ID) */
  147. DacDetected = (BYTE)Info_Dac_BT485;
  148. else
  149. if ((TmpByte & (BYTE)BT484_ID_M) == (BYTE)BT484_ID)
  150. DacDetected = (BYTE)Info_Dac_BT484;
  151. else
  152. {
  153. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CUR_XLOW),0x00);
  154. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_WADR_OVL),0x55);
  155. mgaReadBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CUR_XLOW), TmpByte);
  156. if (TmpByte == 0x55)
  157. DacDetected = (BYTE)Info_Dac_BT482; /* SIERRA */
  158. else
  159. {
  160. /*** Procedure to detect CL_PX2085 ***/
  161. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CMD_REG0),0x82);
  162. /*** Set index register ***/
  163. mgaReadBYTE(*(pDevice + RAMDAC_OFFSET + BT485_STATUS),TmpByte2);
  164. TmpByte = TmpByte2 & 0x0f;
  165. TmpByte |= 0x40;
  166. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_STATUS),TmpByte);
  167. mgaReadBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CMD_REG0),reg0);
  168. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CMD_REG0),0x02);
  169. /*** Set direct register ***/
  170. mgaReadBYTE(*(pDevice + RAMDAC_OFFSET + BT485_STATUS),TmpByte1);
  171. TmpByte = TmpByte & 0x0f;
  172. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_STATUS),TmpByte);
  173. mgaReadBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CMD_REG0),TmpByte);
  174. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_STATUS),TmpByte1);
  175. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CMD_REG0),reg0);
  176. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_STATUS),TmpByte2);
  177. if(TmpByte == 0x82)
  178. DacDetected = (BYTE)Info_Dac_PX2085;
  179. else
  180. DacDetected = (BYTE)Info_Dac_BT485; /* other DAC same as BT485 */
  181. }
  182. }
  183. }
  184. }
  185. }
  186. *Info = (DWORD)DacDetected;
  187. DST0Cache = *DST0;
  188. DST1Cache = *DST1;
  189. InfoCache = *Info;
  190. CacheFlag = TRUE;
  191. }
  192. }