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.

481 lines
16 KiB

  1. /************************************************************************/
  2. /* */
  3. /* ATIMP.H */
  4. /* */
  5. /* November 2 1992 (c) 1992, ATI Technologies Incorporated. */
  6. /************************************************************************/
  7. /********************** PolyTron RCS Utilities
  8. $Revision: 1.22 $
  9. $Date: 01 Mar 1996 12:10:48 $
  10. $Author: RWolff $
  11. $Log: S:/source/wnt/ms11/miniport/archive/atimp.h_v $
  12. *
  13. * Rev 1.22 01 Mar 1996 12:10:48 RWolff
  14. * Allocated more space for mapped registers, since VGA Graphics Index
  15. * and Graphics Data are now handled as separate registers rather than
  16. * as offsets into the block of VGA registers.
  17. *
  18. * Rev 1.21 02 Feb 1996 17:14:52 RWolff
  19. * Moved DDC/VDIF merge source information into hardware device extension
  20. * so each card can be considered independently in a multihead setup.
  21. *
  22. * Rev 1.20 29 Jan 1996 16:53:58 RWolff
  23. * Now uses VideoPortInt10() rather than no-BIOS code on PPC, removed
  24. * dead code.
  25. *
  26. * Rev 1.19 22 Dec 1995 14:52:32 RWolff
  27. * Added support for Mach 64 GT internal DAC.
  28. *
  29. * Rev 1.18 19 Dec 1995 14:00:26 RWolff
  30. * Increased size of buffer used to store query structure and mode tables
  31. * to allow for increase in the number of "canned" tables due to support
  32. * for higher refresh rates.
  33. *
  34. * Rev 1.17 28 Nov 1995 18:07:58 RWolff
  35. * Added "Card Initialized" field to hardware device extension. This
  36. * is part of multiheaded support, to prevent multiple initializations
  37. * of a single card.
  38. *
  39. * Rev 1.16 27 Oct 1995 14:21:26 RWolff
  40. * Removed mapped LFB from hardware device extension.
  41. *
  42. * Rev 1.15 08 Sep 1995 16:36:12 RWolff
  43. * Added support for AT&T 408 DAC (STG1703 equivalent).
  44. *
  45. * Rev 1.14 24 Aug 1995 15:38:38 RWolff
  46. * Changed detection of block I/O cards to match Microsoft's
  47. * standard for plug-and-play.
  48. *
  49. * Rev 1.13 28 Jul 1995 14:39:50 RWolff
  50. * Added support for the Mach 64 VT (CT equivalent with video overlay).
  51. *
  52. * Rev 1.12 31 Mar 1995 11:57:44 RWOLFF
  53. * Changed debug thresholds to avoid being swamped by level 3 statements
  54. * in VIDEOPRT.SYS, removed DEBUG_SWITCH since it's no longer used.
  55. *
  56. * Rev 1.11 30 Mar 1995 12:01:54 RWOLFF
  57. * Added definitions for debug level thresholds.
  58. *
  59. * Rev 1.10 07 Feb 1995 18:19:54 RWOLFF
  60. * Updated colour depth table for STG1702/1703. Entries for DACs
  61. * that are supposedly equivalent to these are unchanged, since
  62. * I did not have cards with these DACs and more than 2M of
  63. * video memory to test with.
  64. *
  65. * Rev 1.9 30 Jan 1995 11:56:42 RWOLFF
  66. * Added support for CT internal DAC.
  67. *
  68. * Rev 1.8 18 Jan 1995 15:39:32 RWOLFF
  69. * Added support for Chrontel DAC.
  70. *
  71. * Rev 1.7 23 Dec 1994 10:48:32 ASHANMUG
  72. * ALPHA/Chrontel-DAC
  73. *
  74. * Rev 1.6 18 Nov 1994 11:53:28 RWOLFF
  75. * Added support for split rasters, Power PC, and new DAC type DAC_STG1703.
  76. *
  77. * Rev 1.5 06 Sep 1994 10:46:52 ASHANMUG
  78. * Disable 1600x1200 on all cards except with TVM DAC
  79. *
  80. * Rev 1.4 31 Aug 1994 16:16:10 RWOLFF
  81. * Added support for TVP3026 DAC and 1152x864, doubled QUERYSIZE to
  82. * allow additional mode tables (needed because we now support 1152x864
  83. * and 1600x1200, we have more refresh rates at 1280x1024, and TVP DAC
  84. * supports high-res high depth modes AND 4BPP).
  85. *
  86. * Rev 1.3 19 Aug 1994 17:06:22 RWOLFF
  87. * Added support for the SC15026 DAC.
  88. *
  89. * Rev 1.2 12 May 1994 11:09:00 RWOLFF
  90. * Expanded CardInfo field of hardware device extension structure to allow
  91. * more mode tables (needed when setting up "canned" refresh rates"), added
  92. * defined value for hardware default refresh rate.
  93. *
  94. * Rev 1.1 03 Mar 1994 12:37:10 ASHANMUG
  95. * Make pageable
  96. *
  97. * Rev 1.0 31 Jan 1994 11:40:12 RWOLFF
  98. * Initial revision.
  99. Rev 1.8 14 Jan 1994 15:19:14 RWOLFF
  100. Added support for 1600x1200 mode.
  101. Rev 1.7 15 Dec 1993 15:25:04 RWOLFF
  102. Added support for SC15021 DAC.
  103. Rev 1.6 30 Nov 1993 18:11:38 RWOLFF
  104. Changed maximum pixel depth for STG1700 DAC at 640x480 and 800x600 to 32BPP
  105. Rev 1.5 05 Nov 1993 13:22:46 RWOLFF
  106. Added new DAC types.
  107. Rev 1.4 08 Oct 1993 15:16:54 RWOLFF
  108. Updated build and version numbers.
  109. Rev 1.3 08 Oct 1993 11:01:46 RWOLFF
  110. Removed code specific to a particular family of ATI accelerators, added
  111. definition for a delay which is only used on DEC Alpha machines.
  112. Rev 1.2 24 Sep 1993 11:47:44 RWOLFF
  113. Added definition for DEBUG_SWITCH, which will allow VideoDebugPrint() calls
  114. to be turned on and off all at once.
  115. Rev 1.1 03 Sep 1993 14:27:00 RWOLFF
  116. Partway through CX isolation.
  117. Rev 1.0 16 Aug 1993 13:30:56 Robert_Wolff
  118. Initial revision.
  119. Rev 1.15 06 Jul 1993 15:48:32 RWOLFF
  120. Added MaxDepth[] entries for AT&T 491 and ATI 68860 DACs.
  121. Rev 1.14 10 Jun 1993 15:57:02 RWOLFF
  122. Added definition for size of buffer used in registry reads,
  123. moved definition of checked-version-only breakpoint INT
  124. here to avoid duplicating it in all C files.
  125. Rev 1.13 07 Jun 1993 12:59:00 BRADES
  126. add EXT_CUR_Y, and EXT_SRC_Y mach8 register defines.
  127. Rev 1.12 18 May 1993 14:07:38 RWOLFF
  128. Added definition TTY_ATTR_NORMAL (white on blue attribute), which is needed
  129. in aperture tests and was supplied by now-obsolete TTY.H.
  130. Rev 1.11 10 May 1993 16:41:18 RWOLFF
  131. Added table listing maximum pixel depth for each supported DAC/resolution
  132. combination.
  133. Rev 1.10 30 Apr 1993 17:08:24 RWOLFF
  134. RegistryBuffer is now dynamically allocated.
  135. Rev 1.9 30 Apr 1993 15:52:42 BRADES
  136. fix DISP_STATUS from 5 to 2e8.
  137. Rev 1.7 14 Apr 1993 17:41:30 RWOLFF
  138. Removed redundant definitions to eliminate warnings.
  139. Rev 1.6 08 Apr 1993 16:45:42 RWOLFF
  140. Revision level as checked in at Microsoft.
  141. Rev 1.5 30 Mar 1993 17:09:38 RWOLFF
  142. Made RegistryParameterCallback() avialable to all miniport source files,
  143. increased buffer capacity for registry reads.
  144. Rev 1.4 25 Mar 1993 11:17:16 RWOLFF
  145. No longer grabs registers we don't use.
  146. Rev 1.3 08 Mar 1993 19:30:52 BRADES
  147. submit to MS NT
  148. Rev 1.2 10 Feb 1993 13:00:48 Robert_Wolff
  149. Added VideoRamLength field to HW_DEVICE_EXTENSION, FrameLength is now
  150. the aperture size rather than the amount of video memory.
  151. Rev 1.1 05 Feb 1993 16:55:06 Robert_Wolff
  152. Now initializes "shareable" field of VIDEO_ACCESS_RANGE structures
  153. to allow VGA driver to run concurrently with ours. This allows switching
  154. to/from full-screen DOS sessions.
  155. Rev 1.0 05 Feb 1993 16:17:42 Robert_Wolff
  156. Initial revision.
  157. Rev 1.0 02 Nov 1992 20:48:14 Chris_Brady
  158. Initial revision.
  159. End of PolyTron RCS section *****************/
  160. #ifdef DOC
  161. DESCRIPTION
  162. ATI Windows NT Miniport driver for the Mach64, Mach32, and Mach8
  163. families.
  164. This file will select the appropriate functions depending on the
  165. computer configuration.
  166. Environment:
  167. Kernel mode
  168. #endif
  169. /*
  170. * SPLIT_RASTERS is defined in order to work with a display driver which
  171. * may break a scan line across the boundary between 64k pages when using
  172. * the VGA aperture, and undefined when working with a display driver
  173. * which requires that every scan line be contained within a single page
  174. * (modes with a screen width of less than 1024 pixels are padded to a
  175. * pitch of 1024, modes with a width greater than 1024 but less than
  176. * 2048 are padded to a pitch of 2048).
  177. */
  178. #define SPLIT_RASTERS 1
  179. /*
  180. * Values used to indicate priority of VideoDebugPrint() calls.
  181. *
  182. * To set the debug threshold, set the ati\Device0\VideoDebugLevel
  183. * registry field to the lowest-priority debug statments you want
  184. * to see. For example, a value of 2 will display DEBUG_ERROR and
  185. * DEBUG_IMPORTANT in addition to DEBUG_TRACE, but will not display
  186. * DEBUG_DETAIL.
  187. */
  188. #define DEBUG_ERROR 0 /* Statements with this level should never happen */
  189. #define DEBUG_NORMAL 1 /* Entry/exit points of major functions and other important information */
  190. #define DEBUG_DETAIL 2 /* Detailed debug information */
  191. #define DEBUG_RIDICULOUS 3 /* This level will trigger MASSIVE numbers of statments from VIDEOPRT.SYS */
  192. /*
  193. * Uncomment to allow building using free version of VIDEOPRT.LIB
  194. */
  195. //#undef VideoDebugPrint
  196. //#define VideoDebugPrint(x)
  197. /*
  198. * Delay for DEC Alpha and other machines too fast to allow
  199. * consecutive I/O instructions without a delay in between.
  200. */
  201. #if defined (ALPHA) || defined (_ALPHA_)
  202. #define DEC_DELAY delay(3);
  203. #else
  204. #define DEC_DELAY
  205. #endif
  206. /*
  207. * Definitions used by the IOCTL_VIDEO_ATI_GET_VERSION packet.
  208. */
  209. #define MINIPORT_BUILD 511 /* NT Retail build number */
  210. #define MINIPORT_VERSION_MAJOR 0 /* Major version number */
  211. #define MINIPORT_VERSION_MINOR 3 /* Minor version number */
  212. // #define DBG 1
  213. #define CURSOR_WIDTH 64
  214. #define CURSOR_HEIGHT 64
  215. /*
  216. * Screen attributes for "blue screen" text (white on blue), used
  217. * to recognize whether or not we are looking at the "blue screen"
  218. * or other memory.
  219. */
  220. #define TTY_ATTR_NORMAL 0x17
  221. //------------------------------------------------------------------------
  222. /*
  223. * List of available resolutions
  224. */
  225. #define RES_640 0
  226. #define RES_800 1
  227. #define RES_1024 2
  228. #define RES_1152 3
  229. #define RES_1280 4
  230. #define RES_1600 5
  231. /*
  232. * "Card found" status variables. We support a single card that does
  233. * not use block relocatable I/O, or up to 16 cards (INT 10 AH=A0 through
  234. * AH=AF) that use block relocatable I/O, but never a mix of block and
  235. * non-block cards.
  236. */
  237. extern BOOL FoundNonBlockCard;
  238. extern USHORT NumBlockCardsFound;
  239. /*
  240. * List of greatest pixel depths available for each supported
  241. * DAC at all resolutions.
  242. *
  243. * A value of 0 indicates that the DAC is known to not support
  244. * the corresponding resolution. A value of 1 indicates that
  245. * it is unknown whether or not the DAC supports the corresponding
  246. * resolution. Since we don't report any modes with a colour depth
  247. * less than 4BPP, both will be seen as the resolution not being
  248. * supported.
  249. */
  250. #ifdef INCLUDE_ATIMP
  251. short MaxDepth[HOW_MANY_DACs][RES_1600-RES_640+1] =
  252. {
  253. 16, 16, 16, 16, 8, 1, /* DAC_ATI_68830 */
  254. 24, 16, 8, 8, 8, 1, /* DAC_SIERRA */
  255. 32, 32, 16, 16, 8, 1, /* DAC_TI34075 */
  256. 8, 8, 8, 8, 8, 1, /* DAC_BT47x */
  257. 24, 16, 8, 8, 8, 1, /* DAC_BT48x */
  258. 32, 32, 32, 32, 24, 1, /* DAC_ATI_68860 */
  259. 32, 32, 16, 16, 8, 1, /* DAC_STG1700 */
  260. 24, 24, 24, 24, 16, 1, /* DAC_SC15021 NOTE: Should be able to handle 32BPP. */
  261. /*
  262. * DAC types below are for cases where incompatible DAC types
  263. * report the same code in CONFIG_STATUS_1. Since the DAC type
  264. * field is 3 bits and can't grow (bits immediately above and
  265. * below are already assigned), DAC types 8 and above will
  266. * not conflict with reported DAC types but are still legal
  267. * in the query structure's DAC type field (8 bit unsigned integer).
  268. */
  269. 24, 16, 8, 8, 8, 1, /* DAC_ATT491 */
  270. 32, 32, 16, 16, 8, 1, /* DAC_ATT498 */
  271. 24, 16, 8, 8, 8, 1, /* DAC_SC15026 */
  272. 32, 32, 32, 32, 24, 24, /* DAC_TVP3026 */
  273. 32, 32, 32, 32, 24, 24, /* DAC_IBM514 */
  274. 32, 32, 24, 16, 16, 1, /* DAC_STG1702 */
  275. 32, 32, 24, 16, 16, 1, /* DAC_STG1703 */
  276. 32, 32, 16, 16, 8, 1, /* DAC_CH8398 */
  277. 32, 32, 16, 16, 8, 1, /* DAC_ATT408 */
  278. 32, 32, 16, 16, 8, 1, /* DAC_INTERNAL_CT */
  279. 32, 32, 16, 16, 8, 1, /* DAC_INTERNAL_GT */
  280. 32, 32, 16, 16, 8, 1 /* DAC_INTERNAL_VT */
  281. };
  282. #else
  283. extern short MaxDepth[HOW_MANY_DACs][RES_1600-RES_640+1];
  284. #endif
  285. //-----------------------------------------------------------------------
  286. typedef struct tagVDATA {
  287. ULONG Address;
  288. ULONG Value;
  289. } VDATA, *PVDATA;
  290. //------------------------------------------
  291. #ifndef QUERYSIZE
  292. #define QUERYSIZE 12288
  293. #endif
  294. /*
  295. * Value stored in VIDEO_MODE_INFORMATION.Frequency field to
  296. * indicate hardware default refresh rate.
  297. */
  298. #define DEFAULT_REFRESH 1
  299. /*
  300. * Number of mapped address ranges allowed in HW_DEVICE_EXTENSION
  301. * structure. Modules which will be mapping address ranges to fill
  302. * arrays with this size contain checks on this value. If the array
  303. * would be overfilled, these checks will cause compile-time errors.
  304. */
  305. #define NUM_ADDRESS_RANGES_ALLOWED 108
  306. /*
  307. * Define device extension structure. This is device dependant/private
  308. * information.
  309. */
  310. typedef struct _HW_DEVICE_EXTENSION {
  311. /*
  312. * I/O space ranges used. The extra 1 is for the
  313. * VGAWONDER extended base register, which is determined
  314. * at runtime.
  315. */
  316. PVOID aVideoAddressIO[NUM_ADDRESS_RANGES_ALLOWED];
  317. /*
  318. * Memory Mapped address ranges used. This array must
  319. * be the same size as the I/O mapped array.
  320. */
  321. PVOID aVideoAddressMM[NUM_ADDRESS_RANGES_ALLOWED];
  322. PVOID RomBaseRange; /* ROM address range used */
  323. PHYSICAL_ADDRESS PhysicalFrameAddress; /* Physical address of the LFB */
  324. ULONG VideoRamSize; /* Amount of installed video memory */
  325. ULONG FrameLength; /* Aperture size. */
  326. ULONG ModeIndex; /* Index of current mode in either ModesVGA[] */
  327. /* or mode tables in CardInfo[], depending on */
  328. /* whether video card is VGAWonder or accelerator */
  329. ULONG HardwareCursorAddr; /* Storage of cursor bitmap for 68800 hardware cursor */
  330. ULONG ModelNumber; /* ATI Adapter Card Type */
  331. USHORT BiosPrefix; /* Card sequence for accelerator INT 10 calls */
  332. ULONG BaseIOAddress; /* Used in matching BIOS prefix to I/O base on relocatable cards */
  333. char CardInfo[QUERYSIZE]; /* Storage for query information */
  334. struct st_eeprom_data *ee; /* Information used to access EEPROM */
  335. /*
  336. * The following 4 fields are used when re-initializing the windowed
  337. * screen after a full-screen DOS session. They are a flag to show
  338. * that the mode is being re-initialized instead of entered for the
  339. * first time, the palette of colours to use, the first palette entry
  340. * to be reloaded, and the number of palette entries to be reloaded.
  341. */
  342. BOOL ReInitializing;
  343. ULONG Clut[256];
  344. USHORT FirstEntry;
  345. USHORT NumEntries;
  346. /*
  347. * Used to ensure that ATIMPInitialize() is only called once for
  348. * any given card.
  349. */
  350. BOOL CardInitialized;
  351. ULONG PreviousPowerState;
  352. /*
  353. * Shows whether to merge "canned" mode tables with tables from
  354. * VDIF file, or with tables from EDID structure returned by DDC.
  355. */
  356. ULONG MergeSource;
  357. ULONG EdidChecksum; /* Checksum of EDID structure */
  358. } HW_DEVICE_EXTENSION, *PHW_DEVICE_EXTENSION;
  359. #if defined INCLUDE_ATIMP
  360. PHW_DEVICE_EXTENSION phwDeviceExtension; // Global Miniport Variable now
  361. #else
  362. extern PHW_DEVICE_EXTENSION phwDeviceExtension;
  363. #endif
  364. /*
  365. * Registry callback routine and buffers to allow data to be retrieved
  366. * by other routines.
  367. */
  368. extern VP_STATUS
  369. RegistryParameterCallback(
  370. PHW_DEVICE_EXTENSION phwDeviceExtension,
  371. PVOID Context,
  372. PWSTR Name,
  373. PVOID Data,
  374. ULONG Length
  375. );
  376. #define REGISTRY_BUFFER_SIZE 200 /* Size of buffer used in registry reads */
  377. extern UCHAR RegistryBuffer[]; /* Last value retrieved from the registry */
  378. extern ULONG RegistryBufferLength; /* Size of last retrieved value */
  379. /*
  380. * Macros to provide debug breakpoints in checked version while
  381. * clearing them in free version.
  382. */
  383. #if DBG
  384. #if defined(i386) || defined(_X86_)
  385. #define INT _asm int 3;
  386. #else
  387. #define INT DbgBreakPoint();
  388. /*
  389. * Function prototype has vanished from headers we include, so
  390. * we must supply it on our own.
  391. */
  392. extern void DbgBreakPoint(void);
  393. #endif
  394. #else
  395. #define INT
  396. #endif
  397. /*
  398. * Routine to make an absolute far call.
  399. */
  400. #if 0
  401. #ifdef _X86_
  402. extern VP_STATUS CallAbsolute(unsigned short, unsigned short, VIDEO_X86_BIOS_ARGUMENTS *);
  403. #endif
  404. #endif