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.

1116 lines
43 KiB

  1. /*/****************************************************************************
  2. * name: MGAVidInit
  3. *
  4. * description: Initialise the VIDEO related hardware of the MGA device.
  5. *
  6. * designed: Bart Simpson, february 11, 1993
  7. * last modified: $Author: bleblanc $, $Date: 94/11/09 10:48:34 $
  8. *
  9. * version: $Id: VID.C 1.49 94/11/09 10:48:34 bleblanc Exp $
  10. *
  11. * parameters: BYTE* to Video buffer
  12. * modifies: MGA hardware
  13. * calls: GetMGAConfiguration
  14. * returns: -
  15. ******************************************************************************/
  16. #include "switches.h"
  17. #include "g3dstd.h"
  18. #include "caddi.h"
  19. #include "def.h"
  20. #include "mga.h"
  21. #include "global.h"
  22. #include "proto.h"
  23. #include "mgai.h"
  24. #ifdef WINDOWS_NT
  25. #include "video.h"
  26. #if defined(ALLOC_PRAGMA)
  27. #pragma alloc_text(PAGE,MGAVidInit)
  28. #endif
  29. #endif
  30. /* extern void setTVP3026Freq(volatile BYTE _Far *pDevice, LONG fout_voulue, LONG reg, WORD pWidth); */
  31. /*-------------- start of extern global variables -----------------------*/
  32. VOID MGAVidInit(BYTE* pInitBuffer, BYTE* pVideoBuffer)
  33. {
  34. DWORD DST0, DST1, Info;
  35. DWORD TmpDword, ByteCount, RegisterCount;
  36. BYTE TmpByte, DUB_SEL;
  37. BOOL pixelClk90Mhz;
  38. volatile BYTE _Far *pDevice;
  39. WORD res;
  40. #if( defined(WINDOWS) || defined(OS2))
  41. ((struct {unsigned short o; short s;}*) &pDevice)->o = *((WORD*)(pInitBuffer + INITBUF_MgaOffset));
  42. ((struct {unsigned short o; short s;}*) &pDevice)->s = *((WORD*)(pInitBuffer + INITBUF_MgaSegment));
  43. #else
  44. #ifdef WINDOWS_NT
  45. pDevice = (BYTE *)(*((DWORD*)(pInitBuffer + INITBUF_MgaOffset)));
  46. #else
  47. #ifdef __MICROSOFTC600__
  48. /*** DOS real-mode 32-bit address ***/
  49. pDevice = *((DWORD*)(pInitBuffer + INITBUF_MgaOffset));
  50. #else
  51. /*** DOS protected-mode 48-bit address ***/
  52. ((struct {unsigned long o; short s;}*) &pDevice)->o = *((DWORD*)(pInitBuffer + INITBUF_MgaOffset));
  53. ((struct {unsigned long o; short s;}*) &pDevice)->s = *((WORD*)(pInitBuffer + INITBUF_MgaSegment));
  54. #endif
  55. #endif
  56. #endif
  57. /* value is true if PixelClk >= 90Mhz */
  58. pixelClk90Mhz = *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)) >= 90000;
  59. /*** ##### DUBIC PATCH Disable mouse IRQ and proceed ###### ***/
  60. if ( (*((BYTE*)(pInitBuffer + INITBUF_DubicPresent))) ) /* Dubic Present */
  61. {
  62. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_NDX_PTR), 0x08);
  63. mgaReadBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_DUB_SEL), DUB_SEL);
  64. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_DUB_SEL), 0x00);
  65. }
  66. /*** ###################################################### ***/
  67. /*** Get System Configuration ***/
  68. GetMGAConfiguration(pDevice, &DST0, &DST1, &Info);
  69. /*** Program the Titan CRTC_CTRL register ***/
  70. mgaReadDWORD(*(pDevice + TITAN_OFFSET + TITAN_CRT_CTRL), TmpDword);
  71. TmpDword &= ~((DWORD)TITAN_CRTCBPP_M |
  72. (DWORD)TITAN_ALW_M |
  73. (DWORD)TITAN_INTERLACE_M |
  74. (DWORD)TITAN_VIDEODELAY0_M |
  75. (DWORD)TITAN_VIDEODELAY1_M |
  76. (DWORD)TITAN_VIDEODELAY2_M |
  77. (DWORD)TITAN_VSCALE_M |
  78. (DWORD)TITAN_SYNCDEL_M);
  79. TmpDword |= ((DWORD)(*((BYTE*)(pInitBuffer + INITBUF_PWidth))) << TITAN_CRTCBPP_A) & (DWORD)TITAN_CRTCBPP_M;
  80. /* PACK PIXEL */
  81. if( !(*((BYTE*)(pInitBuffer + INITBUF_PWidth)) == (BYTE)(TITAN_PWIDTH_PW24 >> TITAN_PWIDTH_A))/* NOT PACK PIXEL */ )
  82. TmpDword |= ((DWORD)(*((BYTE*)(pVideoBuffer + VIDEOBUF_ALW))) << TITAN_ALW_A) & (DWORD)TITAN_ALW_M;
  83. if (*((BYTE*)(pVideoBuffer + VIDEOBUF_Interlace)) == TRUE)
  84. {
  85. if (*((WORD*)(pInitBuffer + INITBUF_ScreenWidth)) <= (WORD)768)
  86. {
  87. TmpDword |= (DWORD)TITAN_INTERLACE_768;
  88. }
  89. else
  90. {
  91. if (*((WORD*)(pInitBuffer + INITBUF_ScreenWidth)) <= (WORD)1024)
  92. {
  93. TmpDword |= (DWORD)TITAN_INTERLACE_1024;
  94. }
  95. else
  96. {
  97. TmpDword |= (DWORD)TITAN_INTERLACE_1280;
  98. }
  99. }
  100. }
  101. TmpDword |= ((DWORD)(*((BYTE*)(pVideoBuffer + VIDEOBUF_VideoDelay))) << TITAN_VIDEODELAY0_A) & (DWORD)TITAN_VIDEODELAY0_M;
  102. TmpDword |= ((DWORD)(*((BYTE*)(pVideoBuffer + VIDEOBUF_VideoDelay))) << (TITAN_VIDEODELAY1_A - 1)) & (DWORD)TITAN_VIDEODELAY1_M;
  103. TmpDword |= ((DWORD)(*((BYTE*)(pVideoBuffer + VIDEOBUF_VideoDelay))) << (TITAN_VIDEODELAY2_A - 2)) & (DWORD)TITAN_VIDEODELAY2_M;
  104. /* Programing Atlas VSCALE and SYNCDEL if NO DUBIC */
  105. if ( !(*((BYTE*)(pInitBuffer + INITBUF_DubicPresent))) ) /* No Dubic */
  106. {
  107. /*********************************************************************/
  108. if ( ((Info & (DWORD)Info_Dac_M) != (DWORD)Info_Dac_ViewPoint ) &&
  109. (*((BYTE*)(pInitBuffer + INITBUF_ChipSet)) != 2/*ATHENA_CHIP*/)
  110. )
  111. {
  112. /*------ hsync and vsync polarity extern implementation */
  113. mgaReadBYTE(*(pDevice + TITAN_OFFSET + TITAN_CONFIG + 2), TmpByte);
  114. TmpByte |= 1; /* Expansion device available <16> of CONFIG */
  115. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_CONFIG + 2), TmpByte);
  116. TmpByte = *(BYTE*)(pVideoBuffer + VIDEOBUF_VsyncPol);
  117. TmpByte |= *(BYTE*)(pVideoBuffer + VIDEOBUF_HsyncPol) << 1;
  118. mgaWriteBYTE(*(pDevice + EXPDEV_OFFSET), TmpByte );
  119. }
  120. /*********************************************************************/
  121. /*** Set synch polarity for athena chipset ***/
  122. /* MISC REGISTER
  123. bit 7: 0 - Vsync positive
  124. 1 - Vsync negative
  125. bit 6: 0 - Hsync positive
  126. 1 - Hsync negative
  127. */
  128. if(*((BYTE*)(pInitBuffer + INITBUF_ChipSet)) == 2/*ATHENA_CHIP*/)
  129. {
  130. mgaReadBYTE(*(pDevice + TITAN_OFFSET + TITAN_MISC_OUT_R), TmpByte);
  131. TmpByte &= 0x3f; /* Set bit <7:6> to 0 */
  132. TmpByte |= *(BYTE*)(pVideoBuffer + VIDEOBUF_HsyncPol) << 6;
  133. TmpByte |= *(BYTE*)(pVideoBuffer + VIDEOBUF_VsyncPol) << 7;
  134. if (((Info & (DWORD)Info_Dac_M) == (DWORD)Info_Dac_TVP3026) ||
  135. ((Info & (DWORD)Info_Dac_M) == (DWORD)Info_Dac_ViewPoint)
  136. )
  137. TmpByte |= 0xc0; /* force <7:6> to negative polarity and
  138. use DAC support for synch polarity */
  139. else
  140. TmpByte ^= 0xc0; /* reverse bit <7:6> */
  141. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_MISC_OUT_W), TmpByte);
  142. }
  143. switch (Info & (DWORD)Info_Dac_M)
  144. {
  145. case (DWORD)Info_Dac_BT484:
  146. case (DWORD)Info_Dac_BT485:
  147. case (DWORD)Info_Dac_PX2085:
  148. case (DWORD)Info_Dac_ATT2050:
  149. switch ( *((BYTE*)(pVideoBuffer + VIDEOBUF_HsyncDelay)) )
  150. {
  151. default:
  152. case 0:
  153. TmpDword |= (((DWORD)0 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  154. break;
  155. case 3:
  156. TmpDword |= (((DWORD)1 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  157. break;
  158. case 5:
  159. TmpDword |= (((DWORD)2 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  160. break;
  161. case 8:
  162. TmpDword |= (((DWORD)3 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  163. break;
  164. }
  165. /* PACK PIXEL */
  166. switch ( *((BYTE*)(pInitBuffer + INITBUF_PWidth)) & 0x3 )
  167. {
  168. case TITAN_CRTCBPP_8:
  169. TmpDword |= (DWORD)0x01 << TITAN_VSCALE_A;
  170. break; /* 0x1 = clock divide by 2 */
  171. case TITAN_CRTCBPP_16:
  172. TmpDword |= (((DWORD)0 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  173. TmpDword |= (DWORD)0x02 << TITAN_VSCALE_A;
  174. break;
  175. case TITAN_CRTCBPP_32:
  176. TmpDword |= (((DWORD)0 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  177. TmpDword |= (DWORD)0x03 << TITAN_VSCALE_A;
  178. break;
  179. }
  180. break;
  181. case (DWORD)Info_Dac_ViewPoint:
  182. case (DWORD)Info_Dac_TVP3026:
  183. switch ( *((BYTE*)(pVideoBuffer + VIDEOBUF_HsyncDelay)) )
  184. {
  185. case 0:
  186. case 1:
  187. TmpDword |= (((DWORD)0 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  188. break;
  189. case 2:
  190. case 3:
  191. TmpDword |= (((DWORD)1 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  192. break;
  193. case 4:
  194. case 5:
  195. case 6:
  196. TmpDword |= (((DWORD)2 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  197. break;
  198. case 7:
  199. case 8:
  200. default:
  201. TmpDword |= (((DWORD)3 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  202. break;
  203. }
  204. /* PACK PIXEL */
  205. switch ( *((BYTE*)(pInitBuffer + INITBUF_PWidth)) & 0x3)
  206. { /* for PRO board (2 DUBIC) */
  207. case TITAN_CRTCBPP_8:
  208. TmpDword |= (((DWORD)0 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  209. break; /* VSCALE = 0 */
  210. case TITAN_CRTCBPP_16:
  211. TmpDword |= (((DWORD)0 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  212. TmpDword |= (DWORD)0x01 << TITAN_VSCALE_A;
  213. break;
  214. case TITAN_CRTCBPP_32:
  215. TmpDword |= (((DWORD)0 << TITAN_SYNCDEL_A) & (DWORD)TITAN_SYNCDEL_M);
  216. TmpDword |= (DWORD)0x02 << TITAN_VSCALE_A;
  217. break;
  218. }
  219. break;
  220. }
  221. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_CRT_CTRL), TmpDword);
  222. }
  223. else /* ELSE NO DUBIC programming DUBIC */
  224. {
  225. mgaWriteDWORD(*(pDevice + TITAN_OFFSET + TITAN_CRT_CTRL), TmpDword);
  226. /*** Program the Dubic DUB_CTL register ***/
  227. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_NDX_PTR), DUBIC_DUB_CTL);
  228. for (TmpDword = 0, ByteCount = 0; ByteCount <= 3; ByteCount++)
  229. {
  230. mgaReadBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_DATA), TmpByte);
  231. TmpDword |= ((DWORD)TmpByte << ((DWORD)8 * ByteCount));
  232. }
  233. /** Do not program the LVID field, KEEP it for EXTERNAL APPLICATION
  234. *** if bit 7 of LvidInitFlag is 1
  235. **/
  236. if (*((BYTE*)(pVideoBuffer + VIDEOBUF_LvidInitFlag)) & 0x80)
  237. {
  238. TmpDword &= ~((DWORD)DUBIC_IMOD_M | (DWORD)DUBIC_VSYNC_POL_M | (DWORD)DUBIC_HSYNC_POL_M |
  239. (DWORD)DUBIC_DACTYPE_M | (DWORD)DUBIC_INT_EN_M | (DWORD)DUBIC_GENLOCK_M |
  240. (DWORD)DUBIC_BLANK_SEL_M | (DWORD)DUBIC_SYNC_DEL_M | (DWORD)DUBIC_SRATE_M |
  241. (DWORD)DUBIC_FBM_M | (DWORD)DUBIC_VGA_EN_M | (DWORD)DUBIC_BLANKDEL_M);
  242. }
  243. else /*** disable live video ***/
  244. {
  245. TmpDword &= ~((DWORD)DUBIC_IMOD_M | (DWORD)DUBIC_VSYNC_POL_M | (DWORD)DUBIC_HSYNC_POL_M |
  246. (DWORD)DUBIC_DACTYPE_M | (DWORD)DUBIC_INT_EN_M | (DWORD)DUBIC_GENLOCK_M |
  247. (DWORD)DUBIC_BLANK_SEL_M | (DWORD)DUBIC_SYNC_DEL_M | (DWORD)DUBIC_SRATE_M |
  248. (DWORD)DUBIC_FBM_M | (DWORD)DUBIC_VGA_EN_M | (DWORD)DUBIC_BLANKDEL_M |
  249. (DWORD)DUBIC_LVID_M);
  250. }
  251. TmpDword |= ((~((DWORD)(*((BYTE*)(pInitBuffer + INITBUF_PWidth))) + (DWORD)1)) << DUBIC_IMOD_A) & (DWORD)DUBIC_IMOD_M;
  252. TmpDword |= ((DWORD)(*((BYTE*)(pVideoBuffer + VIDEOBUF_VsyncPol))) << DUBIC_VSYNC_POL_A) & (DWORD)DUBIC_VSYNC_POL_M;
  253. TmpDword |= ((DWORD)(*((BYTE*)(pVideoBuffer + VIDEOBUF_HsyncPol))) << DUBIC_HSYNC_POL_A) & (DWORD)DUBIC_HSYNC_POL_M;
  254. TmpDword |= (Info << DUBIC_DACTYPE_A) & (DWORD)DUBIC_DACTYPE_M;
  255. if (*((BYTE*)(pVideoBuffer + VIDEOBUF_Interlace)) == TRUE)
  256. {
  257. TmpDword |= (DWORD)DUBIC_INT_EN_M;
  258. }
  259. /*** GenLock forced to 0 ***/
  260. /*** vga_en forced to 0 ***/
  261. /*** BlankSel forced to 0 (only one DAC) ***/
  262. /*** Blankdel forced to 0 for mode TERMINATOR ***/
  263. switch (Info & (DWORD)Info_Dac_M) /*** IMOD need to be set in TmpDword (DUB_CTL) ***/
  264. {
  265. case (DWORD)Info_Dac_ATT:
  266. switch (TmpDword & (DWORD)DUBIC_IMOD_M)
  267. {
  268. case (DWORD)DUBIC_IMOD_32:
  269. TmpDword |= (((DWORD)1 << DUBIC_SYNC_DEL_A) & (DWORD)DUBIC_SYNC_DEL_M);
  270. break;
  271. case (DWORD)DUBIC_IMOD_16:
  272. TmpDword |= (((DWORD)8 << DUBIC_SYNC_DEL_A) & (DWORD)DUBIC_SYNC_DEL_M);
  273. break;
  274. case (DWORD)DUBIC_IMOD_8:
  275. TmpDword |= (((DWORD)4 << DUBIC_SYNC_DEL_A) & (DWORD)DUBIC_SYNC_DEL_M);
  276. break;
  277. }
  278. break;
  279. case (DWORD)Info_Dac_BT481:
  280. case (DWORD)Info_Dac_BT482:
  281. switch (TmpDword & (DWORD)DUBIC_IMOD_M)
  282. {
  283. case (DWORD)DUBIC_IMOD_32:
  284. TmpDword |= (((DWORD)1 << DUBIC_SYNC_DEL_A) & (DWORD)DUBIC_SYNC_DEL_M);
  285. break;
  286. case (DWORD)DUBIC_IMOD_16:
  287. TmpDword |= (((DWORD)8 << DUBIC_SYNC_DEL_A) & (DWORD)DUBIC_SYNC_DEL_M);
  288. break;
  289. case (DWORD)DUBIC_IMOD_8:
  290. TmpDword |= (((DWORD)7 << DUBIC_SYNC_DEL_A) & (DWORD)DUBIC_SYNC_DEL_M);
  291. break;
  292. }
  293. break;
  294. case (DWORD)Info_Dac_Sierra:
  295. switch (TmpDword & (DWORD)DUBIC_IMOD_M)
  296. {
  297. case (DWORD)DUBIC_IMOD_32:
  298. TmpDword |= (((DWORD)1 << DUBIC_SYNC_DEL_A) & (DWORD)DUBIC_SYNC_DEL_M);
  299. break;
  300. case (DWORD)DUBIC_IMOD_16:
  301. TmpDword |= (((DWORD)12 << DUBIC_SYNC_DEL_A) & (DWORD)DUBIC_SYNC_DEL_M);
  302. break;
  303. case (DWORD)DUBIC_IMOD_8:
  304. TmpDword |= (((DWORD)8 << DUBIC_SYNC_DEL_A) & (DWORD)DUBIC_SYNC_DEL_M);
  305. break;
  306. }
  307. break;
  308. case (DWORD)Info_Dac_BT484:
  309. case (DWORD)Info_Dac_BT485:
  310. case (DWORD)Info_Dac_PX2085:
  311. case (DWORD)Info_Dac_ATT2050:
  312. /*** BEN note: Definir cette facon de faire pour les autres RAMDAC lorsque
  313. ce sera calcule dans vidfile.c ... ***/
  314. TmpDword |= ( ((DWORD)(*((BYTE*)(pVideoBuffer + VIDEOBUF_HsyncDelay))) << DUBIC_SYNC_DEL_A) & (DWORD)DUBIC_SYNC_DEL_M);
  315. break;
  316. case (DWORD)Info_Dac_Chameleon: /*** UNKNOWN ***/
  317. break;
  318. case (DWORD)Info_Dac_TVP3026:
  319. case (DWORD)Info_Dac_ViewPoint:
  320. TmpDword |= ( ((DWORD)(*((BYTE*)(pVideoBuffer + VIDEOBUF_HsyncDelay))) << DUBIC_SYNC_DEL_A) & (DWORD)DUBIC_SYNC_DEL_M);
  321. TmpDword |= (DWORD)DUBIC_BLANKDEL_M;
  322. break;
  323. }
  324. TmpDword |= ((DWORD)(*((BYTE*)(pInitBuffer + INITBUF_FBM))) << DUBIC_FBM_A) & (DWORD)DUBIC_FBM_M;
  325. TmpDword |= ((DWORD)(*((BYTE*)(pVideoBuffer + VIDEOBUF_Srate))) << DUBIC_SRATE_A) & (DWORD)DUBIC_SRATE_M;
  326. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_NDX_PTR), DUBIC_DUB_CTL);
  327. for (ByteCount = 0; ByteCount <= 3; ByteCount++)
  328. {
  329. TmpByte = (BYTE)(TmpDword >> ((DWORD)8 * ByteCount));
  330. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_DATA), TmpByte);
  331. }
  332. /*** Program the Dubic DUB_CTL2 register ***/
  333. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_NDX_PTR), DUBIC_DUB_CTL2);
  334. for (TmpDword = 0, ByteCount = 0; ByteCount <= 3; ByteCount++)
  335. {
  336. mgaReadBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_DATA), TmpByte);
  337. TmpDword |= ((DWORD)TmpByte << ((DWORD)8 * ByteCount));
  338. }
  339. /*** !!!??? This comment is not valid since we set LVIDFIELD just after that ***/
  340. /** Do not program the LVIDFIELD field, KEEP it for EXTERNAL APPLICATION
  341. *** if bit 7 of LvidInitFlag is 1
  342. **/
  343. if (*((BYTE*)(pVideoBuffer + VIDEOBUF_LvidInitFlag)) & 0x80)
  344. {
  345. TmpDword &= ~((DWORD)DUBIC_SYNCEN_M | (DWORD)DUBIC_LASERSCL_M |
  346. (DWORD)DUBIC_CLKSEL_M | (DWORD)DUBIC_LDCLKEN_M);
  347. }
  348. else /*** Disable live video ***/
  349. {
  350. TmpDword &= ~((DWORD)DUBIC_SYNCEN_M | (DWORD)DUBIC_LASERSCL_M | (DWORD)DUBIC_LVIDFIELD_M |
  351. (DWORD)DUBIC_CLKSEL_M | (DWORD)DUBIC_LDCLKEN_M);
  352. }
  353. /** Because we lost the cursor in interlace mode , we have to program **/
  354. /** LVIDFIELD to 1 **/
  355. if (*((BYTE*)(pVideoBuffer + VIDEOBUF_Interlace)) == TRUE)
  356. TmpDword |= (DWORD)DUBIC_LVIDFIELD_M;
  357. else
  358. TmpDword &= ~((DWORD)DUBIC_LVIDFIELD_M);
  359. TmpDword |= ((DWORD)(*((BYTE*)(pVideoBuffer + VIDEOBUF_LaserScl))) << DUBIC_LASERSCL_A) & (DWORD)DUBIC_LASERSCL_M;
  360. TmpDword |= (DWORD)DUBIC_SYNCEN_M; /*** sync forced to enable ***/
  361. /*** CLOCKSEL forced to 0 except for viewpoint ***/
  362. if (
  363. ((Info & (DWORD)Info_Dac_M) == Info_Dac_ViewPoint) ||
  364. ((Info & (DWORD)Info_Dac_M) == Info_Dac_TVP3026)
  365. )
  366. TmpDword |= (DWORD)DUBIC_CLKSEL_M;
  367. /* Special case for BT485: LDCLKEN must be set to 1 only in VGA mode */
  368. /* and in 24-bit mode */
  369. if( ((Info & (DWORD)Info_Dac_M) == (DWORD)Info_Dac_BT485) ||
  370. ((Info & (DWORD)Info_Dac_M) == (DWORD)Info_Dac_PX2085) ||
  371. ((Info & (DWORD)Info_Dac_M) == (DWORD)Info_Dac_ATT2050)
  372. )
  373. {
  374. if( *((BYTE*)(pInitBuffer + INITBUF_PWidth)) == (BYTE)(TITAN_PWIDTH_PW32 >> TITAN_PWIDTH_A) )
  375. TmpDword |= (DWORD)DUBIC_LDCLKEN_M; /*** ldclkl running ***/
  376. }
  377. else
  378. TmpDword |= (DWORD)DUBIC_LDCLKEN_M; /*** ldclkl running ***/
  379. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_NDX_PTR), DUBIC_DUB_CTL2);
  380. for (ByteCount = 0; ByteCount <= 3; ByteCount++)
  381. {
  382. TmpByte = (BYTE)(TmpDword >> ((DWORD)8 * ByteCount));
  383. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_DATA), TmpByte);
  384. }
  385. /*** Program the Dubic OVS_COL register ***/
  386. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_NDX_PTR), DUBIC_OVS_COL);
  387. TmpDword = *((DWORD*)(pVideoBuffer + VIDEOBUF_OvsColor));
  388. for (ByteCount = 0; ByteCount <= 3; ByteCount++)
  389. {
  390. TmpByte = (BYTE)(TmpDword >> ((DWORD)8 * ByteCount));
  391. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_DATA), TmpByte);
  392. }
  393. }
  394. /*** Program the RAMDAC ***/
  395. switch (Info & (DWORD)Info_Dac_M)
  396. {
  397. case (DWORD)Info_Dac_ATT: /*** UNKNOWN ***/
  398. break;
  399. case (DWORD)Info_Dac_BT481: /*** UNKNOWN ***/
  400. break;
  401. case (DWORD)Info_Dac_BT482:
  402. switch (*((BYTE*)(pInitBuffer + INITBUF_PWidth)))
  403. {
  404. case (BYTE)(TITAN_PWIDTH_PW8 >> TITAN_PWIDTH_A):
  405. TmpByte = 0x01;
  406. break;
  407. case (BYTE)(TITAN_PWIDTH_PW16 >> TITAN_PWIDTH_A):
  408. if ( *((BYTE*)(pInitBuffer + INITBUF_565Mode)) )
  409. TmpByte = 0xe1;
  410. else
  411. TmpByte = 0xa1;
  412. break;
  413. }
  414. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT482_CMD_REGA), TmpByte);
  415. /*** Read Mask (INDIRECT) ***/
  416. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT482_WADR_PAL), 0x00);
  417. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT482_PIX_RD_MSK), 0xff);
  418. /*** Command Register B (INDIRECT) ***/
  419. TmpByte = ((*((BYTE*)(pVideoBuffer + VIDEOBUF_Pedestal)) & (BYTE)0x1) << 5) | (BYTE)0x02;
  420. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT482_WADR_PAL), 0x02);
  421. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT482_PIX_RD_MSK), TmpByte);
  422. /*** Cursor Register (INDIRECT) ***/
  423. TmpByte = ((*((BYTE*)(pVideoBuffer + VIDEOBUF_Interlace)) & (BYTE)0x1) << 4) | (BYTE)0x04;
  424. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT482_WADR_PAL), 0x03);
  425. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT482_PIX_RD_MSK), TmpByte);
  426. break;
  427. case (DWORD)Info_Dac_Sierra: /*** UNKNOWN ***/
  428. break;
  429. case (DWORD)Info_Dac_BT484:
  430. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT484_PIX_RD_MSK), 0xff);
  431. /* Overlay must me 0 */
  432. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT484_WADR_OVL), 0x00);
  433. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT484_COL_OVL), 0x00);
  434. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT484_COL_OVL), 0x00);
  435. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT484_COL_OVL), 0x00);
  436. /** BEN 0x1e */
  437. TmpByte = ((*((BYTE*)(pVideoBuffer + VIDEOBUF_Pedestal)) & (BYTE)0x1) << 5) | (BYTE)0x02;
  438. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT484_CMD_REG0), TmpByte);
  439. switch (*((BYTE*)(pInitBuffer + INITBUF_PWidth)))
  440. {
  441. case (BYTE)(TITAN_PWIDTH_PW8 >> TITAN_PWIDTH_A):
  442. TmpByte = 0x40;
  443. break;
  444. case (BYTE)(TITAN_PWIDTH_PW16 >> TITAN_PWIDTH_A):
  445. if ( *((BYTE*)(pInitBuffer + INITBUF_565Mode)) )
  446. TmpByte = 0x28;
  447. else
  448. TmpByte = 0x20;
  449. break;
  450. case (BYTE)(TITAN_PWIDTH_PW32 >> TITAN_PWIDTH_A):
  451. TmpByte = 0x00;
  452. break;
  453. }
  454. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT484_CMD_REG1), TmpByte);
  455. TmpByte = ((*((BYTE*)(pVideoBuffer + VIDEOBUF_Interlace)) & (BYTE)0x1) << 3) | (BYTE)0x24;
  456. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT484_CMD_REG2), TmpByte);
  457. break;
  458. case (DWORD)Info_Dac_BT485:
  459. case (DWORD)Info_Dac_PX2085:
  460. case (DWORD)Info_Dac_ATT2050:
  461. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_PIX_RD_MSK), 0xff);
  462. /** BEN 0x9e */
  463. /* OverScan must me 0 */
  464. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_WADR_OVL), 0x00);
  465. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_COL_OVL), 0x00);
  466. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_COL_OVL), 0x00);
  467. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_COL_OVL), 0x00);
  468. TmpByte = ((*((BYTE*)(pVideoBuffer + VIDEOBUF_Pedestal)) & (BYTE)0x1) << 5) | (BYTE)0x82;
  469. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CMD_REG0), TmpByte);
  470. switch (*((BYTE*)(pInitBuffer + INITBUF_PWidth)))
  471. {
  472. case (BYTE)(TITAN_PWIDTH_PW8 >> TITAN_PWIDTH_A):
  473. TmpByte = 0x40;
  474. break;
  475. case (BYTE)(TITAN_PWIDTH_PW16 >> TITAN_PWIDTH_A):
  476. if ( *((BYTE*)(pInitBuffer + INITBUF_565Mode)) )
  477. TmpByte = 0x28;
  478. else
  479. TmpByte = 0x20;
  480. break;
  481. case (BYTE)(TITAN_PWIDTH_PW32 >> TITAN_PWIDTH_A):
  482. TmpByte = 0x00;
  483. break;
  484. }
  485. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CMD_REG1), TmpByte);
  486. if( ((Info & (DWORD)Info_Dac_M) == (DWORD)Info_Dac_BT485) ||
  487. ((Info & (DWORD)Info_Dac_M) == (DWORD)Info_Dac_ATT2050)
  488. )
  489. TmpByte = ((*((BYTE*)(pVideoBuffer + VIDEOBUF_Interlace)) & (BYTE)0x1) << 3) | (BYTE)0x24;
  490. else /* PX2085 */
  491. TmpByte = ((*((BYTE*)(pVideoBuffer + VIDEOBUF_Interlace)) & (BYTE)0x1) << 3) | (BYTE)0x44;
  492. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CMD_REG2), TmpByte);
  493. /*** Indirect addressing from STATUS REGISTER ***/
  494. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_WADR_PAL), 0x01);
  495. switch (*((BYTE*)(pInitBuffer + INITBUF_PWidth)))
  496. {
  497. case (BYTE)(TITAN_PWIDTH_PW8 >> TITAN_PWIDTH_A):
  498. case (BYTE)(TITAN_PWIDTH_PW16 >> TITAN_PWIDTH_A):
  499. if ( ((Info & (DWORD)Info_Dac_M) == (DWORD)Info_Dac_PX2085) ||
  500. ((Info & (DWORD)Info_Dac_M) == (DWORD)Info_Dac_BT485) ||
  501. pixelClk90Mhz /* pclk >= 90Mhz */
  502. )
  503. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CMD_REG3), 0x08);
  504. else
  505. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CMD_REG3), 0x00);
  506. break;
  507. case (BYTE)(TITAN_PWIDTH_PW32 >> TITAN_PWIDTH_A):
  508. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + BT485_CMD_REG3), 0x00);
  509. break;
  510. }
  511. break;
  512. case (DWORD)Info_Dac_Chameleon: /*** UNKNOWN ***/
  513. break;
  514. case (DWORD)Info_Dac_ViewPoint:
  515. /* Software reset to put the DAC in a default state */
  516. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_RESET);
  517. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x00 );
  518. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_PIX_RD_MSK), 0xff);
  519. /* OverScan must me 0 */
  520. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_OVS_RED);
  521. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x00 );
  522. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_OVS_GREEN);
  523. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x00 );
  524. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_OVS_BLUE);
  525. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x00 );
  526. /* Misc. Control Register */
  527. TmpByte = ((*((BYTE*)(pVideoBuffer + VIDEOBUF_Pedestal)) & (BYTE)0x1) << 4);
  528. /*** (94/02/07) BEN modif to program sync polarity in VIEWPOINT ***/
  529. /*** (94/04/11) Christian: doesn't apply for ATHENA ***/
  530. /* if ( ! (*((BYTE*)(pInitBuffer + INITBUF_DubicPresent))) && */
  531. /* (*((BYTE*)(pInitBuffer + INITBUF_ChipSet)) != 2) */ /*ATHENA_CHIP*/
  532. /* ) */
  533. if ( ! (*((BYTE*)(pInitBuffer + INITBUF_DubicPresent))))
  534. {
  535. TmpByte &= 0xfc; /* Set bit 0,1 to 0 */
  536. TmpByte |= *(BYTE*)(pVideoBuffer + VIDEOBUF_HsyncPol);
  537. TmpByte |= *(BYTE*)(pVideoBuffer + VIDEOBUF_VsyncPol) << 1;
  538. }
  539. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_GEN_CTL);
  540. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), TmpByte);
  541. /* Multiplex Control Register (True Color 24 bit) */
  542. switch (*((BYTE*)(pInitBuffer + INITBUF_PWidth)))
  543. {
  544. case (BYTE)(TITAN_PWIDTH_PW8 >> TITAN_PWIDTH_A):
  545. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_MUX_CTL1);
  546. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x80 );
  547. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_MUX_CTL2);
  548. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x1c );
  549. break;
  550. case (BYTE)(TITAN_PWIDTH_PW16 >> TITAN_PWIDTH_A):
  551. if ( *((BYTE*)(pInitBuffer + INITBUF_565Mode)) )
  552. {
  553. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_MUX_CTL1);
  554. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x45 ); /* XGA */
  555. }
  556. else
  557. {
  558. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_MUX_CTL1);
  559. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x44 ); /* Targa */
  560. }
  561. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_MUX_CTL2);
  562. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x04 );
  563. break;
  564. case (BYTE)(TITAN_PWIDTH_PW32 >> TITAN_PWIDTH_A):
  565. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_MUX_CTL1);
  566. #if !(MACRO_ECHO)
  567. if ( *((BYTE*)(pInitBuffer + INITBUF_ChipSet)) == 1) /* ATLAS */
  568. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x46 );
  569. else
  570. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x46 );
  571. #else
  572. /*
  573. * Redundant if-else causes massive compilation error in macro
  574. * debug echo mode.
  575. */
  576. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x46 );
  577. #endif
  578. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_MUX_CTL2);
  579. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x04 );
  580. break;
  581. }
  582. /* Input Clock Select Register (Select CLK1 as doubled clock source */
  583. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_INPUT_CLK);
  584. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x11 );
  585. /* Output Clock Selection Register Bits
  586. VCLK/2 output ratio (xx001xxx)
  587. RCLK/2 output ratio (xxxxx001)
  588. */
  589. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_OUTPUT_CLK);
  590. switch (*((BYTE*)(pInitBuffer + INITBUF_PWidth)))
  591. {
  592. case (BYTE)(TITAN_PWIDTH_PW8 >> TITAN_PWIDTH_A):
  593. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x5b );
  594. break;
  595. case (BYTE)(TITAN_PWIDTH_PW16 >> TITAN_PWIDTH_A):
  596. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x52 );
  597. break;
  598. case (BYTE)(TITAN_PWIDTH_PW32 >> TITAN_PWIDTH_A):
  599. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x49 );
  600. break;
  601. }
  602. if ( ! (*((BYTE*)(pInitBuffer + INITBUF_DubicPresent))) )
  603. {
  604. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_GEN_IO_CTL);
  605. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x03 );
  606. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_GEN_IO_DATA);
  607. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x01 );
  608. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_AUX_CTL);
  609. switch (*((BYTE*)(pInitBuffer + INITBUF_PWidth)))
  610. {
  611. case (BYTE)(TITAN_PWIDTH_PW8 >> TITAN_PWIDTH_A):
  612. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x09 );
  613. break;
  614. case (BYTE)(TITAN_PWIDTH_PW16 >> TITAN_PWIDTH_A):
  615. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x08 );
  616. break;
  617. case (BYTE)(TITAN_PWIDTH_PW32 >> TITAN_PWIDTH_A):
  618. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x08 );
  619. break;
  620. }
  621. }
  622. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_INDEX), VPOINT_KEY_CTL);
  623. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + VPOINT_DATA), (BYTE)0x10 );
  624. break;
  625. case (DWORD)Info_Dac_TVP3026:
  626. /* Software reset to put the DAC in a default state */
  627. res = *((WORD*)(pInitBuffer + INITBUF_ScreenWidth));
  628. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_PIX_RD_MSK), 0xff);
  629. /* FIX AVEC GAL DAT No GEN014 */
  630. /* general purpose I/O tell to the gal the vertical resolution */
  631. /* if vertical resolution is >= 1024, the count is by increment
  632. /* of two */
  633. if ( res < 1280)
  634. {
  635. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_GEN_IO_CTL);
  636. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x00 );
  637. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_GEN_IO_DATA);
  638. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x01 );
  639. }
  640. else
  641. {
  642. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_GEN_IO_CTL);
  643. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x01 );
  644. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_GEN_IO_DATA);
  645. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x00 );
  646. }
  647. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_MISC_CTL);
  648. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x0c);
  649. /* init Interlace Cursor support */
  650. /* NOTE: We set the vertival detect method bit to 1 to be in synch
  651. with NPI diag code. Whith some video parameters, the cursor
  652. disaper if we put this bit a 0.
  653. */
  654. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_CURSOR_CTL);
  655. mgaReadBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), TmpByte);
  656. /* Set interlace bit */
  657. TmpByte &= ~(BYTE)(1 << 5);
  658. TmpByte |= (((*((BYTE*)(pVideoBuffer + VIDEOBUF_Interlace)) & (BYTE)0x1)) << 5);
  659. /* Set vertival detect method */
  660. TmpByte |= 0x10;
  661. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), TmpByte);
  662. /* OverScan must me 0 */
  663. /* Overscan is not enabled in general ctl register */
  664. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_CUR_COL_ADDR), 00);
  665. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_CUR_COL_DATA), 00);
  666. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_CUR_COL_DATA), 00);
  667. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_CUR_COL_DATA), 00);
  668. /* Put to ZERO */
  669. /* Misc. Control Register */
  670. TmpByte = ((*((BYTE*)(pVideoBuffer + VIDEOBUF_Pedestal)) & (BYTE)0x1) << 4);
  671. /* For the TVP3026, we use DAC capability for sync polarity */
  672. if (! (*((BYTE*)(pInitBuffer + INITBUF_DubicPresent))) )
  673. {
  674. TmpByte &= 0xfc; /* Set bit 0,1 to 0 */
  675. TmpByte |= *(BYTE*)(pVideoBuffer + VIDEOBUF_HsyncPol);
  676. TmpByte |= *(BYTE*)(pVideoBuffer + VIDEOBUF_VsyncPol) << 1;
  677. }
  678. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_GEN_CTL);
  679. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), TmpByte);
  680. /* Multiplex Control Register (True Color 24 bit) */
  681. switch (*((BYTE*)(pInitBuffer + INITBUF_PWidth)))
  682. {
  683. case (BYTE)(TITAN_PWIDTH_PW8 >> TITAN_PWIDTH_A):
  684. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_CLK_SEL);
  685. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0xb5 );
  686. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_TRUE_COLOR_CTL);
  687. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0xa0 );
  688. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_MUX_CTL);
  689. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x4c );
  690. break;
  691. case (BYTE)(TITAN_PWIDTH_PW16 >> TITAN_PWIDTH_A):
  692. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_CLK_SEL);
  693. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0xa5 );
  694. if ( *((BYTE*)(pInitBuffer + INITBUF_565Mode)) )
  695. {
  696. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_TRUE_COLOR_CTL);
  697. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x65 );
  698. }
  699. else
  700. {
  701. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_TRUE_COLOR_CTL);
  702. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x64 );
  703. }
  704. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_MUX_CTL);
  705. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x54 );
  706. break;
  707. case (BYTE)(TITAN_PWIDTH_PW32 >> TITAN_PWIDTH_A):
  708. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_CLK_SEL);
  709. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x95 );
  710. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_TRUE_COLOR_CTL);
  711. if ( *((BYTE*)(pInitBuffer + INITBUF_ChipSet)) == 1) /* ATLAS */
  712. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x66 );
  713. else
  714. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x66 );
  715. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_MUX_CTL);
  716. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x5c );
  717. break;
  718. case (BYTE)(TITAN_PWIDTH_PW24 >> TITAN_PWIDTH_A):
  719. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_CLK_SEL);
  720. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x95 );
  721. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_TRUE_COLOR_CTL);
  722. if ( *((BYTE*)(pInitBuffer + INITBUF_ChipSet)) == 1) /* ATLAS */
  723. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x76 );
  724. else
  725. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x76 );
  726. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_MUX_CTL);
  727. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), (BYTE)0x5c );
  728. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_LATCH_CTL);
  729. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), 4 );
  730. break;
  731. }
  732. if ( *((BYTE*)(pInitBuffer + INITBUF_DB_FrontBack)) )
  733. {
  734. /** Enable double buffer feature of the TVP3026 and set DAC mask **/
  735. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_TRUE_COLOR_CTL);
  736. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), 0xA0);
  737. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_MUX_CTL);
  738. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), 0x54);
  739. /*** Always display buffer A ***/
  740. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_INDEX), TVP3026_LATCH_CTL);
  741. mgaWriteBYTE(*(pDevice + RAMDAC_OFFSET + TVP3026_DATA), 0x86);
  742. }
  743. break;
  744. }
  745. /*** Program the LUT in the DAC (the LUT is internal to the function) ***/
  746. /*** Done only if flag LUTMode is FALSE ***/
  747. if ( ! (*((BYTE*)(pInitBuffer + INITBUF_LUTMode))) )
  748. {
  749. if ( *((BYTE*)(pInitBuffer + INITBUF_565Mode)) )
  750. SetMGALUT(pDevice, (BYTE*)0, *((BYTE*)(pInitBuffer + INITBUF_PWidth)), 0x08);
  751. else if ( *((BYTE*)(pInitBuffer + INITBUF_DB_FrontBack)) )
  752. SetMGALUT(pDevice, (BYTE*)0, *((BYTE*)(pInitBuffer + INITBUF_PWidth)), 0x10);
  753. else
  754. SetMGALUT(pDevice, (BYTE*)0, *((BYTE*)(pInitBuffer + INITBUF_PWidth)), 0);
  755. }
  756. /*** Program the CLOCK GENERATOR ***/
  757. switch (Info & (DWORD)Info_Dac_M)
  758. {
  759. case (DWORD)Info_Dac_BT482:
  760. switch (*((BYTE*)(pInitBuffer + INITBUF_PWidth)))
  761. {
  762. case (BYTE)(TITAN_PWIDTH_PW8 >> TITAN_PWIDTH_A):
  763. setFrequence(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)), 2);
  764. break;
  765. case (BYTE)(TITAN_PWIDTH_PW16 >> TITAN_PWIDTH_A):
  766. setFrequence(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)) << 1, 2);
  767. break;
  768. case (BYTE)(TITAN_PWIDTH_PW32 >> TITAN_PWIDTH_A):
  769. setFrequence(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)) << 1, 2);
  770. break;
  771. }
  772. break;
  773. case (DWORD)Info_Dac_BT485:
  774. case (DWORD)Info_Dac_PX2085:
  775. switch (*((BYTE*)(pInitBuffer + INITBUF_PWidth)))
  776. {
  777. case (BYTE)(TITAN_PWIDTH_PW8 >> TITAN_PWIDTH_A):
  778. setFrequence(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)) >> 1, 2);
  779. break;
  780. case (BYTE)(TITAN_PWIDTH_PW16 >> TITAN_PWIDTH_A):
  781. setFrequence(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)) >> 1, 2);
  782. break;
  783. case (BYTE)(TITAN_PWIDTH_PW32 >> TITAN_PWIDTH_A):
  784. setFrequence(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)), 2);
  785. break;
  786. }
  787. break;
  788. case (DWORD)Info_Dac_ATT2050:
  789. switch (*((BYTE*)(pInitBuffer + INITBUF_PWidth)))
  790. {
  791. case (BYTE)(TITAN_PWIDTH_PW8 >> TITAN_PWIDTH_A):
  792. case (BYTE)(TITAN_PWIDTH_PW16 >> TITAN_PWIDTH_A):
  793. if (pixelClk90Mhz) /* pclk >= 90Mhz */
  794. setFrequence(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)) >> 1, 2);
  795. else
  796. setFrequence(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)), 2);
  797. break;
  798. case (BYTE)(TITAN_PWIDTH_PW32 >> TITAN_PWIDTH_A):
  799. setFrequence(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)), 2);
  800. break;
  801. }
  802. break;
  803. case (DWORD)Info_Dac_ViewPoint:
  804. setFrequence(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)) >> 1, 2);
  805. break;
  806. case (DWORD)Info_Dac_TVP3026:
  807. setTVP3026Freq(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)), 2, *((BYTE*)(pInitBuffer + INITBUF_PWidth)));
  808. /*** BEN we call it twice because of a bug with setup program for windows at
  809. 1152x882x24 ***/
  810. setTVP3026Freq(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)), 2, *((BYTE*)(pInitBuffer + INITBUF_PWidth)));
  811. break;
  812. default:
  813. setFrequence(pDevice, *((DWORD*)(pVideoBuffer + VIDEOBUF_PCLK)), 2);
  814. break;
  815. }
  816. /*** Program the CRTC ***/
  817. /*** Select access on 0x3d4 and 0x3d5 ***/
  818. mgaReadBYTE(*(pDevice + TITAN_OFFSET + TITAN_MISC_OUT_R), TmpByte);
  819. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_MISC_OUT_W), (TmpByte | (BYTE)0x01));
  820. /*** Unprotect registers 0-7 ***/
  821. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_1_CRTC_ADDR), 0x11);
  822. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_1_CRTC_DATA), 0x40);
  823. for (RegisterCount = 0; RegisterCount <= 24; RegisterCount++)
  824. {
  825. TmpByte = *((BYTE*)(pVideoBuffer + VIDEOBUF_CRTC + RegisterCount));
  826. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_1_CRTC_ADDR), (unsigned char)RegisterCount);
  827. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_1_CRTC_DATA), TmpByte);
  828. }
  829. /*** Get extended address register ***/
  830. RegisterCount = (DWORD)26;
  831. TmpByte = *((BYTE*)(pVideoBuffer + VIDEOBUF_CRTC + RegisterCount));
  832. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_AUX_ADDR), 0x0A);
  833. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_AUX_DATA), TmpByte);
  834. RegisterCount = (DWORD)28;
  835. TmpByte = *((BYTE*)(pVideoBuffer + VIDEOBUF_CRTC + RegisterCount));
  836. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_AUX_ADDR), 0x0D);
  837. mgaWriteBYTE(*(pDevice + TITAN_OFFSET + TITAN_AUX_DATA), TmpByte);
  838. /*** Get interlace support register ***/
  839. /*** ##### DUBIC PATCH ReEnable mouse IRQ ################# ***/
  840. if ( (*((BYTE*)(pInitBuffer + INITBUF_DubicPresent))) ) /* Dubic Present */
  841. {
  842. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_NDX_PTR), 0x08);
  843. mgaWriteBYTE(*(pDevice + DUBIC_OFFSET + DUBIC_DUB_SEL), DUB_SEL);
  844. }
  845. /*** ###################################################### ***/
  846. }
  847.