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.

1635 lines
64 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: hw.h
  3. *
  4. * All the hardware specific driver file stuff. Parts are mirrored in
  5. * 'hw.inc'.
  6. *
  7. * Copyright (c) 1992-1996 Microsoft Corporation
  8. * Copyright (c) 1993-1996 Matrox Electronic Systems, Ltd.
  9. \**************************************************************************/
  10. // The following is used to define the MGA memory map.
  11. // MGA map
  12. #define SrcWin 0x0000
  13. #define IntReg 0x1c00
  14. #define DstWin 0x2000
  15. #define ExtDev 0x3c00
  16. // Internal registers
  17. #define VgaReg 0x0000
  18. #define DwgReg 0x0000
  19. #define StartDwgReg 0x0100
  20. #define HstReg 0x0200
  21. // External devices
  22. #define RamDac 0x0000
  23. #define Dubic 0x0080
  24. #define Viwic 0x0100
  25. #define ClkGen 0x0180
  26. #define ExpDev 0x0200
  27. // TITAN registers
  28. #define DWGCTL 0x0000
  29. #define MACCESS 0x0004
  30. #define MCTLWTST 0x0008
  31. #define ZORG 0x000C
  32. #define DST0 0x0010
  33. #define DST1 0x0014
  34. #define ZMSK 0x0018
  35. #define PLNWT 0x001C
  36. #define BCOL 0x0020
  37. #define FCOL 0x0024
  38. #define SRCBLT 0x002C
  39. #define SRC0 0x0030
  40. #define SRC1 0x0034
  41. #define SRC2 0x0038
  42. #define SRC3 0x003C
  43. #define XYSTRT 0x0040
  44. #define XYEND 0x0044
  45. #define SHIFT 0x0050
  46. #define SGN 0x0058
  47. #define LEN 0x005C
  48. #define AR0 0x0060
  49. #define AR1 0x0064
  50. #define AR2 0x0068
  51. #define AR3 0x006C
  52. #define AR4 0x0070
  53. #define AR5 0x0074
  54. #define AR6 0x0078
  55. #define CXBNDRY 0x0080
  56. #define FXBNDRY 0x0084
  57. #define YDSTLEN 0x0088
  58. #define PITCH 0x008C
  59. #define YDST 0x0090
  60. #define YDSTORG 0x0094
  61. #define CYTOP 0x0098
  62. #define CYBOT 0x009C
  63. #define CXLEFT 0x00A0
  64. #define CXRIGHT 0x00A4
  65. #define FXLEFT 0x00A8
  66. #define FXRIGHT 0x00AC
  67. #define XDST 0x00B0
  68. #define DR0 0x00C0
  69. #define DR1 0x00C4
  70. #define DR2 0x00C8
  71. #define DR3 0x00CC
  72. #define DR4 0x00D0
  73. #define DR5 0x00D4
  74. #define DR6 0x00D8
  75. #define DR7 0x00DC
  76. #define DR8 0x00E0
  77. #define DR9 0x00E4
  78. #define DR10 0x00E8
  79. #define DR11 0x00EC
  80. #define DR12 0x00F0
  81. #define DR13 0x00F4
  82. #define DR14 0x00F8
  83. #define DR15 0x00FC
  84. // VGA registers
  85. #define CRTC_INDEX 0x03D4
  86. #define CRTC_DATA 0x03D5
  87. #define CRTCEXT_INDEX 0x03DE
  88. #define CRTCEXT_DATA 0x03DF
  89. #define INSTS1 0x03DA
  90. // Host registers
  91. #define SRCPAGE 0x0000
  92. #define DSTPAGE 0x0004
  93. #define BYTACCDATA 0x0008
  94. #define ADRGEN 0x000C
  95. #define FIFOSTATUS 0x0010
  96. #define STATUS 0x0014
  97. #define ICLEAR 0x0018
  98. #define IEN 0x001C
  99. #define RST 0x0040
  100. #define TEST 0x0044
  101. #define REV 0x0048
  102. #define CONFIG_REG 0x0050
  103. #define OPMODE 0x0054
  104. #define CRTC_CTRL 0x005C
  105. #define VCOUNT 0x0020
  106. // Bt485
  107. #define BT485_PAL_OR_CURS_RAM_WRITE 0x0000
  108. #define BT485_COLOR_PAL_DATA 0x0004
  109. #define BT485_PIXEL_MASK 0x0008
  110. #define BT485_PAL_OR_CURS_RAM_READ 0x000C
  111. #define BT485_OVS_OR_CURS_COLOR_WRITE 0x0010
  112. #define BT485_OVS_OR_CURS_COLOR_DATA 0x0014
  113. #define BT485_COMMAND_0 0x0018
  114. #define BT485_OVS_OR_CURS_COLOR_READ 0x001C
  115. #define BT485_COMMAND_1 0x0020
  116. #define BT485_COMMAND_2 0x0024
  117. #define BT485_COMMAND_3_OR_STATUS 0x0028
  118. #define BT485_CURS_RAM_ARRAY 0x002C
  119. #define BT485_CURS_X_LOW 0x0030
  120. #define BT485_CURS_X_HIGH 0x0034
  121. #define BT485_CURS_Y_LOW 0x0038
  122. #define BT485_CURS_Y_HIGH 0x003C
  123. // Bt482
  124. #define BT482_PAL_OR_CURS_RAM_WRITE 0x0000
  125. #define BT482_COLOR_PAL_DATA 0x0004
  126. #define BT482_PIXEL_MASK 0x0008
  127. #define BT482_PAL_OR_CURS_RAM_READ 0x000C
  128. #define BT482_OVS_OR_CURS_COLOR_WRITE 0x0010
  129. #define BT482_OVS_OR_CURS_COLOR_DATA 0x0014
  130. #define BT482_COMMAND_A 0x0018
  131. #define BT482_OVS_OR_CURS_COLOR_READ 0x001C
  132. // ViewPoint
  133. #define VPOINT_PAL_ADDR_WRITE 0x0000
  134. #define VPOINT_PAL_COLOR 0x0004
  135. #define VPOINT_PIX_READ_MASK 0x0008
  136. #define VPOINT_PAL_ADDR_READ 0x000c
  137. #define VPOINT_RESERVED_4 0x0010
  138. #define VPOINT_RESERVED_5 0x0014
  139. #define VPOINT_INDEX 0x0018
  140. #define VPOINT_DATA 0x001c
  141. // Dubic
  142. #define DUB_SEL 0x0080
  143. #define NDX_PTR 0x0081
  144. #define DUB_DATA 0x0082
  145. #define LASER 0x0083
  146. #define MOUSE0 0x0084
  147. #define MOUSE1 0x0085
  148. #define MOUSE2 0x0086
  149. #define MOUSE3 0x0087
  150. // Index within NDX_PTR to access the following registers through DUB_DATA
  151. #define DUB_CTL 0x00
  152. #define KEY_COL 0x01
  153. #define KEY_MSK 0x02
  154. #define DBX_MIN 0x03
  155. #define DBX_MAX 0x04
  156. #define DBY_MIN 0x05
  157. #define DBY_MAX 0x06
  158. #define OVS_COL 0x07
  159. #define CUR_X 0x08
  160. #define CUR_Y 0x09
  161. #define DUB_CTL2 0x0A
  162. #define DUB_UnDef 0x0B
  163. #define CUR_COL0 0x0C
  164. #define CUR_COL1 0x0D
  165. #define CRC_CTL 0x0E
  166. #define CRC_DAT 0x0F
  167. // **************************************************************************
  168. // Titan registers: fields definitions
  169. // DWGCTRL - Drawing Control Register
  170. #define opcode_LINE_OPEN 0x00000000
  171. #define opcode_AUTOLINE_OPEN 0x00000001
  172. #define opcode_LINE_CLOSE 0x00000002
  173. #define opcode_AUTOLINE_CLOSE 0x00000003
  174. #define opcode_AUTO 0x00000001
  175. #define opcode_TRAP 0x00000004
  176. #define opcode_TEXTURE_TRAP 0x00000005
  177. #define opcode_RESERVED_1 0x00000006
  178. #define opcode_RESERVED_2 0x00000007
  179. #define opcode_BITBLT 0x00000008
  180. #define opcode_ILOAD 0x00000009
  181. #define opcode_IDUMP 0x0000000a
  182. #define opcode_RESERVED_3 0x0000000b
  183. #define opcode_FBITBLT 0x0000000c
  184. #define opcode_ILOAD_SCALE 0x0000000d
  185. #define opcode_RESERVED_4 0x0000000e
  186. #define opcode_ILOAD_FILTER 0x0000000f
  187. #define atype_RPL 0x00000000
  188. #define atype_RSTR 0x00000010
  189. #define atype_ANTI 0x00000020
  190. #define atype_ZI 0x00000030
  191. #define atype_I 0x00000070
  192. #define blockm_ON 0x00000040
  193. #define blockm_OFF 0x00000000
  194. #define linear_XY_BITBLT 0x00000000
  195. #define linear_LINEAR_BITBLT 0x00000080
  196. #define zmode_NOZCMP 0x00000000
  197. #define zmode_RESERVED_1 0x00000100
  198. #define zmode_ZE 0x00000200
  199. #define zmode_ZNE 0x00000300
  200. #define zmode_ZLT 0x00000400
  201. #define zmode_ZLTE 0x00000500
  202. #define zmode_ZGT 0x00000600
  203. #define zmode_ZGTE 0x00000700
  204. #define solid_NO_SOLID 0x00000000
  205. #define solid_SOLID 0x00000800
  206. #define arzero_NO_ZERO 0x00000000
  207. #define arzero_ZERO 0x00001000
  208. #define sgnzero_NO_ZERO 0x00000000
  209. #define sgnzero_ZERO 0x00002000
  210. #define shftzero_NO_ZERO 0x00000000
  211. #define shftzero_ZERO 0x00004000
  212. #define bop_BLACK 0x00000000 // 0 0
  213. #define bop_BLACKNESS 0x00000000 // 0 0
  214. #define bop_NOTMERGEPEN 0x00010000 // DPon ~(D | S)
  215. #define bop_MASKNOTPEN 0x00020000 // DPna D & ~S
  216. #define bop_NOTCOPYPEN 0x00030000 // Pn ~S
  217. #define bop_MASKPENNOT 0x00040000 // PDna (~D) & S
  218. #define bop_NOT 0x00050000 // Dn ~D
  219. #define bop_XORPEN 0x00060000 // DPx D ^ S
  220. #define bop_NOTMASKPEN 0x00070000 // DPan ~(D & S)
  221. #define bop_MASKPEN 0x00080000 // DPa D & S
  222. #define bop_NOTXORPEN 0x00090000 // DPxn ~(D ^ S)
  223. #define bop_NOP 0x000a0000 // D D
  224. #define bop_MERGENOTPEN 0x000b0000 // DPno D | ~S
  225. #define bop_COPYPEN 0x000c0000 // P S
  226. #define bop_SRCCOPY 0x000c0000 // P S
  227. #define bop_MERGEPENNOT 0x000d0000 // PDno (~D)| S
  228. #define bop_MERGEPEN 0x000e0000 // DPo D | S
  229. #define bop_MASK 0x000f0000
  230. #define bop_WHITE 0x000f0000 // 1 1
  231. #define bop_WHITENESS 0x000f0000 // 1 1
  232. #define trans_0 0x00000000
  233. #define trans_1 0x00100000
  234. #define trans_2 0x00200000
  235. #define trans_3 0x00300000
  236. #define trans_4 0x00400000
  237. #define trans_5 0x00500000
  238. #define trans_6 0x00600000
  239. #define trans_7 0x00700000
  240. #define trans_8 0x00800000
  241. #define trans_9 0x00900000
  242. #define trans_10 0x00a00000
  243. #define trans_11 0x00b00000
  244. #define trans_12 0x00c00000
  245. #define trans_13 0x00d00000
  246. #define trans_14 0x00e00000
  247. #define trans_15 0x00f00000
  248. #define alphadit_FOREGROUND 0x00000000
  249. #define alphadit_RED 0x01000000
  250. #define bltmod_BMONO 0x00000000
  251. #define bltmod_BPLAN 0x02000000
  252. #define bltmod_BFCOL 0x04000000
  253. #define bltmod_BUCOL 0x06000000
  254. #define bltmod_BU32BGR 0x06000000
  255. #define bltmod_BMONOWF 0x08000000
  256. #define bltmod_BU32RGB 0x0e000000
  257. #define bltmod_BU24BGR 0x16000000
  258. #define bltmod_BU24RGB 0x1e000000
  259. #define bltmod_BUYUV 0x1c000000
  260. #define zdrwen_NO_DEPTH 0x00000000
  261. #define zdrwen_DEPTH 0x02000000
  262. #define zlte_LESS_THEN 0x00000000
  263. #define zlte_LESS_THEN_OR_EQUAL 0x04000000
  264. #define afor_DATA_ALU 0x00000000
  265. #define afor_FORE_COL 0x08000000
  266. #define hbgr_SRC_RGB 0x00000000
  267. #define hbgr_SRC_BGR 0x08000000
  268. #define hbgr_SRC_EG3 0x00000000
  269. #define hbgr_SRC_WINDOWS 0x08000000
  270. #define abac_OLD_DATA 0x00000000
  271. #define abac_BG_COLOR 0x10000000
  272. #define hcprs_SRC_32_BPP 0x00000000
  273. #define hcprs_SRC_24_BPP 0x10000000
  274. #define pattern_OFF 0x00000000
  275. #define pattern_ON 0x20000000
  276. #define transc_BIT 30 // bit #30
  277. #define transc_BG_OPAQUE 0x00000000
  278. #define transc_BG_TRANSP 0x40000000
  279. // MACCESS - Memory Access Register
  280. #define pwidth_PW8 0x00000000
  281. #define pwidth_PW16 0x00000001
  282. #define pwidth_PW32 0x00000002
  283. #define pwidth_PW24 0x00000003
  284. #define dither_DISABLE 0x40000000
  285. #define dither_555 0x80000000
  286. #define dither_565 0x00000000
  287. #define fbc_SBUF 0x00000000
  288. #define fbc_RESERVED 0x00000004
  289. #define fbc_DBUFA 0x00000008
  290. #define fbc_DBUFB 0x0000000c
  291. // MCTLWTST - Memory Control Wait State Register
  292. // DST0, DST1 - Destination in Register
  293. // ZMASK - Z Mask Control Register
  294. // PLNWT - Plane Write Mask
  295. #define plnwt_MASK_8BPP 0xffffffff
  296. #define plnwt_MASK_15BPP 0x7fff7fff
  297. #define plnwt_MASK_16BPP 0xffffffff
  298. #define plnwt_MASK_24BPP 0xffffffff
  299. #define plnwt_MASK_32BPP 0xffffffff
  300. #define plnwt_ALL 0xffffffff
  301. #define plnwt_FREE 0xff000000
  302. #define plnwt_RED 0x00ff0000
  303. #define plnwt_GREEN 0x0000ff00
  304. #define plnwt_BLUE 0x000000ff
  305. // BCOL - Background Color
  306. // FCOL - ForeGround Color
  307. // SRCBLT - Source Register for Blit
  308. // SRC0, SRC1, SRC2, SRC3 - Source Register
  309. // XYSTART - X Y Start Address
  310. // XYEND - X Y End Address
  311. // SHIFT - Funnel Shifter Control Register
  312. #define funoff_MASK 0xffc0ffff
  313. #define funoff_RED_TO_FREE 0x00380000 // -8
  314. #define funoff_GREEN_TO_FREE 0x00300000 // -16
  315. #define funoff_BLUE_TO_FREE 0x00280000 // -24
  316. #define funoff_FREE_TO_RED 0x00080000 // 8
  317. #define funoff_FREE_TO_GREEN 0x00100000 // 16
  318. #define funoff_FREE_TO_BLUE 0x00180000 // 24
  319. #define funoff_X_TO_FREE_STEP 0x00080000
  320. #define funoff_FREE_TO_X_STEP 0x00080000
  321. // SGN - Sign Register
  322. #define sdydxl_MAJOR_Y 0x00000000
  323. #define sdydxl_MAJOR_X 0x00000001
  324. #define scanleft_LEFT 0x00000001
  325. #define scanleft_RIGHT 0x00000000
  326. #define sdxl_ADD 0x00000000
  327. #define sdxl_SUB 0x00000002
  328. #define sdy_ADD 0x00000000
  329. #define sdy_SUB 0x00000004
  330. #define sdxr_INC 0x00000000
  331. #define sdxr_DEC 0x00000020
  332. #define scanleft_LEFT_TO_RIGHT 0x00000000
  333. #define scanleft_RIGHT_TO_LEFT 0x00000001
  334. #define sdy_TOP_TO_BOTTOM 0x00000000
  335. #define sdy_BOTTOM_TO_TOP 0x00000004
  336. #define DRAWING_DIR_TBLR sdy_TOP_TO_BOTTOM+scanleft_RIGHT // 0x00
  337. #define DRAWING_DIR_TBRL sdy_TOP_TO_BOTTOM+scanleft_LEFT // 0x01
  338. #define DRAWING_DIR_BTLR sdy_BOTTOM_TO_TOP+scanleft_RIGHT // 0x04
  339. #define DRAWING_DIR_BTRL sdy_BOTTOM_TO_TOP+scanleft_LEFT // 0x05
  340. // LEN - length register
  341. // AR0
  342. #define ARX_BIT_MASK 0x0001ffff
  343. // AR1
  344. // AR2
  345. // AR3
  346. // AR4
  347. // AR5
  348. // AR6
  349. // CXBNDRY
  350. #define bcxleft_MASK 0x000007ff
  351. #define bcxleft_SHIFT 0
  352. #define bcxright_MASK 0x07ff0000
  353. #define bcxright_SHIFT 16
  354. // FXBNDRY
  355. #define bfxleft_MASK 0x0000ffff
  356. #define bfxleft_SHIFT 0
  357. #define bfxright_MASK 0xffff0000
  358. #define bfxright_SHIFT 16
  359. // YDSTLEN
  360. #define ylength_MASK 0x0000ffff
  361. #define ylength_SHIFT 0
  362. #define yval_MASK 0xffff0000
  363. #define yval_SHIFT 16
  364. // PITCH - Memory Pitch
  365. #define iy_512 0x00000200
  366. #define iy_640 0x00000280
  367. #define iy_768 0x00000300
  368. #define iy_800 0x00000320
  369. #define iy_1024 0x00000400
  370. #define iy_1152 0x00000480
  371. #define iy_1280 0x00000500
  372. #define iy_1536 0x00000600
  373. #define iy_1600 0x00000640
  374. #define ylin_LINEARIZE 0x00000000
  375. #define ylin_LINEARIZE_NOT 0x00008000
  376. #define iy_MASK 0x00001fe0
  377. // YDST - Y Address Register
  378. // YDSTORG - memory origin register
  379. // YTOP - Clipper Y Top Boundary
  380. // YBOT - Clipper Y Bottom Boundary
  381. // CXLEFT - Clipper X Minimum Boundary
  382. // CXRIGHT - Clipper X Maximum Boundary
  383. // FXLEFT - X Address Register (Left)
  384. // FXRIGHT - X Address Register (Right)
  385. // XDST - X Destination Address Register
  386. // DR0
  387. // DR1
  388. // DR2
  389. // DR3
  390. // DR4
  391. // DR5
  392. // DR6
  393. // DR7
  394. // DR8
  395. // DR9
  396. // DR10
  397. // DR11
  398. // DR12
  399. // DR13
  400. // DR14
  401. // DR15
  402. // **************************************************************************
  403. // Host registers: fields definitions
  404. // SRCPAGE - Source Page Register
  405. // DSTPAGE - Destination Page Register
  406. // BYTEACCDATA - Byte Accumulator Data
  407. // ADRGEN - Address Generator Register
  408. // FIFOSTATUS - Bus FIFO Status Register
  409. #define fifocount_MASK 0x0000007f
  410. #define bfull_MASK 0x00000100
  411. #define bempty_MASK 0x00000200
  412. #define byteaccaddr_MASK 0x007f0000
  413. #define addrgenstate_MASK 0x3f000000
  414. // STATUS - Status Register
  415. #define bferrists_MASK 0x00000001
  416. #define dmatcists_MASK 0x00000002
  417. #define pickists_MASK 0x00000004
  418. #define vsyncsts_MASK 0x00000008
  419. #define byteflag_MASK 0x00000f00
  420. #define dwgengsts_MASK 0x00010000
  421. // ICLEAR - Interrupt Clear Register
  422. #define bferriclr_OFF 0x00000000
  423. #define bferriclr_ON 0x00000001
  424. #define dmactciclr_OFF 0x00000000
  425. #define dmactciclr_ON 0x00000002
  426. #define pickiclr_OFF 0x00000000
  427. #define pickiclr_ON 0x00000004
  428. // IEN - Interrupt Enable Register
  429. #define bferrien_OFF 0x00000000
  430. #define bferrien_ON 0x00000001
  431. #define dmactien_OFF 0x00000000
  432. #define dmactien_ON 0x00000002
  433. #define pickien_OFF 0x00000000
  434. #define pickien_ON 0x00000004
  435. #define vsyncien_OFF 0x00000000
  436. #define vsyncien_ON 0x00000008
  437. // RST - Reset Register
  438. #define softreset 0x00000001
  439. // TEST - Test Register
  440. #define vgatest 0x00000001
  441. #define robitwren 0x00000100
  442. // REV - Revision Register
  443. // CONFIG_REG - Configuration Register
  444. // OPMODE - Operating Mode Register
  445. #define OPMODE_OTHER_INFO 0xfffffff0
  446. #define pseudodma_OFF 0x00000000
  447. #define pseudodma_ON 0x00000001
  448. #define dmaact_OFF 0x00000000
  449. #define dmaact_ON 0x00000002
  450. #define dmamod_GENERAL_PURPOSE 0x00000000
  451. #define dmamod_BLIT_WRITE 0x00000004
  452. #define dmamod_VECTOR_WRITE 0x00000008
  453. #define dmamod_BLIT_READ 0x0000000c
  454. // CRTC_CTRL - CRTC Control
  455. // VCOUNT - VCOUNT Register
  456. // COLOR PATTERN
  457. #define PATTERN_PITCH 32
  458. #define PATTERN_PITCH_SHIFT 5
  459. // DMA
  460. #define DMAWINSIZE 7*1024 / 4 // 7k in DWORDS
  461. // FIFO
  462. #define FIFOSIZE 32
  463. #define INTEL_PAGESIZE 4*1024 // 4k bytes per page
  464. #define INTEL_PAGESIZE_DW 4*1024/4 // 1k dwords per page
  465. // Accelerator flags
  466. #define NO_CACHE 0
  467. #define SIGN_CACHE 1 // 1 is also the nb of registers affected
  468. #define ARX_CACHE 2
  469. #define PATTERN_CACHE 4 // 4 is also the nb of registers affected
  470. #define GET_CACHE_FLAGS(ppdev,fl) (ppdev->HopeFlags & (fl))
  471. // MGA Rop definitions
  472. #define MGA_BLACKNESS 0x0000 // 0 0
  473. #define MGA_NOTMERGEPEN 0x0001 // DPon ~(D | S)
  474. #define MGA_MASKNOTPEN 0x0002 // DPna D & ~S
  475. #define MGA_NOTCOPYPEN 0x0003 // Pn ~S
  476. #define MGA_MASKPENNOT 0x0004 // PDna (~D) & S
  477. #define MGA_NOT 0x0005 // Dn ~D
  478. #define MGA_XORPEN 0x0006 // DPx D ^ S
  479. #define MGA_NOTMASKPEN 0x0007 // DPan ~(D & S)
  480. #define MGA_MASKPEN 0x0008 // DPa D & S
  481. #define MGA_NOTXORPEN 0x0009 // DPxn ~(D ^ S)
  482. #define MGA_NOP 0x000a // D D
  483. #define MGA_MERGENOTPEN 0x000b // DPno D | ~S
  484. #define MGA_SRCCOPY 0x000c // P S
  485. #define MGA_MERGEPENNOT 0x000d // PDno (~D)| S
  486. #define MGA_MERGEPEN 0x000e // DPo D | S
  487. #define MGA_WHITENESS 0x000f // 1 1
  488. // Special MCTLWTST value for IDUMPs
  489. #define IDUMP_MCTLWTST 0xc4001000
  490. // **************************************************************************
  491. // Explicit register offsets.
  492. #define DMAWND SrcWin
  493. #define SRCWND SrcWin
  494. #define DSTWND DstWin
  495. #define DWG_DWGCTL IntReg+DwgReg+DWGCTL
  496. #define DWG_MACCESS IntReg+DwgReg+MACCESS
  497. #define DWG_MCTLWTST IntReg+DwgReg+MCTLWTST
  498. #define DWG_ZORG IntReg+DwgReg+ZORG
  499. #define DWG_DST0 IntReg+DwgReg+DST0
  500. #define DWG_DST1 IntReg+DwgReg+DST1
  501. #define DWG_ZMSK IntReg+DwgReg+ZMSK
  502. #define DWG_PLNWT IntReg+DwgReg+PLNWT
  503. #define DWG_BCOL IntReg+DwgReg+BCOL
  504. #define DWG_FCOL IntReg+DwgReg+FCOL
  505. #define DWG_SRCBLT IntReg+DwgReg+SRCBLT
  506. #define DWG_SRC0 IntReg+DwgReg+SRC0
  507. #define DWG_SRC1 IntReg+DwgReg+SRC1
  508. #define DWG_SRC2 IntReg+DwgReg+SRC2
  509. #define DWG_SRC3 IntReg+DwgReg+SRC3
  510. #define DWG_XYSTRT IntReg+DwgReg+XYSTRT
  511. #define DWG_XYEND IntReg+DwgReg+XYEND
  512. #define DWG_SHIFT IntReg+DwgReg+SHIFT
  513. #define DWG_SGN IntReg+DwgReg+SGN
  514. #define DWG_LEN IntReg+DwgReg+LEN
  515. #define DWG_AR0 IntReg+DwgReg+AR0
  516. #define DWG_AR1 IntReg+DwgReg+AR1
  517. #define DWG_AR2 IntReg+DwgReg+AR2
  518. #define DWG_AR3 IntReg+DwgReg+AR3
  519. #define DWG_AR4 IntReg+DwgReg+AR4
  520. #define DWG_AR5 IntReg+DwgReg+AR5
  521. #define DWG_AR6 IntReg+DwgReg+AR6
  522. #define DWG_PITCH IntReg+DwgReg+PITCH
  523. #define DWG_YDST IntReg+DwgReg+YDST
  524. #define DWG_YDSTLEN IntReg+DwgReg+YDSTLEN
  525. #define DWG_YDSTORG IntReg+DwgReg+YDSTORG
  526. #define DWG_CYTOP IntReg+DwgReg+CYTOP
  527. #define DWG_CYBOT IntReg+DwgReg+CYBOT
  528. #define DWG_CXBNDRY IntReg+DwgReg+CXBNDRY
  529. #define DWG_CXLEFT IntReg+DwgReg+CXLEFT
  530. #define DWG_CXRIGHT IntReg+DwgReg+CXRIGHT
  531. #define DWG_FXBNDRY IntReg+DwgReg+FXBNDRY
  532. #define DWG_FXLEFT IntReg+DwgReg+FXLEFT
  533. #define DWG_FXRIGHT IntReg+DwgReg+FXRIGHT
  534. #define DWG_XDST IntReg+DwgReg+XDST
  535. #define DWG_DR0 IntReg+DwgReg+DR0
  536. #define DWG_DR1 IntReg+DwgReg+DR1
  537. #define DWG_DR2 IntReg+DwgReg+DR2
  538. #define DWG_DR3 IntReg+DwgReg+DR3
  539. #define DWG_DR4 IntReg+DwgReg+DR4
  540. #define DWG_DR5 IntReg+DwgReg+DR5
  541. #define DWG_DR6 IntReg+DwgReg+DR6
  542. #define DWG_DR7 IntReg+DwgReg+DR7
  543. #define DWG_DR8 IntReg+DwgReg+DR8
  544. #define DWG_DR9 IntReg+DwgReg+DR9
  545. #define DWG_DR10 IntReg+DwgReg+DR10
  546. #define DWG_DR11 IntReg+DwgReg+DR11
  547. #define DWG_DR12 IntReg+DwgReg+DR12
  548. #define DWG_DR13 IntReg+DwgReg+DR13
  549. #define DWG_DR14 IntReg+DwgReg+DR14
  550. #define DWG_DR15 IntReg+DwgReg+DR15
  551. #define HST_SRCPAGE IntReg+HstReg+SRCPAGE
  552. #define HST_DSTPAGE IntReg+HstReg+DSTPAGE
  553. #define HST_BYTACCDATA IntReg+HstReg+BYTACCDATA
  554. #define HST_ADRGEN IntReg+HstReg+ADRGEN
  555. #define HST_FIFOSTATUS IntReg+HstReg+FIFOSTATUS
  556. #define HST_STATUS IntReg+HstReg+STATUS
  557. #define HST_ICLEAR IntReg+HstReg+ICLEAR
  558. #define HST_IEN IntReg+HstReg+IEN
  559. #define HST_RST IntReg+HstReg+RST
  560. #define HST_TEST IntReg+HstReg+TEST
  561. #define HST_REV IntReg+HstReg+REV
  562. #define HST_CONFIG_REG IntReg+HstReg+CONFIG_REG
  563. #define HST_OPMODE IntReg+HstReg+OPMODE
  564. #define HST_CRTC_CTRL IntReg+HstReg+CRTC_CTRL
  565. #define HST_VCOUNT IntReg+HstReg+VCOUNT
  566. #define VGA_CRTC_INDEX IntReg+VgaReg+CRTC_INDEX
  567. #define VGA_CRTC_DATA IntReg+VgaReg+CRTC_DATA
  568. #define VGA_CRTCEXT_INDEX IntReg+VgaReg+CRTCEXT_INDEX
  569. #define VGA_CRTCEXT_DATA IntReg+VgaReg+CRTCEXT_DATA
  570. #define VGA_INSTS1 IntReg+VgaReg+INSTS1
  571. #define BT485_PALETTE_RAM_WRITE ExtDev+RamDac+BT485_PAL_OR_CURS_RAM_WRITE
  572. #define BT485_CURSOR_RAM_WRITE ExtDev+RamDac+BT485_PAL_OR_CURS_RAM_WRITE
  573. #define BT485_PALETTE_DATA ExtDev+RamDac+BT485_COLOR_PAL_DATA
  574. #define BT485_PEL_MASK ExtDev+RamDac+BT485_PIXEL_MASK
  575. #define BT485_PALETTE_RAM_READ ExtDev+RamDac+BT485_PAL_OR_CURS_RAM_READ
  576. #define BT485_CURSOR_RAM_READ ExtDev+RamDac+BT485_PAL_OR_CURS_RAM_READ
  577. #define BT485_CURSOR_COLOR_WRITE ExtDev+RamDac+BT485_OVS_OR_CURS_COLOR_WRITE
  578. #define BT485_OVSCAN_COLOR_WRITE ExtDev+RamDac+BT485_OVS_OR_CURS_COLOR_WRITE
  579. #define BT485_CURSOR_COLOR_DATA ExtDev+RamDac+BT485_OVS_OR_CURS_COLOR_DATA
  580. #define BT485_OVSCAN_COLOR_DATA ExtDev+RamDac+BT485_OVS_OR_CURS_COLOR_DATA
  581. #define BT485_COMMAND_REG0 ExtDev+RamDac+BT485_COMMAND_0
  582. #define BT485_CURSOR_COLOR_READ ExtDev+RamDac+BT485_OVS_OR_CURS_COLOR_READ
  583. #define BT485_OVSCAN_COLOR_READ ExtDev+RamDac+BT485_OVS_OR_CURS_COLOR_READ
  584. #define BT485_COMMAND_REG1 ExtDev+RamDac+BT485_COMMAND_1
  585. #define BT485_COMMAND_REG2 ExtDev+RamDac+BT485_COMMAND_2
  586. #define BT485_COMMAND_REG3 ExtDev+RamDac+BT485_COMMAND_3_OR_STATUS
  587. #define BT485_STATUS ExtDev+RamDac+BT485_COMMAND_3_OR_STATUS
  588. #define BT485_CURSOR_RAM_DATA ExtDev+RamDac+BT485_CURS_RAM_ARRAY
  589. #define BT485_CURSOR_X_LOW ExtDev+RamDac+BT485_CURS_X_LOW
  590. #define BT485_CURSOR_X_HIGH ExtDev+RamDac+BT485_CURS_X_HIGH
  591. #define BT485_CURSOR_Y_LOW ExtDev+RamDac+BT485_CURS_Y_LOW
  592. #define BT485_CURSOR_Y_HIGH ExtDev+RamDac+BT485_CURS_Y_HIGH
  593. #define BT482_PALETTE_RAM_WRITE ExtDev+RamDac+BT482_PAL_OR_CURS_RAM_WRITE
  594. #define BT482_CURSOR_RAM_WRITE ExtDev+RamDac+BT482_PAL_OR_CURS_RAM_WRITE
  595. #define BT482_PALETTE_DATA ExtDev+RamDac+BT482_COLOR_PAL_DATA
  596. #define BT482_PEL_MASK ExtDev+RamDac+BT482_PIXEL_MASK
  597. #define BT482_PALETTE_RAM_READ ExtDev+RamDac+BT482_PAL_OR_CURS_RAM_READ
  598. #define BT482_CURSOR_RAM_READ ExtDev+RamDac+BT482_PAL_OR_CURS_RAM_READ
  599. #define BT482_CURSOR_COLOR_WRITE ExtDev+RamDac+BT482_OVS_OR_CURS_COLOR_WRITE
  600. #define BT482_OVRLAY_COLOR_WRITE ExtDev+RamDac+BT482_OVS_OR_CURS_COLOR_WRITE
  601. #define BT482_OVRLAY_REGS ExtDev+RamDac+BT482_OVS_OR_CURS_COLOR_DATA
  602. #define BT482_COMMAND_REGA ExtDev+RamDac+BT482_COMMAND_A
  603. #define BT482_CURSOR_COLOR_READ ExtDev+RamDac+BT482_OVS_OR_CURS_COLOR_READ
  604. #define BT482_OVRLAY_COLOR_READ ExtDev+RamDac+BT482_OVS_OR_CURS_COLOR_READ
  605. #define VIEWPOINT_PAL_ADDR_WRITE ExtDev+RamDac+VPOINT_PAL_ADDR_WRITE
  606. #define VIEWPOINT_PAL_COLOR ExtDev+RamDac+VPOINT_PAL_COLOR
  607. #define VIEWPOINT_PIX_READ_MASK ExtDev+RamDac+VPOINT_PIX_READ_MASK
  608. #define VIEWPOINT_PAL_ADDR_READ ExtDev+RamDac+VPOINT_PAL_ADDR_READ
  609. #define VIEWPOINT_RESERVED_4 ExtDev+RamDac+VPOINT_RESERVED_4
  610. #define VIEWPOINT_RESERVED_5 ExtDev+RamDac+VPOINT_RESERVED_5
  611. #define VIEWPOINT_INDEX ExtDev+RamDac+VPOINT_INDEX
  612. #define VIEWPOINT_DATA ExtDev+RamDac+VPOINT_DATA
  613. #define DUBIC_DUB_SEL ExtDev+Dubic+DUB_SEL
  614. #define DUBIC_NDX_PTR ExtDev+Dubic+NDX_PTR
  615. #define DUBIC_DUB_DATA ExtDev+Dubic+DUB_DATA
  616. #define DUBIC_LASER ExtDev+Dubic+LASER
  617. #define DUBIC_MOUSE0 ExtDev+Dubic+MOUSE0
  618. #define DUBIC_MOUSE1 ExtDev+Dubic+MOUSE1
  619. #define DUBIC_MOUSE2 ExtDev+Dubic+MOUSE2
  620. #define DUBIC_MOUSE3 ExtDev+Dubic+MOUSE3
  621. // **************************************************************************
  622. // RAMDAC registers fields
  623. // Bt482 --------------------------------------------------------------------
  624. // Extended registers
  625. #define READ_MASK_REG 0x00
  626. #define OVERLAY_MASK_REG 0x01
  627. #define COMMAND_B_REG 0x02
  628. #define CURS_REG 0x03
  629. #define CURS_X_LOW_REG 0x04
  630. #define CURS_X_HIGH_REG 0x05
  631. #define CURS_Y_LOW_REG 0x06
  632. #define CURS_Y_HIGH_REG 0x07
  633. // COMMAND_A
  634. #define BT482_PSEUDO_COLOR 0x00
  635. #define BT482_DUAL_EDGE_CLOCK_555 0x80
  636. #define BT482_DUAL_EDGE_CLOCK_565 0xc0
  637. #define BT482_SINGLE_EDGE_CLOCK_555 0xa0
  638. #define BT482_SINGLE_EDGE_CLOCK_565 0xe0
  639. #define BT482_DUAL_EDGE_CLOCK_888OL 0x90
  640. #define BT482_SINGLE_EDGE_CLOCK_888 0xF0
  641. #define BT482_EXTENDED_REG_SELECT 0x01
  642. #define BT482_EXTENDED_REG_UNSELECT 0x00
  643. // COMMAND_B_REG
  644. #define BT482_OVERLAY_REG_DISABLED 0x00
  645. #define BT482_OVERLAY_REG_ENABLED 0x40
  646. #define BT482_SETUP_00_IRE 0x00
  647. #define BT482_SETUP_75_IRE 0x20
  648. #define BT482_NO_SYNC_ON_BLUE 0x00
  649. #define BT482_SYNC_ON_BLUE 0x10
  650. #define BT482_NO_SYNC_ON_GREEN 0x00
  651. #define BT482_SYNC_ON_GREEN 0x08
  652. #define BT482_NO_SYNC_ON_RED 0x00
  653. #define BT482_SYNC_ON_RED 0x04
  654. #define BT482_COLOR_6_BIT 0x00
  655. #define BT482_COLOR_8_BIT 0x02
  656. #define BT482_SLEEP_UNSELECT 0x00
  657. #define BT482_SLEEP_SELECT 0x01
  658. // CURSOR_REG
  659. #define BT482_INTERNAL_CURSOR 0x00
  660. #define BT482_EXTERNAL_CURSOR 0x20
  661. #define BT482_NONINTERLACED_DISPLAY 0x00
  662. #define BT482_INTERLACED_DISPLAY 0x10
  663. #define BT482_CURSOR_COLOR_PALETTE_SELECT 0x00
  664. #define BT482_CURSOR_RAM_SELECT 0x08
  665. #define BT482_CURSOR_OP_ENABLED 0x00
  666. #define BT482_CURSOR_OP_DISABLED 0x04
  667. #define BT482_CURSOR_FIELDS 0x03
  668. #define BT482_CURSOR_DISABLED 0x00
  669. #define BT482_CURSOR_3_COLOR 0x01
  670. #define BT482_CURSOR_WINDOWS 0x02
  671. #define BT482_CURSOR_XWINDOWS 0x03
  672. // Bt485 --------------------------------------------------------------------
  673. // COMMAND_0
  674. #define BT485_REG3_UNSELECT 0x00
  675. #define BT485_REG3_SELECT 0x80
  676. #define BT485_INT_CLOCK_ENABLED 0x00
  677. #define BT485_INT_CLOCK_DISABLED 0x40
  678. #define BT485_SETUP_00_IRE 0x00
  679. #define BT485_SETUP_75_IRE 0x20
  680. #define BT485_NO_SYNC_ON_BLUE 0x00
  681. #define BT485_SYNC_ON_BLUE 0x10
  682. #define BT485_NO_SYNC_ON_GREEN 0x00
  683. #define BT485_SYNC_ON_GREEN 0x08
  684. #define BT485_NO_SYNC_ON_RED 0x00
  685. #define BT485_SYNC_ON_RED 0x04
  686. #define BT485_COLOR_6_BIT 0x00
  687. #define BT485_COLOR_8_BIT 0x02
  688. #define BT485_SLEEP_UNSELECT 0x00
  689. #define BT485_SLEEP_SELECT 0x01
  690. // COMMAND_1
  691. #define BT485_24BPP 0x00
  692. #define BT485_16BPP 0x20
  693. #define BT485_8BPP 0x40
  694. #define BT485_4BPP 0x60
  695. #define BT485_TRUECOLOR_BYPASS_DISABLED 0x00
  696. #define BT485_TRUECOLOR_BYPASS_ENABLED 0x10
  697. #define BT485_RGB_555 0x00
  698. #define BT485_RGB_565 0x08
  699. #define BT485_2_1_MUX 0x00
  700. #define BT485_1_1_MUX 0x04
  701. #define BT485_MUX_PORT_CR10 0x00
  702. #define BT485_MUX_PORT_P7D 0x02
  703. #define BT485_MUX_PORT_B_A 0x00
  704. #define BT485_MUX_PORT_D_C 0x01
  705. // COMMAND_2
  706. #define BT485_SCLK_ENABLED 0x00
  707. #define BT485_SCLK_DISABLED 0x80
  708. #define BT485_TEST_PATH_DISABLED 0x00
  709. #define BT485_TEST_PATH_ENABLED 0x40
  710. #define BT485_PORTSEL_MASKED 0x00
  711. #define BT485_PORTSEL_NONMASKED 0x20
  712. #define BT485_PCLK0_SELECT 0x00
  713. #define BT485_PCLK1_SELECT 0x10
  714. #define BT485_NONINTERLACED_DISPLAY 0x00
  715. #define BT485_INTERLACED_DISPLAY 0x08
  716. #define BT485_SPARSE_INDEXING 0x00
  717. #define BT485_CONTIGUOUS_INDEXING 0x04
  718. #define BT485_CURSOR_FIELDS 0x03
  719. #define BT485_CURSOR_DISABLED 0x00
  720. #define BT485_CURSOR_3_COLOR 0x01
  721. #define BT485_CURSOR_WINDOWS 0x02
  722. #define BT485_CURSOR_XWINDOWS 0x03
  723. // COMMAND_3
  724. #define BT485_2X_CLOCK_DISABLED 0x00
  725. #define BT485_2X_CLOCK_ENABLED 0x08
  726. #define BT485_CURSOR_32X32 0x00
  727. #define BT485_CURSOR_64X64 0x04
  728. #define BT485_CURSOR_64X64_FIELDS 0x03
  729. #define BT485_CURSOR_64X64_XOR_000 0x00
  730. #define BT485_CURSOR_64X64_XOR_100 0x01
  731. #define BT485_CURSOR_64X64_AND_000 0x02
  732. #define BT485_CURSOR_64X64_AND_100 0x03
  733. // ViewPoint ----------------------------------------------------------------
  734. // Indirect register map
  735. #define VPOINT_CUR_X_LSB 0x00
  736. #define VPOINT_CUR_X_MSB 0x01
  737. #define VPOINT_CUR_Y_LSB 0x02
  738. #define VPOINT_CUR_Y_MSB 0x03
  739. #define VPOINT_SPRITE_X 0x04
  740. #define VPOINT_SPRITE_Y 0x05
  741. #define VPOINT_CUR_CTL 0x06
  742. #define VPOINT_RESERVED_07 0x07
  743. #define VPOINT_CUR_RAM_LSB 0x08
  744. #define VPOINT_CUR_RAM_MSB 0x09
  745. #define VPOINT_CUR_RAM_DATA 0x0a
  746. #define VPOINT_RESERVED_0b 0x0b
  747. #define VPOINT_RESERVED_0c 0x0c
  748. #define VPOINT_RESERVED_0d 0x0d
  749. #define VPOINT_RESERVED_0e 0x0e
  750. #define VPOINT_RESERVED_0f 0x0f
  751. #define VPOINT_WIN_XSTART_LSB 0x10
  752. #define VPOINT_WIN_XSTART_MSB 0x11
  753. #define VPOINT_WIN_XSTOP_LSB 0x12
  754. #define VPOINT_WIN_XSTOP_MSB 0x13
  755. #define VPOINT_WIN_YSTART_LSB 0x14
  756. #define VPOINT_WIN_YSTART_MSB 0x15
  757. #define VPOINT_WIN_YSTOP_LSB 0x16
  758. #define VPOINT_WIN_YSTOP_MSB 0x17
  759. #define VPOINT_MUX_CTL1 0x18
  760. #define VPOINT_MUX_CTL2 0x19
  761. #define VPOINT_INPUT_CLK 0x1a
  762. #define VPOINT_OUTPUT_CLK 0x1b
  763. #define VPOINT_PAL_PAGE 0x1c
  764. #define VPOINT_GEN_CTL 0x1d
  765. #define VPOINT_RESERVED_1e 0x1e
  766. #define VPOINT_RESERVED_1f 0x1f
  767. #define VPOINT_OVS_RED 0x20
  768. #define VPOINT_OVS_GREEN 0x21
  769. #define VPOINT_OVS_BLUE 0x22
  770. #define VPOINT_CUR_COL0_RED 0x23
  771. #define VPOINT_CUR_COL0_GREEN 0x24
  772. #define VPOINT_CUR_COL0_BLUE 0x25
  773. #define VPOINT_CUR_COL1_RED 0x26
  774. #define VPOINT_CUR_COL1_GREEN 0x27
  775. #define VPOINT_CUR_COL1_BLUE 0x28
  776. #define VPOINT_AUX_CTL 0x29
  777. #define VPOINT_GEN_IO_CTL 0x2a
  778. #define VPOINT_GEN_IO_DATA 0x2b
  779. #define VPOINT_RESERVED_2c 0x2c
  780. #define VPOINT_RESERVED_2d 0x2d
  781. #define VPOINT_RESERVED_2e 0x2e
  782. #define VPOINT_RESERVED_2f 0x2f
  783. #define VPOINT_KEY_OLVGA_LOW 0x30
  784. #define VPOINT_KEY_OLVGA_HIGH 0x31
  785. #define VPOINT_KEY_RED_LOW 0x32
  786. #define VPOINT_KEY_RED_HI 0x33
  787. #define VPOINT_KEY_GREEN_LOW 0x34
  788. #define VPOINT_KEY_GREEN_HI 0x35
  789. #define VPOINT_KEY_BLUE_LOW 0x36
  790. #define VPOINT_KEY_BLUE_HI 0x37
  791. #define VPOINT_KEY_CTL 0x38
  792. #define VPOINT_RESERVED_39 0x39
  793. #define VPOINT_SENSE_TEST 0x3a
  794. #define VPOINT_TEST_DATA 0x3b
  795. #define VPOINT_CRC_LSB 0x3c
  796. #define VPOINT_CRC_MSB 0x3d
  797. #define VPOINT_CRC_CTL 0x3e
  798. #define VPOINT_ID 0x3f
  799. #define VPOINT_RESET 0xff
  800. #define VIEWPOINT_CURSOR_ON 0x40 //enable XGA + enable sprite
  801. #define VIEWPOINT_CURSOR_OFF 0x00 //disable XGA cursor
  802. // TVP3026 ------------------------------------------------------------------
  803. // Direct Register Map
  804. // For the Millenium, scale will be 0, for older chips, scale will be 2
  805. #define TVP3026_PAL_ADDR_WR(scale) ExtDev+RamDac+(0x00<<scale) //Palette RAM Address Write
  806. #define TVP3026_CUR_ADDR_WR(scale) ExtDev+RamDac+(0x00<<scale) //Cursor RAM Address Write
  807. #define TVP3026_INDIRECT_INDEX(scale) ExtDev+RamDac+(0x00<<scale) //Indirect Index
  808. #define TVP3026_PAL_DATA(scale) ExtDev+RamDac+(0x01<<scale) //Palette RAM Data
  809. #define TVP3026_PIX_RD_MSK(scale) ExtDev+RamDac+(0x02<<scale) //Pixel Read Mask
  810. #define TVP3026_PAL_ADDR_RD(scale) ExtDev+RamDac+(0x03<<scale) //Palette RAM A.address Read
  811. #define TVP3026_CUR_ADDR_RD(scale) ExtDev+RamDac+(0x03<<scale) //Cursor RAM Address Read
  812. #define TVP3026_CUR_COLOR_ADDR_WR(scale) ExtDev+RamDac+(0x04<<scale) //Cursor Color Address Write
  813. #define TVP3026_OVS_COLOR_ADDR_WR(scale) ExtDev+RamDac+(0x04<<scale) //Overscan Color Address Write
  814. #define TVP3026_CUR_COLOR_DATA(scale) ExtDev+RamDac+(0x05<<scale) //Cursor Color Data
  815. #define TVP3026_OVS_COLOR_DATA(scale) ExtDev+RamDac+(0x05<<scale) //Overscan Color Data
  816. #define TVP3026_RESERVED_0(scale) ExtDev+RamDac+(0x06<<scale) //Reserved
  817. #define TVP3026_CUR_COLOR_ADDR_RD(scale) ExtDev+RamDac+(0x07<<scale) //Cursor Color Address Read
  818. #define TVP3026_OVS_COLOR_ADDR_RD(scale) ExtDev+RamDac+(0x07<<scale) //Overscan Color Address Read
  819. #define TVP3026_RESERVED_1(scale) ExtDev+RamDac+(0x08<<scale) //Reserved
  820. #define TVP3026_RESERVED_2(scale) ExtDev+RamDac+(0x09<<scale) //Reserved
  821. #define TVP3026_INDEXED_DATA(scale) ExtDev+RamDac+(0x0a<<scale) //Indexed Data
  822. #define TVP3026_CUR_DATA(scale) ExtDev+RamDac+(0x0b<<scale) //Cursor RAM Data
  823. #define TVP3026_CUR_X_LSB(scale) ExtDev+RamDac+(0x0c<<scale) //Cursor Position X LSB
  824. #define TVP3026_CUR_X_MSB(scale) ExtDev+RamDac+(0x0d<<scale) //Cursor Position X MSB
  825. #define TVP3026_CUR_Y_LSB(scale) ExtDev+RamDac+(0x0e<<scale) //Cursor Position Y LSB
  826. #define TVP3026_CUR_Y_MSB(scale) ExtDev+RamDac+(0x0f<<scale) //Cursor Position Y MSB
  827. // Indirect Register Map
  828. #define TVP3026_I_PAL_STATUS 0x000
  829. #define TVP3026_I_REV 0x001
  830. #define TVP3026_I_RES_02 0x002
  831. #define TVP3026_I_RES_03 0x003
  832. #define TVP3026_I_RES_04 0x004
  833. #define TVP3026_I_RES_05 0x005
  834. #define TVP3026_I_CUR_CTL 0x006
  835. #define TVP3026_I_RES_07 0x007
  836. #define TVP3026_I_RES_08 0x008
  837. #define TVP3026_I_RES_09 0x009
  838. #define TVP3026_I_RES_0A 0x00a
  839. #define TVP3026_I_RES_0B 0x00b
  840. #define TVP3026_I_RES_0C 0x00c
  841. #define TVP3026_I_RES_0D 0x00d
  842. #define TVP3026_I_RES_0E 0x00e
  843. #define TVP3026_I_LATCH_CTL 0x00f
  844. #define TVP3026_I_RES_10 0x010
  845. #define TVP3026_I_RES_11 0x011
  846. #define TVP3026_I_RES_12 0x012
  847. #define TVP3026_I_RES_13 0x013
  848. #define TVP3026_I_RES_14 0x014
  849. #define TVP3026_I_RES_15 0x015
  850. #define TVP3026_I_RES_16 0x016
  851. #define TVP3026_I_RES_17 0x017
  852. #define TVP3026_I_TRUE_COL_CTL 0x018
  853. #define TVP3026_I_MPX_CTL 0x019
  854. #define TVP3026_I_CLK_SEL 0x01a
  855. #define TVP3026_I_RES_1B 0x01b
  856. #define TVP3026_I_PAL_PAGE 0x01c
  857. #define TVP3026_I_GENERAL_CTL 0x01d
  858. #define TVP3026_I_MISC_CTL 0x01e
  859. #define TVP3026_I_RES_1F 0x01f
  860. #define TVP3026_I_RES_20 0x020
  861. #define TVP3026_I_RES_21 0x021
  862. #define TVP3026_I_RES_22 0x022
  863. #define TVP3026_I_RES_23 0x023
  864. #define TVP3026_I_RES_24 0x024
  865. #define TVP3026_I_RES_25 0x025
  866. #define TVP3026_I_RES_26 0x026
  867. #define TVP3026_I_RES_27 0x027
  868. #define TVP3026_I_RES_28 0x028
  869. #define TVP3026_I_RES_29 0x029
  870. #define TVP3026_I_GEN_IO_CTL 0x02a
  871. #define TVP3026_I_GEN_IO_DATA 0x02b
  872. #define TVP3026_I_PLL_ADDR 0x02c
  873. #define TVP3026_I_PEL_CLK_PLL_DATA 0x02d
  874. #define TVP3026_I_MEM_CLK_PLL_DATA 0x02e
  875. #define TVP3026_I_LOAD_CLK_PLL_DATA 0x02f
  876. #define TVP3026_I_COL_KEY_OVL_LO 0x030
  877. #define TVP3026_I_COL_KEY_OVL_HI 0x031
  878. #define TVP3026_I_COL_KEY_R_LO 0x032
  879. #define TVP3026_I_COL_KEY_R_HI 0x033
  880. #define TVP3026_I_COL_KEY_G_LO 0x034
  881. #define TVP3026_I_COL_KEY_G_HI 0x035
  882. #define TVP3026_I_COL_KEY_B_LO 0x036
  883. #define TVP3026_I_COL_KEY_B_HI 0x037
  884. #define TVP3026_I_COL_KEY_CTL 0x038
  885. #define TVP3026_I_MCLK_CTL 0x039
  886. #define TVP3026_I_SENSE_TEST 0x03a
  887. #define TVP3026_I_TEST_DATA 0x03b
  888. #define TVP3026_I_CRC_REM_LSB 0x03c
  889. #define TVP3026_I_CRC_REM_MSB 0x03d
  890. #define TVP3026_I_CRC_BIT_SEL 0x03e
  891. #define TVP3026_I_ID 0x03f
  892. #define TVP3026_I_SOFT_RESET 0x0ff
  893. #define TVP3026_D_CURSOR_ON 0x02 //00000010b enable XGA cursor
  894. #define TVP3026_D_CURSOR_OFF 0x00 //00000000b disable cursor
  895. #define TVP3026_D_CURSOR_MASK 0x03
  896. //access cursor bitmap:
  897. #define TVP3026_D_CURSOR_RAM_00 0x00 //00000000b access bytes 000-0FF
  898. #define TVP3026_D_CURSOR_RAM_01 0x04 //00000100b access bytes 100-1FF
  899. #define TVP3026_D_CURSOR_RAM_10 0x08 //00001000b access bytes 200-2FF
  900. #define TVP3026_D_CURSOR_RAM_11 0x0c //00001100b access bytes 300-3FF
  901. #define TVP3026_D_CURSOR_RAM_MASK 0x0c
  902. #define TVP3026_D_OVS_COLOR 0x00 //00000000b Overscan color
  903. #define TVP3026_D_CUR_COLOR_0 0x01 //00000001b Cursor color 0
  904. #define TVP3026_D_CUR_COLOR_1 0x02 //00000010b Cursor color 1
  905. #define TVP3026_D_CUR_COLOR_2 0x03 //00000011b Cursor color 2
  906. // --------------------------------------------------------------------------
  907. // MGA PRODUCT ID (from DEFBIND.H in miniport driver)
  908. #define MGA_ULT_1M 1
  909. #define MGA_ULT_2M 2
  910. #define MGA_IMP_3M 3
  911. #define MGA_IMP_3M_Z 4
  912. #define MGA_PRO_4M5 5
  913. #define MGA_PRO_4M5_Z 6
  914. #define MGA_PCI_2M 7
  915. #define MGA_PCI_4M 8
  916. #define MGA_STORM 10
  917. ////////////////////////////////////////////////////////////////////////
  918. // Private IOCTL call definitions
  919. #define COMMON_FLAG 0x80000000
  920. #define CUSTOM_FLAG 0x00002000
  921. #define IOCTL_VIDEO_MTX_QUERY_NUM_OFFSCREEN_BLOCKS \
  922. CTL_CODE(FILE_DEVICE_VIDEO, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
  923. #define IOCTL_VIDEO_MTX_QUERY_OFFSCREEN_BLOCKS \
  924. CTL_CODE(FILE_DEVICE_VIDEO, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
  925. #define IOCTL_VIDEO_MTX_INITIALIZE_MGA \
  926. CTL_CODE(FILE_DEVICE_VIDEO, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
  927. #define IOCTL_VIDEO_MTX_QUERY_RAMDAC_INFO \
  928. CTL_CODE(FILE_DEVICE_VIDEO, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)
  929. #define IOCTL_VIDEO_MTX_GET_UPDATED_INF \
  930. CTL_CODE(FILE_DEVICE_VIDEO, 0x804, METHOD_BUFFERED, FILE_ANY_ACCESS)
  931. #define IOCTL_VIDEO_MTX_QUERY_BOARD_ID \
  932. CTL_CODE(FILE_DEVICE_VIDEO, 0x805, METHOD_BUFFERED, FILE_ANY_ACCESS)
  933. #define IOCTL_VIDEO_MTX_QUERY_HW_DATA \
  934. CTL_CODE(FILE_DEVICE_VIDEO, 0x806, METHOD_BUFFERED, FILE_ANY_ACCESS)
  935. #define IOCTL_VIDEO_MTX_QUERY_BOARD_ARRAY \
  936. CTL_CODE(FILE_DEVICE_VIDEO, 0x807, METHOD_BUFFERED, FILE_ANY_ACCESS)
  937. #define IOCTL_VIDEO_MTX_MAKE_BOARD_CURRENT \
  938. CTL_CODE(FILE_DEVICE_VIDEO, 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
  939. #define IOCTL_VIDEO_MTX_INIT_MODE_LIST \
  940. CTL_CODE(FILE_DEVICE_VIDEO, 0x809, METHOD_BUFFERED, FILE_ANY_ACCESS)
  941. // This structure is used with VIDEO_IOCTL_MTX_QUERY_NUM_OFFSCREEN_BLOCKS.
  942. typedef struct _VIDEO_NUM_OFFSCREEN_BLOCKS
  943. {
  944. ULONG NumBlocks; // number of offscreen blocks
  945. ULONG OffscreenBlockLength; // size of OFFSCREEN_BLOCK structure
  946. } VIDEO_NUM_OFFSCREEN_BLOCKS;
  947. // This structure is used with VIDEO_IOCTL_MTX_QUERY_OFFSCREEN_BLOCKS.
  948. typedef struct _OFFSCREEN_BLOCK
  949. {
  950. ULONG Type; // N_VRAM, N_DRAM, Z_VRAM, or Z_DRAM
  951. ULONG XStart; // X origin of offscreen memory area
  952. ULONG YStart; // Y origin of offscreen memory area
  953. ULONG Width; // offscreen width, in pixels
  954. ULONG Height; // offscreen height, in pixels
  955. ULONG SafePlanes; // offscreen available planes
  956. ULONG ZOffset; // Z start offset, if any Z
  957. } OFFSCREEN_BLOCK;
  958. // This structure is used with IOCTL_VIDEO_MTX_QUERY_RAMDAC_INFO.
  959. typedef struct _RAMDAC_INFO
  960. {
  961. ULONG Flags; // Ramdac type
  962. ULONG Width; // Maximum cursor width
  963. ULONG Height; // Maximum cursor height
  964. ULONG OverScanX; // X overscan
  965. ULONG OverScanY; // Y overscan
  966. } RAMDAC_INFO, *PRAMDAC_INFO;
  967. // Definitions for 'Type' field.
  968. #define N_VRAM 0 // Normal offscreen in VRAM, supports block mode
  969. #define N_DRAM 6 // Normal offscreen in DRAM, no support for block mode
  970. #define Z_VRAM 1 // Z-buffer memory in VRAM, supports block mode
  971. #define Z_DRAM 7 // Z-buffer memory in DRAM, no support for block mode
  972. // These structures are used with IOCTL_VIDEO_MTX_QUERY_HW_DATA. They should
  973. // be kept in sync with the CursorInfo and HwData structures defined in the
  974. // miniport driver.
  975. typedef struct _CURSOR_INFO
  976. {
  977. ULONG MaxWidth;
  978. ULONG MaxHeight;
  979. ULONG MaxDepth;
  980. ULONG MaxColors;
  981. ULONG CurWidth;
  982. ULONG CurHeight;
  983. LONG cHotSX;
  984. LONG cHotSY;
  985. LONG HotSX;
  986. LONG HotSY;
  987. } CURSOR_INFO, *PCURSOR_INFO;
  988. // Defines for HwData.Features flags
  989. #define DDC_MONITOR_SUPPORT 0x0001
  990. #define STORM_ON_MOTHERBOARD 0x0002
  991. #define MEDIA_EXCEL 0x0004
  992. #define INTERLEAVE_MODE 0x0008
  993. typedef struct _HW_DATA
  994. {
  995. ULONG StructLength; /* Structure length in bytes */
  996. ULONG MapAddress; /* Memory map address */
  997. ULONG MapAddress2; /* Physical base address, frame buffer */
  998. ULONG RomAddress; /* Physical base address, flash EPROM */
  999. ULONG ProductType; /* MGA Ultima ID, MGA Impression ID, ... */
  1000. ULONG ProductRev; /* 4 bit revision codes as follows */
  1001. /* 0 - 3 : pcb revision */
  1002. /* 4 - 7 : Titan revision */
  1003. /* 8 - 11 : Dubic revision */
  1004. /* 12 - 31 : all 1's indicating no other device
  1005. present */
  1006. ULONG ShellRev; /* Shell revision */
  1007. ULONG BindingRev; /* Binding revision */
  1008. ULONG MemAvail; /* Frame buffer memory in bytes */
  1009. BYTE VGAEnable; /* 0 = vga disabled, 1 = vga enabled */
  1010. BYTE Sync; /* relects the hardware straps */
  1011. BYTE Device8_16; /* relects the hardware straps */
  1012. BYTE PortCfg; /* 0-Disabled, 1-Mouse Port, 2-Laser Port */
  1013. BYTE PortIRQ; /* IRQ level number, -1 = interrupts disabled */
  1014. ULONG MouseMap; /* Mouse I/O map base if PortCfg = Mouse Port else don't care */
  1015. BYTE MouseIRate; /* Mouse interrupt rate in Hz */
  1016. BYTE DacType; /* 0 = BT482, 3 = BT485 */
  1017. CURSOR_INFO cursorInfo;
  1018. ULONG VramAvail; /* VRAM memory available on board in bytes */
  1019. ULONG DramAvail; /* DRAM memory available on board in bytes */
  1020. ULONG CurrentOverScanX; /* Left overscan in pixels */
  1021. ULONG CurrentOverScanY; /* Top overscan in pixels */
  1022. ULONG YDstOrg; /* Physical offset of display start */
  1023. ULONG YDstOrg_DB; /* Starting offset for double buffer */
  1024. ULONG CurrentZoomFactor;
  1025. ULONG CurrentXStart;
  1026. ULONG CurrentYStart;
  1027. ULONG CurrentPanXGran; /* X Panning granularity */
  1028. ULONG CurrentPanYGran; /* Y Panning granularity */
  1029. ULONG Features; /* Bit 0: 0 = DDC monitor not available */
  1030. /* 1 = DDC monitor available */
  1031. BYTE Reserved[64];
  1032. ULONG MgaBase1; /* MGA control aperture */
  1033. ULONG MgaBase2; /* Direct frame buffer */
  1034. ULONG RomBase; /* BIOS flash EPROM */
  1035. ULONG PresentMCLK;
  1036. } HW_DATA, *PHW_DATA;
  1037. // Definitions for RamDacType field.
  1038. #define RAMDAC_FIELDS 0xf000
  1039. #define RAMDAC_NONE 0x0000
  1040. #define RAMDAC_BT482 0x1000
  1041. #define RAMDAC_BT485 0x2000
  1042. #define RAMDAC_VIEWPOINT 0x3000
  1043. #define RAMDAC_TVP3026 0x4000
  1044. #define RAMDAC_PX2085 0x5000
  1045. #define RAMDAC_TVP3030 0x6000
  1046. //////////////////////////////////////////////////////////////////////
  1047. // PowerPC considerations
  1048. //
  1049. // The PowerPC does not guarantee that I/O to separate addresses will
  1050. // be executed in order. However, the PowerPC guarantees that
  1051. // output to the same address will be executed in order.
  1052. //
  1053. // Consequently, we use the following synchronization macros. They
  1054. // are relatively expensive in terms of performance, so we try to avoid
  1055. // them whereever possible.
  1056. //
  1057. // CP_EIEIO() 'Ensure In-order Execution of I/O'
  1058. // - Used to flush any pending I/O in situations where we wish to
  1059. // avoid out-of-order execution of I/O to separate addresses.
  1060. //
  1061. // CP_MEMORY_BARRIER()
  1062. // - Used to flush any pending I/O in situations where we wish to
  1063. // avoid out-of-order execution or 'collapsing' of I/O to
  1064. // the same address. We used to have to do this separately for
  1065. // the Alpha because unlike the PowerPC it did not guarantee that
  1066. // output to the same address will be exectued in order. However,
  1067. // with the move to kernel-mode, on Alpha we are now calling HAL
  1068. // routines for every port I/O which ensure that this is not a
  1069. // problem.
  1070. #if defined(_PPC_)
  1071. // On PowerPC, CP_MEMORY_BARRIER doesn't do anything.
  1072. #define CP_EIEIO() MEMORY_BARRIER()
  1073. #define CP_MEMORY_BARRIER()
  1074. #elif defined(_ALPHA_)
  1075. // On Alpha, since we must do all non-frame-buffer I/O through HAL
  1076. // routines, which automatically do memory-barriers, we don't have
  1077. // to do memory barriers ourselves (and should not, because it's a
  1078. // performance hit).
  1079. #define CP_EIEIO()
  1080. #define CP_MEMORY_BARRIER()
  1081. #else
  1082. // On other systems, both CP_EIEIO and CP_MEMORY_BARRIER don't do anything.
  1083. #define CP_EIEIO() MEMORY_BARRIER()
  1084. #define CP_MEMORY_BARRIER() MEMORY_BARRIER()
  1085. #endif
  1086. ////////////////////////////////////////////////////////////////////////
  1087. // Unsafe direct access macros
  1088. //
  1089. // These are macros for directly accessing the MGA's accelerator
  1090. // registers. They should be used with care, because they always
  1091. // ignore memory barriers:
  1092. #define CP_WRITE_DIRECT(pjBase, addr, dw) \
  1093. WRITE_REGISTER_ULONG((BYTE*) (pjBase) + (addr), (ULONG) (dw))
  1094. #define CP_WRITE_DIRECT_BYTE(pjBase, addr, j) \
  1095. WRITE_REGISTER_UCHAR((BYTE*) (pjBase) + (addr), (UCHAR) (j))
  1096. #define CP_READ_REGISTER(p) \
  1097. READ_REGISTER_ULONG((BYTE*) (p))
  1098. #define CP_READ_REGISTER_BYTE(p) \
  1099. READ_REGISTER_UCHAR((BYTE*) (p))
  1100. ////////////////////////////////////////////////////////////////////////
  1101. // 'Safe' direct access macros
  1102. //
  1103. // These are the 'safe' slow versions for directly writing to a port,
  1104. // because they automatically always handle memory barriers:
  1105. #define CP_WRITE_REGISTER(p, dw) \
  1106. { \
  1107. CP_EIEIO(); \
  1108. WRITE_REGISTER_ULONG(p, (ULONG) (dw)); \
  1109. CP_EIEIO(); \
  1110. }
  1111. #define CP_WRITE_REGISTER_WORD(p, w) \
  1112. { \
  1113. CP_EIEIO(); \
  1114. WRITE_REGISTER_USHORT(p, (USHORT) (w)); \
  1115. CP_EIEIO(); \
  1116. }
  1117. #define CP_WRITE_REGISTER_BYTE(p, j) \
  1118. { \
  1119. CP_EIEIO(); \
  1120. WRITE_REGISTER_UCHAR(p, (UCHAR) (j)); \
  1121. CP_EIEIO(); \
  1122. }
  1123. ////////////////////////////////////////////////////////////////////////
  1124. // MGA direct access macros
  1125. //
  1126. // These macros abstract some MGA register accesses.
  1127. #define CP_WRITE_SRC(pjBase, dw) \
  1128. { \
  1129. CP_WRITE_DIRECT((pjBase), DWG_SRC0, (dw)); \
  1130. CP_MEMORY_BARRIER(); \
  1131. }
  1132. #define CP_READ_STATUS(pjBase) \
  1133. CP_READ_REGISTER_BYTE((BYTE*) (pjBase) + HST_STATUS + 2)
  1134. #define CP_READ(pjBase, addr) \
  1135. CP_READ_REGISTER((BYTE*) (pjBase) + (addr))
  1136. #if DBG
  1137. #define CP_START(pjBase, addr, dw) \
  1138. { \
  1139. CP_EIEIO(); \
  1140. vWriteDword((BYTE*) (pjBase) + (addr) + (StartDwgReg), (ULONG) (dw)); \
  1141. CP_EIEIO(); \
  1142. }
  1143. #define CP_WRITE(pjBase, addr, dw) \
  1144. vWriteDword((BYTE*) (pjBase) + (addr), (ULONG) (dw))
  1145. #define CP_WRITE_BYTE(pjBase, addr, j) \
  1146. vWriteByte((BYTE*) (pjBase) + (addr), (UCHAR) (j))
  1147. #define CHECK_FIFO_SPACE(pjBase, level) \
  1148. vCheckFifoSpace((pjBase), (level))
  1149. #define GET_FIFO_SPACE(pjBase) \
  1150. cGetFifoSpace((pjBase))
  1151. #else
  1152. #define CP_START(pjBase, addr, dw) \
  1153. { \
  1154. CP_EIEIO(); \
  1155. WRITE_REGISTER_ULONG((BYTE*) (pjBase) + (addr) + (StartDwgReg), (ULONG) (dw)); \
  1156. CP_EIEIO(); \
  1157. }
  1158. #define CP_WRITE(pjBase, addr, dw) \
  1159. WRITE_REGISTER_ULONG((BYTE*) (pjBase) + (addr), (ULONG) (dw))
  1160. #define CP_WRITE_BYTE(pjBase, addr, j) \
  1161. WRITE_REGISTER_UCHAR((BYTE*) (pjBase) + (addr), (UCHAR) (j))
  1162. #define CHECK_FIFO_SPACE(pjBase, level) \
  1163. { \
  1164. CP_EIEIO(); \
  1165. do {} while (CP_READ_REGISTER_BYTE((pjBase) + HST_FIFOSTATUS) < (level)); \
  1166. }
  1167. __inline CHAR GET_FIFO_SPACE(BYTE* pjBase) \
  1168. { \
  1169. CP_EIEIO(); \
  1170. return(CP_READ_REGISTER_BYTE((pjBase) + HST_FIFOSTATUS)); \
  1171. }
  1172. #endif
  1173. // It used to be that we had to worry about the Alpha collapsing writes
  1174. // to the same address. Not any more! With NT 4.0, all I/O on the
  1175. // Alpha goes through HAL calls that automatically ensure that
  1176. // collapsed writes will not be a problem.
  1177. #define CP_WRITE_DMA(ppdev, pjDma, dw) \
  1178. CP_WRITE((pjDma), 0, (dw))
  1179. #define CP_READ_DMA(ppdev, pjDma) \
  1180. CP_READ((pjDma), 0)
  1181. #define CHECK_FIFO_FREE(pjBase, cFifo, needed) \
  1182. { \
  1183. (cFifo) -= (needed); \
  1184. while ((CHAR) (cFifo) < 0) \
  1185. { \
  1186. (cFifo) = GET_FIFO_SPACE(pjBase) - (needed); \
  1187. } \
  1188. }
  1189. /////////////////////////////////////////////////////////////////
  1190. __inline ULONG COLOR_REPLICATE(PDEV* ppdev, ULONG x)
  1191. {
  1192. ULONG ulResult = x;
  1193. if (ppdev->cjPelSize == 1)
  1194. {
  1195. ulResult |= (ulResult << 8);
  1196. ulResult |= (ulResult << 16);
  1197. }
  1198. else if (ppdev->cjPelSize == 2)
  1199. {
  1200. ulResult |= (ulResult << 16);
  1201. }
  1202. return(ulResult);
  1203. }
  1204. // The PACKXY macro is used for line drawing, and is safe for
  1205. // negative 'x' values:
  1206. #define PACKXY(x, y) (((y) << 16) | (x) & 0xffff)
  1207. // This one isn't safe for negative 'x' values:
  1208. #define PACKXY_QUICK(x, y) (((y) << 16) | (x))
  1209. /////////////////////////////////////////////////////////////////
  1210. // DirectDraw stuff
  1211. __inline BOOL VBLANK_IS_ACTIVE(BYTE* pjBase)
  1212. {
  1213. CP_EIEIO();
  1214. return(CP_READ_REGISTER_BYTE((BYTE*) (pjBase) + VGA_INSTS1) & 0x08);
  1215. }
  1216. __inline BOOL DISPLAY_IS_ACTIVE(BYTE* pjBase)
  1217. {
  1218. CP_EIEIO();
  1219. return(!(CP_READ_REGISTER_BYTE((BYTE*) (pjBase) + VGA_INSTS1) & 0x01));
  1220. }
  1221. __inline ULONG GET_SCANLINE(BYTE* pjBase)
  1222. {
  1223. CP_EIEIO();
  1224. return(CP_READ_REGISTER((pjBase) + HST_VCOUNT));
  1225. }
  1226. //////////////////////////////////////////////////////////////////////////
  1227. // START_ and END_DIRECT_ACCESS should bracket direct frame buffer
  1228. // access so that memory barriers are performed correctly on the
  1229. // PowerPC and Alpha.
  1230. #define START_DIRECT_ACCESS_MGA_NO_WAIT(ppdev, pjBase)\
  1231. CP_EIEIO()
  1232. #define START_DIRECT_ACCESS_MGA(ppdev, pjBase)\
  1233. CP_EIEIO();WAIT_NOT_BUSY(pjBase)
  1234. #define END_DIRECT_ACCESS_MGA(ppdev, pjBase)\
  1235. CP_EIEIO()
  1236. #define START_DIRECT_ACCESS_STORM(ppdev, pjBase)\
  1237. {\
  1238. CP_EIEIO();\
  1239. WAIT_NOT_BUSY(pjBase);\
  1240. }
  1241. //////////////////////////////////////////////////////////////////////////
  1242. // The STORM has an ugly framebuffer read coherency bug -- it does not
  1243. // invalidate its frame buffer cache when an accelerator operation is
  1244. // done. To work around this, we do some extra reads to make sure the
  1245. // data in the cache is currently valid.
  1246. //
  1247. // This problem was most evident with USWC turned on with a Pentium Pro,
  1248. // when using a software cursor and selecting text using 'QuickEdit' mode
  1249. // in a console window -- cursor turds would be left around the screen.
  1250. #define START_DIRECT_ACCESS_STORM_FOR_READ(ppdev, pjBase) \
  1251. { \
  1252. volatile ULONG ulTmp; \
  1253. CP_EIEIO(); \
  1254. WAIT_NOT_BUSY(pjBase); \
  1255. ulTmp = *(volatile ULONG *)(ppdev->pjScreen); \
  1256. ulTmp = *(volatile ULONG *)(ppdev->pjScreen + 32); \
  1257. CHECK_FIFO_SPACE(pjBase, 1);/* Done to flush USWC cache */ \
  1258. }
  1259. // The STORM has an ugly framebuffer cache coherency bug. We need to
  1260. // do some extra reads to make sure that data written to the
  1261. // framebuffer are actually flushed from the cache into video memory.
  1262. //
  1263. // This problem was evident when running OpenGL conformance tests.
  1264. #define END_DIRECT_ACCESS_STORM(ppdev, pjBase) \
  1265. { \
  1266. volatile ULONG ulTmp; \
  1267. CP_EIEIO(); \
  1268. ulTmp = *(volatile ULONG *)(ppdev->pjScreen); \
  1269. ulTmp = *(volatile ULONG *)(ppdev->pjScreen + 128); \
  1270. }
  1271. #define BLT_WRITE_ON(ppdev, pjBase) \
  1272. { \
  1273. ULONG ul; \
  1274. \
  1275. ul = CP_READ_REGISTER(pjBase + HST_OPMODE) & OPMODE_OTHER_INFO; \
  1276. CP_WRITE_DIRECT_BYTE(pjBase, HST_OPMODE, ul | (dmamod_BLIT_WRITE)); \
  1277. CP_MEMORY_BARRIER(); \
  1278. CP_WRITE_DIRECT_BYTE(pjBase, HST_OPMODE, ul | (dmamod_BLIT_WRITE | pseudodma_ON)); \
  1279. CP_EIEIO(); \
  1280. CP_READ_REGISTER(pjBase + HST_OPMODE); \
  1281. }
  1282. #define BLT_WRITE_OFF(ppdev, pjBase) \
  1283. { \
  1284. ULONG ul; \
  1285. \
  1286. ul = CP_READ_REGISTER(pjBase + HST_OPMODE) & OPMODE_OTHER_INFO; \
  1287. CP_WRITE_DIRECT_BYTE(pjBase, HST_OPMODE, ul | (pseudodma_OFF)); \
  1288. CP_EIEIO(); \
  1289. }
  1290. #define BLT_READ_ON(ppdev, pjBase) \
  1291. { \
  1292. ULONG ul; \
  1293. \
  1294. ul = CP_READ_REGISTER(pjBase + HST_OPMODE) & OPMODE_OTHER_INFO; \
  1295. CP_WRITE_DIRECT_BYTE(pjBase, HST_OPMODE, ul | (dmamod_BLIT_READ)); \
  1296. CP_MEMORY_BARRIER(); \
  1297. CP_WRITE_DIRECT_BYTE(pjBase, HST_OPMODE, ul | (dmamod_BLIT_READ | pseudodma_ON)); \
  1298. CP_EIEIO(); \
  1299. }
  1300. #define BLT_READ_OFF(ppdev, pjBase) \
  1301. BLT_WRITE_OFF((ppdev), (pjBase))
  1302. #define IS_BUSY(pjBase) \
  1303. ((CP_READ_STATUS(pjBase) & (dwgengsts_MASK >> 16)) != 0)
  1304. #define WAIT_NOT_BUSY(pjBase) \
  1305. { \
  1306. do {} while (IS_BUSY(pjBase)); \
  1307. }
  1308. #define DATA_TRANSFER(pjBase, pjSrc, cdSrc) \
  1309. { \
  1310. LONG i = (LONG) (cdSrc); \
  1311. ULONG* pulSrcTmp = (ULONG*) (pjSrc); \
  1312. do { \
  1313. CP_WRITE_DIRECT(pjBase, DWG_SRC0, *pulSrcTmp); \
  1314. pulSrcTmp++; \
  1315. } while (--i != 0); \
  1316. }