Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1126 lines
60 KiB

  1. /******************************************************************************\
  2. *
  3. * $Workfile: hw.h $
  4. *
  5. * All the hardware specific driver file stuff. Parts are mirrored in
  6. * 'hw.inc'.
  7. *
  8. * Copyright (c) 1992-1995 Microsoft Corporation
  9. * Copyright (c) 1996 Cirrus Logic, Inc.
  10. *
  11. * $Log: S:/projects/drivers/ntsrc/display/HW.H_V $
  12. *
  13. * Rev 1.4 10 Jan 1997 15:40:14 PLCHU
  14. *
  15. *
  16. * Rev 1.3 Nov 07 1996 16:48:02 unknown
  17. *
  18. *
  19. * Rev 1.1 Oct 10 1996 15:37:46 unknown
  20. *
  21. *
  22. * Rev 1.3 12 Aug 1996 16:48:16 frido
  23. * Cleaned up source.
  24. *
  25. * Rev 1.2 29 Jul 1996 12:28:38 frido
  26. * Added WriteMask register.
  27. *
  28. * Rev 1.1 03 Jul 1996 13:38:42 frido
  29. * Added DirectDraw support.
  30. *
  31. * sge01 10-23-96 Add second aperture flag
  32. *
  33. * sge02 10-29-96 Merge port and register access for
  34. * VGA relocatable and MMIO registers.
  35. *
  36. \******************************************************************************/
  37. #define CP_TRACK() \
  38. ( \
  39. DISPDBG((100, "CP access - File(%s) line(%d)", __FILE__, __LINE__)) \
  40. )
  41. ////////////////////////////////////////////////////////////////////////////////
  42. // Ports //
  43. ////////////////////////////////////////////////////////////////////////////////
  44. #define SR_INDEX 0x3C4 // Sequencer Registers
  45. #define SR_DATA 0x3C5
  46. #define DAC_PEL_READ_ADDR 0x3C7
  47. #define DAC_PEL_WRITE_ADDR 0x3C8
  48. #define DAC_PEL_DATA 0x3C9
  49. #define INDEX_REG 0x3CE // Graphics Controler Registers
  50. #define DATA_REG 0x3CF
  51. #if 1 // extra defines
  52. #define CRTC_INDEX 0x3D4 // CRT Controller Registers
  53. #define CRTC_DATA 0x3D5
  54. #define STATUS_1 0x3DA // Input Status Register 1
  55. #define DISPLAY_MODE_INACTIVE 0x01
  56. #define VBLANK_ACTIVE 0x08
  57. #endif
  58. ////////////////////////////////////////////////////////////////////////////////
  59. // Alpha and PowerPC considerations
  60. //
  61. // Both the Alpha and the PowerPC do not guarantee that I/O to separate
  62. // addresses will be executed in order. The Alpha and PowerPC differ, however,
  63. // in that the PowerPC guarantees that output to the same address will be
  64. // executed in order, while the Alpha may cache and 'collapse' consecutive
  65. // output to become only one output.
  66. //
  67. // Consequently, we use the following synchronization macros. They are
  68. // relatively expensive in terms of performance, so we try to avoid them
  69. // whereever possible.
  70. //
  71. // CP_EIEIO() 'Ensure In-order Execution of I/O'
  72. // - Used to flush any pending I/O in situations where we wish to avoid
  73. // out-of-order execution of I/O to separate addresses.
  74. //
  75. // CP_MEMORY_BARRIER()
  76. // - Used to flush any pending I/O in situations where we wish to avoid
  77. // out-of-order execution or 'collapsing' of I/O to the same address. On
  78. // the PowerPC, this will be defined as a null operation.
  79. #if defined(_PPC_)
  80. // On PowerPC, CP_MEMORY_BARRIER doesn't do anything.
  81. #define CP_EIEIO() MEMORY_BARRIER()
  82. #define CP_MEMORY_BARRIER() 0
  83. #elseif defined(_ALPHA_)
  84. // On Alpha, CP_EIEIO() is the same thing as a CP_MEMORY_BARRIER().
  85. #define CP_EIEIO() MEMORY_BARRIER()
  86. #define CP_MEMORY_BARRIER() MEMORY_BARRIER()
  87. #else
  88. // On i386 and MIPS, there is nu such thing as MEMORY_BARRIER.
  89. #define CP_EIEIO() 0
  90. #define CP_MEMORY_BARRIER() 0
  91. #endif
  92. //
  93. // Merge port and register access for VGA relocatable and MMIO registers.
  94. //
  95. #define CL_READ_PORT_UCHAR(Port) ppdev->pfnREAD_PORT_UCHAR(Port)
  96. #define CL_READ_PORT_USHORT(Port) ppdev->pfnREAD_PORT_USHORT(Port)
  97. #define CL_READ_PORT_ULONG(Port) ppdev->pfnREAD_PORT_ULONG(Port)
  98. #define CL_WRITE_PORT_UCHAR(Port, Value) ppdev->pfnWRITE_PORT_UCHAR(Port, Value)
  99. #define CL_WRITE_PORT_USHORT(Port, Value) ppdev->pfnWRITE_PORT_USHORT(Port, Value)
  100. #define CL_WRITE_PORT_ULONG(Port, Value) ppdev->pfnWRITE_PORT_ULONG(Port, Value)
  101. ////////////////////////////////////////////////////////////////////////////////
  102. // Port access macros //
  103. ////////////////////////////////////////////////////////////////////////////////
  104. #define CP_OUT_DWORD(pjBase, cjOffset, ul) \
  105. ( \
  106. CP_TRACK(), \
  107. CL_WRITE_PORT_ULONG((BYTE*) (pjBase) + (cjOffset), (DWORD) (ul)), \
  108. CP_EIEIO() \
  109. )
  110. #define CP_OUT_WORD(pjBase, cjOffset, w) \
  111. ( \
  112. CP_TRACK(), \
  113. CL_WRITE_PORT_USHORT((BYTE*) (pjBase) + (cjOffset), (WORD) (w)), \
  114. CP_EIEIO() \
  115. )
  116. #define CP_OUT_BYTE(pjBase, cjOffset, j) \
  117. ( \
  118. CP_TRACK(), \
  119. CL_WRITE_PORT_UCHAR((BYTE*) (pjBase) + (cjOffset), (BYTE) (j)), \
  120. CP_EIEIO() \
  121. )
  122. #define CP_IN_DWORD(pjBase, cjOffset) \
  123. ( \
  124. CP_TRACK(), \
  125. CL_READ_PORT_ULONG((BYTE*) (pjBase) + (cjOffset)) \
  126. )
  127. #define CP_IN_WORD(pjBase, cjOffset) \
  128. ( \
  129. CP_TRACK(), \
  130. CL_READ_PORT_USHORT((BYTE*) (pjBase) + (cjOffset)) \
  131. )
  132. #define CP_IN_BYTE(pjBase, cjOffset) \
  133. ( \
  134. CP_TRACK(), \
  135. CL_READ_PORT_UCHAR((BYTE*) (pjBase) + (cjOffset)) \
  136. )
  137. ////////////////////////////////////////////////////////////////////////////////
  138. // Memory mapped register access macros //
  139. ////////////////////////////////////////////////////////////////////////////////
  140. #define CP_WRITE_ULONG(pjBase, cjOffset, ul) \
  141. ( \
  142. CP_TRACK(), \
  143. WRITE_REGISTER_ULONG((ULONG*)((BYTE*)(pjBase) + (cjOffset)), (DWORD)(ul)) \
  144. )
  145. #define CP_WRITE_USHORT(pjBase, cjOffset, w) \
  146. ( \
  147. CP_TRACK(), \
  148. WRITE_REGISTER_USHORT((BYTE*) (pjBase) + (cjOffset), (WORD) (w)) \
  149. )
  150. #define CP_WRITE_UCHAR(pjBase, cjOffset, j) \
  151. ( \
  152. CP_TRACK(), \
  153. WRITE_REGISTER_UCHAR((BYTE*) (pjBase) + (cjOffset), (BYTE) (j)) \
  154. )
  155. #define CP_READ_ULONG(pjBase, cjOffset) \
  156. ( \
  157. CP_TRACK(), \
  158. READ_REGISTER_ULONG((BYTE*) (pjBase) + (cjOffset)) \
  159. )
  160. #define CP_READ_USHORT(pjBase, cjOffset) \
  161. ( \
  162. CP_TRACK(), \
  163. READ_REGISTER_USHORT((BYTE*) (pjBase) + (cjOffset)) \
  164. )
  165. #define CP_READ_UCHAR(pjBase, cjOffset) \
  166. ( \
  167. CP_TRACK(), \
  168. READ_REGISTER_UCHAR((BYTE*) (pjBase) + (cjOffset)) \
  169. )
  170. ////////////////////////////////////////////////////////////////////////////////
  171. // Blt engine MM register access macros //
  172. ////////////////////////////////////////////////////////////////////////////////
  173. #define CP_MM_ACL_STAT(ppdev, pjBase) \
  174. ( \
  175. CP_READ_UCHAR(pjBase, MM_BLT_START_STATUS_REG) \
  176. )
  177. #define CP_MM_ROP(ppdev, pjBase, val) \
  178. { \
  179. CP_WRITE_UCHAR(pjBase, MM_BLT_ROP, val); \
  180. } \
  181. #define CP_MM_SRC_Y_OFFSET(ppdev, pjBase, val) \
  182. { \
  183. CP_WRITE_USHORT(pjBase, MM_BLT_SRC_PITCH, val); \
  184. }
  185. #define CP_MM_DST_Y_OFFSET(ppdev, pjBase, val) \
  186. { \
  187. CP_WRITE_USHORT(pjBase, MM_BLT_DST_PITCH, val); \
  188. }
  189. #define CP_MM_SRC_ADDR(ppdev, pjBase, val) \
  190. { \
  191. CP_WRITE_ULONG(pjBase, MM_BLT_SRC_ADDR, val); \
  192. }
  193. #define CP_MM_DST_WRITE_MASK(ppdev, pjBase, val) \
  194. { \
  195. CP_WRITE_UCHAR(pjBase, MM_BLT_DST_WRITE_MASK, val); \
  196. }
  197. #define CP_MM_BLT_MODE(ppdev, pjBase, val) \
  198. { \
  199. CP_WRITE_UCHAR(pjBase, MM_BLT_MODE, val); \
  200. CP_WRITE_UCHAR(pjBase, MM_BLT_EXT, 0); \
  201. }
  202. #define CP_MM_START_REG(ppdev, pjBase, val) \
  203. { \
  204. CP_WRITE_UCHAR(pjBase, MM_BLT_START_STATUS_REG, val); \
  205. }
  206. #define CP_MM_FG_COLOR(ppdev, pjBase, val) \
  207. { \
  208. CP_WRITE_ULONG(pjBase, MM_BLT_FG_COLOR, val); \
  209. }
  210. #define CP_MM_BG_COLOR(ppdev, pjBase, val) \
  211. { \
  212. CP_WRITE_ULONG(pjBase, MM_BLT_BG_COLOR, val); \
  213. }
  214. #define CP_MM_XCNT(ppdev, pjBase, val) \
  215. { \
  216. CP_WRITE_USHORT(pjBase, MM_BLT_WIDTH, val); \
  217. }
  218. #define CP_MM_YCNT(ppdev, pjBase, val) \
  219. { \
  220. CP_WRITE_USHORT(pjBase, MM_BLT_HEIGHT, val); \
  221. }
  222. #define CP_MM_DST_ADDR(ppdev, pjBase, relval) \
  223. { \
  224. CP_WRITE_ULONG(pjBase, MM_BLT_DST_ADDR, (relval) + ppdev->xyOffset); \
  225. }
  226. #define CP_MM_DST_ADDR_ABS(ppdev, pjBase, val) \
  227. { \
  228. CP_WRITE_ULONG(pjBase, MM_BLT_DST_ADDR, val); \
  229. }
  230. #define CP_MM_BLT_EXT_MODE(ppdev, pjBase, val) \
  231. { \
  232. CP_WRITE_UCHAR(pjBase, MM_BLT_EXT, val); \
  233. }
  234. #if 1 // D5480
  235. #define CP_MM_BLT_MODE_PACKED(ppdev, pjBase, val) \
  236. { \
  237. CP_WRITE_ULONG(pjBase, MM_BLT_MODE, val); \
  238. }
  239. // Note: The PACKXY_FAST macro is unsafe with negative coordinates
  240. #define PACKXY(x, y) (((y) << 16) | ((x) & 0xffff))
  241. #define PACKXY_FAST(x, y) (((y) << 16) | (x))
  242. #define CP_MM_DST_XY_SAFE(ppdev, pjBase, x, y) \
  243. { \
  244. CP_WRITE_ULONG(pjBase, MM_BLT_DST_X, PACKXY((x), (y))); \
  245. }
  246. #define CP_MM_DST_XY(ppdev, pjBase, x, y) \
  247. { \
  248. CP_WRITE_ULONG(pjBase, MM_BLT_DST_X, PACKXY_FAST((x), (y))); \
  249. }
  250. #define CP_MM_DST_X(ppdev, pjBase, x) \
  251. { \
  252. CP_WRITE_USHORT(pjBase, MM_BLT_DST_X, (x)); \
  253. }
  254. #define CP_MM_DST_Y(ppdev, pjBase, y) \
  255. { \
  256. CP_WRITE_USHORT(pjBase, MM_BLT_DST_Y, (y)); \
  257. }
  258. #define CP_MM_SRC_XY_SAFE(ppdev, pjBase, x, y) \
  259. { \
  260. CP_WRITE_ULONG(pjBase, MM_BLT_SRC_X, PACKXY((x), (y))); \
  261. }
  262. #define CP_MM_SRC_XY(ppdev, pjBase, x, y) \
  263. { \
  264. CP_WRITE_ULONG(pjBase, MM_BLT_SRC_X, PACKXY_FAST((x), (y))); \
  265. }
  266. #define CP_MM_SRC_XY_PACKED(ppdev, pjBase, xy) \
  267. { \
  268. CP_WRITE_ULONG(pjBase, MM_BLT_SRC_X, xy); \
  269. }
  270. #define CP_MM_CLIP_ULXY_SAFE(ppdev, pjBase, x, y) \
  271. { \
  272. CP_WRITE_ULONG(pjBase, MM_BLT_CLIP_ULX, PACKXY((x), (y))); \
  273. }
  274. #define CP_MM_CLIP_ULXY(ppdev, pjBase, x, y) \
  275. { \
  276. CP_WRITE_ULONG(pjBase, MM_BLT_CLIP_ULX, PACKXY_FAST((x), (y))); \
  277. }
  278. #define CP_MM_CLIP_LRXY_SAFE(ppdev, pjBase, x, y) \
  279. { \
  280. CP_WRITE_ULONG(pjBase, MM_BLT_CLIP_LRX, PACKXY((x), (y))); \
  281. }
  282. #define CP_MM_CLIP_LRXY(ppdev, pjBase, x, y) \
  283. { \
  284. CP_WRITE_ULONG(pjBase, MM_BLT_CLIP_LRX, PACKXY_FAST((x), (y))); \
  285. }
  286. #endif // endif D5480
  287. ////////////////////////////////////////////////////////////////////////////////
  288. // Blt engine IO register access macros //
  289. ////////////////////////////////////////////////////////////////////////////////
  290. #define CP_IO_ACL_STAT(ppdev, pjPorts) \
  291. ( \
  292. CP_OUT_BYTE(pjPorts, INDEX_REG, IO_BLT_START_STATUS_REG), \
  293. CP_IN_BYTE(pjPorts, DATA_REG) \
  294. )
  295. #define CP_IO_ROP(ppdev, pjPorts, val) \
  296. { \
  297. CP_OUT_WORD(pjPorts, INDEX_REG, IO_BLT_ROP | ((val) << 8)); \
  298. }
  299. #define CP_IO_SRC_Y_OFFSET(ppdev, pjPorts, val) \
  300. { \
  301. CP_OUT_WORD(pjPorts, INDEX_REG, \
  302. IO_BLT_SRC_PITCH_HIGH | ((val) & 0xff00)); \
  303. CP_OUT_WORD(pjPorts, INDEX_REG, \
  304. IO_BLT_SRC_PITCH_LOW | (((val) & 0x00ff) << 8)); \
  305. }
  306. #define CP_IO_DST_Y_OFFSET(ppdev, pjPorts, val) \
  307. { \
  308. CP_OUT_WORD(pjPorts, INDEX_REG, \
  309. IO_BLT_DST_PITCH_HIGH | ((val) & 0xff00)); \
  310. CP_OUT_WORD(pjPorts, INDEX_REG, \
  311. IO_BLT_DST_PITCH_LOW | (((val) & 0x00ff) << 8)); \
  312. }
  313. #define CP_IO_SRC_ADDR(ppdev, pjPorts, val) \
  314. { \
  315. CP_OUT_WORD(pjPorts, INDEX_REG, \
  316. IO_BLT_SRC_ADDR_HIGH | (((val) & 0xff0000) >> 8)); \
  317. CP_OUT_WORD(pjPorts, INDEX_REG, \
  318. IO_BLT_SRC_ADDR_MID | (((val) & 0x00ff00))); \
  319. CP_OUT_WORD(pjPorts, INDEX_REG, \
  320. IO_BLT_SRC_ADDR_LOW | (((val) & 0x0000ff) << 8)); \
  321. }
  322. #define CP_IO_BLT_MODE(ppdev, pjPorts, val) \
  323. { \
  324. CP_OUT_WORD(pjPorts, INDEX_REG, IO_BLT_MODE | ((val) << 8)); \
  325. }
  326. #define CP_IO_START_REG(ppdev, pjPorts, val) \
  327. { \
  328. CP_OUT_WORD(pjPorts, INDEX_REG, \
  329. IO_BLT_START_STATUS_REG | ((val) << 8)); \
  330. }
  331. #define CP_IO_FG_COLOR(ppdev, pjPorts, val) \
  332. { \
  333. if (ppdev->flCaps & CAPS_TRUE_COLOR) \
  334. { \
  335. CP_OUT_WORD(pjPorts, INDEX_REG, \
  336. IO_BLT_FG_COLOR_BYTE_3 | (((val) & 0xff000000) >> 16)); \
  337. CP_OUT_WORD(pjPorts, INDEX_REG, \
  338. IO_BLT_FG_COLOR_BYTE_2 | (((val) & 0x00ff0000) >> 8)); \
  339. } \
  340. CP_OUT_WORD(pjPorts, INDEX_REG, \
  341. IO_BLT_FG_COLOR_BYTE_1 | ((val) & 0x0000ff00)); \
  342. CP_OUT_WORD(pjPorts, INDEX_REG, \
  343. IO_BLT_FG_COLOR_BYTE_0 | (((val) & 0x000000ff) << 8)); \
  344. }
  345. #define CP_IO_BG_COLOR(ppdev, pjPorts, val) \
  346. { \
  347. if (ppdev->flCaps & CAPS_TRUE_COLOR) \
  348. { \
  349. CP_OUT_WORD(pjPorts, INDEX_REG, \
  350. IO_BLT_BG_COLOR_BYTE_3 | (((val) & 0xff000000) >> 16)); \
  351. CP_OUT_WORD(pjPorts, INDEX_REG, \
  352. IO_BLT_BG_COLOR_BYTE_2 | (((val) & 0x00ff0000) >> 8)); \
  353. } \
  354. CP_OUT_WORD(pjPorts, INDEX_REG, \
  355. IO_BLT_BG_COLOR_BYTE_1 | ((val) & 0x0000ff00)); \
  356. CP_OUT_WORD(pjPorts, INDEX_REG, \
  357. IO_BLT_BG_COLOR_BYTE_0 | (((val) & 0x000000ff) << 8)); \
  358. }
  359. #define CP_IO_XCNT(ppdev, pjPorts, val) \
  360. { \
  361. CP_OUT_WORD(pjPorts, INDEX_REG, \
  362. IO_BLT_WIDTH_HIGH | ((val) & 0xff00)); \
  363. CP_OUT_WORD(pjPorts, INDEX_REG, \
  364. IO_BLT_WIDTH_LOW | (((val) & 0x00ff) << 8)); \
  365. }
  366. #define CP_IO_YCNT(ppdev, pjPorts, val) \
  367. { \
  368. CP_OUT_WORD(pjPorts, INDEX_REG, \
  369. IO_BLT_HEIGHT_HIGH | ((val) & 0xff00)); \
  370. CP_OUT_WORD(pjPorts, INDEX_REG, \
  371. IO_BLT_HEIGHT_LOW | (((val) & 0x00ff) << 8)); \
  372. }
  373. #define CP_IO_DST_ADDR(ppdev, pjPorts, relval) \
  374. { \
  375. LONG val = ((relval) + ppdev->xyOffset); \
  376. CP_OUT_WORD(pjPorts, INDEX_REG, \
  377. IO_BLT_DST_ADDR_HIGH | (((val) & 0xff0000) >> 8)); \
  378. CP_OUT_WORD(pjPorts, INDEX_REG, \
  379. IO_BLT_DST_ADDR_MID | ((val) & 0x00ff00)); \
  380. CP_OUT_WORD(pjPorts, INDEX_REG, \
  381. IO_BLT_DST_ADDR_LOW | (((val) & 0x0000ff) << 8)); \
  382. }
  383. #define CP_IO_DST_ADDR_ABS(ppdev, pjPorts, val) \
  384. { \
  385. CP_OUT_WORD(pjPorts, INDEX_REG, \
  386. IO_BLT_DST_ADDR_HIGH | (((val) & 0xff0000) >> 8)); \
  387. CP_OUT_WORD(pjPorts, INDEX_REG, \
  388. IO_BLT_DST_ADDR_MID | ((val) & 0x00ff00)); \
  389. CP_OUT_WORD(pjPorts, INDEX_REG, \
  390. IO_BLT_DST_ADDR_LOW | (((val) & 0x0000ff) << 8)); \
  391. }
  392. #if 1 // D5480
  393. #define CP_IO_BLT_EXT_MODE(ppdev, pjPorts, val) \
  394. { \
  395. CP_OUT_WORD(pjPorts, INDEX_REG, (IO_BLT_EXT_MODE | ((val)<<8))); \
  396. }
  397. #define CP_IO_DST_XY(ppdev, pjPorts, x, y) \
  398. { \
  399. CP_OUT_WORD(pjPorts, INDEX_REG, \
  400. IO_BLT_DST_X_HIGH | ((x) & 0x00ff00)); \
  401. CP_OUT_WORD(pjPorts, INDEX_REG, \
  402. IO_BLT_DST_X_LOW | (((x) & 0x0000ff) << 8)); \
  403. CP_OUT_WORD(pjPorts, INDEX_REG, \
  404. IO_BLT_DST_Y_HIGH | ((y) & 0x00ff00)); \
  405. CP_OUT_WORD(pjPorts, INDEX_REG, \
  406. IO_BLT_DST_Y_LOW | (((y) & 0x0000ff) << 8)); \
  407. }
  408. #define CP_IO_DST_X(ppdev, pjPorts, x) \
  409. { \
  410. CP_OUT_WORD(pjPorts, INDEX_REG, \
  411. IO_BLT_DST_X_HIGH | ((x) & 0x00ff00)); \
  412. CP_OUT_WORD(pjPorts, INDEX_REG, \
  413. IO_BLT_DST_X_LOW | (((x) & 0x0000ff) << 8)); \
  414. }
  415. #define CP_IO_DST_Y(ppdev, pjPorts, y) \
  416. { \
  417. CP_OUT_WORD(pjPorts, INDEX_REG, \
  418. IO_BLT_DST_Y_HIGH | ((y) & 0x00ff00)); \
  419. CP_OUT_WORD(pjPorts, INDEX_REG, \
  420. IO_BLT_DST_Y_LOW | (((y) & 0x0000ff) << 8)); \
  421. }
  422. #define CP_IO_SRC_XY(ppdev, pjPorts, x, y) \
  423. { \
  424. CP_OUT_WORD(pjPorts, INDEX_REG, \
  425. IO_BLT_SRC_X_HIGH | ((x) & 0x00ff00)); \
  426. CP_OUT_WORD(pjPorts, INDEX_REG, \
  427. IO_BLT_SRC_X_LOW | (((x) & 0x0000ff) << 8)); \
  428. CP_OUT_WORD(pjPorts, INDEX_REG, \
  429. IO_BLT_SRC_Y_HIGH | ((y) & 0x00ff00)); \
  430. CP_OUT_WORD(pjPorts, INDEX_REG, \
  431. IO_BLT_SRC_Y_LOW | (((y) & 0x0000ff) << 8)); \
  432. }
  433. #define CP_IO_CLIP_ULXY(ppdev, pjPorts, x, y) \
  434. { \
  435. CP_OUT_WORD(pjPorts, INDEX_REG, \
  436. IO_BLT_CLIP_ULX_HIGH | ((x) & 0x00ff00)); \
  437. CP_OUT_WORD(pjPorts, INDEX_REG, \
  438. IO_BLT_CLIP_ULX_LOW | (((x) & 0x0000ff) << 8)); \
  439. CP_OUT_WORD(pjPorts, INDEX_REG, \
  440. IO_BLT_CLIP_ULY_HIGH | ((y) & 0x00ff00)); \
  441. CP_OUT_WORD(pjPorts, INDEX_REG, \
  442. IO_BLT_CLIP_ULY_LOW | (((y) & 0x0000ff) << 8)); \
  443. }
  444. #define CP_IO_CLIP_LRXY(ppdev, pjPorts, x, y) \
  445. { \
  446. CP_OUT_WORD(pjPorts, INDEX_REG, \
  447. IO_BLT_CLIP_LRX_HIGH | ((x) & 0x00ff00)); \
  448. CP_OUT_WORD(pjPorts, INDEX_REG, \
  449. IO_BLT_CLIP_LRX_LOW | (((x) & 0x0000ff) << 8)); \
  450. CP_OUT_WORD(pjPorts, INDEX_REG, \
  451. IO_BLT_CLIP_LRY_HIGH | ((y) & 0x00ff00)); \
  452. CP_OUT_WORD(pjPorts, INDEX_REG, \
  453. IO_BLT_CLIP_LRY_LOW | (((y) & 0x0000ff) << 8)); \
  454. }
  455. #endif // endif D5480
  456. ////////////////////////////////////////////////////////////////////////////////
  457. // Hardware registers //
  458. ////////////////////////////////////////////////////////////////////////////////
  459. #if 1 // D5480
  460. #define ENABLE_SOLID_FILL_PACKED 0x04000000
  461. #define INVERT_SOURCE_PACKED 0x02000000
  462. #define SOURCE_GRANULARITY_PACKED 0x01000000
  463. #define ENABLE_COMMAND_LIST_PACKED 0x80000000
  464. #define ENABLE_XY_POSITION_PACKED 0x40000000
  465. #define ENABLE_CLIP_RECT_PACKED 0x20000000
  466. #endif // endif D5480
  467. #if 1 // D5480
  468. #define ENABLE_COMMAND_LIST 0x80
  469. #define ENABLE_XY_POSITION 0x40
  470. #define ENABLE_CLIP_RECT 0x20
  471. #endif // endif D5480
  472. #define ENABLE_COLOR_EXPAND 0x80
  473. #define ENABLE_8x8_PATTERN_COPY 0x40
  474. #define SET_16BPP_COLOR 0x10
  475. #define SET_24BPP_COLOR 0x20
  476. #define SET_32BPP_COLOR 0x30
  477. #define ENABLE_TRANSPARENCY_COMPARE 0x08
  478. #define SRC_CPU_DATA 0x04
  479. #define DST_CPU_DATA 0x02
  480. #define DECREMENT_BLT_ADDRESS 0x01
  481. #define ENABLE_SOLID_FILL 0x04
  482. #define INVERT_SOURCE 0x02
  483. #define SOURCE_GRANULARITY 0x01
  484. #define IO_BLT_XPAR_COLOR_LOW 0x34
  485. #define IO_BLT_XPAR_COLOR_HIGH 0x35
  486. #define IO_BLT_XPAR_COLOR_MASK_LOW 0x38
  487. #define IO_BLT_XPAR_COLOR_MASK_HIGH 0x39
  488. #define IO_BLT_BG_COLOR_BYTE_0 0x00
  489. #define IO_BLT_BG_COLOR_BYTE_1 0x10
  490. #define IO_BLT_BG_COLOR_BYTE_2 0x12
  491. #define IO_BLT_BG_COLOR_BYTE_3 0x14
  492. #define IO_BLT_FG_COLOR_BYTE_0 0x01
  493. #define IO_BLT_FG_COLOR_BYTE_1 0x11
  494. #define IO_BLT_FG_COLOR_BYTE_2 0x13
  495. #define IO_BLT_FG_COLOR_BYTE_3 0x15
  496. #define IO_BLT_WIDTH_LOW 0x20
  497. #define IO_BLT_WIDTH_HIGH 0x21
  498. #define IO_BLT_HEIGHT_LOW 0x22
  499. #define IO_BLT_HEIGHT_HIGH 0x23
  500. #define IO_BLT_DST_PITCH_LOW 0x24
  501. #define IO_BLT_DST_PITCH_HIGH 0x25
  502. #define IO_BLT_SRC_PITCH_LOW 0x26
  503. #define IO_BLT_SRC_PITCH_HIGH 0x27
  504. #define IO_BLT_DST_ADDR_LOW 0x28
  505. #define IO_BLT_DST_ADDR_MID 0x29
  506. #define IO_BLT_DST_ADDR_HIGH 0x2A
  507. #define IO_BLT_SRC_ADDR_LOW 0x2C
  508. #define IO_BLT_SRC_ADDR_MID 0x2D
  509. #define IO_BLT_SRC_ADDR_HIGH 0x2E
  510. #define IO_BLT_MODE 0x30
  511. #define IO_BLT_ROP 0x32
  512. #define IO_BLT_START_STATUS_REG 0x31
  513. #if 1 // D5480
  514. #define IO_BLT_EXT_MODE 0x33
  515. #define IO_BLT_DST_X_LOW 0x40
  516. #define IO_BLT_DST_X_HIGH 0x41
  517. #define IO_BLT_DST_Y_LOW 0x42
  518. #define IO_BLT_DST_Y_HIGH 0x43
  519. #define IO_BLT_SRC_X_LOW 0x44
  520. #define IO_BLT_SRC_X_HIGH 0x45
  521. #define IO_BLT_SRC_Y_LOW 0x46
  522. #define IO_BLT_SRC_Y_HIGH 0x47
  523. #define IO_BLT_CLIP_ULX_LOW 0x48
  524. #define IO_BLT_CLIP_ULX_HIGH 0x49
  525. #define IO_BLT_CLIP_ULY_LOW 0x4A
  526. #define IO_BLT_CLIP_ULY_HIGH 0x4B
  527. #define IO_BLT_CLIP_LRX_LOW 0x4C
  528. #define IO_BLT_CLIP_LRX_HIGH 0x4D
  529. #define IO_BLT_CLIP_LRY_LOW 0x4E
  530. #define IO_BLT_CLIP_LRY_HIGH 0x4F
  531. #endif // endif D5480
  532. #define MM_BLT_BG_COLOR 0x00
  533. #define MM_BLT_FG_COLOR 0x04
  534. #define MM_BLT_WIDTH 0x08
  535. #define MM_BLT_HEIGHT 0x0A
  536. #define MM_BLT_DST_PITCH 0x0C
  537. #define MM_BLT_SRC_PITCH 0x0E
  538. #define MM_BLT_DST_ADDR 0x10
  539. #define MM_BLT_SRC_ADDR 0x14
  540. #define MM_BLT_DST_WRITE_MASK 0x17
  541. #define MM_BLT_MODE 0x18
  542. #define MM_BLT_ROP 0x1A
  543. #define MM_BLT_EXT 0x1B
  544. #define MM_BLT_COLOR_KEY 0x1C
  545. #define MM_BLT_START_STATUS_REG 0x40
  546. #if 1 // D5480
  547. #define MM_BLT_DST_X 0x28
  548. #define MM_BLT_DST_Y 0x2A
  549. #define MM_BLT_SRC_X 0x2C
  550. #define MM_BLT_SRC_Y 0x2E
  551. #define MM_BLT_CLIP_ULX 0x30
  552. #define MM_BLT_CLIP_LRX 0x34
  553. #endif // endif D5480
  554. #define DIR_TBLR 0x00 // Top-Bottom, Left-Right
  555. #define DIR_BTRL 0x01 // Bottom-Top, Right-Left
  556. #define BLT_AUTO_START 0x80
  557. #define BLT_SECOND_APERTURE 0x40 // second aperture, sge01
  558. #define BLT_PROGRESS_STATUS 0x08
  559. #define BLT_RESET 0x04
  560. #define BLT_START 0x02
  561. #define BLT_SUSPEND 0x02
  562. #define BLT_STATUS 0x01
  563. ////////////////////////////////////////////////////////////////////////////////
  564. // Some handy clipping control structures //
  565. ////////////////////////////////////////////////////////////////////////////////
  566. typedef struct {
  567. ULONG c;
  568. RECTL arcl[8];
  569. } ENUMRECTS8, *PENUMRECTS8;
  570. //
  571. // The following two macros touch registers which are only available
  572. // on the 5446 and 5480. Only set these registers if we are on one
  573. // of these chips.
  574. //
  575. #define CP_IO_XPAR_COLOR(ppdev, pjPorts, val) \
  576. { \
  577. if (ppdev->flCaps & CAPS_TRANSPARENCY) { \
  578. CP_OUT_WORD(pjPorts, INDEX_REG, \
  579. IO_BLT_XPAR_COLOR_HIGH | ((val) & 0xff00)); \
  580. CP_OUT_WORD(pjPorts, INDEX_REG, \
  581. IO_BLT_XPAR_COLOR_LOW | (((val) & 0x00ff) << 8)); \
  582. } \
  583. }
  584. #define CP_IO_XPAR_COLOR_MASK(ppdev, pjPorts, val) \
  585. { \
  586. if (ppdev->flCaps & CAPS_TRANSPARENCY) { \
  587. CP_OUT_WORD(pjPorts, INDEX_REG, \
  588. IO_BLT_XPAR_COLOR_MASK_HIGH | ((val) & 0xff00)); \
  589. CP_OUT_WORD(pjPorts, INDEX_REG, \
  590. IO_BLT_XPAR_COLOR_MASK_LOW | (((val) & 0x00ff) << 8)); \
  591. } \
  592. }
  593. ////////////////////////////////////////////////////////////////////////////////
  594. // MM IO settings //
  595. ////////////////////////////////////////////////////////////////////////////////
  596. #define CP_SET_MM_IO_FLAGS(ppdev, pjPorts, val) \
  597. { \
  598. CP_OUT_WORD(pjPorts, SR_INDEX, (0x17 | (val << 8))); \
  599. }
  600. #define CP_GET_MM_IO_FLAGS(ppdev, pjPorts) \
  601. ( \
  602. CP_OUT_BYTE(pjPorts, SR_INDEX, 0x17), \
  603. CP_IN_BYTE(pjPorts, SR_DATA) \
  604. )
  605. #define CP_ENABLE_MM_IO(ppdev, pjPorts) \
  606. { \
  607. BYTE jAttr; \
  608. ppdev->flCaps |= CAPS_MM_IO; \
  609. jAttr = CP_GET_MM_IO_FLAGS(ppdev, pjPorts); \
  610. jAttr |= 0x4; \
  611. jAttr &= ~0x40; \
  612. CP_SET_MM_IO_FLAGS(ppdev, pjPorts, jAttr); \
  613. }
  614. #define CP_DISABLE_MM_IO(ppdev, pjPorts) \
  615. { \
  616. BYTE jAttr; \
  617. if (ppdev->flCaps & CAPS_MM_IO) \
  618. { \
  619. CP_MM_WAIT_FOR_BLT_COMPLETE(ppdev, ppdev->pjBase); \
  620. } \
  621. else \
  622. { \
  623. CP_IO_WAIT_FOR_BLT_COMPLETE(ppdev, pjPorts); \
  624. } \
  625. ppdev->flCaps &= ~CAPS_MM_IO; \
  626. jAttr = CP_GET_MM_IO_FLAGS(ppdev, pjPorts); \
  627. jAttr &= ~0x4; \
  628. CP_SET_MM_IO_FLAGS(ppdev, pjPorts, jAttr); \
  629. }
  630. #define WAIT_COUNT 0x100000
  631. // #if DBG //DBG
  632. #if (DBG_STRESS_FAILURE || DBG)
  633. #define WAIT_BUSY_BLT(ppdev, pjBase) \
  634. { \
  635. ULONG ul = 0; \
  636. do \
  637. { \
  638. ul++; \
  639. if (ul >= WAIT_COUNT) \
  640. { \
  641. DISPDBG((0, "WAIT_BUSY_BLT timeout" \
  642. " file(%s) line(%d)", __FILE__, __LINE__)); \
  643. DISPDBG((0, "Last start blt was at file(%s) line(%d)", \
  644. glpszLastBltFile, gulLastBltLine)); \
  645. DISPDBG((0, "press 'g' to continue...")); EngDebugBreak(); \
  646. ul = 0; \
  647. } \
  648. } while (CP_MM_ACL_STAT(ppdev, pjBase) & 0x10); \
  649. }
  650. extern ULONG gulLastBltLine;
  651. extern CHAR * glpszLastBltFile;
  652. extern BOOL gbResetOnTimeout;
  653. ////////////////////////////////////////////////////////////////////////////
  654. // Wait for the Blt Operation to Complete //
  655. ////////////////////////////////////////////////////////////////////////////
  656. #define CP_IO_WAIT_FOR_BLT_COMPLETE(ppdev, pjPorts) \
  657. { \
  658. ULONG ul = 0; \
  659. do \
  660. { \
  661. ul++; \
  662. if (ul >= WAIT_COUNT) \
  663. { \
  664. DISPDBG((0, "WAIT_FOR_BLT_COMPLETE timeout" \
  665. " file(%s) line(%d)", __FILE__, __LINE__)); \
  666. DISPDBG((0,"Last start blt was at file(%s) line(%d)", \
  667. glpszLastBltFile, gulLastBltLine)); \
  668. DISPDBG((0, "press 'g' to continue...")); EngDebugBreak(); \
  669. ul = 0; \
  670. if (gbResetOnTimeout) \
  671. { \
  672. CP_IO_START_REG(ppdev, pjPorts, BLT_RESET); \
  673. } \
  674. } \
  675. } while (CP_IO_ACL_STAT(ppdev, pjPorts) & BLT_STATUS); \
  676. }
  677. #define CP_MM_WAIT_FOR_BLT_COMPLETE(ppdev, pjBase) \
  678. { \
  679. ULONG ul = 0; \
  680. do \
  681. { \
  682. ul++; \
  683. if (ul >= WAIT_COUNT) \
  684. { \
  685. DISPDBG((0, "WAIT_FOR_BLT_COMPLETE timeout" \
  686. " file(%s) line(%d)", __FILE__, __LINE__)); \
  687. DISPDBG((0, "Last start blt was at file(%s) line(%d)", \
  688. glpszLastBltFile, gulLastBltLine)); \
  689. DISPDBG((0, "press 'g' to continue...")); EngDebugBreak(); \
  690. ul = 0; \
  691. if (gbResetOnTimeout) \
  692. { \
  693. CP_MM_START_REG(ppdev, pjBase, BLT_RESET); \
  694. } \
  695. } \
  696. } while (CP_MM_ACL_STAT(ppdev, pjBase) & BLT_STATUS); \
  697. }
  698. ////////////////////////////////////////////////////////////////////////////
  699. // Start the Blt Operation - save debug info //
  700. ////////////////////////////////////////////////////////////////////////////
  701. #define CP_IO_START_BLT(ppdev, pjPorts) \
  702. { \
  703. DISPDBG((5, "START_BLT file(%s) line(%d)", __FILE__, __LINE__)); \
  704. gulLastBltLine = __LINE__; \
  705. glpszLastBltFile = __FILE__; \
  706. CP_IO_START_REG(ppdev, pjPorts, BLT_START); \
  707. }
  708. #define CP_MM_START_BLT(ppdev, pjBase) \
  709. { \
  710. DISPDBG((5, "START_BLT file(%s) line(%d)", __FILE__, __LINE__)); \
  711. gulLastBltLine = __LINE__; \
  712. glpszLastBltFile = __FILE__; \
  713. if (!(ppdev->flCaps & CAPS_AUTOSTART)) \
  714. { \
  715. CP_MM_START_REG(ppdev, pjBase, BLT_START); \
  716. } \
  717. }
  718. #else
  719. #define WAIT_BUSY_BLT(ppdev, pjBase) \
  720. while (CP_MM_ACL_STAT(ppdev, pjBase) & 0x10)
  721. ////////////////////////////////////////////////////////////////////////////
  722. // Wait for the Blt Operation to Complete //
  723. ////////////////////////////////////////////////////////////////////////////
  724. #define CP_IO_WAIT_FOR_BLT_COMPLETE(ppdev, pjPorts) \
  725. { \
  726. while (CP_IO_ACL_STAT(ppdev, pjPorts) & BLT_STATUS); \
  727. }
  728. #define CP_MM_WAIT_FOR_BLT_COMPLETE(ppdev, pjBase) \
  729. { \
  730. while (CP_MM_ACL_STAT(ppdev, pjBase) & BLT_STATUS); \
  731. }
  732. ////////////////////////////////////////////////////////////////////////////
  733. // Start the Blt Operation //
  734. ////////////////////////////////////////////////////////////////////////////
  735. #define CP_IO_START_BLT(ppdev, pjPorts) \
  736. { \
  737. CP_IO_START_REG(ppdev, pjPorts, BLT_START); \
  738. }
  739. #define CP_MM_START_BLT(ppdev, pjBase) \
  740. { \
  741. if (!(ppdev->flCaps & CAPS_AUTOSTART)) \
  742. { \
  743. CP_MM_START_REG(ppdev, pjBase, BLT_START); \
  744. } \
  745. }
  746. #endif
  747. ////////////////////////////////////////////////////////////////////////////////
  748. // TRANSFER_DWORD //
  749. // 32-bit transfers to host transfer buffer, the source has to be aligned //
  750. ////////////////////////////////////////////////////////////////////////////////
  751. #define TRANSFER_DWORD_ALIGNED(ppdev, pulXfer, p, c) \
  752. { \
  753. ULONG mcd = (ULONG)(c); \
  754. ULONG* mpdSrc = (ULONG*) (p); \
  755. ASSERTDD((((ULONG_PTR) p) & 3) == 0, "Transfer not dword aligned"); \
  756. ASSERTDD((c) > 0, "Can't have a zero transfer count"); \
  757. \
  758. CP_EIEIO(); \
  759. do { \
  760. CP_MEMORY_BARRIER(); \
  761. /* *pulXfer = *mpdSrc++; */ \
  762. WRITE_REGISTER_ULONG((PULONG)(pulXfer), *mpdSrc); \
  763. mpdSrc++; \
  764. } while (--mcd); \
  765. }
  766. ////////////////////////////////////////////////////////////////////////////////
  767. // TRANSFER_DWORD //
  768. // 32-bit transfers to host transfer buffer, the source has not to be aligned //
  769. ////////////////////////////////////////////////////////////////////////////////
  770. #define TRANSFER_DWORD(ppdev, pulXfer, p, c) \
  771. { \
  772. ULONG mcd = (c); \
  773. ULONG UNALIGNED* mpdSrc = (ULONG*) (p); \
  774. ASSERTDD((c) > 0, "Can't have a zero transfer count"); \
  775. \
  776. CP_EIEIO(); \
  777. do { \
  778. CP_MEMORY_BARRIER(); \
  779. /* *pulXfer = *mpdSrc++; */ \
  780. WRITE_REGISTER_ULONG((PULONG)(pulXfer), *mpdSrc); \
  781. mpdSrc++; \
  782. } while (--mcd); \
  783. }
  784. #if 1 // D5480
  785. ////////////////////////////////////////////////////////////////////////////////
  786. // Command List stuff //
  787. ////////////////////////////////////////////////////////////////////////////////
  788. #define COMMAND_TOTAL_PACKETS 127 // We support 128 packets.
  789. #define COMMAND_BUFFER_SIZE 4096
  790. #define COMMAND_BUFFER_ALIGN 255
  791. #define COMMAND_LAST_PACKET 0x80000000
  792. #define COMMAND_DISCARD_SRC 0x40000000
  793. #define COMMAND_FOURTH_NOTHING 0x30000000
  794. #define COMMAND_FOURTH_BLT_ROP 0x10000000
  795. #define COMMAND_FOURTH_DST_SRC 0x00000000
  796. #define COMMAND_NOSRC_NOTHING 0x70000000
  797. #define CP_MM_CL_SWITCH(ppdev) \
  798. { \
  799. if( ppdev->pCommandList == ppdev->pCLFirst ) \
  800. ppdev->pCommandList = ppdev->pCLSecond; \
  801. else \
  802. ppdev->pCommandList = ppdev->pCLFirst; \
  803. }
  804. #endif // endif D5480
  805. ////////////////////////////////////////////////////////////////////////////////
  806. // Pointer stuff //
  807. ////////////////////////////////////////////////////////////////////////////////
  808. #define SPRITE_BUFFER_SIZE 256
  809. #define POINTER_X_POSITION 0x10
  810. #define POINTER_Y_POSITION 0x11
  811. #define POINTER_ATTRIBUTES 0x12
  812. #define POINTER_OFFSET 0x13
  813. #define ENABLE_POINTER 0x01
  814. #define ALLOW_DAC_ACCESS_TO_EXT_COLORS 0x02
  815. #define POINTER_SIZE_64x64 0x04
  816. #define OVERSCAN_COLOR_PROTECT 0x80
  817. #define POINTER_X_SHIFT 0x01
  818. #define POINTER_Y_SHIFT 0x02
  819. #define POINTER_SHAPE_RESET 0x04
  820. #define POINTER_DISABLED 0x08
  821. #define CP_PTR_XY_POS(ppdev, pjPorts, x, y) \
  822. { \
  823. DISPDBG((10, "\t CP_PTR_XY_POS (%d,%d)", x, y)); \
  824. CP_OUT_WORD(pjPorts, SR_INDEX, \
  825. (POINTER_Y_POSITION | ((y & 0x7) << 5)) | ((y & 0x7f8) << 5)); \
  826. CP_OUT_WORD(pjPorts, SR_INDEX, \
  827. (POINTER_X_POSITION | ((x & 0x7) << 5)) | ((x & 0x7f8) << 5)); \
  828. /* [HWBUG] - must set position twice */ \
  829. CP_OUT_WORD(pjPorts, SR_INDEX, \
  830. (POINTER_Y_POSITION | ((y & 0x7) << 5)) | ((y & 0x7f8) << 5)); \
  831. CP_OUT_WORD(pjPorts, SR_INDEX, \
  832. (POINTER_X_POSITION | ((x & 0x7) << 5)) | ((x & 0x7f8) << 5)); \
  833. }
  834. #define CP_PTR_SET_FLAGS(ppdev, pjPorts, val) \
  835. { \
  836. CP_OUT_WORD(pjPorts, SR_INDEX, POINTER_ATTRIBUTES | (val << 8)); \
  837. }
  838. #define CP_PTR_GET_FLAGS(ppdev, pjPorts) \
  839. ( \
  840. CP_OUT_BYTE(pjPorts, SR_INDEX, POINTER_ATTRIBUTES), \
  841. CP_IN_BYTE(pjPorts, SR_DATA) \
  842. )
  843. #define CP_PTR_ADDR(ppdev, pjPorts, val) \
  844. { \
  845. CP_OUT_WORD(pjPorts, SR_INDEX, POINTER_OFFSET | (val << 8)); \
  846. }
  847. #define CP_PTR_ENABLE(ppdev, pjPorts) \
  848. { \
  849. BYTE jAttr; \
  850. DISPDBG((10, "\t CP_PTR_ENABLE")); \
  851. if (ppdev->flPointer & POINTER_DISABLED) \
  852. { \
  853. ppdev->flPointer &= ~POINTER_DISABLED; \
  854. jAttr = CP_PTR_GET_FLAGS(ppdev, pjPorts); \
  855. jAttr |= ENABLE_POINTER; \
  856. CP_PTR_SET_FLAGS(ppdev, pjPorts, jAttr); \
  857. DISPDBG((10, "\t CP_PTR_ENABLE - done")); \
  858. } \
  859. }
  860. #define CP_PTR_DISABLE(ppdev, pjPorts) \
  861. { \
  862. BYTE jAttr; \
  863. DISPDBG((10, "\t CP_PTR_DISABLE")); \
  864. if (!(ppdev->flPointer & POINTER_DISABLED)) \
  865. { \
  866. ppdev->flPointer |= POINTER_DISABLED; \
  867. jAttr = CP_PTR_GET_FLAGS(ppdev, pjPorts); \
  868. jAttr &= ~ENABLE_POINTER; \
  869. CP_PTR_SET_FLAGS(ppdev, pjPorts, jAttr); \
  870. CP_PTR_XY_POS(ppdev, pjPorts, 2047, 2047); \
  871. DISPDBG((10, "\t CP_PTR_DISABLE - done")); \
  872. } \
  873. }
  874. ////////////////////////////////////////////////////////////////////////////////
  875. // ROP definitions for the hardware //
  876. ////////////////////////////////////////////////////////////////////////////////
  877. #define R3_BLACKNESS 0x00 // dest = BLACK
  878. #define R3_NOTSRCERASE 0x11 // dest = (NOT src) AND (NOT dest)
  879. #define R3_NOTSRCCOPY 0x33 // dest = (NOT source)
  880. #define R3_SRCERASE 0x44 // dest = source AND (NOT dest )
  881. #define R3_DSTINVERT 0x55 // dest = (NOT dest)
  882. #define R3_PATINVERT 0x5A // dest = pattern XOR dest
  883. #define R3_SRCINVERT 0x66 // dest = source XOR dest
  884. #define R3_SRCAND 0x88 // dest = source AND dest
  885. #define R3_NOP 0xAA // dest = dest
  886. #define R3_MERGEPAINT 0xBB // dest = (NOT source) OR dest
  887. #define R3_MERGECOPY 0xC0 // dest = (source AND pattern)
  888. #define R3_SRCCOPY 0xCC // dest = source
  889. #define R3_SRCPAINT 0xEE // dest = source OR dest
  890. #define R3_PATCOPY 0xF0 // dest = pattern
  891. #define R3_PATPAINT 0xFB // dest = DPSnoo
  892. #define R3_WHITENESS 0xFF // dest = WHITE
  893. #define R4_BLACKNESS 0x0000 // dest = BLACK
  894. #define R4_NOTSRCERASE 0x1111 // dest = (NOT src) AND (NOT dest)
  895. #define R4_NOTSRCCOPY 0x3333 // dest = (NOT source)
  896. #define R4_SRCERASE 0x4444 // dest = source AND (NOT dest )
  897. #define R4_DSTINVERT 0x5555 // dest = (NOT dest)
  898. #define R4_PATINVERT 0x5A5A // dest = pattern XOR dest
  899. #define R4_SRCINVERT 0x6666 // dest = source XOR dest
  900. #define R4_SRCAND 0x8888 // dest = source AND dest
  901. #define R4_MERGEPAINT 0xBBBB // dest = (NOT source) OR dest
  902. #define R4_MERGECOPY 0xC0C0 // dest = (source AND pattern)
  903. #define R4_SRCCOPY 0xCCCC // dest = source
  904. #define R4_SRCPAINT 0xEEEE // dest = source OR dest
  905. #define R4_PATCOPY 0xF0F0 // dest = pattern
  906. #define R4_PATPAINT 0xFBFB // dest = DPSnoo
  907. #define R4_WHITENESS 0xFFFF // dest = WHITE
  908. #define HW_0 0x00
  909. #define HW_1 0x0E
  910. #define HW_P 0x0D
  911. #define HW_D 0x06
  912. #define HW_Pn 0xD0
  913. #define HW_Dn 0x0B
  914. #define HW_DPa 0x05
  915. #define HW_PDna 0x09
  916. #define HW_DPna 0x50
  917. #define HW_DPon 0x90
  918. #define HW_DPo 0x6D
  919. #define HW_PDno 0xAD
  920. #define HW_DPno 0xD6
  921. #define HW_DPan 0xDA
  922. #define HW_DPx 0x59
  923. #define HW_DPxn 0x95
  924. #define CL_BLACKNESS HW_0
  925. #define CL_WHITENESS HW_1
  926. #define CL_SRC_COPY HW_P
  927. #define CL_DST HW_D
  928. #define CL_NOT_SRC_COPY HW_Pn
  929. #define CL_DST_INVERT HW_Dn
  930. #define CL_SRC_AND HW_DPa
  931. #define CL_SRC_ERASE HW_PDna
  932. #define CL_NOT_SRC_OR_DST HW_DPna
  933. #define CL_NOT_SRC_ERASE HW_DPon
  934. #define CL_SRC_PAINT HW_DPo
  935. #define CL_SRC_AND_NOT_DST HW_PDno
  936. #define CL_MERGE_PAINT HW_DPno
  937. #define CL_NOT_SRC_AND_NOT_DST HW_DPan
  938. #define CL_SRC_INVERT HW_DPx
  939. #define CL_NOT_SRC HW_PDxn
  940. #if 1 // D5480
  941. #define HW_PACKED_0 0x000000
  942. #define HW_PACKED_1 0x0E0000
  943. #define HW_PACKED_P 0x0D0000
  944. #define HW_PACKED_D 0x060000
  945. #define HW_PACKED_Pn 0xD00000
  946. #define HW_PACKED_Dn 0x0B0000
  947. #define HW_PACKED_DPa 0x050000
  948. #define HW_PACKED_PDna 0x090000
  949. #define HW_PACKED_DPna 0x500000
  950. #define HW_PACKED_DPon 0x900000
  951. #define HW_PACKED_DPo 0x6D0000
  952. #define HW_PACKED_PDno 0xAD0000
  953. #define HW_PACKED_DPno 0xD60000
  954. #define HW_PACKED_DPan 0xDA0000
  955. #define HW_PACKED_DPx 0x590000
  956. #define HW_PACKED_DPxn 0x950000
  957. #define CL_PACKED_BLACKNESS HW_PACKED_0
  958. #define CL_PACKED_WHITENESS HW_PACKED_1
  959. #define CL_PACKED_SRC_COPY HW_PACKED_P
  960. #define CL_PACKED_DST HW_PACKED_D
  961. #define CL_PACKED_NOT_SRC_COPY HW_PACKED_Pn
  962. #define CL_PACKED_DST_INVERT HW_PACKED_Dn
  963. #define CL_PACKED_SRC_AND HW_PACKED_DPa
  964. #define CL_PACKED_SRC_ERASE HW_PACKED_PDna
  965. #define CL_PACKED_NOT_SRC_OR_DST HW_PACKED_DPna
  966. #define CL_PACKED_NOT_SRC_ERASE HW_PACKED_DPon
  967. #define CL_PACKED_SRC_PAINT HW_PACKED_DPo
  968. #define CL_PACKED_SRC_AND_NOT_DST HW_PACKED_PDno
  969. #define CL_PACKED_MERGE_PAINT HW_PACKED_DPno
  970. #define CL_PACKED_NOT_SRC_AND_NOT_DST HW_PACKED_DPan
  971. #define CL_PACKED_SRC_INVERT HW_PACKED_DPx
  972. #define CL_PACKED_NOT_SRC HW_PACKED_PDxn
  973. #endif // endif D5480