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.

362 lines
7.3 KiB

  1. /*++
  2. Copyright (c) 1993 Weitek Corporation
  3. Module Name:
  4. Bt485.h
  5. Abstract:
  6. This module contains the Bt485 specific DAC definitions for the
  7. Weitek P9 miniport device driver.
  8. Environment:
  9. Kernel mode
  10. Revision History may be found at the end of this file.
  11. --*/
  12. //
  13. // Define the relative offset of each of the Bt485 registers in the
  14. // DACRegisters array found in the Device Extension.
  15. //
  16. typedef enum
  17. {
  18. RS_0,
  19. RS_1,
  20. RS_2,
  21. RS_3,
  22. RS_4,
  23. RS_5,
  24. RS_6,
  25. RS_7,
  26. RS_8,
  27. RS_9,
  28. RS_A,
  29. RS_B,
  30. RS_C,
  31. RS_D,
  32. RS_E,
  33. RS_F,
  34. NUM_DAC_REGS
  35. } DAC_REG_INDEX;
  36. //
  37. // The following definitions provide a readable means of referencing the
  38. // Bt485 registers via their virtual addresses found in the
  39. // HwDeviceExtension.
  40. //
  41. #define PAL_WR_ADDR_REG HwDeviceExtension->pDACRegs[RS_0]
  42. #define PAL_DATA_REG HwDeviceExtension->pDACRegs[RS_1]
  43. #define PIXEL_MSK_REG HwDeviceExtension->pDACRegs[RS_2]
  44. #define PAL_RD_ADDR_REG HwDeviceExtension->pDACRegs[RS_3]
  45. #define CURS_CLR_ADDR HwDeviceExtension->pDACRegs[RS_4]
  46. #define CURS_CLR_DATA HwDeviceExtension->pDACRegs[RS_5]
  47. #define CMD_REG_0 HwDeviceExtension->pDACRegs[RS_6]
  48. #define CLR_RD_ADDR_REG HwDeviceExtension->pDACRegs[RS_7]
  49. #define CMD_REG_1 HwDeviceExtension->pDACRegs[RS_8]
  50. #define CMD_REG_2 HwDeviceExtension->pDACRegs[RS_9]
  51. #define CMD_REG_3 HwDeviceExtension->pDACRegs[RS_A]
  52. #define CURS_DATA_REG HwDeviceExtension->pDACRegs[RS_B]
  53. #define CURS_X HwDeviceExtension->pDACRegs[RS_C]
  54. #define CURS_X_HI HwDeviceExtension->pDACRegs[RS_D]
  55. #define CURS_Y HwDeviceExtension->pDACRegs[RS_E]
  56. #define CURS_Y_HI HwDeviceExtension->pDACRegs[RS_F]
  57. //
  58. // Bit definitions for CMD_REG_0.
  59. //
  60. #define ENB_CMD_REG_3 0x80
  61. #define DIS_CMD_REG_3 0x00
  62. #define MODE_8_BIT 0x02
  63. //
  64. // Bit definitions for CMD_REG_1.
  65. //
  66. #define PIX_PORT_24 0x60
  67. #define PIX_PORT_8 0x40
  68. #define PIX_PORT_16 0x30
  69. #define PIX_PORT_32 0x10
  70. //
  71. // Bit definitions for CMD_REG_2.
  72. //
  73. #define SCLK_INV 0x40 // Bt489 - invert SCLK if in forbidden region
  74. #define SCLK_NORM ~SCLK_INV
  75. #define PORTSEL_MSKD 0x20
  76. #define PCLK1_SEL 0x10
  77. #define PCLK0_SEL ~PCLK1_SEL
  78. #define CURS_ACTIVE 0x03
  79. #define ENB_CURS 0x02
  80. #define DIS_CURS ~CURS_ACTIVE
  81. //
  82. // Bit definitions for CMD_REG_3.
  83. //
  84. #define CUR_MODE_64 0x04
  85. #define CUR_MODE_32 ~CUR_MODE_64
  86. #define DAC_CLK_2X 0x08
  87. #define DAC_CLK_2X_489 0x80 // per os2 driver code - undocumented for Bt489
  88. #define CUR_REG_IND_MSK ~0x03
  89. //
  90. // Bit definitions for CMD_REG_4 on Bt489.
  91. //
  92. #define MUX_485_COMPAT (0x00<<4) // 485 compatible value - set at reset
  93. #define CR4_MUX_81 (0x02<<4) // 489 8:1 mux mode (8 bpp)
  94. #define CR4_MUX_41 (0x03<<4) // 489 4:1 mux mode (16 bpp)
  95. #define CR4_MUX_21 (0x04<<4) // 489 2:1 mux mode (32 bpp)
  96. #define CR4_MUX_24BPP (0x07<<4) // 489 24 bpp mux mode (24 bpp)
  97. #define CR4_MUX_BITS (0x07<<4)
  98. //
  99. // Bit definitions for PAL_WR_ADDR to enable CMD_REG_3.
  100. //
  101. #define CMD_REG_3_ENB 0x01
  102. #define CMD_REG_3_DIS 0x00
  103. //
  104. // Bit definitions for PAL_WR_ADDR to enable CMD_REG_4 on Bt489.
  105. //
  106. #define CMD_REG_4_ENB 0x02
  107. #define CMD_REG_4_DIS 0x00
  108. //
  109. // Max clock frequency supported w/o clock doubling.
  110. //
  111. //
  112. #define CLK_MAX_FREQ 6750
  113. #define CLK489_MAX_FREQ 8500
  114. //
  115. // General purpose macros for accessing the DAC registers.
  116. //
  117. //
  118. // Macros for accessing the palette registers.
  119. //
  120. extern VOID
  121. WriteDAC(
  122. PHW_DEVICE_EXTENSION HwDeviceExtension,
  123. ULONG ulIndex,
  124. UCHAR ucValue
  125. );
  126. extern UCHAR
  127. ReadDAC(
  128. PHW_DEVICE_EXTENSION HwDeviceExtension,
  129. ULONG ulIndex
  130. );
  131. #define RD_DAC(addr) \
  132. ReadDAC(HwDeviceExtension, (ULONG) addr)
  133. #define WR_DAC(addr, data) \
  134. WriteDAC(HwDeviceExtension, (ULONG) addr, (UCHAR) (data))
  135. #define PAL_WR_ADDR(data) \
  136. WriteDAC(HwDeviceExtension, PAL_WR_ADDR_REG, (data))
  137. #define PAL_WR_DATA(data) \
  138. WriteDAC(HwDeviceExtension, PAL_DATA_REG, (data))
  139. //
  140. // Macros for accessing the command register 3.
  141. //
  142. #define WR_CMD_REG_3(data) \
  143. WR_DAC(CMD_REG_0, RD_DAC(CMD_REG_0) | ENB_CMD_REG_3); \
  144. PAL_WR_ADDR(CMD_REG_3_ENB); \
  145. WR_DAC(CMD_REG_3, (data)); \
  146. PAL_WR_ADDR(CMD_REG_3_DIS)
  147. #define RD_CMD_REG_3(data) \
  148. WR_DAC(CMD_REG_0, RD_DAC(CMD_REG_0) | ENB_CMD_REG_3); \
  149. PAL_WR_ADDR(CMD_REG_3_ENB); \
  150. data = RD_DAC(CMD_REG_3); \
  151. PAL_WR_ADDR(CMD_REG_3_DIS)
  152. //
  153. // Macros for accessing the command register 4 on Bt489 DAC.
  154. //
  155. #define WR_CMD_REG_4(data) \
  156. WR_DAC(CMD_REG_0, RD_DAC(CMD_REG_0) | ENB_CMD_REG_3); \
  157. PAL_WR_ADDR(CMD_REG_4_ENB); \
  158. WR_DAC(CMD_REG_3, (data)); \
  159. PAL_WR_ADDR(CMD_REG_4_DIS)
  160. #define RD_CMD_REG_4(data) \
  161. WR_DAC(CMD_REG_0, RD_DAC(CMD_REG_0) | ENB_CMD_REG_3); \
  162. PAL_WR_ADDR(CMD_REG_4_ENB); \
  163. data = RD_DAC(CMD_REG_3); \
  164. PAL_WR_ADDR(CMD_REG_4_DIS)
  165. //
  166. // Macros for accessing the hardware cursor registers.
  167. //
  168. #define WR_CURS_POS_X(pos) \
  169. WR_DAC(CURS_X, (UCHAR) pos); \
  170. WR_DAC(CURS_X_HI, (UCHAR) (pos >> 8))
  171. #define WR_CURS_POS_Y(pos) \
  172. WR_DAC(CURS_Y, (UCHAR) pos); \
  173. WR_DAC(CURS_Y_HI, (UCHAR) (pos >> 8))
  174. #define WR_CURS_DATA(data) \
  175. WR_DAC(CURS_DATA_REG, (data))
  176. #define CURS_IS_ON() \
  177. (RD_DAC(CMD_REG_2) & CURS_ACTIVE)
  178. #define CURS_ON() \
  179. WR_DAC(CMD_REG_2, RD_DAC(CMD_REG_2) | ENB_CURS)
  180. #define CURS_OFF() \
  181. WR_DAC(CMD_REG_2, RD_DAC(CMD_REG_2) & DIS_CURS)
  182. //
  183. // Function Prototypes for the Bt485 DAC which are defined in BT485.C.
  184. //
  185. //
  186. // Bt485 function prototypes.
  187. //
  188. VOID
  189. Bt485SetPalette(
  190. PHW_DEVICE_EXTENSION HwDeviceExtension,
  191. ULONG *pPal,
  192. ULONG StartIndex,
  193. ULONG Count
  194. );
  195. VOID
  196. Bt485SetPointerPos(
  197. PHW_DEVICE_EXTENSION HwDeviceExtension,
  198. ULONG ptlX,
  199. ULONG ptlY
  200. );
  201. VOID
  202. Bt485SetPointerShape(
  203. PHW_DEVICE_EXTENSION HwDeviceExtension,
  204. PUCHAR pHWCursorShape
  205. );
  206. VOID
  207. Bt485PointerOn(
  208. PHW_DEVICE_EXTENSION HwDeviceExtension
  209. );
  210. VOID
  211. Bt485PointerOff(
  212. PHW_DEVICE_EXTENSION HwDeviceExtension
  213. );
  214. VOID
  215. Bt485ClearPalette(
  216. PHW_DEVICE_EXTENSION HwDeviceExtension
  217. );
  218. BOOLEAN
  219. Bt485SetMode(
  220. PHW_DEVICE_EXTENSION HwDeviceExtension
  221. );
  222. VOID
  223. Bt485RestoreMode(
  224. PHW_DEVICE_EXTENSION HwDeviceExtension
  225. );
  226. VOID
  227. Bt485SetClkDoubler(
  228. PHW_DEVICE_EXTENSION HwDeviceExtension
  229. );
  230. VOID
  231. Bt485ClrClkDoubler(
  232. PHW_DEVICE_EXTENSION HwDeviceExtension
  233. );
  234. //
  235. // Function Prototypes for the Bt489 DAC which are defined in P91BT489.C.
  236. //
  237. //
  238. // Bt489 function prototypes.
  239. //
  240. VOID
  241. Bt489SetPalette(
  242. PHW_DEVICE_EXTENSION HwDeviceExtension,
  243. ULONG *pPal,
  244. ULONG StartIndex,
  245. ULONG Count
  246. );
  247. VOID
  248. Bt489SetPointerPos(
  249. PHW_DEVICE_EXTENSION HwDeviceExtension,
  250. ULONG ptlX,
  251. ULONG ptlY
  252. );
  253. VOID
  254. Bt489SetPointerShape(
  255. PHW_DEVICE_EXTENSION HwDeviceExtension,
  256. PUCHAR pHWCursorShape
  257. );
  258. VOID
  259. Bt489PointerOn(
  260. PHW_DEVICE_EXTENSION HwDeviceExtension
  261. );
  262. VOID
  263. Bt489PointerOff(
  264. PHW_DEVICE_EXTENSION HwDeviceExtension
  265. );
  266. VOID
  267. Bt489ClearPalette(
  268. PHW_DEVICE_EXTENSION HwDeviceExtension
  269. );
  270. BOOLEAN
  271. Bt489SetMode(
  272. PHW_DEVICE_EXTENSION HwDeviceExtension
  273. );
  274. VOID
  275. Bt489RestoreMode(
  276. PHW_DEVICE_EXTENSION HwDeviceExtension
  277. );
  278. VOID
  279. Bt489SetClkDoubler(
  280. PHW_DEVICE_EXTENSION HwDeviceExtension
  281. );
  282. VOID
  283. Bt489ClrClkDoubler(
  284. PHW_DEVICE_EXTENSION HwDeviceExtension
  285. );