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.

1712 lines
46 KiB

  1. //***************************************************************************
  2. //
  3. // FileName:
  4. // $Workfile: zivabrd.cpp $
  5. //
  6. // Author:
  7. // TOSHIBA [PCS](PSY) Seiichi Nakamura
  8. // Copyright (c) 1997 TOSHIBA CORPORATION
  9. //
  10. // Description:
  11. //
  12. //***************************************************************************
  13. // $Header: /DVD Drivers/ZiVA.WDM/zivabrd.cpp 66 98/10/15 12:20p Yagi $
  14. // $Modtime: 98/10/13 12:02p $
  15. // $Nokeywords:$
  16. //***************************************************************************
  17. #include "includes.h"
  18. #include "ioif.h"
  19. #include "zivachip.h"
  20. #include "adv.h"
  21. #include "mixhal.h"
  22. // by oka
  23. #include "userdata.h"
  24. #include "zivabrd.h"
  25. #include "timeout.h"
  26. #include "dramcfg.h"
  27. //***************************************************************************
  28. // IMBoardListItem Help Class
  29. //***************************************************************************
  30. CList::CList( void ): pTopItem( NULL ), pCurrentItem( NULL )
  31. {
  32. };
  33. void CList::Init( void )
  34. {
  35. pTopItem = NULL;
  36. pCurrentItem = NULL;
  37. };
  38. BOOL CList::SearchItem( IMBoardListItem *pItem )
  39. {
  40. IMBoardListItem *pCurrent;
  41. if( pTopItem == NULL )
  42. return FALSE;
  43. pCurrent = pTopItem;
  44. while( pCurrent != NULL )
  45. {
  46. if( pCurrent == pItem )
  47. return TRUE;
  48. pCurrent = pCurrent->GetNext();
  49. }
  50. return FALSE;
  51. };
  52. IMBoardListItem *CList::SearchBottomItem( void )
  53. {
  54. IMBoardListItem *pCurrent;
  55. if( pTopItem == NULL )
  56. return NULL;
  57. pCurrent = pTopItem;
  58. while( pCurrent->GetNext() != NULL )
  59. pCurrent = pCurrent->GetNext();
  60. return pCurrent;
  61. };
  62. BOOL CList::AddItem( IMBoardListItem *pItem )
  63. {
  64. IMBoardListItem *pBottom;
  65. if( SearchItem( pItem ) == TRUE )
  66. return FALSE;
  67. pItem->SetNext( NULL );
  68. if( pTopItem == NULL )
  69. {
  70. pTopItem = pCurrentItem = pItem;
  71. return TRUE;
  72. };
  73. pBottom = SearchBottomItem();
  74. ASSERT( pBottom != NULL );
  75. pBottom->SetNext( pItem );
  76. return TRUE;
  77. };
  78. BOOL CList::DeleteItem( IMBoardListItem *pItem )
  79. {
  80. IMBoardListItem *pCurrent;
  81. if( SearchItem( pItem ) == FALSE )
  82. return FALSE;
  83. if( pTopItem == pItem )
  84. {
  85. pTopItem = pTopItem->GetNext();
  86. pItem->SetNext( NULL );
  87. return TRUE;
  88. };
  89. pCurrent = pTopItem;
  90. while( pCurrent->GetNext() != pItem )
  91. pCurrent = pCurrent->GetNext();
  92. pCurrent->SetNext( pItem->GetNext() );
  93. pItem->SetNext( NULL );
  94. return TRUE;
  95. };
  96. BOOL CList::SetCurrentToTop( void )
  97. {
  98. pCurrentItem = pTopItem;
  99. return TRUE;
  100. };
  101. IMBoardListItem *CList::GetNext( void )
  102. {
  103. IMBoardListItem *pItem;
  104. pItem = pCurrentItem;
  105. if( pCurrentItem != NULL )
  106. pCurrentItem = pCurrentItem->GetNext();
  107. return pItem;
  108. };
  109. //***************************************************************************
  110. // ZiVA Board Class
  111. //***************************************************************************
  112. //---------------------------------------------------------------------------
  113. // CMPEGBoardHAL Constructor
  114. //---------------------------------------------------------------------------
  115. CMPEGBoardHAL::CMPEGBoardHAL()
  116. {
  117. m_pKernelObj = NULL; // KernelService Object
  118. #ifdef POWERCHECK_BY_FLAG
  119. m_PowerState = POWERSTATE_OFF;
  120. #endif
  121. m_DMABufferLinearAddr = 0; // DMA buffer addr
  122. m_DMABufferPhysicalAddr = 0; // DMA buffer addr
  123. m_EventIntMask = 0;
  124. // by oka
  125. m_ZivaPbtIntMask = 0;
  126. for(DWORD i=0;i<24;i++)
  127. m_MaskReference[i]=0;
  128. m_PowerOnTime = 0;
  129. m_NeedPowerOnDelay = FALSE;
  130. m_WrapperType = WrapperType_VxD; // default WrapperType
  131. };
  132. //---------------------------------------------------------------------------
  133. // CMPEGBoardHAL Destructor
  134. //---------------------------------------------------------------------------
  135. CMPEGBoardHAL::~CMPEGBoardHAL()
  136. {
  137. };
  138. //---------------------------------------------------------------------------
  139. // CMPEGBoardHAL Init
  140. //---------------------------------------------------------------------------
  141. HALRESULT CMPEGBoardHAL::Init( WRAPPERTYPE wraptype )
  142. {
  143. m_pKernelObj = NULL; // KernelService Object
  144. m_DMABufferLinearAddr = 0; // DMA buffer addr
  145. m_DMABufferPhysicalAddr = 0; // DMA buffer addr
  146. m_EventIntMask = 0;
  147. m_WrapperType = wraptype;
  148. // by oka
  149. m_ZivaPbtIntMask = 0;
  150. for(DWORD i=0;i<24;i++)
  151. m_MaskReference[i]=0;
  152. m_PowerOnTime = 0;
  153. m_NeedPowerOnDelay = FALSE;
  154. // by oka
  155. m_CCRingBufferStart = 0xFFFFFFFF;
  156. m_CCDataPoint = m_CCDataNumber = m_CCRingBufferNumber = 0;
  157. m_CCsend_point = m_CCpending = m_CCnumber = 0;
  158. m_SendDataEventList.Init();
  159. m_StartVOBUEventList.Init();
  160. m_EndVOBEventList.Init();
  161. m_VUnderFlowEventList.Init();
  162. m_AUnderFlowEventList.Init();
  163. m_SPUnderFlowEventList.Init();
  164. m_VOverFlowEventList.Init();
  165. m_AOverFlowEventList.Init();
  166. m_SPOverFlowEventList.Init();
  167. m_VideoProp.Init(); // Video Property Set
  168. m_AudioProp.Init(); // Audio Property Set
  169. m_SubpicProp.Init(); // Subpic Property Set
  170. return HAL_SUCCESS;
  171. };
  172. //---------------------------------------------------------------------------
  173. // IWrapperHAL SetKernelService
  174. //---------------------------------------------------------------------------
  175. HALRESULT CMPEGBoardHAL::SetKernelService( IKernelService *pKernelService )
  176. {
  177. ASSERT( m_pKernelObj == NULL );
  178. m_pKernelObj = pKernelService;
  179. ioif.Init( m_pKernelObj );
  180. ziva.Init( m_pKernelObj, &ioif );
  181. adv7175a.Init( m_pKernelObj, &ioif );
  182. adv7170.Init( m_pKernelObj, &ioif );
  183. m_Stream.Init( &ziva , m_pKernelObj , &ioif , this );
  184. // LUKE BUG!!!!!!
  185. {
  186. BYTE Data;
  187. m_pKernelObj->GetPCIConfigData( 0x44, &Data );
  188. Data = (BYTE)( Data & 0xfb ); // reset bit 2(CLKON)
  189. m_pKernelObj->SetPCIConfigData( 0x44, Data );
  190. };
  191. // Check sub device ID and select ADV device
  192. {
  193. WORD SubDevID;
  194. m_pKernelObj->GetPCIConfigData( 0x2E, &SubDevID );
  195. if( SubDevID==0x0001 ) // SantaClara2
  196. {
  197. adv = &adv7175a;
  198. }
  199. else
  200. {
  201. adv = &adv7170;
  202. }
  203. }
  204. return HAL_SUCCESS;
  205. };
  206. //---------------------------------------------------------------------------
  207. // IWrapperHAL SetSinkWrapper
  208. //---------------------------------------------------------------------------
  209. HALRESULT CMPEGBoardHAL::SetSinkWrapper( IMPEGBoardEvent *pMPEGBoardEvent )
  210. {
  211. ASSERT( m_pKernelObj != NULL );
  212. ASSERT( pMPEGBoardEvent != NULL );
  213. BOOL rc = FALSE;
  214. CAutoHwInt hwintLock( m_pKernelObj );
  215. switch( pMPEGBoardEvent->GetEventType() )
  216. {
  217. case WrapperEvent_StartVOBU:
  218. rc = m_StartVOBUEventList.AddItem( pMPEGBoardEvent );
  219. m_EventIntMask |= ( ZIVA_INT_GOPV | ZIVA_INT_NV );
  220. break;
  221. case WrapperEvent_EndVOB:
  222. rc = m_EndVOBEventList.AddItem( pMPEGBoardEvent );
  223. m_ZivaPbtIntMask |= PBT_INT_END_VOB; // by oka for PBT_INT_SRC
  224. m_EventIntMask |= ZIVA_INT_AOR;
  225. break;
  226. case WrapperEvent_VUnderFlow:
  227. rc = m_VUnderFlowEventList.AddItem( pMPEGBoardEvent );
  228. m_EventIntMask |= ZIVA_INT_UND;
  229. break;
  230. case WrapperEvent_AUnderFlow:
  231. rc = m_AUnderFlowEventList.AddItem( pMPEGBoardEvent );
  232. m_EventIntMask |= ZIVA_INT_UND;
  233. break;
  234. case WrapperEvent_SPUnderFlow:
  235. rc = m_SPUnderFlowEventList.AddItem( pMPEGBoardEvent );
  236. m_EventIntMask |= ZIVA_INT_UND;
  237. break;
  238. case WrapperEvent_VOverFlow:
  239. rc = m_VOverFlowEventList.AddItem( pMPEGBoardEvent );
  240. m_EventIntMask |= ZIVA_INT_BUFF;
  241. break;
  242. case WrapperEvent_AOverFlow:
  243. rc = m_AOverFlowEventList.AddItem( pMPEGBoardEvent );
  244. m_EventIntMask |= ZIVA_INT_BUFF;
  245. break;
  246. case WrapperEvent_SPOverFlow:
  247. rc = m_SPOverFlowEventList.AddItem( pMPEGBoardEvent );
  248. m_EventIntMask |= ZIVA_INT_BUFF;
  249. break;
  250. // by oka
  251. case WrapperEvent_ButtonActivate:
  252. rc = m_ButtonActivteEventList.AddItem( pMPEGBoardEvent );
  253. m_EventIntMask |= ZIVA_INT_HLI ;
  254. break;
  255. case WrapperEvent_NextPicture:
  256. rc = m_NextPictureEventList.AddItem( pMPEGBoardEvent );
  257. m_EventIntMask |= ZIVA_INT_PICD ;
  258. break;
  259. case WrapperEvent_UserData:
  260. rc = m_UserDataEventList.AddItem( pMPEGBoardEvent );
  261. //m_EventIntMask |= ZIVA_INT_USR | ZIVA_INT_VSYNC;
  262. // by oka
  263. if (!SetEventIntMask( ZIVA_INT_USR ))
  264. {
  265. DBG_BREAK();
  266. return HAL_ERROR;
  267. }
  268. break;
  269. // end
  270. case WrapperEvent_VSync:
  271. rc = m_VSyncEventList.AddItem( pMPEGBoardEvent );
  272. if (!SetEventIntMask( ZIVA_INT_VSYNC ))
  273. {
  274. DBG_BREAK();
  275. return HAL_ERROR;
  276. }
  277. // ziva.INT_MASK = GetEventIntMask();
  278. break;
  279. default:
  280. DBG_BREAK();
  281. return HAL_ERROR;
  282. };
  283. if( rc == FALSE )
  284. {
  285. DBG_BREAK();
  286. return HAL_ERROR;
  287. };
  288. return HAL_SUCCESS;
  289. };
  290. //---------------------------------------------------------------------------
  291. // IWrapperHAL UnsetSinkWrapper
  292. //---------------------------------------------------------------------------
  293. HALRESULT CMPEGBoardHAL::UnsetSinkWrapper( IMPEGBoardEvent *pMPEGBoardEvent )
  294. {
  295. ASSERT( m_pKernelObj != NULL );
  296. ASSERT( pMPEGBoardEvent != NULL );
  297. BOOL rc = FALSE;
  298. CAutoHwInt hwintLock( m_pKernelObj );
  299. switch( pMPEGBoardEvent->GetEventType() )
  300. {
  301. case WrapperEvent_StartVOBU:
  302. rc = m_StartVOBUEventList.DeleteItem( pMPEGBoardEvent );
  303. m_EventIntMask &= ~( ZIVA_INT_GOPV | ZIVA_INT_NV );
  304. break;
  305. case WrapperEvent_EndVOB:
  306. rc = m_EndVOBEventList.DeleteItem( pMPEGBoardEvent );
  307. m_EventIntMask &= ~ZIVA_INT_AOR;
  308. m_ZivaPbtIntMask &= ~PBT_INT_END_VOB; // by oka for PBT_INT_SRC
  309. break;
  310. case WrapperEvent_VUnderFlow:
  311. rc = m_VUnderFlowEventList.DeleteItem( pMPEGBoardEvent );
  312. m_EventIntMask &= ~ZIVA_INT_UND;
  313. break;
  314. case WrapperEvent_AUnderFlow:
  315. rc = m_AUnderFlowEventList.DeleteItem( pMPEGBoardEvent );
  316. m_EventIntMask &= ~ZIVA_INT_UND;
  317. break;
  318. case WrapperEvent_SPUnderFlow:
  319. rc = m_SPUnderFlowEventList.DeleteItem( pMPEGBoardEvent );
  320. m_EventIntMask &= ~ZIVA_INT_UND;
  321. break;
  322. case WrapperEvent_VOverFlow:
  323. rc = m_VOverFlowEventList.DeleteItem( pMPEGBoardEvent );
  324. m_EventIntMask &= ~ZIVA_INT_BUFF;
  325. break;
  326. case WrapperEvent_AOverFlow:
  327. rc = m_AOverFlowEventList.DeleteItem( pMPEGBoardEvent );
  328. m_EventIntMask &= ~ZIVA_INT_BUFF;
  329. break;
  330. case WrapperEvent_SPOverFlow:
  331. rc = m_SPOverFlowEventList.DeleteItem( pMPEGBoardEvent );
  332. m_EventIntMask &= ~ZIVA_INT_BUFF;
  333. break;
  334. // by oka
  335. case WrapperEvent_ButtonActivate:
  336. rc = m_ButtonActivteEventList.DeleteItem( pMPEGBoardEvent );
  337. m_EventIntMask &= ~ZIVA_INT_HLI ;
  338. break;
  339. case WrapperEvent_NextPicture:
  340. rc = m_NextPictureEventList.DeleteItem( pMPEGBoardEvent );
  341. m_EventIntMask &= ~ZIVA_INT_PICD ;
  342. break;
  343. case WrapperEvent_UserData:
  344. rc = m_UserDataEventList.DeleteItem( pMPEGBoardEvent );
  345. //m_EventIntMask &= ~(ZIVA_INT_USR | ZIVA_INT_VSYNC);
  346. // by oka
  347. if (!UnsetEventIntMask( ZIVA_INT_USR ))
  348. {
  349. DBG_BREAK();
  350. return HAL_ERROR;
  351. }
  352. break;
  353. // end
  354. case WrapperEvent_VSync:
  355. rc = m_VSyncEventList.DeleteItem( pMPEGBoardEvent );
  356. if (!UnsetEventIntMask( ZIVA_INT_VSYNC ))
  357. {
  358. DBG_BREAK();
  359. return HAL_ERROR;
  360. }
  361. break;
  362. default:
  363. DBG_BREAK();
  364. return HAL_ERROR;
  365. };
  366. if( rc == FALSE )
  367. {
  368. DBG_BREAK();
  369. return HAL_ERROR;
  370. };
  371. return HAL_SUCCESS;
  372. };
  373. //---------------------------------------------------------------------------
  374. // IWrapperHAL HALHwInterrupt
  375. //---------------------------------------------------------------------------
  376. HALRESULT CMPEGBoardHAL::HALHwInterrupt( void )
  377. {
  378. ASSERT( m_pKernelObj != NULL );
  379. // POWERSTATE PowerState;
  380. // GetPowerState( &PowerState );
  381. // if( PowerState!=POWERSTATE_ON )
  382. // return( HAL_IRQ_OTHER );
  383. WORD wLukeIntFlag;
  384. // get interrupt flag register from luke
  385. wLukeIntFlag = ioif.luke2.IO_INTF;
  386. if( wLukeIntFlag==0xFFFF ) // Yagi 97.09.24
  387. return( HAL_IRQ_OTHER ); //
  388. // Clear interrupt flag
  389. ioif.luke2.IO_INTF = (WORD)(wLukeIntFlag & 0x039f);
  390. // STCREFINT (STC Reference interrupt flag )
  391. if( (wLukeIntFlag & 0x200 ) != 0 )
  392. {
  393. };
  394. // MBAT ( Master Abort Occur interrupt flag ) this interrupt is ERROR!!!
  395. if( (wLukeIntFlag & 0x100 ) != 0 )
  396. {
  397. BYTE Data;
  398. // Config Data Master and Target Abort clear
  399. m_pKernelObj->GetPCIConfigData( 0x07, &Data );
  400. m_pKernelObj->SetPCIConfigData( 0x07, Data );
  401. };
  402. // STCINT( System timer interrupt flag )
  403. if( (wLukeIntFlag & 0x80 ) != 0 )
  404. {
  405. };
  406. // VS_INT( v-sync interrupt flag )
  407. if( (wLukeIntFlag & 0x10 ) != 0 )
  408. {
  409. };
  410. // VD_INT( video decoder interrut flag )
  411. if( (wLukeIntFlag & 0x08 ) != 0 )
  412. {
  413. DWORD dwZiVAIntFlag;
  414. dwZiVAIntFlag = ziva.INT_STATUS & ziva.INT_MASK;
  415. CheckZiVAInterrupt( dwZiVAIntFlag );
  416. // Clear ZiVA Interrupt
  417. ziva.Host_Control = (ziva.Host_Control & 0xFFFFFFFC) | 0x82;
  418. // Clear Ziva Interrupt Source
  419. ziva.HLI_INT_SRC = 0;
  420. ziva.BUFF_INT_SRC = 0;
  421. ziva.UND_INT_SRC = 0;
  422. ziva.AOR_INT_SRC = 0;
  423. ziva.AEE_INT_SRC = 0;
  424. ziva.ERR_INT_SRC = 0;
  425. ziva.INT_STATUS = 0;
  426. };
  427. // MST_ABT( bus-master DMA software abort )
  428. if( (wLukeIntFlag & 0x04 ) != 0 )
  429. {
  430. IHALBuffer *pFinishBuff;
  431. DWORD Num, DmaNo ;
  432. Num = m_Stream.m_DmaFifo.GetItemNum();
  433. for( DWORD i = 0 ; i < Num ; i ++ )
  434. {
  435. m_Stream.m_DmaFifo.GetItem( &DmaNo );
  436. pFinishBuff = m_Stream.DMAFinish( DmaNo );
  437. if( pFinishBuff != NULL )
  438. NotifyEvent( &m_SendDataEventList , (VOID *)pFinishBuff );
  439. };
  440. m_NaviCount = 0;
  441. m_Stream.m_DmaFifo.Flush();
  442. Num = m_Stream.m_HalFifo.GetItemNum();
  443. for( i = 0 ; i < Num ; i ++ )
  444. {
  445. m_Stream.m_HalFifo.GetItem( &pFinishBuff );
  446. if( pFinishBuff != NULL )
  447. NotifyEvent( &m_SendDataEventList , (VOID *)pFinishBuff );
  448. };
  449. m_Stream.m_HalFifo.Flush();
  450. SetMasterAbortEvent();
  451. };
  452. // check Data complete
  453. if( (wLukeIntFlag & 0x03 ) != 0 )
  454. {
  455. BYTE Num = 0;
  456. if( (wLukeIntFlag & 0x02 ) != 0 )Num ++;
  457. if( (wLukeIntFlag & 0x01 ) != 0 )Num ++;
  458. for( int i = 0 ; i < Num; i ++ )
  459. {
  460. DWORD DMANo;
  461. if( m_Stream.m_DmaFifo.GetItemNum() != 0 )
  462. {
  463. m_Stream.m_DmaFifo.GetItem( &DMANo );
  464. switch( DMANo )
  465. {
  466. case 0:
  467. // MST_INT0( bus-master DMA complete interrupt flag )
  468. if( (wLukeIntFlag & 0x01 ) != 0 )
  469. {
  470. IHALBuffer *pFinishBuff;
  471. pFinishBuff = m_Stream.DMAFinish( 0 );
  472. if( pFinishBuff != NULL )
  473. NotifyEvent( &m_SendDataEventList , (VOID *)pFinishBuff );
  474. }
  475. else
  476. {
  477. DBG_PRINTF( ("status ERROR!!! LINE = %d\r\n", __LINE__ ));
  478. DBG_BREAK();
  479. };
  480. break;
  481. case 1:
  482. // MST_INT1( bus-master DMA complete interrupt flag )
  483. if( (wLukeIntFlag & 0x02 ) != 0 )
  484. {
  485. IHALBuffer *pFinishBuff;
  486. pFinishBuff = m_Stream.DMAFinish( 1 );
  487. if( pFinishBuff != NULL )
  488. NotifyEvent( &m_SendDataEventList , (VOID *)pFinishBuff );
  489. }
  490. else
  491. {
  492. DBG_PRINTF( ("status ERROR!!! LINE = %d\r\n", __LINE__ ));
  493. DBG_BREAK();
  494. };
  495. break;
  496. default:
  497. DBG_PRINTF( ("status ERROR!!! LINE = %d\r\n", __LINE__ ));
  498. ASSERT( 0 == 1 );
  499. };
  500. };
  501. };
  502. m_Stream.DeFifo();
  503. };
  504. if( (wLukeIntFlag & 0x039f) != 0 )
  505. return HAL_IRQ_MINE;
  506. return HAL_IRQ_OTHER;
  507. };
  508. //---------------------------------------------------------------------------
  509. // IWrapperHAL QueryDMABufferSize
  510. //---------------------------------------------------------------------------
  511. HALRESULT CMPEGBoardHAL::QueryDMABufferSize( DWORD *Size, DWORD *BFlag )
  512. {
  513. *Size = 2048; // 2048 byte
  514. *BFlag = 0;
  515. return HAL_SUCCESS;
  516. };
  517. //---------------------------------------------------------------------------
  518. // IWrapperHAL QueryDMABufferSize
  519. //---------------------------------------------------------------------------
  520. HALRESULT CMPEGBoardHAL::SetDMABuffer( DWORD LinearAddr, DWORD physicalAddr )
  521. {
  522. m_DMABufferLinearAddr = LinearAddr;
  523. m_DMABufferPhysicalAddr = physicalAddr;
  524. return HAL_SUCCESS;
  525. };
  526. //---------------------------------------------------------------------------
  527. // IWrapperHAL GetCapability 1998.03.27 H.Yagi
  528. //---------------------------------------------------------------------------
  529. HALRESULT CMPEGBoardHAL::GetCapability( CAPSTYPE PropType, DWORD *pPropType )
  530. {
  531. ASSERT( m_pKernelObj != NULL );
  532. HALRESULT ret;
  533. WORD DeviceID, SubDevID, VenderID, SubVenID;
  534. ret = HAL_SUCCESS;
  535. m_pKernelObj->GetPCIConfigData( 0x00, &VenderID );
  536. m_pKernelObj->GetPCIConfigData( 0x02, &DeviceID );
  537. m_pKernelObj->GetPCIConfigData( 0x2C, &SubVenID );
  538. m_pKernelObj->GetPCIConfigData( 0x2E, &SubDevID );
  539. switch( PropType ){
  540. case VideoProperty:
  541. *pPropType = VideoProperty_TVSystem_BIT |
  542. VideoProperty_AspectRatio_BIT |
  543. VideoProperty_DisplayMode_BIT |
  544. VideoProperty_Resolution_BIT |
  545. VideoProperty_DigitalOut_BIT |
  546. VideoProperty_DigitalPalette_BIT |
  547. VideoProperty_APS_BIT |
  548. VideoProperty_ClosedCaption_BIT |
  549. // VideoProperty_OutputSource_BIT |
  550. VideoProperty_CompositeOut_BIT |
  551. VideoProperty_SVideoOut_BIT |
  552. VideoProperty_SkipFieldControl_BIT |
  553. VideoProperty_FilmCamera_BIT |
  554. VideoProperty_SquarePixel_BIT;
  555. if( VenderID==0x1179 && DeviceID==0x0407 ){ // SantaClara2 or SanJode
  556. switch( SubDevID ){
  557. case 0x0001: // SantaClara2
  558. case 0x0003: // SanJose
  559. *pPropType |= VideoProperty_OutputSource_BIT;
  560. break;
  561. }
  562. }
  563. ret = HAL_SUCCESS;
  564. break;
  565. case AudioProperty:
  566. case SubpicProperty:
  567. ret = HAL_NOT_IMPLEMENT;
  568. break;
  569. case DigitalVideoOut:
  570. *pPropType = DigitalVideoOut_ZV_BIT |
  571. DigitalVideoOut_LPB08_BIT |
  572. DigitalVideoOut_LPB16_BIT |
  573. DigitalVideoOut_VMI_BIT |
  574. DigitalVideoOut_AMCbt_BIT |
  575. DigitalVideoOut_AMC656_BIT |
  576. DigitalVideoOut_DAV2_BIT |
  577. DigitalVideoOut_CIRRUS_BIT ;
  578. // Check SubDevID
  579. switch( SubDevID ){
  580. case 0x0001: // SantaClara2
  581. case 0x0003: // SanJose
  582. *pPropType = DigitalVideoOut_ZV_BIT;
  583. break;
  584. }
  585. ret = HAL_SUCCESS;
  586. break;
  587. }
  588. return ret;
  589. };
  590. //---------------------------------------------------------------------------
  591. // IClassLibHAL GetMixHALStream
  592. //---------------------------------------------------------------------------
  593. HALRESULT CMPEGBoardHAL::GetMixHALStream( IHALStreamControl **ppHALStreamControl )
  594. {
  595. ASSERT( m_pKernelObj != NULL );
  596. *ppHALStreamControl = (IHALStreamControl *)&m_Stream;
  597. return HAL_SUCCESS;
  598. };
  599. //---------------------------------------------------------------------------
  600. // IClassLibHAL GetVideoHALStream
  601. //---------------------------------------------------------------------------
  602. HALRESULT CMPEGBoardHAL::GetVideoHALStream( IHALStreamControl **ppHALStreamControl )
  603. {
  604. return HAL_NOT_IMPLEMENT;
  605. };
  606. //---------------------------------------------------------------------------
  607. // IClassLibHAL GetAudioHALStream
  608. //---------------------------------------------------------------------------
  609. HALRESULT CMPEGBoardHAL::GetAudioHALStream( IHALStreamControl **ppHALStreamControl )
  610. {
  611. return HAL_NOT_IMPLEMENT;
  612. };
  613. //---------------------------------------------------------------------------
  614. // IClassLibHAL GetSubpicHALStream
  615. //---------------------------------------------------------------------------
  616. HALRESULT CMPEGBoardHAL::GetSubpicHALStream( IHALStreamControl **ppHALStreamControl )
  617. {
  618. return HAL_NOT_IMPLEMENT;
  619. };
  620. //---------------------------------------------------------------------------
  621. // IClassLibHAL SetSinkClassLib
  622. //---------------------------------------------------------------------------
  623. HALRESULT CMPEGBoardHAL::SetSinkClassLib( IMPEGBoardEvent *pMPEGBoardEvent )
  624. {
  625. if( pMPEGBoardEvent->GetEventType() == ClassLibEvent_SendData )
  626. {
  627. if( m_SendDataEventList.AddItem( pMPEGBoardEvent ) == FALSE )
  628. {
  629. DBG_BREAK();
  630. return HAL_ERROR;
  631. };
  632. return HAL_SUCCESS;
  633. }
  634. DBG_BREAK();
  635. return HAL_ERROR;
  636. };
  637. //---------------------------------------------------------------------------
  638. // IClassLibHAL UnsetSinkClassLib
  639. //---------------------------------------------------------------------------
  640. HALRESULT CMPEGBoardHAL::UnsetSinkClassLib( IMPEGBoardEvent *pMPEGBoardEvent )
  641. {
  642. if( pMPEGBoardEvent->GetEventType() == ClassLibEvent_SendData )
  643. {
  644. if( m_SendDataEventList.DeleteItem( pMPEGBoardEvent ) == FALSE )
  645. {
  646. DBG_BREAK();
  647. return HAL_ERROR;
  648. };
  649. return HAL_SUCCESS;
  650. }
  651. DBG_BREAK();
  652. return HAL_ERROR;
  653. };
  654. //---------------------------------------------------------------------------
  655. // IClassLibHAL SetPowerState
  656. //---------------------------------------------------------------------------
  657. HALRESULT CMPEGBoardHAL::SetPowerState( POWERSTATE dwSwitch )
  658. {
  659. ASSERT( m_pKernelObj != NULL );
  660. // CAutoHwInt hwintLock( m_pKernelObj );
  661. // POWERSTATE PowerState;
  662. // GetPowerState( &PowerState );
  663. // DBG_PRINTF( ("HAL:SetPowerState: OldState = %d, NewState = %d\n", PowerState, dwSwitch));
  664. /*
  665. if( dwSwitch == PowerState )
  666. return HAL_SUCCESS;
  667. */
  668. if( dwSwitch == POWERSTATE_ON )
  669. {
  670. BYTE Data;
  671. #ifndef _WDMDDK_
  672. m_pKernelObj->DisableHwInt();
  673. #endif
  674. // reset bit 7(PWROFF) and set bit 2(CLKON)
  675. m_pKernelObj->GetPCIConfigData( 0x44, &Data );
  676. Data = (BYTE)( (Data & 0x7f) | 0x04 );
  677. m_pKernelObj->SetPCIConfigData( 0x44, Data );
  678. // 10 msec wait.
  679. m_pKernelObj->Sleep( 10 );
  680. // set bit 6(BOFFZ) and bit 5(SRESET)
  681. m_pKernelObj->GetPCIConfigData( 0x44, &Data );
  682. Data = (BYTE)( Data | 0x60 );
  683. m_pKernelObj->SetPCIConfigData( 0x44, Data );
  684. // 1 msec wait.
  685. m_pKernelObj->Sleep( 1 );
  686. // reset bit 5(SRESET)
  687. m_pKernelObj->GetPCIConfigData( 0x44, &Data );
  688. Data = (BYTE)( Data & 0xdf );
  689. m_pKernelObj->SetPCIConfigData( 0x44, Data );
  690. #ifndef _WDMDDK_
  691. m_pKernelObj->EnableHwInt();
  692. #endif
  693. // Download ZiVA microcode
  694. switch( m_VideoProp.m_TVSystem )
  695. {
  696. case TV_NTSC:
  697. if( ziva.WriteMicrocode( 0 ) == FALSE )
  698. {
  699. DBG_BREAK();
  700. return HAL_ERROR;
  701. };
  702. break;
  703. case TV_PALB: case TV_PALD: case TV_PALG:
  704. case TV_PALH: case TV_PALI: case TV_PALM:
  705. case TV_PALN:
  706. if( ziva.WriteMicrocode( 1 ) == FALSE )
  707. {
  708. DBG_BREAK();
  709. return HAL_ERROR;
  710. };
  711. break;
  712. default:
  713. DBG_BREAK();
  714. return HAL_ERROR;
  715. };
  716. // HOST_control reset ZiVA and translate Run mode.
  717. ziva.Host_Control |= 0x00000022;
  718. // HOST_OPTIONS set by WrapperType. 98.09.25 by H.Yagi
  719. if( m_WrapperType == WrapperType_WDM ){
  720. ziva.HOST_OPTIONS |= 0x010;
  721. }
  722. #ifdef POWERCHECK_BY_FLAG
  723. m_PowerState = POWERSTATE_ON;
  724. #endif
  725. m_Stream.SetTransferMode( HALSTREAM_DVD_MODE );
  726. // setup properties
  727. SetVideoProperty_TVSystem( (void *)&m_VideoProp.m_TVSystem );
  728. SetVideoProperty_AspectRatio( (void *)&m_VideoProp.m_AspectRatio );
  729. SetVideoProperty_DisplayMode( (void *)&m_VideoProp.m_DisplayMode );
  730. SetVideoProperty_Resolution( (void *)&m_VideoProp.m_Size );
  731. SetVideoProperty_DigitalOut( (void *)&m_VideoProp.m_DigitalOut );
  732. for( int i = 0; i < 3; i ++ )
  733. {
  734. Digital_Palette Pal;
  735. Pal.Select = (VIDEOPALETTETYPE)i;
  736. Pal.pPalette = m_VideoProp.m_DigitalPalette[i];
  737. SetVideoProperty_DigitalPalette( (void *)&Pal );
  738. };
  739. SetVideoProperty_APS( (void *)&m_VideoProp.m_APS );
  740. SetVideoProperty_ClosedCaption( (void *)&m_VideoProp.m_ClosedCaption );
  741. SetVideoProperty_OutputSource( (void *)&m_VideoProp.m_OutputSource );
  742. SetVideoProperty_CompositeOut( (void *)&m_VideoProp.m_CompositeOut );
  743. SetVideoProperty_SVideoOut( (void *)&m_VideoProp.m_SVideoOut );
  744. SetVideoProperty_SkipFieldControl( (void *)&m_VideoProp.m_SkipFieldControl );
  745. SetAudioProperty_Type( (void *)&m_AudioProp.m_Type );
  746. SetAudioProperty_Number( (void *)&m_AudioProp.m_StreamNo );
  747. SetAudioProperty_Volume( (void *)&m_AudioProp.m_Volume );
  748. SetAudioProperty_Sampling( (void *)&m_AudioProp.m_Sampling );
  749. SetAudioProperty_Channel( (void *)&m_AudioProp.m_ChannelNo );
  750. SetAudioProperty_Quant( (void *)&m_AudioProp.m_Quant );
  751. SetAudioProperty_AudioOut( (void *)&m_AudioProp.m_OutType );
  752. SetAudioProperty_Cgms( (void *)&m_AudioProp.m_Cgms );
  753. SetAudioProperty_AnalogOut( (void *)&m_AudioProp.m_AnalogOut );
  754. SetAudioProperty_DigitalOut( (void *)&m_AudioProp.m_DigitalOut );
  755. SetAudioProperty_AC3DRangeLowBoost( (void *)&m_AudioProp.m_AC3DRangeLowBoost );
  756. SetAudioProperty_AC3DRangeHighCut( (void *)&m_AudioProp.m_AC3DRangeHighCut );
  757. SetAudioProperty_AC3OperateMode( (void *)&m_AudioProp.m_AC3OperateMode );
  758. SetSubpicProperty_Number( (void *)&m_SubpicProp.m_StreamNo);
  759. SetSubpicProperty_Palette( (void *)&m_SubpicProp.m_Palette );
  760. SetSubpicProperty_Hilight( (void *)&m_SubpicProp.m_Hlight );
  761. SetSubpicProperty_State( (void *)&m_SubpicProp.m_OutType );
  762. // Audio Mute Off
  763. // ioif.luke2.IO_CONT = ioif.luke2.IO_CONT & 0xffffffb8;
  764. ioif.luke2.IO_CONT = ( (ioif.luke2.IO_CONT & 0xffffffb8)|0x40 ); // *Luke2Z spec is changed.
  765. // power on delay
  766. m_NeedPowerOnDelay = TRUE;
  767. m_pKernelObj->GetTickCount( &m_PowerOnTime );
  768. //by oka
  769. m_CCstart = ziva.USER_DATA_BUFFER_START;
  770. m_CCend = ziva.USER_DATA_BUFFER_END;
  771. m_OSDStartAddr = ziva.OSD_BUFFER_START;
  772. m_OSDEndAddr = ziva.OSD_BUFFER_END;
  773. // end
  774. return HAL_SUCCESS;
  775. };
  776. if( dwSwitch == POWERSTATE_OFF )
  777. {
  778. BYTE Data;
  779. #ifndef _WDMDDK_
  780. m_pKernelObj->DisableHwInt();
  781. #endif
  782. // Audio Mute
  783. // ioif.luke2.IO_CONT = (ioif.luke2.IO_CONT & 0xffffff00) | 0x40;
  784. ioif.luke2.IO_CONT = (ioif.luke2.IO_CONT & 0xffffff00); // *Luke2Z spec is changed.
  785. // Check ZV Enable bit
  786. m_pKernelObj->GetPCIConfigData( 0x44, &Data );
  787. if( (Data & 0x01) != 0 )
  788. {
  789. Data = (BYTE)( Data & 0xfe );
  790. m_pKernelObj->SetPCIConfigData( 0x44, Data );
  791. };
  792. // reset bit 6(BOFFZ)
  793. m_pKernelObj->GetPCIConfigData( 0x44, &Data );
  794. Data = (BYTE)( Data & 0xbf );
  795. m_pKernelObj->SetPCIConfigData( 0x44, Data );
  796. // reset bit 2(CLKON) and set bit 7(PWROFF)
  797. m_pKernelObj->GetPCIConfigData( 0x44, &Data );
  798. Data = (BYTE)( (Data & 0xfb) | 0x80 );
  799. m_pKernelObj->SetPCIConfigData( 0x44, Data );
  800. #ifdef POWERCHECK_BY_FLAG
  801. m_PowerState = POWERSTATE_OFF;
  802. #endif
  803. #ifndef _WDMDDK_
  804. m_pKernelObj->EnableHwInt();
  805. #endif
  806. return HAL_SUCCESS;
  807. };
  808. return HAL_INVALID_PARAM;
  809. };
  810. //---------------------------------------------------------------------------
  811. // IClassLibHAL GetPowerState
  812. //---------------------------------------------------------------------------
  813. HALRESULT CMPEGBoardHAL::GetPowerState( POWERSTATE *pSwitch )
  814. {
  815. ASSERT( m_pKernelObj != NULL );
  816. #ifdef POWERCHECK_BY_FLAG
  817. *pSwitch = m_PowerState;
  818. return HAL_SUCCESS;
  819. #else
  820. BYTE Data;
  821. m_pKernelObj->GetPCIConfigData( 0x44, &Data );
  822. if( ( Data & 0x80 ) == 0 )
  823. {
  824. if( ( ziva.Host_Control & 0xc00000 ) == 0 )
  825. *pSwitch = POWERSTATE_ON;
  826. else
  827. {
  828. SetPowerState( POWERSTATE_OFF );
  829. *pSwitch = POWERSTATE_OFF;
  830. };
  831. }
  832. else
  833. *pSwitch = POWERSTATE_OFF;
  834. #endif
  835. return HAL_SUCCESS;
  836. };
  837. //---------------------------------------------------------------------------
  838. // IClassLibHAL SetSTC
  839. //---------------------------------------------------------------------------
  840. HALRESULT CMPEGBoardHAL::SetSTC( DWORD STCValue )
  841. {
  842. POWERSTATE PowerState;
  843. GetPowerState( &PowerState );
  844. if( PowerState != POWERSTATE_ON )
  845. return HAL_POWEROFF;
  846. ziva.MRC_PIC_STC = STCValue;
  847. return HAL_SUCCESS;
  848. };
  849. //---------------------------------------------------------------------------
  850. // IClassLibHAL GetSTC
  851. //---------------------------------------------------------------------------
  852. HALRESULT CMPEGBoardHAL::GetSTC( DWORD *pSTCValue )
  853. {
  854. POWERSTATE PowerState;
  855. GetPowerState( &PowerState );
  856. if( PowerState != POWERSTATE_ON )
  857. return HAL_POWEROFF;
  858. *pSTCValue = ziva.MRC_PIC_STC;
  859. return HAL_SUCCESS;
  860. };
  861. //---------------------------------------------------------------------------
  862. // Send HAL Notify
  863. //---------------------------------------------------------------------------
  864. void CMPEGBoardHAL::NotifyEvent( CList *pList, VOID *Ret )
  865. {
  866. IMPEGBoardEvent *pEvent;
  867. pList->SetCurrentToTop();
  868. while( ( pEvent = (IMPEGBoardEvent *)pList->GetNext() ) != NULL )
  869. pEvent->Advice( Ret );
  870. };
  871. //---------------------------------------------------------------------------
  872. // Check ZIVA Interrupt(ZiVA Decoder To Host Interrupt Check )
  873. //---------------------------------------------------------------------------
  874. void CMPEGBoardHAL::CheckZiVAInterrupt( DWORD dwIntFlag )
  875. {
  876. // ERR: Bitstream data error has been deteced.
  877. if( ( dwIntFlag & ZIVA_INT_ERR ) != 0 )
  878. {
  879. };
  880. // PIC-V: Starting display of new picture.
  881. if( ( dwIntFlag & ZIVA_INT_PICV ) != 0 )
  882. {
  883. // by oka
  884. NotifyEvent( &m_NextPictureEventList, NULL );
  885. };
  886. // GOP-V: Starting display of first I-Picture after GOP startcode.
  887. if( ( dwIntFlag & ZIVA_INT_GOPV ) != 0 )
  888. {
  889. for( DWORD i = 0 ; i < m_NaviCount; i ++ )
  890. NotifyEvent( &m_StartVOBUEventList, NULL );
  891. m_NaviCount = 0;
  892. };
  893. // SEQ-V: Starting display of first I-Pucture after sequence start-code.
  894. if( ( dwIntFlag & ZIVA_INT_SEQV ) != 0 )
  895. {
  896. };
  897. // END-V: Starting display of last picture before sequence-end startcode.
  898. if( ( dwIntFlag & ZIVA_INT_ENDV ) != 0 )
  899. {
  900. };
  901. // PIC-D: Completed picture decode.
  902. if( ( dwIntFlag & ZIVA_INT_PICD ) != 0 )
  903. {
  904. };
  905. // VSYNC: VSYNC pulse occurred.
  906. if( ( dwIntFlag & ZIVA_INT_VSYNC ) != 0 )
  907. {
  908. // for VSyncEvent
  909. NotifyEvent( &m_VSyncEventList, NULL );
  910. // by oka
  911. if( m_VideoProp.m_ClosedCaption == ClosedCaption_On ){
  912. SendCCData();
  913. }
  914. /****** commented out by H.Yagi 98.05.13 **** start *****
  915. DWORD Data;
  916. switch( (DWORD)ziva.CURR_PIC_DISPLAYED )
  917. {
  918. case ADDR_PIC1_BUFFER_START:
  919. Data = ziva.PIC1_TREF_PTYP_FLGS;
  920. break;
  921. case ADDR_PIC2_BUFFER_START:
  922. Data = ziva.PIC2_TREF_PTYP_FLGS;
  923. break;
  924. case ADDR_PIC3_BUFFER_START:
  925. Data = ziva.PIC3_TREF_PTYP_FLGS;
  926. break;
  927. default:
  928. Data = 0;
  929. };
  930. static DWORD SkipCounter = 0;
  931. static DWORD OldData = 0;
  932. if( ( OldData & 0x40 ) == 0 && (Data & 0x40 ) != 0 )
  933. SkipCounter = 5;
  934. OldData = Data;
  935. ****** commented out by H.Yagi 98.05.13 **** end *****/
  936. /*
  937. // check Progressive and repeat_first
  938. if( (Data & 0x50 ) == 0x50 )
  939. {
  940. if( ziva.VIDEO_FIELD == 0 ) // check Top field?
  941. {
  942. if( (Data & 0x20 ) == 0 && SkipCounter == 0 ) // check Top_Field_first = 1?
  943. {
  944. // Skip!!
  945. SkipCounter = 5;
  946. };
  947. }
  948. else // Bottom field.
  949. {
  950. if( (Data & 0x20 ) != 0 && SkipCounter == 0 ) // check Top_Field_first = 0?
  951. {
  952. // Skip!!
  953. SkipCounter = 5;
  954. };
  955. };
  956. };
  957. */
  958. /****** commented out by H.Yagi 98.05.13 **** start *****
  959. DWORD Flag;
  960. ziva.ZiVAReadMemory( 0x210, &Flag );
  961. // if( SkipCounter == 4 || SkipCounter ==3 || SkipCounter == 5 )
  962. // if( Flag != 0 && SkipCounter == Flag )
  963. if( Flag != 0 )
  964. {
  965. if( ( Flag & 0x01 ) != 0 && SkipCounter == 5 )
  966. ioif.luke2.AVCONT |= 0x02;
  967. if( ( Flag & 0x02 ) != 0 && SkipCounter == 4 )
  968. ioif.luke2.AVCONT |= 0x02;
  969. if( ( Flag & 0x04 ) != 0 && SkipCounter == 3 )
  970. ioif.luke2.AVCONT |= 0x02;
  971. if( ( Flag & 0x08 ) != 0 && SkipCounter == 2 )
  972. ioif.luke2.AVCONT |= 0x02;
  973. if( ( Flag & 0x10 ) != 0 && SkipCounter == 1 )
  974. ioif.luke2.AVCONT |= 0x02;
  975. };
  976. if( SkipCounter > 0 )
  977. SkipCounter --;
  978. ****** commented out by H.Yagi 98.05.13 **** end *****/
  979. };
  980. // AOR: VCD Mode: VCD sector address out of range in CDROM_MPEG mode
  981. // PBT: DVD Mode: Delect VOBU_E_PTM
  982. if( ( dwIntFlag & ZIVA_INT_AOR ) != 0 )
  983. {
  984. // by oka for END_VOB or NV_LBN
  985. DWORD PbtInt = (m_ZivaPbtIntMask & ziva.PBT_INT_SRC);
  986. // END_VOB
  987. if ((PbtInt & PBT_INT_END_VOB) != 0)
  988. {
  989. ziva.INT_MASK &= (ULONG)(~ZIVA_INT_AOR);
  990. NotifyEvent( &m_EndVOBEventList, NULL );
  991. }
  992. };
  993. // UND: Input buffer underflow.
  994. if( ( dwIntFlag & ZIVA_INT_UND ) != 0 )
  995. {
  996. DWORD UFlag = ziva.UND_INT_SRC;
  997. // Check Video Underflow
  998. if( (UFlag & 0x01) != 0 )
  999. NotifyEvent( &m_VUnderFlowEventList , NULL );
  1000. // Check Audio Underflow
  1001. if( (UFlag & 0x02) != 0 )
  1002. NotifyEvent( &m_AUnderFlowEventList , NULL );
  1003. // Check SubPic Underflow
  1004. if( (UFlag & 0x04) != 0 )
  1005. NotifyEvent( &m_SPUnderFlowEventList , NULL );
  1006. };
  1007. // END-C: High-Priority command execution is complete.
  1008. if( ( dwIntFlag & ZIVA_INT_ENDC ) != 0 )
  1009. {
  1010. SetENDCEvent();
  1011. };
  1012. // RDY-S: Ready for data during CDROM_MPEG mode SlowMotion() or SingleStep() Commands.
  1013. if( ( dwIntFlag & ZIVA_INT_RDYS ) != 0 )
  1014. {
  1015. };
  1016. // SCN: A Scan() command has caused a transition to PAUSE()
  1017. if( ( dwIntFlag & ZIVA_INT_SCN ) != 0 )
  1018. {
  1019. };
  1020. // USR: User data is ready
  1021. if( ( dwIntFlag & ZIVA_INT_USR ) != 0 )
  1022. {
  1023. // by oka
  1024. SetUSRData();
  1025. };
  1026. // END-P: Entered PAUSE state.
  1027. if( ( dwIntFlag & ZIVA_INT_ENDP ) != 0 )
  1028. {
  1029. SetENDPEvent();
  1030. };
  1031. // END-D: a data transfer is complete, from either a Dump DumpData_VCD(),DumpData_DVD(),or ROMtoDRAM() command.
  1032. if( ( dwIntFlag & ZIVA_INT_ENDD ) != 0 )
  1033. {
  1034. };
  1035. // A/E/E: Deteced CD submode auto-pause, end of recoerd, or end of file.
  1036. if( ( dwIntFlag & ZIVA_INT_AEE ) != 0 )
  1037. {
  1038. };
  1039. // BUF-F: An input buffer is full or the video input buffer os fulling CDROM_MPEG mode SlowMotion() and SingleStep() commands.
  1040. if( ( dwIntFlag & ZIVA_INT_BUFF ) != 0 )
  1041. {
  1042. DWORD OFlag = ziva.BUFF_INT_SRC;
  1043. // Check Video OverFlow
  1044. if( (OFlag & 0x01) != 0 )
  1045. NotifyEvent( &m_VOverFlowEventList , NULL );
  1046. // Check Audio OverFlow
  1047. if( (OFlag & 0x02) != 0 )
  1048. NotifyEvent( &m_AOverFlowEventList , NULL );
  1049. // Check SubPic Underflow
  1050. if( (OFlag & 0x04) != 0 )
  1051. NotifyEvent( &m_SPOverFlowEventList , NULL );
  1052. };
  1053. // SEQ-E: A sequence_end_code startcode has been processed by the MPEG video decoder.
  1054. if( ( dwIntFlag & ZIVA_INT_SEQE ) != 0 )
  1055. {
  1056. };
  1057. // NV: an NV_PACK has benn received and parsed into DSI and PCI packets.
  1058. if( ( dwIntFlag & ZIVA_INT_NV ) != 0 )
  1059. {
  1060. m_NaviCount ++;
  1061. };
  1062. // HLI: a button activation highlight has just been displayed.
  1063. if( ( dwIntFlag & ZIVA_INT_HLI ) != 0 )
  1064. {
  1065. // by oka
  1066. DWORD Data;
  1067. Data = ziva.HLI_INT_SRC;
  1068. NotifyEvent( &m_ButtonActivteEventList, (PVOID)Data );
  1069. };
  1070. // RDY-D: The decoder is ready to receive data.
  1071. if( ( dwIntFlag & ZIVA_INT_RDYD ) != 0 )
  1072. {
  1073. SetRDYDEvent();
  1074. };
  1075. // Reserved.
  1076. if( ( dwIntFlag & ZIVA_INT_RESERV1 ) != 0 )
  1077. {
  1078. };
  1079. // AUD: A new audio frequency, sample size, or audio emphasis value was detected.
  1080. if( ( dwIntFlag & ZIVA_INT_AUD ) != 0 )
  1081. {
  1082. };
  1083. // INIT: Decoder microcode initialization is complete. Status Area is Valid. Decoder is ready to accept host commands.
  1084. if( ( dwIntFlag & ZIVA_INT_INIT ) != 0 )
  1085. {
  1086. };
  1087. };
  1088. //---------------------------------------------------------------------------
  1089. // WaitMasterAbort
  1090. //---------------------------------------------------------------------------
  1091. BOOL CMPEGBoardHAL::WaitMasterAbort( void )
  1092. {
  1093. // Wait Master Abort interrupt
  1094. CTimeOut TimeOut( 5000, 10, m_pKernelObj );
  1095. //#ifdef _WDMDDK_
  1096. // WORD wLukeIntFlag;
  1097. //#endif
  1098. while( TRUE )
  1099. {
  1100. if( IsMasterAbortOccurred() == TRUE )
  1101. break;
  1102. //#ifdef _WDMDDK_
  1103. // wLukeIntFlag = ioif.luke2.IO_INTF;
  1104. // if( (wLukeIntFlag & 0x04 ) != 0 )
  1105. // break;
  1106. //#endif
  1107. TimeOut.Sleep();
  1108. if( TimeOut.CheckTimeOut() == TRUE )
  1109. {
  1110. DBG_BREAK();
  1111. return FALSE;
  1112. };
  1113. };
  1114. return TRUE;
  1115. };
  1116. //---------------------------------------------------------------------------
  1117. // WaitWaitRDYD
  1118. //---------------------------------------------------------------------------
  1119. BOOL CMPEGBoardHAL::WaitRDYD( void )
  1120. {
  1121. // Wait RDY-D interrupt
  1122. CTimeOut TimeOut( 5000, 10, m_pKernelObj );
  1123. //#ifdef _WDMDDK_
  1124. // DWORD dwZiVAIntFlag;
  1125. //#endif
  1126. while( TRUE )
  1127. {
  1128. if( IsRDYDOccurred() == TRUE )
  1129. break;
  1130. //#ifdef _WDMDDK_
  1131. // dwZiVAIntFlag = ziva.INT_STATUS & ziva.INT_MASK;
  1132. // if( ( dwZiVAIntFlag & ZIVA_INT_RDYD ) != 0 )
  1133. // break;
  1134. //#endif
  1135. TimeOut.Sleep();
  1136. if( TimeOut.CheckTimeOut() == TRUE )
  1137. {
  1138. DBG_BREAK();
  1139. return FALSE;
  1140. };
  1141. };
  1142. return TRUE;
  1143. };
  1144. //---------------------------------------------------------------------------
  1145. // WaitWaitENDP
  1146. //---------------------------------------------------------------------------
  1147. BOOL CMPEGBoardHAL::WaitENDP( void )
  1148. {
  1149. // Wait END-P interrupt
  1150. CTimeOut TimeOut( 5000, 10, m_pKernelObj );
  1151. //#ifdef _WDMDDK_
  1152. // DWORD dwZiVAIntFlag;
  1153. //#endif
  1154. while( TRUE )
  1155. {
  1156. if( IsENDPOccurred() == TRUE )
  1157. break;
  1158. //#ifdef _WDMDDK_
  1159. // dwZiVAIntFlag = ziva.INT_STATUS & ziva.INT_MASK;
  1160. // if( ( dwZiVAIntFlag & ZIVA_INT_ENDP ) != 0 )
  1161. // break;
  1162. //#endif
  1163. TimeOut.Sleep();
  1164. if( TimeOut.CheckTimeOut() == TRUE )
  1165. {
  1166. DBG_BREAK();
  1167. return FALSE;
  1168. };
  1169. };
  1170. return TRUE;
  1171. };
  1172. //---------------------------------------------------------------------------
  1173. // WaitWaitENDC
  1174. //---------------------------------------------------------------------------
  1175. BOOL CMPEGBoardHAL::WaitENDC( void )
  1176. {
  1177. // Wait END-C interrupt
  1178. CTimeOut TimeOut( 5000, 10, m_pKernelObj );
  1179. //#ifdef _WDMDDK_
  1180. // DWORD dwZiVAIntFlag;
  1181. //// DWORD StatusPointer,Status;
  1182. //#endif
  1183. while( TRUE )
  1184. {
  1185. if( IsENDCOccurred() == TRUE )
  1186. break;
  1187. //#ifdef _WDMDDK_
  1188. // dwZiVAIntFlag = ziva.INT_STATUS & ziva.INT_MASK;
  1189. // if( ( dwZiVAIntFlag & ZIVA_INT_ENDC ) != 0 )
  1190. // break;
  1191. //
  1192. ///*
  1193. // StatusPointer = Status = 0;
  1194. // ziva.ZiVAReadMemory(ADDR_STATUS_ADDRESS, &StatusPointer);
  1195. // if( StatusPointer != 0 )
  1196. // {
  1197. // ziva.ZiVAReadMemory(StatusPointer, &Status);
  1198. // if( Status == 0x04 )
  1199. // return TRUE;
  1200. // };
  1201. //*/
  1202. //#endif
  1203. TimeOut.Sleep();
  1204. if( TimeOut.CheckTimeOut() == TRUE )
  1205. {
  1206. DBG_BREAK();
  1207. return FALSE;
  1208. };
  1209. };
  1210. return TRUE;
  1211. };
  1212. //---------------------------------------------------------------------------
  1213. //
  1214. //---------------------------------------------------------------------------
  1215. void CMPEGBoardHAL::ClearMasterAbortEvent( void ){ fMasterAbortFlag = FALSE; };
  1216. void CMPEGBoardHAL::SetMasterAbortEvent( void ){ fMasterAbortFlag = TRUE; };
  1217. BOOL CMPEGBoardHAL::IsMasterAbortOccurred( void ) { return fMasterAbortFlag; };
  1218. void CMPEGBoardHAL::ClearRDYDEvent( void ){ fRDYDFlag = FALSE; };
  1219. void CMPEGBoardHAL::SetRDYDEvent( void ){ fRDYDFlag = TRUE; };
  1220. BOOL CMPEGBoardHAL::IsRDYDOccurred( void ) { return fRDYDFlag; };
  1221. void CMPEGBoardHAL::ClearENDPEvent( void ){ fENDPFlag = FALSE; };
  1222. void CMPEGBoardHAL::SetENDPEvent( void ){ fENDPFlag = TRUE; };
  1223. BOOL CMPEGBoardHAL::IsENDPOccurred( void ) { return fENDPFlag; };
  1224. void CMPEGBoardHAL::ClearENDCEvent( void ){ fENDCFlag = FALSE; };
  1225. void CMPEGBoardHAL::SetENDCEvent( void ){ fENDCFlag = TRUE; };
  1226. BOOL CMPEGBoardHAL::IsENDCOccurred( void ) { return fENDCFlag; };
  1227. //---------------------------------------------------------------------------
  1228. // CMPEGBoardHAL::SetUSRData
  1229. // by oka Closed Caption
  1230. //---------------------------------------------------------------------------
  1231. inline void CMPEGBoardHAL::SetUSRData( void )
  1232. {
  1233. // USER_DATA_WRITE�̃A�h���X�����f�[�^�������o��
  1234. DWORD read, write;
  1235. read = ziva.USER_DATA_READ;
  1236. write = ziva.USER_DATA_WRITE;
  1237. // check header
  1238. DWORD header,data_size;
  1239. // DWORD header_type;
  1240. ziva.ZiVAReadMemory(read, &header);
  1241. if (read == 0xFFFFFFFF)
  1242. {
  1243. // FIFO overflow
  1244. //RETAILMSG(ZONE_TRACE,(TEXT("FIFO overflow \r\n")));
  1245. ziva.USER_DATA_READ = write;
  1246. //DBG_BREAK();
  1247. return;
  1248. }
  1249. ASSERT((header & 0xFFFF0000) >> 16 == 0xFEED);
  1250. // header_type = (header & 0x0000F000) >> 12;
  1251. data_size = (header & 0x00000FFF);
  1252. // RETAILMSG(1,(TEXT("start=%08X end=%08X read=%X header=%08X header_type=%01d size=%04X \r\n"),
  1253. // start, end, read, header, header_type, data_size ));
  1254. m_UserData.Init();
  1255. DWORD data_tmp;
  1256. DWORD point;
  1257. point = read;
  1258. DWORD count;
  1259. for(count=0;count<data_size;count+=4)
  1260. {
  1261. // for ring buffer
  1262. if (point+4 >= m_CCend)
  1263. {
  1264. point = m_CCstart;
  1265. } else {
  1266. point += 4;
  1267. }
  1268. // Get user data
  1269. ziva.ZiVAReadMemory(point, &data_tmp);
  1270. if (!(m_UserData.Set(data_tmp)))
  1271. {
  1272. //RETAILMSG(ZONE_ERROR, (TEXT("CMPEGBoardHAL::SetUSRData UserData size too Big!!\r\n")));
  1273. DBG_BREAK();
  1274. break;
  1275. }
  1276. }
  1277. // check line21 indicator (first user data must be line21 data in DVD Book)
  1278. if(!((m_UserData.Get(0) == 0x43) && (m_UserData.Get(1) == 0x43)))
  1279. {
  1280. //Not Line21 data
  1281. //DBG_BREAK();
  1282. //RETAILMSG(ZONE_ERROR,(TEXT("Not Line21 Data \r\n")));
  1283. ziva.USER_DATA_READ = write;
  1284. return;
  1285. }
  1286. // check top_field_flag_of_gop
  1287. // GOP�̓��̃t�B�[���h�������킵�Ă����B
  1288. // �����𑗂��Ȃ��Ƃ��ׂĂ��\�����邱�Ƃ��ł��Ȃ��B
  1289. // if((data[4] & 0x80) == 0)
  1290. // {
  1291. // // data size error
  1292. // DBG_BREAK();
  1293. // DEBUGMSG(ZONE_TRACE,(TEXT("Bottom field data!!\r\n")));
  1294. // ziva.USER_DATA_READ = write;
  1295. // return;
  1296. // } else {
  1297. // ziva.USER_DATA_READ = write;
  1298. // return;
  1299. // }
  1300. DWORD number_of_data;
  1301. number_of_data = m_UserData.Get(4) & 0x3F;
  1302. // user_data_start_code -> number_of_displayed_field_gop = 5byte
  1303. if ((number_of_data * 3) + 5 > data_size)
  1304. {
  1305. // data size error
  1306. DBG_BREAK();
  1307. //DEBUGMSG(ZONE_ERROR,(TEXT("line21 data size error \r\n")));
  1308. return;
  1309. }
  1310. // �L���f�[�^�������O�o�b�t�@�ɓo�^
  1311. count = 0;
  1312. point = m_CCDataPoint;
  1313. m_CCRingBufferNumber = 0;
  1314. while(count<number_of_data)
  1315. {
  1316. if(m_UserData.Get(5+count*3) != 0xFF)
  1317. {
  1318. // line21_switch off
  1319. count++;
  1320. } else {
  1321. // RETAILMSG(1,(TEXT("%c%c"),(data[count*3+6] & 0x7f),(data[count*3+7] & 0x7f)));
  1322. m_CCData[m_CCDataPoint] = (DWORD)(m_UserData.Get(count*3+6)<<8)
  1323. | m_UserData.Get(count*3+7);
  1324. m_CCRingBufferNumber++;
  1325. count++;
  1326. m_CCDataPoint++;
  1327. if (m_CCDataPoint >= CC_DATA_SIZE)
  1328. { m_CCDataPoint = 0; }
  1329. }
  1330. }
  1331. m_CCRingBufferStart = point;
  1332. NotifyEvent( &m_UserDataEventList, &m_UserData );
  1333. // RETAILMSG(1,(TEXT("\r\n")));
  1334. // DEBUGMSG(ZONE_TRACE,(TEXT("line21 data size 0x%x ring start 0x%x num0x%x \r\n"),
  1335. // m_CCDataNumber,
  1336. // m_CCRingBufferStart,m_CCRingBufferNumber));
  1337. // USER_DATA_READ��USER_DATA_WRITE�̃A�h���X���������݁AZiVA�Ƀf�[�^�̓]���I����
  1338. // �m�点���B
  1339. ziva.USER_DATA_READ = write;
  1340. return;
  1341. }
  1342. //---------------------------------------------------------------------------
  1343. // CMPEGBoardHAL::SendCCData
  1344. // m_CCDataNumber ���ꂩ�瑗���ׂ��f�[�^�̃T�C�Y
  1345. // by oka for Closed Caption
  1346. //---------------------------------------------------------------------------
  1347. inline void CMPEGBoardHAL::SendCCData( void )
  1348. {
  1349. // �Е��̃t�B�[���h�ł̂ݏ����������BEven�̂Ƃ���Odd�̃f�[�^�������̂����z
  1350. // �������A�t�����Ȃ��Ƃ������ƂłȂ��B�H�H�H
  1351. if( ziva.VIDEO_FIELD == 0 ) // check Top field?
  1352. {
  1353. // RETAILMSG(1,(TEXT("top field\r\n")));
  1354. // return;
  1355. } else {
  1356. return;
  1357. }
  1358. // �^�C�~���O�ɂ����Ă͐V�K�f�[�^�̓o�^�̂��Ƃɏ��������ق����������������Ȃ��B
  1359. if(m_CCnumber < m_CCDataNumber)
  1360. {
  1361. adv->SetClosedCaptionData( m_CCData[m_CCsend_point] );
  1362. m_CCsend_point++;
  1363. m_CCnumber++;
  1364. } else {
  1365. adv->SetClosedCaptionData( 0x00008080 );
  1366. }
  1367. // Ring�o�b�t�@�̐ݒ�
  1368. if (m_CCsend_point >= CC_DATA_SIZE)
  1369. m_CCsend_point = 0;
  1370. // ���̃o�b�t�@�̊J�n�ʒu���^���炽
  1371. if (m_CCRingBufferStart != 0xFFFFFFFF)
  1372. {
  1373. //�O�̃f�[�^�̓]�������ׂďI�����Ă�����
  1374. if (m_CCnumber == m_CCDataNumber)
  1375. {
  1376. ASSERT(m_CCsend_point == m_CCRingBufferStart);
  1377. m_CCsend_point = m_CCRingBufferStart;
  1378. m_CCDataNumber = m_CCRingBufferNumber;
  1379. }
  1380. else // �f�[�^�̓]�����ǂ��‚��Ȃ������Ƃ��̏���
  1381. {
  1382. m_CCpending = m_CCDataNumber - m_CCnumber;
  1383. // ���ꂩ�瑗���ׂ��f�[�^�̐�
  1384. m_CCDataNumber = m_CCpending + m_CCRingBufferNumber;
  1385. // �����Ȃ��f�[�^���R�O�𒴂������A���������ł��Ȃ��̂Ŏ̂Ă��B
  1386. if (m_CCpending > 30)
  1387. {
  1388. //RETAILMSG(ZONE_ERROR,(TEXT("pendig data is too large \r\n")));
  1389. m_CCpending = 0;
  1390. m_CCDataNumber = m_CCRingBufferNumber;
  1391. m_CCsend_point = m_CCRingBufferStart;
  1392. }
  1393. }
  1394. // if (m_CCpending > 0)
  1395. // {
  1396. // RETAILMSG(ZONE_TRACE,(TEXT("send_p %02x num %02x RingStart %02x RingNumber %02x "),
  1397. // m_CCsend_point,m_CCnumber, m_CCRingBufferStart,m_CCRingBufferNumber));
  1398. //
  1399. // RETAILMSG(ZONE_TRACE,(TEXT("pend %02x CCDataNumber %04x \r\n"),
  1400. // m_CCpending,m_CCDataNumber));
  1401. // }
  1402. m_CCRingBufferStart = 0xFFFFFFFF;
  1403. // �������f�[�^�̐��̏�����
  1404. m_CCnumber = 0;
  1405. } else {
  1406. //�]�����ǂ��‚��Ȃ������Ƃ��ɂ����Ȃ��f�[�^���Ƃ΂�
  1407. while((m_CCpending > 0) && (m_CCData[m_CCsend_point] == 0x00008080))
  1408. {
  1409. m_CCsend_point++;
  1410. m_CCpending--;
  1411. m_CCnumber++;
  1412. if (m_CCsend_point >= CC_DATA_SIZE)
  1413. { m_CCsend_point = 0;}
  1414. }
  1415. }
  1416. // if(m_CCnumber > m_CCDataNumber)
  1417. // {
  1418. // RETAILMSG(1,(TEXT("m_CCnumber > m_CCDataNumber \r\n")));
  1419. // DBG_BREAK();
  1420. // }
  1421. ASSERT(m_CCnumber <= m_CCDataNumber);
  1422. return;
  1423. }
  1424. //---------------------------------------------------------------------------
  1425. // CMPEGBoardHAL::SetEventIntMask
  1426. // mask �g�p�����C�x���g�r�b�g�𗧂Ă��l
  1427. // by oka
  1428. //---------------------------------------------------------------------------
  1429. BOOL CMPEGBoardHAL::SetEventIntMask( DWORD mask )
  1430. {
  1431. // ZiVA use 0-23 bit
  1432. if ( (mask & 0xff000000) != 0)
  1433. return FALSE;
  1434. DWORD tmp_mask;
  1435. tmp_mask = mask;
  1436. for ( DWORD bit = 0; bit < 24 ; bit++ )
  1437. {
  1438. if( (tmp_mask & 0x00000001) != 0 )
  1439. {
  1440. m_MaskReference[bit]++;
  1441. }
  1442. tmp_mask = tmp_mask >> 1;
  1443. }
  1444. m_EventIntMask |= mask;
  1445. return TRUE;
  1446. }
  1447. //---------------------------------------------------------------------------
  1448. // CMPEGBoardHAL::UnsetEventIntMask
  1449. // mask �g�p�s�‚ɂ����C�x���g�r�b�g�𗧂Ă��l
  1450. // by oka
  1451. //---------------------------------------------------------------------------
  1452. BOOL CMPEGBoardHAL::UnsetEventIntMask( DWORD mask )
  1453. {
  1454. // ZiVA use 0-23 bit
  1455. if ( (mask & 0xff000000) != 0)
  1456. return FALSE;
  1457. DWORD tmp_mask = 0;
  1458. for ( DWORD bit = 0; bit < 24 ; bit++ )
  1459. {
  1460. if( (mask & 0x00000001) != 0 )
  1461. {
  1462. if ( m_MaskReference[bit] < 2 )
  1463. {
  1464. tmp_mask |= (0x1 << bit);
  1465. m_MaskReference[bit] = 0;
  1466. } else {
  1467. m_MaskReference[bit]--;
  1468. }
  1469. }
  1470. mask = (mask >> 1);
  1471. }
  1472. m_EventIntMask &= (DWORD)~(tmp_mask);
  1473. return TRUE;
  1474. }
  1475. //---------------------------------------------------------------------------
  1476. //
  1477. //---------------------------------------------------------------------------
  1478. //***************************************************************************
  1479. // End of Zivabrd.cpp
  1480. //***************************************************************************