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.

355 lines
10 KiB

  1. //**************************************************************************
  2. //
  3. // Title : MPEvent.cpp
  4. //
  5. // Date : 1997.12.09 1st making
  6. //
  7. // Author : Toshiba [PCS](PSY) Hideki Yagi
  8. //
  9. // Copyright 1997 Toshiba Corporation. All Rights Reserved.
  10. //
  11. // -------------------------------------------------------------------------
  12. //
  13. // Change log :
  14. //
  15. // Date Revision Description
  16. // ------------ ---------- -----------------------------------------------
  17. // 1997.12.09 000.0000 1st making.
  18. //
  19. //**************************************************************************
  20. #include "includes.h"
  21. #include "hal.h"
  22. #include "classlib.h"
  23. #include "ctime.h"
  24. #include "schdat.h"
  25. #include "mpevent.h"
  26. #include "wdmbuff.h"
  27. #include "ccque.h"
  28. #include "userdata.h"
  29. #include "wdmkserv.h"
  30. #include "ctvctrl.h"
  31. #include "hlight.h"
  32. #include "hwdevex.h"
  33. #include "dvdinit.h"
  34. #define USCC_BuffSize 0x200 // OK?
  35. ////////////////////////////////////////////////////////////////////////////
  36. //
  37. ////////////////////////////////////////////////////////////////////////////
  38. void AdviceCallBack( PHW_STREAM_REQUEST_BLOCK pSrb )
  39. {
  40. StreamClassStreamNotification( StreamRequestComplete,
  41. pSrb->StreamObject, pSrb );
  42. }
  43. IMBoardListItem *CDataXferEvent::GetNext( void )
  44. {
  45. return( m_Next );
  46. }
  47. void CDataXferEvent::SetNext( IMBoardListItem *item )
  48. {
  49. m_Next = item;
  50. return;
  51. }
  52. HALEVENTTYPE CDataXferEvent::GetEventType( void )
  53. {
  54. return( m_EventType );
  55. }
  56. void CDataXferEvent::Advice( void *pData )
  57. {
  58. CWDMBuffer *ptr;
  59. PHW_STREAM_REQUEST_BLOCK pSrb;
  60. ptr = (CWDMBuffer *)pData;
  61. ptr->SetNext( NULL ); // 98.04.10
  62. pSrb = ptr->GetSRB();
  63. if( pSrb->Status != STATUS_CANCELLED ){
  64. pSrb->Status = STATUS_SUCCESS;
  65. }
  66. DBG_PRINTF( ("DataXfer-Advice: cuurent Irql = 0x%04x pSrb=0x%x\n\r", KeGetCurrentIrql(),pSrb ) );
  67. // if( KeGetCurrentIrql() > PASSIVE_LEVEL ){
  68. // StreamClassCallAtNewPriority( NULL,
  69. // pSrb->HwDeviceExtension,
  70. //// LowToigh,
  71. // Low,
  72. // (PHW_PRIORITY_ROUTINE)AdviceCallBack,
  73. // pSrb
  74. // );
  75. // }else{
  76. #ifndef REARRANGEMENT
  77. if (ptr->m_EndFlag == FALSE)
  78. return; //non last buffer
  79. DBG_PRINTF( ("DVDWDM:Advice()---CompleteNotification Srb=%x\n\r", pSrb));
  80. #endif REARRANGEMENT
  81. StreamClassStreamNotification( StreamRequestComplete,
  82. pSrb->StreamObject, pSrb );
  83. // }
  84. return;
  85. }
  86. ////////////////////////////////////////////////////////////////////////////
  87. //
  88. ////////////////////////////////////////////////////////////////////////////
  89. void CUserDataEvent::Init( HW_DEVICE_EXTENSION *pHwDevExt )
  90. {
  91. m_Next = NULL;
  92. m_EventType = WrapperEvent_UserData;
  93. m_pHwDevExt = pHwDevExt;
  94. }
  95. IMBoardListItem *CUserDataEvent::GetNext( void )
  96. {
  97. return( m_Next );
  98. }
  99. void CUserDataEvent::SetNext( IMBoardListItem *item )
  100. {
  101. m_Next = item;
  102. return;
  103. }
  104. HALEVENTTYPE CUserDataEvent::GetEventType( void )
  105. {
  106. return( m_EventType );
  107. }
  108. void CUserDataEvent::Advice( void *pData )
  109. {
  110. HW_DEVICE_EXTENSION *pHwDevExt;
  111. pHwDevExt = m_pHwDevExt;
  112. LONG cp;
  113. UCHAR field;
  114. CUserData *pUData;
  115. DWORD dwSizeUData;
  116. UCHAR ccbuff[ USCC_BuffSize ]; // tmp buff for USCC data
  117. PUCHAR pDest;
  118. // If FF or FR play mode now, no process for Closed Caption.
  119. if( pHwDevExt->Rate < 10000 )
  120. return;
  121. pUData = (CUserData *)pData; // pointer to user data
  122. dwSizeUData = pUData->GetDataSize();
  123. PHW_STREAM_REQUEST_BLOCK pSrb; // pointer to SRB included
  124. // SRB_READ_DATA for C.C.
  125. // Copy User Data to temp buffer.
  126. pUData->DataCopy( ccbuff, dwSizeUData );
  127. // Get SRB included SRB_READ_DATA.
  128. pSrb = pHwDevExt->ccque.get();
  129. cp = 0;
  130. if( pSrb!=NULL ){
  131. if( pSrb->CommandData.DataBufferArray->FrameExtent < sizeof( KSGOP_USERDATA ) ){
  132. pSrb->Status = STATUS_INVALID_BUFFER_SIZE;
  133. pSrb->ActualBytesTransferred = 0;
  134. StreamClassStreamNotification( StreamRequestComplete,
  135. pSrb->StreamObject,
  136. pSrb );
  137. return;
  138. }
  139. pDest = (PUCHAR)(pSrb->CommandData.DataBufferArray->Data);
  140. *(PULONG)pDest = 0xB2010000; // user_data_start_code
  141. pDest += 4;
  142. *pDest++ = ccbuff[cp++]; // line21_indicator
  143. *pDest++ = ccbuff[cp++];
  144. *pDest++ = ccbuff[cp++]; // reserved
  145. *pDest++ = ccbuff[cp++];
  146. field = *pDest++ = ccbuff[cp++]; // top_field_flag_of_gop &
  147. field &= 0x3f; // number_of_displayed_field
  148. if( pSrb->CommandData.DataBufferArray->FrameExtent <
  149. (field-1)*3 + sizeof(KSGOP_USERDATA) ){
  150. pSrb->Status = STATUS_INVALID_BUFFER_SIZE;
  151. pSrb->ActualBytesTransferred = 0;
  152. StreamClassStreamNotification( StreamRequestComplete,
  153. pSrb->StreamObject,
  154. pSrb );
  155. return;
  156. }
  157. pSrb->CommandData.DataBufferArray->DataUsed =
  158. pSrb->ActualBytesTransferred =
  159. (field-1)*3 + sizeof(KSGOP_USERDATA);
  160. //
  161. // copy line21_data()
  162. //
  163. for( ;field ; field-- ){
  164. *pDest++ = ccbuff[cp++]; // marker_bits & line21_switch
  165. *pDest++ = ccbuff[cp++]; // line21_data1
  166. *pDest++ = ccbuff[cp++]; // line21_data2
  167. }
  168. PKSSTREAM_HEADER pPacket;
  169. pPacket = pSrb->CommandData.DataBufferArray;
  170. pPacket->OptionsFlags = KSSTREAM_HEADER_OPTIONSF_TIMEVALID |
  171. KSSTREAM_HEADER_OPTIONSF_DURATIONVALID;
  172. pSrb->NumberOfBuffers = 1;
  173. pPacket->PresentationTime.Time = pHwDevExt->ticktime.GetStreamTime();
  174. pPacket->Duration = 1000;
  175. pSrb->Status = STATUS_SUCCESS;
  176. StreamClassStreamNotification( StreamRequestComplete,
  177. pSrb->StreamObject,
  178. pSrb );
  179. }
  180. return;
  181. }
  182. ////////////////////////////////////////////////////////////////////////////
  183. //
  184. ////////////////////////////////////////////////////////////////////////////
  185. void CVSyncEvent::Init( HW_DEVICE_EXTENSION *pHwDevExt )
  186. {
  187. m_Next = NULL;
  188. m_EventType = WrapperEvent_VSync;
  189. m_pHwDevExt = pHwDevExt;
  190. m_Vcount = 0;
  191. }
  192. IMBoardListItem *CVSyncEvent::GetNext( void )
  193. {
  194. return( m_Next );
  195. }
  196. void CVSyncEvent::SetNext( IMBoardListItem *item )
  197. {
  198. m_Next = item;
  199. return;
  200. }
  201. HALEVENTTYPE CVSyncEvent::GetEventType( void )
  202. {
  203. return( m_EventType );
  204. }
  205. void CVSyncEvent::Advice( void *pData )
  206. {
  207. HW_DEVICE_EXTENSION *pHwDevExt;
  208. pHwDevExt = m_pHwDevExt;
  209. PKSEVENT_ENTRY pEvent, pLast;
  210. PMYTIME pTim;
  211. LONGLONG MinIntTime;
  212. LONGLONG strmTime;
  213. ULONGLONG sysTime;
  214. // do this process every 5 Vsyncs.
  215. if( m_Vcount<=5 ){
  216. m_Vcount++;
  217. return;
  218. }
  219. m_Vcount = 0;
  220. sysTime = pHwDevExt->ticktime.GetSystemTime();
  221. if( !pHwDevExt || !pHwDevExt->pstroAud || !pHwDevExt->pstroSP ){
  222. return;
  223. }
  224. strmTime = pHwDevExt->ticktime.GetStreamTime();
  225. //
  226. // loop through all time_mark events
  227. //
  228. pEvent = NULL;
  229. pLast = NULL;
  230. while((pEvent = StreamClassGetNextEvent( pHwDevExt,
  231. pHwDevExt->pstroAud,
  232. (GUID *)&KSEVENTSETID_Clock,
  233. KSEVENT_CLOCK_POSITION_MARK,
  234. pLast)) != NULL )
  235. {
  236. if( ((PKSEVENT_TIME_MARK)(pEvent+1))->MarkTime <= strmTime ){
  237. //
  238. // signal the event here
  239. //
  240. StreamClassStreamNotification( SignalStreamEvent,
  241. pHwDevExt->pstroAud,
  242. pEvent );
  243. }
  244. pLast = pEvent;
  245. }
  246. //
  247. // loop through all time_interval events
  248. //
  249. pEvent = NULL;
  250. pLast = NULL;
  251. while( (pEvent = StreamClassGetNextEvent( pHwDevExt,
  252. pHwDevExt->pstroAud,
  253. (GUID *)&KSEVENTSETID_Clock,
  254. KSEVENT_CLOCK_INTERVAL_MARK,
  255. pLast)) !=NULL )
  256. {
  257. //
  258. // check if this event has been used for this interval yet
  259. //
  260. pTim = ((PMYTIME)(pEvent + 1 ));
  261. if( pTim && pTim->tim.Interval ){
  262. if( pTim->tim.TimeBase <= strmTime){
  263. MinIntTime = (strmTime - pTim->tim.TimeBase)/pTim->tim.Interval;
  264. MinIntTime *= pTim->tim.Interval;
  265. MinIntTime += pTim->tim.TimeBase;
  266. if( MinIntTime > pTim->LastTime ){
  267. //
  268. // signal the event here
  269. //
  270. StreamClassStreamNotification( SignalStreamEvent,
  271. pHwDevExt->pstroAud,
  272. pEvent );
  273. pTim->LastTime = strmTime;
  274. }
  275. }
  276. }else{
  277. ;
  278. DBG_BREAK();
  279. }
  280. pLast = pEvent;
  281. }
  282. }