Windows NT 4.0 source code leak
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.

336 lines
11 KiB

4 years ago
  1. #if defined(JAZZ)
  2. /*++
  3. Copyright (c) 1989 Microsoft Corporation
  4. Module Name:
  5. jazzG364.c
  6. cAbstract:
  7. This module implements the video prom code for the Jazz G364 video board.
  8. Author:
  9. Lluis Abello (lluis) 20-Jul-1992
  10. Environment:
  11. Kernel mode.
  12. Revision History:
  13. Thid code was moved from jxdisp.c
  14. --*/
  15. #include "fwp.h"
  16. #include "jazzvdeo.h"
  17. #include "jxvideo.h"
  18. #include "ioaccess.h"
  19. JAZZ_VIDEO_TYPE FwVideoType;
  20. MONITOR_CONFIGURATION_DATA DefaultMonitor = {
  21. 0, // version :do not change
  22. 0, // revision :do not change
  23. 1280, // HorizontalResolution
  24. 11832, // HorizontalDisplayTime
  25. 1596, // HorizontalBackPorch
  26. 587, // HorizontalFrontPorch
  27. 1745, // HorizontalSync
  28. 1024, // VerticalResolution
  29. 28, // VerticalBackPorch
  30. 1, // VerticalFrontPorch
  31. 3, // VerticalSync
  32. 0, // HorizontalScreenSize : do not change
  33. 0 // VerticalScreenSize : do not change
  34. };
  35. #define G364_PALETTE_BLACK 0x000000
  36. #define G364_PALETTE_RED 0xB00000
  37. #define G364_PALETTE_GREEN 0x00B000
  38. #define G364_PALETTE_YELLOW 0xB0B000
  39. #define G364_PALETTE_BLUE 0x0000B0
  40. #define G364_PALETTE_MAGENTA 0xB000B0
  41. #define G364_PALETTE_CYAN 0x00B0B0
  42. #define G364_PALETTE_WHITE 0xB0B0B0
  43. #define G364_PALETTE_HI_BLACK 0x000000
  44. #define G364_PALETTE_HI_RED 0xFF0000
  45. #define G364_PALETTE_HI_GREEN 0x00FF00
  46. #define G364_PALETTE_HI_YELLOW 0xFFFF00
  47. #define G364_PALETTE_HI_BLUE 0x0000FF
  48. #define G364_PALETTE_HI_MAGENTA 0xFF00FF
  49. #define G364_PALETTE_HI_CYAN 0x00FFFF
  50. #define G364_PALETTE_HI_WHITE 0xFFFFFF
  51. ARC_STATUS
  52. InitializeG364 (
  53. IN PVIDEO_VIRTUAL_SPACE VirtualAdr,
  54. IN OUT PMONITOR_CONFIGURATION_DATA CurrentMonitor
  55. )
  56. /*++
  57. Routine Description:
  58. This routine initializes the G364 video control registers, and clears the
  59. video screen.
  60. Arguments:
  61. None.
  62. Return Value:
  63. If the video was initialized, ESUCCESS is returned, otherwise an error
  64. code is returned.
  65. --*/
  66. {
  67. ULONG ScreenUnitRate;
  68. ULONG MultiplierValue;
  69. ULONG HalfLineTime;
  70. ULONG FrontPorch;
  71. ULONG BackPorch;
  72. ULONG HalfSync;
  73. ULONG TransferDelay;
  74. ULONG DmaDisplay;
  75. ULONG DataLong;
  76. ULONG Index;
  77. PG364_VIDEO_REGISTERS VideoControl = (PG364_VIDEO_REGISTERS) (VirtualAdr->ControlVirtualBase + 0x80000);
  78. PMONITOR_CONFIGURATION_DATA Monitor;
  79. BOOLEAN UpdateMonitor;
  80. //
  81. // Determine if this is actually the G364 board.
  82. //
  83. if (READ_REGISTER_UCHAR((PUCHAR)(VirtualAdr->ControlVirtualBase)) == JazzVideoG364) {
  84. FwVideoType = JazzVideoG364;
  85. } else {
  86. FwVideoType = MipsVideoG364;
  87. }
  88. //
  89. // Reset the whole video board.
  90. //
  91. WRITE_REGISTER_UCHAR((PUCHAR)(VirtualAdr->ControlVirtualBase+0x180000),0);
  92. Monitor = CurrentMonitor;
  93. UpdateMonitor = FALSE;
  94. //
  95. // Check to see if the Monitor parameters are valid.
  96. //
  97. do {
  98. //
  99. // Determine the desired screen unit rate, in picoseconds (a screen unit is
  100. // four pixels).
  101. //
  102. if ((Monitor->HorizontalDisplayTime != 0) && (Monitor->HorizontalResolution != 0)) {
  103. ScreenUnitRate = (Monitor->HorizontalDisplayTime * 1000) * 4 / Monitor->HorizontalResolution;
  104. } else {
  105. continue;
  106. }
  107. if (ScreenUnitRate == 0) {
  108. continue;
  109. }
  110. //
  111. // Multiplier value is the oscillator period (in picoseconds) divided by
  112. // the pixel rate.
  113. //
  114. if (FwVideoType == JazzVideoG364) {
  115. MultiplierValue = 123077 / (ScreenUnitRate / 4);
  116. if (MultiplierValue < 5 || MultiplierValue > 18) {
  117. continue;
  118. }
  119. } else {
  120. MultiplierValue = 200000 / (ScreenUnitRate / 4);
  121. if (MultiplierValue < 5 || MultiplierValue > 29) {
  122. continue;
  123. }
  124. }
  125. break;
  126. //
  127. // If the while is executed, the parameters are not valid. Set UpdateMonitor
  128. // and point to the default parameters, which are valid. Note that the
  129. // "while" will evaluate TRUE because the value of (a,b) is the value of b.
  130. //
  131. } while (Monitor = &DefaultMonitor, UpdateMonitor = TRUE);
  132. //
  133. // Update the monitor parameters if necessary.
  134. //
  135. if (UpdateMonitor) {
  136. CurrentMonitor->HorizontalResolution = DefaultMonitor.HorizontalResolution;
  137. CurrentMonitor->HorizontalDisplayTime = DefaultMonitor.HorizontalDisplayTime;
  138. CurrentMonitor->HorizontalBackPorch = DefaultMonitor.HorizontalBackPorch;
  139. CurrentMonitor->HorizontalFrontPorch = DefaultMonitor.HorizontalFrontPorch;
  140. CurrentMonitor->HorizontalSync = DefaultMonitor.HorizontalSync;
  141. CurrentMonitor->VerticalResolution = DefaultMonitor.VerticalResolution;
  142. CurrentMonitor->VerticalBackPorch = DefaultMonitor.VerticalBackPorch;
  143. CurrentMonitor->VerticalFrontPorch = DefaultMonitor.VerticalFrontPorch;
  144. CurrentMonitor->VerticalSync = DefaultMonitor.VerticalSync;
  145. }
  146. //
  147. // write multiplier value
  148. //
  149. DataLong = 0;
  150. ((PG364_VIDEO_BOOT)(&DataLong))->ClockSelect = 1;
  151. ((PG364_VIDEO_BOOT)(&DataLong))->MicroPort64Bits = 1;
  152. ((PG364_VIDEO_BOOT)(&DataLong))->Multiplier = MultiplierValue;
  153. WRITE_REGISTER_ULONG(&VideoControl->Boot.Long, DataLong);
  154. //
  155. // Initialize the G364 control parameters.
  156. //
  157. DataLong = 0;
  158. //
  159. // If vertical front porch is 1, use tesselated sync, otherwise use normal sync.
  160. //
  161. if (Monitor->VerticalFrontPorch > 1) {
  162. ((PG364_VIDEO_PARAMETERS)(&DataLong))->PlainSync = 1;
  163. }
  164. ((PG364_VIDEO_PARAMETERS)(&DataLong))->DelaySync = G364_DELAY_SYNC_CYCLES;
  165. ((PG364_VIDEO_PARAMETERS)(&DataLong))->BitsPerPixel = EIGHT_BITS_PER_PIXEL;
  166. ((PG364_VIDEO_PARAMETERS)(&DataLong))->AddressStep = G364_ADDRESS_STEP_INCREMENT;
  167. ((PG364_VIDEO_PARAMETERS)(&DataLong))->DisableCursor = 1;
  168. WRITE_REGISTER_ULONG(&VideoControl->Parameters.Long, DataLong);
  169. //
  170. // Initialize the G364 operational values.
  171. //
  172. HalfSync = (Monitor->HorizontalSync * 1000) / ScreenUnitRate / 2;
  173. WRITE_REGISTER_ULONG(&VideoControl->HorizontalSync.Long, HalfSync );
  174. BackPorch = (Monitor->HorizontalBackPorch * 1000) / ScreenUnitRate;
  175. WRITE_REGISTER_ULONG(&VideoControl->BackPorch.Long, BackPorch );
  176. WRITE_REGISTER_ULONG(&VideoControl->Display.Long, Monitor->HorizontalResolution / 4);
  177. //
  178. // The LineTime needs to be an even number of units, so calculate LineTime / 2
  179. // and then multiply by two to program. ShortDisplay and BroadPulse also
  180. // use LineTime / 2.
  181. //
  182. HalfLineTime = (Monitor->HorizontalSync + Monitor->HorizontalFrontPorch +
  183. Monitor->HorizontalBackPorch + Monitor->HorizontalDisplayTime) * 1000 /
  184. ScreenUnitRate / 2;
  185. WRITE_REGISTER_ULONG(&VideoControl->LineTime.Long, HalfLineTime * 2);
  186. FrontPorch = (Monitor->HorizontalFrontPorch * 1000) / ScreenUnitRate;
  187. WRITE_REGISTER_ULONG(&VideoControl->ShortDisplay.Long,
  188. HalfLineTime - ((HalfSync * 2) + BackPorch + FrontPorch));
  189. WRITE_REGISTER_ULONG(&VideoControl->BroadPulse.Long, HalfLineTime - FrontPorch);
  190. WRITE_REGISTER_ULONG(&VideoControl->VerticalSync.Long, Monitor->VerticalSync * 2);
  191. WRITE_REGISTER_ULONG(&VideoControl->VerticalPreEqualize.Long, Monitor->VerticalFrontPorch * 2);
  192. WRITE_REGISTER_ULONG(&VideoControl->VerticalPostEqualize.Long, 1 * 2);
  193. WRITE_REGISTER_ULONG(&VideoControl->VerticalBlank.Long,
  194. (Monitor->VerticalBackPorch - 1) * 2);
  195. WRITE_REGISTER_ULONG(&VideoControl->VerticalDisplay.Long, Monitor->VerticalResolution * 2);
  196. WRITE_REGISTER_ULONG(&VideoControl->LineStart.Long, LINE_START_VALUE);
  197. //
  198. // Transfer delay is 1.65 microseconds expressed in screen units, plus 1.
  199. //
  200. TransferDelay = (1650000 / ScreenUnitRate) + 1;
  201. if (BackPorch <= TransferDelay) {
  202. TransferDelay = BackPorch - 1;
  203. }
  204. WRITE_REGISTER_ULONG(&VideoControl->TransferDelay.Long, TransferDelay);
  205. //
  206. // DMA display (also known as MemInit) is 1024 (the length of the VRAM
  207. // shift register) minus TransferDelay.
  208. //
  209. DmaDisplay = 1024 - TransferDelay;
  210. WRITE_REGISTER_ULONG(&VideoControl->DmaDisplay.Long, DmaDisplay);
  211. WRITE_REGISTER_ULONG(&VideoControl->PixelMask.Long, G364_PIXEL_MASK_VALUE);
  212. //
  213. // Set up the color map.
  214. //
  215. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_BLACK],
  216. G364_PALETTE_BLACK);
  217. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_RED],
  218. G364_PALETTE_RED);
  219. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_GREEN],
  220. G364_PALETTE_GREEN);
  221. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_YELLOW],
  222. G364_PALETTE_YELLOW);
  223. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_BLUE],
  224. G364_PALETTE_BLUE);
  225. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_MAGENTA],
  226. G364_PALETTE_MAGENTA);
  227. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_CYAN],
  228. G364_PALETTE_CYAN);
  229. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_WHITE],
  230. G364_PALETTE_WHITE);
  231. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_HI_BLACK],
  232. G364_PALETTE_HI_BLACK);
  233. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_HI_RED],
  234. G364_PALETTE_HI_RED);
  235. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_HI_GREEN],
  236. G364_PALETTE_HI_GREEN);
  237. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_HI_YELLOW],
  238. G364_PALETTE_HI_YELLOW);
  239. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_HI_BLUE],
  240. G364_PALETTE_HI_BLUE);
  241. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_HI_MAGENTA],
  242. G364_PALETTE_HI_MAGENTA);
  243. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_HI_CYAN],
  244. G364_PALETTE_HI_CYAN);
  245. WRITE_REGISTER_ULONG(&VideoControl->ColorMapData[FW_COLOR_HI_WHITE],
  246. G364_PALETTE_HI_WHITE);
  247. //
  248. // Enable the G364
  249. //
  250. ((PG364_VIDEO_PARAMETERS)(&DataLong))->EnableVideo = 1;
  251. WRITE_REGISTER_ULONG(&VideoControl->Parameters.Long, DataLong);
  252. //
  253. // G364 C04 bug # 6:
  254. // "The action of starting the VTG may cause the TopOfScreen register to become corrupted"
  255. //
  256. WRITE_REGISTER_ULONG(&VideoControl->TopOfScreen, 0);
  257. return ESUCCESS;
  258. }
  259. #endif