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.

669 lines
23 KiB

  1. /************************************************************************/
  2. /* */
  3. /* CVTVGA.C */
  4. /* */
  5. /* Copyright (c) 1992, ATI Technologies Incorporated. */
  6. /************************************************************************/
  7. /********************** PolyTron RCS Utilities
  8. $Revision: 1.9 $
  9. $Date: 20 Jul 1995 17:53:30 $
  10. $Author: mgrubac $
  11. $Log: S:/source/wnt/ms11/miniport/vcs/cvtvga.c $
  12. *
  13. * Rev 1.9 20 Jul 1995 17:53:30 mgrubac
  14. * Added support for VDIF files
  15. *
  16. * Rev 1.8 10 Apr 1995 15:55:26 RWOLFF
  17. * Updated 640x480 72Hz mode table from version 1.2 to version 1.5 of the
  18. * Programmer's Guide to the Mach 32 Registers, added routine to replace
  19. * BookValues[] entries where the Mach 64 needs CRT parameters the Mach 8
  20. * and Mach 32 can't handle (currently, only 640x480 72Hz falls into
  21. * this category).
  22. *
  23. * Rev 1.7 23 Dec 1994 10:47:58 ASHANMUG
  24. * ALPHA/Chrontel-DAC
  25. *
  26. * Rev 1.6 18 Nov 1994 11:39:04 RWOLFF
  27. * Added comments with function name at the end of each function.
  28. *
  29. * Rev 1.5 31 Aug 1994 16:22:42 RWOLFF
  30. * Added support for 1152x864 and 1600x1200 "canned" mode tables.
  31. *
  32. * Rev 1.4 19 Aug 1994 17:09:52 RWOLFF
  33. * Added support for non-standard pixel clock generators.
  34. *
  35. * Rev 1.3 18 May 1994 17:02:58 RWOLFF
  36. * Interlaced mode tables now report frame rate rather than vertical
  37. * scan frequency in the refresh rate field.
  38. *
  39. * Rev 1.2 12 May 1994 11:13:04 RWOLFF
  40. * Added refresh rate to entries in BookValues[], re-ordered BookValues[]
  41. * to allow a single range of indices to cover all desired refresh rates at
  42. * a given resolution even when the highest nonitnerlaced refresh rates
  43. * are ignored.
  44. *
  45. * Rev 1.1 07 Feb 1994 14:06:06 RWOLFF
  46. * Added alloc_text() pragmas to allow miniport to be swapped out when
  47. * not needed.
  48. *
  49. * Rev 1.0 31 Jan 1994 11:05:14 RWOLFF
  50. * Initial revision.
  51. Rev 1.4 30 Nov 1993 18:15:02 RWOLFF
  52. Corrected clock select value for 1280x1024 60Hz noninterlaced.
  53. Rev 1.3 08 Oct 1993 15:17:56 RWOLFF
  54. No longer includes VIDFIND.H
  55. Rev 1.2 08 Oct 1993 11:05:14 RWOLFF
  56. Removed unused "fall back to 56Hz" function for 800x600.
  57. Rev 1.1 03 Sep 1993 14:21:52 RWOLFF
  58. Partway through CX isolation.
  59. Rev 1.0 16 Aug 1993 13:22:04 Robert_Wolff
  60. Initial revision.
  61. Rev 1.12 30 Apr 1993 16:39:18 RWOLFF
  62. 640x480 8BPP now stable on 512k Graphics Vantage. Fix is not yet final -
  63. old code is present but commented out, will remove when fix is final.
  64. Rev 1.11 21 Apr 1993 17:17:16 RWOLFF
  65. Now uses AMACH.H instead of 68800.H/68801.H.
  66. Rev 1.10 30 Mar 1993 17:10:28 RWOLFF
  67. Added 1280x1024 60Hz noninterlaced to resolutions which can be selected
  68. by BookVgaTable().
  69. Rev 1.9 25 Mar 1993 11:12:34 RWOLFF
  70. Brought comment block in function header into sync with actual code.
  71. Rev 1.8 08 Mar 1993 19:28:28 BRADES
  72. submit to MS NT
  73. Rev 1.6 06 Jan 1993 10:57:56 Robert_Wolff
  74. Added type casts to eliminate compile warnings.
  75. Rev 1.5 02 Dec 1992 17:28:58 Robert_Wolff
  76. Added function FallBack800to56(), which replaces those parameters
  77. of an 800x600 mode table with the values used by the 56Hz vertical
  78. frequency mode in Programmer's Guide to the Mach 32 Registers.
  79. Rev 1.4 27 Nov 1992 15:18:30 STEPHEN
  80. No change.
  81. Rev 1.3 17 Nov 1992 17:21:02 Robert_Wolff
  82. Now uses parameters from Appendix D of the Programmer's Guide to
  83. the Mach 32 Registers rather than values from the EEPROM if the
  84. CRTC_USAGE bit is clear (clear = use sync polarities only, will
  85. be clear if card is configured for a predefined monitor rather
  86. than having CRT parameters written to the EEPROM), fixed calculation
  87. of parameters for Mach 8 in 800x600 at 60, 70, and 72 Hz noninterlaced
  88. (other frequencies at 800x600, other resolutions on Mach 8, and all
  89. resolutions on Mach 32 didn't have this problem).
  90. Rev 1.2 13 Nov 1992 17:09:44 Robert_Wolff
  91. Now includes 68801.H, which consists of the now-obsolete MACH8.H
  92. and elements moved from VIDFIND.H.
  93. Rev 1.1 12 Nov 1992 16:39:38 Robert_Wolff
  94. Merged source trees for Windows NT driver and VIDEO.EXE test program
  95. (same source file can be used for both). XlateVgaTable() now takes
  96. an extra parameter to determine whether to handle data for Mach32
  97. or Mach8 cards, rather than using the global variable classMACH32.
  98. Rev 1.0 05 Nov 1992 13:59:56 Robert_Wolff
  99. Initial revision.
  100. Rev 1.1 09 Oct 1992 15:03:28 Robert_Wolff
  101. Now assigns values for DISP_CNTL, CLOCK_SEL, VFIFO_16, and VFIFO_24.
  102. Rev 1.0 01 Oct 1992 15:31:42 Robert_Wolff
  103. Initial revision.
  104. End of PolyTron RCS section *****************/
  105. #ifdef DOC
  106. CVTVGA.C - Functions to convert CRT parameter table from VGA
  107. to 8514 format.
  108. #endif
  109. #include "miniport.h"
  110. #include "ntddvdeo.h"
  111. #include "video.h"
  112. #include "stdtyp.h"
  113. #define INCLUDE_CVTVGA
  114. #include "amach.h"
  115. #include "amach1.h"
  116. #include "cvtvga.h"
  117. #include "atimp.h"
  118. #include "services.h"
  119. /*
  120. * Arrays of VGA parameter tables used in translating from
  121. * VGA format to 8514 format. Currently the 800x600 noninterlaced
  122. * entries have different values for the Mach8 and Mach32
  123. * engines (Mach 8 is the "else" case with the comment
  124. * "TESTING ONLY" for 56Hz). Assume that the VFIFO_DEPTH
  125. * field is 8 entries.
  126. */
  127. static struct st_vga_data VgaParmTable_M32[10] =
  128. {
  129. {0x050, 0x000, 0x04F, 0x0DF, 0x0E3, 0x0800, 0x023, 32000000L}, /* Mode 12, VGAP$PS2.ASM */
  130. {0x064, 0x000, 0x063, 0x057, 0x0E3, 0x0800, 0x023, 36000000L}, /* m800_36m, VGAP$68A.MAC */
  131. {0x064, 0x000, 0x063, 0x057, 0x0E3, 0x0800, 0x023, 40000000L}, /* m800_40mphip, VGAP$68A.MAC */
  132. {0x064, 0x000, 0x063, 0x057, 0x0E3, 0x0800, 0x023, 44900000L}, /* m800_45m, VGAP$68A.MAC */
  133. {0x064, 0x000, 0x063, 0x057, 0x0E3, 0x0800, 0x023, 50350000L}, /* m800_50mvesa, VGAP$68A.MAC */
  134. {0x064, 0x0C0, 0x063, 0x057, 0x0E3, 0x0800, 0x033, 32500000L}, /* m800_36m8514, VGAP$68A.MAC */
  135. {0x080, 0x000, 0x07F, 0x0FF, 0x0E3, 0x0800, 0x023, 65000000L}, /* m1024_65m, VGAP$68A.MAC */
  136. {0x080, 0x000, 0x07F, 0x0FF, 0x0E3, 0x0800, 0x023, 75000000L}, /* m1024_75mvesa, VGAP$68A.MAC */
  137. {0x080, 0x000, 0x07F, 0x0FF, 0x0E3, 0x0800, 0x023, 75000000L}, /* m1024_75m72Hz, VGAP$68A.MAC */
  138. {0x080, 0x0C0, 0x07F, 0x0FF, 0x0E3, 0x0800, 0x033, 44900000L} /* m1024_45m, VGAP$68A.MAC */
  139. };
  140. static struct st_vga_data VgaParmTable_M8[10] =
  141. {
  142. {0x050, 0x000, 0x04F, 0x0DF, 0x0E3, 0x0800, 0x023, 32000000L}, /* Mode 12, VGAP$PS2.ASM */
  143. {0x064, 0x000, 0x063, 0x02B, 0x0E7, 0x0800, 0x023, 36000000L}, /* m800_36m, VGAP$68A.MAC */
  144. {0x064, 0x000, 0x063, 0x02B, 0x0E7, 0x0800, 0x023, 40000000L}, /* m800_40mphip, VGAP$68A.MAC */
  145. {0x064, 0x000, 0x063, 0x02B, 0x0E7, 0x0800, 0x023, 44900000L}, /* m800_45m, VGAP$68A.MAC */
  146. {0x064, 0x000, 0x063, 0x02B, 0x0E7, 0x0800, 0x023, 50350000L}, /* m800_50mvesa, VGAP$68A.MAC */
  147. {0x064, 0x0C0, 0x063, 0x057, 0x0E3, 0x0800, 0x033, 32500000L}, /* m800_36m8514, VGAP$68A.MAC */
  148. {0x080, 0x000, 0x07F, 0x0FF, 0x0E3, 0x0800, 0x023, 65000000L}, /* m1024_65m, VGAP$68A.MAC */
  149. {0x080, 0x000, 0x07F, 0x0FF, 0x0E3, 0x0800, 0x023, 75000000L}, /* m1024_75mvesa, VGAP$68A.MAC */
  150. {0x080, 0x000, 0x07F, 0x0FF, 0x0E3, 0x0800, 0x023, 75000000L}, /* m1024_75m72Hz, VGAP$68A.MAC */
  151. {0x080, 0x0C0, 0x07F, 0x0FF, 0x0E3, 0x0800, 0x033, 44900000L} /* m1024_45m, VGAP$68A.MAC */
  152. };
  153. /*
  154. * Pointer to currently-used VGA parameter table
  155. */
  156. static struct st_vga_data *VgaParmTable;
  157. /*
  158. * Some of the processing of vertical values is handled differently
  159. * on non-Mach32 cards with 512k of video memory. The routine which
  160. * behaves differently based on whether or not we have an older card
  161. * with 512k is called several times, so setting this flag in a higher-
  162. * level routine will reduce the number of tests required.
  163. */
  164. static BOOL HalfMeg;
  165. static void GetVertOverflow(unsigned char *Value);
  166. static unsigned short Gen8514V(union SplitWord INPut, short VgaTblEntry);
  167. /*
  168. * Allow miniport to be swapped out when not needed.
  169. */
  170. #if defined (ALLOC_PRAGMA)
  171. #pragma alloc_text(PAGE_M, GetVertOverflow)
  172. #pragma alloc_text(PAGE_M, Gen8514V)
  173. #pragma alloc_text(PAGE_M, XlateVgaTable)
  174. #pragma alloc_text(PAGE_M, BookVgaTable)
  175. #endif
  176. /****************************************************************
  177. * GetVertOverflow
  178. *
  179. * Gets the overflow (2 most significant bits) of a vertical
  180. * value. On entry, Value will point to a copy of the CRT07
  181. * register which has been shifted so that bit 8 of the desired
  182. * value is in bit 0 of *Value, and bit 9 of the desired value
  183. * is in bit 5 of *Value. On exit, bits 8 and 9 will be in bits
  184. * 0 and 1 respectively of *Value.
  185. *
  186. * INPUT: Value = ptr to raw overflow value
  187. *
  188. * RETURN: Value = ptr to processed overflow value
  189. *
  190. ****************************************************************/
  191. static void GetVertOverflow(unsigned char *Value)
  192. {
  193. unsigned char Scratch; /* Scratchpad variable */
  194. Scratch = (*Value >> 4) & 0x02;
  195. *Value = (*Value & 0x01) | Scratch;
  196. return;
  197. } /* GetVertOverflow() */
  198. /****************************************************************
  199. * Gen8514V
  200. *
  201. * Another stage in the processing of a vertical value. This is
  202. * taken directly from gen8514v in COMBO$01.ASM.
  203. *
  204. * INPUT: INPut = value before processing
  205. * VgaTblEntry = which set of VGA parameters corresponds
  206. * to the desired mode
  207. *
  208. * RETURN: processed value
  209. *
  210. ****************************************************************/
  211. static unsigned short Gen8514V(union SplitWord INPut, short VgaTblEntry)
  212. {
  213. union SplitWord Scratch; /* Scratchpad variable */
  214. if(VgaParmTable[VgaTblEntry].Mode & WORD_MODE)
  215. INPut.word <<= 1;
  216. INPut.word -= 1;
  217. Scratch.word = INPut.word;
  218. Scratch.word <<= 1;
  219. // 512k handling not yet final. 640x480 is stable with wrong colours
  220. // with special case commented out, don't want to delete code until
  221. // changes are final.
  222. //
  223. // if (HalfMeg)
  224. // {
  225. // Scratch.word <<= 1;
  226. // INPut.byte.low &= 0x01;
  227. // }
  228. // else{
  229. INPut.byte.low &= 0x03;
  230. // }
  231. Scratch.byte.low &= 0x0F8;
  232. INPut.byte.high = Scratch.byte.high;
  233. INPut.byte.low |= Scratch.byte.low;
  234. Scratch.byte.high &= 0x01;
  235. Scratch.byte.high <<= 2;
  236. INPut.byte.low |= Scratch.byte.high;
  237. return INPut.word;
  238. } /* Gen8514V() */
  239. /*
  240. * short XlateVgaTable(HwDeviceExtension, TableOffset, pmode, VgaTblEntry,
  241. * BookTblEntry, ee, IsMach32);
  242. *
  243. * PVOID HwDeviceExtension; Hardware extension for Windows NT
  244. * short TableOffset; Offset of start of desired mode table into EEPROM
  245. * struct st_mode_table *pmode; Mode table to fill in
  246. * short VgaTblEntry; Resolution/vertical frequency of desired mode
  247. * short BookTblEntry; Appendix D entry to use if parameters not in EEPROM
  248. * struct st_eeprom_data *ee; EEPROM setup description
  249. * BOOL IsMach32; Indicates whether card is a Mach32 or a Mach8
  250. *
  251. * Translates an EEPROM mode table from VGA to 8514 format and
  252. * fills in the mode table passed in the parameter pmode.
  253. *
  254. * RETURN: Nonzero if values filled in
  255. * Zero if we were unable to find the appropriate
  256. * VGA parameter table. If this is the case, the
  257. * value INVALID_WARNING is placed in pmode->m_h_overscan,
  258. * pmode->m_v_overscan, pmode->m_overscan_8b, and
  259. * pmode->m_overscan_gr.
  260. */
  261. short XlateVgaTable(PVOID HwDeviceExtension,
  262. short TableOffset, struct st_mode_table *pmode,
  263. short VgaTblEntry, short BookTblEntry,
  264. struct st_eeprom_data *ee, BOOL IsMach32)
  265. {
  266. PHW_DEVICE_EXTENSION phwDeviceExtension = HwDeviceExtension;
  267. /*
  268. * Certain modes on some cards require extra scaling. This variable
  269. * is set to the scaling factor (zero if no scaling needed). Initially
  270. * assume that no scaling is needed.
  271. */
  272. short FudgeFactor = 0;
  273. union SplitWord ValueRead; /* Value read from the EEPROM */
  274. /*
  275. * Storage for CRT registers 06, 07 and 11. These registers are either
  276. * used a number of times and would need repeated reads if they weren't
  277. * saved, or are read before they are needed because they are the
  278. * other byte of a word which contains a register which is needed
  279. * at an earlier stage of the calculation.
  280. */
  281. unsigned char Crt06;
  282. unsigned char Crt07;
  283. unsigned char Crt11;
  284. /*
  285. * Saved value of the low byte of the vertical sync start.
  286. */
  287. unsigned char VSyncStart;
  288. /*
  289. * If this is a mode for which we have no information,
  290. * set up our warning and return.
  291. */
  292. if (VgaTblEntry == NO_TBL_ENTRY)
  293. {
  294. pmode->m_h_overscan = (short) INVALID_WARNING;
  295. pmode->m_v_overscan = (short) INVALID_WARNING;
  296. pmode->m_overscan_8b = (short) INVALID_WARNING;
  297. pmode->m_overscan_gr = (short) INVALID_WARNING;
  298. return 0;
  299. }
  300. /*
  301. * Under some circumstances, the CRT parameters will not be
  302. * properly entered into the EEPROM, so attempting to read
  303. * them will produce garbage values. If this is the case,
  304. * the CRTC_USAGE bit in word 0 of the mode table will
  305. * be clear (use sync polarities only).
  306. *
  307. * This case must be detected here, rather than calling
  308. * BookVgaTable() whenever the USE_STORED_PARMS bit of the
  309. * mode descriptor word is clear, because adjusting the screen
  310. * size and position for a custom monitor does not always set
  311. * this bit, but it will set the CRTC_USAGE bit.
  312. *
  313. * For this case, and for modes for which we have the parameters
  314. * from Appendix D of the Programmer's Guide to the Mach 32
  315. * Registers but no way to calculate the mode table information
  316. * based on values read from the EEPROM, fill in the mode table
  317. * with the book values and return.
  318. */
  319. ValueRead.word = (ee->EEread)((short)(TableOffset+0));
  320. if ((VgaTblEntry >= USE_BOOK_VALUE) || !(ValueRead.word & CRTC_USAGE))
  321. {
  322. BookVgaTable(BookTblEntry, pmode);
  323. return 1;
  324. }
  325. /*
  326. * We have VGA parameter tables to allow us to calculate the mode
  327. * table entries from the EEPROM contents.
  328. *
  329. * Initially assume that we have either a Mach32 card or an older
  330. * card with 1M of video memory.
  331. */
  332. HalfMeg = 0;
  333. /*
  334. * Select the VGA parameter table for the card we are using
  335. * (Mach8 or Mach32). On Mach8 cards, check if we are using
  336. * a mode which requires scaling, and if we have only 512k
  337. * of video memory.
  338. */
  339. if (IsMach32)
  340. {
  341. VgaParmTable = VgaParmTable_M32;
  342. }
  343. else{
  344. VgaParmTable = VgaParmTable_M8;
  345. if (VgaParmTable[VgaTblEntry].Stretch == 0x080)
  346. FudgeFactor = 1;
  347. if (!(INP(SUBSYS_STAT) & 0x080))
  348. HalfMeg = 1;
  349. }
  350. /*
  351. * Get the horizontal total first.
  352. */
  353. ValueRead.word = (ee->EEread)((short) (TableOffset+3));
  354. ValueRead.byte.high = ((ValueRead.byte.high + 5) << FudgeFactor) - 1;
  355. pmode->m_h_total = ValueRead.byte.high;
  356. Crt06 = ValueRead.byte.low;
  357. /*
  358. * Get the horizontal display width.
  359. */
  360. pmode->m_h_disp = VgaParmTable[VgaTblEntry].DisplayWidth;
  361. pmode->m_x_size = (pmode->m_h_disp + 1) * 8;
  362. /*
  363. * Get the start of the horizontal sync.
  364. */
  365. ValueRead.word = (ee->EEread)((short) (TableOffset+4));
  366. pmode->m_h_sync_strt = ((ValueRead.byte.high - 2) << FudgeFactor) + FudgeFactor;
  367. /*
  368. * Get the horizontal sync width.
  369. */
  370. ValueRead.word &= 0x1F1F;
  371. ValueRead.byte.low -= ValueRead.byte.high;
  372. ValueRead.byte.low &= 0x1f;
  373. ValueRead.byte.low <<= FudgeFactor;
  374. if (pmode->control & HSYNC_BIT)
  375. ValueRead.byte.low |= NEG_SYNC_FACTOR;
  376. pmode->m_h_sync_wid = ValueRead.byte.low;
  377. /*
  378. * Get the vertical total.
  379. */
  380. ValueRead.word = (ee->EEread)((short) (TableOffset+8));
  381. Crt07 = ValueRead.byte.high;
  382. ValueRead.byte.low = Crt06;
  383. GetVertOverflow(&(ValueRead.byte.high)); /* Overflow in bits 0&5 */
  384. ValueRead.word += 2;
  385. if (VgaParmTable[VgaTblEntry].MiscParms & INTERL)
  386. ValueRead.word += 4;
  387. ValueRead.word = Gen8514V(ValueRead, VgaTblEntry);
  388. if (VgaParmTable[VgaTblEntry].MiscParms & INTERL)
  389. ValueRead.byte.low &= 0x0FE;
  390. pmode->m_v_total = ValueRead.word;
  391. /*
  392. * Get the number of displayed scanlines.
  393. */
  394. ValueRead.byte.low = VgaParmTable[VgaTblEntry].DisplayHgt;
  395. ValueRead.byte.high = Crt07 >> 1; /* Overflow in bits 1&6 */
  396. GetVertOverflow(&(ValueRead.byte.high));
  397. ValueRead.word++;
  398. pmode->m_v_disp = Gen8514V(ValueRead, VgaTblEntry);
  399. /*
  400. * Y size is derived by removing bit 2.
  401. */
  402. pmode->m_y_size = (((pmode->m_v_disp >> 1) & 0x0FFFC) | (pmode->m_v_disp & 0x03)) + 1;
  403. /*
  404. * Get the start of the vertical sync.
  405. */
  406. ValueRead.word = (ee->EEread)((short) (TableOffset+5));
  407. Crt11 = ValueRead.byte.low;
  408. ValueRead.byte.low = ValueRead.byte.high;
  409. VSyncStart = ValueRead.byte.high;
  410. ValueRead.byte.high = Crt07 >> 2; /* Overflow in bits 2&7 */
  411. GetVertOverflow(&(ValueRead.byte.high));
  412. ValueRead.word++;
  413. pmode->m_v_sync_strt = Gen8514V(ValueRead, VgaTblEntry);
  414. /*
  415. * Get the vertical sync width.
  416. */
  417. Crt11 -= (VSyncStart & 0x0f);
  418. if (VgaParmTable[VgaTblEntry].Mode & WORD_MODE)
  419. Crt11 <<= 1;
  420. Crt11 &= 0x0f;
  421. if (pmode->control & VSYNC_BIT)
  422. Crt11 |= NEG_SYNC_FACTOR;
  423. pmode->m_v_sync_wid = Crt11;
  424. /*
  425. * Get the clock select and display control values.
  426. */
  427. pmode->m_clock_select = VgaParmTable[VgaTblEntry].ClockSel;
  428. pmode->ClockFreq = VgaParmTable[VgaTblEntry].ClockFreq;
  429. pmode->m_disp_cntl = (UCHAR)(VgaParmTable[VgaTblEntry].DispCntl);
  430. /*
  431. * Assume an 8-entry FIFO for 16 and 24 bit colour.
  432. */
  433. pmode->m_vfifo_24 = 8;
  434. pmode->m_vfifo_16 = 8;
  435. /*
  436. * Some parameters in 8514 format do not have corresponding EEPROM
  437. * table entries in VGA format. Set the pmode fields for these
  438. * parameters to zero.
  439. */
  440. pmode->m_h_overscan = 0;
  441. pmode->m_v_overscan = 0;
  442. pmode->m_overscan_8b = 0;
  443. pmode->m_overscan_gr = 0;
  444. pmode->m_status_flags = 0;
  445. /*
  446. * Let the caller know that the pmode table is now filled in.
  447. */
  448. return 1;
  449. } /* XlateVgaTable() */
  450. /*
  451. * void BookVgaTable(VgaTblEntry, pmode);
  452. *
  453. * short VgaTblEntry; Desired entry in BookValues[]
  454. * struct st_mode_table *pmode; Mode table to fill in
  455. *
  456. * Fills in a mode table using the values in the BookValues[] entry
  457. * corresponding to the resolution specified by VgaTblEntry.
  458. */
  459. void BookVgaTable(short VgaTblEntry, struct st_mode_table *pmode)
  460. {
  461. pmode->m_h_total = BookValues[VgaTblEntry].HTotal;
  462. pmode->m_h_disp = BookValues[VgaTblEntry].HDisp;
  463. pmode->m_x_size = (pmode->m_h_disp+1)*8;
  464. pmode->m_h_sync_strt = BookValues[VgaTblEntry].HSyncStrt;
  465. pmode->m_h_sync_wid = BookValues[VgaTblEntry].HSyncWid;
  466. pmode->m_v_total = BookValues[VgaTblEntry].VTotal;
  467. pmode->m_v_disp = BookValues[VgaTblEntry].VDisp;
  468. /*
  469. * y_size is derived by removing bit 2
  470. */
  471. pmode->m_y_size = (((pmode->m_v_disp >> 1) & 0x0FFFC) | (pmode->m_v_disp & 0x03)) + 1;
  472. pmode->m_v_sync_strt = BookValues[VgaTblEntry].VSyncStrt;
  473. pmode->m_v_sync_wid = BookValues[VgaTblEntry].VSyncWid;
  474. pmode->m_disp_cntl = BookValues[VgaTblEntry].DispCntl;
  475. pmode->m_clock_select = BookValues[VgaTblEntry].ClockSel;
  476. pmode->ClockFreq = BookValues[VgaTblEntry].ClockFreq;
  477. /*
  478. * Assume 8 FIFO entries for 16 and 24 bit colour.
  479. */
  480. pmode->m_vfifo_24 = 8;
  481. pmode->m_vfifo_16 = 8;
  482. /*
  483. * Fill in the refresh rate
  484. */
  485. pmode->Refresh = BookValues[VgaTblEntry].Refresh;
  486. /*
  487. * Clear the values which we don't have data for, then let
  488. * the caller know that the table is filled in.
  489. */
  490. pmode->m_h_overscan = 0;
  491. pmode->m_v_overscan = 0;
  492. pmode->m_overscan_8b = 0;
  493. pmode->m_overscan_gr = 0;
  494. pmode->m_status_flags = 0;
  495. return;
  496. } /* BookVgaTable() */
  497. /***************************************************************************
  498. *
  499. * void SetMach64Tables(void);
  500. *
  501. * DESCRIPTION:
  502. * Replace "canned" mode tables that differ between Mach 64 and
  503. * Mach 8/Mach 32 parameters with Mach 64 versions. Whenever possible,
  504. * an update to a VESA-compatible parameter table should be done in
  505. * BookValues[] - this routine is only for those cases where the
  506. * Mach 64 requires a pixel clock frequency that the clock generator
  507. * on the Mach 8 or Mach 32 can't produce.
  508. *
  509. * GLOBALS CHANGED:
  510. * Some entries in BookValues[] table
  511. *
  512. * CALLED BY:
  513. * QueryMach64()
  514. *
  515. * AUTHOR:
  516. * Robert Wolff
  517. *
  518. * CHANGE HISTORY:
  519. *
  520. * TEST HISTORY:
  521. *
  522. ***************************************************************************/
  523. void SetMach64Tables(void)
  524. {
  525. #define NUM_TABLES_TO_SWAP 1
  526. ULONG TableIndices[NUM_TABLES_TO_SWAP] =
  527. {
  528. B640F72
  529. };
  530. struct st_book_data NewTables[NUM_TABLES_TO_SWAP] =
  531. {
  532. {0x067, 0x04F, 0x052, 0x025, 0x040B, 0x03BF, 0x03D0, 0x023, 0x023, 31200000L, 0x0800, 72} /* 640x480 72Hz NI */
  533. };
  534. ULONG LoopCount;
  535. /*
  536. * Go through the list of tables that need to be replaced, setting all
  537. * the fields to the Mach 64 values.
  538. */
  539. for (LoopCount = 0; LoopCount < NUM_TABLES_TO_SWAP; LoopCount++)
  540. {
  541. BookValues[TableIndices[LoopCount]].HTotal = NewTables[LoopCount].HTotal;
  542. BookValues[TableIndices[LoopCount]].HDisp = NewTables[LoopCount].HDisp;
  543. BookValues[TableIndices[LoopCount]].HSyncStrt = NewTables[LoopCount].HSyncStrt;
  544. BookValues[TableIndices[LoopCount]].HSyncWid = NewTables[LoopCount].HSyncWid;
  545. BookValues[TableIndices[LoopCount]].VTotal = NewTables[LoopCount].VTotal;
  546. BookValues[TableIndices[LoopCount]].VDisp = NewTables[LoopCount].VDisp;
  547. BookValues[TableIndices[LoopCount]].VSyncStrt = NewTables[LoopCount].VSyncStrt;
  548. BookValues[TableIndices[LoopCount]].VSyncWid = NewTables[LoopCount].VSyncWid;
  549. BookValues[TableIndices[LoopCount]].DispCntl = NewTables[LoopCount].DispCntl;
  550. BookValues[TableIndices[LoopCount]].ClockFreq = NewTables[LoopCount].ClockFreq;
  551. BookValues[TableIndices[LoopCount]].ClockSel = NewTables[LoopCount].ClockSel;
  552. BookValues[TableIndices[LoopCount]].Refresh = NewTables[LoopCount].Refresh;
  553. }
  554. return;
  555. } /* SetMach64Tables() */