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.

347 lines
12 KiB

  1. /************************************************************************/
  2. /* */
  3. /* QUERY_CX.H */
  4. /* */
  5. /* Oct 19 1993 (c) 1993, ATI Technologies Incorporated. */
  6. /************************************************************************/
  7. /********************** PolyTron RCS Utilities
  8. $Revision: 1.14 $
  9. $Date: 01 May 1996 14:11:26 $
  10. $Author: RWolff $
  11. $Log: S:/source/wnt/ms11/miniport/archive/query_cx.h_v $
  12. *
  13. * Rev 1.14 01 May 1996 14:11:26 RWolff
  14. * Added prototype for new routine DenseOnAlpha().
  15. *
  16. * Rev 1.13 23 Apr 1996 17:24:00 RWolff
  17. * Split mapping of memory types reported by BIOS into our enumeration
  18. * of memory types according to ASIC type, since ?T and ?X use the same
  19. * memory type code to refer to different memory types.
  20. *
  21. * Rev 1.12 15 Apr 1996 16:58:22 RWolff
  22. * Added prototype for routine which identifies which flavour of the
  23. * Mach 64 is in use.
  24. *
  25. * Rev 1.11 20 Mar 1996 13:45:38 RWolff
  26. * Increased size of buffer where screen is stored prior to video memory
  27. * being used to hold query information.
  28. *
  29. * Rev 1.10 01 Mar 1996 12:16:02 RWolff
  30. * Added definitions used for Alpha "blue screen" preservation.
  31. *
  32. * Rev 1.9 11 Jan 1996 19:43:32 RWolff
  33. * New definitions and structures to support use of AX=A?07 BIOS call rather
  34. * than special cases to restrict refresh rates.
  35. *
  36. * Rev 1.8 24 Feb 1995 12:29:18 RWOLFF
  37. * Prototype for TextBanding_cx()
  38. *
  39. * Rev 1.7 18 Nov 1994 11:54:14 RWOLFF
  40. * Split structures and internal variables so that they can be included
  41. * separately, as needed for no-BIOS support.
  42. *
  43. * Rev 1.6 14 Sep 1994 15:20:26 RWOLFF
  44. * Added definitions for all 32BPP colour orderings.
  45. *
  46. * Rev 1.5 31 Aug 1994 16:28:18 RWOLFF
  47. * Added support for 1152x864.
  48. *
  49. * Rev 1.4 30 Jun 1994 18:12:56 RWOLFF
  50. * Removed prototype for IsApertureConflict_cx() and definitions used
  51. * only by this function. Function moved to SETUP_CX.C because the
  52. * new method of checking for conflict requires access to definitions
  53. * and data structures which are only available in this module.
  54. *
  55. * Rev 1.3 12 May 1994 11:21:02 RWOLFF
  56. * Updated comment.
  57. *
  58. * Rev 1.2 27 Apr 1994 14:11:22 RWOLFF
  59. * Removed unused lookup table.
  60. *
  61. * Rev 1.1 07 Feb 1994 14:13:02 RWOLFF
  62. * Removed prototype for GetMemoryNeeded_cx().
  63. *
  64. * Rev 1.0 31 Jan 1994 11:43:00 RWOLFF
  65. * Initial revision.
  66. *
  67. * Rev 1.2 14 Jan 1994 15:24:32 RWOLFF
  68. * Updated CX query structure to match BIOS version 0.13, added 1600x1200
  69. * support, prototype for BlockWriteAvail_cx()
  70. *
  71. * Rev 1.1 30 Nov 1993 18:27:38 RWOLFF
  72. * Prototypes for new routines, fields of cx_query structure now match
  73. * fields in structure returned by BIOS query call.
  74. *
  75. * Rev 1.0 05 Nov 1993 13:36:52 RWOLFF
  76. * Initial revision.
  77. End of PolyTron RCS section *****************/
  78. #ifdef DOC
  79. QUERY_CX.H - Header file for QUERY_CX.C
  80. #endif
  81. /*
  82. * Definitions for deep colour and RAMDAC special features support,
  83. * stored in q_shadow_1 field (Mach 64 does not use shadow sets)
  84. * of query_structure.
  85. */
  86. #define S1_SYNC_ON_GREEN 0x8000
  87. #define S1_GAMMA_CORRECT 0x4000
  88. #define S1_GREYSCALE_256 0x2000
  89. #define S1_SLEEPMODE 0x1000
  90. #define S1_32BPP 0x00F0
  91. #define S1_32BPP_xRGB 0x0080
  92. #define S1_32BPP_BGRx 0x0040
  93. #define S1_32BPP_RGBx 0x0020
  94. #define S1_32BPP_xBGR 0x0010
  95. #define S1_24BPP 0x000C
  96. #define S1_24BPP_BGR 0x0008
  97. #define S1_24BPP_RGB 0x0004
  98. #define S1_16BPP 0x0003
  99. #define S1_16BPP_555 0x0002
  100. #define S1_16BPP_565 0x0001
  101. /*
  102. * Prototypes for functions provided by QUERY_CX.C
  103. */
  104. extern int DetectMach64(void);
  105. extern VP_STATUS QueryMach64(struct query_structure *Query);
  106. extern BOOL BlockWriteAvail_cx(struct query_structure *Query);
  107. extern BOOL TextBanding_cx(struct query_structure *Query);
  108. extern PWSTR IdentifyMach64Asic(struct query_structure *Query, PULONG AsicStringLength);
  109. #if defined(ALPHA)
  110. extern BOOL DenseOnAlpha(struct query_structure *Query);
  111. #endif
  112. /*
  113. * Structures used in QUERY_CX.C and (on non-x86 machines with no
  114. * emulation, so VideoPortInt10() is not available) modules which
  115. * emulate the query functions of the BIOS.
  116. */
  117. #ifdef STRUCTS_QUERY_CX
  118. /*
  119. * Hardware capability structure returned by BIOS call AX=0xA?07.
  120. */
  121. #pragma pack(1)
  122. struct cx_hw_cap{
  123. BYTE cx_HorRes; /* Horizontal resolution in units of 8 pixels */
  124. BYTE cx_RamOrDacType; /* RAM type or bitmask of DAC types */
  125. BYTE cx_MemReq; /* Minimum memory to support the mode in question */
  126. BYTE cx_MaxDotClock; /* Maximum dot clock, in megahertz */
  127. BYTE cx_MaxPixDepth; /* Code for maximum pixel depth for the mode in question */
  128. };
  129. /*
  130. * Query structure returned by CX BIOS call AX=0xA?09. This structure
  131. * is NOT interchangeable with query_structure from AMACH1.H.
  132. *
  133. * The alignment of fields within the BIOS query and mode table
  134. * structures does not match the default structure alignment of the
  135. * Windows NT C compiler, so we must force byte alignment.
  136. */
  137. struct cx_query{
  138. WORD cx_sizeof_struct; /* Size of the structure in bytes */
  139. BYTE cx_structure_rev; /* Structure revision number */
  140. BYTE cx_number_modes; /* Number of mode tables */
  141. WORD cx_mode_offset; /* Offset in bytes to first mode table */
  142. BYTE cx_mode_size; /* Size of each mode table */
  143. BYTE cx_vga_type; /* VGA enabled/disabled status */
  144. WORD cx_asic_rev; /* ASIC revision */
  145. BYTE cx_vga_boundary; /* VGA boundary */
  146. BYTE cx_memory_size; /* Amount of memory installed */
  147. BYTE cx_dac_type; /* DAC type */
  148. BYTE cx_memory_type; /* Type of memory chips installed */
  149. BYTE cx_bus_type; /* Bus type */
  150. BYTE cx_special_sync; /* Flags for composite sync and sync on green */
  151. WORD cx_aperture_addr; /* Aperture address in megabytes (0-4095) */
  152. BYTE cx_aperture_cfg; /* Aperture configuration */
  153. BYTE cx_deep_colour; /* Deep colour support information */
  154. BYTE cx_ramdac_info; /* Special features available from DAC */
  155. BYTE cx_reserved_1; /* Reserved */
  156. WORD cx_current_mode; /* Offset of current mode table */
  157. WORD cx_io_base; /* I/O base address */
  158. BYTE cx_reserved_2[6]; /* Reserved */
  159. };
  160. /*
  161. * Mode table structure returned by CX BIOS call AX=0xA?09. This structure
  162. * is NOT interchangeable with st_mode_table from AMACH1.H.
  163. */
  164. struct cx_mode_table{
  165. WORD cx_x_size; /* Horizontal resolution in pixels */
  166. WORD cx_y_size; /* Vertical resolution in pixels */
  167. BYTE cx_pixel_depth; /* Maximum pixel depth */
  168. BYTE cx_reserved_1; /* Reserved */
  169. WORD cx_eeprom_offset; /* Offset of table into EEPROM */
  170. WORD cx_reserved_2; /* Reserved */
  171. WORD cx_reserved_3; /* Reserved */
  172. WORD cx_crtc_gen_cntl; /* Interlace and double scan status */
  173. BYTE cx_crtc_h_total; /* CRTC_H_TOTAL value */
  174. BYTE cx_crtc_h_disp; /* CRTC_H_DISP value */
  175. BYTE cx_crtc_h_sync_strt; /* CRTC_H_SYNC_STRT value */
  176. BYTE cx_crtc_h_sync_wid; /* CRTC_H_SYNC_WID value */
  177. WORD cx_crtc_v_total; /* CRTC_V_TOTAL value */
  178. WORD cx_crtc_v_disp; /* CRTC_V_DISP value */
  179. WORD cx_crtc_v_sync_strt; /* CRTC_V_SYNC_STRT value */
  180. BYTE cx_crtc_v_sync_wid; /* CRTC_V_SYNC_WID value */
  181. BYTE cx_clock_cntl; /* Clock selector and divider */
  182. WORD cx_dot_clock; /* Dot clock for programmable clock chip */
  183. WORD cx_h_overscan; /* Horizontal overscan information */
  184. WORD cx_v_overscan; /* Vertical overscan information */
  185. WORD cx_overscan_8b; /* 8BPP and blue overscan colour */
  186. WORD cx_overscan_gr; /* Green and red overscan colour */
  187. };
  188. #pragma pack()
  189. #endif /* defined STRUCTS_QUERY_CX */
  190. #ifdef INCLUDE_QUERY_CX
  191. /*
  192. * Private definitions used in QUERY_CX.C
  193. */
  194. #define FORMAT_DACMASK 0 /* cx_hw_cap.cx_RamOrDacType is mask of DAC types */
  195. #define FORMAT_RAMMASK 1 /* cx_hw_cap.cx_RamOrDacType is mask of RAM types */
  196. #define FORMAT_DACTYPE 2 /* cx_hw_cap.cx_RamOrDacType is DAC type */
  197. #define FORMAT_RAMTYPE 3 /* cx_hw_cap.cx_RamOrDacType is RAM type */
  198. /*
  199. * The following definitions are used in creating a buffer where the
  200. * contents of an existing VGA graphics screen and specific VGA registers
  201. * are stored in preparation for using the screen as a buffer below
  202. * 1M physical in order to store the BIOS query information. It is
  203. * assumed that the temporary buffer used to store this information
  204. * is an array of unsigned characters.
  205. *
  206. * According to Arthur Lai, older BIOSes determined the required size
  207. * of the query buffer at runtime by examining the installed modes,
  208. * while newer BIOSes take a buffer large enough to handle the worst
  209. * case scenario in order to reduce code size. This should never be
  210. * larger than 1 kilobyte. In the unlikely event that this is exceeded,
  211. * we will save the first kilobyte and allow the remainder to be
  212. * overwritten by query data, rather than overflowing our save buffer.
  213. */
  214. #define VGA_SAVE_SIZE 1024 /* Array location where size of buffer is stored */
  215. #define VGA_SAVE_SIZE_H 1025
  216. #define VGA_SAVE_SEQ02 1026 /* Array location where sequencer register 2 value stored */
  217. #define VGA_SAVE_GRA08 1027 /* Array location where graphics register 8 value stored */
  218. #define VGA_SAVE_GRA01 1028 /* Array location where graphics register 1 value stored */
  219. #define VGA_TOTAL_SIZE 1029 /* Size of screen/register save buffer */
  220. /*
  221. * Pixel depths for use as an array index. Two columns will be wasted
  222. * since there is no depth code equal to zero and we don't use 15BPP,
  223. * but this allows direct indexing using the pixel width field of the
  224. * hardware capabilities structure returned by BIOS call AX=0xA?07.
  225. */
  226. enum {
  227. DEPTH_NOTHING = 0,
  228. DEPTH_4BPP,
  229. DEPTH_8BPP,
  230. DEPTH_15BPP,
  231. DEPTH_16BPP,
  232. DEPTH_24BPP,
  233. DEPTH_32BPP,
  234. HOW_MANY_DEPTHS
  235. };
  236. /*
  237. * Mappings of Mach 64 query values to enumerations from AMACH1.H
  238. */
  239. UCHAR CXMapMemSize[8] =
  240. {
  241. VRAM_512k,
  242. VRAM_1mb,
  243. VRAM_2mb,
  244. VRAM_4mb,
  245. VRAM_6mb,
  246. VRAM_8mb
  247. };
  248. UCHAR CXMapRamType[7] =
  249. {
  250. VMEM_DRAM_256Kx16,
  251. VMEM_VRAM_256Kx4_SER512,
  252. VMEM_VRAM_256Kx16_SER256,
  253. VMEM_DRAM_256Kx4,
  254. VMEM_DRAM_256Kx4_GRAP, /* Space filler - type 4 not documented */
  255. VMEM_VRAM_256Kx4_SPLIT512,
  256. VMEM_VRAM_256Kx16_SPLIT256
  257. };
  258. UCHAR CTMapRamType[7] =
  259. {
  260. VMEM_GENERIC_DRAM, /* Space filler - type 0 not documented */
  261. VMEM_GENERIC_DRAM,
  262. VMEM_EDO_DRAM,
  263. VMEM_BRRAM,
  264. VMEM_SDRAM,
  265. VMEM_GENERIC_DRAM, /* Space filler - type 5 not documented */
  266. VMEM_GENERIC_DRAM /* Space filler - type 6 not documented */
  267. };
  268. UCHAR CXMapBus[8] =
  269. {
  270. BUS_ISA_16, /* ISA bus */
  271. BUS_EISA,
  272. BUS_ISA_8, /* Use "weakest" bus for types marked as reserved */
  273. BUS_ISA_8, /* Reserved */
  274. BUS_ISA_8, /* Reserved */
  275. BUS_ISA_8, /* Reserved */
  276. BUS_LB_486, /* Mach 64 lumps all VLB types together */
  277. BUS_PCI
  278. };
  279. /*
  280. * Lookup table to translate the code for maximum colour depth returned
  281. * in the BIOS mode tables into bits per pixel.
  282. */
  283. USHORT CXPixelDepth[7] =
  284. {
  285. 0, /* Undefined */
  286. 4,
  287. 8,
  288. 16, /* xRRR RRGG GGGB BBBB */
  289. 16, /* RRRR RGGG GGGB BBBB */
  290. 24,
  291. 32
  292. };
  293. /*
  294. * Used in searching mode tables for desired resolution.
  295. */
  296. USHORT CXHorRes[6] =
  297. {
  298. 640,
  299. 800,
  300. 1024,
  301. 1152,
  302. 1280,
  303. 1600
  304. };
  305. /*
  306. * Flags to show that a given resolution is supported.
  307. */
  308. UCHAR CXStatusFlags[6] =
  309. {
  310. VRES_640x480,
  311. VRES_800x600,
  312. VRES_1024x768,
  313. VRES_1152x864,
  314. VRES_1280x1024,
  315. VRES_1600x1200
  316. };
  317. #endif /* defined INCLUDE_QUERY_CX */