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.

676 lines
33 KiB

  1. /******************************Module*Header*******************************\
  2. *
  3. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  4. * !! !!
  5. * !! WARNING: NOT DDK SAMPLE CODE !!
  6. * !! !!
  7. * !! This source code is provided for completeness only and should not be !!
  8. * !! used as sample code for display driver development. Only those sources !!
  9. * !! marked as sample code for a given driver component should be used for !!
  10. * !! development purposes. !!
  11. * !! !!
  12. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  13. *
  14. * Module Name: tvp3026.h
  15. *
  16. * Content: This module contains the definitions for the TI TVP3026 RAMDAC.
  17. *
  18. * Copyright (c) 1994-1999 3Dlabs Inc. Ltd. All rights reserved.
  19. * Copyright (c) 1995-2003 Microsoft Corporation. All rights reserved.
  20. \*****************************************************************************/
  21. #define ADbgpf VideoDebugPrint
  22. //
  23. // TI TVP3026 RAMDAC definitions
  24. // This set of registers resides at &(pCtrlRegs->ExternalVideo)
  25. //
  26. typedef struct _tvp3026_regs {
  27. volatile RAMDAC_REG pciAddrWr; // 0x00 - palette/cursor RAM write address, Index Register
  28. volatile RAMDAC_REG palData; // 0x01 - palette RAM data
  29. volatile RAMDAC_REG pixelMask; // 0x02 - pixel read mask
  30. volatile RAMDAC_REG pcAddrRd; // 0x03 - palette/cursor RAM read address
  31. volatile RAMDAC_REG curAddrWr; // 0x04 - cursor/overscan color write address
  32. volatile RAMDAC_REG curData; // 0x05 - cursor/overscan color data
  33. volatile RAMDAC_REG Reserverd1; // 0x06 - reserved
  34. volatile RAMDAC_REG curAddrRd; // 0x07 - cursor/overscan color read address
  35. volatile RAMDAC_REG Reserverd2; // 0x08 - reserved
  36. volatile RAMDAC_REG curCtl; // 0x09 - direct cursor control
  37. volatile RAMDAC_REG indexData; // 0x0A - indexed data
  38. volatile RAMDAC_REG curRAMData; // 0x0B - cursor RAM data
  39. volatile RAMDAC_REG cursorXLow; // 0x0C - cursor position X low byte
  40. volatile RAMDAC_REG cursorXHigh; // 0x0D - cursor position X high byte
  41. volatile RAMDAC_REG cursorYLow; // 0x0E - cursor position Y low byte
  42. volatile RAMDAC_REG cursorYHigh; // 0x0F - cursor position Y high byte
  43. } TVP3026RAMDAC, *pTVP3026RAMDAC;
  44. // macro declared by any function wishing to use the TI TVP3026 RAMDAC . MUST be declared
  45. // after GLINT_DECL.
  46. //
  47. #if MINIVDD
  48. #define TVP3026_DECL \
  49. pTVP3026RAMDAC pTVP3026Regs = (pTVP3026RAMDAC)&(pDev->pRegisters->Glint.ExtVCReg)
  50. #else
  51. #define TVP3026_DECL \
  52. pTVP3026RAMDAC pTVP3026Regs = (pTVP3026RAMDAC)&(pRegisters->Glint.ExtVCReg)
  53. #endif
  54. // use the following macros as the address to pass to the
  55. // VideoPortWriteRegisterUlong function
  56. //
  57. // Palette Access
  58. #define __TVP3026_PAL_WR_ADDR ((PULONG)&(pTVP3026Regs->pciAddrWr.reg))
  59. #define __TVP3026_PAL_RD_ADDR ((PULONG)&(pTVP3026Regs->palAddrRd.reg))
  60. #define __TVP3026_PAL_DATA ((volatile PULONG)&(pTVP3026Regs->palData.reg))
  61. // Pixel mask
  62. #define __TVP3026_PIXEL_MASK ((PULONG)&(pTVP3026Regs->pixelMask.reg))
  63. // Access to the indexed registers
  64. #define __TVP3026_INDEX_ADDR ((PULONG)&(pTVP3026Regs->pciAddrWr.reg))
  65. #define __TVP3026_INDEX_DATA ((PULONG)&(pTVP3026Regs->indexData.reg))
  66. // Access to the Cursor
  67. #define __TVP3026_CUR_RAM_WR_ADDR ((PULONG)&(pTVP3026Regs->pciAddrWr.reg))
  68. #define __TVP3026_CUR_RAM_RD_ADDR ((PULONG)&(pTVP3026Regs->palAddrRd.reg))
  69. #define __TVP3026_CUR_RAM_DATA ((PULONG)&(pTVP3026Regs->curRAMData.reg))
  70. #define __TVP3026_CUR_WR_ADDR ((PULONG)&(pTVP3026Regs->curAddrWr.reg))
  71. #define __TVP3026_CUR_RD_ADDR ((PULONG)&(pTVP3026Regs->curAddrRd.reg))
  72. #define __TVP3026_CUR_DATA ((PULONG)&(pTVP3026Regs->curData.reg))
  73. #define __TVP3026_CUR_CTL ((PULONG)&(pTVP3026Regs->curCtl.reg))
  74. // Access to the overscan color
  75. #define __TVP3026_OVRC_WR_ADDR ((PULONG)&(pTVP3026Regs->curAddrWr.reg))
  76. #define __TVP3026_OVRC_RD_ADDR ((PULONG)&(pTVP3026Regs->curAddrRd.reg))
  77. #define __TVP3026_OVRC_DATA ((PULONG)&(pTVP3026Regs->curData.reg))
  78. // Cursor position control
  79. #define __TVP3026_CUR_X_LSB ((PULONG)&(pTVP3026Regs->cursorXLow.reg))
  80. #define __TVP3026_CUR_X_MSB ((PULONG)&(pTVP3026Regs->cursorXHigh.reg))
  81. #define __TVP3026_CUR_Y_LSB ((PULONG)&(pTVP3026Regs->cursorYLow.reg))
  82. #define __TVP3026_CUR_Y_MSB ((PULONG)&(pTVP3026Regs->cursorYHigh.reg))
  83. // ----------------------Values for some direct registers-----------------------
  84. /********************************************************************************/
  85. /* DIRECT REGISTER - CURSOR AND OVERSCAN COLOR */
  86. /********************************************************************************/
  87. // ** TVP3026_OVRC_WR_ADDR
  88. // ** TVP3026_OVRC_RD_ADDR
  89. // ** TVP3026_CUR_WR_ADDR
  90. // ** TVP3026_CUR_RD_ADDR
  91. // Default - undefined
  92. #define TVP3026_OVERSCAN_COLOR 0x00
  93. #define TVP3026_CURSOR_COLOR0 0x01
  94. #define TVP3026_CURSOR_COLOR1 0x02
  95. #define TVP3026_CURSOR_COLOR2 0x03
  96. /********************************************************************************/
  97. /* DIRECT REGISTER - CURSOR CONTROL */
  98. /********************************************************************************/
  99. // ** TVP3026_CUR_CTL
  100. // Default - 0x00
  101. #define TVP3026_CURSOR_OFF 0x00 // Cursor off
  102. #define TVP3026_CURSOR_COLOR 0x01 // 2-bits select color
  103. #define TVP3026_CURSOR_XGA 0x02 // 2-bits select XOR
  104. #define TVP3026_CURSOR_XWIN 0x03 // 2-bits select transparency/color
  105. /********************************************************************************/
  106. /* DIRECT REGISTER - CURSOR POSITION CONTROL */
  107. /********************************************************************************/
  108. // ** TVP3026_CUR_X_LSB
  109. // ** TVP3026_CUR_X_MSB
  110. // ** TVP3026_CUR_Y_LSB
  111. // ** TVP3026_CUR_Y_MSB
  112. // Default - undefined
  113. // Values written into those registers represent the BOTTOM-RIGHT corner
  114. // of the cursor. If 0 is in X or Y position - the cursor is off the screen
  115. // Only 12 bits are used, giving the range from 0 to 4095 ( 0x0000 - 0x0FFF)
  116. // The size of the cursor is (64,64) (0x40, 0x40)
  117. #define TVP3026_CURSOR_OFFSCREEN 0x00 // Cursor offscreen
  118. // ------------------------Indirect indexed registers map--------------------------
  119. /********************************************************************************/
  120. /* INDIRECT REGISTER - SILICON REVISION */
  121. /********************************************************************************/
  122. #define __TVP3026_SILICON_REVISION 0x01 // Chip revision:
  123. // bits 4-7 - major number, 0-3 - minor number
  124. // TVP3026_REVISION_LEVEL
  125. #define TVP3026_REVISION_LEVEL 0x01 // predefined
  126. // TVP3030_REVISION_LEVEL
  127. #define TVP3030_REVISION_LEVEL 0x00 // predefined
  128. /********************************************************************************/
  129. /* INDIRECT REGISTER - CHIP ID */
  130. /********************************************************************************/
  131. #define __TVP3026_CHIP_ID 0x3F //
  132. // Default - 0x26
  133. #define TVP3026_ID_CODE 0x26 // predefined
  134. #define TVP3030_ID_CODE 0x30 // predefined
  135. /********************************************************************************/
  136. /* INDIRECT REGISTER - CURSOR CONTROL */
  137. /********************************************************************************/
  138. #define __TVP3026_CURSOR_CONTROL 0x06 // Indirect cursor control -
  139. // Default - 0x00
  140. #define TVP3026_CURSOR_USE_DIRECT_CCR (1 << 7)// Enable Direct Cursor Control Register
  141. #define TVP3026_CURSOR_USE_INDEX_CCR (0 << 7)// Disable Direct Cursor Control Register
  142. #define TVP3026_CURSOR_INTERLACE_ODD (1 << 6)// Detect odd field as 1
  143. #define TVP3026_CURSOR_INTERLACE_EVEN (0 << 6)// Detect even field as 1
  144. #define TVP3026_CURSOR_INTERLACE_ON (1 << 5)// Enable interlaced cursor
  145. #define TVP3026_CURSOR_INTERLACE_OFF (0 << 5)// Disable interlaced cursor
  146. #define TVP3026_CURSOR_VBLANK_4096 (1 << 4)// Blank is detected after 4096
  147. #define TVP3026_CURSOR_VBLANK_2048 (0 << 4)// or 2048 dot clocks
  148. #define TVP3026_CURSOR_RAM_ADDRESS(x) (((x) & 0x03) << 2)// High bits of cursor RAM address
  149. #define TVP3026_CURSOR_RAM_MASK ((0x03) << 2) // Mask for high bits of cursor RAM address
  150. // CURSOR_OFF 0x00 // Cursor off
  151. // CURSOR_COLOR 0x01 // 2-bits select color
  152. // CURSOR_XGA 0x02 // 2-bits select XOR
  153. // CURSOR_XWIN 0x03 // 2-bits select transparency/color
  154. /********************************************************************************/
  155. /* INDIRECT REGISTER - LATCH CONTROL */
  156. /********************************************************************************/
  157. #define __TVP3026_LATCH_CONTROL 0x0F // Latch control register -
  158. // Default - 0x06
  159. #define TVP3026_LATCH_ALL_MODES 0x06 // All modes except packed-24
  160. #define TVP3026_LATCH_4_3 0x07 // 4:3 or 8:3 packed-24
  161. #define TVP3026_LATCH_5_2 0x20 // 5:2 packed-24
  162. #define TVP3026_LATCH_5_4_1 0x1F // 5:4 packed-24 x1 horz zoom
  163. #define TVP3026_LATCH_5_4_2 0x1E // 5:4 packed-24 x2 horz zoom
  164. #define TVP3026_LATCH_5_4_4 0x1C // 5:4 packed-24 x4 horz zoom
  165. #define TVP3026_LATCH_5_4_8 0x18 // 5:4 packed-24 x8 horz zoom
  166. /********************************************************************************/
  167. /* INDIRECT REGISTER - TRUE COLOR CONTROL */
  168. /********************************************************************************/
  169. #define __TVP3026_TRUE_COLOR 0x18 // True Color control
  170. // Default - 0x80
  171. /********************************************************************************/
  172. /* INDIRECT REGISTER - MULTIPLEX CONTROL */
  173. /********************************************************************************/
  174. #define __TVP3026_MULTIPLEX_CONTROL 0x19 // Multiplex control
  175. // Default - 0x98
  176. /********************************************************************************/
  177. /* INDIRECT REGISTER - CLOCK SELECTION */
  178. /********************************************************************************/
  179. #define __TVP3026_CLOCK 0x1A //
  180. // Default - 0x07
  181. #define TVP3026_SCLK_ENABLE (1 << 7)// Enable SCLK output
  182. #define TVP3026_SCLK_DISABLE (0 << 7)// Disable SCLK output
  183. #define TVP3026_VCLK_ZERO (7 << 4)// VCLK forced to Logical "0"
  184. #define TVP3026_VCLK_DOTCLOCK (0 << 4)// VCLK is equal to Dot clock
  185. #define TVP3026_VCLK_DOTCLOCK_DIV2 (1 << 4)// VCLK is equal to Dot clock/2
  186. #define TVP3026_VCLK_DOTCLOCK_DIV4 (2 << 4)// VCLK is equal to Dot clock/4
  187. #define TVP3026_VCLK_DOTCLOCK_DIV8 (3 << 4)// VCLK is equal to Dot clock/8
  188. #define TVP3026_VCLK_DOTCLOCK_DIV16 (4 << 4)// VCLK is equal to Dot clock/16
  189. #define TVP3026_VCLK_DOTCLOCK_DIV32 (5 << 4)// VCLK is equal to Dot clock/32
  190. #define TVP3026_VCLK_DOTCLOCK_DIV64 (6 << 4)// VCLK is equal to Dot clock/64
  191. #define TVP3026_CLK_CLK0 (0 << 0)// Select CLK0 as clock source
  192. #define TVP3026_CLK_CLK1 (1 << 0)// Select CLK1 as clock source
  193. #define TVP3026_CLK_CLK2_TTL (2 << 0)// Select CLK2 as clock source
  194. #define TVP3026_CLK_CLK2N_TTL (3 << 0)// Select /CLK2 as clock source
  195. #define TVP3026_CLK_CLK2_ECL (4 << 0)// Select CLK2 and /CLK2 as ECL clock source
  196. #define TVP3026_CLK_PIXEL_PLL (5 << 0)// Select Pixel Clock PLL as clock source
  197. #define TVP3026_CLK_DISABLE (6 << 0)// Disable clock source / Power-save mode
  198. #define TVP3026_CLK_CLK0_VGA (7 << 0)// Select CLK0 as clock source with VGA latching
  199. /********************************************************************************/
  200. /* INDIRECT REGISTER - PALETTE PAGE */
  201. /********************************************************************************/
  202. #define __TVP3026_PALETTE_PAGE 0x1C //
  203. // Default - 0x00
  204. /********************************************************************************/
  205. /* INDIRECT REGISTER - GENERAL CONTROL */
  206. /********************************************************************************/
  207. #define __TVP3026_GENERAL_CONTROL 0x1D //
  208. // Default - 0x00
  209. #define TVP3026_OVERSCAN_ENABLE (1 << 6)// Enable overscan coloring
  210. #define TVP3026_OVERSCAN_DISABLE (0 << 6)// Disable overscan coloring
  211. #define TVP3026_SYNC_ENABLE (1 << 5)// Enable SYNC signal on IOG
  212. #define TVP3026_SYNC_DISABLE (0 << 5)// Disable SYNC signal on IOG
  213. #define TVP3026_PEDESTAL_ON (1 << 4)// Enable 7.5 IRE blanking pedestal
  214. #define TVP3026_PEDESTAL_OFF (0 << 4)// Disable blanking pedestal
  215. #define TVP3026_BIG_ENDIAN (1 << 3)// Big Endian format on pixel bus
  216. #define TVP3026_LITTLE_ENDIAN (0 << 3)// Little Endian format on pixel bus
  217. #define TVP3026_VSYNC_INVERT (1 << 1)// Invert VSYNC signal on VSYNCOUT
  218. #define TVP3026_VSYNC_NORMAL (0 << 1)// Do not invert VSYNC signal on VSYNCOUT
  219. #define TVP3026_HSYNC_INVERT (1 << 0)// Invert HSYNC signal on HSYNCOUT
  220. #define TVP3026_HSYNC_NORMAL (0 << 0)// Do not invert HSYNC signal on HSYNCOUT
  221. /********************************************************************************/
  222. /* INDIRECT REGISTER - MISC CONTROL */
  223. /********************************************************************************/
  224. #define __TVP3026_MISC_CONTROL 0x1E //
  225. // Default - 0x00
  226. #define TVP3026_PSEL_INVERT (1 << 5)// PSEL == 1 - Pseudo/True Color
  227. #define TVP3026_PSEL_NORMAL (0 << 5)// PSEL == 1 - Direct Color
  228. #define TVP3026_PSEL_ENABLE (1 << 4)// PSEL controls Color Switching
  229. #define TVP3026_PSEL_DISABLE (0 << 4)// PSEL is disabled
  230. #define TVP3026_DAC_8BIT (1 << 3)// DAC is in 8-bit mode
  231. #define TVP3026_DAC_6BIT (0 << 3)// DAC is in 6-bit mode
  232. #define TVP3026_DAC_6BITPIN_DISABLE (1 << 2)// Disable 6/8 pin and use bit 3 of this register
  233. #define TVP3026_DAC_6BITPIN_ENABLE (0 << 2)// Use 6/8 pin and ignore bit 3 of this register
  234. #define TVP3026_DAC_POWER_ON (0 << 0)// Turn DAC Power on
  235. #define TVP3026_DAC_POWER_OFF (1 << 0)// Turn DAC Power off
  236. /********************************************************************************/
  237. /* INDIRECT REGISTER - GP I/O CONTROL */
  238. /********************************************************************************/
  239. #define __TVP3026_GP_CONTROL 0x2A //
  240. // Default - 0x00
  241. /********************************************************************************/
  242. /* INDIRECT REGISTER - GP I/O DATA */
  243. /********************************************************************************/
  244. #define __TVP3026_GP_DATA 0x2B //
  245. // Default - undefined
  246. /********************************************************************************/
  247. /* INDIRECT REGISTER - PLL ADDRESS */
  248. /********************************************************************************/
  249. #define __TVP3026_PLL_ADDRESS 0x2C //
  250. // Default - undefined
  251. #define TVP3026_PIXEL_CLOCK_START 0xFC// Start Pixel Clock Programming
  252. #define TVP3026_MCLK_START 0xF3// Start MCLK Programming
  253. #define TVP3026_LOOP_CLOCK_START 0xCF// Start Loop Clock Programming
  254. /********************************************************************************/
  255. /* INDIRECT REGISTER - PLL PIXEL DATA */
  256. /********************************************************************************/
  257. #define __TVP3026_PLL_PIX_DATA 0x2D //
  258. // Default - undefined
  259. /********************************************************************************/
  260. /* INDIRECT REGISTER - PLL MEMORY DATA */
  261. /********************************************************************************/
  262. #define __TVP3026_PLL_MEM_DATA 0x2E //
  263. // Default - undefined
  264. /********************************************************************************/
  265. /* INDIRECT REGISTER - PLL LOOP DATA */
  266. /********************************************************************************/
  267. #define __TVP3026_PLL_LOOP_DATA 0x2F //
  268. // Default - undefined
  269. /********************************************************************************/
  270. /* INDIRECT REGISTER - COLOR KEY OVERLAY LOW */
  271. /********************************************************************************/
  272. #define __TVP3026_CCOVR_LOW 0x30 //
  273. // Default - undefined
  274. /********************************************************************************/
  275. /* INDIRECT REGISTER - COLOR KEY OVERLAY HIGH */
  276. /********************************************************************************/
  277. #define __TVP3026_CCOVR_HIGH 0x31 //
  278. // Default - undefined
  279. /********************************************************************************/
  280. /* INDIRECT REGISTER - COLOR KEY RED LOW */
  281. /********************************************************************************/
  282. #define __TVP3026_CCRED_LOW 0x32 //
  283. // Default - undefined
  284. /********************************************************************************/
  285. /* INDIRECT REGISTER - COLOR KEY RED HIGH */
  286. /********************************************************************************/
  287. #define __TVP3026_CCRED_HIGH 0x33 //
  288. // Default - undefined
  289. /********************************************************************************/
  290. /* INDIRECT REGISTER - COLOR KEY GREEN LOW */
  291. /********************************************************************************/
  292. #define __TVP3026_CCGREEN_LOW 0x34 //
  293. // Default - undefined
  294. /********************************************************************************/
  295. /* INDIRECT REGISTER - COLOR KEY RED HIGH */
  296. /********************************************************************************/
  297. #define __TVP3026_CCGREEN_HIGH 0x35 //
  298. // Default - undefined
  299. /********************************************************************************/
  300. /* INDIRECT REGISTER - COLOR KEY BLUE LOW */
  301. /********************************************************************************/
  302. #define __TVP3026_CCBLUE_LOW 0x36 //
  303. // Default - undefined
  304. /********************************************************************************/
  305. /* INDIRECT REGISTER - COLOR KEY BLUE HIGH */
  306. /********************************************************************************/
  307. #define __TVP3026_CCBLUE_HIGH 0x37 //
  308. // Default - undefined
  309. /********************************************************************************/
  310. /* INDIRECT REGISTER - COLOR KEY CONTROL */
  311. /********************************************************************************/
  312. #define __TVP3026_CC_CONTROL 0x38 //
  313. // Default - 0x00
  314. /********************************************************************************/
  315. /* INDIRECT REGISTER - MCLK/LOOP CONTROL */
  316. /********************************************************************************/
  317. #define __TVP3026_MCLK_CONTROL 0x39 //
  318. // Default - 0x18
  319. #define TVP3026_RCLK_LOOP (1 << 5)// RCLK is made from LCLK - all other modes
  320. #define TVP3026_RCLK_PIXEL (0 << 5)// RCLK is clocked by Pixel Clock (VGA Mode)
  321. #define TVP3026_MCLK_PLL (1 << 4)// MCLK from PLL - normal mode
  322. #define TVP3026_MCLK_DOT (0 << 4)// MCLK from dot clock - during freq. change
  323. #define TVP3026_MCLK_STROBE_HIGH (1 << 3)// Strobe high for bit 4
  324. #define TVP3026_MCLK_STROBE_LOW (0 << 3)// Strobe low for bit 4
  325. #define TVP3026_LOOP_DIVIDE2 (0 << 0)// Divide Loop clock by 2
  326. #define TVP3026_LOOP_DIVIDE4 (1 << 0)// Divide Loop clock by 4
  327. #define TVP3026_LOOP_DIVIDE6 (2 << 0)// Divide Loop clock by 6
  328. #define TVP3026_LOOP_DIVIDE8 (3 << 0)// Divide Loop clock by 8
  329. #define TVP3026_LOOP_DIVIDE10 (4 << 0)// Divide Loop clock by 10
  330. #define TVP3026_LOOP_DIVIDE12 (5 << 0)// Divide Loop clock by 12
  331. #define TVP3026_LOOP_DIVIDE14 (6 << 0)// Divide Loop clock by 14
  332. #define TVP3026_LOOP_DIVIDE16 (7 << 0)// Divide Loop clock by 16
  333. /********************************************************************************/
  334. /* INDIRECT REGISTER - SENSE TEST */
  335. /********************************************************************************/
  336. #define __TVP3026_SENSE_TEST 0x3A //
  337. // Default - 0x00
  338. /********************************************************************************/
  339. /* INDIRECT REGISTER - TEST MODE DATA */
  340. /********************************************************************************/
  341. #define __TVP3026_TEST_MODE 0x3B //
  342. // Default - undefined
  343. /********************************************************************************/
  344. /* INDIRECT REGISTER - CRC REMAINDER LSB */
  345. /********************************************************************************/
  346. #define __TVP3026_CRC_LSB 0x3C //
  347. // Default - undefined
  348. /********************************************************************************/
  349. /* INDIRECT REGISTER - CRC REMAINDER MSB */
  350. /********************************************************************************/
  351. #define __TVP3026_CRC_MSB 0x3D //
  352. // Default - undefined
  353. /********************************************************************************/
  354. /* INDIRECT REGISTER - CRC BITS SELECT */
  355. /********************************************************************************/
  356. #define __TVP3026_CRC_SELECT 0x3E //
  357. // Default - undefined
  358. /********************************************************************************/
  359. /* INDIRECT REGISTER - SOFTWARE RESET */
  360. /********************************************************************************/
  361. #define __TVP3026_SOFT_RESET 0xFF //
  362. // Default - undefined
  363. //
  364. // On rev 1 chips we need to SYNC with GLINT while accessing the RAMDAC. This
  365. // is because accesses to the RAMDAC can be corrupted by localbuffer
  366. // activity. Put this macro before accesses that can co-exist with GLINT
  367. // 3D activity, Must have initialized glintInfo before using this.
  368. //
  369. #define TVP3026_SYNC_WITH_GLINT \
  370. { \
  371. if (GLInfo.wRenderChipRev == GLINT300SX_REV1) \
  372. SYNC_WITH_GLINT; \
  373. }
  374. /*
  375. // We never need a delay between each write to the 3026. The only way to guarantee
  376. // that the write has completed used to be to read from a GLINT control register.
  377. // Reading forces any posted writes to be flushed out. PPC needs 2 reads
  378. // to give us enough time.
  379. //#define TVP3026_DELAY \
  380. //{ \
  381. // volatile LONG __junk; \
  382. // __junk = pDev->pRegisters->Glint.FBModeSel; \
  383. //}
  384. //#else
  385. */
  386. #define TVP3026_DELAY
  387. // macro to load a given data value into an internal TVP3026 register.
  388. //
  389. #define TVP3026_WRITE_CURRENT_INDEX TVP3026_SET_INDEX_REG
  390. #define TVP3026_SET_INDEX_REG(index) \
  391. { \
  392. VideoPortWriteRegisterUlong(__TVP3026_INDEX_ADDR, (ULONG)((index) & 0xff)); \
  393. TVP3026_DELAY; \
  394. }
  395. #define TVP3026_READ_CURRENT_INDEX(data) \
  396. { \
  397. data = VideoPortReadRegisterUlong(__TVP3026_INDEX_ADDR) & 0xff; \
  398. TVP3026_DELAY; \
  399. }
  400. #define TVP3026_WRITE_INDEX_REG(index, data) \
  401. { \
  402. TVP3026_SET_INDEX_REG(index); \
  403. ADbgpf(("*(0x%X) <-- 0x%X\n", __TVP3026_INDEX_DATA, (data) & 0xff)); \
  404. VideoPortWriteRegisterUlong(__TVP3026_INDEX_DATA, (ULONG)((data) & 0xff)); \
  405. TVP3026_DELAY; \
  406. }
  407. #define TVP3026_READ_INDEX_REG(index, data) \
  408. { \
  409. TVP3026_SET_INDEX_REG(index); \
  410. data = VideoPortReadRegisterUlong(__TVP3026_INDEX_DATA) & 0xff; \
  411. TVP3026_DELAY; \
  412. ADbgpf(("0x%X <-- *(0x%X)\n", data, __TVP3026_INDEX_DATA)); \
  413. }
  414. // macros to write a given RGB triplet into cursors 0, 1 and 2
  415. #define TVP3026_SET_CURSOR_COLOR0(red, green, blue) \
  416. { \
  417. VideoPortWriteRegisterUlong(__TVP3026_CUR_WR_ADDR, (ULONG)(TVP3026_CURSOR_COLOR0)); \
  418. TVP3026_DELAY; \
  419. VideoPortWriteRegisterUlong(__TVP3026_CUR_DATA, (ULONG)(red)); \
  420. TVP3026_DELAY; \
  421. VideoPortWriteRegisterUlong(__TVP3026_CUR_DATA, (ULONG)(green)); \
  422. TVP3026_DELAY; \
  423. VideoPortWriteRegisterUlong(__TVP3026_CUR_DATA, (ULONG)(blue)); \
  424. TVP3026_DELAY; \
  425. }
  426. #define TVP3026_SET_CURSOR_COLOR1(red, green, blue) \
  427. { \
  428. VideoPortWriteRegisterUlong(__TVP3026_CUR_WR_ADDR, (ULONG)(TVP3026_CURSOR_COLOR1)); \
  429. TVP3026_DELAY; \
  430. VideoPortWriteRegisterUlong(__TVP3026_CUR_DATA, (ULONG)(red)); \
  431. TVP3026_DELAY; \
  432. VideoPortWriteRegisterUlong(__TVP3026_CUR_DATA, (ULONG)(green)); \
  433. TVP3026_DELAY; \
  434. VideoPortWriteRegisterUlong(__TVP3026_CUR_DATA, (ULONG)(blue)); \
  435. TVP3026_DELAY; \
  436. }
  437. #define TVP3026_SET_CURSOR_COLOR2(red, green, blue) \
  438. { \
  439. VideoPortWriteRegisterUlong(__TVP3026_CUR_WR_ADDR, (ULONG)(TVP3026_CURSOR_COLOR2)); \
  440. TVP3026_DELAY; \
  441. VideoPortWriteRegisterUlong(__TVP3026_CUR_DATA, (ULONG)(red)); \
  442. TVP3026_DELAY; \
  443. VideoPortWriteRegisterUlong(__TVP3026_CUR_DATA, (ULONG)(green)); \
  444. TVP3026_DELAY; \
  445. VideoPortWriteRegisterUlong(__TVP3026_CUR_DATA, (ULONG)(blue)); \
  446. TVP3026_DELAY; \
  447. }
  448. #define TVP3026_SET_OVERSCAN_COLOR(red, green, blue) \
  449. { \
  450. VideoPortWriteRegisterUlong(__TVP3026_OVRC_WR_ADDR, (ULONG)(TVP3026_OVERSCAN_COLOR)); \
  451. TVP3026_DELAY; \
  452. VideoPortWriteRegisterUlong(__TVP3026_OVRC_DATA, (ULONG)(red)); \
  453. TVP3026_DELAY; \
  454. VideoPortWriteRegisterUlong(__TVP3026_OVRC_DATA, (ULONG)(green)); \
  455. TVP3026_DELAY; \
  456. VideoPortWriteRegisterUlong(__TVP3026_OVRC_DATA, (ULONG)(blue)); \
  457. TVP3026_DELAY; \
  458. }
  459. // macros to load a given RGB triple into the TVP3026 palette. Send the starting
  460. // index and then send RGB triples. Auto-increment is turned on.
  461. // Use TVP3026_PALETTE_START and multiple TVP3026_LOAD_PALETTE calls to load
  462. // a contiguous set of entries. Use TVP3026_LOAD_PALETTE_INDEX to load a set
  463. // of sparse entries.
  464. //
  465. #define TVP3026_PALETTE_START_WR(index) \
  466. { \
  467. VideoPortWriteRegisterUlong(__TVP3026_PAL_WR_ADDR, (ULONG)(index)); \
  468. TVP3026_DELAY; \
  469. }
  470. #define TVP3026_PALETTE_START_RD(index) \
  471. { \
  472. VideoPortWriteRegisterUlong(__TVP3026_PAL_RD_ADDR, (ULONG)(index)); \
  473. TVP3026_DELAY; \
  474. }
  475. #define TVP3026_LOAD_PALETTE(red, green, blue) \
  476. { \
  477. VideoPortWriteRegisterUlong(__TVP3026_PAL_DATA, (ULONG)(red)); \
  478. TVP3026_DELAY; \
  479. VideoPortWriteRegisterUlong(__TVP3026_PAL_DATA, (ULONG)(green)); \
  480. TVP3026_DELAY; \
  481. VideoPortWriteRegisterUlong(__TVP3026_PAL_DATA, (ULONG)(blue)); \
  482. TVP3026_DELAY; \
  483. }
  484. #define TVP3026_LOAD_PALETTE_INDEX(index, red, green, blue) \
  485. { \
  486. VideoPortWriteRegisterUlong(__TVP3026_PAL_WR_ADDR, (ULONG)(index)); \
  487. TVP3026_DELAY; \
  488. VideoPortWriteRegisterUlong(__TVP3026_PAL_DATA, (ULONG)(red)); \
  489. TVP3026_DELAY; \
  490. VideoPortWriteRegisterUlong(__TVP3026_PAL_DATA, (ULONG)(green)); \
  491. TVP3026_DELAY; \
  492. VideoPortWriteRegisterUlong(__TVP3026_PAL_DATA, (ULONG)(blue)); \
  493. TVP3026_DELAY; \
  494. }
  495. // macro to read back a given RGB triple from the TVP3026 palette. Use after
  496. // a call to TVP3026_PALETTE_START_RD
  497. //
  498. #define TVP3026_READ_PALETTE(red, green, blue) \
  499. { \
  500. red = VideoPortReadRegisterUlong(__TVP3026_PAL_DATA) & 0xff; \
  501. TVP3026_DELAY; \
  502. green = VideoPortReadRegisterUlong(__TVP3026_PAL_DATA) & 0xff; \
  503. TVP3026_DELAY; \
  504. blue = VideoPortReadRegisterUlong(__TVP3026_PAL_DATA) & 0xff; \
  505. TVP3026_DELAY; \
  506. }
  507. // macros to set/get the pixel read mask. The mask is 8 bits wide and gets
  508. // replicated across all bytes that make up a pixel.
  509. //
  510. #define TVP3026_SET_PIXEL_READMASK(mask) \
  511. { \
  512. VideoPortWriteRegisterUlong(__TVP3026_PIXEL_MASK, (ULONG)(mask)); \
  513. TVP3026_DELAY; \
  514. }
  515. #define TVP3026_READ_PIXEL_READMASK(mask) \
  516. { \
  517. mask = VideoPortReadRegisterUlong(__TVP3026_PIXEL_MASK) & 0xff; \
  518. }
  519. // macros to load values into the cursor array
  520. //
  521. #define TVP3026_CURSOR_ARRAY_START(offset) \
  522. { \
  523. volatile LONG __temp; \
  524. TVP3026_READ_INDEX_REG(__TVP3026_CURSOR_CONTROL, __temp); \
  525. __temp &= ~TVP3026_CURSOR_RAM_MASK ; \
  526. __temp |= TVP3026_CURSOR_RAM_ADDRESS((offset)>> 8) ; \
  527. TVP3026_WRITE_INDEX_REG(__TVP3026_CURSOR_CONTROL, __temp); \
  528. VideoPortWriteRegisterUlong(__TVP3026_CUR_RAM_WR_ADDR, (ULONG)((offset)& 0xff)); \
  529. TVP3026_DELAY; \
  530. }
  531. #define TVP3026_LOAD_CURSOR_ARRAY(data) \
  532. { \
  533. VideoPortWriteRegisterUlong(__TVP3026_CUR_RAM_DATA, (ULONG)(data)); \
  534. TVP3026_DELAY; \
  535. }
  536. #define TVP3026_READ_CURSOR_ARRAY(data) \
  537. { \
  538. data = VideoPortReadRegisterUlong(__TVP3026_CUR_RAM_DATA) & 0xff; \
  539. TVP3026_DELAY; \
  540. }
  541. #define TVP3026_LOAD_CURSOR_CTRL(data) \
  542. { \
  543. VideoPortWriteRegisterUlong(__TVP3026_CUR_CTL, (ULONG)(data)); \
  544. TVP3026_DELAY; \
  545. }
  546. // macro to move the cursor
  547. //
  548. #define TVP3026_MOVE_CURSOR(x, y) \
  549. { \
  550. VideoPortWriteRegisterUlong(__TVP3026_CUR_X_LSB, (ULONG)((x) & 0xff)); \
  551. TVP3026_DELAY; \
  552. VideoPortWriteRegisterUlong(__TVP3026_CUR_X_MSB, (ULONG)((x) >> 8)); \
  553. TVP3026_DELAY; \
  554. VideoPortWriteRegisterUlong(__TVP3026_CUR_Y_LSB, (ULONG)((y) & 0xff)); \
  555. TVP3026_DELAY; \
  556. VideoPortWriteRegisterUlong(__TVP3026_CUR_Y_MSB, (ULONG)((y) >> 8)); \
  557. TVP3026_DELAY; \
  558. }
  559. // macro to change the cursor hotspot
  560. //
  561. #define TVP3026_CURSOR_HOTSPOT(x, y) \
  562. { \
  563. TVP3026_DELAY; \
  564. }
  565. #define TVP3026_IS_FOUND(bFound) \
  566. {\
  567. volatile LONG __revLevel; \
  568. volatile LONG __productID; \
  569. volatile LONG __oldValue; \
  570. __oldValue = VideoPortReadRegisterUlong(__TVP3026_INDEX_ADDR);\
  571. TVP3026_DELAY; \
  572. TVP3026_READ_INDEX_REG (__TVP3026_SILICON_REVISION, __revLevel);\
  573. TVP3026_READ_INDEX_REG (__TVP3026_CHIP_ID, __productID); \
  574. bFound = ( (__revLevel >= TVP3026_REVISION_LEVEL) && \
  575. (__productID == TVP3026_ID_CODE)) ? TRUE : FALSE ; \
  576. VideoPortWriteRegisterUlong(__TVP3026_INDEX_ADDR, __oldValue ); \
  577. TVP3026_DELAY; \
  578. }