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.

5916 lines
160 KiB

  1. //***************************************************************************
  2. // Command process
  3. //
  4. //***************************************************************************
  5. extern "C" {
  6. #include <wdmwarn4.h>
  7. #include <strmini.h>
  8. #include <mmsystem.h>
  9. }
  10. #include "common.h"
  11. #include "regs.h"
  12. #include "cdack.h"
  13. #include "cvdec.h"
  14. #include "cvpro.h"
  15. #include "cadec.h"
  16. #include "ccpgd.h"
  17. #include "dvdcmd.h"
  18. #include "strmid.h"
  19. extern "C" {
  20. //#include "dxapi.h"
  21. #include "ddkmapi.h"
  22. }
  23. extern void USCC_on( PHW_DEVICE_EXTENSION pHwDevExt );
  24. extern void USCC_discont( PHW_DEVICE_EXTENSION pHwDevExt );
  25. HANDLE hClk;
  26. HANDLE hMaster;
  27. BOOL fClkPause;
  28. ULONGLONG LastSysTime = 0;
  29. ULONGLONG PauseTime = 0;
  30. static ULONGLONG LastStamp;
  31. static ULONGLONG LastSys;
  32. static BOOLEAN fValid;
  33. extern BOOLEAN fProgrammed;
  34. extern BOOLEAN fStarted;
  35. BOOLEAN fProgrammed;
  36. BOOLEAN fStarted;
  37. static ULONGLONG StartSys;
  38. KSPIN_MEDIUM VPMedium = {
  39. STATIC_KSMEDIUMSETID_VPBus,
  40. 0,
  41. 0
  42. };
  43. /*
  44. ** AdapterCancelPacket()
  45. */
  46. extern "C" VOID STREAMAPI AdapterCancelPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  47. {
  48. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  49. DebugPrint(( DebugLevelVerbose, "TOSDVD:AdapterCancelPacket\r\n" ));
  50. DebugPrint(( DebugLevelVerbose, "TOSDVD: pSrb = 0x%x\r\n", pSrb ));
  51. if( pHwDevExt->pSrbDMA0 == pSrb ) {
  52. DebugPrint( (DebugLevelTrace, "TOSDVD: pSrb == pSrbDMA0\r\n" ) );
  53. pHwDevExt->pSrbDMA0 = NULL;
  54. pHwDevExt->fSrbDMA0last = FALSE;
  55. }
  56. if( pHwDevExt->pSrbDMA1 == pSrb ) {
  57. DebugPrint( (DebugLevelTrace, "TOSDVD: pSrb == pSrbDMA1\r\n" ) );
  58. pHwDevExt->pSrbDMA1 = NULL;
  59. pHwDevExt->fSrbDMA1last = FALSE;
  60. }
  61. pSrb->Status = STATUS_CANCELLED;
  62. switch (pSrb->Flags & (SRB_HW_FLAGS_DATA_TRANSFER |
  63. SRB_HW_FLAGS_STREAM_REQUEST)) {
  64. //
  65. // find all stream commands, and do stream notifications
  66. //
  67. case SRB_HW_FLAGS_STREAM_REQUEST | SRB_HW_FLAGS_DATA_TRANSFER:
  68. DebugPrint(( DebugLevelVerbose, "TOSDVD: SRB_HW_FLAGS_STREAM_REQUEST | SRB_HW_FLAGS_DATA_TRANSFER\r\n", pSrb ));
  69. // StreamClassStreamNotification( ReadyForNextStreamDataRequest,
  70. // pSrb->StreamObject);
  71. pHwDevExt->DevQue.remove( pSrb );
  72. pHwDevExt->CCQue.remove( pSrb );
  73. StreamClassStreamNotification( StreamRequestComplete,
  74. pSrb->StreamObject,
  75. pSrb);
  76. break;
  77. case SRB_HW_FLAGS_STREAM_REQUEST:
  78. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_HW_FLAGS_STREAM_REQUEST\r\n", pSrb ) );
  79. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  80. pSrb->StreamObject);
  81. StreamClassStreamNotification( StreamRequestComplete,
  82. pSrb->StreamObject,
  83. pSrb);
  84. break;
  85. default:
  86. DebugPrint( (DebugLevelTrace, "TOSDVD: default\r\n", pSrb ) );
  87. StreamClassDeviceNotification( ReadyForNextDeviceRequest,
  88. pSrb->HwDeviceExtension );
  89. StreamClassDeviceNotification( DeviceRequestComplete,
  90. pSrb->HwDeviceExtension,
  91. pSrb );
  92. break;
  93. }
  94. }
  95. /*
  96. ** AdapterTimeoutPacket()
  97. */
  98. extern "C" VOID STREAMAPI AdapterTimeoutPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  99. {
  100. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  101. DebugPrint( (DebugLevelTrace, "TOSDVD:AdapterTimeoutPacket\r\n") );
  102. if( pHwDevExt->PlayMode == PLAY_MODE_FREEZE ) {
  103. DebugPrint( (DebugLevelTrace, "TOSDVD: pause mode\r\n") );
  104. pSrb->TimeoutCounter = pSrb->TimeoutOriginal;
  105. return;
  106. }
  107. TRAP;
  108. // pSrb->TimeoutCounter = pSrb->TimeoutOriginal;
  109. if( pHwDevExt->pSrbDMA0 ) {
  110. DebugPrint(( DebugLevelTrace, "TOSDVD: pSrbDMA0 exist\r\n" ));
  111. pHwDevExt->pSrbDMA0 = NULL;
  112. pHwDevExt->fSrbDMA0last = FALSE;
  113. }
  114. if( pHwDevExt->pSrbDMA1 ) {
  115. DebugPrint(( DebugLevelTrace, "TOSDVD: pSrbDMA1 exist\r\n" ));
  116. pHwDevExt->pSrbDMA1 = NULL;
  117. pHwDevExt->fSrbDMA1last = FALSE;
  118. }
  119. if( pHwDevExt->pstroVid ) {
  120. StreamClassScheduleTimer(
  121. pHwDevExt->pstroVid,
  122. pHwDevExt,
  123. 0,
  124. NULL,
  125. pHwDevExt->pstroVid
  126. );
  127. }
  128. if( pHwDevExt->pstroAud ) {
  129. StreamClassScheduleTimer(
  130. pHwDevExt->pstroAud,
  131. pHwDevExt,
  132. 0,
  133. NULL,
  134. pHwDevExt->pstroAud
  135. );
  136. }
  137. if( pHwDevExt->pstroSP ) {
  138. StreamClassScheduleTimer(
  139. pHwDevExt->pstroSP,
  140. pHwDevExt,
  141. 0,
  142. NULL,
  143. pHwDevExt->pstroSP
  144. );
  145. }
  146. pHwDevExt->DevQue.init();
  147. pHwDevExt->CCQue.init();
  148. pHwDevExt->pSrbCpp = NULL;
  149. pHwDevExt->bDMAstop = FALSE;
  150. StreamClassAbortOutstandingRequests( pHwDevExt, NULL, STATUS_CANCELLED );
  151. }
  152. /*
  153. ** AdapterReceivePacket()
  154. */
  155. extern "C" VOID STREAMAPI AdapterReceivePacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  156. {
  157. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  158. // DWORD st, et;
  159. DebugPrint( (DebugLevelTrace, "TOSDVD:AdapterReceivePacket\r\n") );
  160. switch( pSrb->Command ){
  161. case SRB_GET_STREAM_INFO:
  162. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_GET_STREAM_INFO\r\n") );
  163. AdapterStreamInfo( pSrb );
  164. break;
  165. case SRB_OPEN_STREAM:
  166. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_OPEN_STREAM\r\n") );
  167. AdapterOpenStream( pSrb );
  168. break;
  169. case SRB_CLOSE_STREAM:
  170. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_CLOSE_STREAM\r\n") );
  171. AdapterCloseStream( pSrb );
  172. break;
  173. case SRB_INITIALIZE_DEVICE:
  174. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_INITIALIZE_DEVICE\r\n") );
  175. //
  176. // schedule a low priority callback to get the config
  177. // space. processing will continue when this runs.
  178. //
  179. StreamClassCallAtNewPriority(
  180. NULL,
  181. pSrb->HwDeviceExtension,
  182. Low,
  183. (PHW_PRIORITY_ROUTINE) GetPCIConfigSpace,
  184. pSrb
  185. );
  186. return;
  187. // st = GetCurrentTime_ms();
  188. //
  189. // HwInitialize( pSrb );
  190. //
  191. // et = GetCurrentTime_ms();
  192. // DebugPrint( (DebugLevelTrace, "TOSDVD:init %dms\r\n", et - st ) );
  193. //
  194. // break;
  195. case SRB_OPEN_DEVICE_INSTANCE:
  196. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_OPEN_DEVICE_INSTANCE\r\n") );
  197. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  198. break;
  199. case SRB_CLOSE_DEVICE_INSTANCE:
  200. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_CLOSE_DEVICE_INSTANCE\r\n") );
  201. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  202. break;
  203. case SRB_GET_DEVICE_PROPERTY:
  204. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_GET_DEVICE_PROPERTY\r\n") );
  205. TRAP;
  206. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  207. break;
  208. case SRB_SET_DEVICE_PROPERTY:
  209. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_DEVICE_PROPERTY\r\n") );
  210. TRAP;
  211. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  212. break;
  213. case SRB_CHANGE_POWER_STATE:
  214. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_CHANGE_POWER_STATE\r\n") );
  215. if (pSrb->CommandData.DeviceState == PowerDeviceD0) {
  216. //
  217. // bugbug - need to turn power back on here.
  218. //
  219. } else {
  220. //
  221. // bugbug - need to turn power off here, as well as
  222. // disabling interrupts.
  223. //
  224. decDisableInt( pHwDevExt );
  225. }
  226. pSrb->Status = STATUS_SUCCESS;
  227. break;
  228. case SRB_UNINITIALIZE_DEVICE:
  229. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_UNINITIALIZE_DEVICE\r\n") );
  230. decDisableInt( pHwDevExt );
  231. pSrb->Status = STATUS_SUCCESS;
  232. break;
  233. case SRB_UNKNOWN_DEVICE_COMMAND:
  234. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_UNKNOWN_DEVICE_COMMAND\r\n") );
  235. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  236. break;
  237. // case SRB_QUERY_UNLOAD:
  238. // DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_QUERY_UNLOAD\r\n") );
  239. // pSrb->Status = STATUS_NOT_IMPLEMENTED;
  240. // break;
  241. case SRB_PAGING_OUT_DRIVER:
  242. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_PAGING_OUT_DRIVER\r\n") );
  243. decDisableInt( pHwDevExt );
  244. pSrb->Status = STATUS_SUCCESS;
  245. break;
  246. case SRB_GET_DATA_INTERSECTION:
  247. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_GET_DATA_INTERSECTION\r\n") );
  248. HwProcessDataIntersection( pSrb );
  249. break;
  250. default:
  251. if( pSrb->Command == 0x10D ) {
  252. DebugPrint( (DebugLevelTrace, "TOSDVD: ---------------------------------------------\r\n" ) );
  253. DebugPrint( (DebugLevelTrace, "TOSDVD: -------- UNKNOWN SRB COMMAND (0x10D) --------\r\n" ) );
  254. DebugPrint( (DebugLevelTrace, "TOSDVD: ---------------------------------------------\r\n" ) );
  255. }
  256. else {
  257. DebugPrint( (DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->Command, pSrb->Command ) );
  258. TRAP;
  259. }
  260. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  261. }
  262. StreamClassDeviceNotification( ReadyForNextDeviceRequest,
  263. pSrb->HwDeviceExtension );
  264. StreamClassDeviceNotification( DeviceRequestComplete,
  265. pSrb->HwDeviceExtension,
  266. pSrb );
  267. }
  268. /*
  269. ** AdapterStreamInfo()
  270. */
  271. VOID AdapterStreamInfo( PHW_STREAM_REQUEST_BLOCK pSrb )
  272. {
  273. PHW_STREAM_INFORMATION pstrinfo =
  274. &(pSrb->CommandData.StreamBuffer->StreamInfo );
  275. // define the number of streams which this mini driver can support.
  276. pSrb->CommandData.StreamBuffer->StreamHeader.NumberOfStreams = STREAMNUM;
  277. pSrb->CommandData.StreamBuffer->StreamHeader.SizeOfHwStreamInformation =
  278. sizeof(HW_STREAM_INFORMATION);
  279. // store a pointer to the topology for the device
  280. pSrb->CommandData.StreamBuffer->StreamHeader.Topology = (KSTOPOLOGY *)&Topology;
  281. // pSrb->CommandData.StreamBuffer->StreamHeader.NumDevPropArrayEntries = 1;
  282. // pSrb->CommandData.StreamBuffer->StreamHeader.DevicePropertiesArray = devicePropSet;
  283. /* Video */
  284. pstrinfo->NumberOfPossibleInstances = 1;
  285. pstrinfo->DataFlow = KSPIN_DATAFLOW_IN;
  286. pstrinfo->DataAccessible = TRUE;
  287. pstrinfo->NumberOfFormatArrayEntries = 1;
  288. pstrinfo->StreamFormatsArray = Mpeg2VidInfo; // see strmid.h
  289. //--- 97.09.23 K.Chujo
  290. // pstrinfo->NumStreamPropArrayEntries = 2;
  291. pstrinfo->NumStreamPropArrayEntries = 3;
  292. //--- End.
  293. pstrinfo->StreamPropertiesArray = mpegVidPropSet; // see strmid.h
  294. pstrinfo++;
  295. /* Audio */
  296. pstrinfo->NumberOfPossibleInstances = 1;
  297. pstrinfo->DataFlow = KSPIN_DATAFLOW_IN;
  298. pstrinfo->DataAccessible = TRUE;
  299. pstrinfo->NumberOfFormatArrayEntries = 2;
  300. pstrinfo->StreamFormatsArray = AudioFormatBlocks;
  301. //--- 97.09.23 K.Chujo
  302. // pstrinfo->NumStreamPropArrayEntries = 2;
  303. pstrinfo->NumStreamPropArrayEntries = 3;
  304. //--- End.
  305. pstrinfo->StreamPropertiesArray = mpegAudioPropSet; // see strmid.h
  306. pstrinfo->StreamEventsArray = ClockEventSet;
  307. pstrinfo->NumStreamEventArrayEntries = SIZEOF_ARRAY(ClockEventSet);
  308. pstrinfo++;
  309. /* Sub-pic */
  310. pstrinfo->NumberOfPossibleInstances = 1;
  311. pstrinfo->DataFlow = KSPIN_DATAFLOW_IN;
  312. pstrinfo->DataAccessible = TRUE;
  313. pstrinfo->NumberOfFormatArrayEntries = 1;
  314. pstrinfo->StreamFormatsArray = Mpeg2SubpicInfo;
  315. //--- 97.09.23 K.Chujo
  316. // pstrinfo->NumStreamPropArrayEntries = 2;
  317. pstrinfo->NumStreamPropArrayEntries = 3;
  318. //--- End.
  319. pstrinfo->StreamPropertiesArray = SPPropSet;
  320. pstrinfo++;
  321. /* V-port */
  322. pstrinfo->NumberOfPossibleInstances = 1;
  323. pstrinfo->DataFlow = KSPIN_DATAFLOW_OUT;
  324. pstrinfo->DataAccessible = TRUE;
  325. pstrinfo->NumberOfFormatArrayEntries = 1;
  326. pstrinfo->StreamFormatsArray = VPEInfo;
  327. pstrinfo->NumStreamPropArrayEntries = 1;
  328. pstrinfo->StreamPropertiesArray = VideoPortPropSet;
  329. pstrinfo->MediumsCount = 1;
  330. pstrinfo->Mediums = &VPMedium;
  331. pstrinfo->StreamEventsArray = VPEventSet;
  332. pstrinfo->NumStreamEventArrayEntries = SIZEOF_ARRAY(VPEventSet);
  333. pstrinfo++;
  334. /* CC */
  335. pstrinfo->NumberOfPossibleInstances = 1;
  336. pstrinfo->DataFlow = KSPIN_DATAFLOW_OUT;
  337. pstrinfo->DataAccessible = TRUE;
  338. pstrinfo->NumberOfFormatArrayEntries = 1;
  339. pstrinfo->StreamFormatsArray = CCInfo;
  340. pstrinfo->NumStreamPropArrayEntries = 1;
  341. pstrinfo->StreamPropertiesArray = CCPropSet;
  342. pSrb->Status = STATUS_SUCCESS;
  343. }
  344. /*
  345. ** HwProcessDataIntersection()
  346. */
  347. VOID HwProcessDataIntersection( PHW_STREAM_REQUEST_BLOCK pSrb )
  348. {
  349. NTSTATUS Status = STATUS_SUCCESS;
  350. PSTREAM_DATA_INTERSECT_INFO IntersectInfo;
  351. PKSDATARANGE DataRange;
  352. PKSDATAFORMAT pFormat = NULL;
  353. ULONG formatSize;
  354. //
  355. // BUGBUG - this is a tempory implementation. We need to compare
  356. // the data types passed in and error if the ranges don't overlap.
  357. // we also need to return valid format blocks, not just the data range.
  358. //
  359. IntersectInfo = pSrb->CommandData.IntersectInfo;
  360. DataRange = IntersectInfo->DataRange;
  361. switch (IntersectInfo->StreamNumber) {
  362. case strmVideo:
  363. pFormat = &hwfmtiMpeg2Vid;
  364. formatSize = sizeof hwfmtiMpeg2Vid;
  365. break;
  366. case strmAudio:
  367. if (IsEqualGUID2(&(DataRange->SubFormat), &(Mpeg2AudioFormat.DataFormat.SubFormat))) {
  368. // DebugPrint( (DebugLevelError, "TOSDVD: AC3 Audio format query\r\n") );
  369. pFormat = (PKSDATAFORMAT) &Mpeg2AudioFormat;
  370. formatSize = sizeof (KSDATAFORMAT_WAVEFORMATEX);
  371. }
  372. else if (IsEqualGUID2(&(DataRange->SubFormat), &(LPCMAudioFormat.DataFormat.SubFormat))) {
  373. // DebugPrint( (DebugLevelError, "TOSDVD: LPCM Audio format query\r\n") );
  374. pFormat = (PKSDATAFORMAT) &LPCMAudioFormat;
  375. formatSize = sizeof (KSDATAFORMAT_WAVEFORMATEX);
  376. }
  377. else {
  378. // DebugPrint( (DebugLevelError, "TOSDVD: unknown Audio format query\r\n") );
  379. pFormat = NULL;
  380. formatSize = 0;
  381. }
  382. break;
  383. case strmSubpicture:
  384. pFormat = &hwfmtiMpeg2Subpic;
  385. formatSize = sizeof hwfmtiMpeg2Subpic;
  386. break;
  387. case strmYUVVideo:
  388. DebugPrint( (DebugLevelTrace, "TOSDVD: VPE\r\n") );
  389. pFormat = &hwfmtiVPEOut;
  390. formatSize = sizeof hwfmtiVPEOut;
  391. break;
  392. case strmCCOut:
  393. DebugPrint(( DebugLevelTrace, "TOSDVD: CC\r\n" ));
  394. pFormat = &hwfmtiCCOut;
  395. formatSize = sizeof hwfmtiCCOut;
  396. break;
  397. default:
  398. DebugPrint( (DebugLevelTrace, "TOSDVD: STATUS_NOT_IMPLEMENTED\r\n") );
  399. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  400. return;
  401. } // end streamnumber switch
  402. if (pFormat) {
  403. //
  404. // do a minimal compare of the dataranges to at least verify
  405. // that the guids are the same.
  406. // BUGBUG - this is woefully incomplete.
  407. //
  408. DataRange = IntersectInfo->DataRange;
  409. if (!(IsEqualGUID2(&DataRange->MajorFormat,
  410. &pFormat->MajorFormat) &&
  411. IsEqualGUID2(&DataRange->Specifier,
  412. &pFormat->Specifier))) {
  413. // if (IntersectInfo->StreamNumber == strmAudio)
  414. // DebugPrint( (DebugLevelError, "TOSDVD: Audio STATUS_NO_MATCH\r\n") );
  415. DebugPrint( (DebugLevelTrace, "TOSDVD: STATUS_NO_MATCH\r\n") );
  416. Status = STATUS_NO_MATCH;
  417. } else { // if guids are equal
  418. //
  419. // check to see if the size of the passed in buffer is a ULONG.
  420. // if so, this indicates that we are to return only the size
  421. // needed, and not return the actual data.
  422. //
  423. // if (IntersectInfo->StreamNumber == strmAudio)
  424. // DebugPrint( (DebugLevelError, "TOSDVD: Audio GUIDs are equal\r\n") );
  425. if (IntersectInfo->SizeOfDataFormatBuffer != sizeof(ULONG)) {
  426. //
  427. // we are to copy the data, not just return the size
  428. //
  429. if (IntersectInfo->SizeOfDataFormatBuffer < formatSize) {
  430. DebugPrint( (DebugLevelTrace, "TOSDVD: STATUS_BUFFER_TOO_SMALL\r\n") );
  431. Status = STATUS_BUFFER_TOO_SMALL;
  432. } else { // if too small
  433. RtlCopyMemory(IntersectInfo->DataFormatBuffer,
  434. pFormat,
  435. formatSize);
  436. pSrb->ActualBytesTransferred = formatSize;
  437. // if (IntersectInfo->StreamNumber == strmAudio)
  438. // DebugPrint( (DebugLevelError, "TOSDVD: Audio STATUS_SUCCESS\r\n") );
  439. DebugPrint( (DebugLevelTrace, "TOSDVD: STATUS_SUCCESS(data copy)\r\n") );
  440. Status = STATUS_SUCCESS;
  441. } // if too small
  442. } else { // if sizeof ULONG specified
  443. //
  444. // caller wants just the size of the buffer. Get that.
  445. //
  446. *(PULONG) IntersectInfo->DataFormatBuffer = formatSize;
  447. pSrb->ActualBytesTransferred = sizeof(ULONG);
  448. DebugPrint( (DebugLevelTrace, "TOSDVD: STATUS_SUCCESS(return size)\r\n") );
  449. } // if sizeof ULONG
  450. } // if guids are equal
  451. } else { // if pFormat
  452. DebugPrint( (DebugLevelTrace, "TOSDVD: STATUS_NOT_SUPPORTED\r\n") );
  453. Status = STATUS_NOT_SUPPORTED;
  454. } // if pFormat
  455. pSrb->Status = Status;
  456. return;
  457. }
  458. /*
  459. ** AdapterOpenStream()
  460. */
  461. VOID AdapterOpenStream( PHW_STREAM_REQUEST_BLOCK pSrb )
  462. {
  463. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  464. pSrb->Status = STATUS_SUCCESS;
  465. pHwDevExt->lCPPStrm = -1; // reset the copy protection stream number.
  466. ASSERT( pHwDevExt->CppFlagCount == 0 );
  467. ASSERT( pHwDevExt->pSrbCpp == NULL );
  468. ASSERT( pHwDevExt->bCppReset == FALSE );
  469. pHwDevExt->CppFlagCount = 0;
  470. pHwDevExt->pSrbCpp = NULL;
  471. pHwDevExt->bCppReset = FALSE;
  472. switch( pSrb->StreamObject->StreamNumber ){
  473. case strmVideo:
  474. DebugPrint( (DebugLevelTrace, "TOSDVD: Video\r\n") );
  475. pSrb->StreamObject->ReceiveDataPacket =
  476. VideoReceiveDataPacket;
  477. pSrb->StreamObject->ReceiveControlPacket =
  478. VideoReceiveCtrlPacket;
  479. pHwDevExt->pstroVid = pSrb->StreamObject;
  480. ProcessVideoFormat( pSrb->CommandData.OpenFormat, pHwDevExt );
  481. pHwDevExt->DevQue.init();
  482. SetVideoRateDefault( pHwDevExt );
  483. // If you would like to take out of previous picture,
  484. // insert codes here to reset and initialize MPEG Decoder Chip.
  485. pHwDevExt->cOpenInputStream++;
  486. pHwDevExt->DAck.PCIF_VSYNC_ON();
  487. USCC_on( pHwDevExt );
  488. break;
  489. case strmAudio:
  490. DebugPrint( (DebugLevelTrace, "TOSDVD: Audio\r\n") );
  491. pSrb->StreamObject->ReceiveDataPacket =
  492. AudioReceiveDataPacket;
  493. pSrb->StreamObject->ReceiveControlPacket =
  494. AudioReceiveCtrlPacket;
  495. pSrb->StreamObject->HwClockObject.HwClockFunction = StreamClockRtn;
  496. pSrb->StreamObject->HwClockObject.ClockSupportFlags =
  497. CLOCK_SUPPORT_CAN_SET_ONBOARD_CLOCK | CLOCK_SUPPORT_CAN_READ_ONBOARD_CLOCK |
  498. CLOCK_SUPPORT_CAN_RETURN_STREAM_TIME;
  499. pHwDevExt->pstroAud = pSrb->StreamObject;
  500. ProcessAudioFormat( pSrb->CommandData.OpenFormat, pHwDevExt );
  501. pSrb->StreamObject->HwEventRoutine = (PHW_EVENT_ROUTINE) AudioEvent;
  502. fStarted = fProgrammed = FALSE;
  503. SetAudioRateDefault( pHwDevExt );
  504. pHwDevExt->cOpenInputStream++;
  505. break;
  506. case strmSubpicture:
  507. DebugPrint( (DebugLevelTrace, "TOSDVD: Subpic\r\n") );
  508. pSrb->StreamObject->ReceiveDataPacket =
  509. SubpicReceiveDataPacket;
  510. pSrb->StreamObject->ReceiveControlPacket =
  511. SubpicReceiveCtrlPacket;
  512. pHwDevExt->pstroSP = pSrb->StreamObject;
  513. SetSubpicRateDefault( pHwDevExt );
  514. pHwDevExt->cOpenInputStream++;
  515. break;
  516. case strmYUVVideo:
  517. DebugPrint( (DebugLevelTrace, "TOSDVD: VPE\r\n") );
  518. pSrb->StreamObject->ReceiveDataPacket =
  519. VpeReceiveDataPacket;
  520. pSrb->StreamObject->ReceiveControlPacket =
  521. VpeReceiveCtrlPacket;
  522. pHwDevExt->pstroYUV = pSrb->StreamObject;
  523. pSrb->StreamObject->HwEventRoutine = (PHW_EVENT_ROUTINE) CycEvent;
  524. break;
  525. case strmCCOut:
  526. DebugPrint(( DebugLevelTrace, "TOSDVD: CC\r\n" ));
  527. pSrb->StreamObject->ReceiveDataPacket =
  528. CCReceiveDataPacket;
  529. pSrb->StreamObject->ReceiveControlPacket =
  530. CCReceiveCtrlPacket;
  531. pHwDevExt->pstroCC = pSrb->StreamObject;
  532. pHwDevExt->CCQue.init();
  533. break;
  534. default:
  535. DebugPrint( (DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->StreamObject->StreamNumber, pSrb->StreamObject->StreamNumber ) );
  536. TRAP;
  537. break;
  538. }
  539. pSrb->StreamObject->Dma = TRUE;
  540. pSrb->StreamObject->Pio = TRUE; // Need Pio = TRUE for access on CPU
  541. }
  542. /*
  543. ** AdapterCloseStream()
  544. */
  545. VOID AdapterCloseStream( PHW_STREAM_REQUEST_BLOCK pSrb )
  546. {
  547. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  548. pSrb->Status = STATUS_SUCCESS;
  549. switch ( pSrb->StreamObject->StreamNumber ) {
  550. case strmVideo:
  551. DebugPrint(( DebugLevelTrace, "TOSDVD: Video\r\n" ));
  552. pHwDevExt->pstroVid = NULL;
  553. pHwDevExt->cOpenInputStream--;
  554. // Temporary ??
  555. pHwDevExt->XferStartCount = 0;
  556. pHwDevExt->DecodeStart = FALSE;
  557. pHwDevExt->SendFirst = FALSE;
  558. break;
  559. case strmAudio:
  560. DebugPrint(( DebugLevelTrace, "TOSDVD: Audio\r\n" ));
  561. pHwDevExt->pstroAud = NULL;
  562. pHwDevExt->cOpenInputStream--;
  563. break;
  564. case strmSubpicture:
  565. DebugPrint(( DebugLevelTrace, "TOSDVD: Subpic\r\n" ));
  566. pHwDevExt->pstroSP = NULL;
  567. pHwDevExt->cOpenInputStream--;
  568. break;
  569. case strmYUVVideo:
  570. DebugPrint(( DebugLevelTrace, "TOSDVD: VPE\r\n" ));
  571. pHwDevExt->pstroYUV = NULL;
  572. pHwDevExt->VideoPort = 0; // Disable
  573. pHwDevExt->DAck.PCIF_SET_DIGITAL_OUT( pHwDevExt->VideoPort );
  574. break;
  575. case strmCCOut:
  576. DebugPrint(( DebugLevelTrace, "TOSDVD: CC\r\n" ));
  577. pHwDevExt->pstroCC = NULL;
  578. // PHW_STREAM_REQUEST_BLOCK pSrbTmp;
  579. // for( ; ; ) {
  580. // pSrbTmp = pHwDevExt->CCQue.get();
  581. // if( pSrbTmp == NULL )
  582. // break;
  583. // pSrbTmp->Status = STATUS_SUCCESS;
  584. //
  585. // DebugPrint(( DebugLevelTrace, "TOSDVD: CC pSrb = 0x%x\r\n", pSrbTmp ));
  586. //
  587. // StreamClassStreamNotification( StreamRequestComplete,
  588. // pSrbTmp->StreamObject,
  589. // pSrbTmp );
  590. // }
  591. break;
  592. default:
  593. DebugPrint( (DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->StreamObject->StreamNumber, pSrb->StreamObject->StreamNumber ) );
  594. TRAP;
  595. break;
  596. }
  597. }
  598. /*
  599. ** ClockEvents ()
  600. **
  601. ** handle any time event mark events
  602. **
  603. ** Arguments:
  604. **
  605. **
  606. **
  607. ** Returns:
  608. **
  609. ** Side Effects:
  610. */
  611. void ClockEvents( PHW_DEVICE_EXTENSION pHwDevExt )
  612. {
  613. PKSEVENT_ENTRY pEvent, pLast;
  614. PMYTIME pTim;
  615. LONGLONG MinIntTime;
  616. LONGLONG strmTime;
  617. if( !pHwDevExt || !pHwDevExt->pstroAud )
  618. return;
  619. // BUGBUG
  620. if( !pHwDevExt->pstroSP )
  621. return;
  622. strmTime = LastStamp + ( GetSystemTime() - LastSys );
  623. //
  624. // loop through all time_mark events
  625. //
  626. pEvent = NULL;
  627. pLast = NULL;
  628. while(( pEvent = StreamClassGetNextEvent(
  629. pHwDevExt,
  630. pHwDevExt->pstroAud,
  631. (GUID *)&KSEVENTSETID_Clock,
  632. KSEVENT_CLOCK_POSITION_MARK,
  633. pLast )) != NULL )
  634. {
  635. DebugPrint((
  636. DebugLevelTrace,
  637. "TOSDVD:ClockEvent(1) 0x%s, 0x%s\r\n",
  638. DebugLLConvtoStr( ((PKSEVENT_TIME_MARK)(pEvent +1))->MarkTime, 16 ),
  639. DebugLLConvtoStr( strmTime, 16 )
  640. ));
  641. //c DebugPrint(( DebugLevelTrace, "TOSDVD: strmTime 0x%x\r\n", strmTime ));
  642. //c DebugPrint(( DebugLevelTrace, "TOSDVD: LastStamp 0x%x\r\n", LastStamp ));
  643. //c DebugPrint(( DebugLevelTrace, "TOSDVD: GetSystemTime() 0x%x\r\n", GetSystemTime() ));
  644. //c DebugPrint(( DebugLevelTrace, "TOSDVD: LastSys 0x%x\r\n", LastSys ));
  645. // TRAP;
  646. if (((PKSEVENT_TIME_MARK)(pEvent +1))->MarkTime <= strmTime ) {
  647. DebugPrint(( DebugLevelTrace, "TOSDVD: Notify\r\n" ));
  648. // TRAP;
  649. //
  650. // signal the event here
  651. //
  652. StreamClassStreamNotification(
  653. SignalStreamEvent,
  654. pHwDevExt->pstroAud,
  655. pEvent
  656. );
  657. }
  658. pLast = pEvent;
  659. }
  660. //
  661. // loop through all time_interval events
  662. //
  663. pEvent = NULL;
  664. pLast = NULL;
  665. while(( pEvent = StreamClassGetNextEvent(
  666. pHwDevExt,
  667. pHwDevExt->pstroAud,
  668. (GUID *)&KSEVENTSETID_Clock,
  669. KSEVENT_CLOCK_INTERVAL_MARK,
  670. pLast )) != NULL )
  671. {
  672. //
  673. // check if this event has been used for this interval yet
  674. //
  675. pTim = ((PMYTIME)(pEvent + 1));
  676. DebugPrint((
  677. DebugLevelTrace,
  678. "TOSDVD:ClockEvent(2) strmTime 0x%s\r\n",
  679. DebugLLConvtoStr( strmTime, 16 )
  680. ));
  681. DebugPrint((
  682. DebugLevelTrace,
  683. "TOSDVD: Interval 0x%s\r\n",
  684. DebugLLConvtoStr( pTim->tim.Interval, 16 )
  685. ));
  686. DebugPrint((
  687. DebugLevelTrace,
  688. "TOSDVD: TimeBase 0x%s\r\n",
  689. DebugLLConvtoStr( pTim->tim.TimeBase, 16 )
  690. ));
  691. if (pTim && pTim->tim.Interval)
  692. {
  693. if (pTim->tim.TimeBase <= strmTime)
  694. {
  695. MinIntTime = (strmTime - pTim->tim.TimeBase) / pTim->tim.Interval;
  696. MinIntTime *= pTim->tim.Interval;
  697. MinIntTime += pTim->tim.TimeBase;
  698. DebugPrint((
  699. DebugLevelTrace,
  700. "TOSDVD: MinIntTime 0x%s\r\n",
  701. DebugLLConvtoStr( MinIntTime, 16 )
  702. ));
  703. DebugPrint((
  704. DebugLevelTrace,
  705. "TOSDVD: LastTime 0x%s\r\n",
  706. DebugLLConvtoStr( pTim->LastTime, 16 )
  707. ));
  708. if (MinIntTime > pTim->LastTime )
  709. {
  710. DebugPrint(( DebugLevelTrace, "TOSDVD: Notify\r\n" ));
  711. TRAP;
  712. //
  713. // signal the event here
  714. //
  715. StreamClassStreamNotification(
  716. SignalStreamEvent,
  717. pHwDevExt->pstroAud,
  718. pEvent
  719. );
  720. pTim->LastTime = strmTime;
  721. }
  722. }
  723. }
  724. else
  725. {
  726. DebugPrint(( DebugLevelTrace, "TOSDVD:ClockEvent(?)\r\n" ));
  727. TRAP;
  728. }
  729. pLast = pEvent;
  730. }
  731. }
  732. /*
  733. ** AudioEvent ()
  734. **
  735. ** receives notification for audio clock enable / disable events
  736. **
  737. ** Arguments:
  738. **
  739. **
  740. **
  741. ** Returns:
  742. **
  743. ** Side Effects:
  744. */
  745. NTSTATUS STREAMAPI AudioEvent( PHW_EVENT_DESCRIPTOR pEvent )
  746. {
  747. PUCHAR pCopy = (PUCHAR)( pEvent->EventEntry + 1 );
  748. PMYTIME pmyt = (PMYTIME)pCopy;
  749. PUCHAR pSrc = (PUCHAR)pEvent->EventData;
  750. ULONG cCopy;
  751. DebugPrint(( DebugLevelVerbose, "TOSDVD:AudioEvent\r\n" ));
  752. if( pEvent->Enable ) {
  753. switch( pEvent->EventEntry->EventItem->EventId ) {
  754. case KSEVENT_CLOCK_POSITION_MARK:
  755. cCopy = sizeof( KSEVENT_TIME_MARK );
  756. break;
  757. case KSEVENT_CLOCK_INTERVAL_MARK:
  758. cCopy = sizeof( KSEVENT_TIME_INTERVAL );
  759. break;
  760. default:
  761. TRAP;
  762. return( STATUS_NOT_IMPLEMENTED );
  763. }
  764. if( pEvent->EventEntry->EventItem->DataInput != cCopy ) {
  765. TRAP;
  766. return( STATUS_INVALID_BUFFER_SIZE );
  767. }
  768. //
  769. // copy the input buffer
  770. //
  771. for( ; cCopy > 0; cCopy-- ) {
  772. *pCopy++ = *pSrc++;
  773. }
  774. if( pEvent->EventEntry->EventItem->EventId == KSEVENT_CLOCK_INTERVAL_MARK) {
  775. pmyt->LastTime = 0;
  776. }
  777. }
  778. return( STATUS_SUCCESS );
  779. }
  780. /*
  781. ** CycEvent ()
  782. **
  783. ** receives notification for stream event enable/ disable
  784. **
  785. ** Arguments:}
  786. **
  787. **
  788. **
  789. ** Returns:
  790. **
  791. ** Side Effects:
  792. */
  793. NTSTATUS STREAMAPI CycEvent( PHW_EVENT_DESCRIPTOR pEvent )
  794. {
  795. PSTREAMEX pstrm = (PSTREAMEX)( pEvent->StreamObject->HwStreamExtension );
  796. DebugPrint( (DebugLevelTrace, "TOSDVD:CycEvent\r\n") );
  797. if( pEvent->Enable ) {
  798. pstrm->EventCount++;
  799. }
  800. else {
  801. pstrm->EventCount--;
  802. }
  803. return( STATUS_SUCCESS );
  804. }
  805. /*
  806. ** VideoReceiveDataPacket()
  807. */
  808. extern "C" VOID STREAMAPI VideoReceiveDataPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  809. {
  810. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  811. // PULONG pCount = &(pHwDevExt->XferStartCount);
  812. DebugPrint( (DebugLevelVerbose, "TOSDVD:VideoReceiveDataPacket---------\r\n") );
  813. switch( pSrb->Command ){
  814. case SRB_WRITE_DATA:
  815. DebugPrint( (DebugLevelVerbose, "TOSDVD: SRB_WRITE_DATA\r\n") );
  816. { // Temporary
  817. ULONG i;
  818. PKSSTREAM_HEADER pStruc;
  819. for( i = 0; i < pSrb->NumberOfBuffers; i++ ) {
  820. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[i];
  821. if( !( pStruc->OptionsFlags & (KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY |
  822. KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY |
  823. KSSTREAM_HEADER_OPTIONSF_TYPECHANGED ))) {
  824. // DebugPrint(( DebugLevelTrace, "TOSDVD: *** Video # 0x%x\r\n",
  825. // pStruc->xHdr.MediaSpecificFlags >> 16 ));
  826. }
  827. if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY ) {
  828. DebugPrint(( DebugLevelTrace, "TOSDVD: DATADISCONTINUITY(Video)\r\n" ));
  829. VideoDataDiscontinuity( pHwDevExt );
  830. pHwDevExt->bStopCC = TRUE;
  831. USCC_discont( pHwDevExt );
  832. }
  833. if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY ) {
  834. DebugPrint(( DebugLevelTrace, "TOSDVD: TIMEDISCONTINUITY(Video)\r\n" ));
  835. //--- 97.09.08 K.Chujo
  836. pHwDevExt->TimeDiscontFlagCount++;
  837. DebugPrint(( DebugLevelTrace, "TOSDVD: TimeDiscontFlagCount=%ld\r\n", pHwDevExt->TimeDiscontFlagCount ));
  838. if( pHwDevExt->TimeDiscontFlagCount >= pHwDevExt->cOpenInputStream ) {
  839. //--- 97.09.10 K.Chujo
  840. // old
  841. // DecodeStart(pHwDevExt, pHwDevExt->dwSTCInit);
  842. // new
  843. StreamClassScheduleTimer(
  844. NULL,
  845. pHwDevExt,
  846. 1,
  847. (PHW_TIMER_ROUTINE)MenuDecodeStart, // 97.09.14 rename
  848. pHwDevExt
  849. );
  850. //--- End.
  851. }
  852. //--- End.
  853. }
  854. if( pStruc->TypeSpecificFlags & KS_AM_UseNewCSSKey ) {
  855. pHwDevExt->CppFlagCount++;
  856. DebugPrint(( DebugLevelTrace, "TOSDVD: CppFlagCount=%ld\r\n", pHwDevExt->CppFlagCount ));
  857. if( pHwDevExt->CppFlagCount >= pHwDevExt->cOpenInputStream + 1 )
  858. SetCppFlag( pHwDevExt );
  859. }
  860. }
  861. for( i = 0; i < pSrb->NumberOfBuffers; i++ ) {
  862. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[i];
  863. DebugPrint( (DebugLevelVerbose, "TOSDVD: VideoPacet Flag = 0x%x\r\n", pStruc->OptionsFlags ));
  864. if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TYPECHANGED ) {
  865. DebugPrint(( DebugLevelTrace, "TOSDVD:TYPECHANGE(Video)\r\n" ));
  866. if( pStruc->DataUsed >= sizeof(KSDATAFORMAT) + sizeof(KS_MPEGVIDEOINFO2) ) {
  867. ProcessVideoFormat( (PKSDATAFORMAT)pStruc->Data, pHwDevExt );
  868. }
  869. else {
  870. TRAP;
  871. }
  872. i = pSrb->NumberOfBuffers;
  873. break;
  874. }
  875. if( pStruc->DataUsed )
  876. break;
  877. }
  878. if( i == pSrb->NumberOfBuffers ) {
  879. pSrb->Status = STATUS_SUCCESS;
  880. break;
  881. }
  882. }
  883. // DebugDumpKSTIME( pSrb );
  884. // for Debug
  885. // if( pHwDevExt->Rate < 10000 ) {
  886. // DebugPrint( (DebugLevelTrace, "TOSDVD: Change PTS for F.F. (Video)\r\n" ) );
  887. // }
  888. // end
  889. //--- 97.09.25 K.Chujo
  890. FastSlowControl( pSrb );
  891. //--- End.
  892. if( pHwDevExt->bVideoQueue == TRUE ) {
  893. pHwDevExt->bStopCC = FALSE;
  894. pHwDevExt->DevQue.put_video( pSrb );
  895. }
  896. else {
  897. pSrb->Status = STATUS_SUCCESS;
  898. DebugPrint( (DebugLevelTrace, "TOSDVD: VideoData was Discarded\r\n" ) );
  899. break;
  900. }
  901. // if( *pCount <= 24 )
  902. // (*pCount)++;
  903. // if( *pCount == 24 )
  904. // DMAxfer( pHwDevExt, 0x03 );
  905. // else if( (*pCount) == 25 ) {
  906. if( pHwDevExt->pSrbDMA0 == NULL && pHwDevExt->pSrbDMA1 == NULL )
  907. PreDMAxfer( pHwDevExt/*, 0x03 */);
  908. // }
  909. // for Debug
  910. // if( pHwDevExt->Rate < 10000 ) {
  911. // DebugPrint( (DebugLevelTrace, "TOSDVD: ReadyForNextStreamDataRequest(Video)\r\n" ) );
  912. // }
  913. // end
  914. StreamClassStreamNotification( ReadyForNextStreamDataRequest,
  915. pSrb->StreamObject );
  916. return;
  917. default:
  918. DebugPrint( (DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->Command, pSrb->Command ) );
  919. TRAP;
  920. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  921. break;
  922. }
  923. DebugPrint(( DebugLevelTrace, "TOSDVD:---------VideoReceiveDataPacket( SRB has no data)\r\n" ));
  924. StreamClassStreamNotification( ReadyForNextStreamDataRequest,
  925. pSrb->StreamObject );
  926. StreamClassStreamNotification( StreamRequestComplete,
  927. pSrb->StreamObject,
  928. pSrb );
  929. }
  930. /*
  931. ** VideoReceiveCtrlPacket()
  932. */
  933. extern "C" VOID STREAMAPI VideoReceiveCtrlPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  934. {
  935. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  936. DebugPrint( (DebugLevelTrace, "TOSDVD:VideoReceiveCtrlPacket---------\r\n") );
  937. switch( pSrb->Command ){
  938. case SRB_SET_STREAM_STATE:
  939. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_STATE\r\n") );
  940. switch( pSrb->CommandData.StreamState ) {
  941. case KSSTATE_STOP:
  942. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_STOP\r\n") );
  943. StopData( pHwDevExt );
  944. SetVideoRateDefault( pHwDevExt );
  945. pHwDevExt->bVideoQueue = FALSE;
  946. pHwDevExt->bAudioQueue = FALSE;
  947. pHwDevExt->bSubpicQueue = FALSE;
  948. break;
  949. case KSSTATE_PAUSE:
  950. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_PAUSE\r\n") );
  951. PauseTime = GetSystemTime();
  952. if( !fStarted ) {
  953. fStarted = TRUE;
  954. LastStamp = 0;
  955. StartSys = LastSysTime = PauseTime;
  956. }
  957. fClkPause = TRUE;
  958. SetPlayMode( pHwDevExt, PLAY_MODE_FREEZE );
  959. break;
  960. case KSSTATE_RUN:
  961. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_RUN\r\n") );
  962. if( !fStarted && !fProgrammed ) {
  963. LastStamp = 0;
  964. StartSys = LastSysTime = GetSystemTime();
  965. }
  966. fStarted = TRUE;
  967. fClkPause = FALSE;
  968. SetPlayMode( pHwDevExt, pHwDevExt->RunMode );
  969. break;
  970. }
  971. pSrb->Status = STATUS_SUCCESS;
  972. break;
  973. case SRB_GET_STREAM_STATE:
  974. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_GET_STREAM_STATE\r\n") );
  975. pSrb->Status = STATUS_SUCCESS;
  976. break;
  977. case SRB_GET_STREAM_PROPERTY:
  978. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_GET_STREAM_PROPERTY\r\n") );
  979. GetVideoProperty( pSrb );
  980. if( pSrb->Status != STATUS_PENDING ) {
  981. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  982. pSrb->StreamObject );
  983. StreamClassStreamNotification( StreamRequestComplete,
  984. pSrb->StreamObject,
  985. pSrb );
  986. }
  987. return;
  988. case SRB_SET_STREAM_PROPERTY:
  989. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_PROPERTY\r\n") );
  990. SetVideoProperty( pSrb );
  991. if( pSrb->Status != STATUS_PENDING ) {
  992. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  993. pSrb->StreamObject );
  994. StreamClassStreamNotification( StreamRequestComplete,
  995. pSrb->StreamObject,
  996. pSrb );
  997. }
  998. return;
  999. case SRB_OPEN_MASTER_CLOCK:
  1000. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_OPEN_MASTER_CLOCK\r\n") );
  1001. hMaster = pSrb->CommandData.MasterClockHandle;
  1002. pSrb->Status = STATUS_SUCCESS;
  1003. break;
  1004. case SRB_CLOSE_MASTER_CLOCK:
  1005. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_CLOSE_MASTER_CLOCK\r\n") );
  1006. hMaster = pSrb->CommandData.MasterClockHandle;
  1007. pSrb->Status = STATUS_SUCCESS;
  1008. break;
  1009. case SRB_INDICATE_MASTER_CLOCK:
  1010. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_INDICATE_MASTER_CLOCK\r\n") );
  1011. hClk = pSrb->CommandData.MasterClockHandle;
  1012. pSrb->Status = STATUS_SUCCESS;
  1013. break;
  1014. case SRB_UNKNOWN_STREAM_COMMAND:
  1015. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_UNKNOWN_STREAM_COMMAND\r\n") );
  1016. TRAP;
  1017. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1018. break;
  1019. case SRB_SET_STREAM_RATE:
  1020. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_RATE\r\n") );
  1021. TRAP;
  1022. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1023. break;
  1024. case SRB_PROPOSE_DATA_FORMAT:
  1025. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_PROPOSE_DATA_FORMAT\r\n") );
  1026. VideoQueryAccept( pSrb );
  1027. break;
  1028. //--- 97.09.23 K.Chujo
  1029. case SRB_PROPOSE_STREAM_RATE:
  1030. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_PROPOSE_STREAM_RATE\r\n") );
  1031. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1032. // SetRateChange( pSrb );
  1033. break;
  1034. //--- End.
  1035. default:
  1036. DebugPrint( (DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->Command, pSrb->Command ) );
  1037. TRAP;
  1038. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1039. break;
  1040. }
  1041. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  1042. pSrb->StreamObject );
  1043. StreamClassStreamNotification( StreamRequestComplete,
  1044. pSrb->StreamObject,
  1045. pSrb );
  1046. }
  1047. /*
  1048. ** AudioReceiveDataPacket()
  1049. */
  1050. extern "C" VOID STREAMAPI AudioReceiveDataPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  1051. {
  1052. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  1053. DebugPrint( (DebugLevelVerbose, "TOSDVD:AudioReceiveDataPacket---------\r\n") );
  1054. switch( pSrb->Command ){
  1055. case SRB_WRITE_DATA:
  1056. DebugPrint( (DebugLevelVerbose, "TOSDVD: SRB_WRITE_DATA\r\n") );
  1057. { // Temporary
  1058. ULONG i;
  1059. PKSSTREAM_HEADER pStruc;
  1060. for( i = 0; i < pSrb->NumberOfBuffers; i++ ) {
  1061. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[i];
  1062. if( !( pStruc->OptionsFlags & (KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY |
  1063. KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY |
  1064. KSSTREAM_HEADER_OPTIONSF_TYPECHANGED ))) {
  1065. // DebugPrint(( DebugLevelTrace, "TOSDVD: *** Audio # 0x%x\r\n",
  1066. // pStruc->xHdr.MediaSpecificFlags >> 16 ));
  1067. }
  1068. if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY ) {
  1069. DebugPrint(( DebugLevelTrace, "TOSDVD: DATADISCONTINUITY(Audio)\r\n" ));
  1070. AudioDataDiscontinuity( pHwDevExt );
  1071. }
  1072. if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY ) {
  1073. DebugPrint(( DebugLevelTrace, "TOSDVD: TIMEDISCONTINUITY(Audio)\r\n" ));
  1074. //--- 97.09.08 K.Chujo
  1075. pHwDevExt->TimeDiscontFlagCount++;
  1076. DebugPrint(( DebugLevelTrace, "TOSDVD: TimeDiscontFlagCount=%ld\r\n", pHwDevExt->TimeDiscontFlagCount ));
  1077. if( pHwDevExt->TimeDiscontFlagCount >= pHwDevExt->cOpenInputStream ) {
  1078. //--- 97.09.10 K.Chujo
  1079. // old
  1080. // DecodeStart(pHwDevExt, pHwDevExt->dwSTCInit);
  1081. // new
  1082. StreamClassScheduleTimer(
  1083. NULL,
  1084. pHwDevExt,
  1085. 1,
  1086. (PHW_TIMER_ROUTINE)MenuDecodeStart, // 97.09.14 rename
  1087. pHwDevExt
  1088. );
  1089. //--- End.
  1090. }
  1091. //--- End.
  1092. }
  1093. if( pStruc->TypeSpecificFlags & KS_AM_UseNewCSSKey ) {
  1094. pHwDevExt->CppFlagCount++;
  1095. DebugPrint(( DebugLevelTrace, "TOSDVD: CppFlagCount=%ld\r\n", pHwDevExt->CppFlagCount ));
  1096. if( pHwDevExt->CppFlagCount >= pHwDevExt->cOpenInputStream + 1 )
  1097. SetCppFlag( pHwDevExt );
  1098. }
  1099. }
  1100. for( i = 0; i < pSrb->NumberOfBuffers; i++ ) {
  1101. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[i];
  1102. DebugPrint( (DebugLevelVerbose, "TOSDVD: AudioPacket Flag = 0x%x\r\n", pStruc->OptionsFlags ));
  1103. if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TYPECHANGED ) {
  1104. DebugPrint(( DebugLevelTrace, "TOSDVD:TYPECHANGE(Audio)\r\n" ));
  1105. // if( pStruc->DataUsed >= sizeof(KSDATAFORMAT) + sizeof(KS_MPEGVIDEOINFO2) ) {
  1106. if( pStruc->DataUsed ) {
  1107. ProcessAudioFormat( (PKSDATAFORMAT)pStruc->Data, pHwDevExt );
  1108. }
  1109. else {
  1110. TRAP;
  1111. }
  1112. i = pSrb->NumberOfBuffers;
  1113. break;
  1114. }
  1115. if( pStruc->DataUsed )
  1116. break;
  1117. }
  1118. if( i == pSrb->NumberOfBuffers ) {
  1119. pSrb->Status = STATUS_SUCCESS;
  1120. break;
  1121. }
  1122. }
  1123. // for Debug
  1124. // if( pHwDevExt->Rate < 10000 ) {
  1125. // DebugPrint( (DebugLevelTrace, "TOSDVD: Change PTS for F.F. (Audio)\r\n" ) );
  1126. // }
  1127. // end
  1128. //--- 97.09.25 K.Chujo
  1129. // FastSlowControl( pSrb );
  1130. //--- End.
  1131. if( pHwDevExt->bAudioQueue == TRUE ) {
  1132. pHwDevExt->DevQue.put_audio( pSrb );
  1133. }
  1134. else {
  1135. pSrb->Status = STATUS_SUCCESS;
  1136. DebugPrint( (DebugLevelTrace, "TOSDVD: AudioData was Discarded\r\n" ) );
  1137. break;
  1138. }
  1139. if( pHwDevExt->pSrbDMA0 == NULL && pHwDevExt->pSrbDMA1 == NULL )
  1140. PreDMAxfer( pHwDevExt/*, 0x03 */);
  1141. // for Debug
  1142. // if( pHwDevExt->Rate < 10000 ) {
  1143. // DebugPrint( (DebugLevelTrace, "TOSDVD: ReadyForNextStreamDataRequest(Audio)\r\n" ) );
  1144. // }
  1145. // end
  1146. StreamClassStreamNotification( ReadyForNextStreamDataRequest,
  1147. pSrb->StreamObject );
  1148. return;
  1149. default:
  1150. DebugPrint( (DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->Command, pSrb->Command ) );
  1151. TRAP;
  1152. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1153. break;
  1154. }
  1155. DebugPrint(( DebugLevelTrace, "TOSDVD:---------AudioReceiveDataPacket( SRB has no data)\r\n" ));
  1156. StreamClassStreamNotification( ReadyForNextStreamDataRequest,
  1157. pSrb->StreamObject );
  1158. StreamClassStreamNotification( StreamRequestComplete,
  1159. pSrb->StreamObject,
  1160. pSrb );
  1161. }
  1162. /*
  1163. ** AudioReceiveCtrlPacket()
  1164. */
  1165. extern "C" VOID STREAMAPI AudioReceiveCtrlPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  1166. {
  1167. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  1168. DebugPrint( (DebugLevelTrace, "TOSDVD:AudioReceiveCtrlPacket---------\r\n") );
  1169. switch( pSrb->Command ){
  1170. case SRB_SET_STREAM_STATE:
  1171. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_STATE\r\n") );
  1172. switch( pSrb->CommandData.StreamState ) {
  1173. case KSSTATE_STOP:
  1174. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_STOP\r\n") );
  1175. SetAudioRateDefault( pHwDevExt );
  1176. pHwDevExt->bAudioQueue = FALSE;
  1177. break;
  1178. case KSSTATE_PAUSE:
  1179. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_PAUSE\r\n") );
  1180. break;
  1181. case KSSTATE_RUN:
  1182. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_RUN\r\n") );
  1183. break;
  1184. }
  1185. pSrb->Status = STATUS_SUCCESS;
  1186. break;
  1187. case SRB_GET_STREAM_STATE:
  1188. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_GET_STREAM_STATE\r\n") );
  1189. pSrb->Status = STATUS_SUCCESS;
  1190. break;
  1191. case SRB_GET_STREAM_PROPERTY:
  1192. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_GET_STREAM_PROPERTY\r\n") );
  1193. GetAudioProperty( pSrb );
  1194. if( pSrb->Status != STATUS_PENDING ) {
  1195. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  1196. pSrb->StreamObject );
  1197. StreamClassStreamNotification( StreamRequestComplete,
  1198. pSrb->StreamObject,
  1199. pSrb );
  1200. }
  1201. return;
  1202. case SRB_SET_STREAM_PROPERTY:
  1203. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_PROPERTY\r\n") );
  1204. SetAudioProperty( pSrb );
  1205. if( pSrb->Status != STATUS_PENDING ) {
  1206. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  1207. pSrb->StreamObject );
  1208. StreamClassStreamNotification( StreamRequestComplete,
  1209. pSrb->StreamObject,
  1210. pSrb );
  1211. }
  1212. return;
  1213. case SRB_OPEN_MASTER_CLOCK:
  1214. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_OPEN_MASTER_CLOCK\r\n") );
  1215. hMaster = pSrb->CommandData.MasterClockHandle;
  1216. pSrb->Status = STATUS_SUCCESS;
  1217. break;
  1218. case SRB_CLOSE_MASTER_CLOCK:
  1219. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_CLOSE_MASTER_CLOCK\r\n") );
  1220. hMaster = pSrb->CommandData.MasterClockHandle;
  1221. pSrb->Status = STATUS_SUCCESS;
  1222. break;
  1223. case SRB_INDICATE_MASTER_CLOCK:
  1224. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_INDICATE_MASTER_CLOCK\r\n") );
  1225. hClk = pSrb->CommandData.MasterClockHandle;
  1226. pSrb->Status = STATUS_SUCCESS;
  1227. break;
  1228. case SRB_UNKNOWN_STREAM_COMMAND:
  1229. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_UNKNOWN_STREAM_COMMAND\r\n") );
  1230. TRAP;
  1231. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1232. break;
  1233. case SRB_SET_STREAM_RATE:
  1234. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_RATE\r\n") );
  1235. TRAP;
  1236. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1237. break;
  1238. case SRB_PROPOSE_DATA_FORMAT:
  1239. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_PROPOSE_DATA_FORMAT\r\n") );
  1240. AudioQueryAccept( pSrb );
  1241. break;
  1242. default:
  1243. DebugPrint( (DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->Command, pSrb->Command ) );
  1244. TRAP;
  1245. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1246. break;
  1247. }
  1248. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  1249. pSrb->StreamObject );
  1250. StreamClassStreamNotification( StreamRequestComplete,
  1251. pSrb->StreamObject,
  1252. pSrb );
  1253. }
  1254. /*
  1255. ** SubpicReceiveDataPacket()
  1256. */
  1257. extern "C" VOID STREAMAPI SubpicReceiveDataPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  1258. {
  1259. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  1260. DebugPrint( (DebugLevelVerbose, "TOSDVD:SubpicReceiveDataPacket---------\r\n") );
  1261. switch( pSrb->Command ){
  1262. case SRB_WRITE_DATA:
  1263. DebugPrint( (DebugLevelVerbose, "TOSDVD: SRB_WRITE_DATA\r\n") );
  1264. { // Temporary
  1265. ULONG i;
  1266. PKSSTREAM_HEADER pStruc;
  1267. for( i = 0; i < pSrb->NumberOfBuffers; i++ ) {
  1268. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[i];
  1269. if(!( pStruc->OptionsFlags & (KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY |
  1270. KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY |
  1271. KSSTREAM_HEADER_OPTIONSF_TYPECHANGED ))) {
  1272. // DebugPrint(( DebugLevelTrace, "TOSDVD: *** Subpic # 0x%x\r\n",
  1273. // pStruc->xHdr.MediaSpecificFlags >> 16 ));
  1274. }
  1275. if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_DATADISCONTINUITY ) {
  1276. DebugPrint(( DebugLevelTrace, "TOSDVD: DATADISCONTINUITY(Subpic)\r\n" ));
  1277. SubpicDataDiscontinuity( pHwDevExt );
  1278. }
  1279. if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TIMEDISCONTINUITY ) {
  1280. DebugPrint(( DebugLevelTrace, "TOSDVD: TIMEDISCONTINUITY(Subpic)\r\n" ));
  1281. //--- 97.09.08 K.Chujo
  1282. pHwDevExt->TimeDiscontFlagCount++;
  1283. DebugPrint(( DebugLevelTrace, "TOSDVD: TimeDiscontFlagCount=%ld\r\n", pHwDevExt->TimeDiscontFlagCount ));
  1284. if( pHwDevExt->TimeDiscontFlagCount >= pHwDevExt->cOpenInputStream ) {
  1285. //--- 97.09.10 K.Chujo
  1286. // old
  1287. // DecodeStart(pHwDevExt, pHwDevExt->dwSTCInit);
  1288. // new
  1289. StreamClassScheduleTimer(
  1290. NULL,
  1291. pHwDevExt,
  1292. 1,
  1293. (PHW_TIMER_ROUTINE)MenuDecodeStart, // 97.09.14 rename
  1294. pHwDevExt
  1295. );
  1296. //--- End.
  1297. }
  1298. //--- End.
  1299. }
  1300. if( pStruc->TypeSpecificFlags & KS_AM_UseNewCSSKey ) {
  1301. pHwDevExt->CppFlagCount++;
  1302. DebugPrint(( DebugLevelTrace, "TOSDVD: CppFlagCount=%ld\r\n", pHwDevExt->CppFlagCount ));
  1303. if( pHwDevExt->CppFlagCount >= pHwDevExt->cOpenInputStream + 1 )
  1304. SetCppFlag( pHwDevExt );
  1305. }
  1306. }
  1307. for( i = 0; i < pSrb->NumberOfBuffers; i++ ) {
  1308. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[i];
  1309. DebugPrint( (DebugLevelVerbose, "TOSDVD: SubPicPacket Flag = 0x%x\r\n", pStruc->OptionsFlags ));
  1310. if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TYPECHANGED ) {
  1311. DebugPrint(( DebugLevelTrace, "TOSDVD:TYPECHANGE(subpic)\r\n" ));
  1312. TRAP;
  1313. i = pSrb->NumberOfBuffers;
  1314. break;
  1315. }
  1316. if( pStruc->DataUsed )
  1317. break;
  1318. }
  1319. if( i == pSrb->NumberOfBuffers ) {
  1320. pSrb->Status = STATUS_SUCCESS;
  1321. break;
  1322. }
  1323. }
  1324. //--- 97.09.14 K.Chujo
  1325. {
  1326. ULONG i;
  1327. PKSSTREAM_HEADER pStruc;
  1328. // PUCHAR pDat;
  1329. // ULONG strID;
  1330. for ( i=0; i<pSrb->NumberOfBuffers; i++ ) {
  1331. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[i];
  1332. SetSubpicID( pHwDevExt, pStruc );
  1333. // pDat = (PUCHAR)pStruc->Data;
  1334. // strID = (ULONG)GetStreamID(pDat);
  1335. // if( (strID & 0xE0)==0x20 ) {
  1336. // if( pHwDevExt->VPro.SUBP_GET_SUBP_CH() != strID ) {
  1337. // SetSubpicID( pHwDevExt, strID );
  1338. // }
  1339. // }
  1340. }
  1341. }
  1342. //--- End.
  1343. // for Debug
  1344. // if( pHwDevExt->Rate < 10000 ) {
  1345. // DebugPrint( (DebugLevelTrace, "TOSDVD: Change PTS for F.F. (Subpic)\r\n" ) );
  1346. // }
  1347. // end
  1348. //--- 97.09.25 K.Chujo
  1349. // FastSlowControl( pSrb );
  1350. //--- End.
  1351. if( pHwDevExt->bSubpicQueue == TRUE ) {
  1352. pHwDevExt->DevQue.put_subpic( pSrb );
  1353. }
  1354. else {
  1355. pSrb->Status = STATUS_SUCCESS;
  1356. DebugPrint( (DebugLevelTrace, "TOSDVD: SubpicData was Discarded\r\n" ) );
  1357. break;
  1358. }
  1359. // if( pHwDevExt->pSrbDMA0 == NULL && pHwDevExt->pSrbDMA1 == NULL )
  1360. // PreDMAxfer( pHwDevExt/*, 0x03 */);
  1361. // for Debug
  1362. // if( pHwDevExt->Rate < 10000 ) {
  1363. // DebugPrint( (DebugLevelTrace, "TOSDVD: ReadyForNextStreamDataRequest(Subpic)\r\n" ) );
  1364. // }
  1365. // end
  1366. StreamClassStreamNotification( ReadyForNextStreamDataRequest,
  1367. pSrb->StreamObject );
  1368. return;
  1369. default:
  1370. DebugPrint( (DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->Command, pSrb->Command ) );
  1371. TRAP;
  1372. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1373. break;
  1374. }
  1375. DebugPrint(( DebugLevelTrace, "TOSDVD:---------SubpicReceiveDataPacket( SRB has no data)\r\n" ));
  1376. StreamClassStreamNotification( ReadyForNextStreamDataRequest,
  1377. pSrb->StreamObject );
  1378. StreamClassStreamNotification( StreamRequestComplete,
  1379. pSrb->StreamObject,
  1380. pSrb );
  1381. }
  1382. /*
  1383. ** SubpicReceiveCtrlPacket()
  1384. */
  1385. extern "C" VOID STREAMAPI SubpicReceiveCtrlPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  1386. {
  1387. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  1388. //h DebugPrint( (DebugLevelTrace, "TOSDVD:SubpicReceiveCtrlPacket---------\r\n") );
  1389. switch( pSrb->Command ){
  1390. case SRB_SET_STREAM_STATE:
  1391. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_STATE\r\n") );
  1392. switch( pSrb->CommandData.StreamState ) {
  1393. case KSSTATE_STOP:
  1394. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_STOP\r\n") );
  1395. SetSubpicRateDefault( pHwDevExt );
  1396. pHwDevExt->bSubpicQueue = FALSE;
  1397. break;
  1398. case KSSTATE_PAUSE:
  1399. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_PAUSE\r\n") );
  1400. break;
  1401. case KSSTATE_RUN:
  1402. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_RUN\r\n") );
  1403. break;
  1404. }
  1405. pSrb->Status = STATUS_SUCCESS;
  1406. break;
  1407. case SRB_GET_STREAM_STATE:
  1408. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_GET_STREAM_STATE\r\n") );
  1409. pSrb->Status = STATUS_SUCCESS;
  1410. break;
  1411. case SRB_GET_STREAM_PROPERTY:
  1412. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_GET_STREAM_PROPERTY\r\n") );
  1413. GetSubpicProperty( pSrb );
  1414. if( pSrb->Status != STATUS_PENDING ) {
  1415. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  1416. pSrb->StreamObject );
  1417. StreamClassStreamNotification( StreamRequestComplete,
  1418. pSrb->StreamObject,
  1419. pSrb );
  1420. }
  1421. return;
  1422. case SRB_SET_STREAM_PROPERTY:
  1423. //h DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_PROPERTY\r\n") );
  1424. SetSubpicProperty( pSrb );
  1425. if( pSrb->Status != STATUS_PENDING ) {
  1426. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  1427. pSrb->StreamObject );
  1428. StreamClassStreamNotification( StreamRequestComplete,
  1429. pSrb->StreamObject,
  1430. pSrb );
  1431. }
  1432. return;
  1433. case SRB_OPEN_MASTER_CLOCK:
  1434. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_OPEN_MASTER_CLOCK\r\n") );
  1435. hMaster = pSrb->CommandData.MasterClockHandle;
  1436. pSrb->Status = STATUS_SUCCESS;
  1437. break;
  1438. case SRB_CLOSE_MASTER_CLOCK:
  1439. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_CLOSE_MASTER_CLOCK\r\n") );
  1440. hMaster = pSrb->CommandData.MasterClockHandle;
  1441. pSrb->Status = STATUS_SUCCESS;
  1442. break;
  1443. case SRB_INDICATE_MASTER_CLOCK:
  1444. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_INDICATE_MASTER_CLOCK\r\n") );
  1445. hClk = pSrb->CommandData.MasterClockHandle;
  1446. pSrb->Status = STATUS_SUCCESS;
  1447. break;
  1448. case SRB_UNKNOWN_STREAM_COMMAND:
  1449. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_UNKNOWN_STREAM_COMMAND\r\n") );
  1450. TRAP;
  1451. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1452. break;
  1453. case SRB_SET_STREAM_RATE:
  1454. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_RATE\r\n") );
  1455. TRAP;
  1456. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1457. break;
  1458. case SRB_PROPOSE_DATA_FORMAT:
  1459. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_PROPOSE_DATA_FORMAT\r\n") );
  1460. TRAP;
  1461. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1462. break;
  1463. default:
  1464. DebugPrint( (DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->Command, pSrb->Command ) );
  1465. TRAP;
  1466. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1467. break;
  1468. }
  1469. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  1470. pSrb->StreamObject );
  1471. StreamClassStreamNotification( StreamRequestComplete,
  1472. pSrb->StreamObject,
  1473. pSrb );
  1474. }
  1475. /*
  1476. ** VpeReceiveDataPacket()
  1477. */
  1478. extern "C" VOID STREAMAPI VpeReceiveDataPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  1479. {
  1480. // PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  1481. DebugPrint( (DebugLevelVerbose, "TOSDVD:VpeReceiveDataPacket---------\r\n") );
  1482. switch( pSrb->Command ){
  1483. case SRB_READ_DATA:
  1484. DebugPrint( (DebugLevelVerbose, "TOSDVD: SRB_READ_DATA\r\n") );
  1485. pSrb->ActualBytesTransferred = 0;
  1486. pSrb->Status = STATUS_SUCCESS;
  1487. break;
  1488. case SRB_WRITE_DATA:
  1489. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_WRITE_DATA\r\n") );
  1490. TRAP;
  1491. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1492. break;
  1493. default:
  1494. DebugPrint( (DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->Command, pSrb->Command ) );
  1495. TRAP;
  1496. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1497. break;
  1498. }
  1499. StreamClassStreamNotification( ReadyForNextStreamDataRequest,
  1500. pSrb->StreamObject );
  1501. StreamClassStreamNotification( StreamRequestComplete,
  1502. pSrb->StreamObject,
  1503. pSrb );
  1504. }
  1505. /*
  1506. ** VpeReceiveCtrlPacket()
  1507. */
  1508. extern "C" VOID STREAMAPI VpeReceiveCtrlPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  1509. {
  1510. DebugPrint( (DebugLevelTrace, "TOSDVD:VpeReceiveCtrlPacket---------\r\n") );
  1511. switch( pSrb->Command ){
  1512. case SRB_SET_STREAM_STATE:
  1513. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_STATE\r\n") );
  1514. switch( pSrb->CommandData.StreamState ) {
  1515. case KSSTATE_STOP:
  1516. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_STOP\r\n") );
  1517. break;
  1518. case KSSTATE_PAUSE:
  1519. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_PAUSE\r\n") );
  1520. break;
  1521. case KSSTATE_RUN:
  1522. DebugPrint( (DebugLevelTrace, "TOSDVD: KSSTATE_RUN\r\n") );
  1523. break;
  1524. }
  1525. pSrb->Status = STATUS_SUCCESS;
  1526. break;
  1527. case SRB_GET_STREAM_STATE:
  1528. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_GET_STREAM_STATE\r\n") );
  1529. pSrb->Status = STATUS_SUCCESS;
  1530. break;
  1531. case SRB_GET_STREAM_PROPERTY:
  1532. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_GET_STREAM_PROPERTY\r\n") );
  1533. GetVpeProperty( pSrb );
  1534. if( pSrb->Status != STATUS_PENDING ) {
  1535. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  1536. pSrb->StreamObject );
  1537. StreamClassStreamNotification( StreamRequestComplete,
  1538. pSrb->StreamObject,
  1539. pSrb );
  1540. }
  1541. return;
  1542. case SRB_SET_STREAM_PROPERTY:
  1543. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_PROPERTY\r\n") );
  1544. SetVpeProperty( pSrb );
  1545. break;
  1546. case SRB_OPEN_MASTER_CLOCK:
  1547. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_OPEN_MASTER_CLOCK\r\n") );
  1548. hMaster = pSrb->CommandData.MasterClockHandle;
  1549. pSrb->Status = STATUS_SUCCESS;
  1550. break;
  1551. case SRB_CLOSE_MASTER_CLOCK:
  1552. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_CLOSE_MASTER_CLOCK\r\n") );
  1553. hMaster = pSrb->CommandData.MasterClockHandle;
  1554. pSrb->Status = STATUS_SUCCESS;
  1555. break;
  1556. case SRB_INDICATE_MASTER_CLOCK:
  1557. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_INDICATE_MASTER_CLOCK\r\n") );
  1558. hClk = pSrb->CommandData.MasterClockHandle;
  1559. pSrb->Status = STATUS_SUCCESS;
  1560. break;
  1561. case SRB_UNKNOWN_STREAM_COMMAND:
  1562. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_UNKNOWN_STREAM_COMMAND\r\n") );
  1563. TRAP;
  1564. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1565. break;
  1566. case SRB_SET_STREAM_RATE:
  1567. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_RATE\r\n") );
  1568. TRAP;
  1569. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1570. break;
  1571. case SRB_PROPOSE_DATA_FORMAT:
  1572. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_PROPOSE_DATA_FORMAT\r\n") );
  1573. TRAP;
  1574. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1575. break;
  1576. default:
  1577. DebugPrint( (DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->Command, pSrb->Command ) );
  1578. TRAP;
  1579. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1580. break;
  1581. }
  1582. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  1583. pSrb->StreamObject );
  1584. StreamClassStreamNotification( StreamRequestComplete,
  1585. pSrb->StreamObject,
  1586. pSrb );
  1587. }
  1588. /*
  1589. ** CCReceiveDataPacket()
  1590. */
  1591. extern "C" VOID STREAMAPI CCReceiveDataPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  1592. {
  1593. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  1594. DebugPrint(( DebugLevelVerbose, "TOSDVD:CCReceiveDataPacket---------\r\n" ));
  1595. switch( pSrb->Command ) {
  1596. case SRB_READ_DATA:
  1597. DebugPrint(( DebugLevelVerbose, "TOSDVD: SRB_READ_DATA\r\n" ));
  1598. DebugPrint(( DebugLevelTrace, "TOSDVD: put queue CC pSrb = 0x%x\r\n", pSrb ));
  1599. pHwDevExt->CCQue.put( pSrb );
  1600. pSrb->Status = STATUS_PENDING;
  1601. pSrb->TimeoutCounter = 0; // prevent the packet from timing out, ever
  1602. StreamClassStreamNotification( ReadyForNextStreamDataRequest,
  1603. pSrb->StreamObject );
  1604. return;
  1605. case SRB_WRITE_DATA:
  1606. DebugPrint(( DebugLevelTrace, "TOSDVD: SRB_WRITE_DATA\r\n" ));
  1607. TRAP;
  1608. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1609. break;
  1610. default:
  1611. DebugPrint(( DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->Command, pSrb->Command ));
  1612. TRAP;
  1613. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1614. break;
  1615. }
  1616. StreamClassStreamNotification( ReadyForNextStreamDataRequest,
  1617. pSrb->StreamObject );
  1618. StreamClassStreamNotification( StreamRequestComplete,
  1619. pSrb->StreamObject,
  1620. pSrb );
  1621. }
  1622. /*
  1623. ** CCReceiveCtrlPacket()
  1624. */
  1625. extern "C" VOID STREAMAPI CCReceiveCtrlPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  1626. {
  1627. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  1628. DebugPrint(( DebugLevelTrace, "TOSDVD:CCReceiveCtrlPacket---------\r\n" ));
  1629. switch( pSrb->Command ) {
  1630. case SRB_SET_STREAM_STATE:
  1631. DebugPrint(( DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_STATE\r\n" ));
  1632. switch( pSrb->CommandData.StreamState ) {
  1633. case KSSTATE_STOP:
  1634. DebugPrint(( DebugLevelTrace, "TOSDVD: KSSTATE_STOP\r\n" ));
  1635. break;
  1636. case KSSTATE_PAUSE:
  1637. DebugPrint(( DebugLevelTrace, "TOSDVD: KSSTATE_PAUSE\r\n" ));
  1638. break;
  1639. case KSSTATE_RUN:
  1640. DebugPrint(( DebugLevelTrace, "TOSDVD: KSSTATE_RUN\r\n" ));
  1641. break;
  1642. }
  1643. ((PSTREAMEX)(pHwDevExt->pstroCC->HwStreamExtension))->state = pSrb->CommandData.StreamState;
  1644. pSrb->Status = STATUS_SUCCESS;
  1645. break;
  1646. case SRB_GET_STREAM_STATE:
  1647. DebugPrint(( DebugLevelTrace, "TOSDVD: SRB_GET_STREAM_STATE\r\n" ));
  1648. pSrb->Status = STATUS_SUCCESS;
  1649. break;
  1650. case SRB_GET_STREAM_PROPERTY:
  1651. DebugPrint(( DebugLevelTrace, "TOSDVD: SRB_GET_STREAM_PROPERTY\r\n" ));
  1652. GetCCProperty( pSrb );
  1653. break;
  1654. case SRB_SET_STREAM_PROPERTY:
  1655. DebugPrint(( DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_PROPERTY\r\n" ));
  1656. SetCCProperty( pSrb );
  1657. break;
  1658. case SRB_OPEN_MASTER_CLOCK:
  1659. DebugPrint( (DebugLevelTrace, "TOSDVD: SRB_OPEN_MASTER_CLOCK\r\n") );
  1660. hMaster = pSrb->CommandData.MasterClockHandle;
  1661. pSrb->Status = STATUS_SUCCESS;
  1662. break;
  1663. case SRB_CLOSE_MASTER_CLOCK:
  1664. DebugPrint(( DebugLevelTrace, "TOSDVD: SRB_CLOSE_MASTER_CLOCK\r\n" ));
  1665. hMaster = pSrb->CommandData.MasterClockHandle;
  1666. pSrb->Status = STATUS_SUCCESS;
  1667. break;
  1668. case SRB_INDICATE_MASTER_CLOCK:
  1669. DebugPrint(( DebugLevelTrace, "TOSDVD: SRB_INDICATE_MASTER_CLOCK\r\n" ));
  1670. hClk = pSrb->CommandData.MasterClockHandle;
  1671. pSrb->Status = STATUS_SUCCESS;
  1672. break;
  1673. case SRB_UNKNOWN_STREAM_COMMAND:
  1674. DebugPrint(( DebugLevelTrace, "TOSDVD: SRB_UNKNOWN_STREAM_COMMAND\r\n" ));
  1675. TRAP;
  1676. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1677. break;
  1678. case SRB_SET_STREAM_RATE:
  1679. DebugPrint(( DebugLevelTrace, "TOSDVD: SRB_SET_STREAM_RATE\r\n" ));
  1680. TRAP;
  1681. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1682. break;
  1683. case SRB_PROPOSE_DATA_FORMAT:
  1684. DebugPrint(( DebugLevelTrace, "TOSDVD: SRB_PROPOSE_DATA_FORMAT\r\n" ));
  1685. TRAP;
  1686. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1687. break;
  1688. default:
  1689. DebugPrint(( DebugLevelTrace, "TOSDVD: default %d(0x%x)\r\n", pSrb->Command, pSrb->Command ));
  1690. TRAP;
  1691. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1692. break;
  1693. }
  1694. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  1695. pSrb->StreamObject );
  1696. StreamClassStreamNotification( StreamRequestComplete,
  1697. pSrb->StreamObject,
  1698. pSrb );
  1699. }
  1700. void VideoQueryAccept(PHW_STREAM_REQUEST_BLOCK pSrb)
  1701. {
  1702. DebugPrint( (DebugLevelTrace, "TOSDVD:VideoQueryAccept\r\n" ) );
  1703. PKSDATAFORMAT pfmt = pSrb->CommandData.OpenFormat;
  1704. // KS_MPEGVIDEOINFO2 * pblock = (KS_MPEGVIDEOINFO2 *)((ULONG)pfmt + sizeof (KSDATAFORMAT));
  1705. //
  1706. // pick up the format block and examine it. Default to not implemented
  1707. //
  1708. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  1709. if (pfmt->FormatSize != sizeof(KSDATAFORMAT) + sizeof(KS_MPEGVIDEOINFO2))
  1710. {
  1711. return;
  1712. }
  1713. pSrb->Status = STATUS_SUCCESS;
  1714. }
  1715. void ProcessVideoFormat( PKSDATAFORMAT pfmt, PHW_DEVICE_EXTENSION pHwDevExt )
  1716. {
  1717. DebugPrint( (DebugLevelTrace, "TOSDVD:ProcessVideoFormat\r\n" ) );
  1718. KS_MPEGVIDEOINFO2 * VidFmt = (KS_MPEGVIDEOINFO2 *)((DWORD_PTR)pfmt + sizeof (KSDATAFORMAT));
  1719. if( pfmt->FormatSize != sizeof(KSDATAFORMAT) + sizeof(KS_MPEGVIDEOINFO2) ) {
  1720. TRAP;
  1721. return;
  1722. }
  1723. //
  1724. // copy the picture aspect ratio for now
  1725. //
  1726. pHwDevExt->VPFmt.dwPictAspectRatioX = VidFmt->hdr.dwPictAspectRatioX;
  1727. pHwDevExt->VPFmt.dwPictAspectRatioY = VidFmt->hdr.dwPictAspectRatioY;
  1728. DebugPrint(( DebugLevelTrace, "TOSDVD: AspectRatioX %d\r\n", VidFmt->hdr.dwPictAspectRatioX ));
  1729. DebugPrint(( DebugLevelTrace, "TOSDVD: AspectRatioY %d\r\n", VidFmt->hdr.dwPictAspectRatioY ));
  1730. if( pHwDevExt->VPFmt.dwPictAspectRatioX == 4 && pHwDevExt->VPFmt.dwPictAspectRatioY == 3 ) {
  1731. pHwDevExt->CPgd.CPGD_SET_ASPECT( 0 );
  1732. }
  1733. else if (pHwDevExt->VPFmt.dwPictAspectRatioX == 16 && pHwDevExt->VPFmt.dwPictAspectRatioY == 9 ) {
  1734. pHwDevExt->CPgd.CPGD_SET_ASPECT( 1 );
  1735. }
  1736. //
  1737. // check for pan scan enabled
  1738. //
  1739. #if DBG
  1740. if( VidFmt->dwFlags & KS_MPEG2_DoPanScan )
  1741. DebugPrint(( DebugLevelTrace, "TOSDVD: KS_MPEG2_DoPanScan\r\n" ));
  1742. if( VidFmt->dwFlags & KS_MPEG2_DVDLine21Field1 )
  1743. DebugPrint(( DebugLevelTrace, "TOSDVD: KS_MPEG2_DVDLine21Field1\r\n" ));
  1744. if( VidFmt->dwFlags & KS_MPEG2_DVDLine21Field2 )
  1745. DebugPrint(( DebugLevelTrace, "TOSDVD: KS_MPEG2_DVDLine21Field2\r\n" ));
  1746. if( VidFmt->dwFlags & KS_MPEG2_SourceIsLetterboxed )
  1747. DebugPrint(( DebugLevelTrace, "TOSDVD: KS_MPEG2_SourceIsLetterboxed\r\n" ));
  1748. if( VidFmt->dwFlags & KS_MPEG2_FilmCameraMode )
  1749. DebugPrint(( DebugLevelTrace, "TOSDVD: KS_MPEG2_FilmCameraMode\r\n" ));
  1750. #endif
  1751. if (VidFmt->dwFlags & KS_MPEG2_DoPanScan)
  1752. {
  1753. TRAP;
  1754. //
  1755. // under pan scan for DVD for NTSC, we must be going to a 540 by
  1756. // 480 bit image, from a 720 x 480 (or 704 x 480) We will
  1757. // use this as the base starting dimensions. If the Sequence
  1758. // header provides other sizes, then those should be updated,
  1759. // and the Video port connection should be updated when the
  1760. // sequence header is received.
  1761. //
  1762. //
  1763. // change the picture aspect ratio. Since we will be stretching
  1764. // from 540 to 720 in the horizontal direction, our aspect ratio
  1765. // will
  1766. //
  1767. pHwDevExt->VPFmt.dwPictAspectRatioX = (VidFmt->hdr.dwPictAspectRatioX * (54000 / 72));
  1768. pHwDevExt->VPFmt.dwPictAspectRatioY = VidFmt->hdr.dwPictAspectRatioY * 1000;
  1769. }
  1770. //
  1771. // call the IVPConfig interface here
  1772. //
  1773. if (pHwDevExt->pstroYUV &&
  1774. ((PSTREAMEX)(pHwDevExt->pstroYUV->HwStreamExtension))->EventCount)
  1775. {
  1776. StreamClassStreamNotification(
  1777. SignalMultipleStreamEvents,
  1778. pHwDevExt->pstroYUV,
  1779. &MY_KSEVENTSETID_VPNOTIFY,
  1780. KSEVENT_VPNOTIFY_FORMATCHANGE
  1781. );
  1782. }
  1783. }
  1784. // Debug
  1785. void BadWait( DWORD dwTime )
  1786. {
  1787. DWORD st, et;
  1788. st = GetCurrentTime_ms();
  1789. for( ; ; ) {
  1790. KeStallExecutionProcessor( 1 );
  1791. et = GetCurrentTime_ms();
  1792. if( st + dwTime < et )
  1793. break;
  1794. }
  1795. DebugPrint( (DebugLevelTrace, "TOSDVD:wait %dms\r\n", et - st ) );
  1796. }
  1797. void VideoDataDiscontinuity( PHW_DEVICE_EXTENSION pHwDevExt )
  1798. {
  1799. pHwDevExt->DataDiscontFlagCount |= VIDEO_DISCONT_FLAG;
  1800. pHwDevExt->bVideoQueue = TRUE;
  1801. }
  1802. void AudioDataDiscontinuity( PHW_DEVICE_EXTENSION pHwDevExt )
  1803. {
  1804. pHwDevExt->DataDiscontFlagCount |= AUDIO_DISCONT_FLAG;
  1805. pHwDevExt->bAudioQueue = TRUE;
  1806. }
  1807. void SubpicDataDiscontinuity( PHW_DEVICE_EXTENSION pHwDevExt )
  1808. {
  1809. pHwDevExt->DataDiscontFlagCount |= SUBPIC_DISCONT_FLAG;
  1810. pHwDevExt->bSubpicQueue = TRUE;
  1811. }
  1812. void ClearDataDiscontinuity( PHW_DEVICE_EXTENSION pHwDevExt )
  1813. {
  1814. pHwDevExt->DataDiscontFlagCount = 0;
  1815. }
  1816. void VideoTimeDiscontinuity( PHW_DEVICE_EXTENSION pHwDevExt )
  1817. {
  1818. }
  1819. void AudioTimeDiscontinuity( PHW_DEVICE_EXTENSION pHwDevExt )
  1820. {
  1821. }
  1822. void SubpicTimeDiscontinuity( PHW_DEVICE_EXTENSION pHwDevExt )
  1823. {
  1824. }
  1825. void ClearTimeDiscontinuity( PHW_DEVICE_EXTENSION pHwDevExt )
  1826. {
  1827. pHwDevExt->TimeDiscontFlagCount = 0;
  1828. }
  1829. void FastSlowControl( PHW_STREAM_REQUEST_BLOCK pSrb )
  1830. {
  1831. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  1832. ULONG i;
  1833. PKSSTREAM_HEADER pStruc;
  1834. PUCHAR pDat;
  1835. LONGLONG pts = 0;
  1836. LONGLONG dts = 0;
  1837. LONGLONG tmp = 0;
  1838. LONG Rate;
  1839. LONGLONG start;
  1840. REFERENCE_TIME InterceptTime;
  1841. for( i = 0; i < pSrb->NumberOfBuffers; i++ ) {
  1842. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[i];
  1843. if( pStruc->DataUsed ) {
  1844. pDat = (PUCHAR)pStruc->Data;
  1845. if( *(pDat+21) & 0x80 ) {
  1846. pts += ((DWORD)(*(pDat+23) & 0x0E)) << 29;
  1847. pts += ((DWORD)(*(pDat+24) & 0xFF)) << 22;
  1848. pts += ((DWORD)(*(pDat+25) & 0xFE)) << 14;
  1849. pts += ((DWORD)(*(pDat+26) & 0xFF)) << 7;
  1850. pts += ((DWORD)(*(pDat+27) & 0xFE)) >> 1;
  1851. DebugPrint( (DebugLevelTrace, "TOSDVD:ReceiveDataPacket PTS 0x%lx(100ns)\r\n", pts * 1000 / 9));
  1852. }
  1853. }
  1854. }
  1855. pts = 0;
  1856. // if( pHwDevExt->PlayMode == PLAY_MODE_FAST ) {
  1857. if( pHwDevExt->RunMode == PLAY_MODE_FAST ) {
  1858. // DebugPrint( (DebugLevelTrace, "TOSDVD: FastSlowControl\r\n") );
  1859. Rate = pHwDevExt->Rate;
  1860. InterceptTime = pHwDevExt->InterceptTime;
  1861. start = pHwDevExt->StartTime * 9 / 1000;
  1862. for( i = 0; i < pSrb->NumberOfBuffers; i++ ) {
  1863. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[i];
  1864. if( pStruc->DataUsed ) {
  1865. pDat = (PUCHAR)pStruc->Data;
  1866. // PTS modify
  1867. if( *(pDat+21) & 0x80 ) {
  1868. pts += ((DWORD)(*(pDat+23) & 0x0E)) << 29;
  1869. pts += ((DWORD)(*(pDat+24) & 0xFF)) << 22;
  1870. pts += ((DWORD)(*(pDat+25) & 0xFE)) << 14;
  1871. pts += ((DWORD)(*(pDat+26) & 0xFF)) << 7;
  1872. pts += ((DWORD)(*(pDat+27) & 0xFE)) >> 1;
  1873. DebugPrint( (DebugLevelTrace, "TOSDVD: PTS before Rate Change = %lx\r\n", pts ));
  1874. // DebugPrint( (DebugLevelTrace, "TOSDVD: Rate = %lx\r\n", Rate ));
  1875. // DebugPrint( (DebugLevelTrace, "TOSDVD: InterceptTime = %lx\r\n", InterceptTime ));
  1876. tmp = pts;
  1877. // pts = Rate * ( pts - ConvertStrmtoPTS(InterceptTime) ) / 10000;
  1878. pts = Rate * ( pts - (InterceptTime * 9 / 1000) ) / 10000;
  1879. *(pDat+23) = (UCHAR)(((pts & 0xC0000000) >> 29) | 0x11);
  1880. *(pDat+24) = (UCHAR)(((pts & 0x3FC00000) >> 22) | 0x00);
  1881. *(pDat+25) = (UCHAR)(((pts & 0x003F8000) >> 14) | 0x01);
  1882. *(pDat+26) = (UCHAR)(((pts & 0x00007F80) >> 7) | 0x00);
  1883. *(pDat+27) = (UCHAR)(((pts & 0x0000007F) << 1) | 0x01);
  1884. DebugPrint( (DebugLevelTrace, "TOSDVD: PTS after Rate Change = %lx\r\n", pts ));
  1885. }
  1886. // DTS modify
  1887. if( *(pDat+17)==0xE0 ) { // 0xE0 is Video Stream ID
  1888. if( (*(pDat+21) & 0xC0) == 0xC0 ) {
  1889. dts += ((DWORD)(*(pDat+28) & 0x0E)) << 29;
  1890. dts += ((DWORD)(*(pDat+29) & 0xFF)) << 22;
  1891. dts += ((DWORD)(*(pDat+30) & 0xFE)) << 14;
  1892. dts += ((DWORD)(*(pDat+31) & 0xFF)) << 7;
  1893. dts += ((DWORD)(*(pDat+32) & 0xFE)) >> 1;
  1894. dts = pts - (tmp - dts);
  1895. *(pDat+28) = (UCHAR)(((dts & 0xC0000000) >> 29) | 0x11);
  1896. *(pDat+29) = (UCHAR)(((dts & 0x3FC00000) >> 22) | 0x00);
  1897. *(pDat+30) = (UCHAR)(((dts & 0x003F8000) >> 14) | 0x01);
  1898. *(pDat+31) = (UCHAR)(((dts & 0x00007F80) >> 7) | 0x00);
  1899. *(pDat+32) = (UCHAR)(((dts & 0x0000007F) << 1) | 0x01);
  1900. }
  1901. }
  1902. }
  1903. }
  1904. }
  1905. }
  1906. //--- for Debug 97.08.30; K.Chujo
  1907. DWORD xunGetPTS(void *pBuf)
  1908. {
  1909. PUCHAR pDat;
  1910. DWORD pts = 0;
  1911. // DWORD dts = 0;
  1912. static count = 0;
  1913. pDat = (PUCHAR)pBuf;
  1914. if (*(pDat+21) & 0x80) { // if PTS exists,
  1915. pts += ((DWORD)(*(pDat+23) & 0x0E)) << 29;
  1916. pts += ((DWORD)(*(pDat+24) & 0xFF)) << 22;
  1917. pts += ((DWORD)(*(pDat+25) & 0xFE)) << 14;
  1918. pts += ((DWORD)(*(pDat+26) & 0xFF)) << 7;
  1919. pts += ((DWORD)(*(pDat+27) & 0xFE)) >> 1;
  1920. }
  1921. if (*(pDat+17)==0xE0) { // 0xE0 is Video Stream ID
  1922. // if ( (*(pDat+21) & 0xC0) == 0xC0 ) {
  1923. // dts += ((DWORD)(*(pDat+28) & 0x0E)) << 29;
  1924. // dts += ((DWORD)(*(pDat+29) & 0xFF)) << 22;
  1925. // dts += ((DWORD)(*(pDat+30) & 0xFE)) << 14;
  1926. // dts += ((DWORD)(*(pDat+31) & 0xFF)) << 7;
  1927. // dts += ((DWORD)(*(pDat+32) & 0xFE)) >> 1;
  1928. //// DebugPrint( (DebugLevelTrace, "TOSDVD: DTS(V) 0x%08lX\r\n", dts) );
  1929. //// DebugPrint( (DebugLevelTrace, "TOSDVD: DIFF(pts - dts) = 0x%04lX\r\n", pts-dts) );
  1930. //
  1931. // dts = pts - 0x2328; // PTS - 100ms
  1932. // *(pDat+28) = (UCHAR)(((dts & 0xC0000000) >> 29) | 0x11);
  1933. // *(pDat+29) = (UCHAR)(((dts & 0x3FC00000) >> 22) | 0x00);
  1934. // *(pDat+30) = (UCHAR)(((dts & 0x003F8000) >> 14) | 0x01);
  1935. // *(pDat+31) = (UCHAR)(((dts & 0x00007F80) >> 7) | 0x00);
  1936. // *(pDat+32) = (UCHAR)(((dts & 0x0000007F) << 1) | 0x01);
  1937. // }
  1938. // if (pts!=0) {
  1939. // DebugPrint( (DebugLevelTrace, "TOSDVD: PTS(V) 0x%04lX\r\n", pts) );
  1940. // }
  1941. // else {
  1942. // DebugPrint( (DebugLevelTrace, "TOSDVD: PTS(V) ******\r\n") );
  1943. // }
  1944. }
  1945. else if (*(pDat+17)==0xBD && (*(pDat+(*(pDat+22)+23)) & 0xF8)==0x80) {
  1946. // if (pts!=0) {
  1947. // DebugPrint( (DebugLevelTrace, "TOSDVD: PTS(A) 0x%04lX\r\n", pts) );
  1948. // }
  1949. // else {
  1950. // DebugPrint( (DebugLevelTrace, "TOSDVD: PTS(A) ******\r\n") );
  1951. // }
  1952. }
  1953. else if (*(pDat+17)==0xBD && (*(pDat+(*(pDat+22)+23)) & 0xE0)==0x20) {
  1954. // if (pts!=0) {
  1955. // DebugPrint( (DebugLevelTrace, "TOSDVD: PTS(S) 0x%04lX\r\n", pts) );
  1956. // }
  1957. // else {
  1958. // DebugPrint( (DebugLevelTrace, "TOSDVD: PTS(S) ******\r\n") );
  1959. // }
  1960. }
  1961. else if (*(pDat+17)==0xBD && (*(pDat+(*(pDat+22)+23)) & 0xF8)==0xA0) {
  1962. }
  1963. else {
  1964. DebugPrint( (DebugLevelTrace, "TOSDVD: unexpected ID(%02X) "/*\r\n"*/, *(pDat+17) ) );
  1965. pts = 0xFFFFFFFF;
  1966. DebugPrint( (DebugLevelTrace, "--> %02X %02X %02X %02X\r\n", *(pDat+0), *(pDat+1), *(pDat+2), *(pDat+3) ));
  1967. }
  1968. return(pts);
  1969. }
  1970. //---
  1971. //--- 97.09.10 K.Chujo
  1972. DWORD GetStreamID(void *pBuf)
  1973. {
  1974. PUCHAR pDat = (PUCHAR)pBuf;
  1975. UCHAR strID;
  1976. UCHAR subID;
  1977. strID = *(pDat+17);
  1978. // Check Video Stream
  1979. if( strID==0xE0 ) {
  1980. return( (DWORD)strID );
  1981. }
  1982. #if 0
  1983. // MPEG Audio
  1984. else if ( (strID & 0x??) == 0x@@ ) {
  1985. return( (DWORD)strID );
  1986. }
  1987. #endif
  1988. // Check Private Stream 1 (AC-3/PCM/Subpic)
  1989. else {
  1990. subID = *(pDat+(*(pDat+22)+23));
  1991. return( (DWORD)subID );
  1992. }
  1993. }
  1994. //--- End.
  1995. ULONG GetHowLongWait( PHW_DEVICE_EXTENSION pHwDevExt, PKSSTREAM_HEADER pStruc )
  1996. {
  1997. ULONGLONG stc;
  1998. ULONGLONG pts = 0;
  1999. ULONGLONG waitTime = 0;
  2000. PUCHAR pDat;
  2001. if( pStruc->DataUsed ) {
  2002. pDat = (PUCHAR)pStruc->Data;
  2003. if( *(pDat+21) & 0x80 ) {
  2004. pts += ((ULONGLONG)(*(pDat+23) & 0x0E)) << 29;
  2005. pts += ((ULONGLONG)(*(pDat+24) & 0xFF)) << 22;
  2006. pts += ((ULONGLONG)(*(pDat+25) & 0xFE)) << 14;
  2007. pts += ((ULONGLONG)(*(pDat+26) & 0xFF)) << 7;
  2008. pts += ((ULONGLONG)(*(pDat+27) & 0xFE)) >> 1;
  2009. stc = (ULONGLONG)pHwDevExt->VDec.VIDEO_GET_STCA();
  2010. DebugPrint( (DebugLevelTrace, "TOSDVD: pts = %lx(90KHz) %ld(100ns dec)\r\n", pts, pts * 1000 / 9) );
  2011. DebugPrint( (DebugLevelTrace, "TOSDVD: stc = %lx(90KHz) %ld(100ns dec)\r\n", stc, stc * 1000 / 9) );
  2012. if( stc < pts && pts - stc > 45000 ) {
  2013. waitTime = (pts - stc - 45000) * 100 / 9;
  2014. if( waitTime > 1000000 ) {
  2015. // Buggy. This is temporary coding for Windows98 beta 3
  2016. pHwDevExt->VDec.VIDEO_SET_STCA( (ULONG)pts );
  2017. DebugPrint( (DebugLevelTrace, "TOSDVD: <<<< Bad Wait Time (%ldms)\r\n", waitTime/1000 ) );
  2018. waitTime = 0;
  2019. }
  2020. }
  2021. }
  2022. }
  2023. return( (ULONG)waitTime );
  2024. }
  2025. void ScheduledDMAxfer( PHW_DEVICE_EXTENSION pHwDevExt )
  2026. {
  2027. DebugPrint( (DebugLevelTrace, "TOSDVD: ++++ Schedule flag off ++++\r\n" ) );
  2028. if( pHwDevExt->bDMAscheduled == TRUE ) {
  2029. pHwDevExt->bDMAscheduled = FALSE;
  2030. PreDMAxfer( pHwDevExt );
  2031. }
  2032. }
  2033. void PreDMAxfer( PHW_DEVICE_EXTENSION pHwDevExt )
  2034. {
  2035. PHW_STREAM_REQUEST_BLOCK pSrb;
  2036. PKSSTREAM_HEADER pStruc;
  2037. ULONG index;
  2038. BOOLEAN last;
  2039. BOOLEAN fDMA0 = FALSE;
  2040. BOOLEAN fDMA1 = FALSE;
  2041. ULONG time0 = 0;
  2042. ULONG time1 = 0;
  2043. if( pHwDevExt->bDMAstop == TRUE ) {
  2044. DebugPrint( (DebugLevelTrace, "TOSDVD: ++++ bDMAstop == TRUE ++++\r\n" ) );
  2045. return;
  2046. }
  2047. pHwDevExt->fDMA = 0x03;
  2048. // If Play Mode is not FAST, call DMAxfer directrly
  2049. // if( pHwDevExt->PlayMode != PLAY_MODE_FAST || pHwDevExt->DecodeStart == FALSE ) {
  2050. if( pHwDevExt->RunMode != PLAY_MODE_FAST || pHwDevExt->DecodeStart == FALSE ) {
  2051. if( pHwDevExt->bDMAscheduled == TRUE ) {
  2052. pHwDevExt->bDMAscheduled = FALSE;
  2053. }
  2054. DMAxfer( pHwDevExt );
  2055. return;
  2056. }
  2057. // {
  2058. // ULONG dwSTC;
  2059. // dwSTC = pHwDevExt->VDec.VIDEO_GET_STCA();
  2060. // DebugPrint( (DebugLevelTrace, "TOSDVD: dwSTC = %lx\r\n", dwSTC ) );
  2061. // }
  2062. // If called from end of DMA interrupt routine when scheduled, then no operation.
  2063. if( pHwDevExt->bDMAscheduled == TRUE )
  2064. return;
  2065. if( pHwDevExt->PlayMode == PLAY_MODE_FREEZE )
  2066. return;
  2067. if( pHwDevExt->pSrbDMA0 == NULL ) {
  2068. pSrb = pHwDevExt->DevQue.refer1st( &index, &last );
  2069. if( pSrb != NULL ) {
  2070. fDMA0 = TRUE;
  2071. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[index];
  2072. time0 = GetHowLongWait( pHwDevExt, pStruc );
  2073. }
  2074. if( pHwDevExt->pSrbDMA1 == NULL ) {
  2075. pSrb = pHwDevExt->DevQue.refer2nd( &index, &last );
  2076. if( pSrb != NULL ) {
  2077. fDMA1 = TRUE;
  2078. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[index];
  2079. time1 = GetHowLongWait( pHwDevExt, pStruc );
  2080. }
  2081. }
  2082. }
  2083. else if( pHwDevExt->pSrbDMA1 == NULL ) {
  2084. pSrb = pHwDevExt->DevQue.refer1st( &index, &last );
  2085. if( pSrb != NULL ) {
  2086. fDMA1 = TRUE;
  2087. pStruc = &((PKSSTREAM_HEADER)(pSrb->CommandData.DataBufferArray))[index];
  2088. time1 = GetHowLongWait( pHwDevExt, pStruc );
  2089. }
  2090. }
  2091. // both DMA0 and DMA1 are available
  2092. if( fDMA0 == TRUE && fDMA1 == TRUE ) {
  2093. if( time0 == 0 && time1 == 0 ) {
  2094. DMAxfer( pHwDevExt );
  2095. }
  2096. else if( time0 == 0 ) {
  2097. pHwDevExt->fDMA = 0x01;
  2098. DMAxfer( pHwDevExt );
  2099. // Scheduling
  2100. DebugPrint( (DebugLevelTrace, "TOSDVD: ++++ Scheduling ++++\r\n" ) );
  2101. DebugPrint( (DebugLevelTrace, "TOSDVD: time1 = %x\r\n", time1 ) );
  2102. pHwDevExt->bDMAscheduled = TRUE;
  2103. StreamClassScheduleTimer(
  2104. NULL,
  2105. pHwDevExt,
  2106. time1,
  2107. (PHW_TIMER_ROUTINE)ScheduledDMAxfer,
  2108. pHwDevExt
  2109. );
  2110. }
  2111. else {
  2112. // Scheduling
  2113. DebugPrint( (DebugLevelTrace, "TOSDVD: ++++ Scheduling ++++\r\n" ) );
  2114. DebugPrint( (DebugLevelTrace, "TOSDVD: time0 = %x\r\n", time0 ) );
  2115. pHwDevExt->bDMAscheduled = TRUE;
  2116. StreamClassScheduleTimer(
  2117. NULL,
  2118. pHwDevExt,
  2119. time0,
  2120. (PHW_TIMER_ROUTINE)ScheduledDMAxfer,
  2121. pHwDevExt
  2122. );
  2123. }
  2124. }
  2125. // only DMA0 is available
  2126. else if( fDMA0 == TRUE ) {
  2127. if( time0 == 0 ) {
  2128. DMAxfer( pHwDevExt );
  2129. }
  2130. else {
  2131. // Scheduling
  2132. DebugPrint( (DebugLevelTrace, "TOSDVD: ++++ Scheduling ++++\r\n" ) );
  2133. DebugPrint( (DebugLevelTrace, "TOSDVD: time0 = %x\r\n", time0 ) );
  2134. pHwDevExt->bDMAscheduled = TRUE;
  2135. StreamClassScheduleTimer(
  2136. NULL,
  2137. pHwDevExt,
  2138. time0,
  2139. (PHW_TIMER_ROUTINE)ScheduledDMAxfer,
  2140. pHwDevExt
  2141. );
  2142. }
  2143. }
  2144. // only DMA1 is available
  2145. else if( fDMA1 == TRUE ) {
  2146. if( time1 == 0 ) {
  2147. DMAxfer( pHwDevExt );
  2148. }
  2149. else {
  2150. // Scheduling
  2151. DebugPrint( (DebugLevelTrace, "TOSDVD: ++++ Scheduling ++++\r\n" ) );
  2152. DebugPrint( (DebugLevelTrace, "TOSDVD: time1 = %x\r\n", time1 ) );
  2153. pHwDevExt->bDMAscheduled = TRUE;
  2154. StreamClassScheduleTimer(
  2155. NULL,
  2156. pHwDevExt,
  2157. time1,
  2158. (PHW_TIMER_ROUTINE)ScheduledDMAxfer,
  2159. pHwDevExt
  2160. );
  2161. }
  2162. }
  2163. else {
  2164. // DebugPrint( (DebugLevelTrace, "TOSDVD: ++++++ No Data in queue (PreDMAxfer) ++++++\r\n" ) );
  2165. }
  2166. }
  2167. void DMAxfer( PHW_DEVICE_EXTENSION pHwDevExt )
  2168. {
  2169. ULONG addr;
  2170. ULONG vbuffsize;
  2171. ULONG index0 = 0, index1 = 0;
  2172. // PUCHAR ioBase = pHwDevExt->ioBaseLocal;
  2173. BOOL fDMA0 = FALSE;
  2174. BOOL fDMA1 = FALSE;
  2175. UCHAR fDMA;
  2176. // SCR discontinue test
  2177. PKSSTREAM_HEADER pStruc;
  2178. // unsigned char *p;
  2179. DWORD dwTMP;
  2180. DWORD dwPTS = 0;
  2181. BOOL TimeValid = FALSE;
  2182. if( (fDMA = pHwDevExt->fDMA) == 0 )
  2183. return;
  2184. if( !pHwDevExt->SendFirst ) {
  2185. fProgrammed = FALSE;
  2186. pHwDevExt->bSTCvalid = FALSE;
  2187. }
  2188. if( pHwDevExt->pSrbDMA0 == NULL && (fDMA & 0x01) ) {
  2189. pHwDevExt->pSrbDMA0 = pHwDevExt->DevQue.get( &index0, &(pHwDevExt->fSrbDMA0last) );
  2190. if( pHwDevExt->pSrbDMA0 == NULL ) {
  2191. pHwDevExt->fSrbDMA0last = FALSE;
  2192. DebugPrint( (DebugLevelVerbose, "TOSDVD: pHwDevExt->pSrbDMA0 == NULL\r\n") );
  2193. }
  2194. else {
  2195. // debug
  2196. if( ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA0->SRBExtension))->pfnEndSrb ) {
  2197. DebugPrint(( DebugLevelTrace, "TOSDVD:exist pfnEndSrb(DmaXfer0) srb = 0x%x, %d\r\n", pHwDevExt->pSrbDMA0, pHwDevExt->fSrbDMA0last ));
  2198. }
  2199. fDMA0 = TRUE;
  2200. ULONG index;
  2201. index = index0;
  2202. if( pHwDevExt->pSrbDMA0->NumberOfBuffers != pHwDevExt->pSrbDMA0->NumberOfPhysicalPages )
  2203. index++;
  2204. pStruc = &((PKSSTREAM_HEADER)(pHwDevExt->pSrbDMA0->CommandData.DataBufferArray))[index];
  2205. SetAudioID( pHwDevExt, pStruc );
  2206. //--- Change DTS ---//
  2207. //xunGetPTS( (PUCHAR)pStruc->Data );
  2208. //------------------//
  2209. if( !pHwDevExt->DecodeStart ) {
  2210. if( !(pHwDevExt->DataDiscontFlagCount & VIDEO_DISCONT_FLAG) && !pHwDevExt->bSTCvalid ) {
  2211. dwPTS = pHwDevExt->dwSTCtemp;
  2212. TimeValid = TRUE;
  2213. DebugPrint( (DebugLevelTrace, "TOSDVD: <---- Underflow STC ---->\r\n") );
  2214. }
  2215. else if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TIMEVALID ) {
  2216. if( TimeValid==FALSE ) {
  2217. dwPTS = ConvertStrmtoPTS( pStruc->PresentationTime.Time );
  2218. }
  2219. else {
  2220. dwTMP = ConvertStrmtoPTS( pStruc->PresentationTime.Time );
  2221. dwPTS = (dwPTS>dwTMP) ? dwTMP : dwPTS;
  2222. }
  2223. TimeValid = TRUE;
  2224. }
  2225. }
  2226. }
  2227. }
  2228. if( pHwDevExt->pSrbDMA1 == NULL && (fDMA & 0x02) ) {
  2229. pHwDevExt->pSrbDMA1 = pHwDevExt->DevQue.get( &index1, &(pHwDevExt->fSrbDMA1last) );
  2230. if( pHwDevExt->pSrbDMA1 == NULL ) {
  2231. pHwDevExt->fSrbDMA1last = FALSE;
  2232. DebugPrint( (DebugLevelVerbose, "TOSDVD: pHwDevExt->pSrbDMA1 == NULL\r\n") );
  2233. }
  2234. else {
  2235. // debug
  2236. if( ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA1->SRBExtension))->pfnEndSrb ) {
  2237. DebugPrint(( DebugLevelTrace, "TOSDVD:exist pfnEndSrb(DmaXfer1) srb = 0x%x, %d\r\n", pHwDevExt->pSrbDMA1, pHwDevExt->fSrbDMA1last ));
  2238. }
  2239. fDMA1 = TRUE;
  2240. ULONG index;
  2241. index = index1;
  2242. if( pHwDevExt->pSrbDMA1->NumberOfBuffers != pHwDevExt->pSrbDMA1->NumberOfPhysicalPages )
  2243. index++;
  2244. pStruc = &((PKSSTREAM_HEADER)(pHwDevExt->pSrbDMA1->CommandData.DataBufferArray))[index];
  2245. SetAudioID( pHwDevExt, pStruc );
  2246. //--- Change DTS ---//
  2247. //xunGetPTS( (PUCHAR)pStruc->Data );
  2248. //------------------//
  2249. if( !pHwDevExt->DecodeStart ) {
  2250. if( !(pHwDevExt->DataDiscontFlagCount & VIDEO_DISCONT_FLAG) && !pHwDevExt->bSTCvalid ) {
  2251. dwPTS = pHwDevExt->dwSTCtemp;
  2252. TimeValid = TRUE;
  2253. DebugPrint( (DebugLevelTrace, "TOSDVD: <---- Underflow STC ---->\r\n") );
  2254. }
  2255. else if( pStruc->OptionsFlags & KSSTREAM_HEADER_OPTIONSF_TIMEVALID ) {
  2256. if( TimeValid==FALSE ) {
  2257. dwPTS = ConvertStrmtoPTS( pStruc->PresentationTime.Time );
  2258. }
  2259. else {
  2260. dwTMP = ConvertStrmtoPTS( pStruc->PresentationTime.Time );
  2261. dwPTS = (dwPTS>dwTMP) ? dwTMP : dwPTS;
  2262. }
  2263. TimeValid = TRUE;
  2264. }
  2265. }
  2266. }
  2267. }
  2268. if( !fDMA0 && !fDMA1 ) {
  2269. // DebugPrint( (DebugLevelTrace, "TOSDVD: ++++ No Data in Queue (DMAxfer) ++++\r\n") );
  2270. return;
  2271. }
  2272. if( pHwDevExt->SendFirst && !pHwDevExt->DecodeStart ) {
  2273. if( TimeValid && pHwDevExt->bSTCvalid == FALSE ) {
  2274. pHwDevExt->bSTCvalid = TRUE;
  2275. pHwDevExt->dwSTCInit = dwPTS;
  2276. }
  2277. if( TimeValid && pHwDevExt->dwSTCInit > dwPTS ) {
  2278. DebugPrint( (DebugLevelTrace, "TOSDVD: %lx --> %lx\r\n", pHwDevExt->dwSTCInit, dwPTS ) );
  2279. pHwDevExt->dwSTCInit = dwPTS;
  2280. }
  2281. vbuffsize = pHwDevExt->VDec.VIDEO_GET_STD_CODE();
  2282. if( vbuffsize > 250000 ) {
  2283. #if DBG
  2284. DWORD ct = GetCurrentTime_ms();
  2285. DebugPrint(( DebugLevelTrace, "TOSDVD:VBuff Size %d ( %dms )\r\n", vbuffsize, ct - pHwDevExt->SendFirstTime ));
  2286. #endif
  2287. if( pHwDevExt->bSTCvalid == FALSE ) {
  2288. DebugPrint( (DebugLevelTrace, "TOSDVD: Use old STC in Decode Start %lx --> %lx\r\n", pHwDevExt->dwSTCInit, pHwDevExt->dwSTCtemp ) );
  2289. pHwDevExt->dwSTCInit = pHwDevExt->dwSTCtemp;
  2290. }
  2291. DecodeStart( pHwDevExt, pHwDevExt->dwSTCInit );
  2292. }
  2293. }
  2294. if( ! pHwDevExt->SendFirst ) {
  2295. DebugPrint( (DebugLevelTrace, "TOSDVD:Send First\r\n" ) );
  2296. pHwDevExt->bSTCvalid = TimeValid;
  2297. if( pHwDevExt->bSTCvalid==FALSE ) {
  2298. DebugPrint( (DebugLevelTrace, "TOSDVD: <-------- PTS as STC is invalid in SendFirst -------->\r\n" ) );
  2299. }
  2300. InitFirstTime( pHwDevExt, dwPTS );
  2301. pHwDevExt->SendFirst = TRUE;
  2302. pHwDevExt->dwSTCInit = dwPTS;
  2303. StreamClassScheduleTimer(
  2304. pHwDevExt->pstroVid,
  2305. pHwDevExt,
  2306. 3000000,
  2307. (PHW_TIMER_ROUTINE)TimerDecodeStart,
  2308. pHwDevExt
  2309. );
  2310. fProgrammed = TRUE;
  2311. pHwDevExt->SendFirstTime = GetCurrentTime_ms();
  2312. }
  2313. if( fDMA0 ) {
  2314. // DebugDumpPackHeader( pHwDevExt->pSrbDMA0 );
  2315. // DebugDumpWriteData( pHwDevExt->pSrbDMA0 );
  2316. addr = (ULONG)( pHwDevExt->pSrbDMA0->ScatterGatherBuffer[index0].PhysicalAddress.LowPart );
  2317. pHwDevExt->DAck.PCIF_SET_DMA0_ADDR( addr );
  2318. ASSERT( ( pHwDevExt->pSrbDMA0->ScatterGatherBuffer[index0].Length & 0x7ff ) == 0 );
  2319. pHwDevExt->DAck.PCIF_SET_DMA0_SIZE( pHwDevExt->pSrbDMA0->ScatterGatherBuffer[index0].Length );
  2320. pHwDevExt->DAck.PCIF_DMA0_START();
  2321. DebugPrint(( DebugLevelVerbose, "TOSDVD:DMA0 start! srb = 0x%x\r\n", pHwDevExt->pSrbDMA0 ));
  2322. }
  2323. if( fDMA1 ) {
  2324. // DebugDumpPackHeader( pHwDevExt->pSrbDMA1 );
  2325. // DebugDumpWriteData( pHwDevExt->pSrbDMA1 );
  2326. addr = (ULONG)( pHwDevExt->pSrbDMA1->ScatterGatherBuffer[index1].PhysicalAddress.LowPart );
  2327. pHwDevExt->DAck.PCIF_SET_DMA1_ADDR( addr );
  2328. ASSERT( ( pHwDevExt->pSrbDMA1->ScatterGatherBuffer[index1].Length & 0x7ff ) == 0 );
  2329. pHwDevExt->DAck.PCIF_SET_DMA1_SIZE( pHwDevExt->pSrbDMA1->ScatterGatherBuffer[index1].Length );
  2330. pHwDevExt->DAck.PCIF_DMA1_START();
  2331. DebugPrint(( DebugLevelVerbose, "TOSDVD:DMA1 start! srb = 0x%x\r\n", pHwDevExt->pSrbDMA1 ));
  2332. }
  2333. }
  2334. void DMAxferKeyData( PHW_DEVICE_EXTENSION pHwDevExt, PHW_STREAM_REQUEST_BLOCK pSrb, PUCHAR addr, DWORD dwSize, PHW_TIMER_ROUTINE pfnCallBack )
  2335. {
  2336. PHYSICAL_ADDRESS phyadd;
  2337. DebugPrint( (DebugLevelTrace, "TOSDVD:DMAxferKeyData\r\n" ) );
  2338. ASSERT( pHwDevExt->pSrbDMA0 == NULL && pHwDevExt->pSrbDMA1 == NULL );
  2339. // BUGBUG!
  2340. // must be wait underflow!
  2341. // SendFirst
  2342. decStopData( pHwDevExt, TRUE );
  2343. InitFirstTime( pHwDevExt, 0 );
  2344. RtlCopyMemory(pHwDevExt->pDmaBuf,
  2345. addr,
  2346. dwSize);
  2347. phyadd = pHwDevExt->addr;
  2348. pHwDevExt->DAck.PCIF_SET_DMA0_ADDR( phyadd.LowPart );
  2349. pHwDevExt->DAck.PCIF_SET_DMA0_SIZE( dwSize );
  2350. pHwDevExt->DAck.PCIF_DMA0_START();
  2351. pHwDevExt->bKeyDataXfer = TRUE;
  2352. pHwDevExt->pSrbDMA0 = pSrb;
  2353. pHwDevExt->pfnEndKeyData = pfnCallBack;
  2354. pSrb->Status = STATUS_PENDING; // add by seichan 1997/07/10
  2355. return;
  2356. }
  2357. void EndKeyData( PHW_DEVICE_EXTENSION pHwDevExt )
  2358. {
  2359. BOOLEAN bStatus;
  2360. DebugPrint( (DebugLevelTrace, "TOSDVD:EndKeyData\r\n" ) );
  2361. pHwDevExt->bKeyDataXfer = FALSE;
  2362. bStatus = pHwDevExt->CPro.DiscKeyEnd();
  2363. ASSERTMSG( "\r\n...CPro Status Error!!( DiscKeyEnd )", bStatus );
  2364. pHwDevExt->pSrbDMA0->Status = STATUS_SUCCESS;
  2365. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  2366. pHwDevExt->pSrbDMA0->StreamObject );
  2367. StreamClassStreamNotification( StreamRequestComplete,
  2368. pHwDevExt->pSrbDMA0->StreamObject,
  2369. pHwDevExt->pSrbDMA0 );
  2370. pHwDevExt->pSrbDMA0 = NULL;
  2371. pHwDevExt->XferStartCount = 0;
  2372. pHwDevExt->DecodeStart = FALSE;
  2373. pHwDevExt->SendFirst = FALSE;
  2374. StreamClassScheduleTimer(
  2375. pHwDevExt->pstroVid,
  2376. pHwDevExt,
  2377. 0,
  2378. (PHW_TIMER_ROUTINE)TimerDecodeStart,
  2379. pHwDevExt
  2380. );
  2381. return;
  2382. }
  2383. void InitFirstTime( PHW_DEVICE_EXTENSION pHwDevExt, DWORD dwSTC )
  2384. {
  2385. DWORD st, et;
  2386. DebugPrint(( DebugLevelTrace, "TOSDVD:InitFirstTime\r\n" ));
  2387. DebugPrint(( DebugLevelTrace, "TOSDVD: STC 0x%x( 0x%s(100ns) )\r\n", dwSTC, DebugLLConvtoStr( ConvertPTStoStrm(dwSTC), 16 ) ));
  2388. // for debug
  2389. UCHAR mvar;
  2390. mvar = READ_PORT_UCHAR( pHwDevExt->ioBaseLocal + TC812_IRM );
  2391. mvar &= 0xEF;
  2392. WRITE_PORT_UCHAR( pHwDevExt->ioBaseLocal + TC812_IRM, mvar );
  2393. WRITE_PORT_UCHAR( pHwDevExt->ioBaseLocal + TC812_ERM, 0 );
  2394. //
  2395. st = GetCurrentTime_ms();
  2396. // TC81201F bug recovery
  2397. pHwDevExt->VDec.VIDEO_PLAY_STILL();
  2398. BadWait( 200 );
  2399. // normal process
  2400. pHwDevExt->VDec.VIDEO_SYSTEM_STOP();
  2401. pHwDevExt->VDec.VIDEO_DECODE_STOP();
  2402. pHwDevExt->ADec.AUDIO_ZR38521_STOP();
  2403. pHwDevExt->VPro.SUBP_STC_OFF();
  2404. // TC81201F bug recovery
  2405. pHwDevExt->VDec.VIDEO_BUG_PRE_SEARCH_01();
  2406. // normal process
  2407. pHwDevExt->VDec.VIDEO_STD_CLEAR();
  2408. pHwDevExt->VDec.VIDEO_USER_CLEAR();
  2409. pHwDevExt->VDec.VIDEO_UDAT_CLEAR();
  2410. pHwDevExt->ADec.AUDIO_ZR38521_STOPF();
  2411. if( pHwDevExt->DataDiscontFlagCount & VIDEO_DISCONT_FLAG ) {
  2412. // when decode new data
  2413. pHwDevExt->VPro.SUBP_RESET_INIT();
  2414. pHwDevExt->VPro.SUBP_BUFF_CLEAR();
  2415. }
  2416. else {
  2417. // when recover underflow
  2418. // Don't reset and clear buffer.
  2419. }
  2420. pHwDevExt->VDec.VIDEO_UFLOW_INT_OFF();
  2421. pHwDevExt->VDec.VIDEO_ALL_IFLAG_CLEAR();
  2422. pHwDevExt->DAck.PCIF_ALL_IFLAG_CLEAR();
  2423. pHwDevExt->DAck.PCIF_PACK_START_ON();
  2424. pHwDevExt->VDec.VIDEO_SYSTEM_START();
  2425. // TC81201F bug recovery
  2426. // Accoding to TOSHIBA MM lab. Hisatomi-san,
  2427. // BLACK DATA or SKIP DATA should be set from host bus.
  2428. // However the VxD is not implemented and work good,
  2429. // so the minidriver is not implemented too.
  2430. // If you need, insert code here.
  2431. // TC81201F bug recovery
  2432. pHwDevExt->VDec.VIDEO_PVSIN_OFF();
  2433. pHwDevExt->VDec.VIDEO_BUG_PRE_SEARCH_02();
  2434. // TC81201F bug recovery
  2435. BadWait( 200 );
  2436. // pHwDevExt->VDec.VIDEO_BUG_PRE_SEARCH_03();
  2437. // /* error check */ pHwDevExt->VDec.VIDEO_DECODE_STOP();
  2438. // TC81201F bug recovery
  2439. pHwDevExt->VDec.VIDEO_PVSIN_ON();
  2440. pHwDevExt->VDec.VIDEO_BUG_PRE_SEARCH_05();
  2441. // pHwDevExt->VDec.VIDEO_DECODE_INT_ON(); // Not Use ?
  2442. pHwDevExt->VDec.VIDEO_SET_STCS( dwSTC ); // ? ? ? ?
  2443. pHwDevExt->ADec.AUDIO_ZR38521_VDSCR_ON( dwSTC );
  2444. if( pHwDevExt->DataDiscontFlagCount & VIDEO_DISCONT_FLAG ) {
  2445. // when decode new data
  2446. pHwDevExt->VPro.SUBP_SET_STC( /* dwSTC */ 0 );
  2447. pHwDevExt->VPro.SUBP_BUFF_CLEAR();
  2448. }
  2449. else {
  2450. // when recover underflow
  2451. // Don't set stc, because sub stc is reset.
  2452. }
  2453. pHwDevExt->VPro.SUBP_MUTE_ON();
  2454. pHwDevExt->fCauseOfStop = 0;
  2455. et = GetCurrentTime_ms();
  2456. DebugPrint( (DebugLevelTrace, "TOSDVD:init first time %dms\r\n", et - st ) );
  2457. }
  2458. //--- 97.09.10 K.Chujo
  2459. // 97.09.14 rename
  2460. void MenuDecodeStart( PHW_DEVICE_EXTENSION pHwDevExt )
  2461. {
  2462. //--- 97.09.14 K.Chujo
  2463. // if no data exists in queue,
  2464. if( pHwDevExt->DevQue.isEmpty()==TRUE ) {
  2465. // if DMA transfer dosen't finish, wait.
  2466. if( pHwDevExt->pSrbDMA0 != NULL || pHwDevExt->pSrbDMA1 != NULL ) {
  2467. StreamClassScheduleTimer(
  2468. NULL,
  2469. pHwDevExt,
  2470. 100000,
  2471. (PHW_TIMER_ROUTINE)MenuDecodeStart,
  2472. pHwDevExt
  2473. );
  2474. DebugPrint( (DebugLevelTrace, "TOSDVD:Schedule MenuDecodeStart(1)\r\n" ) );
  2475. return;
  2476. }
  2477. }
  2478. // if data exist in queue, wait.
  2479. else {
  2480. StreamClassScheduleTimer(
  2481. NULL,
  2482. pHwDevExt,
  2483. 100000,
  2484. (PHW_TIMER_ROUTINE)MenuDecodeStart,
  2485. pHwDevExt
  2486. );
  2487. DebugPrint( (DebugLevelTrace, "TOSDVD:Schedule MenuDecodeStart(2)\r\n" ) );
  2488. return;
  2489. }
  2490. #if DBG
  2491. //--- for Debug
  2492. {
  2493. DebugPrint(( DebugLevelTrace, "TOSDVD:MenuDecodeStart\r\n" ));
  2494. ULONG vbuffsize = pHwDevExt->VDec.VIDEO_GET_STD_CODE();
  2495. DWORD ct = GetCurrentTime_ms();
  2496. DebugPrint(( DebugLevelTrace, "TOSDVD: VBuff Size %d ( %dms )\r\n", vbuffsize, ct - pHwDevExt->SendFirstTime ));
  2497. }
  2498. //---
  2499. #endif
  2500. //--- End.
  2501. pHwDevExt->fCauseOfStop = 0x01;
  2502. if( pHwDevExt->DecodeStart == FALSE ) {
  2503. DecodeStart( pHwDevExt, pHwDevExt->dwSTCInit );
  2504. }
  2505. }
  2506. //--- End.
  2507. void DecodeStart( PHW_DEVICE_EXTENSION pHwDevExt, DWORD dwSTC )
  2508. {
  2509. DebugPrint(( DebugLevelTrace, "TOSDVD:Decode Start\r\n" ));
  2510. DebugPrint(( DebugLevelTrace, "TOSDVD: STC 0x%x( 0x%s(100ns) )\r\n", dwSTC, DebugLLConvtoStr( ConvertPTStoStrm(dwSTC), 16 ) ));
  2511. if( pHwDevExt->PlayMode == PLAY_MODE_NORMAL ) {
  2512. DebugPrint( (DebugLevelTrace, "TOSDVD: PlayMode = PLAY_MODE_NORMAL\r\n") );
  2513. pHwDevExt->ADec.AUDIO_ZR38521_MUTE_ON();
  2514. // pHwDevExt->ADec.AUDIO_ZR38521_MUTE_OFF();
  2515. pHwDevExt->VDec.VIDEO_PRSO_PS1();
  2516. pHwDevExt->VDec.VIDEO_PLAY_NORMAL();
  2517. pHwDevExt->PlayMode = PLAY_MODE_NORMAL;
  2518. pHwDevExt->RunMode = PLAY_MODE_NORMAL;
  2519. pHwDevExt->VDec.VIDEO_SET_STCS( dwSTC );
  2520. pHwDevExt->ADec.AUDIO_ZR38521_VDSCR_ON( dwSTC );
  2521. // pHwDevExt->ADec.AUDIO_ZR38521_VDSCR_OFF( dwSTC );
  2522. // pHwDevExt->VPro.SUBP_MUTE_OFF();
  2523. if( pHwDevExt->SubpicMute == TRUE )
  2524. pHwDevExt->VPro.SUBP_MUTE_ON();
  2525. else
  2526. pHwDevExt->VPro.SUBP_MUTE_OFF();
  2527. if( pHwDevExt->DataDiscontFlagCount & VIDEO_DISCONT_FLAG ) {
  2528. // when decode new data
  2529. pHwDevExt->VPro.SUBP_SET_STC( dwSTC );
  2530. }
  2531. else {
  2532. // when recover underflow
  2533. // Don't set stc, because sub stc is reset.
  2534. }
  2535. pHwDevExt->VPro.SUBP_STC_ON();
  2536. decHighlight( pHwDevExt, &(pHwDevExt->hli) );
  2537. pHwDevExt->VDec.VIDEO_UFLOW_INT_ON();
  2538. // pHwDevExt->VDec.VIDEO_UFLOW_INT_OFF();
  2539. pHwDevExt->VDec.VIDEO_BUG_PRE_SEARCH_04();
  2540. pHwDevExt->VDec.VIDEO_DECODE_START();
  2541. pHwDevExt->ADec.AUDIO_ZR38521_PLAY();
  2542. pHwDevExt->VPro.VPRO_VIDEO_MUTE_OFF();
  2543. pHwDevExt->CPgd.CPGD_VIDEO_MUTE_OFF();
  2544. // pHwDevExt->VDec.VIDEO_SEEMLESS_ON();
  2545. StreamClassScheduleTimer(
  2546. NULL,
  2547. pHwDevExt,
  2548. 1,
  2549. (PHW_TIMER_ROUTINE)TimerAudioMuteOff,
  2550. pHwDevExt
  2551. );
  2552. }
  2553. else if( pHwDevExt->PlayMode == PLAY_MODE_FAST ) {
  2554. DebugPrint( (DebugLevelTrace, "TOSDVD: PlayMode = PLAY_MODE_FAST\r\n") );
  2555. pHwDevExt->VDec.VIDEO_PRSO_NON();
  2556. pHwDevExt->VDec.VIDEO_PLAY_NORMAL();
  2557. pHwDevExt->VDec.VIDEO_UFLOW_INT_OFF();
  2558. pHwDevExt->ADec.AUDIO_ZR38521_MUTE_ON();
  2559. pHwDevExt->VDec.VIDEO_BUG_PRE_SEARCH_04();
  2560. pHwDevExt->VDec.VIDEO_DECODE_START();
  2561. pHwDevExt->VDec.VIDEO_SYSTEM_STOP();
  2562. pHwDevExt->VDec.VIDEO_PLAY_FAST( FAST_ONLYI );
  2563. pHwDevExt->VDec.VIDEO_SYSTEM_START();
  2564. // pHwDevExt->VDec.VIDEO_SET_STCS( dwSTC );
  2565. // pHwDevExt->ADec.AUDIO_ZR38521_VDSCR_ON( dwSTC );
  2566. // pHwDevExt->VPro.SUBP_MUTE_ON();
  2567. // pHwDevExt->VPro.SUBP_SET_STC( dwSTC );
  2568. // pHwDevExt->VPro.SUBP_STC_ON();
  2569. pHwDevExt->ADec.AUDIO_ZR38521_PLAY();
  2570. dwSTC = pHwDevExt->VDec.VIDEO_GET_STCA( );
  2571. DebugPrint( (DebugLevelTrace, "TOSDVD: dwSTC = %lx\r\n", dwSTC) );
  2572. }
  2573. else if( pHwDevExt->PlayMode == PLAY_MODE_SLOW ) {
  2574. DebugPrint( (DebugLevelTrace, "TOSDVD: PlayMode = PLAY_MODE_SLOW\r\n") );
  2575. pHwDevExt->VDec.VIDEO_PRSO_PS1();
  2576. pHwDevExt->VPro.SUBP_SET_AUDIO_NON();
  2577. // pHwDevExt->VDec.VIDEO_PLAY_SLOW();
  2578. // SetPlaySlow( pHwDevExt );
  2579. pHwDevExt->VDec.VIDEO_PLAY_SLOW( (UCHAR)(pHwDevExt->Rate/10000) );
  2580. pHwDevExt->VDec.VIDEO_SET_STCS( dwSTC );
  2581. pHwDevExt->ADec.AUDIO_ZR38521_STOP();
  2582. pHwDevExt->ADec.AUDIO_ZR38521_MUTE_ON();
  2583. if( pHwDevExt->SubpicMute == TRUE )
  2584. pHwDevExt->VPro.SUBP_MUTE_ON();
  2585. else
  2586. pHwDevExt->VPro.SUBP_MUTE_OFF();
  2587. if( pHwDevExt->DataDiscontFlagCount & VIDEO_DISCONT_FLAG ) {
  2588. // when decode new data
  2589. pHwDevExt->VPro.SUBP_SET_STC( dwSTC );
  2590. }
  2591. else {
  2592. // when recover underflow
  2593. // Don't set stc, because sub stc is reset.
  2594. }
  2595. pHwDevExt->VPro.SUBP_STC_ON();
  2596. pHwDevExt->VDec.VIDEO_UFLOW_INT_ON();
  2597. pHwDevExt->VDec.VIDEO_BUG_PRE_SEARCH_04();
  2598. pHwDevExt->VDec.VIDEO_DECODE_START();
  2599. pHwDevExt->VPro.VPRO_VIDEO_MUTE_OFF();
  2600. pHwDevExt->CPgd.CPGD_VIDEO_MUTE_OFF();
  2601. }
  2602. else if( pHwDevExt->PlayMode == PLAY_MODE_FREEZE ) {
  2603. DebugPrint( (DebugLevelTrace, "TOSDVD: PlayMode = PLAY_MODE_FREEZE\r\n") );
  2604. }
  2605. else {
  2606. DebugPrint( (DebugLevelTrace, "TOSDVD: PlayMode = PLAY_MODE_??????\r\n") );
  2607. }
  2608. //--- 97.09.08 K.Chujo
  2609. ClearDataDiscontinuity( pHwDevExt );
  2610. ClearTimeDiscontinuity( pHwDevExt );
  2611. pHwDevExt->DecodeStart = TRUE;
  2612. //--- End.
  2613. StreamClassScheduleTimer(
  2614. pHwDevExt->pstroVid,
  2615. pHwDevExt,
  2616. 0,
  2617. (PHW_TIMER_ROUTINE)TimerDecodeStart,
  2618. pHwDevExt
  2619. );
  2620. }
  2621. void TimerDecodeStart( PHW_DEVICE_EXTENSION pHwDevExt )
  2622. {
  2623. DebugPrint(( DebugLevelTrace, "TOSDVD:TimerDecodeStart()\r\n" ));
  2624. ULONG vbuffsize = pHwDevExt->VDec.VIDEO_GET_STD_CODE();
  2625. #if DBG
  2626. DWORD ct = GetCurrentTime_ms();
  2627. DebugPrint(( DebugLevelTrace, "TOSDVD: VBuff Size %d ( %dms )\r\n", vbuffsize, ct - pHwDevExt->SendFirstTime ));
  2628. #endif
  2629. // Temporary
  2630. if( vbuffsize > 0 )
  2631. DecodeStart( pHwDevExt, pHwDevExt->dwSTCInit );
  2632. else
  2633. pHwDevExt->SendFirst = FALSE;
  2634. }
  2635. VOID TimerAudioMuteOff( PHW_DEVICE_EXTENSION pHwDevExt )
  2636. {
  2637. ULONG Diff, VStc;
  2638. DebugPrint( (DebugLevelTrace, "TOSDVD:TimerAudioCheck\r\n") );
  2639. if( !pHwDevExt->DecodeStart ) {
  2640. DebugPrint(( DebugLevelTrace, "TOSDVD: Timer cancel\r\n" ));
  2641. return;
  2642. }
  2643. pHwDevExt->ADec.AUDIO_ZR38521_STAT( &Diff );
  2644. if( (Diff > 0xfb50) || (Diff < 0x01e0) ) {
  2645. pHwDevExt->ADec.AUDIO_ZR38521_MUTE_OFF();
  2646. DebugPrint(( DebugLevelTrace, "TOSDVD: Audio Mute Off\r\n" ));
  2647. }
  2648. else {
  2649. VStc = pHwDevExt->VDec.VIDEO_GET_STCA();
  2650. pHwDevExt->ADec.AUDIO_ZR38521_VDSCR_ON( VStc );
  2651. StreamClassScheduleTimer(
  2652. NULL,
  2653. pHwDevExt,
  2654. 120000,
  2655. (PHW_TIMER_ROUTINE)TimerAudioMuteOff,
  2656. pHwDevExt
  2657. );
  2658. }
  2659. }
  2660. // Property
  2661. void GetVideoProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  2662. {
  2663. switch ( pSrb->CommandData.PropertyInfo->PropertySetID ) {
  2664. case 0:
  2665. DebugPrint( (DebugLevelTrace, "TOSDVD: GetVideoProperty 0\r\n") );
  2666. TRAP;
  2667. pSrb->Status = STATUS_SUCCESS;
  2668. break;
  2669. case 1:
  2670. GetCppProperty( pSrb, strmVideo );
  2671. break;
  2672. //--- 97.09.24 K.Chujo
  2673. case 2:
  2674. DebugPrint( (DebugLevelTrace, "TOSDVD: GetVideoProperty 2\r\n") );
  2675. GetVideoRateChange( pSrb );
  2676. break;
  2677. //--- End.
  2678. default:
  2679. DebugPrint( (DebugLevelTrace, "TOSDVD: GetVideoProperty-default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->PropertySetID, pSrb->CommandData.PropertyInfo->PropertySetID ) );
  2680. TRAP;
  2681. pSrb->Status = STATUS_SUCCESS;
  2682. break;
  2683. }
  2684. }
  2685. void SetVideoProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  2686. {
  2687. switch ( pSrb->CommandData.PropertyInfo->PropertySetID ) {
  2688. case 0:
  2689. DebugPrint( (DebugLevelTrace, "TOSDVD: SetVideoProperty 0\r\n") );
  2690. TRAP;
  2691. pSrb->Status = STATUS_SUCCESS;
  2692. break;
  2693. case 1:
  2694. SetCppProperty( pSrb );
  2695. break;
  2696. //--- 97.09.24 K.Chujo
  2697. case 2:
  2698. DebugPrint( (DebugLevelTrace, "TOSDVD: SetVideoProperty 2\r\n") );
  2699. SetVideoRateChange( pSrb );
  2700. break;
  2701. //--- End.
  2702. default:
  2703. DebugPrint( (DebugLevelTrace, "TOSDVD: SetVideoProperty-default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->PropertySetID, pSrb->CommandData.PropertyInfo->PropertySetID ) );
  2704. TRAP;
  2705. pSrb->Status = STATUS_SUCCESS;
  2706. break;
  2707. }
  2708. }
  2709. ULONG audiodecoutmode = KSAUDDECOUTMODE_STEREO_ANALOG;
  2710. void GetAudioProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  2711. {
  2712. switch ( pSrb->CommandData.PropertyInfo->PropertySetID ) {
  2713. case 0:
  2714. DebugPrint( (DebugLevelTrace, "TOSDVD: GetAudioProperty\r\n") );
  2715. pSrb->Status = STATUS_SUCCESS;
  2716. switch(pSrb->CommandData.PropertyInfo->Property->Id) {
  2717. case KSPROPERTY_AUDDECOUT_MODES:
  2718. *(PULONG)(pSrb->CommandData.PropertyInfo->PropertyInfo) =
  2719. KSAUDDECOUTMODE_STEREO_ANALOG | KSAUDDECOUTMODE_SPDIFF;
  2720. break;
  2721. case KSPROPERTY_AUDDECOUT_CUR_MODE:
  2722. *(PULONG)(pSrb->CommandData.PropertyInfo->PropertyInfo) = audiodecoutmode;
  2723. break;
  2724. default:
  2725. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  2726. break;
  2727. }
  2728. break;
  2729. case 1:
  2730. GetCppProperty( pSrb, strmAudio );
  2731. break;
  2732. //--- 97.09.24 K.Chujo
  2733. case 2:
  2734. DebugPrint( (DebugLevelTrace, "TOSDVD: GetAudioProperty 2\r\n") );
  2735. GetAudioRateChange( pSrb );
  2736. break;
  2737. //--- End.
  2738. default:
  2739. DebugPrint( (DebugLevelTrace, "TOSDVD: GetAudioProperty-default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->PropertySetID, pSrb->CommandData.PropertyInfo->PropertySetID ) );
  2740. TRAP;
  2741. pSrb->Status = STATUS_SUCCESS;
  2742. break;
  2743. }
  2744. }
  2745. void SetAudioProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  2746. {
  2747. switch ( pSrb->CommandData.PropertyInfo->PropertySetID ) {
  2748. case 0:
  2749. DebugPrint( (DebugLevelTrace, "TOSDVD: SetAudioProperty\r\n") );
  2750. pSrb->Status = STATUS_SUCCESS;
  2751. switch(pSrb->CommandData.PropertyInfo->Property->Id) {
  2752. case KSPROPERTY_AUDDECOUT_CUR_MODE:
  2753. if ((*(PULONG)(pSrb->CommandData.PropertyInfo->PropertyInfo)) &
  2754. (!(KSAUDDECOUTMODE_STEREO_ANALOG | KSAUDDECOUTMODE_SPDIFF)))
  2755. {
  2756. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  2757. break;
  2758. }
  2759. // HwCodecAc3BypassMode(*(PULONG)(pSrb->CommandData.PropertyInfo->PropertyInfo) &
  2760. // KSAUDDECOUTMODE_SPDIFF);
  2761. audiodecoutmode = *(PULONG)(pSrb->CommandData.PropertyInfo->PropertyInfo);
  2762. break;
  2763. default:
  2764. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  2765. break;
  2766. }
  2767. break;
  2768. case 1:
  2769. SetCppProperty( pSrb );
  2770. break;
  2771. //--- 97.09.24 K.Chujo
  2772. case 2:
  2773. DebugPrint( (DebugLevelTrace, "TOSDVD: SetAudioProperty 2\r\n") );
  2774. SetAudioRateChange( pSrb );
  2775. break;
  2776. //--- End.
  2777. default:
  2778. DebugPrint( (DebugLevelTrace, "TOSDVD: SetAudioProperty-default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->PropertySetID, pSrb->CommandData.PropertyInfo->PropertySetID ) );
  2779. TRAP;
  2780. pSrb->Status = STATUS_SUCCESS;
  2781. break;
  2782. }
  2783. }
  2784. void GetSubpicProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  2785. {
  2786. // PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  2787. switch ( pSrb->CommandData.PropertyInfo->PropertySetID ) {
  2788. case 0:
  2789. DebugPrint( (DebugLevelTrace, "TOSDVD: GetSubpicProperty\r\n") );
  2790. TRAP;
  2791. pSrb->Status = STATUS_SUCCESS;
  2792. break;
  2793. case 1:
  2794. GetCppProperty( pSrb, strmSubpicture );
  2795. break;
  2796. //--- 97.09.24 K.Chujo
  2797. case 2:
  2798. DebugPrint( (DebugLevelTrace, "TOSDVD: GetSubpicProperty 2\r\n") );
  2799. GetSubpicRateChange( pSrb );
  2800. break;
  2801. //--- End.
  2802. default:
  2803. DebugPrint( (DebugLevelTrace, "TOSDVD: GetSubpicProperty-default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->PropertySetID, pSrb->CommandData.PropertyInfo->PropertySetID ) );
  2804. TRAP;
  2805. pSrb->Status = STATUS_SUCCESS;
  2806. break;
  2807. }
  2808. }
  2809. void SetSubpicProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  2810. {
  2811. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  2812. pSrb->Status = STATUS_SUCCESS;
  2813. switch ( pSrb->CommandData.PropertyInfo->PropertySetID ) {
  2814. case 0:
  2815. switch( pSrb->CommandData.PropertyInfo->Property->Id ) {
  2816. case KSPROPERTY_DVDSUBPIC_PALETTE:
  2817. {
  2818. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDSUBPIC_PALETTE\r\n") );
  2819. PKSPROPERTY_SPPAL ppal;
  2820. UCHAR paldata[48];
  2821. int i;
  2822. ppal = (PKSPROPERTY_SPPAL)pSrb->CommandData.PropertyInfo->PropertyInfo;
  2823. for( i = 0; i < 16; i++ ) {
  2824. paldata[i*3+0] = ppal->sppal[i].Y;
  2825. paldata[i*3+1] = ppal->sppal[i].U; // -> Cb
  2826. paldata[i*3+2] = ppal->sppal[i].V; // -> Cr
  2827. }
  2828. pHwDevExt->VPro.VPRO_SUBP_PALETTE( paldata );
  2829. pHwDevExt->CPgd.CPGD_SUBP_PALETTE( paldata );
  2830. }
  2831. break;
  2832. case KSPROPERTY_DVDSUBPIC_HLI:
  2833. {
  2834. //h DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDSUBPIC_HLI\r\n") );
  2835. PKSPROPERTY_SPHLI phli;
  2836. phli = (PKSPROPERTY_SPHLI)pSrb->CommandData.PropertyInfo->PropertyInfo;
  2837. pHwDevExt->hli = *phli;
  2838. decHighlight( pHwDevExt, phli );
  2839. }
  2840. break;
  2841. case KSPROPERTY_DVDSUBPIC_COMPOSIT_ON:
  2842. // DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDSUBPIC_COMPOSIT_ON\r\n") );
  2843. if( *((PKSPROPERTY_COMPOSIT_ON)pSrb->CommandData.PropertyInfo->PropertyInfo )) {
  2844. DebugPrint(( DebugLevelTrace, "TOSDVD: COMPOSIT_ON\r\n" ));
  2845. //--- 97.09.12 K.Chujo; bug fix
  2846. // pHwDevExt->VPro.SUBP_HLITE_ON();
  2847. pHwDevExt->VPro.SUBP_MUTE_OFF();
  2848. //--- End.
  2849. pHwDevExt->SubpicMute = FALSE;
  2850. }
  2851. else {
  2852. DebugPrint(( DebugLevelTrace, "TOSDVD: COMPOSIT_OFF\r\n" ));
  2853. //--- 97.09.12 K.Chujo; bug fix
  2854. // pHwDevExt->VPro.SUBP_HLITE_OFF();
  2855. pHwDevExt->VPro.SUBP_MUTE_ON();
  2856. //--- End.
  2857. pHwDevExt->SubpicMute = TRUE;
  2858. }
  2859. break;
  2860. default:
  2861. DebugPrint( (DebugLevelTrace, "TOSDVD: PropertySetID 0 default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->Property->Id, pSrb->CommandData.PropertyInfo->Property->Id ) );
  2862. TRAP;
  2863. break;
  2864. }
  2865. break;
  2866. case 1:
  2867. SetCppProperty( pSrb );
  2868. break;
  2869. //--- 97.09.24 K.Chujo
  2870. case 2:
  2871. DebugPrint( (DebugLevelTrace, "TOSDVD: SetSubpicProperty 2\r\n") );
  2872. SetSubpicRateChange( pSrb );
  2873. break;
  2874. //--- End.
  2875. default:
  2876. DebugPrint( (DebugLevelTrace, "TOSDVD: SetVideoProperty-default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->PropertySetID, pSrb->CommandData.PropertyInfo->PropertySetID ) );
  2877. TRAP;
  2878. break;
  2879. }
  2880. }
  2881. void GetVpeProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  2882. {
  2883. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  2884. DWORD dwInputBufferSize;
  2885. DWORD dwOutputBufferSize;
  2886. DWORD dwNumConnectInfo = 2;
  2887. DWORD dwNumVideoFormat = 1;
  2888. DWORD dwFieldWidth = 720;
  2889. DWORD dwFieldHeight = 240;
  2890. // the pointers to which the input buffer will be cast to
  2891. LPDDVIDEOPORTCONNECT pConnectInfo;
  2892. LPDDPIXELFORMAT pVideoFormat;
  2893. PKSVPMAXPIXELRATE pMaxPixelRate;
  2894. PKS_AMVPDATAINFO pVpdata;
  2895. // LPAMSCALINGINFO pScaleFactor;
  2896. //
  2897. // NOTE: ABSOLUTELY DO NOT use pmulitem, until it is determined that
  2898. // the stream property descriptor describes a multiple item, or you will
  2899. // pagefault.
  2900. //
  2901. PKSMULTIPLE_ITEM pmulitem =
  2902. &(((PKSMULTIPLE_DATA_PROP)pSrb->CommandData.PropertyInfo->Property)->MultipleItem);
  2903. //
  2904. // NOTE: same goes for this one as above.
  2905. //
  2906. // PKS_AMVPSIZE pdim = &(((PKSVPSIZE_PROP)pSrb->CommandData.PropertyInfo->Property)->Size);
  2907. if( pSrb->CommandData.PropertyInfo->PropertySetID ) {
  2908. TRAP;
  2909. pSrb->Status = STATUS_NO_MATCH;
  2910. return;
  2911. }
  2912. dwInputBufferSize = pSrb->CommandData.PropertyInfo->PropertyInputSize;
  2913. dwOutputBufferSize = pSrb->CommandData.PropertyInfo->PropertyOutputSize;
  2914. pSrb->Status = STATUS_SUCCESS;
  2915. switch( pSrb->CommandData.PropertyInfo->Property->Id ) {
  2916. case KSPROPERTY_VPCONFIG_NUMCONNECTINFO:
  2917. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_NUMCONNECTINFO\r\n") );
  2918. // check that the size of the output buffer is correct
  2919. ASSERT(dwInputBufferSize >= sizeof(DWORD));
  2920. pSrb->ActualBytesTransferred = sizeof(DWORD);
  2921. *(PULONG) pSrb->CommandData.PropertyInfo->PropertyInfo
  2922. = dwNumConnectInfo;
  2923. break;
  2924. case KSPROPERTY_VPCONFIG_NUMVIDEOFORMAT:
  2925. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_NUMVIDEOFORMAT\r\n") );
  2926. // check that the size of the output buffer is correct
  2927. ASSERT(dwInputBufferSize >= sizeof(DWORD));
  2928. pSrb->ActualBytesTransferred = sizeof(DWORD);
  2929. *(PULONG) pSrb->CommandData.PropertyInfo->PropertyInfo
  2930. = dwNumVideoFormat;
  2931. break;
  2932. case KSPROPERTY_VPCONFIG_GETCONNECTINFO:
  2933. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_GETCONNECTINFO\r\n") );
  2934. if (pmulitem->Count > dwNumConnectInfo ||
  2935. pmulitem->Size != sizeof (DDVIDEOPORTCONNECT) ||
  2936. dwOutputBufferSize <
  2937. (pmulitem->Count * sizeof (DDVIDEOPORTCONNECT)))
  2938. {
  2939. DebugPrint(( DebugLevelTrace, "TOSDVD: pmulitem->Count %d\r\n", pmulitem->Count ));
  2940. DebugPrint(( DebugLevelTrace, "TOSDVD: pmulitem->Size %d\r\n", pmulitem->Size ));
  2941. DebugPrint(( DebugLevelTrace, "TOSDVD: dwOutputBufferSize %d\r\n", dwOutputBufferSize ));
  2942. DebugPrint(( DebugLevelTrace, "TOSDVD: sizeof(DDVIDEOPORTCONNECT) %d\r\n", sizeof(DDVIDEOPORTCONNECT) ));
  2943. TRAP;
  2944. //
  2945. // buffer size is invalid, so error the call
  2946. //
  2947. pSrb->Status = STATUS_INVALID_BUFFER_SIZE;
  2948. return;
  2949. }
  2950. //
  2951. // specify the number of bytes written
  2952. //
  2953. pSrb->ActualBytesTransferred = pmulitem->Count*sizeof(DDVIDEOPORTCONNECT);
  2954. pConnectInfo = (LPDDVIDEOPORTCONNECT)(pSrb->CommandData.PropertyInfo->PropertyInfo);
  2955. // S3
  2956. pConnectInfo->dwSize = sizeof (DDVIDEOPORTCONNECT);
  2957. pConnectInfo->dwPortWidth = 8;
  2958. pConnectInfo->guidTypeID = g_S3Guid;
  2959. pConnectInfo->dwFlags = 0x3F;
  2960. pConnectInfo->dwReserved1 = 0;
  2961. pConnectInfo++;
  2962. // ATI
  2963. pConnectInfo->dwSize = sizeof (DDVIDEOPORTCONNECT);
  2964. pConnectInfo->dwPortWidth = 8;
  2965. pConnectInfo->guidTypeID = g_ATIGuid;
  2966. pConnectInfo->dwFlags = 0x4;
  2967. pConnectInfo->dwReserved1 = 0;
  2968. break;
  2969. case KSPROPERTY_VPCONFIG_VPDATAINFO:
  2970. DebugPrint(( DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_VPDATAINFO\r\n" ));
  2971. //
  2972. // specify the number of bytes written
  2973. //
  2974. pSrb->ActualBytesTransferred = sizeof(KS_AMVPDATAINFO);
  2975. //
  2976. // cast the buffer to the porper type
  2977. //
  2978. pVpdata = (PKS_AMVPDATAINFO)pSrb->CommandData.PropertyInfo->PropertyInfo;
  2979. *pVpdata = pHwDevExt->VPFmt;
  2980. pVpdata->dwSize = sizeof (KS_AMVPDATAINFO);
  2981. pVpdata->dwMicrosecondsPerField = 17;
  2982. ASSERT( pVpdata->dwNumLinesInVREF == 0 );
  2983. pVpdata->dwNumLinesInVREF = 0;
  2984. if( pHwDevExt->VideoPort == 4 ) {
  2985. DebugPrint(( DebugLevelTrace, "TOSDVD: Set for S3 LPB\r\n" ));
  2986. // S3 LPB
  2987. pVpdata->bEnableDoubleClock = FALSE;
  2988. pVpdata->bEnableVACT = FALSE;
  2989. pVpdata->bDataIsInterlaced = TRUE;
  2990. pVpdata->lHalfLinesOdd = 0;
  2991. pVpdata->lHalfLinesEven = 0;
  2992. pVpdata->bFieldPolarityInverted = FALSE;
  2993. pVpdata->amvpDimInfo.dwFieldWidth = 720 + 158/2;
  2994. pVpdata->amvpDimInfo.dwFieldHeight = 240 + 1;
  2995. pVpdata->amvpDimInfo.rcValidRegion.left = 158/2;
  2996. pVpdata->amvpDimInfo.rcValidRegion.top = 1;
  2997. pVpdata->amvpDimInfo.rcValidRegion.right = 720 + 158/2 - 4;
  2998. pVpdata->amvpDimInfo.rcValidRegion.bottom = 240 + 1;
  2999. pVpdata->amvpDimInfo.dwVBIWidth = pVpdata->amvpDimInfo.dwFieldWidth;
  3000. pVpdata->amvpDimInfo.dwVBIHeight = pVpdata->amvpDimInfo.rcValidRegion.top;
  3001. }
  3002. else if( pHwDevExt->VideoPort == 7 ) {
  3003. DebugPrint(( DebugLevelTrace, "TOSDVD: Set for ATI AMC\r\n" ));
  3004. // ATI AMC
  3005. pVpdata->bEnableDoubleClock = FALSE;
  3006. pVpdata->bEnableVACT = FALSE;
  3007. pVpdata->bDataIsInterlaced = TRUE;
  3008. pVpdata->lHalfLinesOdd = 1;
  3009. pVpdata->lHalfLinesEven = 0;
  3010. pVpdata->bFieldPolarityInverted = FALSE;
  3011. pVpdata->amvpDimInfo.dwFieldWidth = 720;
  3012. pVpdata->amvpDimInfo.dwFieldHeight = 240 + 2;
  3013. pVpdata->amvpDimInfo.rcValidRegion.left = 0;
  3014. pVpdata->amvpDimInfo.rcValidRegion.top = 2;
  3015. pVpdata->amvpDimInfo.rcValidRegion.right = 720 - 8;
  3016. pVpdata->amvpDimInfo.rcValidRegion.bottom = 240 + 2;
  3017. pVpdata->amvpDimInfo.dwVBIWidth = pVpdata->amvpDimInfo.dwFieldWidth;
  3018. pVpdata->amvpDimInfo.dwVBIHeight = pVpdata->amvpDimInfo.rcValidRegion.top;
  3019. }
  3020. else
  3021. TRAP;
  3022. break ;
  3023. case KSPROPERTY_VPCONFIG_MAXPIXELRATE:
  3024. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_MAXPIXELRATE\r\n") );
  3025. //
  3026. // NOTE:
  3027. // this property is special. And has another different
  3028. // input property!
  3029. //
  3030. if (dwInputBufferSize < sizeof (KSVPSIZE_PROP))
  3031. {
  3032. TRAP;
  3033. pSrb->Status = STATUS_INVALID_BUFFER_SIZE;
  3034. return;
  3035. }
  3036. pSrb->ActualBytesTransferred = sizeof(KSVPMAXPIXELRATE);
  3037. // cast the buffer to the porper type
  3038. pMaxPixelRate = (PKSVPMAXPIXELRATE)pSrb->CommandData.PropertyInfo->PropertyInfo;
  3039. // tell the app that the pixel rate is valid for these dimensions
  3040. pMaxPixelRate->Size.dwWidth = dwFieldWidth;
  3041. pMaxPixelRate->Size.dwHeight = dwFieldHeight;
  3042. pMaxPixelRate->MaxPixelsPerSecond = 1300;
  3043. break;
  3044. case KSPROPERTY_VPCONFIG_INFORMVPINPUT:
  3045. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  3046. break ;
  3047. case KSPROPERTY_VPCONFIG_GETVIDEOFORMAT:
  3048. DebugPrint(( DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_GETVIDEOFORMAT\r\n" ));
  3049. //
  3050. // check that the size of the output buffer is correct
  3051. //
  3052. if (pmulitem->Count > dwNumConnectInfo ||
  3053. pmulitem->Size != sizeof (DDPIXELFORMAT) ||
  3054. dwOutputBufferSize <
  3055. (pmulitem->Count * sizeof (DDPIXELFORMAT)))
  3056. {
  3057. DebugPrint(( DebugLevelTrace, "TOSDVD: pmulitem->Count %d\r\n", pmulitem->Count ));
  3058. DebugPrint(( DebugLevelTrace, "TOSDVD: pmulitem->Size %d\r\n", pmulitem->Size ));
  3059. DebugPrint(( DebugLevelTrace, "TOSDVD: dwOutputBufferSize %d\r\n", dwOutputBufferSize ));
  3060. DebugPrint(( DebugLevelTrace, "TOSDVD: sizeof(DDPIXELFORMAT) %d\r\n", sizeof(DDPIXELFORMAT) ));
  3061. TRAP;
  3062. //
  3063. // buffer size is invalid, so error the call
  3064. //
  3065. pSrb->Status = STATUS_INVALID_BUFFER_SIZE;
  3066. return;
  3067. }
  3068. //
  3069. // specify the number of bytes written
  3070. //
  3071. pSrb->ActualBytesTransferred = pmulitem->Count*sizeof(DDPIXELFORMAT);
  3072. pVideoFormat = (LPDDPIXELFORMAT)(pSrb->CommandData.PropertyInfo->PropertyInfo);
  3073. if( pHwDevExt->VideoPort == 4 ) {
  3074. DebugPrint(( DebugLevelTrace, "TOSDVD: Set for S3 LPB\r\n" ));
  3075. // S3 LPB
  3076. pVideoFormat->dwSize= sizeof (DDPIXELFORMAT);
  3077. pVideoFormat->dwFlags = DDPF_FOURCC;
  3078. pVideoFormat->dwFourCC = MKFOURCC( 'Y', 'U', 'Y', '2' );
  3079. pVideoFormat->dwYUVBitCount = 16;
  3080. }
  3081. else if( pHwDevExt->VideoPort == 7 ) {
  3082. DebugPrint(( DebugLevelTrace, "TOSDVD: Set for ATI AMC\r\n" ));
  3083. // ATI AMC
  3084. pVideoFormat->dwSize= sizeof (DDPIXELFORMAT);
  3085. pVideoFormat->dwFlags = DDPF_FOURCC;
  3086. pVideoFormat->dwYUVBitCount = 16;
  3087. pVideoFormat->dwFourCC = MKFOURCC( 'U', 'Y', 'V', 'Y' );
  3088. // Not needed?
  3089. pVideoFormat->dwYBitMask = (DWORD)0xFF00FF00;
  3090. pVideoFormat->dwUBitMask = (DWORD)0x000000FF;
  3091. pVideoFormat->dwVBitMask = (DWORD)0x00FF0000;
  3092. }
  3093. else
  3094. TRAP;
  3095. break;
  3096. case KSPROPERTY_VPCONFIG_DECIMATIONCAPABILITY:
  3097. //
  3098. // indicate that we can decimate anything, especially if it's late.
  3099. //
  3100. pSrb->ActualBytesTransferred = sizeof (BOOL);
  3101. *((PBOOL)pSrb->CommandData.PropertyInfo->PropertyInfo) = TRUE;
  3102. break;
  3103. default:
  3104. DebugPrint( (DebugLevelTrace, "TOSDVD: PropertySetID 0 default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->Property->Id, pSrb->CommandData.PropertyInfo->Property->Id ) );
  3105. TRAP;
  3106. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  3107. break;
  3108. }
  3109. }
  3110. void SetVpeProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  3111. {
  3112. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  3113. DWORD dwInputBufferSize;
  3114. DWORD dwOutputBufferSize;
  3115. DWORD *lpdwOutputBufferSize;
  3116. ULONG index;
  3117. PKS_AMVPSIZE pDim;
  3118. if( pSrb->CommandData.PropertyInfo->PropertySetID ) {
  3119. TRAP;
  3120. pSrb->Status = STATUS_NO_MATCH;
  3121. return;
  3122. }
  3123. dwInputBufferSize = pSrb->CommandData.PropertyInfo->PropertyInputSize;
  3124. dwOutputBufferSize = pSrb->CommandData.PropertyInfo->PropertyOutputSize;
  3125. lpdwOutputBufferSize = &(pSrb->ActualBytesTransferred);
  3126. pSrb->Status = STATUS_SUCCESS;
  3127. switch( pSrb->CommandData.PropertyInfo->Property->Id ) {
  3128. case KSPROPERTY_VPCONFIG_SETCONNECTINFO:
  3129. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_SETCONNECTINFO\r\n") );
  3130. //
  3131. // pSrb->CommandData.PropertInfo->PropertyInfo
  3132. // points to a ULONG which is an index into the array of
  3133. // connectinfo structs returned to the caller from the
  3134. // Get call to ConnectInfo.
  3135. //
  3136. // Since the sample only supports one connection type right
  3137. // now, we will ensure that the requested index is 0.
  3138. //
  3139. //
  3140. // at this point, we would program the hardware to use
  3141. // the right connection information for the videoport.
  3142. // since we are only supporting one connection, we don't
  3143. // need to do anything, so we will just indicate success
  3144. //
  3145. index = *((ULONG *)(pSrb->CommandData.PropertyInfo->PropertyInfo));
  3146. DebugPrint(( DebugLevelTrace, "TOSDVD: %d\r\n", index ));
  3147. if( index == 0 ) {
  3148. pHwDevExt->VideoPort = 4; // S3 LPB
  3149. pHwDevExt->DAck.PCIF_SET_DIGITAL_OUT( pHwDevExt->VideoPort );
  3150. }
  3151. else if( index == 1 ) {
  3152. pHwDevExt->VideoPort = 7; // ATI AMC
  3153. pHwDevExt->DAck.PCIF_SET_DIGITAL_OUT( pHwDevExt->VideoPort );
  3154. }
  3155. else
  3156. TRAP;
  3157. break;
  3158. case KSPROPERTY_VPCONFIG_DDRAWHANDLE:
  3159. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_DDRAWHANDLE\r\n") );
  3160. pHwDevExt->ddrawHandle =
  3161. (*(PULONG)pSrb->CommandData.PropertyInfo->PropertyInfo);
  3162. break;
  3163. case KSPROPERTY_VPCONFIG_VIDEOPORTID:
  3164. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_VIDEOPORTID\r\n") );
  3165. pHwDevExt->VidPortID =
  3166. (*(PULONG)pSrb->CommandData.PropertyInfo->PropertyInfo);
  3167. break;
  3168. case KSPROPERTY_VPCONFIG_DDRAWSURFACEHANDLE:
  3169. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_DDRAWSURFACEHANDLE\r\n") );
  3170. pHwDevExt->SurfaceHandle =
  3171. (*(PULONG)pSrb->CommandData.PropertyInfo->PropertyInfo);
  3172. break;
  3173. case KSPROPERTY_VPCONFIG_SETVIDEOFORMAT:
  3174. DebugPrint(( DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_SETVIDEOFORMAT\r\n" ));
  3175. //
  3176. // pSrb->CommandData.PropertInfo->PropertyInfo
  3177. // points to a ULONG which is an index into the array of
  3178. // VIDEOFORMAT structs returned to the caller from the
  3179. // Get call to FORMATINFO
  3180. //
  3181. // Since the sample only supports one FORMAT type right
  3182. // now, we will ensure that the requested index is 0.
  3183. //
  3184. //
  3185. // at this point, we would program the hardware to use
  3186. // the right connection information for the videoport.
  3187. // since we are only supporting one connection, we don't
  3188. // need to do anything, so we will just indicate success
  3189. //
  3190. index = *((ULONG *)(pSrb->CommandData.PropertyInfo->PropertyInfo));
  3191. DebugPrint(( DebugLevelTrace, "TOSDVD: %d\r\n", index ));
  3192. break;
  3193. case KSPROPERTY_VPCONFIG_INFORMVPINPUT:
  3194. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_INFORMVPINPUT\r\n") );
  3195. //
  3196. // These are the preferred formats for the VPE client
  3197. //
  3198. // they are multiple properties passed in, return success
  3199. //
  3200. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  3201. break;
  3202. case KSPROPERTY_VPCONFIG_INVERTPOLARITY:
  3203. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_INVERTPOLARITY\r\n") );
  3204. //
  3205. // Toggles the global polarity flag, telling the output
  3206. // of the VPE port to be inverted. Since this hardware
  3207. // does not support this feature, we will just return
  3208. // success for now, although this should be returning not
  3209. // implemented
  3210. //
  3211. break;
  3212. case KSPROPERTY_VPCONFIG_SCALEFACTOR:
  3213. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_VPCONFIG_SCALEFACTOR\r\n") );
  3214. //
  3215. // the sizes for the scaling factor are passed in, and the
  3216. // image dimensions should be scaled appropriately
  3217. //
  3218. //
  3219. // if there is a horizontal scaling available, do it here.
  3220. //
  3221. TRAP;
  3222. pDim =(PKS_AMVPSIZE)(pSrb->CommandData.PropertyInfo->PropertyInfo);
  3223. break;
  3224. default:
  3225. DebugPrint( (DebugLevelTrace, "TOSDVD: PropertySetID 0 default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->Property->Id, pSrb->CommandData.PropertyInfo->Property->Id ) );
  3226. TRAP;
  3227. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  3228. break;
  3229. }
  3230. }
  3231. void GetCCProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  3232. {
  3233. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  3234. if( pSrb->CommandData.PropertyInfo->PropertySetID ) {
  3235. TRAP;
  3236. pSrb->Status = STATUS_NO_MATCH;
  3237. return;
  3238. }
  3239. PKSALLOCATOR_FRAMING pfrm = (PKSALLOCATOR_FRAMING)
  3240. pSrb->CommandData.PropertyInfo->PropertyInfo;
  3241. PKSSTATE State;
  3242. pSrb->Status = STATUS_SUCCESS;
  3243. switch( pSrb->CommandData.PropertyInfo->Property->Id ) {
  3244. case KSPROPERTY_CONNECTION_ALLOCATORFRAMING:
  3245. DebugPrint(( DebugLevelTrace, "TOSDVD: KSPROPERTY_CONNECTION_ALLOCATORFRAMING\r\n" ));
  3246. pfrm->OptionsFlags = 0;
  3247. pfrm->PoolType = NonPagedPool;
  3248. pfrm->Frames = 10;
  3249. pfrm->FrameSize = 200;
  3250. pfrm->FileAlignment = 0;
  3251. pfrm->Reserved = 0;
  3252. pSrb->ActualBytesTransferred = sizeof( KSALLOCATOR_FRAMING );
  3253. break;
  3254. case KSPROPERTY_CONNECTION_STATE:
  3255. DebugPrint(( DebugLevelTrace, "TOSDVD: KSPROPERTY_CONNECTION_STATE\r\n" ));
  3256. State = (PKSSTATE) pSrb->CommandData.PropertyInfo->PropertyInfo;
  3257. pSrb->ActualBytesTransferred = sizeof( State );
  3258. // A very odd rule:
  3259. // When transitioning from stop to pause, DShow tries to preroll
  3260. // the graph. Capture sources can't preroll, and indicate this
  3261. // by returning VFW_S_CANT_CUE in user mode. To indicate this
  3262. // condition from drivers, they must return ERROR_NO_DATA_DETECTED
  3263. *State = ((PSTREAMEX)(pHwDevExt->pstroCC->HwStreamExtension))->state;
  3264. if( ((PSTREAMEX)pHwDevExt->pstroCC->HwStreamExtension)->state == KSSTATE_PAUSE ) {
  3265. //
  3266. // wierd stuff for capture type state change. When you transition
  3267. // from stop to pause, we need to indicate that this device cannot
  3268. // preroll, and has no data to send.
  3269. //
  3270. pSrb->Status = STATUS_NO_DATA_DETECTED;
  3271. }
  3272. break;
  3273. default:
  3274. DebugPrint(( DebugLevelTrace, "TOSDVD: PropertySetID 0 default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->Property->Id, pSrb->CommandData.PropertyInfo->Property->Id ));
  3275. TRAP;
  3276. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  3277. break;
  3278. }
  3279. }
  3280. void SetCCProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  3281. {
  3282. TRAP;
  3283. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  3284. return;
  3285. }
  3286. void GetCppProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb, LONG strm )
  3287. {
  3288. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  3289. BOOLEAN bStatus;
  3290. DebugPrint( (DebugLevelTrace, "TOSDVD: GetCppProperty\r\n") );
  3291. DWORD *lpdwOutputBufferSize;
  3292. lpdwOutputBufferSize = &(pSrb->ActualBytesTransferred);
  3293. switch( pSrb->CommandData.PropertyInfo->Property->Id )
  3294. {
  3295. case KSPROPERTY_DVDCOPY_CHLG_KEY:
  3296. {
  3297. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_CHLG_KEY\r\n") );
  3298. PKS_DVDCOPY_CHLGKEY pChlgKey;
  3299. pChlgKey = (PKS_DVDCOPY_CHLGKEY)pSrb->CommandData.PropertyInfo->PropertyInfo;
  3300. bStatus = pHwDevExt->CPro.decoder_challenge( pChlgKey );
  3301. if( !bStatus ) {
  3302. DebugPrint( (DebugLevelTrace, "TOSDVD: CPro Status Error!!\r\n") );
  3303. TRAP;
  3304. }
  3305. DebugPrint( (DebugLevelTrace, "TOSDVD: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\r\n",
  3306. pChlgKey->ChlgKey[0], pChlgKey->ChlgKey[1], pChlgKey->ChlgKey[2], pChlgKey->ChlgKey[3], pChlgKey->ChlgKey[4],
  3307. pChlgKey->ChlgKey[5], pChlgKey->ChlgKey[6], pChlgKey->ChlgKey[7], pChlgKey->ChlgKey[8], pChlgKey->ChlgKey[9]
  3308. ) );
  3309. *lpdwOutputBufferSize = sizeof(KS_DVDCOPY_CHLGKEY);
  3310. }
  3311. pSrb->Status = STATUS_SUCCESS;
  3312. break;
  3313. case KSPROPERTY_DVDCOPY_DVD_KEY1:
  3314. {
  3315. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_DVD_KEY1\r\n") );
  3316. TRAP;
  3317. }
  3318. pSrb->Status = STATUS_SUCCESS;
  3319. break;
  3320. case KSPROPERTY_DVDCOPY_DEC_KEY2:
  3321. {
  3322. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_DEC_KEY2\r\n") );
  3323. PKS_DVDCOPY_BUSKEY pBusKey;
  3324. pBusKey = (PKS_DVDCOPY_BUSKEY)pSrb->CommandData.PropertyInfo->PropertyInfo;
  3325. bStatus = pHwDevExt->CPro.decoder_bus( pBusKey );
  3326. if( !bStatus ) {
  3327. DebugPrint( (DebugLevelTrace, "TOSDVD: CPro Status Error!!\r\n") );
  3328. TRAP;
  3329. }
  3330. DebugPrint( (DebugLevelTrace, "TOSDVD: %02x %02x %02x %02x %02x\r\n",
  3331. pBusKey->BusKey[0], pBusKey->BusKey[1], pBusKey->BusKey[2], pBusKey->BusKey[3], pBusKey->BusKey[4]
  3332. ) );
  3333. *lpdwOutputBufferSize = sizeof(KS_DVDCOPY_BUSKEY);
  3334. }
  3335. pSrb->Status = STATUS_SUCCESS;
  3336. break;
  3337. case KSPROPERTY_DVDCOPY_TITLE_KEY:
  3338. {
  3339. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_TITLE_KEY\r\n") );
  3340. TRAP;
  3341. }
  3342. pSrb->Status = STATUS_SUCCESS;
  3343. break;
  3344. case KSPROPERTY_DVDCOPY_DISC_KEY:
  3345. {
  3346. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_DISC_KEY\r\n") );
  3347. TRAP;
  3348. }
  3349. pSrb->Status = STATUS_SUCCESS;
  3350. break;
  3351. case KSPROPERTY_DVDCOPY_SET_COPY_STATE:
  3352. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_SET_COPY_STATE\r\n") );
  3353. if( pHwDevExt->lCPPStrm == -1 || pHwDevExt->lCPPStrm == strm ) {
  3354. pHwDevExt->lCPPStrm = strm;
  3355. DebugPrint(( DebugLevelTrace, "TOSDVD: return REQUIRED\r\n" ));
  3356. ((PKS_DVDCOPY_SET_COPY_STATE)(pSrb->CommandData.PropertyInfo->PropertyInfo))->DVDCopyState
  3357. = KS_DVDCOPYSTATE_AUTHENTICATION_REQUIRED;
  3358. }
  3359. else {
  3360. DebugPrint(( DebugLevelTrace, "TOSDVD: return NOT REQUIRED\r\n" ));
  3361. ((PKS_DVDCOPY_SET_COPY_STATE)(pSrb->CommandData.PropertyInfo->PropertyInfo))->DVDCopyState
  3362. = KS_DVDCOPYSTATE_AUTHENTICATION_NOT_REQUIRED;
  3363. }
  3364. pSrb->ActualBytesTransferred = sizeof( KS_DVDCOPY_SET_COPY_STATE );
  3365. pSrb->Status = STATUS_SUCCESS;
  3366. break;
  3367. // case KSPROPERTY_DVDCOPY_REGION:
  3368. //
  3369. // DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_REGION\r\n") );
  3370. //
  3371. // //
  3372. // // indicate region 1 for US content
  3373. // //
  3374. //
  3375. // ((PKS_DVDCOPY_REGION)(pSrb->CommandData.PropertyInfo->PropertyInfo))->RegionData
  3376. // = 0x1;
  3377. //
  3378. // pSrb->ActualBytesTransferred = sizeof (KS_DVDCOPY_REGION);
  3379. // pSrb->Status = STATUS_SUCCESS;
  3380. //
  3381. // break;
  3382. default:
  3383. {
  3384. DebugPrint( (DebugLevelTrace, "TOSDVD: PropertySetID 1 default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->Property->Id, pSrb->CommandData.PropertyInfo->Property->Id ) );
  3385. TRAP;
  3386. }
  3387. pSrb->Status = STATUS_SUCCESS;
  3388. break;
  3389. }
  3390. }
  3391. void SetCppProperty( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  3392. {
  3393. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  3394. BOOLEAN bStatus;
  3395. DebugPrint( (DebugLevelTrace, "TOSDVD: SetCppProperty\r\n") );
  3396. switch( pSrb->CommandData.PropertyInfo->Property->Id )
  3397. {
  3398. case KSPROPERTY_DVDCOPY_CHLG_KEY:
  3399. {
  3400. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_CHLG_KEY\r\n") );
  3401. PKS_DVDCOPY_CHLGKEY pChlgKey;
  3402. pChlgKey = (PKS_DVDCOPY_CHLGKEY)pSrb->CommandData.PropertyInfo->PropertyInfo;
  3403. DebugPrint( (DebugLevelTrace, "TOSDVD: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\r\n",
  3404. pChlgKey->ChlgKey[0], pChlgKey->ChlgKey[1], pChlgKey->ChlgKey[2], pChlgKey->ChlgKey[3], pChlgKey->ChlgKey[4],
  3405. pChlgKey->ChlgKey[5], pChlgKey->ChlgKey[6], pChlgKey->ChlgKey[7], pChlgKey->ChlgKey[8], pChlgKey->ChlgKey[9]
  3406. ) );
  3407. bStatus = pHwDevExt->CPro.drive_challenge( pChlgKey );
  3408. ASSERTMSG( "\r\n...CPro Status Error!!( drive_challenge )", bStatus );
  3409. }
  3410. pSrb->Status = STATUS_SUCCESS;
  3411. break;
  3412. case KSPROPERTY_DVDCOPY_DVD_KEY1:
  3413. {
  3414. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_DVD_KEY1\r\n") );
  3415. PKS_DVDCOPY_BUSKEY pBusKey;
  3416. pBusKey = (PKS_DVDCOPY_BUSKEY)pSrb->CommandData.PropertyInfo->PropertyInfo;
  3417. DebugPrint( (DebugLevelTrace, "TOSDVD: %02x %02x %02x %02x %02x\r\n",
  3418. pBusKey->BusKey[0], pBusKey->BusKey[1], pBusKey->BusKey[2], pBusKey->BusKey[3], pBusKey->BusKey[4]
  3419. ) );
  3420. bStatus = pHwDevExt->CPro.drive_bus( pBusKey );
  3421. ASSERTMSG( "\r\n...CPro Status Error!!( drive_bus )", bStatus );
  3422. }
  3423. pSrb->Status = STATUS_SUCCESS;
  3424. break;
  3425. case KSPROPERTY_DVDCOPY_DEC_KEY2:
  3426. {
  3427. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_DEC_KEY2\r\n") );
  3428. TRAP;
  3429. }
  3430. pSrb->Status = STATUS_SUCCESS;
  3431. break;
  3432. case KSPROPERTY_DVDCOPY_TITLE_KEY:
  3433. {
  3434. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_TITLE_KEY\r\n") );
  3435. PKS_DVDCOPY_TITLEKEY pTitleKey;
  3436. pTitleKey = (PKS_DVDCOPY_TITLEKEY)pSrb->CommandData.PropertyInfo->PropertyInfo;
  3437. DebugPrint( (DebugLevelTrace, "TOSDVD: %02x, %02x %02x %02x %02x %02x\r\n",
  3438. pTitleKey->KeyFlags, pTitleKey->TitleKey[0], pTitleKey->TitleKey[1], pTitleKey->TitleKey[2], pTitleKey->TitleKey[3], pTitleKey->TitleKey[4]
  3439. ) );
  3440. bStatus = pHwDevExt->CPro.TitleKey( pTitleKey );
  3441. ASSERTMSG( "\r\n...CPro Status Error!!( TitleKey )", bStatus );
  3442. // Set CGMS for Digital Audio Copy Guard & NTSC Analog Copy Guard
  3443. {
  3444. ULONG cgms = (pTitleKey->KeyFlags & 0x30) >> 4;
  3445. // for Digital Audio Copy Guard
  3446. pHwDevExt->AudioCgms = cgms;
  3447. pHwDevExt->ADec.SetParam(
  3448. pHwDevExt->AudioMode,
  3449. pHwDevExt->AudioFreq,
  3450. pHwDevExt->AudioType,
  3451. pHwDevExt->AudioCgms,
  3452. &pHwDevExt->DAck
  3453. );
  3454. pHwDevExt->ADec.AUDIO_ZR38521_REPEAT_16();
  3455. pHwDevExt->ADec.AUDIO_TC9425_INIT_DIGITAL();
  3456. pHwDevExt->ADec.AUDIO_TC9425_INIT_ANALOG();
  3457. // for NTSC Analog Copy Guard
  3458. pHwDevExt->CPgd.CPGD_SET_CGMS( cgms );
  3459. }
  3460. }
  3461. pSrb->Status = STATUS_SUCCESS;
  3462. break;
  3463. case KSPROPERTY_DVDCOPY_DISC_KEY:
  3464. {
  3465. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_DISC_KEY\r\n") );
  3466. PKS_DVDCOPY_DISCKEY pDiscKey;
  3467. pDiscKey = (PKS_DVDCOPY_DISCKEY)pSrb->CommandData.PropertyInfo->PropertyInfo;
  3468. bStatus = pHwDevExt->CPro.DiscKeyStart();
  3469. ASSERTMSG( "\r\n...CPro Status Error!!( DiscKeyStart )", bStatus );
  3470. DebugPrint( (DebugLevelTrace, "TOSDVD: %02x %02x %02x %02x %02x %02x %02x %02x ...\r\n",
  3471. pDiscKey->DiscKey[0], pDiscKey->DiscKey[1], pDiscKey->DiscKey[2], pDiscKey->DiscKey[3],
  3472. pDiscKey->DiscKey[4], pDiscKey->DiscKey[5], pDiscKey->DiscKey[6], pDiscKey->DiscKey[7]
  3473. ) );
  3474. DMAxferKeyData(
  3475. pHwDevExt,
  3476. pSrb,
  3477. pDiscKey->DiscKey,
  3478. 2048,
  3479. (PHW_TIMER_ROUTINE)EndKeyData );
  3480. }
  3481. pSrb->Status = STATUS_PENDING;
  3482. break;
  3483. case KSPROPERTY_DVDCOPY_SET_COPY_STATE:
  3484. {
  3485. DebugPrint( (DebugLevelTrace, "TOSDVD: KSPROPERTY_DVDCOPY_SET_COPY_STATE\r\n") );
  3486. PKS_DVDCOPY_SET_COPY_STATE pCopyState;
  3487. pCopyState = (PKS_DVDCOPY_SET_COPY_STATE)pSrb->CommandData.PropertyInfo->PropertyInfo;
  3488. if( pCopyState->DVDCopyState == KS_DVDCOPYSTATE_INITIALIZE ) {
  3489. DebugPrint( (DebugLevelTrace, "TOSDVD: KS_DVDCOPYSTATE_INITIALIZE\r\n") );
  3490. ASSERT( !pHwDevExt->pSrbCpp );
  3491. pHwDevExt->pSrbCpp = pSrb;
  3492. pHwDevExt->bCppReset = TRUE;
  3493. pHwDevExt->CppFlagCount++;
  3494. DebugPrint(( DebugLevelTrace, "TOSDVD: CppFlagCount=%ld\r\n", pHwDevExt->CppFlagCount ));
  3495. if( pHwDevExt->CppFlagCount >= pHwDevExt->cOpenInputStream + 1 )
  3496. SetCppFlag( pHwDevExt );
  3497. pSrb->Status = STATUS_PENDING;
  3498. }
  3499. else if( pCopyState->DVDCopyState == KS_DVDCOPYSTATE_INITIALIZE_TITLE ) {
  3500. DebugPrint(( DebugLevelTrace, "TOSDVD: KS_DVDCOPYSTATE_INITIALIZE_TITLE\r\n" ));
  3501. pHwDevExt->CppFlagCount++;
  3502. if( pHwDevExt->CppFlagCount > pHwDevExt->cOpenInputStream + 1 ) {
  3503. pSrb->Status = STATUS_SUCCESS;
  3504. }
  3505. else {
  3506. ASSERT( !pHwDevExt->pSrbCpp );
  3507. pHwDevExt->pSrbCpp = pSrb;
  3508. pHwDevExt->bCppReset = FALSE;
  3509. DebugPrint(( DebugLevelTrace, "TOSDVD: CppFlagCount=%ld\r\n", pHwDevExt->CppFlagCount ));
  3510. if( pHwDevExt->CppFlagCount >= pHwDevExt->cOpenInputStream + 1 )
  3511. SetCppFlag( pHwDevExt );
  3512. pSrb->Status = STATUS_PENDING;
  3513. }
  3514. }
  3515. else {
  3516. DebugPrint( (DebugLevelTrace, "TOSDVD: DVDCOPYSTATE_DONE\r\n") );
  3517. pHwDevExt->CppFlagCount = 0;
  3518. pSrb->Status = STATUS_SUCCESS;
  3519. }
  3520. }
  3521. break;
  3522. default:
  3523. DebugPrint( (DebugLevelTrace, "TOSDVD: PropertySetID 1 default %d(0x%x)\r\n", pSrb->CommandData.PropertyInfo->Property->Id, pSrb->CommandData.PropertyInfo->Property->Id ) );
  3524. TRAP;
  3525. pSrb->Status = STATUS_SUCCESS;
  3526. break;
  3527. }
  3528. }
  3529. VOID STREAMAPI StreamClockRtn( IN PHW_TIME_CONTEXT TimeContext )
  3530. {
  3531. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)TimeContext->HwDeviceExtension;
  3532. ULONGLONG sysTime = GetSystemTime();
  3533. ULONG foo;
  3534. // DebugPrint( (DebugLevelTrace, "TOSDVD:StreamClockRtn\r\n") );
  3535. if( TimeContext->Function != TIME_GET_STREAM_TIME ) {
  3536. TRAP;
  3537. //
  3538. // should handle set onboard, and read onboard clock here.
  3539. //
  3540. // return FALSE;
  3541. return;
  3542. }
  3543. if (fClkPause) {
  3544. if( fProgrammed ) {
  3545. foo = pHwDevExt->VDec.VIDEO_GET_STCA();
  3546. LastStamp = ConvertPTStoStrm( foo );
  3547. if( pHwDevExt->RunMode == PLAY_MODE_FAST ) {
  3548. REFERENCE_TIME tmp;
  3549. tmp = (REFERENCE_TIME)pHwDevExt->dwSTCinPause * 1000 / 9;
  3550. if( tmp > pHwDevExt->StartTime ) {
  3551. LastStamp = (tmp - pHwDevExt->StartTime) * 10000/pHwDevExt->Rate + pHwDevExt->StartTime;
  3552. }
  3553. }
  3554. LastSys = LastSysTime = sysTime;
  3555. fValid = TRUE;
  3556. }
  3557. else {
  3558. LastStamp = 0;
  3559. LastSys = LastSysTime = sysTime;
  3560. }
  3561. TimeContext->Time = LastStamp;
  3562. TimeContext->SystemTime = sysTime;
  3563. DebugPrint(( DebugLevelTrace, "TOSDVD:Clk pause: 0x%x( 0x%s(100ns) )\r\n", ConvertStrmtoPTS(TimeContext->Time), DebugLLConvtoStr( TimeContext->Time, 16 ) ));
  3564. // return( TRUE );
  3565. return;
  3566. }
  3567. //
  3568. // update the clock 4 times a second, or once every 2500000 100 ns ticks
  3569. //
  3570. if( TRUE || (sysTime - LastSysTime) > 2500000 ) {
  3571. if( fProgrammed ) {
  3572. foo = pHwDevExt->VDec.VIDEO_GET_STCA();
  3573. LastStamp = ConvertPTStoStrm( foo );
  3574. if( pHwDevExt->RunMode == PLAY_MODE_FAST ) {
  3575. REFERENCE_TIME tmp;
  3576. tmp = (REFERENCE_TIME)foo * 1000 / 9;
  3577. if( tmp > pHwDevExt->StartTime ) {
  3578. LastStamp = (tmp - pHwDevExt->StartTime) * 10000/pHwDevExt->Rate + pHwDevExt->StartTime;
  3579. }
  3580. }
  3581. }
  3582. else {
  3583. LastStamp = ( sysTime - StartSys );
  3584. }
  3585. LastSys = LastSysTime = sysTime;
  3586. fValid = TRUE;
  3587. }
  3588. TimeContext->Time = LastStamp + ( sysTime - LastSysTime );
  3589. TimeContext->SystemTime = sysTime;
  3590. DebugPrint(( DebugLevelTrace, "TOSDVD:Clk : 0x%x( 0x%s(100ns) )\r\n", ConvertStrmtoPTS(TimeContext->Time), DebugLLConvtoStr( TimeContext->Time, 16 ) ));
  3591. return;
  3592. }
  3593. ULONGLONG GetSystemTime()
  3594. {
  3595. ULONGLONG ticks;
  3596. ULONGLONG rate;
  3597. ticks = (ULONGLONG)KeQueryPerformanceCounter((PLARGE_INTEGER)&rate).QuadPart;
  3598. //
  3599. // convert from ticks to 100ns clock
  3600. //
  3601. ticks = (ticks & 0xFFFFFFFF00000000) / rate * 10000000 +
  3602. (ticks & 0xFFFFFFFF) * 10000000 / rate;
  3603. return(ticks);
  3604. }
  3605. ULONGLONG ConvertPTStoStrm(ULONG pts)
  3606. {
  3607. ULONGLONG strm;
  3608. strm = (ULONGLONG)pts;
  3609. strm = ( strm * 10000 + 45 ) / 90;
  3610. return (strm);
  3611. }
  3612. //--- 97.09.22 K.Chujo
  3613. ULONG ConvertStrmtoPTS(ULONGLONG strm)
  3614. {
  3615. ULONGLONG pts;
  3616. pts = ( strm * 9 + 500 ) / 1000;
  3617. return ( (ULONG)pts );
  3618. }
  3619. //--- End.
  3620. void TimerCppReset( PHW_STREAM_REQUEST_BLOCK pSrb )
  3621. {
  3622. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  3623. BOOLEAN bStatus;
  3624. BOOL bQueStatus = FALSE;
  3625. // Temporary
  3626. if( pHwDevExt->pSrbCpp == NULL ) {
  3627. DebugPrint(( DebugLevelTrace, "TOSDVD: pSrbCpp is NULL!\r\n" ));
  3628. return;
  3629. }
  3630. if( pHwDevExt->PlayMode == PLAY_MODE_FAST || pHwDevExt->PlayMode == PLAY_MODE_SLOW ) {
  3631. bQueStatus = pHwDevExt->DevQue.isEmpty();
  3632. if( bQueStatus == FALSE ) {
  3633. StreamClassScheduleTimer(
  3634. NULL,
  3635. pHwDevExt,
  3636. 100000,
  3637. (PHW_TIMER_ROUTINE)TimerCppReset,
  3638. pSrb
  3639. );
  3640. DebugPrint( (DebugLevelTrace, "TOSDVD:Schedule TimerCppReset\r\n") );
  3641. return;
  3642. }
  3643. }
  3644. else if( pHwDevExt->DecodeStart ) {
  3645. StreamClassScheduleTimer(
  3646. NULL,
  3647. pHwDevExt,
  3648. 100000,
  3649. (PHW_TIMER_ROUTINE)TimerCppReset,
  3650. pSrb
  3651. );
  3652. DebugPrint( (DebugLevelTrace, "TOSDVD:Schedule TimerCppReset\r\n") );
  3653. return;
  3654. }
  3655. DebugPrint( (DebugLevelTrace, "TOSDVD:TimerCppReset\r\n") );
  3656. // cpp initialize
  3657. if( pHwDevExt->bCppReset ) {
  3658. DebugPrint( (DebugLevelTrace, "TOSDVD:CPro Reset !!!!!!!!!!!! CPro Reset !!!!!!!!!!!! CPro Reset !!!!!!!!!!!!\r\n") );
  3659. bStatus = pHwDevExt->CPro.reset( GUARD );
  3660. ASSERTMSG( "\r\n...CPro Status Error!!( reset )", bStatus );
  3661. }
  3662. else { // TitleKey
  3663. // BUGBUG!
  3664. // must be wait underflow!
  3665. decStopData( pHwDevExt, TRUE );
  3666. pHwDevExt->XferStartCount = 0;
  3667. pHwDevExt->DecodeStart = FALSE;
  3668. pHwDevExt->SendFirst = FALSE;
  3669. StreamClassScheduleTimer(
  3670. pHwDevExt->pstroVid,
  3671. pHwDevExt,
  3672. 0,
  3673. (PHW_TIMER_ROUTINE)TimerDecodeStart,
  3674. pHwDevExt
  3675. );
  3676. }
  3677. pHwDevExt->pSrbCpp = NULL;
  3678. pHwDevExt->bCppReset = FALSE;
  3679. pSrb->Status = STATUS_SUCCESS;
  3680. StreamClassStreamNotification( ReadyForNextStreamControlRequest,
  3681. pSrb->StreamObject );
  3682. StreamClassStreamNotification( StreamRequestComplete,
  3683. pSrb->StreamObject,
  3684. pSrb );
  3685. DebugPrint( (DebugLevelTrace, "TOSDVD: Success return\r\n") );
  3686. return;
  3687. }
  3688. void SetPlayMode( PHW_DEVICE_EXTENSION pHwDevExt, ULONG mode )
  3689. {
  3690. BOOL bDecode;
  3691. bDecode = pHwDevExt->VDec.VIDEO_GET_DECODE_STATE();
  3692. if( !bDecode ) {
  3693. pHwDevExt->VDec.VIDEO_PRSO_PS1();
  3694. pHwDevExt->PlayMode = mode;
  3695. if( mode != PLAY_MODE_FREEZE )
  3696. pHwDevExt->PlayMode = mode;
  3697. // pHwDevExt->ADec.AUDIO_ZR38521_MUTE_ON();
  3698. }
  3699. else {
  3700. if( mode == PLAY_MODE_NORMAL ) {
  3701. if( pHwDevExt->PlayMode == PLAY_MODE_FAST ) {
  3702. decFastNormal( pHwDevExt );
  3703. UnderflowStopData( pHwDevExt );
  3704. // ADO_MUTE();
  3705. // SP_MUTE();
  3706. }
  3707. else {
  3708. decGenericNormal( pHwDevExt );
  3709. // ADO_MUTE();
  3710. StreamClassScheduleTimer(
  3711. NULL,
  3712. pHwDevExt,
  3713. 1,
  3714. (PHW_TIMER_ROUTINE)TimerAudioMuteOff,
  3715. pHwDevExt
  3716. );
  3717. }
  3718. pHwDevExt->PlayMode = PLAY_MODE_NORMAL;
  3719. pHwDevExt->RunMode = PLAY_MODE_NORMAL;
  3720. // pHwDevExt->bDMAscheduled = FALSE;
  3721. // if( pHwDevExt->pSrbDMA0 == NULL && pHwDevExt->pSrbDMA1 == NULL ) {
  3722. // PreDMAxfer( pHwDevExt );
  3723. // }
  3724. }
  3725. else if( mode == PLAY_MODE_SLOW ) {
  3726. if( pHwDevExt->PlayMode == PLAY_MODE_FAST ) {
  3727. decFastSlow( pHwDevExt );
  3728. UnderflowStopData( pHwDevExt );
  3729. }
  3730. else {
  3731. decGenericSlow( pHwDevExt );
  3732. }
  3733. pHwDevExt->PlayMode = PLAY_MODE_SLOW;
  3734. pHwDevExt->RunMode = PLAY_MODE_SLOW;
  3735. }
  3736. else if( mode == PLAY_MODE_FREEZE ) {
  3737. if( pHwDevExt->PlayMode == PLAY_MODE_FAST ) {
  3738. decFastFreeze( pHwDevExt );
  3739. }
  3740. else {
  3741. // CANCEL_ADO_MUTE();
  3742. decGenericFreeze( pHwDevExt );
  3743. // SP_MUTE();
  3744. }
  3745. pHwDevExt->PlayMode = PLAY_MODE_FREEZE;
  3746. // Doesn't change RunMode. Because RunMode indicates the next play mode.
  3747. }
  3748. else if( mode == PLAY_MODE_FAST ) {
  3749. if( pHwDevExt->PlayMode == PLAY_MODE_FREEZE ) {
  3750. decFreezeFast( pHwDevExt );
  3751. pHwDevExt->PlayMode = PLAY_MODE_FAST;
  3752. if( pHwDevExt->pSrbDMA0 == NULL && pHwDevExt->pSrbDMA1 == NULL ) {
  3753. DebugPrint( (DebugLevelTrace, "TOSDVD: <<<< kick >>>>\r\n") );
  3754. PreDMAxfer( pHwDevExt );
  3755. }
  3756. }
  3757. else {
  3758. decStopForFast( pHwDevExt );
  3759. ForcedStopData( pHwDevExt, 0x04 );
  3760. }
  3761. pHwDevExt->PlayMode = PLAY_MODE_FAST;
  3762. pHwDevExt->RunMode = PLAY_MODE_FAST;
  3763. }
  3764. else
  3765. TRAP;
  3766. }
  3767. }
  3768. // unit = ms
  3769. DWORD GetCurrentTime_ms( void )
  3770. {
  3771. LARGE_INTEGER time, rate;
  3772. time = KeQueryPerformanceCounter( &rate );
  3773. return( (DWORD)( ( time.QuadPart * 1000 ) / rate.QuadPart ) );
  3774. }
  3775. void StopData( PHW_DEVICE_EXTENSION pHwDevExt )
  3776. {
  3777. pHwDevExt->SendFirst = FALSE;
  3778. pHwDevExt->DecodeStart = FALSE;
  3779. pHwDevExt->XferStartCount = 0;
  3780. pHwDevExt->CppFlagCount = 0;
  3781. StreamClassScheduleTimer(
  3782. pHwDevExt->pstroVid,
  3783. pHwDevExt,
  3784. 0,
  3785. (PHW_TIMER_ROUTINE)TimerDecodeStart,
  3786. pHwDevExt
  3787. );
  3788. StreamClassScheduleTimer(
  3789. pHwDevExt->pstroAud,
  3790. pHwDevExt,
  3791. 0,
  3792. (PHW_TIMER_ROUTINE)CheckAudioUnderflow,
  3793. pHwDevExt
  3794. );
  3795. if( pHwDevExt->pSrbDMA0 ) {
  3796. DebugPrint(( DebugLevelTrace, "TOSDVD: pSrbDMA0 = 0x%x exist\r\n", pHwDevExt->pSrbDMA0 ));
  3797. if( pHwDevExt->fSrbDMA0last ) {
  3798. if( ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA0->SRBExtension))->pfnEndSrb ) {
  3799. DebugPrint(( DebugLevelTrace, "TOSDVD:exist pfnEndSrb(StopData) srb = 0x%x\r\n", pHwDevExt->pSrbDMA0 ));
  3800. if( pHwDevExt->pSrbDMA0 == pHwDevExt->pSrbDMA1 || pHwDevExt->pSrbDMA1 == NULL ) {
  3801. DebugPrint(( DebugLevelTrace, "TOSDVD:Call TimerCppReset(StopData)\r\n" ));
  3802. StreamClassScheduleTimer(
  3803. NULL,
  3804. pHwDevExt,
  3805. 1,
  3806. ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA0->SRBExtension))->pfnEndSrb,
  3807. ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA0->SRBExtension))->parmSrb
  3808. );
  3809. }
  3810. }
  3811. pHwDevExt->pSrbDMA0->Status = STATUS_SUCCESS;
  3812. StreamClassStreamNotification( StreamRequestComplete,
  3813. pHwDevExt->pSrbDMA0->StreamObject,
  3814. pHwDevExt->pSrbDMA0 );
  3815. }
  3816. pHwDevExt->pSrbDMA0 = NULL;
  3817. pHwDevExt->fSrbDMA0last = FALSE;
  3818. }
  3819. if( pHwDevExt->pSrbDMA1 ) {
  3820. DebugPrint(( DebugLevelTrace, "TOSDVD: pSrbDMA1 = 0x%x exist\r\n", pHwDevExt->pSrbDMA1 ));
  3821. if( pHwDevExt->fSrbDMA1last ) {
  3822. if( ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA1->SRBExtension))->pfnEndSrb ) {
  3823. DebugPrint(( DebugLevelTrace, "TOSDVD:exist pfnEndSrb(StopData) srb = 0x%x\r\n", pHwDevExt->pSrbDMA1 ));
  3824. if( pHwDevExt->pSrbDMA0 == NULL ) {
  3825. DebugPrint(( DebugLevelTrace, "TOSDVD:Call TimerCppReset(StopData)\r\n" ));
  3826. StreamClassScheduleTimer(
  3827. NULL,
  3828. pHwDevExt,
  3829. 1,
  3830. ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA1->SRBExtension))->pfnEndSrb,
  3831. ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA1->SRBExtension))->parmSrb
  3832. );
  3833. }
  3834. }
  3835. pHwDevExt->pSrbDMA1->Status = STATUS_SUCCESS;
  3836. StreamClassStreamNotification( StreamRequestComplete,
  3837. pHwDevExt->pSrbDMA1->StreamObject,
  3838. pHwDevExt->pSrbDMA1 );
  3839. }
  3840. pHwDevExt->pSrbDMA1 = NULL;
  3841. pHwDevExt->fSrbDMA1last = FALSE;
  3842. }
  3843. PHW_STREAM_REQUEST_BLOCK pSrbTmp;
  3844. ULONG index;
  3845. BOOLEAN fSrbDMAlast;
  3846. for( ; ; ) {
  3847. pSrbTmp = pHwDevExt->DevQue.get( &index, &fSrbDMAlast );
  3848. if( pSrbTmp == NULL )
  3849. break;
  3850. if( fSrbDMAlast ) {
  3851. DebugPrint(( DebugLevelVerbose, "TOSDVD: pSrb = 0x%x\r\n", pSrbTmp ));
  3852. if( ((PSRB_EXTENSION)(pSrbTmp->SRBExtension))->pfnEndSrb ) {
  3853. DebugPrint(( DebugLevelTrace, "TOSDVD:exist pfnEndSrb(StopData) srb = 0x%x\r\n", pSrbTmp ));
  3854. DebugPrint(( DebugLevelTrace, "TOSDVD:Call TimerCppReset(StopData)\r\n" ));
  3855. StreamClassScheduleTimer(
  3856. NULL,
  3857. pHwDevExt,
  3858. 1,
  3859. ((PSRB_EXTENSION)(pSrbTmp->SRBExtension))->pfnEndSrb,
  3860. ((PSRB_EXTENSION)(pSrbTmp->SRBExtension))->parmSrb
  3861. );
  3862. }
  3863. pSrbTmp->Status = STATUS_SUCCESS;
  3864. StreamClassStreamNotification( StreamRequestComplete,
  3865. pSrbTmp->StreamObject,
  3866. pSrbTmp );
  3867. }
  3868. }
  3869. pHwDevExt->RunMode = PLAY_MODE_NORMAL; // PlayMode after STOP is Normal Mode;
  3870. fProgrammed = fStarted = FALSE;
  3871. fClkPause = FALSE;
  3872. decStopData( pHwDevExt, FALSE );
  3873. }
  3874. void CheckAudioUnderflow( PHW_DEVICE_EXTENSION pHwDevExt )
  3875. {
  3876. DebugPrint(( DebugLevelTrace, "TOSDVD:CheckAudioUnderflow\r\n" ));
  3877. NTSTATUS status;
  3878. ULONG buffStatus;
  3879. status = pHwDevExt->ADec.AUDIO_ZR38521_BFST( &buffStatus );
  3880. if( status == STATUS_UNSUCCESSFUL ) {
  3881. DebugPrint(( DebugLevelTrace, "TOSDVD: AUDIO_ZR38521_BFST Unsuccessful\r\n" ));
  3882. TRAP;
  3883. }
  3884. if( pHwDevExt->VDec.VIDEO_GET_STD_CODE() >= 1024 /* Underflow Size of Video */ ) {
  3885. // cancel ScheduleTimer
  3886. StreamClassScheduleTimer(
  3887. pHwDevExt->pstroAud,
  3888. pHwDevExt,
  3889. 0,
  3890. (PHW_TIMER_ROUTINE)CheckAudioUnderflow,
  3891. pHwDevExt
  3892. );
  3893. return;
  3894. }
  3895. if( (buffStatus & 0x0700)!=0x0700 && (buffStatus & 0x0001)!=0x0001 ) {
  3896. // reschedule
  3897. StreamClassScheduleTimer(
  3898. pHwDevExt->pstroAud,
  3899. pHwDevExt,
  3900. 500000,
  3901. (PHW_TIMER_ROUTINE)CheckAudioUnderflow,
  3902. pHwDevExt
  3903. );
  3904. return;
  3905. }
  3906. UnderflowStopData( pHwDevExt );
  3907. }
  3908. void UnderflowStopData( PHW_DEVICE_EXTENSION pHwDevExt )
  3909. {
  3910. DebugPrint(( DebugLevelTrace, "TOSDVD:UnderflowStopData fCauseOfStop = %d\r\n", pHwDevExt->fCauseOfStop ));
  3911. ClearTimeDiscontinuity( pHwDevExt );
  3912. pHwDevExt->SendFirst = FALSE;
  3913. pHwDevExt->DecodeStart = FALSE;
  3914. // pHwDevExt->XferStartCount = 0;
  3915. // pHwDevExt->CppFlagCount = 0;
  3916. StreamClassScheduleTimer(
  3917. pHwDevExt->pstroVid,
  3918. pHwDevExt,
  3919. 0,
  3920. (PHW_TIMER_ROUTINE)TimerDecodeStart,
  3921. pHwDevExt
  3922. );
  3923. StreamClassScheduleTimer(
  3924. pHwDevExt->pstroAud,
  3925. pHwDevExt,
  3926. 0,
  3927. (PHW_TIMER_ROUTINE)CheckAudioUnderflow,
  3928. pHwDevExt
  3929. );
  3930. // 97.10.25
  3931. pHwDevExt->bDMAstop = TRUE;
  3932. pHwDevExt->fCauseOfStop = 0x00;
  3933. // StreamClassScheduleTimer(
  3934. // NULL,
  3935. // pHwDevExt,
  3936. // 100000,
  3937. // (PHW_TIMER_ROUTINE)StopDequeue,
  3938. // pHwDevExt
  3939. // );
  3940. StopDequeue( pHwDevExt );
  3941. // 97.10.25
  3942. // if( pHwDevExt->pSrbDMA0 ) {
  3943. // DebugPrint(( DebugLevelTrace, "TOSDVD: pSrbDMA0 = 0x%x exist\r\n", pHwDevExt->pSrbDMA0 ));
  3944. //
  3945. // if( pHwDevExt->fSrbDMA0last ) {
  3946. // if( ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA0->SRBExtension))->pfnEndSrb ) {
  3947. // DebugPrint(( DebugLevelTrace, "TOSDVD:exist pfnEndSrb(UnderflowStopData) srb = 0x%x\r\n", pHwDevExt->pSrbDMA0 ));
  3948. // if( pHwDevExt->pSrbDMA0 == pHwDevExt->pSrbDMA1 || pHwDevExt->pSrbDMA1 == NULL ) {
  3949. // DebugPrint(( DebugLevelTrace, "TOSDVD:Call TimerCppReset(UnderflowStopData)\r\n" ));
  3950. // StreamClassScheduleTimer(
  3951. // NULL,
  3952. // pHwDevExt,
  3953. // 1,
  3954. // ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA0->SRBExtension))->pfnEndSrb,
  3955. // ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA0->SRBExtension))->parmSrb
  3956. // );
  3957. // }
  3958. // }
  3959. //
  3960. // pHwDevExt->pSrbDMA0->Status = STATUS_SUCCESS;
  3961. // StreamClassStreamNotification( StreamRequestComplete,
  3962. // pHwDevExt->pSrbDMA0->StreamObject,
  3963. // pHwDevExt->pSrbDMA0 );
  3964. // }
  3965. // pHwDevExt->pSrbDMA0 = NULL;
  3966. // pHwDevExt->fSrbDMA0last = FALSE;
  3967. // }
  3968. // if( pHwDevExt->pSrbDMA1 ) {
  3969. // DebugPrint(( DebugLevelTrace, "TOSDVD: pSrbDMA1 = 0x%x exist\r\n", pHwDevExt->pSrbDMA1 ));
  3970. //
  3971. // if( pHwDevExt->fSrbDMA1last ) {
  3972. // if( ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA1->SRBExtension))->pfnEndSrb ) {
  3973. // DebugPrint(( DebugLevelTrace, "TOSDVD:exist pfnEndSrb(UnderflowStopData) srb = 0x%x\r\n", pHwDevExt->pSrbDMA1 ));
  3974. // if( pHwDevExt->pSrbDMA0 == NULL ) {
  3975. // DebugPrint(( DebugLevelTrace, "TOSDVD:Call TimerCppReset(UnderflowStopData)\r\n" ));
  3976. // StreamClassScheduleTimer(
  3977. // NULL,
  3978. // pHwDevExt,
  3979. // 1,
  3980. // ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA1->SRBExtension))->pfnEndSrb,
  3981. // ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA1->SRBExtension))->parmSrb
  3982. // );
  3983. // }
  3984. // }
  3985. //
  3986. // pHwDevExt->pSrbDMA1->Status = STATUS_SUCCESS;
  3987. // StreamClassStreamNotification( StreamRequestComplete,
  3988. // pHwDevExt->pSrbDMA1->StreamObject,
  3989. // pHwDevExt->pSrbDMA1 );
  3990. // }
  3991. // pHwDevExt->pSrbDMA1 = NULL;
  3992. // pHwDevExt->fSrbDMA1last = FALSE;
  3993. // }
  3994. //
  3995. // PHW_STREAM_REQUEST_BLOCK pSrbTmp;
  3996. // ULONG index;
  3997. // BOOLEAN fSrbDMAlast;
  3998. //
  3999. // for( ; ; ) {
  4000. // pSrbTmp = pHwDevExt->DevQue.get( &index, &fSrbDMAlast );
  4001. // if( pSrbTmp == NULL )
  4002. // break;
  4003. // if( fSrbDMAlast ) {
  4004. // DebugPrint(( DebugLevelVerbose, "TOSDVD: pSrb = 0x%x\r\n", pSrbTmp ));
  4005. //
  4006. // if( ((PSRB_EXTENSION)(pSrbTmp->SRBExtension))->pfnEndSrb ) {
  4007. // DebugPrint(( DebugLevelTrace, "TOSDVD:exist pfnEndSrb(UnderflowStopData) srb = 0x%x\r\n", pSrbTmp ));
  4008. // DebugPrint(( DebugLevelTrace, "TOSDVD:Call TimerCppReset(UnderflowStopData)\r\n" ));
  4009. // StreamClassScheduleTimer(
  4010. // NULL,
  4011. // pHwDevExt,
  4012. // 1,
  4013. // ((PSRB_EXTENSION)(pSrbTmp->SRBExtension))->pfnEndSrb,
  4014. // ((PSRB_EXTENSION)(pSrbTmp->SRBExtension))->parmSrb
  4015. // );
  4016. // }
  4017. //
  4018. // pSrbTmp->Status = STATUS_SUCCESS;
  4019. // StreamClassStreamNotification( StreamRequestComplete,
  4020. // pSrbTmp->StreamObject,
  4021. // pSrbTmp );
  4022. // }
  4023. // }
  4024. // if( pHwDevExt->fCauseOfStop == 0x01 )
  4025. // return;
  4026. // fProgrammed = fStarted = FALSE;
  4027. fClkPause = FALSE;
  4028. // if( pHwDevExt->fCauseOfStop == 0x00 ) {
  4029. // decStopData( pHwDevExt, TRUE );
  4030. // }
  4031. // pHwDevExt->VDec.VIDEO_DECODE_STOP();
  4032. // pHwDevExt->ADec.AUDIO_ZR38521_STOP();
  4033. // pHwDevExt->VPro.SUBP_STC_OFF();
  4034. // pHwDevExt->bDMAstop = FALSE;
  4035. // DebugPrint(( DebugLevelTrace, "TOSDVD: bDMAstop = FALSE\r\n" ));
  4036. }
  4037. void ForcedStopData( PHW_DEVICE_EXTENSION pHwDevExt, ULONG flag )
  4038. {
  4039. DebugPrint(( DebugLevelTrace, "TOSDVD:ForcedStopData\r\n" ));
  4040. pHwDevExt->VDec.VIDEO_UFLOW_INT_OFF();
  4041. pHwDevExt->VDec.VIDEO_DECODE_STOP();
  4042. pHwDevExt->ADec.AUDIO_ZR38521_STOP();
  4043. pHwDevExt->VPro.SUBP_STC_OFF();
  4044. pHwDevExt->bDMAstop = TRUE;
  4045. pHwDevExt->fCauseOfStop = flag;
  4046. StreamClassScheduleTimer(
  4047. pHwDevExt->pstroAud,
  4048. pHwDevExt,
  4049. 0,
  4050. (PHW_TIMER_ROUTINE)CheckAudioUnderflow,
  4051. pHwDevExt
  4052. );
  4053. StopDequeue( pHwDevExt );
  4054. // StreamClassScheduleTimer(
  4055. // NULL,
  4056. // pHwDevExt,
  4057. // 100000,
  4058. // (PHW_TIMER_ROUTINE)StopDequeue,
  4059. // pHwDevExt
  4060. // );
  4061. }
  4062. void StopDequeue( PHW_DEVICE_EXTENSION pHwDevExt )
  4063. {
  4064. DebugPrint(( DebugLevelTrace, "TOSDVD:StopDequeue\r\n" ));
  4065. if( pHwDevExt->pSrbDMA0 != NULL || pHwDevExt->pSrbDMA1 != NULL ) {
  4066. StreamClassScheduleTimer(
  4067. NULL,
  4068. pHwDevExt,
  4069. 100000,
  4070. (PHW_TIMER_ROUTINE)StopDequeue,
  4071. pHwDevExt
  4072. );
  4073. DebugPrint(( DebugLevelTrace, "TOSDVD:Schedule StopDequeue\r\n" ));
  4074. return;
  4075. }
  4076. PHW_STREAM_REQUEST_BLOCK pSrbTmp;
  4077. ULONG index;
  4078. BOOLEAN fSrbDMAlast;
  4079. for( ; ; ) {
  4080. pSrbTmp = pHwDevExt->DevQue.get( &index, &fSrbDMAlast );
  4081. if( pSrbTmp == NULL )
  4082. break;
  4083. if( fSrbDMAlast ) {
  4084. DebugPrint(( DebugLevelVerbose, "TOSDVD: pSrb = 0x%x\r\n", pSrbTmp ));
  4085. if( ((PSRB_EXTENSION)(pSrbTmp->SRBExtension))->pfnEndSrb ) {
  4086. DebugPrint(( DebugLevelTrace, "TOSDVD:exist pfnEndSrb(StopDequeue) srb = 0x%x\r\n", pSrbTmp ));
  4087. DebugPrint(( DebugLevelTrace, "TOSDVD:Call TimerCppReset(StopDequeue)\r\n" ));
  4088. StreamClassScheduleTimer(
  4089. NULL,
  4090. pHwDevExt,
  4091. 1,
  4092. ((PSRB_EXTENSION)(pSrbTmp->SRBExtension))->pfnEndSrb,
  4093. ((PSRB_EXTENSION)(pSrbTmp->SRBExtension))->parmSrb
  4094. );
  4095. }
  4096. pSrbTmp->Status = STATUS_SUCCESS;
  4097. StreamClassStreamNotification( StreamRequestComplete,
  4098. pSrbTmp->StreamObject,
  4099. pSrbTmp );
  4100. }
  4101. }
  4102. pHwDevExt->bDMAstop = FALSE;
  4103. // 0x04: NORMAL to F.F. or F.F. to F.F.
  4104. if( pHwDevExt->fCauseOfStop == 0x04 ) {
  4105. // pHwDevExt->ADec.AUDIO_ZR38521_STOPF();
  4106. // pHwDevExt->ADec.AUDIO_ZR38521_MUTE_ON();
  4107. // pHwDevExt->VDec.VIDEO_STD_CLEAR();
  4108. // pHwDevExt->VPro.SUBP_BUFF_CLEAR();
  4109. // pHwDevExt->VDec.VIDEO_DECODE_START();
  4110. decResumeForFast( pHwDevExt );
  4111. }
  4112. }
  4113. void SetAudioID( PHW_DEVICE_EXTENSION pHwDevExt, PKSSTREAM_HEADER pStruc )
  4114. {
  4115. ULONG strID;
  4116. strID = (ULONG)GetStreamID(pStruc->Data);
  4117. // AC-3
  4118. if( (strID & 0xF8)==0x80 ) {
  4119. if( pHwDevExt->VPro.SUBP_GET_AUDIO_CH() != strID ) {
  4120. DebugPrint(( DebugLevelTrace, "TOSDVD:AC-3 0x%x\r\n", strID ));
  4121. MYAUDIOFORMAT fmt;
  4122. fmt.dwMode = AUDIO_TYPE_AC3;
  4123. fmt.dwFreq = AUDIO_FS_48;
  4124. ProcessAudioFormat2( &fmt, pHwDevExt );
  4125. pHwDevExt->VPro.SUBP_SET_AUDIO_CH(strID);
  4126. }
  4127. }
  4128. // LPCM
  4129. else if( (strID & 0xF8)==0xA0 ) {
  4130. if( pHwDevExt->VPro.SUBP_GET_AUDIO_CH() != strID ) {
  4131. DebugPrint(( DebugLevelTrace, "TOSDVD:LPCM 0x%x\r\n", strID ));
  4132. MYAUDIOFORMAT fmt;
  4133. fmt.dwMode = AUDIO_TYPE_PCM;
  4134. GetLPCMInfo( pStruc->Data, &fmt );
  4135. ProcessAudioFormat2( &fmt, pHwDevExt );
  4136. pHwDevExt->VPro.SUBP_SET_AUDIO_CH(strID);
  4137. }
  4138. }
  4139. #if 0
  4140. // MPEG audio
  4141. else if( (strID & 0x??)==0x@@ ) {
  4142. }
  4143. #endif
  4144. }
  4145. //--- 97.09.14 K.Chujo
  4146. void SetSubpicID( PHW_DEVICE_EXTENSION pHwDevExt, PKSSTREAM_HEADER pStruc )
  4147. {
  4148. ULONG strID;
  4149. ULONG stc;
  4150. strID = (ULONG)GetStreamID(pStruc->Data);
  4151. if( (strID & 0xE0)==0x20 ) {
  4152. if( pHwDevExt->VPro.SUBP_GET_SUBP_CH() != strID ) {
  4153. pHwDevExt->VPro.SUBP_SET_SUBP_CH( strID );
  4154. stc = pHwDevExt->VDec.VIDEO_GET_STCA();
  4155. pHwDevExt->VPro.SUBP_SET_STC( stc );
  4156. pHwDevExt->VPro.SUBP_STC_ON();
  4157. }
  4158. }
  4159. }
  4160. //--- End.
  4161. void SetCppFlag( PHW_DEVICE_EXTENSION pHwDevExt )
  4162. {
  4163. DebugPrint(( DebugLevelTrace, "TOSDVD:SetCppFlag()\r\n" ));
  4164. BOOL bSet;
  4165. // pHwDevExt->CppFlagCount = 0;
  4166. ASSERT( pHwDevExt->pSrbCpp );
  4167. bSet = pHwDevExt->DevQue.setEndAddress( (PHW_TIMER_ROUTINE)TimerCppReset, pHwDevExt->pSrbCpp );
  4168. DebugPrint(( DebugLevelTrace, "TOSDVD: bSet %d\r\n", bSet ));
  4169. if( !bSet ) {
  4170. DebugPrint(( DebugLevelTrace, "TOSDVD: pSrbDMA0 0x%x, pSrbDMA1 0x%x\r\n", pHwDevExt->pSrbDMA0, pHwDevExt->pSrbDMA1 ));
  4171. if( pHwDevExt->pSrbDMA0 == NULL && pHwDevExt->pSrbDMA1 == NULL ) {
  4172. StreamClassScheduleTimer(
  4173. NULL,
  4174. pHwDevExt,
  4175. 1,
  4176. (PHW_TIMER_ROUTINE)TimerCppReset,
  4177. pHwDevExt->pSrbCpp
  4178. );
  4179. return;
  4180. }
  4181. if( pHwDevExt->pSrbDMA0 ) {
  4182. ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA0->SRBExtension))->pfnEndSrb = (PHW_TIMER_ROUTINE)TimerCppReset;
  4183. ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA0->SRBExtension))->parmSrb = pHwDevExt->pSrbCpp;
  4184. }
  4185. if( pHwDevExt->pSrbDMA1 ) {
  4186. ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA1->SRBExtension))->pfnEndSrb = (PHW_TIMER_ROUTINE)TimerCppReset;
  4187. ((PSRB_EXTENSION)(pHwDevExt->pSrbDMA1->SRBExtension))->parmSrb = pHwDevExt->pSrbCpp;
  4188. }
  4189. }
  4190. return;
  4191. }
  4192. void AudioQueryAccept( PHW_STREAM_REQUEST_BLOCK pSrb )
  4193. {
  4194. DebugPrint(( DebugLevelTrace, "TOSDVD:AudioQueryAccept\r\n" ));
  4195. // We now get connected with a valid format block, so this gets in the way
  4196. // by serges TRAP;
  4197. pSrb->Status = STATUS_SUCCESS;
  4198. }
  4199. void ProcessAudioFormat( PKSDATAFORMAT pfmt, PHW_DEVICE_EXTENSION pHwDevExt )
  4200. {
  4201. DebugPrint(( DebugLevelTrace, "TOSDVD:ProcessAudioFormat\r\n" ));
  4202. if( ( IsEqualGUID2( &pfmt->MajorFormat, &KSDATAFORMAT_TYPE_DVD_ENCRYPTED_PACK ) &&
  4203. IsEqualGUID2( &pfmt->SubFormat, &KSDATAFORMAT_SUBTYPE_AC3_AUDIO ) ) ) {
  4204. // AC-3
  4205. DebugPrint(( DebugLevelTrace, "TOSDVD: AC-3\r\n" ));
  4206. pHwDevExt->AudioFreq = AUDIO_FS_48;
  4207. // We now receive format switches, so this gets in the way
  4208. // TRAP; // added by serges
  4209. /* If the audio type is not already set to AC3 in the decoder, set it to AC3 now */
  4210. if( pHwDevExt->AudioMode != AUDIO_TYPE_AC3 ) {
  4211. pHwDevExt->AudioMode = AUDIO_TYPE_AC3;
  4212. pHwDevExt->VDec.VIDEO_PRSO_PS1();
  4213. pHwDevExt->ADec.AUDIO_ZR38521_BOOT_AC3();
  4214. pHwDevExt->ADec.AUDIO_ZR38521_CFG();
  4215. pHwDevExt->ADec.AUDIO_ZR38521_AC3();
  4216. pHwDevExt->ADec.AUDIO_ZR38521_KCOEF();
  4217. pHwDevExt->ADec.AUDIO_TC6800_INIT_AC3();
  4218. pHwDevExt->VPro.SUBP_SELECT_AUDIO_SSID();
  4219. }
  4220. }
  4221. else if( ( IsEqualGUID2( &pfmt->MajorFormat, &KSDATAFORMAT_TYPE_DVD_ENCRYPTED_PACK ) &&
  4222. IsEqualGUID2( &pfmt->SubFormat, &KSDATAFORMAT_SUBTYPE_LPCM_AUDIO ) ) ) {
  4223. // LPCM
  4224. DebugPrint(( DebugLevelTrace, "TOSDVD: LPCM\r\n" ));
  4225. // We now receive format switches, so this gets in the way
  4226. // by serges TRAP;
  4227. #if DBG
  4228. WAVEFORMATEX * pblock = (WAVEFORMATEX *)((DWORD_PTR)pfmt + sizeof(KSDATAFORMAT) );
  4229. DebugPrint(( DebugLevelTrace, "TOSDVD: wFormatTag %d\r\n", (DWORD)(pblock->wFormatTag) ));
  4230. DebugPrint(( DebugLevelTrace, "TOSDVD: nChannels %d\r\n", (DWORD)(pblock->nChannels) ));
  4231. DebugPrint(( DebugLevelTrace, "TOSDVD: nSamplesPerSec %d\r\n", (DWORD)(pblock->nSamplesPerSec) ));
  4232. DebugPrint(( DebugLevelTrace, "TOSDVD: nAvgBytesPerSec %d\r\n", (DWORD)(pblock->nAvgBytesPerSec) ));
  4233. DebugPrint(( DebugLevelTrace, "TOSDVD: nBlockAlign %d\r\n", (DWORD)(pblock->nBlockAlign) ));
  4234. DebugPrint(( DebugLevelTrace, "TOSDVD: wBitsPerSample %d\r\n", (DWORD)(pblock->wBitsPerSample) ));
  4235. DebugPrint(( DebugLevelTrace, "TOSDVD: cbSize %d\r\n", (DWORD)(pblock->cbSize) ));
  4236. // We now receive format switches, so this gets in the way
  4237. // TRAP; // added by serges
  4238. #endif
  4239. /* If the audio type is not already set to LPCM in the decoder, set it to LPCM now */
  4240. if( pHwDevExt->AudioMode != AUDIO_TYPE_PCM ) {
  4241. pHwDevExt->AudioMode = AUDIO_TYPE_PCM;
  4242. pHwDevExt->VDec.VIDEO_PRSO_PS1();
  4243. pHwDevExt->ADec.AUDIO_ZR38521_BOOT_PCM();
  4244. pHwDevExt->ADec.AUDIO_ZR38521_CFG();
  4245. pHwDevExt->ADec.AUDIO_ZR38521_PCMX();
  4246. pHwDevExt->ADec.AUDIO_TC6800_INIT_PCM();
  4247. pHwDevExt->VPro.SUBP_SELECT_AUDIO_SSID();
  4248. }
  4249. }
  4250. else {
  4251. DebugPrint(( DebugLevelTrace, "TOSDVD: Unsupport audio type\r\n" ));
  4252. DebugPrint(( DebugLevelTrace, "TOSDVD: Major %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x\r\n",
  4253. pfmt->MajorFormat.Data1,
  4254. pfmt->MajorFormat.Data2,
  4255. pfmt->MajorFormat.Data3,
  4256. pfmt->MajorFormat.Data4[0],
  4257. pfmt->MajorFormat.Data4[1],
  4258. pfmt->MajorFormat.Data4[2],
  4259. pfmt->MajorFormat.Data4[3],
  4260. pfmt->MajorFormat.Data4[4],
  4261. pfmt->MajorFormat.Data4[5],
  4262. pfmt->MajorFormat.Data4[6],
  4263. pfmt->MajorFormat.Data4[7]
  4264. ));
  4265. DebugPrint(( DebugLevelTrace, "TOSDVD: Sub %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x\r\n",
  4266. pfmt->SubFormat.Data1,
  4267. pfmt->SubFormat.Data2,
  4268. pfmt->SubFormat.Data3,
  4269. pfmt->SubFormat.Data4[0],
  4270. pfmt->SubFormat.Data4[1],
  4271. pfmt->SubFormat.Data4[2],
  4272. pfmt->SubFormat.Data4[3],
  4273. pfmt->SubFormat.Data4[4],
  4274. pfmt->SubFormat.Data4[5],
  4275. pfmt->SubFormat.Data4[6],
  4276. pfmt->SubFormat.Data4[7]
  4277. ));
  4278. DebugPrint(( DebugLevelTrace, "TOSDVD: Format %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x\r\n",
  4279. pfmt->Specifier.Data1,
  4280. pfmt->Specifier.Data2,
  4281. pfmt->Specifier.Data3,
  4282. pfmt->Specifier.Data4[0],
  4283. pfmt->Specifier.Data4[1],
  4284. pfmt->Specifier.Data4[2],
  4285. pfmt->Specifier.Data4[3],
  4286. pfmt->Specifier.Data4[4],
  4287. pfmt->Specifier.Data4[5],
  4288. pfmt->Specifier.Data4[6],
  4289. pfmt->Specifier.Data4[7]
  4290. ));
  4291. TRAP;
  4292. return;
  4293. }
  4294. pHwDevExt->ADec.SetParam(
  4295. pHwDevExt->AudioMode,
  4296. pHwDevExt->AudioFreq,
  4297. pHwDevExt->AudioType,
  4298. pHwDevExt->AudioCgms,
  4299. &pHwDevExt->DAck
  4300. );
  4301. pHwDevExt->VPro.SetParam( pHwDevExt->AudioMode, pHwDevExt->SubpicMute );
  4302. pHwDevExt->ADec.AUDIO_ZR38521_REPEAT_16();
  4303. pHwDevExt->ADec.AUDIO_TC9425_INIT_DIGITAL();
  4304. pHwDevExt->ADec.AUDIO_TC9425_INIT_ANALOG();
  4305. // pHwDevExt->ADec.AUDIO_ZR38521_MUTE_OFF();
  4306. // AudioType
  4307. // pHwDevExt->DAck.PCIF_AMUTE2_OFF();
  4308. // pHwDevExt->DAck.PCIF_AMUTE_OFF();
  4309. }
  4310. void ProcessAudioFormat2( PMYAUDIOFORMAT pfmt, PHW_DEVICE_EXTENSION pHwDevExt )
  4311. {
  4312. DebugPrint(( DebugLevelTrace, "TOSDVD:ProcessAudioFormat2()\r\n" ));
  4313. if( pfmt->dwMode == AUDIO_TYPE_AC3 ) {
  4314. DebugPrint(( DebugLevelTrace, "TOSDVD: AC-3\r\n" ));
  4315. pHwDevExt->AudioFreq = pfmt->dwFreq;
  4316. if( pHwDevExt->AudioMode != AUDIO_TYPE_AC3 ) {
  4317. pHwDevExt->AudioMode = pfmt->dwMode;
  4318. pHwDevExt->VDec.VIDEO_PRSO_PS1();
  4319. pHwDevExt->ADec.AUDIO_ZR38521_BOOT_AC3();
  4320. pHwDevExt->ADec.AUDIO_ZR38521_CFG();
  4321. pHwDevExt->ADec.AUDIO_ZR38521_AC3();
  4322. pHwDevExt->ADec.AUDIO_ZR38521_KCOEF();
  4323. pHwDevExt->ADec.AUDIO_TC6800_INIT_AC3();
  4324. pHwDevExt->VPro.SUBP_SELECT_AUDIO_SSID();
  4325. }
  4326. }
  4327. else if( pfmt->dwMode == AUDIO_TYPE_PCM ) {
  4328. DebugPrint(( DebugLevelTrace, "TOSDVD: LPCM\r\n" ));
  4329. pHwDevExt->AudioFreq = pfmt->dwFreq;
  4330. if( pHwDevExt->AudioMode != AUDIO_TYPE_PCM ) {
  4331. pHwDevExt->AudioMode = pfmt->dwMode;
  4332. pHwDevExt->VDec.VIDEO_PRSO_PS1();
  4333. pHwDevExt->ADec.AUDIO_ZR38521_BOOT_PCM();
  4334. pHwDevExt->ADec.AUDIO_ZR38521_CFG();
  4335. pHwDevExt->ADec.AUDIO_ZR38521_PCMX();
  4336. pHwDevExt->ADec.AUDIO_TC6800_INIT_PCM();
  4337. pHwDevExt->VPro.SUBP_SELECT_AUDIO_SSID();
  4338. }
  4339. }
  4340. else {
  4341. TRAP;
  4342. return;
  4343. }
  4344. pHwDevExt->ADec.SetParam(
  4345. pHwDevExt->AudioMode,
  4346. pHwDevExt->AudioFreq,
  4347. pHwDevExt->AudioType,
  4348. pHwDevExt->AudioCgms,
  4349. &pHwDevExt->DAck
  4350. );
  4351. pHwDevExt->VPro.SetParam( pHwDevExt->AudioMode, pHwDevExt->SubpicMute );
  4352. pHwDevExt->ADec.AUDIO_ZR38521_REPEAT_16();
  4353. pHwDevExt->ADec.AUDIO_TC9425_INIT_DIGITAL();
  4354. pHwDevExt->ADec.AUDIO_TC9425_INIT_ANALOG();
  4355. // pHwDevExt->ADec.AUDIO_ZR38521_MUTE_OFF();
  4356. // AudioType
  4357. // pHwDevExt->DAck.PCIF_AMUTE2_OFF();
  4358. // pHwDevExt->DAck.PCIF_AMUTE_OFF();
  4359. DebugPrint(( DebugLevelTrace, "TOSDVD: return\r\n" ));
  4360. }
  4361. //--- 97.09.24 K.Chujo
  4362. void SetVideoRateDefault( PHW_DEVICE_EXTENSION pHwDevExt )
  4363. {
  4364. pHwDevExt->VideoStartTime = 0;
  4365. pHwDevExt->VideoInterceptTime = 0;
  4366. pHwDevExt->VideoRate = 1 * 10000;
  4367. pHwDevExt->StartTime = 0;
  4368. pHwDevExt->InterceptTime = 0;
  4369. pHwDevExt->Rate = 1 * 10000;
  4370. pHwDevExt->ChangeFlag = 0;
  4371. }
  4372. void SetAudioRateDefault( PHW_DEVICE_EXTENSION pHwDevExt )
  4373. {
  4374. pHwDevExt->AudioStartTime = 0;
  4375. pHwDevExt->AudioInterceptTime = 0;
  4376. pHwDevExt->AudioRate = 1 * 10000;
  4377. }
  4378. void SetSubpicRateDefault( PHW_DEVICE_EXTENSION pHwDevExt )
  4379. {
  4380. pHwDevExt->SubpicStartTime = 0;
  4381. pHwDevExt->SubpicInterceptTime = 0;
  4382. pHwDevExt->SubpicRate = 1 * 10000;
  4383. }
  4384. void SetRateChange( PHW_DEVICE_EXTENSION pHwDevExt, LONG strm )
  4385. {
  4386. // strm = 1:video, 2:audio, 4:subpic
  4387. pHwDevExt->ChangeFlag = strm;
  4388. // When video stream rate is changed, rate change is enable... Is this OK?
  4389. if( (pHwDevExt->ChangeFlag & 0x01)==0x01 ) {
  4390. pHwDevExt->ChangeFlag = 0;
  4391. // Maybe buggy? use video rate, start time and intercept time
  4392. pHwDevExt->StartTime = pHwDevExt->VideoStartTime;
  4393. pHwDevExt->InterceptTime = pHwDevExt->VideoInterceptTime;
  4394. pHwDevExt->Rate = pHwDevExt->VideoRate;
  4395. DebugPrint( (DebugLevelTrace, "TOSDVD: Calculated Data\r\n" ) );
  4396. DebugPrint( (DebugLevelTrace, "TOSDVD: InterceptTime = 0x%08x\r\n", pHwDevExt->VideoInterceptTime ) );
  4397. DebugPrint( (DebugLevelTrace, "TOSDVD: StartTime = 0x%08x\r\n", pHwDevExt->VideoStartTime ) );
  4398. DebugPrint( (DebugLevelTrace, "TOSDVD: Rate = 0x%08x\r\n", pHwDevExt->VideoRate ) );
  4399. if( pHwDevExt->Rate == 10000 ) {
  4400. SetPlayMode( pHwDevExt, PLAY_MODE_NORMAL );
  4401. }
  4402. else if( pHwDevExt->Rate < 10000 ) {
  4403. SetPlayMode( pHwDevExt, PLAY_MODE_FAST );
  4404. }
  4405. else {
  4406. #if DBG
  4407. //--- debug
  4408. {
  4409. ULONG dwSTC = pHwDevExt->VDec.VIDEO_GET_STCA();
  4410. DebugPrint( (DebugLevelTrace, "TOSDVD: STC in SLOW = %lx (100ns)\r\n", dwSTC * 1000/9 ) );
  4411. }
  4412. //---
  4413. #endif
  4414. SetPlayMode( pHwDevExt, PLAY_MODE_SLOW );
  4415. }
  4416. }
  4417. }
  4418. void SetVideoRateChange( PHW_STREAM_REQUEST_BLOCK pSrb )
  4419. {
  4420. DebugPrint( (DebugLevelTrace, "TOSDVD: SetVideoRateChange\r\n") );
  4421. switch( pSrb->CommandData.PropertyInfo->Property->Id ) {
  4422. case KS_AM_RATE_SimpleRateChange :
  4423. {
  4424. KS_AM_SimpleRateChange* pRateChange;
  4425. PHW_DEVICE_EXTENSION pHwDevExt;
  4426. REFERENCE_TIME NewStartTime;
  4427. LONG NewRate;
  4428. DebugPrint( (DebugLevelTrace, "TOSDVD: KS_AM_RATE_SimpleRateChange\r\n") );
  4429. pRateChange = (KS_AM_SimpleRateChange*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  4430. pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  4431. NewStartTime = pRateChange->StartTime;
  4432. NewRate = ( pRateChange->Rate < 0 ) ? -pRateChange->Rate : pRateChange->Rate;
  4433. DebugPrint( (DebugLevelTrace, "TOSDVD: Received Data\r\n" ) );
  4434. DebugPrint( (DebugLevelTrace, "TOSDVD: StartTime = 0x%08x\r\n", NewStartTime ) );
  4435. DebugPrint( (DebugLevelTrace, "TOSDVD: Rate = 0x%08x\r\n", NewRate) );
  4436. DebugPrint( (DebugLevelTrace, "TOSDVD: Current Data\r\n" ) );
  4437. DebugPrint( (DebugLevelTrace, "TOSDVD: InterceptTime = 0x%08x\r\n", pHwDevExt->VideoInterceptTime ) );
  4438. DebugPrint( (DebugLevelTrace, "TOSDVD: StartTime = 0x%08x\r\n", pHwDevExt->VideoStartTime ) );
  4439. DebugPrint( (DebugLevelTrace, "TOSDVD: Rate = 0x%08x\r\n", pHwDevExt->VideoRate ) );
  4440. // pHwDevExt->VideoInterceptTime
  4441. // = (pHwDevExt->VideoInterceptTime - NewStartTime)
  4442. // * pHwDevExt->VideoRate
  4443. // / NewRate
  4444. // + NewStartTime;
  4445. pHwDevExt->VideoRate = NewRate;
  4446. if( NewRate == 10000 ) {
  4447. pHwDevExt->VideoInterceptTime = 0;
  4448. pHwDevExt->VideoStartTime = 0;
  4449. }
  4450. else {
  4451. pHwDevExt->VideoInterceptTime = (-NewStartTime) * 10000 / NewRate + NewStartTime;
  4452. pHwDevExt->VideoStartTime = NewStartTime;
  4453. }
  4454. SetRateChange( pHwDevExt, 0x01 );
  4455. }
  4456. pSrb->Status = STATUS_SUCCESS;
  4457. break;
  4458. case KS_AM_RATE_ExactRateChange :
  4459. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4460. break;
  4461. case KS_AM_RATE_MaxFullDataRate :
  4462. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4463. break;
  4464. case KS_AM_RATE_Step :
  4465. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4466. break;
  4467. }
  4468. }
  4469. void SetAudioRateChange( PHW_STREAM_REQUEST_BLOCK pSrb )
  4470. {
  4471. DebugPrint( (DebugLevelTrace, "TOSDVD: SetAudioRateChange\r\n") );
  4472. switch( pSrb->CommandData.PropertyInfo->Property->Id ) {
  4473. case KS_AM_RATE_SimpleRateChange :
  4474. {
  4475. KS_AM_SimpleRateChange* pRateChange;
  4476. PHW_DEVICE_EXTENSION pHwDevExt;
  4477. REFERENCE_TIME NewStartTime;
  4478. LONG NewRate;
  4479. DebugPrint( (DebugLevelTrace, "TOSDVD: KS_AM_RATE_SimpleRateChange\r\n") );
  4480. pRateChange = (KS_AM_SimpleRateChange*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  4481. pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  4482. NewStartTime = pRateChange->StartTime;
  4483. NewRate = ( pRateChange->Rate < 0 ) ? -pRateChange->Rate : pRateChange->Rate;
  4484. DebugPrint( (DebugLevelTrace, "TOSDVD: Received Data\r\n" ) );
  4485. DebugPrint( (DebugLevelTrace, "TOSDVD: StartTime = 0x%08x\r\n", NewStartTime ) );
  4486. DebugPrint( (DebugLevelTrace, "TOSDVD: Rate = 0x%08x\r\n", NewRate) );
  4487. // pHwDevExt->AudioInterceptTime
  4488. // = (pHwDevExt->AudioInterceptTime - NewStartTime)
  4489. // * pHwDevExt->AudioRate
  4490. // / NewRate
  4491. // + NewStartTime;
  4492. pHwDevExt->AudioRate = NewRate;
  4493. if( NewRate == 10000 ) {
  4494. pHwDevExt->AudioInterceptTime = 0;
  4495. pHwDevExt->AudioStartTime = 0;
  4496. }
  4497. else {
  4498. pHwDevExt->AudioInterceptTime = (-NewStartTime) * 10000 / NewRate + NewStartTime;
  4499. pHwDevExt->AudioStartTime = NewStartTime;
  4500. }
  4501. SetRateChange( pHwDevExt, 0x02 );
  4502. }
  4503. pSrb->Status = STATUS_SUCCESS;
  4504. break;
  4505. case KS_AM_RATE_ExactRateChange :
  4506. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4507. break;
  4508. case KS_AM_RATE_MaxFullDataRate :
  4509. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4510. break;
  4511. case KS_AM_RATE_Step :
  4512. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4513. break;
  4514. }
  4515. }
  4516. void SetSubpicRateChange( PHW_STREAM_REQUEST_BLOCK pSrb )
  4517. {
  4518. DebugPrint( (DebugLevelTrace, "TOSDVD: SetSubpicRateChange\r\n") );
  4519. switch( pSrb->CommandData.PropertyInfo->Property->Id ) {
  4520. case KS_AM_RATE_SimpleRateChange :
  4521. {
  4522. KS_AM_SimpleRateChange* pRateChange;
  4523. PHW_DEVICE_EXTENSION pHwDevExt;
  4524. REFERENCE_TIME NewStartTime;
  4525. LONG NewRate;
  4526. DebugPrint( (DebugLevelTrace, "TOSDVD: KS_AM_RATE_SimpleRateChange\r\n") );
  4527. pRateChange = (KS_AM_SimpleRateChange*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  4528. pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  4529. NewStartTime = pRateChange->StartTime;
  4530. NewRate = ( pRateChange->Rate < 0 ) ? -pRateChange->Rate : pRateChange->Rate;
  4531. DebugPrint( (DebugLevelTrace, "TOSDVD: Received Data\r\n" ) );
  4532. DebugPrint( (DebugLevelTrace, "TOSDVD: StartTime = 0x%08x\r\n", NewStartTime ) );
  4533. DebugPrint( (DebugLevelTrace, "TOSDVD: Rate = 0x%08x\r\n", NewRate) );
  4534. // pHwDevExt->SubpicInterceptTime
  4535. // = (pHwDevExt->SubpicInterceptTime - NewStartTime)
  4536. // * pHwDevExt->SubpicRate
  4537. // / NewRate
  4538. // + NewStartTime;
  4539. pHwDevExt->SubpicRate = NewRate;
  4540. if( NewRate == 10000 ) {
  4541. pHwDevExt->SubpicInterceptTime = 0;
  4542. pHwDevExt->SubpicStartTime = 0;
  4543. }
  4544. else {
  4545. pHwDevExt->SubpicInterceptTime = (-NewStartTime) * 10000 / NewRate + NewStartTime;
  4546. pHwDevExt->SubpicStartTime = NewStartTime;
  4547. }
  4548. SetRateChange( pHwDevExt, 0x04 );
  4549. }
  4550. pSrb->Status = STATUS_SUCCESS;
  4551. break;
  4552. case KS_AM_RATE_ExactRateChange :
  4553. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4554. break;
  4555. case KS_AM_RATE_MaxFullDataRate :
  4556. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4557. break;
  4558. case KS_AM_RATE_Step :
  4559. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4560. break;
  4561. }
  4562. }
  4563. void GetVideoRateChange( PHW_STREAM_REQUEST_BLOCK pSrb )
  4564. {
  4565. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  4566. DebugPrint( (DebugLevelTrace, "TOSDVD: GetVideoRateChange\r\n") );
  4567. switch( pSrb->CommandData.PropertyInfo->Property->Id ) {
  4568. case KS_AM_RATE_SimpleRateChange :
  4569. {
  4570. KS_AM_SimpleRateChange* pRateChange;
  4571. DebugPrint( (DebugLevelTrace, "TOSDVD: KS_AM_RATE_SimpleRateChange\r\n") );
  4572. pSrb->ActualBytesTransferred = sizeof (KS_AM_RATE_SimpleRateChange);
  4573. pRateChange = (KS_AM_SimpleRateChange*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  4574. pRateChange->StartTime = pHwDevExt->VideoStartTime;
  4575. pRateChange->Rate = pHwDevExt->VideoRate;
  4576. }
  4577. pSrb->Status = STATUS_SUCCESS;
  4578. break;
  4579. case KS_AM_RATE_ExactRateChange :
  4580. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4581. break;
  4582. case KS_AM_RATE_MaxFullDataRate :
  4583. {
  4584. KS_AM_MaxFullDataRate* pMaxRate;
  4585. DebugPrint( (DebugLevelTrace, "TOSDVD: KS_AM_RATE_MaxFullDataRate\r\n") );
  4586. pSrb->ActualBytesTransferred = sizeof (KS_AM_RATE_MaxFullDataRate);
  4587. pMaxRate = (KS_AM_MaxFullDataRate*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  4588. *pMaxRate = pHwDevExt->VideoMaxFullRate;
  4589. }
  4590. pSrb->Status = STATUS_SUCCESS;
  4591. break;
  4592. case KS_AM_RATE_Step :
  4593. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4594. break;
  4595. }
  4596. }
  4597. void GetAudioRateChange( PHW_STREAM_REQUEST_BLOCK pSrb )
  4598. {
  4599. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  4600. DebugPrint( (DebugLevelTrace, "TOSDVD: GetAudioRateChange\r\n") );
  4601. switch( pSrb->CommandData.PropertyInfo->Property->Id ) {
  4602. case KS_AM_RATE_SimpleRateChange :
  4603. {
  4604. KS_AM_SimpleRateChange* pRateChange;
  4605. DebugPrint( (DebugLevelTrace, "TOSDVD: KS_AM_RATE_SimpleRateChange\r\n") );
  4606. pSrb->ActualBytesTransferred = sizeof (KS_AM_RATE_SimpleRateChange);
  4607. pRateChange = (KS_AM_SimpleRateChange*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  4608. pRateChange->StartTime = pHwDevExt->AudioStartTime;
  4609. pRateChange->Rate = pHwDevExt->AudioRate;
  4610. }
  4611. pSrb->Status = STATUS_SUCCESS;
  4612. break;
  4613. case KS_AM_RATE_ExactRateChange :
  4614. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4615. break;
  4616. case KS_AM_RATE_MaxFullDataRate :
  4617. {
  4618. KS_AM_MaxFullDataRate* pMaxRate;
  4619. DebugPrint( (DebugLevelTrace, "TOSDVD: KS_AM_RATE_MaxFullDataRate\r\n") );
  4620. pSrb->ActualBytesTransferred = sizeof (KS_AM_RATE_MaxFullDataRate);
  4621. pMaxRate = (KS_AM_MaxFullDataRate*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  4622. *pMaxRate = pHwDevExt->AudioMaxFullRate;
  4623. }
  4624. pSrb->Status = STATUS_SUCCESS;
  4625. break;
  4626. case KS_AM_RATE_Step :
  4627. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4628. break;
  4629. }
  4630. }
  4631. void GetSubpicRateChange( PHW_STREAM_REQUEST_BLOCK pSrb )
  4632. {
  4633. PHW_DEVICE_EXTENSION pHwDevExt = (PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension;
  4634. DebugPrint( (DebugLevelTrace, "TOSDVD: GetSubpicRateChange\r\n") );
  4635. switch( pSrb->CommandData.PropertyInfo->Property->Id ) {
  4636. case KS_AM_RATE_SimpleRateChange :
  4637. {
  4638. KS_AM_SimpleRateChange* pRateChange;
  4639. DebugPrint( (DebugLevelTrace, "TOSDVD: KS_AM_RATE_SimpleRateChange\r\n") );
  4640. pSrb->ActualBytesTransferred = sizeof (KS_AM_RATE_SimpleRateChange);
  4641. pRateChange = (KS_AM_SimpleRateChange*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  4642. pRateChange->StartTime = pHwDevExt->SubpicStartTime;
  4643. pRateChange->Rate = pHwDevExt->SubpicRate;
  4644. }
  4645. pSrb->Status = STATUS_SUCCESS;
  4646. break;
  4647. case KS_AM_RATE_ExactRateChange :
  4648. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4649. break;
  4650. case KS_AM_RATE_MaxFullDataRate :
  4651. {
  4652. KS_AM_MaxFullDataRate* pMaxRate;
  4653. DebugPrint( (DebugLevelTrace, "TOSDVD: KS_AM_RATE_MaxFullDataRate\r\n") );
  4654. pSrb->ActualBytesTransferred = sizeof (KS_AM_RATE_MaxFullDataRate);
  4655. pMaxRate = (KS_AM_MaxFullDataRate*)pSrb->CommandData.PropertyInfo->PropertyInfo;
  4656. *pMaxRate = pHwDevExt->SubpicMaxFullRate;
  4657. }
  4658. pSrb->Status = STATUS_SUCCESS;
  4659. break;
  4660. case KS_AM_RATE_Step :
  4661. pSrb->Status = STATUS_NOT_IMPLEMENTED;
  4662. break;
  4663. }
  4664. }
  4665. //--- End.
  4666. void GetLPCMInfo( void *pBuf, PMYAUDIOFORMAT pfmt )
  4667. {
  4668. PUCHAR pDat = (PUCHAR)pBuf;
  4669. UCHAR headlen;
  4670. UCHAR val;
  4671. pDat += 14;
  4672. ASSERT( *( pDat + 3 ) == 0xBD );
  4673. headlen = *( pDat + 8 );
  4674. ASSERT( ( *( pDat + 9 + headlen ) & 0xF8 ) == 0xA0 );
  4675. val = (UCHAR)(( *( pDat + 9 + headlen + 5 ) & 0xC0 ) >> 6);
  4676. if( val == 0x00 ) {
  4677. DebugPrint(( DebugLevelTrace, "TOSDVD: 16bits\r\n" ));
  4678. pfmt->dwQuant = AUDIO_QUANT_16;
  4679. }
  4680. else if( val == 0x01 ) {
  4681. DebugPrint(( DebugLevelTrace, "TOSDVD: 20bits\r\n" ));
  4682. pfmt->dwQuant = AUDIO_QUANT_20;
  4683. }
  4684. else if( val == 0x10 ) {
  4685. DebugPrint(( DebugLevelTrace, "TOSDVD: 24bits\r\n" ));
  4686. pfmt->dwQuant = AUDIO_QUANT_24;
  4687. }
  4688. else
  4689. TRAP;
  4690. val = (UCHAR)(( *( pDat + 9 + headlen + 5 ) & 0x30 ) >> 4);
  4691. if( val == 0x00 ) {
  4692. DebugPrint(( DebugLevelTrace, "TOSDVD: 48kHz\r\n" ));
  4693. pfmt->dwFreq = AUDIO_FS_48;
  4694. }
  4695. else if( val == 0x01 ) {
  4696. DebugPrint(( DebugLevelTrace, "TOSDVD: 96kHz\r\n" ));
  4697. pfmt->dwFreq = AUDIO_FS_96;
  4698. }
  4699. else
  4700. TRAP;
  4701. return;
  4702. }