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.

1054 lines
36 KiB

  1. /*++
  2. Copyright (c) 1992-1997 Microsoft Corporation
  3. Copyright (c) 1996-1997 Cirrus Logic, Inc.,
  4. Module Name:
  5. C I R R U S . H
  6. Abstract:
  7. This module contains the definitions for the code that implements the
  8. Cirrus Logic VGA 6410/6420/542x device driver.
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. * chu01 08-26-96 : Distinguish CL-5480 and CL-5436/46 because the former
  13. * has new fratures such as XY-clipping, XY-position and
  14. * BLT command list that the others do not have.
  15. * sge01 10-14-96 : Add PC97 Compliant support.
  16. *
  17. * sge02 10-24-96 : Add second aperture flag.
  18. *
  19. * sge03 10-29-96 : Merge port access and register access for VGA relocatable and MMIO registers.
  20. * chu02 12-16-96 : Enable color correct.
  21. *
  22. * myf0 : 08-19-96 added 85hz supported
  23. * myf1 : 08-20-96 supported panning scrolling
  24. * myf2 : 08-20-96 : fixed hardware save/restore state bug for matterhorn
  25. * myf3 : 09-01-96 : Added IOCTL_CIRRUS_PRIVATE_BIOS_CALL for TV supported
  26. * myf4 : 09-01-96 : patch Viking BIOS bug, PDR #4287, begin
  27. * myf5 : 09-01-96 : Fixed PDR #4365 keep all default refresh rate
  28. * myf6 : 09-17-96 : Merged Desktop SRC1001 & MINI102
  29. * myf7 : 09-19-96 : Fixed exclude 60Hz refresh rate selected
  30. * myf8 :*09-21-96*: May be need change CheckandUpdateDDC2BMonitor --keystring[]
  31. * myf9 : 09-21-96 : 8x6 panel in 6x4x256 mode, cursor can't move to bottom scrn
  32. * ms0809:09-25-96 : fixed dstn panel icon corrupted
  33. * ms923 :09-25-96 : merge MS-923 Disp.zip code
  34. * myf10 :09-26-96 : Fixed DSTN reserved half-frame buffer bug.
  35. * myf11 :09-26-96 : Fixed 755x CE chip HW bug, access ramdac before disable HW
  36. * icons and cursor
  37. * myf12 :10-01-96 : Supported Hot Key switch display
  38. * myf13 :10-02-96 : Fixed Panning scrolling (1280x1024x256) bug y < ppdev->miny
  39. * myf14 :10-15-96 : Fixed PDR#6917, 6x4 panel can't panning scrolling for 754x
  40. * myf15 :10-16-96 : Fixed disable memory mapped IO for 754x, 755x
  41. * myf16 :10-22-96 : Fixed PDR #6933,panel type set different demo board setting
  42. * tao1 : 10-21-96 : added CAPS_IS_7555 flag for direct draw support.
  43. * smith :10-22-96 : Disable Timer event, because sometimes creat PAGE_FAULT or
  44. * IRQ level can't handle
  45. * myf17 :11-04-96 : Added special escape code must be use 11/5/96 later NTCTRL,
  46. * and added Matterhorn LF Device ID==0x4C
  47. * myf18 :11-04-96 : Fixed PDR #7075,
  48. * myf19 :11-06-96 : Fixed Vinking can't work problem, because DEVICEID = 0x30
  49. * is different from data book (CR27=0x2C)
  50. * myf20 :11-12-96 : Fixed DSTN panel initial reserved 128K memoru
  51. * myf21 :11-15-96 : fixed #7495 during change resolution, screen appear garbage
  52. * image, because not clear video memory.
  53. * myf22 :11-19-96 : Added 640x480x256/640x480x64K -85Hz refresh rate for 7548
  54. * myf23 :11-21-96 : Added fixed NT 3.51 S/W cursor panning problem
  55. * myf24 :11-22-96 : Added fixed NT 4.0 Japanese dos full screen problem
  56. * myf25 :12-03-96 : Fixed 8x6x16M 2560byte/line patch H/W bug PDR#7843, and
  57. * fixed pre-install microsoft requested
  58. * myf26 :12-11-96 : Fixed Japanese NT 4.0 Dos-full screen bug for LCD enable
  59. * myf27 :01-09-96 : Fixed NT3.51 PDR#7986, horizontal lines appears at logon
  60. * windows, set 8x6x64K mode boot up CRT, jumper set 8x6 DSTN
  61. * Fixed NT3.51 PDR#7987, set 64K color modes, garbage on
  62. * screen when boot up XGA panel.
  63. * sge04 01-23-96 : Add CL5446_ID and CL5480_ID.
  64. * myf33 :03-21-97 : Support TV ON/OFF
  65. * chu03 03-26-97 : Get rid of 1024x768x16bpp ( Mode 0x74 ) 85H for IBM only.
  66. *
  67. --*/
  68. #define INT10_MODE_SET
  69. //
  70. // Do full save and restore.
  71. //
  72. #define EXTENDED_REGISTER_SAVE_RESTORE 1
  73. //
  74. // Banking ifdefs to enable banking
  75. // the banking type MUST match the type in clhard.asm
  76. //
  77. #define ONE_64K_BANK 0
  78. #define TWO_32K_BANKS 1
  79. #define MULTIPLE_REFRESH_TABLES 0
  80. //crus
  81. //myf17 #define PANNING_SCROLL //myf1
  82. //
  83. // Treat CL-GD5434_6 (rev 0xHH) as CL-GD5434 if requested.
  84. //
  85. #define CL5434_6_SPECIAL_REQUEST 0
  86. //---------------------------------------------------------------------------
  87. //
  88. // only one banking variable must be defined
  89. //
  90. #if TWO_32K_BANKS
  91. #if ONE_64K_BANK
  92. #error !!ERROR: two types of banking defined!
  93. #endif
  94. #elif ONE_64K_BANK
  95. #else
  96. #error !!ERROR: banking type must be defined!
  97. #endif
  98. //
  99. // Enable P6 Cache support
  100. //
  101. #define P6CACHE 1
  102. //
  103. // Base address of VGA memory range. Also used as base address of VGA
  104. // memory when loading a font, which is done with the VGA mapped at A0000.
  105. //
  106. #define MEM_VGA 0xA0000
  107. #define MEM_VGA_SIZE 0x20000
  108. #define MEM_LINEAR 0x0
  109. #define MEM_LINEAR_SIZE 0x0
  110. // #ifdef _ALPHA_
  111. //
  112. // #define PHY_AD_20_23 0x060 // Value for SR7 to map video memory
  113. // #define PHY_VGA 0x0600000 // put it at 6 megabytes for Alpha (for now)
  114. // #define PHY_VGA_SIZE 0x0100000 // allocate a megabyte of space there
  115. //
  116. // #endif
  117. //
  118. //
  119. // For memory mapped IO
  120. //
  121. #define MEMORY_MAPPED_IO_OFFSET (0xB8000 - 0xA0000)
  122. #define RELOCATABLE_MEMORY_MAPPED_IO_OFFSET 0x100
  123. //
  124. // Port definitions for filling the ACCESS_RANGES structure in the miniport
  125. // information, defines the range of I/O ports the VGA spans.
  126. // There is a break in the IO ports - a few ports are used for the parallel
  127. // port. Those cannot be defined in the ACCESS_RANGE, but are still mapped
  128. // so all VGA ports are in one address range.
  129. //
  130. #define VGA_BASE_IO_PORT 0x000003B0
  131. #define VGA_START_BREAK_PORT 0x000003BB
  132. #define VGA_END_BREAK_PORT 0x000003C0
  133. #define VGA_MAX_IO_PORT 0x000003DF
  134. //
  135. // VGA register definitions
  136. //
  137. #define CRTC_ADDRESS_PORT_MONO 0x03B4 // CRT Controller Address and
  138. #define CRTC_DATA_PORT_MONO 0x03B5 // Data registers in mono mode
  139. #define FEAT_CTRL_WRITE_PORT_MONO 0x03BA // Feature Control write port
  140. // in mono mode
  141. #define INPUT_STATUS_1_MONO 0x03BA // Input Status 1 register read
  142. // port in mono mode
  143. #define ATT_INITIALIZE_PORT_MONO INPUT_STATUS_1_MONO
  144. // Register to read to reset
  145. // Attribute Controller index/data
  146. #define ATT_ADDRESS_PORT 0x03C0 // Attribute Controller Address and
  147. #define ATT_DATA_WRITE_PORT 0x03C0 // Data registers share one port
  148. // for writes, but only Address is
  149. // readable at 0x010
  150. #define ATT_DATA_READ_PORT 0x03C1 // Attribute Controller Data reg is
  151. // readable here
  152. #define MISC_OUTPUT_REG_WRITE_PORT 0x03C2 // Miscellaneous Output reg write
  153. // port
  154. #define INPUT_STATUS_0_PORT 0x03C2 // Input Status 0 register read
  155. // port
  156. #define VIDEO_SUBSYSTEM_ENABLE_PORT 0x03C3 // Bit 0 enables/disables the
  157. // entire VGA subsystem
  158. #define SEQ_ADDRESS_PORT 0x03C4 // Sequence Controller Address and
  159. #define SEQ_DATA_PORT 0x03C5 // Data registers
  160. #define DAC_PIXEL_MASK_PORT 0x03C6 // DAC pixel mask reg
  161. #define DAC_ADDRESS_READ_PORT 0x03C7 // DAC register read index reg,
  162. // write-only
  163. #define DAC_STATE_PORT 0x03C7 // DAC state (read/write),
  164. // read-only
  165. #define DAC_ADDRESS_WRITE_PORT 0x03C8 // DAC register write index reg
  166. #define DAC_DATA_REG_PORT 0x03C9 // DAC data transfer reg
  167. #define FEAT_CTRL_READ_PORT 0x03CA // Feature Control read port
  168. #define MISC_OUTPUT_REG_READ_PORT 0x03CC // Miscellaneous Output reg read
  169. // port
  170. #define GRAPH_ADDRESS_PORT 0x03CE // Graphics Controller Address
  171. #define GRAPH_DATA_PORT 0x03CF // and Data registers
  172. // ports in color mode
  173. #define CRTC_ADDRESS_PORT_COLOR 0x03D4 // CRT Controller Address and
  174. #define CRTC_DATA_PORT_COLOR 0x03D5 // Data registers in color mode
  175. #define FEAT_CTRL_WRITE_PORT_COLOR 0x03DA // Feature Control write port
  176. #define INPUT_STATUS_1_COLOR 0x03DA // Input Status 1 register read
  177. // port in color mode
  178. #define ATT_INITIALIZE_PORT_COLOR INPUT_STATUS_1_COLOR
  179. // Register to read to reset
  180. // Attribute Controller index/data
  181. // toggle in color mode
  182. //
  183. // Offsets in HardwareStateHeader->PortValue[] of save areas for non-indexed
  184. // VGA registers.
  185. //
  186. #define CRTC_ADDRESS_MONO_OFFSET 0x04
  187. #define FEAT_CTRL_WRITE_MONO_OFFSET 0x0A
  188. #define ATT_ADDRESS_OFFSET 0x10
  189. #define MISC_OUTPUT_REG_WRITE_OFFSET 0x12
  190. #define VIDEO_SUBSYSTEM_ENABLE_OFFSET 0x13
  191. #define SEQ_ADDRESS_OFFSET 0x14
  192. #define DAC_PIXEL_MASK_OFFSET 0x16
  193. #define DAC_STATE_OFFSET 0x17
  194. #define DAC_ADDRESS_WRITE_OFFSET 0x18
  195. #define GRAPH_ADDRESS_OFFSET 0x1E
  196. #define CRTC_ADDRESS_COLOR_OFFSET 0x24
  197. #define FEAT_CTRL_WRITE_COLOR_OFFSET 0x2A
  198. // toggle in color mode
  199. //
  200. // VGA indexed register indexes.
  201. //
  202. // CL-GD542x specific registers:
  203. //
  204. #define IND_CL_EXTS_ENB 0x06 // index in Sequencer to enable exts
  205. #define IND_NORD_SCRATCH_PAD 0x09 // index in Seq of Nordic scratch pad
  206. #define IND_CL_SCRATCH_PAD 0x0A // index in Seq of 542x scratch pad
  207. #define IND_ALP_SCRATCH_PAD 0x15 // index in Seq of Alpine scratch pad
  208. #define IND_CL_REV_REG 0x25 // index in CRTC of ID Register
  209. #define IND_CL_ID_REG 0x27 // index in CRTC of ID Register
  210. //
  211. #define IND_CURSOR_START 0x0A // index in CRTC of the Cursor Start
  212. #define IND_CURSOR_END 0x0B // and End registers
  213. #define IND_CURSOR_HIGH_LOC 0x0E // index in CRTC of the Cursor Location
  214. #define IND_CURSOR_LOW_LOC 0x0F // High and Low Registers
  215. #define IND_VSYNC_END 0x11 // index in CRTC of the Vertical Sync
  216. // End register, which has the bit
  217. // that protects/unprotects CRTC
  218. // index registers 0-7
  219. #define IND_CR2C 0x2C // Nordic LCD Interface Register
  220. #define IND_CR2D 0x2D // Nordic LCD Display Control
  221. #define IND_SET_RESET_ENABLE 0x01 // index of Set/Reset Enable reg in GC
  222. #define IND_DATA_ROTATE 0x03 // index of Data Rotate reg in GC
  223. #define IND_READ_MAP 0x04 // index of Read Map reg in Graph Ctlr
  224. #define IND_GRAPH_MODE 0x05 // index of Mode reg in Graph Ctlr
  225. #define IND_GRAPH_MISC 0x06 // index of Misc reg in Graph Ctlr
  226. #define IND_BIT_MASK 0x08 // index of Bit Mask reg in Graph Ctlr
  227. #define IND_SYNC_RESET 0x00 // index of Sync Reset reg in Seq
  228. #define IND_MAP_MASK 0x02 // index of Map Mask in Sequencer
  229. #define IND_MEMORY_MODE 0x04 // index of Memory Mode reg in Seq
  230. #define IND_CRTC_PROTECT 0x11 // index of reg containing regs 0-7 in
  231. // CRTC
  232. #define IND_CRTC_COMPAT 0x34 // index of CRTC Compatibility reg
  233. // in CRTC
  234. #define IND_PERF_TUNING 0x16 // index of performance tuning in Seq
  235. #define START_SYNC_RESET_VALUE 0x01 // value for Sync Reset reg to start
  236. // synchronous reset
  237. #define END_SYNC_RESET_VALUE 0x03 // value for Sync Reset reg to end
  238. // synchronous reset
  239. //
  240. // Value to write to Extensions Control register values extensions.
  241. //
  242. #define CL64xx_EXTENSION_ENABLE_INDEX 0x0A // GR0A to be exact!
  243. #define CL64xx_EXTENSION_ENABLE_VALUE 0xEC
  244. #define CL64xx_EXTENSION_DISABLE_VALUE 0xCE
  245. #define CL64xx_TRISTATE_CONTROL_REG 0xA1
  246. #define CL6340_ENABLE_READBACK_REGISTER 0xE0
  247. #define CL6340_ENABLE_READBACK_ALLSEL_VALUE 0xF0
  248. #define CL6340_ENABLE_READBACK_OFF_VALUE 0x00
  249. #define CL6340_IDENTIFICATION_REGISTER 0xE9
  250. //
  251. // Values for Attribute Controller Index register to turn video off
  252. // and on, by setting bit 5 to 0 (off) or 1 (on).
  253. //
  254. #define VIDEO_DISABLE 0
  255. #define VIDEO_ENABLE 0x20
  256. #define INDEX_ENABLE_AUTO_START 0x31
  257. // Masks to keep only the significant bits of the Graphics Controller and
  258. // Sequencer Address registers. Masking is necessary because some VGAs, such
  259. // as S3-based ones, don't return unused bits set to 0, and some SVGAs use
  260. // these bits if extensions are enabled.
  261. //
  262. #define GRAPH_ADDR_MASK 0x0F
  263. #define SEQ_ADDR_MASK 0x07
  264. //
  265. // Mask used to toggle Chain4 bit in the Sequencer's Memory Mode register.
  266. //
  267. #define CHAIN4_MASK 0x08
  268. //
  269. // Value written to the Read Map register when identifying the existence of
  270. // a VGA in VgaInitialize. This value must be different from the final test
  271. // value written to the Bit Mask in that routine.
  272. //
  273. #define READ_MAP_TEST_SETTING 0x03
  274. //
  275. // Default text mode setting for various registers, used to restore their
  276. // states if VGA detection fails after they've been modified.
  277. //
  278. #define MEMORY_MODE_TEXT_DEFAULT 0x02
  279. #define BIT_MASK_DEFAULT 0xFF
  280. #define READ_MAP_DEFAULT 0x00
  281. //
  282. // Palette-related info.
  283. //
  284. //
  285. // Highest valid DAC color register index.
  286. //
  287. #define VIDEO_MAX_COLOR_REGISTER 0xFF
  288. //
  289. // Highest valid palette register index
  290. //
  291. #define VIDEO_MAX_PALETTE_REGISTER 0x0F
  292. //
  293. // Indices for type of memory mapping; used in ModesVGA[], must match
  294. // MemoryMap[].
  295. //
  296. typedef enum _VIDEO_MEMORY_MAP {
  297. MemMap_Mono,
  298. MemMap_CGA,
  299. MemMap_VGA
  300. } VIDEO_MEMORY_MAP, *PVIDEO_MEMORY_MAP;
  301. //
  302. // Memory map table definition
  303. //
  304. typedef struct {
  305. ULONG MaxSize; // Maximum addressable size of memory
  306. ULONG Offset; // Start address of display memory
  307. } MEMORYMAPS;
  308. //
  309. // For a mode, the type of banking supported. Controls the information
  310. // returned in VIDEO_BANK_SELECT. PlanarHCBanking includes NormalBanking.
  311. //
  312. typedef enum _BANK_TYPE {
  313. NoBanking = 0,
  314. NormalBanking,
  315. PlanarHCBanking
  316. } BANK_TYPE, *PBANK_TYPE;
  317. //
  318. // Define type of cirrus boards
  319. //
  320. typedef enum _BOARD_TYPE {
  321. SPEEDSTARPRO = 1,
  322. SIEMENS_ONBOARD_CIRRUS,
  323. NEC_ONBOARD_CIRRUS,
  324. OTHER
  325. } BOARD_TYPE;
  326. //
  327. // The chip ID is returned to the display driver in the
  328. // DriverSpecificAttributeFlags field during processing of
  329. // the IOCTL_VIDEO_QUERY_CURRENT_MODE.
  330. //
  331. #define CL6410 0x0001
  332. #define CL6420 0x0002
  333. #define CL542x 0x0004
  334. #define CL543x 0x0008
  335. #define CL5434 0x0010
  336. #define CL5434_6 0x0020
  337. #define CL5446BE 0x0040
  338. #define CL5436 0x0100
  339. #define CL5446 0x0200
  340. #define CL54UM36 0x0400
  341. //crus
  342. #define CL5480 0x0800
  343. //myf32 begin
  344. //#define CL754x 0x1000
  345. //#define CL755x 0x2000
  346. #define CL7541 0x1000
  347. #define CL7542 0x2000
  348. #define CL7543 0x4000
  349. #define CL7548 0x8000
  350. #define CL754x (CL7541 | CL7542 | CL7543 | CL7548)
  351. #define CL7555 0x10000
  352. #define CL7556 0x20000
  353. #define CL755x (CL7555 | CL7556)
  354. #define CL756x 0x40000
  355. // crus
  356. #define CL6245 0x80000
  357. //myf32 end
  358. //
  359. // Actual Revision IDs for certain cirrus chips
  360. //
  361. #define CL5429_ID 0x27
  362. #define CL5428_ID 0x26
  363. #define CL5430_ID 0x28
  364. #define CL5434_ID 0x2A
  365. #define CL5436_ID 0x2B
  366. //sge04
  367. #define CL5446_ID 0x2E
  368. #define CL5480_ID 0x2F
  369. //myf32 begin
  370. #define CL7542_ID 0x2C
  371. #define CL7541_ID 0x34
  372. #define CL7543_ID 0x30
  373. #define CL7548_ID 0x38
  374. #define CL7555_ID 0x40
  375. #define CL7556_ID 0x4C
  376. //#define CHIP754X (CL7541_ID | CL7542_ID | CL7543_ID | CL7548_ID)
  377. //#define CHIP755X (CL7555_ID | CL7556_ID)
  378. //myf32 end
  379. //
  380. // Driver Specific Attribute Flags
  381. //
  382. #define CAPS_NO_HOST_XFER 0x00000002 // Do not use host xfers to
  383. // the blt engine.
  384. #define CAPS_SW_POINTER 0x00000004 // Use software pointer.
  385. #define CAPS_TRUE_COLOR 0x00000008 // Set upper color registers.
  386. #define CAPS_MM_IO 0x00000010 // Use memory mapped IO.
  387. #define CAPS_BLT_SUPPORT 0x00000020 // BLTs are supported
  388. #define CAPS_IS_542x 0x00000040 // This is a 542x
  389. #define CAPS_AUTOSTART 0x00000080 // Autostart feature support.
  390. #define CAPS_CURSOR_VERT_EXP 0x00000100 // Flag set if 8x6 panel,
  391. #define CAPS_DSTN_PANEL 0x00000200 // DSTN panel in use, ms0809.
  392. #define CAPS_VIDEO 0x00000400 // Video support.
  393. #define CAPS_SECOND_APERTURE 0x00000800 // Second aperture support.
  394. #define CAPS_COMMAND_LIST 0x00001000 // Command List support.
  395. #define CAPS_GAMMA_CORRECT 0x00002000 // Color correction
  396. #define CAPS_VGA_PANEL 0x00004000 // use 6x4 VGA PANEL.
  397. #define CAPS_SVGA_PANEL 0x00008000 // use 8x6 SVGA PANEL.
  398. #define CAPS_XGA_PANEL 0x00010000 // use 10x7 XGA PANEL.
  399. #define CAPS_PANNING 0x00020000 // Panning scrolling supported.
  400. #define CAPS_TV_ON 0x00040000 // TV turn on supported., myf33
  401. #define CAPS_TRANSPARENCY 0x00080000 // Transparency is supported
  402. #define CAPS_ENGINEMANAGED 0x00100000 // Engine managed surface
  403. //myf16, end
  404. //crus end
  405. // bitfields for the DisplayType
  406. #define crt 0x0001
  407. #define panel 0x0002
  408. #define panel8x6 0x0004
  409. #define panel10x7 0x0008
  410. #define TFT_LCD 0x0100
  411. #define STN_LCD 0x0200
  412. #define Mono_LCD 0x0400
  413. #define Color_LCD 0x0800
  414. #define Single_LCD 0x1000
  415. #define Dual_LCD 0x2000
  416. #define Jump_type 0x8000 //myf27
  417. //crus
  418. #define DefaultMode 0x9 //myf19: 11-07-96 if panel can't support mode,
  419. // use 640x480x256c(0x5F) replace.
  420. //
  421. // Indexes into array of mode table pointers
  422. //
  423. #define pCL6410_crt 0
  424. #define pCL6410_panel 1
  425. #define pCL6420_crt 2
  426. #define pCL6420_panel 3
  427. #define pCL542x 4
  428. #define pCL543x 5
  429. #define pStretchScan 6
  430. #define pNEC_CL543x 7
  431. #define NUM_CHIPTYPES 8
  432. typedef struct {
  433. USHORT BiosModeCL6410; // bios modes are different across the
  434. USHORT BiosModeCL6420; // products. that's why we need multiple
  435. USHORT BiosModeCL542x; // values.
  436. } CLMODE, *PCLMODE;
  437. //
  438. // Structure used to describe each video mode in ModesVGA[].
  439. //
  440. typedef struct {
  441. USHORT fbType; // color or monochrome, text or graphics, via
  442. // VIDEO_MODE_COLOR and VIDEO_MODE_GRAPHICS
  443. USHORT numPlanes; // # of video memory planes
  444. USHORT bitsPerPlane; // # of bits of color in each plane
  445. SHORT col; // # of text columns across screen with default font
  446. SHORT row; // # of text rows down screen with default font
  447. USHORT hres; // # of pixels across screen
  448. USHORT vres; // # of scan lines down screen
  449. USHORT wbytes; // # of bytes from start of one scan line to start of next
  450. ULONG sbytes; // total size of addressable display memory in bytes
  451. ULONG Frequency; // Vertical Frequency
  452. ULONG Interlaced; // Determines if the mode is interlaced or not
  453. ULONG MonitorType; // Sets the desired vertical freq in an int10
  454. ULONG MonTypeAX; // Sets the desired horizontal freq in an int10
  455. ULONG MonTypeBX;
  456. ULONG MonTypeCX;
  457. BOOLEAN HWCursorEnable; // Flag to disable cursor if necessary
  458. BANK_TYPE banktype; // NoBanking, NormalBanking, PlanarHCBanking
  459. VIDEO_MEMORY_MAP MemMap; // index from VIDEO_MEMORY_MAP of memory
  460. // mapping used by this mode
  461. ULONG ChipType; // flags that say which chipset runs this mode
  462. //myf32 change USHORT to ULONG
  463. USHORT DisplayType; // display type this mode runs on(crt or panel)
  464. BOOLEAN ValidMode; // TRUE if mode valid, FALSE if not
  465. BOOLEAN LinearSupport; // TRUE if this mode can have its memory
  466. // mapped in linearly.
  467. CLMODE BiosModes;
  468. //
  469. // the mode will be TRUE if there is enough video memory to support the
  470. // mode, and the display type(it could be a panel), will support the mode.
  471. // PANELS only support 640x480 for now.
  472. //
  473. PUSHORT CmdStrings[NUM_CHIPTYPES]; // pointer to array of register-setting commands to
  474. // set up mode
  475. } VIDEOMODE, *PVIDEOMODE;
  476. //
  477. // Mode into which to put the VGA before starting a VDM, so it's a plain
  478. // vanilla VGA. (This is the mode's index in ModesVGA[], currently standard
  479. // 80x25 text mode.)
  480. //
  481. #define DEFAULT_MODE 0
  482. //crus, begin
  483. //myf1, begin
  484. #ifdef PANNING_SCROLL
  485. typedef struct {
  486. USHORT Hres;
  487. USHORT Vres;
  488. USHORT BitsPerPlane;
  489. USHORT ModesVgaStart;
  490. USHORT Mode;
  491. } RESTABLE, *PRESTABLE;
  492. typedef struct {
  493. USHORT hres;
  494. USHORT vres;
  495. USHORT wbytes;
  496. USHORT bpp;
  497. SHORT flag;
  498. } PANNMODE;
  499. USHORT ViewPoint_Mode = 0x5F;
  500. #endif
  501. UCHAR HWcur, HWicon0, HWicon1, HWicon2, HWicon3; //myf11
  502. //myf1, end
  503. //crus, end
  504. //
  505. // Info used by the Validator functions and save/restore code.
  506. // Structure used to trap register accesses that must be done atomically.
  507. //
  508. #define VGA_MAX_VALIDATOR_DATA 100
  509. #define VGA_VALIDATOR_UCHAR_ACCESS 1
  510. #define VGA_VALIDATOR_USHORT_ACCESS 2
  511. #define VGA_VALIDATOR_ULONG_ACCESS 3
  512. typedef struct _VGA_VALIDATOR_DATA {
  513. ULONG Port;
  514. UCHAR AccessType;
  515. ULONG Data;
  516. } VGA_VALIDATOR_DATA, *PVGA_VALIDATOR_DATA;
  517. //
  518. // Number of bytes to save in each plane.
  519. //
  520. #define VGA_PLANE_SIZE 0x10000
  521. //
  522. // Number of each type of indexed register in a standard VGA, used by
  523. // validator and state save/restore functions.
  524. //
  525. // Note: VDMs currently only support basic VGAs only.
  526. //
  527. #define VGA_NUM_SEQUENCER_PORTS 5
  528. #define VGA_NUM_CRTC_PORTS 25
  529. #define VGA_NUM_GRAPH_CONT_PORTS 9
  530. #define VGA_NUM_ATTRIB_CONT_PORTS 21
  531. #define VGA_NUM_DAC_ENTRIES 256
  532. #ifdef EXTENDED_REGISTER_SAVE_RESTORE
  533. //
  534. // Indices to start save/restore in extension registers:
  535. // For both chip types
  536. #define CL64xx_GRAPH_EXT_START 0x0b // does not include ext. enable
  537. #define CL64xx_GRAPH_EXT_END 0xFF
  538. #define CL542x_GRAPH_EXT_START 0x09
  539. #define CL542x_GRAPH_EXT_END 0x39
  540. #define CL542x_SEQUENCER_EXT_START 0x07 // does not include ext. enable
  541. #define CL542x_SEQUENCER_EXT_END 0x1F
  542. #define CL542x_CRTC_EXT_START 0x19
  543. #define CL542x_CRTC_EXT_END 0x1B
  544. //
  545. // Number of extended regs for both chip types
  546. //
  547. #define CL64xx_NUM_GRAPH_EXT_PORTS (CL64xx_GRAPH_EXT_END - CL64xx_GRAPH_EXT_START + 1)
  548. #define CL542x_NUM_GRAPH_EXT_PORTS (CL542x_GRAPH_EXT_END - CL542x_GRAPH_EXT_START + 1)
  549. #define CL542x_NUM_SEQUENCER_EXT_PORTS (CL542x_SEQUENCER_EXT_END - CL542x_SEQUENCER_EXT_START + 1)
  550. #define CL542x_NUM_CRTC_EXT_PORTS (CL542x_CRTC_EXT_END - CL542x_CRTC_EXT_START + 1)
  551. //
  552. // set values for save/restore area based on largest value for a chipset.
  553. //
  554. #define EXT_NUM_GRAPH_CONT_PORTS ((CL64xx_NUM_GRAPH_EXT_PORTS > \
  555. CL542x_NUM_GRAPH_EXT_PORTS) ? \
  556. CL64xx_NUM_GRAPH_EXT_PORTS : \
  557. CL542x_NUM_GRAPH_EXT_PORTS)
  558. #define EXT_NUM_SEQUENCER_PORTS CL542x_NUM_SEQUENCER_EXT_PORTS
  559. #define EXT_NUM_CRTC_PORTS CL542x_NUM_CRTC_EXT_PORTS
  560. #define EXT_NUM_ATTRIB_CONT_PORTS 0
  561. #define EXT_NUM_DAC_ENTRIES 0
  562. #else
  563. #define EXT_NUM_GRAPH_CONT_PORTS 0
  564. #define EXT_NUM_SEQUENCER_PORTS 0
  565. #define EXT_NUM_CRTC_PORTS 0
  566. #define EXT_NUM_ATTRIB_CONT_PORTS 0
  567. #define EXT_NUM_DAC_ENTRIES 0
  568. #endif
  569. //
  570. // These constants determine the offsets within the
  571. // VIDEO_HARDWARE_STATE_HEADER structure that are used to save and
  572. // restore the VGA's state.
  573. //
  574. #define VGA_HARDWARE_STATE_SIZE sizeof(VIDEO_HARDWARE_STATE_HEADER)
  575. #define VGA_BASIC_SEQUENCER_OFFSET (VGA_HARDWARE_STATE_SIZE + 0)
  576. #define VGA_BASIC_CRTC_OFFSET (VGA_BASIC_SEQUENCER_OFFSET + \
  577. VGA_NUM_SEQUENCER_PORTS)
  578. #define VGA_BASIC_GRAPH_CONT_OFFSET (VGA_BASIC_CRTC_OFFSET + \
  579. VGA_NUM_CRTC_PORTS)
  580. #define VGA_BASIC_ATTRIB_CONT_OFFSET (VGA_BASIC_GRAPH_CONT_OFFSET + \
  581. VGA_NUM_GRAPH_CONT_PORTS)
  582. #define VGA_BASIC_DAC_OFFSET (VGA_BASIC_ATTRIB_CONT_OFFSET + \
  583. VGA_NUM_ATTRIB_CONT_PORTS)
  584. #define VGA_BASIC_LATCHES_OFFSET (VGA_BASIC_DAC_OFFSET + \
  585. (3 * VGA_NUM_DAC_ENTRIES))
  586. #define VGA_EXT_SEQUENCER_OFFSET (VGA_BASIC_LATCHES_OFFSET + 4)
  587. #define VGA_EXT_CRTC_OFFSET (VGA_EXT_SEQUENCER_OFFSET + \
  588. EXT_NUM_SEQUENCER_PORTS)
  589. #define VGA_EXT_GRAPH_CONT_OFFSET (VGA_EXT_CRTC_OFFSET + \
  590. EXT_NUM_CRTC_PORTS)
  591. #define VGA_EXT_ATTRIB_CONT_OFFSET (VGA_EXT_GRAPH_CONT_OFFSET +\
  592. EXT_NUM_GRAPH_CONT_PORTS)
  593. #define VGA_EXT_DAC_OFFSET (VGA_EXT_ATTRIB_CONT_OFFSET + \
  594. EXT_NUM_ATTRIB_CONT_PORTS)
  595. #define VGA_VALIDATOR_OFFSET (VGA_EXT_DAC_OFFSET + 4 * EXT_NUM_DAC_ENTRIES)
  596. #define VGA_VALIDATOR_AREA_SIZE sizeof (ULONG) + (VGA_MAX_VALIDATOR_DATA * \
  597. sizeof (VGA_VALIDATOR_DATA)) + \
  598. sizeof (ULONG) + \
  599. sizeof (ULONG) + \
  600. sizeof (PVIDEO_ACCESS_RANGE)
  601. #define VGA_MISC_DATA_AREA_OFFSET VGA_VALIDATOR_OFFSET + VGA_VALIDATOR_AREA_SIZE
  602. #define VGA_MISC_DATA_AREA_SIZE 0
  603. #define VGA_PLANE_0_OFFSET VGA_MISC_DATA_AREA_OFFSET + VGA_MISC_DATA_AREA_SIZE
  604. #define VGA_PLANE_1_OFFSET VGA_PLANE_0_OFFSET + VGA_PLANE_SIZE
  605. #define VGA_PLANE_2_OFFSET VGA_PLANE_1_OFFSET + VGA_PLANE_SIZE
  606. #define VGA_PLANE_3_OFFSET VGA_PLANE_2_OFFSET + VGA_PLANE_SIZE
  607. //
  608. // Space needed to store all state data.
  609. //
  610. #define VGA_TOTAL_STATE_SIZE VGA_PLANE_3_OFFSET + VGA_PLANE_SIZE
  611. //
  612. // Merge port and register access for VGA relocatable and MMIO registers
  613. //
  614. // sge03
  615. typedef VIDEOPORT_API UCHAR (*FnVideoPortReadPortUchar)(PUCHAR Port);
  616. typedef VIDEOPORT_API USHORT (*FnVideoPortReadPortUshort)(PUSHORT Port);
  617. typedef VIDEOPORT_API ULONG (*FnVideoPortReadPortUlong)(PULONG Port);
  618. typedef VIDEOPORT_API VOID (*FnVideoPortWritePortUchar)(PUCHAR Port, UCHAR Value);
  619. typedef VIDEOPORT_API VOID (*FnVideoPortWritePortUshort)(PUSHORT Port, USHORT Value);
  620. typedef VIDEOPORT_API VOID (*FnVideoPortWritePortUlong)(PULONG Port, ULONG Value);
  621. typedef struct _PORT_READ_WRITE_FUNTION_TABLE
  622. {
  623. FnVideoPortReadPortUchar pfnVideoPortReadPortUchar;
  624. FnVideoPortReadPortUshort pfnVideoPortReadPortUshort;
  625. FnVideoPortReadPortUlong pfnVideoPortReadPortUlong;
  626. FnVideoPortWritePortUchar pfnVideoPortWritePortUchar;
  627. FnVideoPortWritePortUshort pfnVideoPortWritePortUshort;
  628. FnVideoPortWritePortUlong pfnVideoPortWritePortUlong;
  629. } PORT_READ_WRITE_FUNTION_TABLE;
  630. //
  631. // Device extension for the driver object. This data is only used
  632. // locally, so this structure can be added to as needed.
  633. //
  634. typedef struct _HW_DEVICE_EXTENSION {
  635. PHYSICAL_ADDRESS PhysicalVideoMemoryBase; // physical memory address and
  636. PHYSICAL_ADDRESS PhysicalFrameOffset; // physical memory address and
  637. ULONG PhysicalVideoMemoryLength; // length of display memory
  638. ULONG PhysicalFrameLength; // length of display memory for
  639. // the current mode.
  640. PUCHAR IOAddress; // base I/O address of VGA ports
  641. PUCHAR VideoMemoryAddress; // base virtual memory address of VGA memory
  642. ULONG NumAvailableModes; // number of available modes this session
  643. ULONG ModeIndex; // index of current mode in ModesVGA[]
  644. PVIDEOMODE CurrentMode; // pointer to VIDEOMODE structure for
  645. // current mode
  646. USHORT FontPelColumns; // Width of the font in pels
  647. USHORT FontPelRows; // height of the font in pels
  648. USHORT cursor_vert_exp_flag;
  649. VIDEO_CURSOR_POSITION CursorPosition; // current cursor position
  650. UCHAR CursorEnable; // whether cursor is enabled or not
  651. UCHAR CursorTopScanLine; // Cursor Start register setting (top scan)
  652. UCHAR CursorBottomScanLine; // Cursor End register setting (bottom scan)
  653. // add HW cursor data here
  654. BOOLEAN VideoPointerEnabled; // Whether HW Cursor is supported
  655. ULONG ChipType; // CL6410, CL6420, CL542x, or CL543x
  656. //myf32 change USHORT to ULONG
  657. USHORT ChipRevision; // chip revision value
  658. INTERFACE_TYPE BusType; // isa, pci, etc.
  659. USHORT DisplayType; // crt, panel or panel8x6
  660. USHORT BoardType; // Diamond, etc ...
  661. WCHAR LegacyPnPId[8]; // legacy PnP ID
  662. ULONG AdapterMemorySize; // amount of installed video ram
  663. BOOLEAN LinearMode; // TRUE if memory is mapped linear
  664. BOOLEAN BiosGT130; // Do we have a 1.30 or higher bios
  665. BOOLEAN BIOSPresent; // Indicates whether a bios is present
  666. BOOLEAN AutoFeature; // Autostart on 54x6
  667. // crus
  668. BOOLEAN BitBLTEnhance; // BitBLT enhancement includes
  669. // XY-position, XY-clipping and
  670. // command list in off-screen memory
  671. // For CL-GD5480, it is TRUE,
  672. // otherwise, it is FALSE.
  673. //
  674. // The following two values are used to pass information to the
  675. // IO Callback called by IOWaitDisplEnableThenWrite.
  676. //
  677. ULONG DEPort; // stores the port address to write to
  678. UCHAR DEValue; // stores the value to write
  679. //
  680. // These 4 fields must be at the end of the device extension and must be
  681. // kept in this order since this data will be copied to and from the save
  682. // state buffer that is passed to and from the VDM.
  683. //
  684. ULONG TrappedValidatorCount; // number of entries in the Trapped
  685. // validator data Array.
  686. VGA_VALIDATOR_DATA TrappedValidatorData[VGA_MAX_VALIDATOR_DATA];
  687. // Data trapped by the validator routines
  688. // but not yet played back into the VGA
  689. // register.
  690. ULONG SequencerAddressValue; // Determines if the Sequencer Address Port
  691. // is currently selecting the SyncReset data
  692. // register.
  693. ULONG CurrentNumVdmAccessRanges; // Number of access ranges in
  694. // the access range array pointed
  695. // to by the next field
  696. PVIDEO_ACCESS_RANGE CurrentVdmAccessRange; // Access range currently
  697. // associated to the VDM
  698. // sge01 PC97 Compliant
  699. ULONG ulBIOSVersionNumber; // BIOS version number.
  700. BOOLEAN bMMAddress; // VGA register MMIO
  701. BOOLEAN bSecondAperture; // TRUE if chips have second apterture
  702. // else FALSE, sge02
  703. //crus, begin
  704. //myf12, for hoy-key support
  705. SHORT bBlockSwitch; //display switch block flag //myf12
  706. SHORT bDisplaytype; //display type, 0:LCD, 1:CRT, 2:SIM //myf12
  707. ULONG bCurrentMode; //Current Mode
  708. //crus end
  709. PORT_READ_WRITE_FUNTION_TABLE gPortRWfn;
  710. ULONG PMCapability;
  711. } HW_DEVICE_EXTENSION, *PHW_DEVICE_EXTENSION;
  712. //
  713. // Function prototypes.
  714. //
  715. //
  716. // Entry points for the VGA validator. Used in VgaEmulatorAccessEntries[].
  717. //
  718. VP_STATUS
  719. VgaValidatorUcharEntry (
  720. ULONG_PTR Context,
  721. ULONG Port,
  722. UCHAR AccessMode,
  723. PUCHAR Data
  724. );
  725. VP_STATUS
  726. VgaValidatorUshortEntry (
  727. ULONG_PTR Context,
  728. ULONG Port,
  729. UCHAR AccessMode,
  730. PUSHORT Data
  731. );
  732. VP_STATUS
  733. VgaValidatorUlongEntry (
  734. ULONG_PTR Context,
  735. ULONG Port,
  736. UCHAR AccessMode,
  737. PULONG Data
  738. );
  739. BOOLEAN
  740. VgaPlaybackValidatorData (
  741. PVOID Context
  742. );
  743. #ifdef _X86_
  744. //
  745. // Bank switch code start and end labels, defined in CLHARD.ASM
  746. //
  747. // three versions for Cirrus Logic products
  748. //
  749. extern UCHAR CL64xxBankSwitchStart;
  750. extern UCHAR CL64xxBankSwitchEnd;
  751. extern UCHAR CL64xxPlanarHCBankSwitchStart;
  752. extern UCHAR CL64xxPlanarHCBankSwitchEnd;
  753. extern UCHAR CL64xxEnablePlanarHCStart;
  754. extern UCHAR CL64xxEnablePlanarHCEnd;
  755. extern UCHAR CL64xxDisablePlanarHCStart;
  756. extern UCHAR CL64xxDisablePlanarHCEnd;
  757. extern UCHAR CL542xBankSwitchStart;
  758. extern UCHAR CL542xBankSwitchEnd;
  759. extern UCHAR CL542xPlanarHCBankSwitchStart;
  760. extern UCHAR CL542xPlanarHCBankSwitchEnd;
  761. extern UCHAR CL542xEnablePlanarHCStart;
  762. extern UCHAR CL542xEnablePlanarHCEnd;
  763. extern UCHAR CL542xDisablePlanarHCStart;
  764. extern UCHAR CL542xDisablePlanarHCEnd;
  765. extern UCHAR CL543xBankSwitchStart;
  766. extern UCHAR CL543xBankSwitchEnd;
  767. extern UCHAR CL543xPlanarHCBankSwitchStart;
  768. extern UCHAR CL543xPlanarHCBankSwitchEnd;
  769. #endif
  770. //
  771. // Vga init scripts for font loading
  772. //
  773. extern USHORT EnableA000Data[];
  774. extern USHORT DisableA000Color[];
  775. //
  776. // Mode Information
  777. //
  778. extern MEMORYMAPS MemoryMaps[];
  779. extern ULONG NumVideoModes;
  780. extern VIDEOMODE ModesVGA[];
  781. //crus, begin
  782. //myf1, begin
  783. #ifdef PANNING_SCROLL
  784. extern RESTABLE ResolutionTable[];
  785. extern PANNMODE PanningMode;
  786. extern USHORT ViewPoint_Mode;
  787. #endif
  788. extern SHORT Panning_flag;
  789. //myf1, end
  790. //crus, end
  791. #define NUM_VGA_ACCESS_RANGES 5
  792. extern VIDEO_ACCESS_RANGE VgaAccessRange[];
  793. #define VGA_NUM_EMULATOR_ACCESS_ENTRIES 6
  794. extern EMULATOR_ACCESS_ENTRY VgaEmulatorAccessEntries[];
  795. #define NUM_MINIMAL_VGA_VALIDATOR_ACCESS_RANGE 4
  796. extern VIDEO_ACCESS_RANGE MinimalVgaValidatorAccessRange[];
  797. #define NUM_FULL_VGA_VALIDATOR_ACCESS_RANGE 2
  798. extern VIDEO_ACCESS_RANGE FullVgaValidatorAccessRange[];
  799. //
  800. // sr754x (NORDIC) prototypes
  801. //
  802. VP_STATUS
  803. NordicSaveRegs(
  804. PHW_DEVICE_EXTENSION HwDeviceExtension,
  805. PUSHORT NordicSaveArea
  806. );
  807. VP_STATUS
  808. NordicRestoreRegs(
  809. PHW_DEVICE_EXTENSION HwDeviceExtension,
  810. PUSHORT NordicSaveArea
  811. );
  812. #define VideoPortReadPortUchar(Port) HwDeviceExtension->gPortRWfn.pfnVideoPortReadPortUchar(Port)
  813. #define VideoPortReadPortUshort(Port) HwDeviceExtension->gPortRWfn.pfnVideoPortReadPortUshort(Port)
  814. #define VideoPortReadPortUlong(Port) HwDeviceExtension->gPortRWfn.pfnVideoPortReadPortUlong(Port)
  815. #define VideoPortWritePortUchar(Port, Value) HwDeviceExtension->gPortRWfn.pfnVideoPortWritePortUchar(Port, Value)
  816. #define VideoPortWritePortUshort(Port, Value) HwDeviceExtension->gPortRWfn.pfnVideoPortWritePortUshort(Port, Value)
  817. #define VideoPortWritePortUlong(Port, Value) HwDeviceExtension->gPortRWfn.pfnVideoPortWritePortUlong(Port, Value)
  818. typedef struct _PGAMMA_VALUE // chu02
  819. {
  820. UCHAR value[4] ;
  821. } GAMMA_VALUE, *PGAMMA_VALUE, *PCONTRAST_VALUE ;
  822. ULONG
  823. GetAttributeFlags(
  824. PHW_DEVICE_EXTENSION HwDeviceExtension
  825. );
  826. typedef struct _POEMMODE_EXCLUDE // chu03
  827. {
  828. UCHAR mode ;
  829. UCHAR refresh ;
  830. BOOLEAN NeverAccessed ;
  831. } OEMMODE_EXCLUDE, *PMODE_EXCLUDE ;
  832. //
  833. // New NT 5.0 Functions
  834. //
  835. ULONG
  836. CirrusGetChildDescriptor(
  837. PVOID pHwDeviceExtension,
  838. PVIDEO_CHILD_ENUM_INFO ChildEnumInfo,
  839. PVIDEO_CHILD_TYPE pChildType,
  840. PVOID pvChildDescriptor,
  841. PULONG pHwId,
  842. PULONG pUnused
  843. );
  844. VP_STATUS
  845. CirrusGetPowerState(
  846. PHW_DEVICE_EXTENSION HwDeviceExtension,
  847. ULONG HwDeviceId,
  848. PVIDEO_POWER_MANAGEMENT VideoPowerManagement
  849. );
  850. VP_STATUS
  851. CirrusSetPowerState(
  852. PHW_DEVICE_EXTENSION HwDeviceExtension,
  853. ULONG HwDeviceId,
  854. PVIDEO_POWER_MANAGEMENT VideoPowerManagement
  855. );
  856. #define VESA_POWER_FUNCTION 0x4f10
  857. #define VESA_POWER_ON 0x0000
  858. #define VESA_POWER_STANDBY 0x0100
  859. #define VESA_POWER_SUSPEND 0x0200
  860. #define VESA_POWER_OFF 0x0400
  861. #define VESA_GET_POWER_FUNC 0x0000
  862. #define VESA_SET_POWER_FUNC 0x0001
  863. #define VESA_STATUS_SUCCESS 0x004f