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.

1155 lines
32 KiB

  1. //***************************************************************************
  2. //
  3. // FileName:
  4. // $Workfile: adv.cpp $
  5. // ADV7170 Interface
  6. //
  7. // Author:
  8. // TOSHIBA [PCS](PSY) Seiichi Nakamura
  9. // Copyright (c) 1997 TOSHIBA CORPORATION
  10. //
  11. // Description:
  12. //
  13. //***************************************************************************
  14. // $Header: /DVD Drivers/Sources/ZiVAHAL/adv.cpp 22 98/04/20 7:19p Hero $
  15. // $Modtime: 98/04/20 6:22p $
  16. // $Nokeywords:$
  17. //
  18. // Macrovision 7.01 10/21
  19. //
  20. //***************************************************************************
  21. // Date | Author | Description
  22. // -----------+--------------+--------------------------------------------
  23. // 1997.11.11 | Hideki Yagi | Modify ADV7175A to ADV7170 for San-Jose
  24. // | | Adding SetCgmsType method.
  25. // 12.04 | Hideki Yagi | Adding WSS support.
  26. //
  27. //---------------------------------------------------------------------------
  28. // includes
  29. //---------------------------------------------------------------------------
  30. #include "includes.h"
  31. #include "ioif.h"
  32. #include "timeout.h"
  33. #include "adv.h"
  34. #include "zivachip.h"
  35. #include "mixhal.h"
  36. // by oka
  37. #include "userdata.h"
  38. #include "zivabrd.h"
  39. #define IIC_TIMEOUT (5000)
  40. #define IIC_SLEEPTIME (1)
  41. // ADV7175A/ADV7170 Slave Address
  42. #define SLAVE_ADDR (0x0d4L)
  43. #define COMPOSITE_OFF (0x40)
  44. #define SVIDEO_OFF (0x38)
  45. // by oka
  46. #define CLOSED_CAPTION_ON (0x06)
  47. //---------------------------------------------------------------------------
  48. // CIIC constructor
  49. //---------------------------------------------------------------------------
  50. CIIC::CIIC(void):SubAddr(0),m_pioif(NULL)
  51. {
  52. };
  53. //---------------------------------------------------------------------------
  54. // CIIC::Init
  55. //---------------------------------------------------------------------------
  56. void CIIC::Init(IKernelService *pKernelObj, CIOIF *pioif, BYTE addr )
  57. {
  58. m_pioif = pioif;
  59. SubAddr = addr;
  60. m_pKernelObj = pKernelObj;
  61. };
  62. //---------------------------------------------------------------------------
  63. // CIIC::IICBusyPoll
  64. //---------------------------------------------------------------------------
  65. BOOL CIIC::IICBusyPoll( void )
  66. {
  67. BYTE Data;
  68. CTimeOut TimeOut( IIC_TIMEOUT, IIC_SLEEPTIME , m_pKernelObj );
  69. // following algorithm is very BAD.
  70. while( TRUE )
  71. {
  72. Data = m_pioif->luke2.I2C_CONT.Get(3); // Get I2C_Cont 31-24 bit
  73. if( (Data & 0x80 ) == 0 ) // check busy bit.
  74. return TRUE;
  75. TimeOut.Sleep();
  76. // check Time out....... 1 sec
  77. if( TimeOut.CheckTimeOut() == TRUE )
  78. {
  79. DBG_BREAK();
  80. return FALSE;
  81. };
  82. };
  83. // return FALSE;
  84. };
  85. //---------------------------------------------------------------------------
  86. // CIIC::set
  87. //---------------------------------------------------------------------------
  88. DWORD CIIC::Set( BYTE Data )
  89. {
  90. ASSERT( m_pioif != NULL );
  91. // DBG_PRINTF( ("CADV7170::CIIC::Set SubAddr = 0x%x Data = 0x%x\n", SubAddr, Data) );
  92. // by oka
  93. // if( IICBusyPoll() == FALSE ) return FALSE;
  94. BYTE status = 0x80;
  95. for( DWORD count = 0;(count < 1000) && (status & 0x80) != 0;count++)
  96. {
  97. status = m_pioif->luke2.I2C_CONT.Get(3); // Get I2C_Cont 31-24 bit
  98. }
  99. if (count == 1000){
  100. return FALSE;
  101. }
  102. // end
  103. m_pioif->luke2.I2C_CONT = (DWORD)( ( SLAVE_ADDR << 16 ) | (SubAddr << 8) | Data );
  104. // by oka
  105. // if( IICBusyPoll() == FALSE ) return FALSE;
  106. for( count = 0;(count < 1000) && (status & 0x80) != 0;count++)
  107. {
  108. status = m_pioif->luke2.I2C_CONT.Get(3); // Get I2C_Cont 31-24 bit
  109. }
  110. if (count == 1000){
  111. return FALSE;
  112. }
  113. // end
  114. // if( ( m_pioif->luke2.I2C_CONT.Get(3) & 0x01 ) == 0 ) // check ACK bit
  115. // return FALSE;
  116. return TRUE;
  117. };
  118. //---------------------------------------------------------------------------
  119. // CIIC::Get
  120. //---------------------------------------------------------------------------
  121. DWORD CIIC::Get( BYTE *Data )
  122. {
  123. ASSERT( m_pioif != NULL );
  124. DBG_PRINTF( ("CADV7170::CIIC::Get SubAddr = 0x%x ", SubAddr) );
  125. if( IICBusyPoll() == FALSE ) return FALSE;
  126. m_pioif->luke2.I2C_CONT = ((DWORD)SLAVE_ADDR << 16 ) | 0x06000000L | ((DWORD)SubAddr << 8);
  127. if( IICBusyPoll() == FALSE ) return FALSE;
  128. m_pioif->luke2.I2C_CONT = ((DWORD)(SLAVE_ADDR | 1) << 16 ) | 0x08000000L | ((DWORD)SubAddr << 8);
  129. if( IICBusyPoll() == FALSE ) return FALSE;
  130. *Data = m_pioif->luke2.I2C_CONT.Get(0);
  131. // if( ( m_pioif->luke2.I2C_CONT.Get(3) & 0x01 ) == 0 ) // check ACK bit
  132. // return FALSE;
  133. return TRUE;
  134. };
  135. //***************************************************************************
  136. // CADV7175A control interfaces
  137. //***************************************************************************
  138. //---------------------------------------------------------------------------
  139. // CADV7175A constructor
  140. //---------------------------------------------------------------------------
  141. CADV7175A::CADV7175A(void)
  142. {
  143. };
  144. //---------------------------------------------------------------------------
  145. // CADV7175A::Init
  146. //---------------------------------------------------------------------------
  147. void CADV7175A::Init(IKernelService *pKernelObj, CIOIF *pioif )
  148. {
  149. ModeRegister0.Init( pKernelObj, pioif, 0x00 );
  150. ModeRegister1.Init( pKernelObj, pioif, 0x01 );
  151. SubCarrierFreqRegister0.Init( pKernelObj, pioif, 0x02 );
  152. SubCarrierFreqRegister1.Init( pKernelObj, pioif, 0x03 );
  153. SubCarrierFreqRegister2.Init( pKernelObj, pioif, 0x04 );
  154. SubCarrierFreqRegister3.Init( pKernelObj, pioif, 0x05 );
  155. SubCarrierPhaseRegister.Init( pKernelObj, pioif, 0x06 );
  156. TimingRegister.Init( pKernelObj, pioif, 0x07 );
  157. ClosedCapExData0.Init( pKernelObj, pioif, 0x08 );
  158. ClosedCapExData1.Init( pKernelObj, pioif, 0x09 );
  159. ClosedCapData0.Init( pKernelObj, pioif, 0x0a );
  160. ClosedCapData1.Init( pKernelObj, pioif, 0x0b );
  161. TimingRegister1.Init( pKernelObj, pioif, 0x0c );
  162. ModeRegister2.Init( pKernelObj, pioif, 0x0d );
  163. NTSCTTXRegister0.Init( pKernelObj, pioif, 0x0e );
  164. NTSCTTXRegister1.Init( pKernelObj, pioif, 0x0f );
  165. NTSCTTXRegister2.Init( pKernelObj, pioif, 0x10 );
  166. NTSCTTXRegister3.Init( pKernelObj, pioif, 0x11 );
  167. ModeRegister3.Init( pKernelObj, pioif, 0x12 );
  168. for( int i = 0 ; i < 17; i ++ )
  169. MacrovisionRegister[i].Init( pKernelObj, pioif, (BYTE)(0x13+i) );
  170. TTXRQControlRegister0.Init( pKernelObj, pioif, 0x24 );
  171. TTXRQControlRegister.Init( pKernelObj, pioif, 0x37 );
  172. bCompPower = FALSE; // Composit Power off
  173. bSVideoPower = FALSE; // s-video Power off
  174. // by oka
  175. bClosedCaption = FALSE; // Closed Caption off
  176. m_apstype = ApsType_Off;
  177. m_OutputType = OUTPUT_NTSC;
  178. };
  179. //---------------------------------------------------------------------------
  180. // CADV7175A::SetNTSC
  181. //---------------------------------------------------------------------------
  182. BOOL CADV7175A::SetNTSC( void )
  183. {
  184. BYTE Data;
  185. ModeRegister0 = 0x14;
  186. Data = 0x20;
  187. // by oka
  188. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  189. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  190. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  191. ModeRegister1 = Data;
  192. SubCarrierFreqRegister0 = 0x16;
  193. SubCarrierFreqRegister1 = 0x7c;
  194. SubCarrierFreqRegister2 = 0xf0;
  195. SubCarrierFreqRegister3 = 0x21;
  196. SubCarrierPhaseRegister = 0x00;
  197. // TimingRegister = 0x0d;
  198. TimingRegister = 0x08;
  199. ClosedCapExData0 = 0x00;
  200. ClosedCapExData1 = 0x00;
  201. ClosedCapData0 = 0x00;
  202. ClosedCapData1 = 0x00;
  203. // TimingRegister1 = 0x72;
  204. TimingRegister1 = 0x00;
  205. if( bCompPower == FALSE && bSVideoPower == FALSE )
  206. ModeRegister2 = 0xc8;
  207. else
  208. ModeRegister2 = 0x48;
  209. NTSCTTXRegister0 = 0x00;
  210. NTSCTTXRegister1 = 0x00;
  211. NTSCTTXRegister2 = 0x00;
  212. NTSCTTXRegister3 = 0x00;
  213. ModeRegister3 = 0x02;
  214. TTXRQControlRegister = 0x00;
  215. if( m_OutputType != OUTPUT_NTSC )
  216. SetMacroVision( m_apstype );
  217. m_OutputType = OUTPUT_NTSC;
  218. return TRUE;
  219. };
  220. //---------------------------------------------------------------------------
  221. // CADV7175A::SetPAL
  222. //---------------------------------------------------------------------------
  223. BOOL CADV7175A::SetPAL( DWORD Type )
  224. {
  225. BYTE Data;
  226. switch( Type )
  227. {
  228. case 0: // PAL B,D,G,H,I
  229. ModeRegister0 = 0x11;
  230. SubCarrierFreqRegister0 = 0xcb;
  231. SubCarrierFreqRegister1 = 0x8a;
  232. SubCarrierFreqRegister2 = 0x09;
  233. SubCarrierFreqRegister3 = 0x2a;
  234. SubCarrierPhaseRegister = 0x00;
  235. break;
  236. case 1: // PAL M
  237. ModeRegister0 = 0x12;
  238. SubCarrierFreqRegister0 = 0xa3;
  239. SubCarrierFreqRegister1 = 0xef;
  240. SubCarrierFreqRegister2 = 0xe6;
  241. SubCarrierFreqRegister3 = 0x21;
  242. SubCarrierPhaseRegister = 0x00;
  243. break;
  244. default:
  245. DBG_BREAK();
  246. return FALSE;
  247. };
  248. Data = 0x20;
  249. // by oka
  250. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  251. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  252. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  253. ModeRegister1 = Data;
  254. // TimingRegister = 0x0d;
  255. TimingRegister = 0x08;
  256. ClosedCapExData0 = 0x00;
  257. ClosedCapExData1 = 0x00;
  258. ClosedCapData0 = 0x00;
  259. ClosedCapData1 = 0x00;
  260. // TimingRegister1 = 0x72;
  261. TimingRegister1 = 0x00;
  262. if( bCompPower == FALSE && bSVideoPower == FALSE )
  263. ModeRegister2 = 0xc8;
  264. else
  265. ModeRegister2 = 0x48;
  266. NTSCTTXRegister0 = 0x00;
  267. NTSCTTXRegister1 = 0x00;
  268. NTSCTTXRegister2 = 0x00;
  269. NTSCTTXRegister3 = 0x00;
  270. ModeRegister3 = 0x00;
  271. TTXRQControlRegister = 0x00;
  272. if( m_OutputType != OUTPUT_PAL )
  273. SetMacroVision( m_apstype );
  274. m_OutputType = OUTPUT_PAL;
  275. return TRUE;
  276. };
  277. //---------------------------------------------------------------------------
  278. // CADV7175A::SetMacroVision
  279. //---------------------------------------------------------------------------
  280. BOOL CADV7175A::SetMacroVision( APSTYPE Type )
  281. {
  282. int i;
  283. switch( m_OutputType )
  284. {
  285. case OUTPUT_NTSC:
  286. switch( Type )
  287. {
  288. case ApsType_Off:
  289. MacrovisionRegister[0] = 0x40; // 0xc0;
  290. for( i = 1 ; i < 17; i ++ )
  291. MacrovisionRegister[i] = 0x00;
  292. break;
  293. case ApsType_1:
  294. MacrovisionRegister[ 0] = 0x76; // 0xf6
  295. MacrovisionRegister[ 1] = 0x07;
  296. MacrovisionRegister[ 2] = 0x95;
  297. MacrovisionRegister[ 3] = 0x50;
  298. MacrovisionRegister[ 4] = 0xce;
  299. MacrovisionRegister[ 5] = 0xb6;
  300. MacrovisionRegister[ 6] = 0x91;
  301. MacrovisionRegister[ 7] = 0xf8;
  302. MacrovisionRegister[ 8] = 0x1f;
  303. MacrovisionRegister[ 9] = 0x00; // 0x0c;
  304. MacrovisionRegister[10] = 0xcc; // 0xc0;
  305. MacrovisionRegister[11] = 0x03;
  306. MacrovisionRegister[12] = 0x00;
  307. MacrovisionRegister[13] = 0x58;
  308. MacrovisionRegister[14] = 0x85;
  309. MacrovisionRegister[15] = 0xca;
  310. MacrovisionRegister[16] = 0xff;
  311. break;
  312. case ApsType_2:
  313. MacrovisionRegister[ 0] = 0x7e;
  314. MacrovisionRegister[ 1] = 0x07;
  315. MacrovisionRegister[ 2] = 0x95;
  316. MacrovisionRegister[ 3] = 0x50;
  317. MacrovisionRegister[ 4] = 0xce;
  318. MacrovisionRegister[ 5] = 0xb6;
  319. MacrovisionRegister[ 6] = 0x91;
  320. MacrovisionRegister[ 7] = 0xf8;
  321. MacrovisionRegister[ 8] = 0x1f;
  322. MacrovisionRegister[ 9] = 0x00; // 0x0c;
  323. MacrovisionRegister[10] = 0xcc; // 0xc0;
  324. MacrovisionRegister[11] = 0x03;
  325. MacrovisionRegister[12] = 0x00;
  326. MacrovisionRegister[13] = 0x58;
  327. MacrovisionRegister[14] = 0x85;
  328. MacrovisionRegister[15] = 0xca;
  329. MacrovisionRegister[16] = 0xff;
  330. break;
  331. case ApsType_3:
  332. MacrovisionRegister[ 0] = 0xfe;
  333. MacrovisionRegister[ 1] = 0x45;
  334. MacrovisionRegister[ 2] = 0x85;
  335. MacrovisionRegister[ 3] = 0x54;
  336. MacrovisionRegister[ 4] = 0xeb;
  337. MacrovisionRegister[ 5] = 0xb6;
  338. MacrovisionRegister[ 6] = 0x91;
  339. MacrovisionRegister[ 7] = 0xf8;
  340. MacrovisionRegister[ 8] = 0x1f;
  341. MacrovisionRegister[ 9] = 0x00; // 0x0c;
  342. MacrovisionRegister[10] = 0xcc; // 0xc0;
  343. MacrovisionRegister[11] = 0x03;
  344. MacrovisionRegister[12] = 0x00;
  345. MacrovisionRegister[13] = 0x58;
  346. MacrovisionRegister[14] = 0x85;
  347. MacrovisionRegister[15] = 0xca;
  348. MacrovisionRegister[16] = 0xff;
  349. break;
  350. default:
  351. return FALSE;
  352. };
  353. break;
  354. case OUTPUT_PAL:
  355. switch( Type )
  356. {
  357. case ApsType_Off:
  358. MacrovisionRegister[ 0] = 0x80;
  359. MacrovisionRegister[ 1] = 0x16;
  360. MacrovisionRegister[ 2] = 0xaa;
  361. MacrovisionRegister[ 3] = 0x61;
  362. MacrovisionRegister[ 4] = 0x05;
  363. MacrovisionRegister[ 5] = 0xd7;
  364. MacrovisionRegister[ 6] = 0x53;
  365. MacrovisionRegister[ 7] = 0xfe;
  366. MacrovisionRegister[ 8] = 0x03;
  367. MacrovisionRegister[ 9] = 0xaa;
  368. MacrovisionRegister[10] = 0x80;
  369. MacrovisionRegister[11] = 0xbf;
  370. MacrovisionRegister[12] = 0x1f;
  371. MacrovisionRegister[13] = 0x18;
  372. MacrovisionRegister[14] = 0x04;
  373. MacrovisionRegister[15] = 0x7a;
  374. MacrovisionRegister[16] = 0x55;
  375. break;
  376. case ApsType_1:
  377. case ApsType_2:
  378. case ApsType_3:
  379. MacrovisionRegister[ 0] = 0xb6;
  380. MacrovisionRegister[ 1] = 0x16; // 0x26; // 0x16;
  381. MacrovisionRegister[ 2] = 0xaa;
  382. MacrovisionRegister[ 3] = 0x61; // 0x62; // 0x61;
  383. MacrovisionRegister[ 4] = 0x05;
  384. MacrovisionRegister[ 5] = 0xd7;
  385. MacrovisionRegister[ 6] = 0x53;
  386. MacrovisionRegister[ 7] = 0xfe; // 0xfc;
  387. MacrovisionRegister[ 8] = 0x03;
  388. MacrovisionRegister[ 9] = 0xaa;
  389. MacrovisionRegister[10] = 0x80;
  390. MacrovisionRegister[11] = 0xbf;
  391. MacrovisionRegister[12] = 0x1f;
  392. MacrovisionRegister[13] = 0x18;
  393. MacrovisionRegister[14] = 0x04;
  394. MacrovisionRegister[15] = 0x7a;
  395. MacrovisionRegister[16] = 0x55;
  396. break;
  397. default:
  398. return FALSE;
  399. };
  400. break;
  401. default:
  402. return FALSE;
  403. };
  404. m_apstype = Type;
  405. return TRUE;
  406. };
  407. //---------------------------------------------------------------------------
  408. // CADV7175A::SetCompPowerOn
  409. //---------------------------------------------------------------------------
  410. BOOL CADV7175A::SetCompPowerOn( BOOL Type )
  411. {
  412. BYTE Data;
  413. bCompPower = Type;
  414. if( bCompPower == FALSE && bSVideoPower == FALSE )
  415. {
  416. Data = 0x20;
  417. // by oka
  418. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  419. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  420. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  421. ModeRegister1 = Data;
  422. ModeRegister2 = 0xc8;
  423. }
  424. else
  425. {
  426. ModeRegister2 = 0x48;
  427. Data = 0x20;
  428. // by oka
  429. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  430. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  431. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  432. ModeRegister1 = Data;
  433. };
  434. return TRUE;
  435. };
  436. //---------------------------------------------------------------------------
  437. // CADV7175A::SetSvideoPowerOn
  438. //---------------------------------------------------------------------------
  439. BOOL CADV7175A::SetSVideoPowerOn( BOOL Type )
  440. {
  441. BYTE Data;
  442. bSVideoPower = Type;
  443. if( bCompPower == FALSE && bSVideoPower == FALSE )
  444. {
  445. Data = 0x20;
  446. // by oka
  447. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  448. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  449. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  450. ModeRegister1 = Data;
  451. ModeRegister2 = 0xc8;
  452. }
  453. else
  454. {
  455. ModeRegister2 = 0x48;
  456. Data = 0x20;
  457. // by oka
  458. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  459. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  460. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  461. ModeRegister1 = Data;
  462. };
  463. return TRUE;
  464. };
  465. //---------------------------------------------------------------------------
  466. // CADV7175A::SetCgmsType
  467. //---------------------------------------------------------------------------
  468. BOOL CADV7175A::SetCgmsType( CGMSTYPE Type, CVideoPropSet VProp )
  469. {
  470. return TRUE;
  471. };
  472. // by oka
  473. //---------------------------------------------------------------------------
  474. // CADV7175A::SetClosedCaptionOn
  475. //---------------------------------------------------------------------------
  476. BOOL CADV7175A::SetClosedCaptionOn( BOOL fswitch )
  477. {
  478. if (fswitch)
  479. {
  480. bClosedCaption = TRUE;
  481. } else {
  482. bClosedCaption = FALSE;
  483. }
  484. BYTE Data;
  485. Data = 0x20;
  486. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  487. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  488. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  489. ModeRegister1 = Data;
  490. return TRUE;
  491. }
  492. //---------------------------------------------------------------------------
  493. // CADV7175A::SetClosedCaption
  494. //---------------------------------------------------------------------------
  495. BOOL CADV7175A::SetClosedCaptionData( DWORD Data )
  496. {
  497. ClosedCapData0 = (BYTE)((Data & 0x0000FF00) >> 8);
  498. ClosedCapData1 = (BYTE)(Data & 0x000000FF);
  499. return TRUE;
  500. }
  501. //***************************************************************************
  502. // CADV7170 control interfaces
  503. //***************************************************************************
  504. //---------------------------------------------------------------------------
  505. // CADV7170 constructor
  506. //---------------------------------------------------------------------------
  507. CADV7170::CADV7170(void)
  508. {
  509. };
  510. //---------------------------------------------------------------------------
  511. // CADV7170::Init
  512. //---------------------------------------------------------------------------
  513. void CADV7170::Init(IKernelService *pKernelObj, CIOIF *pioif )
  514. {
  515. ModeRegister0.Init( pKernelObj, pioif, 0x00 );
  516. ModeRegister1.Init( pKernelObj, pioif, 0x01 );
  517. ModeRegister2.Init( pKernelObj, pioif, 0x02 );
  518. ModeRegister3.Init( pKernelObj, pioif, 0x03 );
  519. ModeRegister4.Init( pKernelObj, pioif, 0x04 );
  520. TimingRegister0.Init( pKernelObj, pioif, 0x07 );
  521. TimingRegister1.Init( pKernelObj, pioif, 0x08 );
  522. SubCarrierFreqRegister0.Init( pKernelObj, pioif, 0x09 );
  523. SubCarrierFreqRegister1.Init( pKernelObj, pioif, 0x0A );
  524. SubCarrierFreqRegister2.Init( pKernelObj, pioif, 0x0B );
  525. SubCarrierFreqRegister3.Init( pKernelObj, pioif, 0x0C );
  526. SubCarrierPhaseRegister.Init( pKernelObj, pioif, 0x0D );
  527. ClosedCapExData0.Init( pKernelObj, pioif, 0x0E );
  528. ClosedCapExData1.Init( pKernelObj, pioif, 0x0F );
  529. ClosedCapData0.Init( pKernelObj, pioif, 0x10 );
  530. ClosedCapData1.Init( pKernelObj, pioif, 0x11 );
  531. NTSCTTXRegister0.Init( pKernelObj, pioif, 0x12 );
  532. NTSCTTXRegister1.Init( pKernelObj, pioif, 0x13 );
  533. NTSCTTXRegister2.Init( pKernelObj, pioif, 0x14 );
  534. NTSCTTXRegister3.Init( pKernelObj, pioif, 0x15 );
  535. CgmsWssRegister0.Init( pKernelObj, pioif, 0x16 );
  536. CgmsWssRegister1.Init( pKernelObj, pioif, 0x17 );
  537. CgmsWssRegister2.Init( pKernelObj, pioif, 0x18 );
  538. TTXRQPositionRegister.Init( pKernelObj, pioif, 0x19 );
  539. for( int i = 0 ; i < 18; i ++ )
  540. MacrovisionRegister[i].Init( pKernelObj, pioif, (BYTE)(0x1E+i) );
  541. bCompPower = FALSE; // Composit Power off
  542. bSVideoPower = FALSE; // s-video Power off
  543. // by oka
  544. bClosedCaption = FALSE; // Closed Caption off
  545. m_apstype = ApsType_Off;
  546. m_OutputType = OUTPUT_NTSC;
  547. m_cgmstype = CgmsType_Off; // CGMS type setting
  548. };
  549. //---------------------------------------------------------------------------
  550. // CADV7170::SetNTSC
  551. //---------------------------------------------------------------------------
  552. BOOL CADV7170::SetNTSC( void )
  553. {
  554. BYTE Data;
  555. ModeRegister0 = 0x70; //0x10;
  556. Data = 0x00;
  557. // by oka
  558. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  559. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  560. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  561. ModeRegister1 = Data;
  562. if( bCompPower == FALSE && bSVideoPower == FALSE )
  563. ModeRegister2 = 0x48;
  564. else
  565. ModeRegister2 = 0x08;
  566. ModeRegister3 = 0x04;
  567. ModeRegister4 = 0x06; //0x12;
  568. TimingRegister0 = 0x08;
  569. TimingRegister1 = 0x00;
  570. SubCarrierFreqRegister0 = 0x16;
  571. SubCarrierFreqRegister1 = 0x7c;
  572. SubCarrierFreqRegister2 = 0xf0;
  573. SubCarrierFreqRegister3 = 0x21;
  574. SubCarrierPhaseRegister = 0x00;
  575. ClosedCapExData0 = 0x00;
  576. ClosedCapExData1 = 0x00;
  577. ClosedCapData0 = 0x00;
  578. ClosedCapData1 = 0x00;
  579. NTSCTTXRegister0 = 0x00;
  580. NTSCTTXRegister1 = 0x00;
  581. NTSCTTXRegister2 = 0x00;
  582. NTSCTTXRegister3 = 0x00;
  583. TTXRQPositionRegister = 0x00;
  584. if( m_OutputType != OUTPUT_NTSC )
  585. SetMacroVision( m_apstype );
  586. m_OutputType = OUTPUT_NTSC;
  587. return TRUE;
  588. };
  589. //---------------------------------------------------------------------------
  590. // CADV7170::SetPAL
  591. //---------------------------------------------------------------------------
  592. BOOL CADV7170::SetPAL( DWORD Type )
  593. {
  594. BYTE Data;
  595. switch( Type )
  596. {
  597. case 0: // PAL B,D,G,H,I
  598. ModeRegister0 = 0x71; //0x11;
  599. SubCarrierFreqRegister0 = 0xcb;
  600. SubCarrierFreqRegister1 = 0x8a;
  601. SubCarrierFreqRegister2 = 0x09;
  602. SubCarrierFreqRegister3 = 0x2a;
  603. SubCarrierPhaseRegister = 0x00;
  604. break;
  605. case 1: // PAL M
  606. ModeRegister0 = 0x72; //0x12;
  607. SubCarrierFreqRegister0 = 0xa3;
  608. SubCarrierFreqRegister1 = 0xef;
  609. SubCarrierFreqRegister2 = 0xe6;
  610. SubCarrierFreqRegister3 = 0x21;
  611. SubCarrierPhaseRegister = 0x00;
  612. break;
  613. default:
  614. DBG_BREAK();
  615. return FALSE;
  616. };
  617. Data = 0x00;
  618. // by oka
  619. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  620. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  621. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  622. ModeRegister1 = Data;
  623. if( bCompPower == FALSE && bSVideoPower == FALSE )
  624. ModeRegister2 = 0x48;
  625. else
  626. ModeRegister2 = 0x08;
  627. ModeRegister3 = 0x00; //0x04;
  628. ModeRegister4 = 0x06; //0x12;
  629. TimingRegister0 = 0x08;
  630. TimingRegister1 = 0x00;
  631. ClosedCapExData0 = 0x00;
  632. ClosedCapExData1 = 0x00;
  633. ClosedCapData0 = 0x00;
  634. ClosedCapData1 = 0x00;
  635. NTSCTTXRegister0 = 0x00;
  636. NTSCTTXRegister1 = 0x00;
  637. NTSCTTXRegister2 = 0x00;
  638. NTSCTTXRegister3 = 0x00;
  639. TTXRQPositionRegister = 0x00;
  640. if( m_OutputType != OUTPUT_PAL )
  641. SetMacroVision( m_apstype );
  642. m_OutputType = OUTPUT_PAL;
  643. return TRUE;
  644. };
  645. //---------------------------------------------------------------------------
  646. // CADV7170::SetMacroVision
  647. //---------------------------------------------------------------------------
  648. BOOL CADV7170::SetMacroVision( APSTYPE Type )
  649. {
  650. int i;
  651. switch( m_OutputType )
  652. {
  653. case OUTPUT_NTSC:
  654. switch( Type )
  655. {
  656. case ApsType_Off:
  657. MacrovisionRegister[0] = 0x40; // 0xc0;
  658. for( i = 1 ; i < 18; i ++ )
  659. MacrovisionRegister[i] = 0x00;
  660. break;
  661. case ApsType_1:
  662. MacrovisionRegister[ 0] = 0x76; // 0xf6
  663. MacrovisionRegister[ 1] = 0x07;
  664. MacrovisionRegister[ 2] = 0x95;
  665. MacrovisionRegister[ 3] = 0x50;
  666. MacrovisionRegister[ 4] = 0xce;
  667. MacrovisionRegister[ 5] = 0xb6;
  668. MacrovisionRegister[ 6] = 0x91;
  669. MacrovisionRegister[ 7] = 0xf8;
  670. MacrovisionRegister[ 8] = 0x1f;
  671. MacrovisionRegister[ 9] = 0x00; // 0x0c;
  672. MacrovisionRegister[10] = 0xcc; // 0xc0;
  673. MacrovisionRegister[11] = 0x03;
  674. MacrovisionRegister[12] = 0x00;
  675. MacrovisionRegister[13] = 0x58;
  676. MacrovisionRegister[14] = 0x85;
  677. MacrovisionRegister[15] = 0xca;
  678. MacrovisionRegister[16] = 0xff;
  679. MacrovisionRegister[17] = 0x00;
  680. break;
  681. case ApsType_2:
  682. MacrovisionRegister[ 0] = 0x7e;
  683. MacrovisionRegister[ 1] = 0x07;
  684. MacrovisionRegister[ 2] = 0x95;
  685. MacrovisionRegister[ 3] = 0x50;
  686. MacrovisionRegister[ 4] = 0xce;
  687. MacrovisionRegister[ 5] = 0xb6;
  688. MacrovisionRegister[ 6] = 0x91;
  689. MacrovisionRegister[ 7] = 0xf8;
  690. MacrovisionRegister[ 8] = 0x1f;
  691. MacrovisionRegister[ 9] = 0x00; // 0x0c;
  692. MacrovisionRegister[10] = 0xcc; // 0xc0;
  693. MacrovisionRegister[11] = 0x03;
  694. MacrovisionRegister[12] = 0x00;
  695. MacrovisionRegister[13] = 0x58;
  696. MacrovisionRegister[14] = 0x85;
  697. MacrovisionRegister[15] = 0xca;
  698. MacrovisionRegister[16] = 0xff;
  699. MacrovisionRegister[17] = 0x00;
  700. break;
  701. case ApsType_3:
  702. MacrovisionRegister[ 0] = 0xfe;
  703. MacrovisionRegister[ 1] = 0x45;
  704. MacrovisionRegister[ 2] = 0x85;
  705. MacrovisionRegister[ 3] = 0x54;
  706. MacrovisionRegister[ 4] = 0xeb;
  707. MacrovisionRegister[ 5] = 0xb6;
  708. MacrovisionRegister[ 6] = 0x91;
  709. MacrovisionRegister[ 7] = 0xf8;
  710. MacrovisionRegister[ 8] = 0x1f;
  711. MacrovisionRegister[ 9] = 0x00; // 0x0c;
  712. MacrovisionRegister[10] = 0xcc; // 0xc0;
  713. MacrovisionRegister[11] = 0x03;
  714. MacrovisionRegister[12] = 0x00;
  715. MacrovisionRegister[13] = 0x58;
  716. MacrovisionRegister[14] = 0x85;
  717. MacrovisionRegister[15] = 0xca;
  718. MacrovisionRegister[16] = 0xff;
  719. MacrovisionRegister[17] = 0x00;
  720. break;
  721. default:
  722. return FALSE;
  723. };
  724. break;
  725. case OUTPUT_PAL:
  726. switch( Type )
  727. {
  728. case ApsType_Off:
  729. MacrovisionRegister[ 0] = 0x80;
  730. MacrovisionRegister[ 1] = 0x16;
  731. MacrovisionRegister[ 2] = 0xaa;
  732. MacrovisionRegister[ 3] = 0x61;
  733. MacrovisionRegister[ 4] = 0x05;
  734. MacrovisionRegister[ 5] = 0xd7;
  735. MacrovisionRegister[ 6] = 0x53;
  736. MacrovisionRegister[ 7] = 0xfe;
  737. MacrovisionRegister[ 8] = 0x03;
  738. MacrovisionRegister[ 9] = 0xaa;
  739. MacrovisionRegister[10] = 0x80;
  740. MacrovisionRegister[11] = 0xbf;
  741. MacrovisionRegister[12] = 0x1f;
  742. MacrovisionRegister[13] = 0x18;
  743. MacrovisionRegister[14] = 0x04;
  744. MacrovisionRegister[15] = 0x7a;
  745. MacrovisionRegister[16] = 0x55;
  746. MacrovisionRegister[17] = 0x00;
  747. break;
  748. case ApsType_1:
  749. case ApsType_2:
  750. case ApsType_3:
  751. MacrovisionRegister[ 0] = 0xb6;
  752. MacrovisionRegister[ 1] = 0x16; // 0x26; // 0x16;
  753. MacrovisionRegister[ 2] = 0xaa;
  754. MacrovisionRegister[ 3] = 0x61; // 0x62; // 0x61;
  755. MacrovisionRegister[ 4] = 0x05;
  756. MacrovisionRegister[ 5] = 0xd7;
  757. MacrovisionRegister[ 6] = 0x53;
  758. MacrovisionRegister[ 7] = 0xfe; // 0xfc;
  759. MacrovisionRegister[ 8] = 0x03;
  760. MacrovisionRegister[ 9] = 0xaa;
  761. MacrovisionRegister[10] = 0x80;
  762. MacrovisionRegister[11] = 0xbf;
  763. MacrovisionRegister[12] = 0x1f;
  764. MacrovisionRegister[13] = 0x18;
  765. MacrovisionRegister[14] = 0x04;
  766. MacrovisionRegister[15] = 0x7a;
  767. MacrovisionRegister[16] = 0x55;
  768. MacrovisionRegister[17] = 0x00;
  769. break;
  770. default:
  771. return FALSE;
  772. };
  773. break;
  774. default:
  775. return FALSE;
  776. };
  777. m_apstype = Type;
  778. return TRUE;
  779. };
  780. //---------------------------------------------------------------------------
  781. // CADV7170::SetCompPowerOn
  782. //---------------------------------------------------------------------------
  783. BOOL CADV7170::SetCompPowerOn( BOOL Type )
  784. {
  785. BYTE Data;
  786. bCompPower = Type;
  787. if( bCompPower == FALSE && bSVideoPower == FALSE )
  788. {
  789. Data = 0x00;
  790. // by oka
  791. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  792. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  793. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  794. ModeRegister1 = Data;
  795. ModeRegister2 = 0x48;
  796. }
  797. else
  798. {
  799. ModeRegister2 = 0x08;
  800. Data = 0x00;
  801. // by oka
  802. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  803. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  804. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  805. ModeRegister1 = Data;
  806. };
  807. Data = ModeRegister4;
  808. if( (bCompPower==TRUE)||(bSVideoPower==TRUE) ){
  809. Data &= 0xBF;
  810. ModeRegister4 = Data;
  811. }else{
  812. Data |= 0x40;
  813. ModeRegister4 = Data;
  814. }
  815. return TRUE;
  816. };
  817. //---------------------------------------------------------------------------
  818. // CADV7170::SetSvideoPowerOn
  819. //---------------------------------------------------------------------------
  820. BOOL CADV7170::SetSVideoPowerOn( BOOL Type )
  821. {
  822. BYTE Data;
  823. bSVideoPower = Type;
  824. if( bCompPower == FALSE && bSVideoPower == FALSE )
  825. {
  826. Data = 0x00;
  827. // by oka
  828. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  829. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  830. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  831. ModeRegister1 = Data;
  832. ModeRegister2 = 0x48;
  833. }
  834. else
  835. {
  836. ModeRegister2 = 0x08;
  837. Data = 0x00;
  838. // by oka
  839. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  840. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  841. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  842. ModeRegister1 = Data;
  843. };
  844. Data = ModeRegister4;
  845. if( (bCompPower==TRUE)||(bSVideoPower==TRUE) ){
  846. Data &= 0xBF;
  847. ModeRegister4 = Data;
  848. }else{
  849. Data |= 0x40;
  850. ModeRegister4 = Data;
  851. }
  852. return TRUE;
  853. };
  854. //---------------------------------------------------------------------------
  855. // CADV7170::SetCgmsType
  856. //---------------------------------------------------------------------------
  857. BOOL CADV7170::SetCgmsType( CGMSTYPE Type, CVideoPropSet VProp )
  858. {
  859. BYTE word0, word1, word2, word3;
  860. word0 = word1 = word2 = word3 = 0x00;
  861. switch( m_OutputType )
  862. {
  863. case OUTPUT_NTSC:
  864. // WORD-0
  865. switch( VProp.m_AspectRatio ){
  866. case Aspect_04_03:
  867. word0 &= 0xFE;
  868. break;
  869. case Aspect_16_09:
  870. word0 |= 0x01;
  871. break;
  872. }
  873. switch( VProp.m_DisplayMode ){
  874. case Display_Original:
  875. case Display_PanScan:
  876. word0 &= 0xFD;
  877. break;
  878. case Display_LetterBox:
  879. word0 |= 0x02;
  880. break;
  881. }
  882. // WORD-1
  883. word1 = 0x00;
  884. // WORD-2
  885. switch( Type ){
  886. case CgmsType_Off:
  887. word2 &= 0xFC;
  888. break;
  889. case CgmsType_1:
  890. word2 &= 0xFC;
  891. word2 |= 0x01;
  892. break;
  893. case CgmsType_On:
  894. word2 |= 0x03;
  895. break;
  896. }
  897. switch( m_apstype ){
  898. case ApsType_Off:
  899. word2 &= 0xF3;
  900. break;
  901. case ApsType_1:
  902. word2 &= 0xF3;
  903. word2 |= 0x08;
  904. break;
  905. case ApsType_2:
  906. word2 &= 0xF3;
  907. word2 |= 0x04;
  908. break;
  909. case ApsType_3:
  910. word2 |= 0x0C;
  911. break;
  912. }
  913. CgmsWssRegister0 = 0x7F; // NTSC(CGMS-A)
  914. CgmsWssRegister1 = (BYTE)( ( word2>>2 )| 0xC0 );
  915. CgmsWssRegister2 = (BYTE)( word0|word1|( word2<<6 ) );
  916. break;
  917. case OUTPUT_PAL:
  918. // Group-1
  919. switch( VProp.m_AspectRatio ){
  920. case Aspect_04_03:
  921. word0 |= 0x08;
  922. break;
  923. case Aspect_16_09:
  924. word0 = 0x07;
  925. break;
  926. }
  927. switch( VProp.m_DisplayMode ){
  928. case Display_Original:
  929. case Display_PanScan:
  930. word0 &= 0xF8;
  931. break;
  932. case Display_LetterBox:
  933. word0 |= 0x03;
  934. break;
  935. }
  936. // Group-2
  937. switch( VProp.m_FilmCamera ){
  938. case Source_Film:
  939. word1 |= 0x01;
  940. break;
  941. case Source_Camera:
  942. word1 &= 0xFE;
  943. break;
  944. }
  945. // Group-4
  946. switch( Type ){
  947. case CgmsType_Off:
  948. word3 = 0x00;
  949. break;
  950. case CgmsType_1:
  951. word3 = 0x02;
  952. break;
  953. case CgmsType_On:
  954. word3 = 0x06;
  955. break;
  956. }
  957. CgmsWssRegister0 = 0x80; // PAL(WSS)
  958. CgmsWssRegister1 = (BYTE)( word2|( word3<<3 ) );
  959. CgmsWssRegister2 = (BYTE)( word0|( word1<<4 ) );
  960. break;
  961. default:
  962. return FALSE;
  963. };
  964. m_cgmstype = Type;
  965. return TRUE;
  966. };
  967. //---------------------------------------------------------------------------
  968. // CADV7170::SetClosedCaptionOn
  969. //---------------------------------------------------------------------------
  970. BOOL CADV7170::SetClosedCaptionOn( BOOL fswitch )
  971. {
  972. if (fswitch)
  973. {
  974. bClosedCaption = TRUE;
  975. } else {
  976. bClosedCaption = FALSE;
  977. }
  978. BYTE Data;
  979. Data = 0x00;
  980. // by oka
  981. if( bClosedCaption == TRUE ) Data |= CLOSED_CAPTION_ON;
  982. if( bCompPower == FALSE ) Data |= COMPOSITE_OFF;
  983. if( bSVideoPower == FALSE ) Data |= SVIDEO_OFF;
  984. ModeRegister1 = Data;
  985. return TRUE;
  986. }
  987. //---------------------------------------------------------------------------
  988. // CADV7170::SetClosedCaptionData
  989. //---------------------------------------------------------------------------
  990. BOOL CADV7170::SetClosedCaptionData( DWORD Data )
  991. {
  992. ClosedCapData0 = (BYTE)((Data & 0x0000FF00) >> 8);
  993. ClosedCapData1 = (BYTE)(Data & 0x000000FF);
  994. return TRUE;
  995. }
  996. //***************************************************************************
  997. // End of
  998. //***************************************************************************