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.

678 lines
18 KiB

  1. //***************************************************************************
  2. //
  3. // DVDCPGD.CPP
  4. // Analog Copy protection Processor Routine
  5. //
  6. // Author:
  7. // TOSHIBA [PCS](PSY) Satoshi Watanabe
  8. // Copyright (c) 1997 TOSHIBA CORPORATION
  9. //
  10. // Description:
  11. // 03/05/97 converted from VxD source
  12. // 03/09/97 converted C++ class
  13. //
  14. //***************************************************************************
  15. #include "common.h"
  16. #include "regs.h"
  17. #include "dvdcpgd.h"
  18. //--- 97.09.15 K.Chujo
  19. //=================================================//
  20. // Burst Inverse line data( Color stripe off ) //
  21. //=================================================//
  22. ULONG CPGD_BSTLNOFF_SIZE = 0x1A;
  23. WORD CPGD_BSTLNOFF_DATA[] = {
  24. 0x0000, 0x0000, 0x0000, 0x0000,
  25. 0x0000, 0x0000, 0x0000, 0x0000,
  26. 0x0000, 0x0000, 0x0000, 0x0000,
  27. 0x0000, 0x0000, 0x0000, 0x0000,
  28. 0x0000, 0x0000, 0x0000, 0x0000,
  29. 0x0000, 0x0000, 0x0000, 0x0000,
  30. 0x0000, 0x0000
  31. };
  32. //=================================================//
  33. // Burst Inverse line data( Color stripe 2 line) //
  34. //=================================================//
  35. ULONG CPGD_BSTLN2_SIZE = 0x1A;
  36. WORD CPGD_BSTLN2_DATA[] = {
  37. 0x001D, 0x002E, 0x003F, 0x0050,
  38. 0x0061, 0x0072, 0x0083, 0x0094,
  39. 0x00A5, 0x00B6, 0x00C7, 0x00D8,
  40. 0x00E9, 0x012C, 0x013D, 0x014E,
  41. 0x015F, 0x0170, 0x0181, 0x0192,
  42. 0x01A3, 0x01B4, 0x01C5, 0x01D6,
  43. 0x01E7, 0x01F8
  44. };
  45. //=================================================//
  46. // Burst Inverse line data( Color stripe 4 line) //
  47. //=================================================//
  48. ULONG CPGD_BSTLN4_SIZE = 0x1A;
  49. WORD CPGD_BSTLN4_DATA[] = {
  50. 0x0017, 0x002C, 0x0041, 0x0056,
  51. 0x006B, 0x0080, 0x0095, 0x00AA,
  52. 0x00BF, 0x00D4, 0x00E9, 0x0000,
  53. 0x0000, 0x0128, 0x013D, 0x0152,
  54. 0x0167, 0x017C, 0x0191, 0x01A6,
  55. 0x01BB, 0x01D0, 0x01E5, 0x01FA,
  56. 0x0000, 0x0000
  57. };
  58. //=================================================//
  59. // AGC data (for Y of S input) //
  60. //=================================================//
  61. WORD CPGD_AGC_Y_TBL[] = {
  62. 0x03E7, 0x03E2, 0x03DE, 0x03D9, 0x03D5, 0x03D0, 0x03CC, 0x03C7,
  63. 0x03C3, 0x03BE, 0x03BA, 0x03B5, 0x03B1, 0x03AC, 0x03A8, 0x03A3,
  64. 0x039E, 0x039A, 0x0395, 0x0391, 0x038C, 0x0388, 0x0383, 0x037F,
  65. 0x037A, 0x0376, 0x0371, 0x036D, 0x0368, 0x0363, 0x035F, 0x035A,
  66. 0x0356, 0x0351, 0x034D, 0x0348, 0x0344, 0x033F, 0x033B, 0x0336,
  67. 0x0332, 0x032D, 0x0329, 0x0324, 0x031F, 0x031B, 0x0316, 0x0312,
  68. 0x030D, 0x0309, 0x0304, 0x0300, 0x02FB, 0x02F7, 0x02F2, 0x02EE,
  69. 0x02E9, 0x02E4, 0x02E0, 0x02DB, 0x02D7, 0x02D2, 0x02CE, 0x02C9,
  70. 0x02C5, 0x02C0, 0x02BC, 0x02B7, 0x02B3, 0x02AE, 0x02AA, 0x02A5,
  71. 0x02A0, 0x029C, 0x0297, 0x0293, 0x028E, 0x028A, 0x0285, 0x0281,
  72. 0x027C, 0x0278, 0x0273, 0x026F, 0x026A, 0x0265, 0x0261, 0x025C,
  73. 0x0258, 0x0253, 0x024F, 0x024A, 0x0246, 0x0241, 0x023D, 0x0238,
  74. 0x0234, 0x022F, 0x022B, 0x0226, 0x0221, 0x021D, 0x0218, 0x0214,
  75. 0x020F, 0x020B, 0x0206, 0x0202, 0x01FD, 0x01F9, 0x01F4, 0x01F0,
  76. 0x01EB, 0x01E6, 0x01E2, 0x01DD, 0x01D9, 0x01D4, 0x01D0, 0x01CB,
  77. 0x01C7, 0x01C2, 0x01BE, 0x01B9, 0x01B5, 0x01B0, 0x01AC, 0x01A7,
  78. 0x01A2, 0x019E, 0x0199, 0x0195, 0x0190, 0x018C, 0x0187, 0x0183,
  79. 0x017E, 0x017A, 0x0175, 0x0171, 0x016C, 0x0167, 0x0163, 0x015E,
  80. 0x015A, 0x0155, 0x0151, 0x014C, 0x0148, 0x0143, 0x013F, 0x013A,
  81. 0x0136, 0x0131, 0x012D, 0x0128
  82. };
  83. //=================================================//
  84. // AGC data (for Composit input) //
  85. //=================================================//
  86. WORD CPGD_AGC_C_TBL[] = {
  87. 0x0382, 0x037E, 0x037A, 0x0375, 0x0371, 0x036D, 0x0369, 0x0364,
  88. 0x0360, 0x035C, 0x0358, 0x0353, 0x034F, 0x034B, 0x0347, 0x0342,
  89. 0x033E, 0x033A, 0x0336, 0x0331, 0x032D, 0x0329, 0x0325, 0x0320,
  90. 0x031C, 0x0318, 0x0314, 0x030F, 0x030B, 0x0307, 0x0303, 0x02FE,
  91. 0x02FA, 0x02F6, 0x02F2, 0x02ED, 0x02E9, 0x02E5, 0x02E1, 0x02DC,
  92. 0x02D8, 0x02D4, 0x02D0, 0x02CB, 0x02C7, 0x02C3, 0x02BF, 0x02BA,
  93. 0x02B6, 0x02B2, 0x02AE, 0x02A9, 0x02A5, 0x02A1, 0x029D, 0x0299,
  94. 0x0294, 0x0290, 0x028C, 0x0288, 0x0283, 0x027F, 0x027B, 0x0277,
  95. 0x0272, 0x026E, 0x026A, 0x0266, 0x0261, 0x025D, 0x0259, 0x0255,
  96. 0x0250, 0x024C, 0x0248, 0x0244, 0x023F, 0x023B, 0x0237, 0x0233,
  97. 0x022E, 0x022A, 0x0226, 0x0222, 0x021D, 0x0219, 0x0215, 0x0211,
  98. 0x020C, 0x0208, 0x0204, 0x0200, 0x01FB, 0x01F7, 0x01F3, 0x01EF,
  99. 0x01EA, 0x01E6, 0x01E2, 0x01DE, 0x01D9, 0x01D5, 0x01D1, 0x01CD,
  100. 0x01C9, 0x01C4, 0x01C0, 0x01BC, 0x01B8, 0x01B3, 0x01AF, 0x01AB,
  101. 0x01A7, 0x01A2, 0x019E, 0x019A, 0x0196, 0x0191, 0x018D, 0x0189,
  102. 0x0185, 0x0180, 0x017C, 0x0178, 0x0174, 0x016F, 0x016B, 0x0167,
  103. 0x0163, 0x015E, 0x015A, 0x0156, 0x0152, 0x014E, 0x0149, 0x0145,
  104. 0x0141, 0x013C, 0x0138, 0x0134, 0x0130, 0x012B, 0x0127, 0x0123,
  105. 0x011F, 0x011A, 0x0116, 0x0112, 0x010E, 0x0109, 0x0105, 0x0101,
  106. 0x00FD, 0x00F8, 0x00F4, 0x00F0
  107. };
  108. //--- End.
  109. void CGuard::init( const PDEVICE_INIT_INFO pDevInit )
  110. {
  111. ioBase = pDevInit->ioBase;
  112. //--- 97.09.15 K.Chujo
  113. ACGchip = NO_ACG;
  114. //--- End.
  115. }
  116. void CGuard::CPGD_RESET_FUNC()
  117. {
  118. WRITE_PORT_UCHAR( ioBase + CPGD_RESET, 0 );
  119. WRITE_PORT_UCHAR( ioBase + CPGD_RESET, 0x80 );
  120. VproRESET_REG = 0x80;
  121. VproVMODE_REG = 0; // ? ? ?
  122. VproAVM_REG = 0; // ? ? ?
  123. //--- 97.09.15 K.Chujo
  124. CpgdVsyncCount = 0;
  125. CGMSnCPGDvalid = FALSE;
  126. AspectFlag = 0x0000;
  127. LetterFlag = 0x0000;
  128. CgmsFlag = 0x0000;
  129. CpgdFlag = 0x0000;
  130. //--- End.
  131. }
  132. void CGuard::CPGD_VIDEO_MUTE_ON()
  133. {
  134. // debug
  135. // if ( !(VproRESET_REG & 0x80) )
  136. // Error;
  137. // debug
  138. VproRESET_REG |= 0x40;
  139. WRITE_PORT_UCHAR( ioBase + CPGD_RESET, VproRESET_REG );
  140. }
  141. void CGuard::CPGD_VIDEO_MUTE_OFF()
  142. {
  143. // debug
  144. // if ( !(VproRESET_REG & 0x80) )
  145. // Error;
  146. // debug
  147. VproRESET_REG &= 0xbf;
  148. WRITE_PORT_UCHAR( ioBase + CPGD_RESET, VproRESET_REG );
  149. }
  150. void CGuard::CPGD_INIT_NTSC()
  151. {
  152. VproVMODE_REG &= 0x7f;
  153. WRITE_PORT_UCHAR( ioBase + CPGD_VMODE, VproVMODE_REG );
  154. VproAVM_REG &= 0x5f;
  155. WRITE_PORT_UCHAR( ioBase + CPGD_AVM, VproAVM_REG );
  156. WRITE_PORT_UCHAR( ioBase + CPGD_DVEN, 0xc0 );
  157. }
  158. void CGuard::CPGD_INIT_PAL()
  159. {
  160. VproVMODE_REG |= 0x80;
  161. WRITE_PORT_UCHAR( ioBase + CPGD_VMODE, VproVMODE_REG );
  162. VproAVM_REG &= 0x5f;
  163. WRITE_PORT_UCHAR( ioBase + CPGD_AVM, VproAVM_REG );
  164. WRITE_PORT_UCHAR( ioBase + CPGD_DVEN, 0x80 );
  165. }
  166. void CGuard::CPGD_CC_ON()
  167. {
  168. // VproVMODE_REG &= 0xbf;
  169. VproVMODE_REG |= 0x40;
  170. WRITE_PORT_UCHAR( ioBase + CPGD_VMODE, VproVMODE_REG );
  171. }
  172. void CGuard::CPGD_CC_OFF()
  173. {
  174. // VproVMODE_REG |= 0x40;
  175. VproVMODE_REG &= 0xbf;
  176. WRITE_PORT_UCHAR( ioBase + CPGD_VMODE, VproVMODE_REG );
  177. }
  178. void CGuard::CPGD_SUBP_PALETTE( PUCHAR pPalData )
  179. {
  180. ULONG i;
  181. WRITE_PORT_UCHAR( ioBase + CPGD_CPSET, 0x80 );
  182. for( i = 0; i < 48; i++ )
  183. WRITE_PORT_UCHAR( ioBase + CPGD_CPSP, *pPalData++ );
  184. WRITE_PORT_UCHAR( ioBase + CPGD_CPSET, 0x40 );
  185. WRITE_PORT_UCHAR( ioBase + CPGD_CPSET, 0 );
  186. }
  187. void CGuard::CPGD_OSD_PALETTE( PUCHAR pPalData )
  188. {
  189. int i;
  190. WRITE_PORT_UCHAR( ioBase + CPGD_CPSET, 0x20 );
  191. for( i = 0; i < 48; i++ )
  192. WRITE_PORT_UCHAR( ioBase + CPGD_CPSP, *pPalData++ );
  193. WRITE_PORT_UCHAR( ioBase + CPGD_CPSET, 0x10 );
  194. WRITE_PORT_UCHAR( ioBase + CPGD_CPSET, 0 );
  195. }
  196. void CGuard::CPGD_SET_AGC_CHIP( ULONG rev )
  197. {
  198. if( rev==2 || rev==3 )
  199. ACGchip = TC6802;
  200. else if ( rev==4 )
  201. ACGchip = TC6814;
  202. else if ( rev==5 )
  203. ACGchip = TC6818;
  204. else
  205. ACGchip = NO_ACG;
  206. }
  207. void CGuard::CPGD_SET_ASPECT( ULONG aspect )
  208. {
  209. if( ACGchip==NO_ACG ) {
  210. return;
  211. }
  212. else {
  213. CPGD_SET_CGMSnCPGD( aspect, LetterFlag, CgmsFlag, CpgdFlag );
  214. }
  215. }
  216. void CGuard::CPGD_SET_LETTER( ULONG letter )
  217. {
  218. if( ACGchip==NO_ACG ) {
  219. return;
  220. }
  221. else {
  222. CPGD_SET_CGMSnCPGD( AspectFlag, letter, CgmsFlag, CpgdFlag );
  223. }
  224. }
  225. void CGuard::CPGD_SET_CGMS( ULONG cgms )
  226. {
  227. if( ACGchip==NO_ACG ) {
  228. return;
  229. }
  230. else {
  231. CPGD_SET_CGMSnCPGD( AspectFlag, LetterFlag, cgms, CpgdFlag );
  232. }
  233. }
  234. void CGuard::CPGD_SET_CPGD( ULONG cpgd )
  235. {
  236. if( ACGchip==NO_ACG ) {
  237. return;
  238. }
  239. else {
  240. CPGD_SET_CGMSnCPGD( AspectFlag, LetterFlag, CgmsFlag, cpgd );
  241. }
  242. }
  243. void CGuard::CPGD_SET_CGMSnCPGD( ULONG aspect, ULONG letter, ULONG cgms, ULONG cpgd )
  244. {
  245. if( ACGchip == NO_ACG ) {
  246. return;
  247. }
  248. else {
  249. aspect &= 0x01;
  250. letter &= 0x01;
  251. cgms &= 0x03;
  252. cpgd &= 0x03;
  253. if( CGMSnCPGDvalid==FALSE || CpgdFlag!=cpgd) {
  254. AspectFlag = aspect;
  255. LetterFlag = letter;
  256. CgmsFlag = cgms;
  257. CpgdFlag = cpgd;
  258. CPGD_SET_CGMSparameter();
  259. CPGD_SET_CPGDparameter();
  260. CGMSnCPGDvalid = TRUE;
  261. }
  262. else if ( AspectFlag!=aspect || LetterFlag!=letter || CgmsFlag!=cgms ) {
  263. AspectFlag = aspect;
  264. LetterFlag = letter;
  265. CgmsFlag = cgms;
  266. CPGD_SET_CGMSparameter();
  267. }
  268. }
  269. }
  270. void CGuard::CPGD_UPDATE_AGC( void )
  271. {
  272. WORD Cval, Yval;
  273. if( ACGchip==NO_ACG ) {
  274. return;
  275. }
  276. else {
  277. if( CpgdVsyncCount == 0 ) {
  278. Cval = CPGD_AGC_C_TBL[0];
  279. Yval = CPGD_AGC_Y_TBL[0];
  280. CPGD_SET_AGC( Cval, Yval );
  281. // DebugPrint( ( DebugLevelTrace, "TOSDVD: AGC_C %x, AGC_Y %x\r\n", Cval, Yval ) );
  282. }
  283. else if( 720<=CpgdVsyncCount && CpgdVsyncCount<=875 ) {
  284. Cval = CPGD_AGC_C_TBL[CpgdVsyncCount- 720];
  285. Yval = CPGD_AGC_Y_TBL[CpgdVsyncCount- 720];
  286. CPGD_SET_AGC( Cval, Yval );
  287. // DebugPrint( ( DebugLevelTrace, "TOSDVD: AGC_C %x, AGC_Y %x\r\n", Cval, Yval ) );
  288. }
  289. else if( 1044<=CpgdVsyncCount && CpgdVsyncCount<=1199 ) {
  290. Cval = CPGD_AGC_C_TBL[1199-CpgdVsyncCount];
  291. Yval = CPGD_AGC_Y_TBL[1199-CpgdVsyncCount];
  292. CPGD_SET_AGC( Cval, Yval );
  293. // DebugPrint( ( DebugLevelTrace, "TOSDVD: AGC_C %x, AGC_Y %x\r\n", Cval, Yval ) );
  294. }
  295. CpgdVsyncCount++;
  296. if( CpgdVsyncCount>=1200 )
  297. CpgdVsyncCount = 0;
  298. }
  299. }
  300. void CGuard::CPGD_SET_CGMSparameter( void )
  301. {
  302. ULONG tmp;
  303. ULONG crc;
  304. tmp = ( 0x8000 | (AspectFlag<<9) | (LetterFlag<<8) | (CgmsFlag<<6) | (CpgdFlag<<4) );
  305. crc = CPGD_CALC_CRC( tmp ) << 2;
  306. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAL, (UCHAR)(tmp >> 8) );
  307. // DebugPrint( ( DebugLevelTrace, "TOSDVD: CGMSAL%x\r\n", (UCHAR)(tmp>>8) ) );
  308. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAM, (UCHAR)(tmp & 0xFF) );
  309. // DebugPrint( ( DebugLevelTrace, "TOSDVD: CGMSAM%x\r\n", (UCHAR)(tmp&0xFF) ) );
  310. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAH, (UCHAR)(crc & 0xFF) );
  311. // DebugPrint( ( DebugLevelTrace, "TOSDVD: CGMSAH%x\r\n", (crc & 0xFF) ) );
  312. }
  313. void CGuard::CPGD_SET_CPGDparameter( void )
  314. {
  315. ULONG tmp;
  316. ULONG crc;
  317. switch( CpgdFlag ) {
  318. case 0x00 :
  319. CPGD_SET_CLR_STRIPE_OFF();
  320. CPGD_SET_CPGD_0();
  321. break;
  322. case 0x01 :
  323. CPGD_SET_CLR_STRIPE_OFF();
  324. CPGD_SET_CPGD_1();
  325. break;
  326. case 0x02 :
  327. CPGD_SET_CLR_STRIPE_2();
  328. CPGD_SET_CPGD_2();
  329. break;
  330. case 0x03 :
  331. CPGD_SET_CLR_STRIPE_4();
  332. CPGD_SET_CPGD_3();
  333. break;
  334. default :
  335. TRAP;
  336. break;
  337. }
  338. }
  339. void CGuard::CPGD_SET_CGMS_A_0( ULONG aspect, ULONG letter )
  340. {
  341. ULONG temp = 0x8000;
  342. ULONG crc;
  343. if( ACGchip==NO_ACG ) {
  344. return;
  345. }
  346. else {
  347. if( letter!=0 )
  348. temp |= 0x1000;
  349. if( aspect!=0 )
  350. temp |= 0x2000;
  351. temp |= 0xC0;
  352. crc = CPGD_CALC_CRC( temp ) << 2;
  353. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAL, (UCHAR)(temp >> 8) );
  354. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAM, (UCHAR)(temp & 0xFF) );
  355. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAH, (UCHAR)(crc & 0xFF) );
  356. }
  357. }
  358. void CGuard::CPGD_SET_CGMS_A_1( ULONG aspect, ULONG letter )
  359. {
  360. ULONG temp = 0x8000;
  361. ULONG crc;
  362. if( ACGchip==NO_ACG ) {
  363. return;
  364. }
  365. else {
  366. if( letter!=0 )
  367. temp |= 0x1000;
  368. if( aspect!=0 )
  369. temp |= 0x2000;
  370. temp |= 0xD0;
  371. crc = CPGD_CALC_CRC( temp ) << 2;
  372. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAL, (UCHAR)(temp >> 8) );
  373. // DebugPrint( ( DebugLevelTrace, "TOSDVD: CGMSAL%x\r\n", (UCHAR)(temp>>8) ) );
  374. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAM, (UCHAR)(temp & 0xFF) );
  375. // DebugPrint( ( DebugLevelTrace, "TOSDVD: CGMSAM%x\r\n", (UCHAR)(temp&0xFF) ) );
  376. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAH, (UCHAR)(crc & 0xFF) );
  377. // DebugPrint( ( DebugLevelTrace, "TOSDVD: CGMSAH%x\r\n", (crc & 0xFF) ) );
  378. }
  379. }
  380. void CGuard::CPGD_SET_CGMS_A_2( ULONG aspect, ULONG letter )
  381. {
  382. ULONG temp = 0x8000;
  383. ULONG crc;
  384. if( ACGchip==NO_ACG ) {
  385. return;
  386. }
  387. else {
  388. if( letter!=0 )
  389. temp |= 0x1000;
  390. if( aspect!=0 )
  391. temp |= 0x2000;
  392. temp |= 0xE0;
  393. crc = CPGD_CALC_CRC( temp ) << 2;
  394. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAL, (UCHAR)(temp >> 8) );
  395. // DebugPrint( ( DebugLevelTrace, "TOSDVD: CGMSA L = %x\r\n", temp>>8 ) );
  396. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAM, (UCHAR)(temp & 0xFF) );
  397. // DebugPrint( ( DebugLevelTrace, "TOSDVD: CGMSA M = %x\r\n", temp & 0xFF ) );
  398. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAH, (UCHAR)(crc & 0xFF) );
  399. // DebugPrint( ( DebugLevelTrace, "TOSDVD: CGMSA H = %x\r\n", crc & 0xFF ) );
  400. }
  401. }
  402. void CGuard::CPGD_SET_CGMS_A_3( ULONG aspect, ULONG letter )
  403. {
  404. ULONG temp = 0x8000;
  405. ULONG crc;
  406. if( ACGchip==NO_ACG ) {
  407. return;
  408. }
  409. else {
  410. if( letter!=0 )
  411. temp |= 0x1000;
  412. if( aspect!=0 )
  413. temp |= 0x2000;
  414. temp |= 0xF0;
  415. crc = CPGD_CALC_CRC( temp ) << 2;
  416. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAL, (UCHAR)(temp >> 8) );
  417. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAM, (UCHAR)(temp & 0xFF) );
  418. WRITE_PORT_UCHAR( ioBase + CPGD_CGMSAH, (UCHAR)(crc & 0xFF) );
  419. }
  420. }
  421. void CGuard::CPGD_SET_CLR_STRIPE_OFF( void )
  422. {
  423. // notes: *1 are unnecessary originally (if TC6802 is on board).
  424. // But I have to use TC6802 parameters when TC6814/TC6818 is on board for beta 3
  425. // because I can't get RevID ( I can't know which ACG chip is ).
  426. // These codes make safe when TC6814/TC6818 is, of cource TC6802 is, NO PROBLEM.
  427. if( ACGchip==NO_ACG ) {
  428. return;
  429. }
  430. else if( ACGchip==TC6802 ) {
  431. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xB1 ); // *1
  432. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xFE ); // *1
  433. WRITE_PORT_UCHAR( ioBase + CPGD_BSTONY, 0x00 );
  434. // DebugPrint( ( DebugLevelTrace, "TOSDVD: SET_CLR_STRIPE_OFF for TC6802\r\n" ) );
  435. }
  436. else if( ACGchip==TC6814 ) {
  437. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xB1 );
  438. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xFE );
  439. WRITE_PORT_UCHAR( ioBase + CPGD_BSTONY, 0x00 );
  440. CPGD_SET_BURST( CPGD_BSTLNOFF_DATA, CPGD_BSTLNOFF_SIZE );
  441. // DebugPrint( ( DebugLevelTrace, "TOSDVD: SET_CLR_STRIPE_OFF for TC6814\r\n" ) );
  442. }
  443. else if( ACGchip==TC6818 ) {
  444. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xB1 );
  445. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0x04 );
  446. WRITE_PORT_UCHAR( ioBase + CPGD_BSTONY, 0x80 );
  447. // DebugPrint( ( DebugLevelTrace, "TOSDVD: SET_CLR_STRIPE_OFF for TC6818\r\n" ) );
  448. }
  449. }
  450. void CGuard::CPGD_SET_CLR_STRIPE_2( void )
  451. {
  452. if( ACGchip==NO_ACG ) {
  453. return;
  454. }
  455. else if( ACGchip==TC6802 ) {
  456. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xB1 );
  457. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xFE );
  458. WRITE_PORT_UCHAR( ioBase + CPGD_BSTONY, 0x00 );
  459. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0x84 );
  460. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0xAA );
  461. // DebugPrint( ( DebugLevelTrace, "TOSDVD: SET_CLR_STRIPE_2 for TC6802\r\n" ) );
  462. }
  463. else if( ACGchip==TC6814 ) {
  464. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xB1 );
  465. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xFE );
  466. WRITE_PORT_UCHAR( ioBase + CPGD_BSTONY, 0x00 );
  467. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0x84 );
  468. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0xAE );
  469. // DebugPrint( ( DebugLevelTrace, "TOSDVD: SET_CLR_STRIPE_2 for TC6814\r\n" ) );
  470. }
  471. else if( ACGchip==TC6818 ) {
  472. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xB1 );
  473. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0x04 );
  474. WRITE_PORT_UCHAR( ioBase + CPGD_BSTONY, 0x80 );
  475. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0x84 );
  476. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0xAE );
  477. // DebugPrint( ( DebugLevelTrace, "TOSDVD: SET_CLR_STRIPE_2 for TC6818\r\n" ) );
  478. }
  479. CPGD_SET_BURST( CPGD_BSTLN2_DATA, CPGD_BSTLN2_SIZE );
  480. }
  481. void CGuard::CPGD_SET_CLR_STRIPE_4( void )
  482. {
  483. if( ACGchip==NO_ACG ) {
  484. return;
  485. }
  486. else if( ACGchip==TC6802 ) {
  487. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xB1 );
  488. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xFE );
  489. WRITE_PORT_UCHAR( ioBase + CPGD_BSTONY, 0x00 );
  490. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0x84 );
  491. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0xAA );
  492. // DebugPrint( ( DebugLevelTrace, "TOSDVD: SET_CLR_STRIPE_4\r\n" ) );
  493. }
  494. else if( ACGchip==TC6814 ) {
  495. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xB1 );
  496. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xFE );
  497. WRITE_PORT_UCHAR( ioBase + CPGD_BSTONY, 0x00 );
  498. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0x84 );
  499. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0xAE );
  500. }
  501. else if( ACGchip==TC6818 ) {
  502. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0xB1 );
  503. WRITE_PORT_UCHAR( ioBase + CPGD_BSTINT, 0x04 );
  504. WRITE_PORT_UCHAR( ioBase + CPGD_BSTONY, 0x80 );
  505. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0x84 );
  506. WRITE_PORT_UCHAR( ioBase + CPGD_BSTSE, 0xAE );
  507. }
  508. CPGD_SET_BURST( CPGD_BSTLN4_DATA, CPGD_BSTLN4_SIZE );
  509. }
  510. void CGuard::CPGD_SET_CPGD_0( void )
  511. {
  512. if( ACGchip==NO_ACG ) {
  513. return;
  514. }
  515. else {
  516. WRITE_PORT_UCHAR( ioBase + CPGD_CPG, 0x00 );
  517. // DebugPrint( ( DebugLevelTrace, "TOSDVD: SET_CPGD_0\r\n" ) );
  518. }
  519. }
  520. void CGuard::CPGD_SET_CPGD_1( void )
  521. {
  522. if( ACGchip==NO_ACG ) {
  523. return;
  524. }
  525. else {
  526. WRITE_PORT_UCHAR( ioBase + CPGD_CPG, 0xE8 );
  527. // DebugPrint( ( DebugLevelTrace, "TOSDVD: SET_CPGD_1\r\n" ) );
  528. }
  529. }
  530. void CGuard::CPGD_SET_CPGD_2( void )
  531. {
  532. if( ACGchip==NO_ACG ) {
  533. return;
  534. }
  535. else {
  536. WRITE_PORT_UCHAR( ioBase + CPGD_CPG, 0xF8 );
  537. // DebugPrint( ( DebugLevelTrace, "TOSDVD: SET_CPGD_2\r\n" ) );
  538. }
  539. }
  540. void CGuard::CPGD_SET_CPGD_3( void )
  541. {
  542. if( ACGchip==NO_ACG ) {
  543. return;
  544. }
  545. else {
  546. WRITE_PORT_UCHAR( ioBase + CPGD_CPG, 0xF8 );
  547. // DebugPrint( ( DebugLevelTrace, "TOSDVD: SET_CPGD_3\r\n" ) );
  548. }
  549. }
  550. void CGuard::CPGD_SET_BURST( PWORD data, ULONG size )
  551. {
  552. ULONG i;
  553. WORD temp;
  554. for( i=0; i<size; i++ ) {
  555. temp = (*(data+i)) & 0x3FF;
  556. WRITE_PORT_UCHAR( ioBase + CPGD_BSTLSL, temp & 0xFF );
  557. // DebugPrint( ( DebugLevelTrace, "TOSDVD: BURST L %x\r\n", temp & 0xFF ) );
  558. WRITE_PORT_UCHAR( ioBase + CPGD_BSTLSH, temp >> 8 );
  559. // DebugPrint( ( DebugLevelTrace, "TOSDVD: BURST H %x\r\n", temp >> 8 ) );
  560. }
  561. }
  562. void CGuard::CPGD_SET_AGC( WORD Cval, WORD Yval )
  563. {
  564. WORD Lval;
  565. Lval = ((Yval & 0x03) << 4) + ((Cval & 0x03) << 6);
  566. Cval >>= 2;
  567. Yval >>= 2;
  568. WRITE_PORT_UCHAR( ioBase + CPGD_CAGC, (UCHAR)Cval );
  569. WRITE_PORT_UCHAR( ioBase + CPGD_YAGC, (UCHAR)Yval );
  570. WRITE_PORT_UCHAR( ioBase + CPGD_LAGC, (UCHAR)Lval );
  571. }
  572. ULONG CGuard::CPGD_CALC_CRC( ULONG val )
  573. {
  574. ULONG crc = 0;
  575. ULONG i, j;
  576. crc = (val & 0x3FFF) << 6;
  577. i = 0x80000000;
  578. j = 0x86000000; // 100001100....00(b)
  579. do {
  580. // DebugPrint( ( DebugLevelTrace, "TOSDVD: i=%x, j=%x, crc=%x\r\n", i, j, crc ) );
  581. if( (crc & i)==0 ) {
  582. i >>= 1;
  583. j >>= 1;
  584. if( i<=0x20 )
  585. break;
  586. }
  587. else {
  588. crc ^= j;
  589. }
  590. } while( 1 );
  591. return( crc );
  592. }
  593. //void CGuard::CPGD_BURST_Y_OFF( void )
  594. //{
  595. // // always turn off Burst Y.
  596. // if( AGCchip==NO_AGC ) {
  597. // return;
  598. // }
  599. // else if( AGCchip==TC6802 || AGCchip==TC6814 ) {
  600. // WRITE_PORT_UCHAR( ioBase + CPGD_BSTONY, 0x00 );
  601. // DebugPrint( ( DebugLevelTrace, "TOSDVD: BURST_Y_OFF\r\n" ) );
  602. // }
  603. // else if( AGCchip==TC6818 ) {
  604. // // no operation, because this register is set by other functions.
  605. // }
  606. //}