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.

667 lines
29 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) 1994-1995 Microsoft Corporation
  8. *
  9. \**************************************************************************/
  10. #define GC_INDEX 0x3CE /* Index and Data Registers */
  11. #define GC_DATA 0x3CF
  12. #define SEQ_INDEX 0x3C4
  13. #define SEQ_DATA 0x3C5
  14. #define CRTC_INDEX 0x3D4
  15. #define CRTC_DATA 0x3D5
  16. #define ATTR_INDEX 0x3C0
  17. #define ATTR_DATA 0x3C0
  18. #define ATTR_DATA_READ 0x3C1
  19. #define MISC_OUTPUT 0x3C2
  20. #define MISC_OUTPUT_READ 0x3CC
  21. #define INPUT_STATUS_REG_1 0x3DA
  22. #define CTRL_REG_0 0x40
  23. #define CTRL_REG_1 0x63CA /* Datapath Registers */
  24. #define DATAPATH_CTRL 0x5A
  25. #define GC_FG_COLOR 0x43
  26. #define GC_BG_COLOR 0x44
  27. #define SEQ_PIXEL_WR_MSK 0x02
  28. #define GC_PLANE_WR_MSK 0x08
  29. #define ROP_A 0x33C7
  30. #define ROP_0 0x33C5
  31. #define ROP_1 0x33C4
  32. #define ROP_2 0x33C3
  33. #define ROP_3 0x33C2
  34. #define DATA_ROTATE 0x03
  35. #define READ_CTRL 0x41
  36. #define X0_SRC_ADDR_LO 0x63C0 /* BitBLT Registers */
  37. #define Y0_SRC_ADDR_HI 0x63C2
  38. #define DEST_ADDR_LO 0x63CC
  39. #define DEST_ADDR_HI 0x63CE
  40. #define BITMAP_WIDTH 0x23C2
  41. #define BITMAP_HEIGHT 0x23C4
  42. #define SRC_PITCH 0x23CA
  43. #define DEST_PITCH 0x23CE
  44. #define BLT_CMD_0 0x33CE
  45. #define BLT_CMD_1 0x33CF
  46. #define PREG_0 0x33CA
  47. #define PREG_1 0x33CB
  48. #define PREG_2 0x33CC
  49. #define PREG_3 0x33CD
  50. #define PREG_4 0x33CA
  51. #define PREG_5 0x33CB
  52. #define PREG_6 0x33CC
  53. #define PREG_7 0x33CD
  54. #define BLT_START_MASK 0x33C0 /* XccelVGA BitBlt Registers */
  55. #define BLT_END_MASK 0x33C1
  56. #define BLT_ROTATE 0x33C8
  57. #define BLT_SKEW_MASK 0x33C9
  58. #define BLT_SRC_ADDR 0x23C0
  59. #define DEST_OFFSET 0x23CC
  60. #define X1 0x83CC /* Line Draw Registers */
  61. #define Y1 0x83CE
  62. #define LINE_PATTERN 0x83C0
  63. #define PATTERN_END 0x62
  64. #define LINE_CMD 0x60
  65. #define LINE_PIX_CNT 0x64
  66. #define LINE_ERR_TERM 0x66
  67. #define SIGN_CODES 0x63
  68. #define X_MAJOR 0x00
  69. #define Y_MAJOR 0x01
  70. #define DELTA_Y_POS 0x00
  71. #define DELTA_Y_NEG 0x02
  72. #define DELTA_X_POS 0x00
  73. #define DELTA_X_NEG 0x04
  74. #define K1_CONST 0x68
  75. #define K2_CONST 0x6A
  76. #define PALETTE_WRITE 0x3C8 /* DAC registers */
  77. #define PALETTE_READ 0x3C7
  78. #define PALETTE_DATA 0x3C9
  79. #define DAC_CMD_0 0x83C6
  80. #define DAC_CMD_1 0x13C8
  81. #define DAC_CMD_2 0x13C9
  82. #define CURSOR_ENABLE 0x02
  83. #define CURSOR_DISABLE 0x00
  84. #define CURSOR_WRITE 0x3C8 /* HW Cursor registers */
  85. #define CURSOR_READ 0x3C7
  86. #define CURSOR_PLANE_0 0x00
  87. #define CURSOR_PLANE_1 0x80
  88. #define CURSOR_DATA 0x13C7
  89. #define CURSOR_COLOR_READ 0x83C7
  90. #define CURSOR_COLOR_WRITE 0x83C8
  91. #define CURSOR_COLOR_DATA 0x83C9
  92. #define OVERSCAN_COLOR 0x00
  93. #define CURSOR_COLOR_1 0x01
  94. #define CURSOR_COLOR_2 0x02
  95. #define CURSOR_COLOR_3 0x03
  96. #define CURSOR_X 0x93C8 /* 16-bit register */
  97. #define CURSOR_Y 0x93C6 /* 16-bit register */
  98. #define CURSOR_CX 32 /* h/w cursor width */
  99. #define CURSOR_CY 32 /* h/w cursor height */
  100. #define PAGE_REG_0 0x45 /* Control Registers */
  101. #define PAGE_REG_1 0x46
  102. #define HI_ADDR_MAP 0x48 /* LO, HI is at 0x49 */
  103. #define ENV_REG_1 0x50
  104. #define VIRT_CTRLR_SEL 0x83C4
  105. #define VER_NUM_REG 0x0C
  106. #define EXT_VER_NUM_REG 0x0D
  107. #define ENV_REG_0 0x0F
  108. #define BLT_CONFIG 0x10
  109. #define CONFIG_STATE 0x52 /* LO, HI is at 0x53 */
  110. #define BIOS_DATA 0x54
  111. #define DATAPATH_CONTROL 0x5A
  112. #define LOCK_KEY_QVISION 0x05
  113. #define EXT_COLOR_MODE 0x01
  114. #define BLT_ENABLE 0x28 /* BLT_CONFIG values */
  115. #define RESET_BLT 0x60 // Make sure we don't enable IRQ9
  116. #define BUFFER_BUSY 0x80 /* CTRL_REG_1 values */
  117. #define GLOBAL_BUSY 0x40
  118. #define BLOCK_WRITE 0x20
  119. #define PACKED_PIXEL_VIEW 0x00
  120. #define PLANAR_VIEW 0x08
  121. #define EXPAND_TO_FG 0x10
  122. #define EXPAND_TO_BG 0x18
  123. #define BITS_PER_PIX_4 0x00
  124. #define BITS_PER_PIX_8 0x02
  125. #define BITS_PER_PIX_16 0x04
  126. #define BITS_PER_PIX_32 0x06
  127. #define ENAB_TRITON_MODE 0x01
  128. #define ROPSELECT_NO_ROPS 0x00 /* DATAPATH_CTRL values */
  129. #define ROPSELECT_PRIMARY_ONLY 0x40
  130. #define ROPSELECT_ALL_EXCPT_PRIMARY 0x80
  131. #define ROPSELECT_ALL 0xc0
  132. #define PIXELMASK_ONLY 0x00
  133. #define PIXELMASK_AND_SRC_DATA 0x10
  134. #define PIXELMASK_AND_CPU_DATA 0x20
  135. #define PIXELMASK_AND_SCRN_LATCHES 0x30
  136. #define PLANARMASK_ONLY 0x00
  137. #define PLANARMASK_NONE_0XFF 0x04
  138. #define PLANARMASK_AND_CPU_DATA 0x08
  139. #define PLANARMASK_AND_SCRN_LATCHES 0x0c
  140. #define SRC_IS_CPU_DATA 0x00
  141. #define SRC_IS_SCRN_LATCHES 0x01
  142. #define SRC_IS_PATTERN_REGS 0x02
  143. #define SRC_IS_LINE_PATTERN 0x03
  144. #define LOGICAL_0 0x00 // 0 (ROP values)
  145. #define NOT_DEST_AND_NOT_SOURCE 0x01 // DSon
  146. #define DEST_AND_NOT_SOURCE 0x02 // DSna
  147. #define NOT_SOURCE 0x03 // Sn
  148. #define NOT_DEST_AND_SOURCE 0x04 // SDna
  149. #define NOT_DEST 0x05 // Dn
  150. #define DEST_XOR_SOURCE 0x06 // DSx
  151. #define NOT_DEST_OR_NOT_SOURCE 0x07 // DSan
  152. #define DEST_AND_SOURCE 0x08 // DSa
  153. #define DEST_XNOR_SOURCE 0x09 // DSxn
  154. #define DEST_DATA 0x0A // D
  155. #define DEST_OR_NOT_SOURCE 0x0B // DSno
  156. #define SOURCE_DATA 0x0C // S
  157. #define NOT_DEST_OR_SOURCE 0x0D // SDno
  158. #define DEST_OR_SOURCE 0x0E // DSo
  159. #define LOGICAL_1 0x0F // 1
  160. #define START_BLT 0x01 /* BLT_CMD_0 values */
  161. #define NO_BYTE_SWAP 0x00
  162. #define BYTE_SWAP 0x20
  163. #define FORWARD 0x00
  164. #define BACKWARD 0x40
  165. #define WRAP 0x00
  166. #define NO_WRAP 0x80
  167. #define PRELOAD 0x02 /* BLT_CMD_0 XccelVGA values */
  168. #define SKIP_LAST 0x04
  169. #define SKIP_SRC 0x08
  170. #define SKIP_DEST 0x10
  171. #define LIN_SRC_ADDR 0x00 /* BLT_CMD_1 values */
  172. #define XY_SRC_ADDR 0x40
  173. #define LIN_DEST_ADDR 0x00
  174. #define XY_DEST_ADDR 0x80
  175. #define BLT_ROP_ENABLE 0x10 /* BLT_CMD_1 XccelVGA values */
  176. #define BLT_DSR 0x20
  177. #define START_LINE 0x01 /* LINE_CMD values */
  178. #define NO_CALC_ONLY 0x00
  179. #define CALC_ONLY 0x02
  180. #define LAST_PIXEL_ON 0x00
  181. #define LAST_PIXEL_NULL 0x04
  182. #define NO_KEEP_X0_Y0 0x00
  183. #define KEEP_X0_Y0 0x08
  184. #define RETAIN_PATTERN_PTR 0x00
  185. #define RESET_PATTERN_PTR 0x10
  186. #define USE_AXIAL_WHEN_ZERO 0x00
  187. #define NO_USE_AXIAL_WHEN_ZERO 0x20
  188. #define AXIAL_ROUND_DOWN 0x40
  189. #define AXIAL_ROUND_UP 0x00
  190. #define LINE_RESET 0x80
  191. #define SS_BIT 0x01 /* BLT_CMD_0 bit */
  192. #define START_BIT 0x01 /* LINE_CMD bit */
  193. #define NO_ROTATE 0x00
  194. #define NO_MASK 0xFF
  195. /////////////////////////////////////////////////////////////////////
  196. //
  197. #define IO_WAIT_FOR_IDLE(ppdev, pjIoBase) \
  198. { \
  199. while (READ_PORT_UCHAR((pjIoBase) + CTRL_REG_1) & GLOBAL_BUSY) \
  200. ; \
  201. }
  202. #define IO_WAIT_BUFFER_NOT_BUSY(ppdev, pjIoBase) \
  203. { \
  204. while (READ_PORT_UCHAR((pjIoBase) + CTRL_REG_1) & BUFFER_BUSY) \
  205. ; \
  206. }
  207. // We occasionally hit a chip bug in QVision 1280's on monochrome
  208. // expansions, where the the driver will get caught in an endless loop
  209. // on engine-busy, even though all data has been transferred
  210. // properly. It turns out that some QVision chips have a bug where
  211. // 'certain types of I/O writes abutting a write to the frame buffer'
  212. // cause the data count occasionally to fail to increment.
  213. //
  214. // As a work-around, we'll always check for the hang condition after
  215. // doing a monochrome expansion, looping a few times to allow the
  216. // engine to catch up, and if it's still hung we reset the engine:
  217. #define WAIT_TRANSFER_DONE_LOOP_COUNT 100
  218. #define IO_WAIT_TRANSFER_DONE(ppdev, pjIoBase) \
  219. { \
  220. LONG i; \
  221. for (i = WAIT_TRANSFER_DONE_LOOP_COUNT; i != 0; i--) \
  222. { \
  223. if (!(READ_PORT_UCHAR((pjIoBase) + CTRL_REG_1) & GLOBAL_BUSY)) \
  224. break; \
  225. } \
  226. if (i == 0) \
  227. { \
  228. IO_BLT_CMD_0(ppdev, (pjIoBase), 0); \
  229. IO_WAIT_FOR_IDLE(ppdev, (pjIoBase)); \
  230. } \
  231. }
  232. //
  233. #define IO_CURSOR_X(ppdev, pjIoBase, x) \
  234. WRITE_PORT_USHORT((pjIoBase) + CURSOR_X, (USHORT)(x))
  235. #define IO_CURSOR_Y(ppdev, pjIoBase, x) \
  236. WRITE_PORT_USHORT((pjIoBase) + CURSOR_Y, (USHORT)(x))
  237. #define IO_CTRL_REG_1(ppdev, pjIoBase, x) \
  238. WRITE_PORT_UCHAR((pjIoBase) + CTRL_REG_1, (x))
  239. #define IO_DATAPATH_CTRL(ppdev, pjIoBase, x) \
  240. { \
  241. WRITE_PORT_USHORT((pjIoBase)+GC_INDEX,(USHORT)(((x)<<8)|DATAPATH_CTRL));\
  242. MEMORY_BARRIER(); \
  243. }
  244. #define IO_FG_COLOR(ppdev, pjIoBase, x) \
  245. { \
  246. WRITE_PORT_USHORT((pjIoBase)+GC_INDEX,(USHORT)(((x)<<8)|GC_FG_COLOR));\
  247. MEMORY_BARRIER(); \
  248. }
  249. #define IO_BG_COLOR(ppdev, pjIoBase, x) \
  250. { \
  251. WRITE_PORT_USHORT((pjIoBase)+GC_INDEX,(USHORT)(((x)<<8)|GC_BG_COLOR));\
  252. MEMORY_BARRIER(); \
  253. }
  254. #define IO_BLT_CONFIG(ppdev, pjIoBase, x) \
  255. { \
  256. WRITE_PORT_USHORT((pjIoBase) +GC_INDEX,(USHORT)(((x)<<8)|BLT_CONFIG));\
  257. MEMORY_BARRIER(); \
  258. }
  259. #define IO_BLT_CMD_0(ppdev, pjIoBase, x) \
  260. { \
  261. MEMORY_BARRIER(); \
  262. WRITE_PORT_UCHAR((pjIoBase) + BLT_CMD_0, (x)); \
  263. MEMORY_BARRIER(); \
  264. }
  265. #define IO_BLT_CMD_1(ppdev, pjIoBase, x) \
  266. WRITE_PORT_UCHAR((pjIoBase) + BLT_CMD_1, (x))
  267. #define IO_PREG_COLOR_8(ppdev, pjIoBase, x) \
  268. { \
  269. ULONG ul; \
  270. \
  271. /* Unfortunately, PREG_0 isn't dword aligned, so we can't */ \
  272. /* do a dword out to it... */ \
  273. \
  274. ul = ((x) << 8) | (x); \
  275. WRITE_PORT_USHORT((pjIoBase) + PREG_4, (USHORT)(ul)); \
  276. WRITE_PORT_USHORT((pjIoBase) + PREG_6, (USHORT)(ul)); \
  277. MEMORY_BARRIER(); \
  278. WRITE_PORT_USHORT((pjIoBase) + PREG_0, (USHORT)(ul)); \
  279. WRITE_PORT_USHORT((pjIoBase) + PREG_2, (USHORT)(ul)); \
  280. }
  281. #define IO_PREG_PATTERN(ppdev, pjIoBase, p) \
  282. { \
  283. USHORT* pw = (USHORT*) (p); \
  284. \
  285. /* Unfortunately, PREG_0 isn't dword aligned, so we can't */ \
  286. /* do a dword out to it... */ \
  287. \
  288. WRITE_PORT_USHORT((pjIoBase) + PREG_4, (USHORT)(*(pw))); \
  289. WRITE_PORT_USHORT((pjIoBase) + PREG_6, (USHORT)(*(pw + 1))); \
  290. MEMORY_BARRIER(); \
  291. WRITE_PORT_USHORT((pjIoBase) + PREG_0, (USHORT)(*(pw + 2))); \
  292. WRITE_PORT_USHORT((pjIoBase) + PREG_2, (USHORT)(*(pw + 3))); \
  293. }
  294. #define IO_BITMAP_WIDTH(ppdev, pjIoBase, x) \
  295. WRITE_PORT_USHORT((pjIoBase) + BITMAP_WIDTH, (USHORT)(x))
  296. #define IO_BITMAP_HEIGHT(ppdev, pjIoBase, x) \
  297. WRITE_PORT_USHORT((pjIoBase) + BITMAP_HEIGHT, (USHORT)(x))
  298. #define IO_PACKED_HEIGHT_WIDTH(ppdev, pjIoBase, yx) \
  299. { \
  300. WRITE_PORT_USHORT((pjIoBase) + BITMAP_HEIGHT, (USHORT)(yx)); \
  301. WRITE_PORT_USHORT((pjIoBase) + BITMAP_WIDTH, (USHORT)((yx) >> 16)); \
  302. }
  303. #define IO_SRC_LIN(ppdev, pjIoBase, x) \
  304. WRITE_PORT_ULONG((pjIoBase) + X0_SRC_ADDR_LO, (x))
  305. #define IO_SRC_ALIGN(ppdev, pjIoBase, x) \
  306. WRITE_PORT_UCHAR((pjIoBase) + X0_SRC_ADDR_LO, (UCHAR)(x))
  307. #define IO_DEST_LIN(ppdev, pjIoBase, x) \
  308. WRITE_PORT_ULONG((pjIoBase) + DEST_ADDR_LO, (x))
  309. /* Note that the pitch is specified in dwords */
  310. #define IO_DEST_PITCH(ppdev, pjIoBase, x) \
  311. WRITE_PORT_USHORT((pjIoBase) + DEST_PITCH, (USHORT)(x))
  312. #define IO_SRC_PITCH(ppdev, pjIoBase, x) \
  313. WRITE_PORT_USHORT((pjIoBase) + SRC_PITCH, (USHORT)(x))
  314. #define IO_ROP_A(ppdev, pjIoBase, x) \
  315. WRITE_PORT_UCHAR((pjIoBase) + ROP_A, (UCHAR)(x))
  316. #define IO_K1_CONST(ppdev, pjIoBase, x) \
  317. { \
  318. WRITE_PORT_USHORT((pjIoBase)+GC_INDEX,(USHORT)(((x)<<8)|(K1_CONST))); \
  319. MEMORY_BARRIER(); \
  320. WRITE_PORT_USHORT((pjIoBase)+GC_INDEX,(USHORT)(((x)&0xff00)|(K1_CONST + 1)));\
  321. MEMORY_BARRIER(); \
  322. }
  323. #define IO_K2_CONST(ppdev, pjIoBase, x) \
  324. { \
  325. WRITE_PORT_USHORT((pjIoBase) +GC_INDEX,(USHORT)(((x)<<8)|(K2_CONST)));\
  326. MEMORY_BARRIER(); \
  327. WRITE_PORT_USHORT((pjIoBase)+GC_INDEX,(USHORT)(((x)&0xff00)|(K2_CONST+1)));\
  328. MEMORY_BARRIER(); \
  329. }
  330. #define IO_LINE_PIX_CNT(ppdev, pjIoBase, x) \
  331. { \
  332. WRITE_PORT_USHORT((pjIoBase)+GC_INDEX,(USHORT)(((x)<<8)|(LINE_PIX_CNT))); \
  333. MEMORY_BARRIER(); \
  334. WRITE_PORT_USHORT((pjIoBase)+GC_INDEX,(USHORT)(((x)&0xff00)|(LINE_PIX_CNT+1))); \
  335. MEMORY_BARRIER(); \
  336. }
  337. #define IO_LINE_ERR_TERM(ppdev, pjIoBase, x) \
  338. { \
  339. WRITE_PORT_USHORT((pjIoBase)+GC_INDEX,(USHORT)(((x)<<8)|(LINE_ERR_TERM)));\
  340. MEMORY_BARRIER(); \
  341. WRITE_PORT_USHORT((pjIoBase)+GC_INDEX,(USHORT)(((x)&0xff00)|(LINE_ERR_TERM+1)));\
  342. MEMORY_BARRIER(); \
  343. }
  344. #define IO_SIGN_CODES(ppdev, pjIoBase, x) \
  345. { \
  346. WRITE_PORT_USHORT((pjIoBase)+ GC_INDEX,(USHORT)(((x)<<8)|SIGN_CODES));\
  347. MEMORY_BARRIER(); \
  348. }
  349. #define IO_LINE_PATTERN(ppdev, pjIoBase, x) \
  350. WRITE_PORT_ULONG((pjIoBase) + LINE_PATTERN, (x))
  351. #define IO_LINE_CMD(ppdev, pjIoBase, x) \
  352. { \
  353. MEMORY_BARRIER(); \
  354. WRITE_PORT_USHORT((pjIoBase) +GC_INDEX,(USHORT)(((x) << 8)|LINE_CMD));\
  355. MEMORY_BARRIER(); \
  356. }
  357. #define IO_PIXEL_WRITE_MASK(ppdev, pjIoBase, x) \
  358. { \
  359. WRITE_PORT_USHORT((pjIoBase)+SEQ_INDEX,(USHORT)(((x)<<8)|SEQ_PIXEL_WR_MSK));\
  360. }
  361. //
  362. #define IO_SRC_XY(ppdev, pjIoBase, x, y) \
  363. WRITE_PORT_ULONG((pjIoBase) + X0_SRC_ADDR_LO, \
  364. (((y) + ppdev->yOffset) << 16) | ((x) + ppdev->xOffset))
  365. #define IO_DEST_XY(ppdev, pjIoBase, x, y) \
  366. WRITE_PORT_ULONG((pjIoBase) + DEST_ADDR_LO, \
  367. (((y) + ppdev->yOffset) << 16) | ((x) + ppdev->xOffset))
  368. #define IO_DEST_X(ppdev, pjIoBase, x) \
  369. WRITE_PORT_USHORT((pjIoBase) + DEST_ADDR_LO, ((x) + (USHORT) ppdev->xOffset))
  370. #define IO_DEST_Y(ppdev, pjIoBase, x) \
  371. WRITE_PORT_USHORT((pjIoBase) + DEST_ADDR_HI, ((x) + (USHORT) ppdev->yOffset))
  372. #define IO_X0_Y0(ppdev, pjIoBase, x, y) \
  373. WRITE_PORT_ULONG((pjIoBase) + X0_SRC_ADDR_LO, \
  374. (((y) + ppdev->yOffset) << 16) | ((x) + ppdev->xOffset))
  375. #define IO_X1_Y1(ppdev, pjIoBase, x, y) \
  376. WRITE_PORT_ULONG((pjIoBase) + X1, \
  377. (((y) + ppdev->yOffset) << 16) | ((x) + ppdev->xOffset))
  378. //
  379. #define IO_ABS_SRC_XY(ppdev, pjIoBase, x, y) \
  380. WRITE_PORT_ULONG((pjIoBase) + X0_SRC_ADDR_LO, ((y) << 16) | (x))
  381. #define IO_ABS_DEST_XY(ppdev, pjIoBase, x, y) \
  382. WRITE_PORT_ULONG((pjIoBase) + DEST_ADDR_LO, ((y) << 16) | (x))
  383. #define IO_ABS_X0_Y0(ppdev, pjIoBase, x, y) \
  384. WRITE_PORT_ULONG((pjIoBase) + X0_SRC_ADDR_LO, ((y) << 16) | (x))
  385. #define IO_ABS_X1_Y1(ppdev, pjIoBase, x, y) \
  386. WRITE_PORT_ULONG((pjIoBase) + X1, ((y) << 16) | (x))
  387. /////////////////////////////////////////////////////////////////////
  388. #define MEM_CTRL_REG_1 0xf3c
  389. #define MEM_DATAPATH_CTRL 0xf3e
  390. #define MEM_FG_COLOR 0xf40
  391. #define MEM_BG_COLOR 0xf41
  392. #define MEM_BLT_CMD_0 0xfb0
  393. #define MEM_BLT_CMD_1 0xfb1
  394. #define MEM_BROADCAST_COLOR 0xf42
  395. #define MEM_PREG_0 0xfa0
  396. #define MEM_PREG_1 0xfa1
  397. #define MEM_PREG_2 0xfa2
  398. #define MEM_PREG_3 0xfa3
  399. #define MEM_PREG_4 0xfa4
  400. #define MEM_PREG_5 0xfa5
  401. #define MEM_PREG_6 0xfa6
  402. #define MEM_PREG_7 0xfa7
  403. #define MEM_BITMAP_HEIGHT 0xfac
  404. #define MEM_BITMAP_WIDTH 0xfae
  405. #define MEM_SRC_ADDR_LO 0xfb8
  406. #define MEM_SRC_ADDR_HI 0xfba
  407. #define MEM_DEST_ADDR_LO 0xfbc
  408. #define MEM_DEST_ADDR_HI 0xfbe
  409. #define MEM_DEST_PITCH 0xfaa
  410. #define MEM_SRC_PITCH 0xfa8
  411. #define MEM_ROP_A 0xf43
  412. #define MEM_K1_CONST 0xf70
  413. #define MEM_K2_CONST 0xf74
  414. #define MEM_LINE_PIX_CNT 0xf68
  415. #define MEM_LINE_ERR_TERM 0xf6c
  416. #define MEM_SIGN_CODES 0xf63
  417. #define MEM_LINE_PATTERN 0xf64
  418. #define MEM_LINE_CMD 0xf60
  419. #define MEM_X0 0xf78
  420. #define MEM_Y0 0xf7a
  421. #define MEM_X1 0xf7c
  422. #define MEM_Y1 0xf7e
  423. #define MEM_SEQ_PIXEL_WR_MSK 0xf30
  424. //
  425. #define MM_WAIT_FOR_IDLE(ppdev, pjMmBase) \
  426. { \
  427. while (READ_REGISTER_UCHAR((pjMmBase) + MEM_CTRL_REG_1) & GLOBAL_BUSY)\
  428. ; \
  429. }
  430. #define MM_WAIT_BUFFER_NOT_BUSY(ppdev, pjMmBase) \
  431. { \
  432. while (READ_REGISTER_UCHAR((pjMmBase) + MEM_CTRL_REG_1) & BUFFER_BUSY)\
  433. ; \
  434. }
  435. // We occasionally hit a chip bug in QVision 1280's on monochrome
  436. // expansions, where the the driver will get caught in an endless loop
  437. // on engine-busy, even though all data has been transferred
  438. // properly. It turns out that some QVision chips have a bug where
  439. // 'certain types of I/O writes abutting a write to the frame buffer'
  440. // cause the data count occasionally to fail to increment.
  441. //
  442. // As a work-around, we'll always check for the hang condition after
  443. // doing a monochrome expansion, looping a few times to allow the
  444. // engine to catch up, and if it's still hung we reset the engine:
  445. #define WAIT_TRANSFER_DONE_LOOP_COUNT 100
  446. #define MM_WAIT_TRANSFER_DONE(ppdev, pjMmBase) \
  447. { \
  448. LONG i; \
  449. for (i = WAIT_TRANSFER_DONE_LOOP_COUNT; i != 0; i--) \
  450. { \
  451. if (!(READ_REGISTER_UCHAR((pjMmBase) + MEM_CTRL_REG_1) & GLOBAL_BUSY)) \
  452. break; \
  453. } \
  454. if (i == 0) \
  455. { \
  456. MM_BLT_CMD_0(ppdev, (pjMmBase), 0); \
  457. MM_WAIT_FOR_IDLE(ppdev, (pjMmBase)); \
  458. } \
  459. }
  460. //
  461. #define MM_CTRL_REG_1(ppdev, pjMmBase, x) \
  462. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_CTRL_REG_1, (UCHAR) (x))
  463. #define MM_DATAPATH_CTRL(ppdev, pjMmBase, x) \
  464. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_DATAPATH_CTRL, (UCHAR) (x))
  465. #define MM_FG_COLOR(ppdev, pjMmBase, x) \
  466. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_FG_COLOR, (UCHAR) (x))
  467. #define MM_BG_COLOR(ppdev, pjMmBase, x) \
  468. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_BG_COLOR, (UCHAR) (x))
  469. #define MM_BLT_CMD_0(ppdev, pjMmBase, x) \
  470. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_BLT_CMD_0, (UCHAR) (x))
  471. #define MM_BLT_CMD_1(ppdev, pjMmBase, x) \
  472. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_BLT_CMD_1, (UCHAR) (x))
  473. #define MM_PREG_COLOR_8(ppdev, pjMmBase, x) \
  474. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_BROADCAST_COLOR, (UCHAR) (x))
  475. #define MM_PREG_PATTERN(ppdev, pjMmBase, p) \
  476. { \
  477. WRITE_REGISTER_ULONG((pjMmBase) + MEM_PREG_4, *((ULONG*) (p))); \
  478. WRITE_REGISTER_ULONG((pjMmBase) + MEM_PREG_0, *((ULONG*) (p) + 1)); \
  479. }
  480. #define MM_PREG_BLOCK(ppdev, pjMmBase, p) \
  481. { \
  482. WRITE_REGISTER_ULONG((pjMmBase) + MEM_PREG_0, *((ULONG*) (p))); \
  483. }
  484. #define MM_BITMAP_WIDTH(ppdev, pjMmBase, x) \
  485. WRITE_REGISTER_USHORT((pjMmBase) + MEM_BITMAP_WIDTH, (USHORT) (x))
  486. #define MM_BITMAP_HEIGHT(ppdev, pjMmBase, x) \
  487. WRITE_REGISTER_USHORT((pjMmBase) + MEM_BITMAP_HEIGHT, (USHORT) (x))
  488. #define MM_PACKED_HEIGHT_WIDTH(ppdev, pjMmBase, yx) \
  489. WRITE_REGISTER_ULONG((pjMmBase) + MEM_BITMAP_HEIGHT, (yx))
  490. #define MM_SRC_LIN(ppdev, pjMmBase, x) \
  491. WRITE_REGISTER_ULONG((pjMmBase) + MEM_SRC_ADDR_LO, (x))
  492. #define MM_SRC_ALIGN(ppdev, pjMmBase, x) \
  493. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_SRC_ADDR_LO, (UCHAR) (x))
  494. #define MM_DEST_LIN(ppdev, pjMmBase, x) \
  495. WRITE_REGISTER_ULONG((pjMmBase) + MEM_DEST_ADDR_LO, (x))
  496. /* Note that the pitch is specified in dwords */
  497. #define MM_DEST_PITCH(ppdev, pjMmBase, x) \
  498. WRITE_REGISTER_USHORT((pjMmBase) + MEM_DEST_PITCH, (USHORT) (x))
  499. #define MM_SRC_PITCH(ppdev, pjMmBase, x) \
  500. WRITE_REGISTER_USHORT((pjMmBase) + MEM_SRC_PITCH, (USHORT) (x))
  501. #define MM_ROP_A(ppdev, pjMmBase, x) \
  502. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_ROP_A, (UCHAR) (x))
  503. #define MM_K1_CONST(ppdev, pjMmBase, x) \
  504. WRITE_REGISTER_USHORT((pjMmBase) + MEM_K1_CONST, (USHORT) (x))
  505. #define MM_K2_CONST(ppdev, pjMmBase, x) \
  506. WRITE_REGISTER_USHORT((pjMmBase) + MEM_K2_CONST, (USHORT) (x))
  507. #define MM_LINE_PIX_CNT(ppdev, pjMmBase, x) \
  508. WRITE_REGISTER_USHORT((pjMmBase) + MEM_LINE_PIX_CNT, (USHORT) (x))
  509. #define MM_LINE_ERR_TERM(ppdev, pjMmBase, x) \
  510. WRITE_REGISTER_USHORT((pjMmBase) + MEM_LINE_ERR_TERM, (USHORT) (x))
  511. #define MM_SIGN_CODES(ppdev, pjMmBase, x) \
  512. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_SIGN_CODES, (UCHAR) (x))
  513. #define MM_LINE_PATTERN(ppdev, pjMmBase, x) \
  514. WRITE_REGISTER_ULONG((pjMmBase) + MEM_LINE_PATTERN, (x))
  515. #define MM_LINE_CMD(ppdev, pjMmBase, x) \
  516. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_LINE_CMD, (UCHAR) (x))
  517. #define MM_PIXEL_WRITE_MASK(ppdev, pjMmBase, x) \
  518. WRITE_REGISTER_UCHAR((pjMmBase) + MEM_SEQ_PIXEL_WR_MSK, (UCHAR) (x))
  519. //
  520. #define MM_SRC_XY(ppdev, pjMmBase, x, y) \
  521. WRITE_REGISTER_ULONG((pjMmBase) + MEM_SRC_ADDR_LO, \
  522. (((y) + ppdev->yOffset) << 16) | ((x) + ppdev->xOffset))
  523. #define MM_DEST_XY(ppdev, pjMmBase, x, y) \
  524. WRITE_REGISTER_ULONG((pjMmBase) + MEM_DEST_ADDR_LO, \
  525. (((y) + ppdev->yOffset) << 16) | ((x) + ppdev->xOffset))
  526. #define MM_DEST_X(ppdev, pjMmBase, x) \
  527. WRITE_REGISTER_USHORT((pjMmBase) + MEM_DEST_ADDR_LO, \
  528. (USHORT) ((x) + (ppdev->xOffset)))
  529. #define MM_DEST_Y(ppdev, pjMmBase, x) \
  530. WRITE_REGISTER_USHORT((pjMmBase) + MEM_DEST_ADDR_HI, \
  531. (USHORT) ((x) + (ppdev->yOffset)))
  532. #define MM_X0_Y0(ppdev, pjMmBase, x, y) \
  533. WRITE_REGISTER_ULONG((pjMmBase) + MEM_X0, \
  534. (((y) + ppdev->yOffset) << 16) | ((x) + ppdev->xOffset))
  535. #define MM_X1_Y1(ppdev, pjMmBase, x, y) \
  536. WRITE_REGISTER_ULONG((pjMmBase) + MEM_X1, \
  537. (((y) + ppdev->yOffset) << 16) | ((x) + ppdev->xOffset))
  538. //
  539. #define MM_ABS_SRC_XY(ppdev, pjMmBase, x, y) \
  540. WRITE_REGISTER_ULONG((pjMmBase) + MEM_SRC_ADDR_LO, ((y) << 16) | (x))
  541. #define MM_ABS_DEST_XY(ppdev, pjMmBase, x, y) \
  542. WRITE_REGISTER_ULONG((pjMmBase) + MEM_DEST_ADDR_LO, ((y) << 16) | (x))
  543. #define MM_ABS_X0_Y0(ppdev, pjMmBase, x, y) \
  544. WRITE_REGISTER_ULONG((pjMmBase) + MEM_X0, ((y) << 16) | (x))
  545. #define MM_ABS_X1_Y1(ppdev, pjMmBase, x, y) \
  546. WRITE_REGISTER_ULONG((pjMmBase) + MEM_X1, ((y) << 16) | (x))