Leaked source code of windows server 2003
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.

436 lines
18 KiB

  1. /************************************************************************/
  2. /* */
  3. /* CVTVGA.H */
  4. /* */
  5. /* Copyright (c) 1992, ATI Technologies Inc. */
  6. /************************************************************************/
  7. /********************** PolyTron RCS Utilities
  8. $Revision: 1.8 $
  9. $Date: 06 Feb 1996 15:59:40 $
  10. $Author: RWolff $
  11. $Log: S:/source/wnt/ms11/miniport/archive/cvtvga.h_v $
  12. *
  13. * Rev 1.8 06 Feb 1996 15:59:40 RWolff
  14. * For 1600x1200, deleted 52Hz table (never an official mode, offered
  15. * only to allow a choice of refresh rates), updated 60Hz to match CRT
  16. * parameters currently offered by install program, added 66Hz and 76Hz.
  17. *
  18. * Rev 1.7 19 Dec 1995 14:01:34 RWolff
  19. * Added support for refresh rates up to 100Hz at 640x480, 800x600, and
  20. * 1024x768 and 75Hz at 1280x1024. Updated mode tables to match those in
  21. * the Mach64 Programmer's Guide.
  22. *
  23. * Rev 1.6 07 Sep 1995 16:43:06 RWolff
  24. * Fixed 1280x1024 95Hz interlaced (listed as 47Hz in display applet) to
  25. * eliminate "wrap" at top of screen. The tables in both the Mach 32
  26. * and Mach 64 books contain the wrong values for vertical total and
  27. * vertical sync start.
  28. *
  29. * Rev 1.5 20 Jul 1995 17:55:48 mgrubac
  30. * Added support for VDIF files
  31. *
  32. * Rev 1.4 10 Apr 1995 15:57:36 RWOLFF
  33. * Added prototype for routine to replace BookValues[] entries where the
  34. * Mach 64 and Mach 8/Mach 32 need different CRT parameters.
  35. *
  36. * Rev 1.3 31 Aug 1994 16:23:08 RWOLFF
  37. * Added support for 1152x864 and 1600x1200 "canned" mode tables.
  38. *
  39. * Rev 1.2 19 Aug 1994 17:10:22 RWOLFF
  40. * Added support for non-standard pixel clock generators.
  41. *
  42. * Rev 1.1 12 May 1994 11:11:02 RWOLFF
  43. * Added refresh rate to st_book_data structure, re-ordered list of book
  44. * mode tables to allow a single range of indices when highest noninterlaced
  45. * refresh rates at a given resolution are ignored.
  46. *
  47. * Rev 1.0 31 Jan 1994 11:40:38 RWOLFF
  48. * Initial revision.
  49. Rev 1.1 08 Oct 1993 11:04:50 RWOLFF
  50. Removed prototype for unused "fall back to 56Hz" function for 800x600.
  51. Rev 1.0 16 Aug 1993 13:30:00 Robert_Wolff
  52. Initial revision.
  53. Rev 1.8 08 Apr 1993 16:44:54 RWOLFF
  54. Revision level as checked in at Microsoft.
  55. Rev 1.6 25 Mar 1993 11:13:38 RWOLFF
  56. Brought function prototype into sync with the function definition
  57. to eliminate compile-time warnings.
  58. Rev 1.5 08 Mar 1993 19:28:18 BRADES
  59. submit to MS NT
  60. Rev 1.4 02 Dec 1992 17:29:56 Robert_Wolff
  61. Added prototype for FallBack800to56().
  62. Rev 1.3 27 Nov 1992 15:18:20 STEPHEN
  63. No change.
  64. Rev 1.2 17 Nov 1992 17:25:34 Robert_Wolff
  65. Fixed gathering of CRT parameters for 68800 card with minimal
  66. install (EEPROM blank, then predefined monitor type selected).
  67. Rev 1.1 12 Nov 1992 16:44:26 Robert_Wolff
  68. Same file is now used for both Windows NT driver and VIDEO.EXE
  69. test program. XlateVgaTable() no longer depends on the global
  70. variable classMACH32.
  71. Rev 1.1 09 Oct 1992 15:01:24 Robert_Wolff
  72. Added fields for DISP_CNTL and CLOCK_SEL values.
  73. Rev 1.0 01 Oct 1992 15:32:38 Robert_Wolff
  74. Initial revision.
  75. End of PolyTron RCS section *****************/
  76. #if defined(DOC)
  77. CVTVGA.H - ATI card VGA to 8514 format translation
  78. DESCRIPTION:
  79. This include file contains definitions specific to the
  80. VGA to 8514 format EEPROM translation module of the program VIDEO.EXE
  81. Included are structure definitions, function prototypes
  82. and general definitions
  83. #endif
  84. /*
  85. * Bit 8 of CRT parameter table entry 0 is set if the table is in
  86. * 8514 format and clear if the table is in VGA format.
  87. */
  88. #define FMT_8514 0x0100
  89. /*
  90. * Bit 6 of CRT parameter table entry 0 is set if all parameters
  91. * are to be read from the EEPROM and clear if only sync polarities
  92. * are to be used.
  93. */
  94. #define CRTC_USAGE 0x0040
  95. /*
  96. * Bit flags to recognize which vertical scan rate is used at
  97. * a given resolution. The name for the constant is in the form
  98. * M<horizontal resolution>F<vertical scan frequency), with the
  99. * "M" standing for (M)ode.
  100. */
  101. #define M640F72 0x0001
  102. #define M800F72 0x0020
  103. #define M800F70 0x0010
  104. #define M800F60 0x0008
  105. #define M800F56 0x0004
  106. #define M800F89 0x0002
  107. #define M800F95 0x0001
  108. #define M1024F66 0x0010
  109. #define M1024F72 0x0008
  110. #define M1024F70 0x0004
  111. #define M1024F60 0x0002
  112. #define M1024F87 0x0001
  113. #define M1280F95 0x0002
  114. #define M1280F87 0x0001
  115. /*
  116. * There are 3 1120x750 modes which use the same flag bit. Assume
  117. * that the 70Hz noninterlaced mode was selected.
  118. */
  119. #define M1120F70 0x0001
  120. /*
  121. * In some installations, the display parameters are not stored
  122. * in the EEPROM. Instead, they are read from a table corresponding
  123. * to Appendix D of the Programmer's Guide to the Mach 32 Registers.
  124. *
  125. * The entries in our copy of the table are arranged in ascending order
  126. * of horizontal resolution, with entries having the same horizontal
  127. * resolution sorted from worst to best (interlaced modes in increasing
  128. * order of vertical scan frequency, followed by noninterlaced modes in
  129. * ascending order of vertical scan frequency.
  130. *
  131. * The name for the constant is in the form
  132. * B<horizontal resolution>F<vertical scan frequency>, with the
  133. * "B" standing for (B)ook.
  134. */
  135. #define B640F60 0
  136. #define B640F72 1
  137. #define B640F75 2
  138. #define B640F90 3
  139. #define B640F100 4
  140. #define B800F89 5
  141. #define B800F95 6
  142. #define B800F56 7
  143. #define B800F60 8
  144. #define B800F70 9
  145. #define B800F72 10
  146. #define B800F75 11
  147. #define B800F90 12
  148. #define B800F100 13
  149. #define B1024F87 14
  150. #define B1024F60 15
  151. #define B1024F66 16
  152. #define B1024F70 17
  153. #define B1024F72 18
  154. #define B1024F75 19
  155. #define B1024F90 20
  156. #define B1024F100 21
  157. #define B1120F70 22
  158. #define B1152F87 23
  159. #define B1152F95 24
  160. #define B1152F60 25
  161. #define B1152F70 26
  162. #define B1152F75 27
  163. #define B1152F80 28
  164. #define B1280F87 29
  165. #define B1280F95 30
  166. #define B1280F60 31
  167. #define B1280F70 32
  168. #define B1280F74 33
  169. #define B1280F75 34
  170. #define B1600F60 35
  171. #define B1600F66 36
  172. #define B1600F76 37
  173. /*
  174. * VGA parameter table entry to use when translating into 8514 format.
  175. * The value NO_TBL_ENTRY will cause the VGA to 8514 format translation
  176. * routine to fail gracefully if we have run into an EEPROM CRT parameter
  177. * table in VGA format for which we have no entry in the VGA parameter table.
  178. *
  179. * The entries in the VGA parameter table are arranged in ascending order
  180. * of horizontal resolution, with entries having the same horizontal
  181. * resolution sorted in ascending order of vertical scan frequency. No
  182. * distinction is made between interlaced and noninterlaced modes.
  183. *
  184. * The name for the constant is in the form
  185. * T<horizontal resolution>F<vertical scan frequency>, with the
  186. * "T" standing for (T)able.
  187. */
  188. #define T640F72 0
  189. #define T800F72 4
  190. #define T800F70 3
  191. #define T800F60 2
  192. #define T800F56 1
  193. #define T800F89 5
  194. #define T1024F72 8
  195. #define T1024F70 7
  196. #define T1024F60 6
  197. #define T1024F87 9
  198. /*
  199. * Some resolution/vertical scan rate combinations (e.g. IBM default
  200. * 640x480) did not have VGA parameter tables in either VGAP$PS2.ASM
  201. * or VGAP$68A.MAC. For these modes, XlateVgaTable() will return
  202. * the parameters in Appendix D of the Programmer's Guide to the
  203. * Mach 32 Registers, since calculating the values for the mode table
  204. * requires a VGA parameter table.
  205. *
  206. * If we encounter one of these modes (identified by its (T)able
  207. * value being greater than or equal to USE_BOOK_VALUE), handle
  208. * it the same way we deal with modes whose parameters are not
  209. * stored in the EEPROM.
  210. */
  211. #define NO_TBL_ENTRY -1
  212. #define USE_BOOK_VALUE 1000
  213. #define T640F60 USE_BOOK_VALUE+B640F60
  214. #define T800F95 USE_BOOK_VALUE+B800F95
  215. #define T1024F66 USE_BOOK_VALUE+B1024F66
  216. #define T1280F87 USE_BOOK_VALUE+B1280F87
  217. #define T1280F95 USE_BOOK_VALUE+B1280F95
  218. #define T1120F70 USE_BOOK_VALUE+B1120F70
  219. /*
  220. * Value returned in overscan words if no table entry was found.
  221. * This value was chosen because it will stand out when the overscan
  222. * words are printed out as 4 hex digits (as is done by VIDEO.EXE).
  223. */
  224. #define INVALID_WARNING 0x0DEAD
  225. /*
  226. * Bits which are set in pmode->control when sync polarity is negative,
  227. * and mask which must be ORed with sync width during VGA to 8514 conversion
  228. * if the sync is negative.
  229. */
  230. #define HSYNC_BIT 0x4000
  231. #define VSYNC_BIT 0x8000
  232. #define NEG_SYNC_FACTOR 0x0020
  233. /*
  234. * Mask for bit which is set in st_vga_data.MiscParms
  235. * for interlaced modes.
  236. */
  237. #define INTERL 0x040
  238. /*
  239. * Mask for bit which is set in st_vga_data.Mode
  240. * if word mode is enabled.
  241. */
  242. #define WORD_MODE 0x004
  243. /*
  244. * Format of VGA parameter table. This structure contains only those values
  245. * from the mode tables in VGAROM\VGAP$68A.MAC and VGAROM\VGAP$PS2.ASM which
  246. * are used in translating EEPROM data from VGA to 8514 format (original
  247. * tables are 64 bytes).
  248. *
  249. * The offsets listed in the comments are the offsets of the corresponding
  250. * bytes in the assembler tables.
  251. */
  252. struct st_vga_data
  253. {
  254. unsigned char Stretch; /* Horizontal values stretched if 128 here, offset 0 */
  255. unsigned char MiscParms; /* Miscelaneous parameters, offset 7 */
  256. unsigned char DisplayWidth; /* Offset 11 */
  257. unsigned char DisplayHgt; /* Offset 28 */
  258. unsigned char Mode; /* Contains word mode flag, offset 33 */
  259. /*
  260. * Values for CLOCK_SEL, DISP_CNTL, and ClockFreq taken from the
  261. * Programmer's Guide to the Mach 32 Registers. These values are
  262. * not stored as a combination of the CRT registers when the
  263. * EEPROM data is in VGA format.
  264. */
  265. unsigned short ClockSel;
  266. unsigned short DispCntl;
  267. unsigned long ClockFreq; /* Pixel clock frequency in Hertz */
  268. };
  269. /*
  270. * Data structure to hold mode parameters as quoted in Appendix D
  271. * of the Programmer's Guide to the Mach 32 Registers.
  272. */
  273. struct st_book_data
  274. {
  275. unsigned char HTotal; /* Horizontal total */
  276. unsigned char HDisp; /* Horizontal displayed */
  277. unsigned char HSyncStrt; /* Horizontal sync start */
  278. unsigned char HSyncWid; /* Horizontal sync width */
  279. unsigned short VTotal; /* Vertical total */
  280. unsigned short VDisp; /* Vertical displayed */
  281. unsigned short VSyncStrt; /* Vertical sync start */
  282. unsigned char VSyncWid; /* Vertical sync width */
  283. unsigned char DispCntl; /* Display control */
  284. unsigned long ClockFreq; /* Pixel clock frequency, in Hertz */
  285. unsigned short ClockSel; /* Clock Select */
  286. unsigned short Refresh; /* Refresh rate */
  287. };
  288. /*
  289. * Data structure which eases setting one particular byte of a
  290. * data word. If foo is a variable of type SplitWord, then a 16 bit
  291. * value can be set using foo.word, or the high and low bytes
  292. * can be accessed independently by using foo.byte.high and
  293. * foo.byte.low.
  294. */
  295. struct TwoBytes
  296. {
  297. unsigned char low;
  298. unsigned char high;
  299. };
  300. union SplitWord
  301. {
  302. unsigned short word;
  303. struct TwoBytes byte;
  304. };
  305. /*
  306. * Function to translate a CRT parameter table in VGA format
  307. * into 8514 format and fill in the mode table.
  308. */
  309. extern short XlateVgaTable(PVOID HwDeviceExtension, short TableOffset,
  310. struct st_mode_table *pmode, short VgaTblEntry,
  311. short BookTblEntry, struct st_eeprom_data *ee,
  312. BOOL IsMach32);
  313. /*
  314. * Function to fill in a CRT parameter table using values from
  315. * Appendix D of the Programmer's Guide to the Mach 32 Registers,
  316. * rather than the EEPROM contents. This is done when the
  317. * bit flag for "use stored parameters" is clear.
  318. */
  319. extern void BookVgaTable(short VgaTblEntry, struct st_mode_table *pmode);
  320. /*
  321. * Function to replace "canned" CRT tables with Mach 64 versions
  322. * in cases where the Mach 64 needs a pixel clock value which the
  323. * Mach 8 and Mach 32 can't generate.
  324. */
  325. extern void SetMach64Tables(void);
  326. /*
  327. * Array of parameters taken from Appendix D of the
  328. * Programmer's Guide to the Mach 32 Registers.
  329. *
  330. * For interlaced modes, the refresh rate field contains the
  331. * frame rate, not the vertical scan frequency.
  332. */
  333. #ifdef INCLUDE_CVTVGA
  334. struct st_book_data BookValues[B1600F76-B640F60+1] =
  335. {
  336. {0x063, 0x04F, 0x052, 0x02C, 0x0418, 0x03BF, 0x03D2, 0x022, 0x023, 25175000L, 0x0800, 60}, /* 640x480 60Hz NI */
  337. {0x069, 0x04F, 0x052, 0x025, 0x040B, 0x03BF, 0x03D0, 0x023, 0x023, 32000000L, 0x0800, 72}, /* 640x480 72Hz NI */
  338. {0x068, 0x04F, 0x051, 0x028, 0x03E3, 0x03BF, 0x03C0, 0x023, 0x023, 31500000L, 0x0800, 75}, /* 640x480 75Hz NI */
  339. {0x067, 0x04F, 0x053, 0x025, 0x0428, 0x03BF, 0x03F0, 0x02E, 0x023, 39910000L, 0x0800, 90}, /* 640x480 90Hz NI */
  340. {0x069, 0x04F, 0x057, 0x030, 0x0422, 0x03BF, 0x03E9, 0x02C, 0x023, 44900000L, 0x0800, 100}, /* 640x480 100Hz NI */
  341. {0x080, 0x063, 0x065, 0x004, 0x057D, 0x04AB, 0x04C2, 0x02C, 0x033, 32500000L, 0x0800, 44}, /* 800x600 89Hz I */
  342. {0x084, 0x063, 0x06D, 0x010, 0x057C, 0x04AB, 0x04C2, 0x00C, 0x033, 36000000L, 0x0800, 47}, /* 800x600 95Hz I */
  343. {0x07F, 0x063, 0x066, 0x009, 0x04E0, 0x04AB, 0x04B0, 0x002, 0x023, 36000000L, 0x0800, 56}, /* 800x600 56Hz NI */
  344. {0x083, 0x063, 0x068, 0x010, 0x04E3, 0x04AB, 0x04B0, 0x004, 0x023, 40000000L, 0x0800, 60}, /* 800x600 60Hz NI */
  345. {0x07D, 0x063, 0x066, 0x012, 0x04F3, 0x04AB, 0x04C0, 0x02C, 0x023, 44900000L, 0x0800, 70}, /* 800x600 70Hz NI */
  346. {0x081, 0x063, 0x06A, 0x00F, 0x0537, 0x04AB, 0x04F8, 0x006, 0x023, 50000000L, 0x0800, 72}, /* 800x600 72Hz NI */
  347. {0x083, 0x063, 0x065, 0x00A, 0x04E0, 0x04AB, 0x04B0, 0x003, 0x023, 49500000L, 0x0800, 75}, /* 800x600 75Hz NI */
  348. {0x07B, 0x063, 0x063, 0x008, 0x04F2, 0x04AB, 0x04BB, 0x00B, 0x023, 56640000L, 0x0800, 90}, /* 800x600 90Hz NI */
  349. {0x086, 0x063, 0x067, 0x008, 0x04E0, 0x04AB, 0x04BA, 0x004, 0x023, 67500000L, 0x0800, 100}, /* 800x600 75Hz NI */
  350. {0x09D, 0x07F, 0x081, 0x016, 0x0660, 0x05FF, 0x0600, 0x008, 0x033, 44900000L, 0x0800, 43}, /* 1024x768 87Hz I */
  351. {0x0A7, 0x07F, 0x082, 0x031, 0x0649, 0x05FF, 0x0602, 0x026, 0x023, 65000000L, 0x0800, 60}, /* 1024x768 60Hz NI */
  352. {0x0AD, 0x07F, 0x085, 0x016, 0x065B, 0x05FF, 0x060B, 0x004, 0x023, 75000000L, 0x0800, 66}, /* 1024x768 66Hz NI */
  353. {0x0A5, 0x07F, 0x082, 0x031, 0x0649, 0x05FF, 0x0602, 0x026, 0x023, 75000000L, 0x0800, 70}, /* 1024x768 70Hz NI */
  354. {0x0A0, 0x07F, 0x082, 0x031, 0x0649, 0x05FF, 0x0602, 0x026, 0x023, 75000000L, 0x0800, 72}, /* 1024x768 72Hz NI */
  355. {0x0A3, 0x07F, 0x081, 0x00C, 0x063B, 0x05FF, 0x0600, 0x003, 0x023, 78750000L, 0x0800, 75}, /* 1024x768 75Hz NI */
  356. {0x0A3, 0x07F, 0x07C, 0x02C, 0x0698, 0x05FF, 0x0628, 0x02F, 0x023, 100000000L, 0x0800, 90}, /* 1024x768 90Hz NI */
  357. {0x0AD, 0x07F, 0x081, 0x02B, 0x062B, 0x05FF, 0x05FF, 0x028, 0x023, 110000000L, 0x0800, 100}, /* 1024x768 100Hz NI */
  358. {0x0AE, 0x08B, 0x095, 0x00F, 0x0659, 0x05DD, 0x05FC, 0x00A, 0x023, 80000000L, 0x0800, 70}, /* 1120x750 70Hz NI */
  359. {0x0B0, 0x08F, 0x097, 0x010, 0x083E, 0x06BF, 0x075D, 0x009, 0x033, 65000000L, 0x0800, 43}, /* 1152x864 87Hz I */
  360. {0x0B4, 0x08F, 0x09A, 0x010, 0x0766, 0x06BF, 0x06FD, 0x009, 0x033, 65000000L, 0x0800, 47}, /* 1152x864 95Hz I */
  361. {0x0B5, 0x08F, 0x097, 0x00E, 0x0727, 0x06BF, 0x06CD, 0x005, 0x023, 80000000L, 0x0800, 60}, /* 1152x864 60Hz NI */
  362. {0x0BC, 0x08F, 0x093, 0x013, 0x0764, 0x06BF, 0x06DC, 0x00B, 0x023, 100000000L, 0x0800, 70}, /* 1152x864 70Hz NI */
  363. {0x0B6, 0x08F, 0x092, 0x012, 0x07D5, 0x06BF, 0x071C, 0x008, 0x023, 110000000L, 0x0800, 75}, /* 1152x864 75Hz NI */
  364. {0x0B3, 0x08F, 0x090, 0x00E, 0x077D, 0x06BF, 0x06FD, 0x007, 0x023, 110000000L, 0x0800, 80}, /* 1152x864 80Hz NI */
  365. {0x0C7, 0x09F, 0x0A9, 0x00A, 0x08F8, 0x07FF, 0x0861, 0x00A, 0x033, 80000000L, 0x0800, 43}, /* 1280x1024 87Hz I */
  366. {0x0C7, 0x09F, 0x0A9, 0x00A, 0x0842, 0x07FF, 0x0800, 0x00A, 0x033, 80000000L, 0x0800, 47}, /* 1280x1024 95Hz I */
  367. {0x0D6, 0x09F, 0x0A9, 0x02E, 0x0852, 0x07FF, 0x0800, 0x025, 0x023, 110000000L, 0x0800 | CLOCK_SEL_MUX, 60}, /* 1280x1024 60Hz NI */
  368. {0x0D2, 0x09F, 0x0A9, 0x00E, 0x0851, 0x07FF, 0x0800, 0x005, 0x023, 126000000L, 0x0800 | CLOCK_SEL_MUX, 70}, /* 1280x1024 70Hz NI */
  369. {0x0D5, 0x09F, 0x0A3, 0x012, 0x084B, 0x07FF, 0x07FF, 0x01E, 0x023, 135000000L, 0x0800 | CLOCK_SEL_MUX, 74}, /* 1280x1024 74Hz NI */
  370. {0x0D2, 0x09F, 0x0A1, 0x012, 0x0851, 0x07FF, 0x0800, 0x003, 0x023, 135000000L, 0x0800 | CLOCK_SEL_MUX, 75}, /* 1280x1024 75Hz NI */
  371. /*
  372. * Although the horizontal CRT parameters are stored in 8-bit fields,
  373. * some refresh rates at 1600x1200 result in a 9-bit value. In these
  374. * cases, we store only the lower-order 8 bits, and the BIOS will
  375. * resolve the matter when we set the mode.
  376. */
  377. {0x0FF, 0x0C7, 0x0CB, 0x034, 0x09E9, 0x095F, 0x0971, 0x028, 0x023, 156000000L, 0x0800, 60}, /* 1600x1200 60Hz NI */
  378. {0x003, 0x0C7, 0x0CC, 0x031, 0x09C8, 0x095F, 0x0962, 0x023, 0x023, 172000000L, 0x0800, 66}, /* 1600x1200 66Hz NI */
  379. {0x003, 0x0C7, 0x0CC, 0x031, 0x09C8, 0x095F, 0x0962, 0x025, 0x023, 198000000L, 0x0800, 76} /* 1600x1200 76Hz NI */
  380. };
  381. #else
  382. extern struct st_book_data BookValues[B1600F76-B640F60+1];
  383. #endif