Leaked source code of windows server 2003
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.

190 lines
6.0 KiB

  1. //==========================================================================;
  2. //
  3. // MiniDriver entry points for stream class driver
  4. //
  5. // $Date: 05 Aug 1998 11:11:18 $
  6. // $Revision: 1.0 $
  7. // $Author: Tashjian $
  8. //
  9. // $Copyright: (c) 1997 - 1998 ATI Technologies Inc. All Rights Reserved. $
  10. //
  11. //==========================================================================;
  12. extern "C"
  13. {
  14. #include "strmini.h"
  15. #include "ksmedia.h"
  16. }
  17. #include "DrvEntry.h"
  18. #include "wdmvdec.h"
  19. #include "wdmdrv.h"
  20. #include "capdebug.h"
  21. #include "VidStrm.h"
  22. /*^^*
  23. * DriverEntry()
  24. * Purpose : Called when an SRB_INITIALIZE_DEVICE request is received
  25. *
  26. * Inputs : IN PDRIVER_OBJECT pDriverObject
  27. * IN PUNICODE_STRING pRegistryPath
  28. *
  29. * Outputs : result of StreamClassregisterAdapter()
  30. * Author : IKLEBANOV
  31. *^^*/
  32. extern "C"
  33. ULONG DriverEntry ( IN PDRIVER_OBJECT pDriverObject,
  34. IN PUNICODE_STRING pRegistryPath )
  35. {
  36. HW_INITIALIZATION_DATA HwInitData;
  37. SetMiniDriverDebugLevel(pRegistryPath);
  38. DBGTRACE(("DriverEntry\n"));
  39. RtlZeroMemory(&HwInitData, sizeof(HwInitData));
  40. HwInitData.HwInitializationDataSize = sizeof(HwInitData);
  41. // Entry points for Port Driver
  42. HwInitData.HwInterrupt = NULL; // HwInterrupt;
  43. HwInitData.HwReceivePacket = ReceivePacket;
  44. HwInitData.HwCancelPacket = CancelPacket;
  45. HwInitData.HwRequestTimeoutHandler = TimeoutPacket;
  46. HwInitData.DeviceExtensionSize = DeivceExtensionSize();
  47. HwInitData.PerRequestExtensionSize = sizeof(SRB_DATA_EXTENSION);
  48. HwInitData.FilterInstanceExtensionSize = 0;
  49. HwInitData.PerStreamExtensionSize = streamDataExtensionSize;
  50. HwInitData.BusMasterDMA = FALSE;
  51. HwInitData.Dma24BitAddresses = FALSE;
  52. HwInitData.BufferAlignment = 3;
  53. HwInitData.TurnOffSynchronization = TRUE;
  54. HwInitData.DmaBufferSize = 0;
  55. DBGTRACE(("StreamClassRegisterAdapter\n"));
  56. return(StreamClassRegisterAdapter(pDriverObject, pRegistryPath, &HwInitData));
  57. }
  58. /*^^*
  59. * ReceivePacket()
  60. * Purpose : Main entry point for receiving adapter based request SRBs from the Class Driver.
  61. * Will always be called at High Priority.
  62. * Note : This is an asyncronous entry point. The request does not complete on return from
  63. * this function, the request only completes when a StreamClassDeviceNotification
  64. * on this request block, of type DeviceRequestComplete, is issued.
  65. *
  66. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  67. *
  68. * Outputs : none
  69. * Author : IKLEBANOV
  70. *^^*/
  71. void STREAMAPI ReceivePacket(IN OUT PHW_STREAM_REQUEST_BLOCK pSrb)
  72. {
  73. DBGINFO(("ReceivePacket() SRB = %x, Command = %x\n",
  74. pSrb, pSrb->Command));
  75. // This needs to be a special case because no spinlocks, etc
  76. // have been initialized until HwInitialize runs. Even though
  77. // this minidriver handles synchronization itself, it assumes
  78. // that no adapter SRBs will arrive until after this one
  79. // completes.
  80. if (pSrb->Command == SRB_INITIALIZE_DEVICE)
  81. {
  82. DBGTRACE(("SRB_INITIALIZE_DEVICE; SRB=%x\n", pSrb));
  83. SrbInitializeDevice(pSrb);
  84. StreamClassDeviceNotification(DeviceRequestComplete, pSrb->HwDeviceExtension, pSrb);
  85. }
  86. else
  87. {
  88. CWDMVideoDecoder* pCWDMVideoDecoder = (CWDMVideoDecoder*)pSrb->HwDeviceExtension;
  89. // check the device extension pointer
  90. if(pCWDMVideoDecoder == NULL)
  91. {
  92. DBGERROR(("ReceivePacket(): Device extension pointer is null!\n"));
  93. TRAP();
  94. pSrb->Status = STATUS_INVALID_PARAMETER;
  95. StreamClassDeviceNotification(DeviceRequestComplete, pSrb->HwDeviceExtension, pSrb);
  96. }
  97. else
  98. pCWDMVideoDecoder->ReceivePacket(pSrb);
  99. }
  100. }
  101. void STREAMAPI CancelPacket(IN OUT PHW_STREAM_REQUEST_BLOCK pSrb)
  102. {
  103. CWDMVideoDecoder* pCWDMVideoDecoder = (CWDMVideoDecoder*)pSrb->HwDeviceExtension;
  104. pCWDMVideoDecoder->CancelPacket(pSrb);
  105. }
  106. void STREAMAPI TimeoutPacket(IN OUT PHW_STREAM_REQUEST_BLOCK pSrb)
  107. {
  108. CWDMVideoDecoder* pCWDMVideoDecoder = (CWDMVideoDecoder*)pSrb->HwDeviceExtension;
  109. pCWDMVideoDecoder->TimeoutPacket(pSrb);
  110. }
  111. /*^^*
  112. * SrbInitializeDevice()
  113. * Purpose : Called when SRB_INITIALIZE_DEVICE SRB is received.
  114. * Performs checking of the hardware presence and I2C provider availability.
  115. * Sets the hardware in an initial state.
  116. * Note : The request does not completed unless we know everything
  117. * about the hardware and we are sure it is capable to work in the current configuration.
  118. * The hardware Caps are also aquised at this point.
  119. *
  120. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  121. *
  122. * Outputs : none
  123. * Author : IKLEBANOV
  124. *^^*/
  125. void SrbInitializeDevice(PHW_STREAM_REQUEST_BLOCK pSrb)
  126. {
  127. DBGTRACE(("SrbInitializeDevice()\n"));
  128. PPORT_CONFIGURATION_INFORMATION pConfigInfo = pSrb->CommandData.ConfigInfo;
  129. pSrb->Status = STATUS_SUCCESS;
  130. ENSURE
  131. {
  132. PBYTE pHwDevExt = (PBYTE)pConfigInfo->HwDeviceExtension;
  133. if (pConfigInfo->NumberOfAccessRanges != 0) {
  134. DBGERROR(("Illegal config info!\n"));
  135. pSrb->Status = STATUS_NO_SUCH_DEVICE;
  136. TRAP();
  137. FAIL;
  138. }
  139. CVideoDecoderDevice * pDevice = InitializeDevice(pConfigInfo, pHwDevExt);
  140. if (!pDevice)
  141. {
  142. DBGERROR(("CI2CScript creation failure!\n"));
  143. pSrb->Status = STATUS_NO_SUCH_DEVICE;
  144. TRAP();
  145. FAIL;
  146. }
  147. CWDMVideoDecoder *pCWDMVideoDecoder = (CWDMVideoDecoder *) new ((PVOID)pHwDevExt)
  148. CWDMVideoDecoder(pConfigInfo, pDevice);
  149. } END_ENSURE;
  150. DBGTRACE(("Exit : SrbInitializeDevice()\n"));
  151. }