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.

361 lines
11 KiB

  1. //==========================================================================;
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1992 - 1998 Microsoft Corporation. All Rights Reserved.
  9. //
  10. //==========================================================================;
  11. #ifndef __STREAMIP_H__
  12. #define __STREAMIP_H__
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif // __cplusplus
  16. #define ENTRIES(a) (sizeof(a)/sizeof(*(a)))
  17. /**************************************************************/
  18. /* Driver Name - Change this to reflect your executable name! */
  19. /**************************************************************/
  20. #define STREAMIPNAME "STREAMIP"
  21. #define STREAMIPNAMEUNICODE L"STREAMIP"
  22. // This defines the name of the WMI device that manages service IOCTLS
  23. #define CodecDeviceName (L"\\\\.\\" STREAMIPNAMEUNICODE)
  24. #define CodecSymbolicName (L"\\DosDevices\\" STREAMIPNAMEUNICODE)
  25. // ------------------------------------------------------------------------
  26. // The master list of all streams supported by this driver
  27. // ------------------------------------------------------------------------
  28. typedef enum
  29. {
  30. STREAM_IP,
  31. STREAM_NET_CONTROL
  32. };
  33. // The MAX_STREAM_COUNT value must be equal to DRIVER_STREAM_COUNT
  34. // This particular value must be defined here to avoid circular references
  35. #define MAX_STREAM_COUNT 1
  36. // We manage multiple instances of each pin up to this limit
  37. #define MAX_PIN_INSTANCES 8
  38. #define BIT(n) (1L<<(n))
  39. #define BITSIZE(v) (sizeof(v)*8)
  40. #define SETBIT(array,n) (array[n/BITSIZE(*array)] |= BIT(n%BITSIZE(*array)))
  41. #define CLEARBIT(array,n) (array[n/BITSIZE(*array)] &= ~BIT(n%BITSIZE(*array)))
  42. /*****************************************************************************
  43. *
  44. * The following structures are samples of information that could be used in
  45. * a device extension structure
  46. *
  47. *****************************************************************************/
  48. //
  49. // this structure is our per stream extension structure. This stores
  50. // information that is relevant on a per stream basis. Whenever a new stream
  51. // is opened, the stream class driver will allocate whatever extension size
  52. // is specified in the HwInitData.PerStreamExtensionSize.
  53. //
  54. typedef struct _STREAM_
  55. {
  56. PIPSINK_FILTER pFilter;
  57. PHW_STREAM_OBJECT pStreamObject; // For timer use
  58. KSSTATE KSState; // Run, Stop, Pause
  59. REFERENCE_TIME FrameTime100ns; // elapsed time based on frames captured
  60. HANDLE hMasterClock;
  61. HANDLE hClock;
  62. ULONG ulStreamInstance; // 0..NumberOfPossibleInstances-1
  63. KSDATAFORMAT OpenedFormat; // Based on the actual open request.
  64. KSDATARANGE MatchedFormat;
  65. KSPIN_LOCK StreamControlSpinLock; // Command queue spin lock
  66. KSPIN_LOCK StreamDataSpinLock; // Data queue spin lock
  67. LIST_ENTRY StreamDataQueue; // Stream data queue
  68. LIST_ENTRY StreamControlQueue; // Stream command queue
  69. } STREAM, *PSTREAM;
  70. //
  71. // This structure is our per SRB extension, and carries the forward and backward
  72. // links for the pending SRB queue.
  73. //
  74. typedef struct _SRB_EXTENSION
  75. {
  76. LIST_ENTRY ListEntry;
  77. PHW_STREAM_REQUEST_BLOCK pSrb;
  78. } SRB_EXTENSION, *PSRB_EXTENSION;
  79. /*****************************************************************************
  80. *
  81. * the following section defines prototypes for the minidriver initialization
  82. * routines
  83. *
  84. ******************************************************************************/
  85. //
  86. // This routine is called by the stream class driver with configuration
  87. // information for an adapter that the mini driver should load on. The mini
  88. // driver should still perform a small verification to determine that the
  89. // adapter is present at the specified addresses, but should not attempt to
  90. // find an adapter as it would have with previous NT miniports.
  91. //
  92. // All initialization of the codec should also be performed at this time.
  93. //
  94. BOOLEAN CodecInitialize (IN OUT PHW_STREAM_REQUEST_BLOCK pSrb);
  95. //
  96. // This routine is called when the system is going to remove or disable the
  97. // device.
  98. //
  99. // The mini-driver should free any system resources that it allocated at this
  100. // time. Note that system resources allocated for the mini-driver by the
  101. // stream class driver will be free'd by the stream driver, and should not be
  102. // free'd in this routine. (Such as the HW_DEVICE_EXTENSION)
  103. //
  104. BOOLEAN CodecUnInitialize( PHW_STREAM_REQUEST_BLOCK pSrb);
  105. BOOLEAN CodecQueryUnload ( PHW_STREAM_REQUEST_BLOCK pSrb); // Not implemented currently
  106. //
  107. // This is the prototype for the Hardware Interrupt Handler. This routine
  108. // will be called if the minidriver registers for and receives an interrupt
  109. //
  110. BOOLEAN HwInterrupt (IN PIPSINK_FILTER pFilter);
  111. //
  112. // This is the prototype for the stream enumeration function. This routine
  113. // provides the stream class driver with the information on data stream types
  114. // supported
  115. //
  116. VOID CodecStreamInfo(PHW_STREAM_REQUEST_BLOCK pSrb);
  117. //
  118. // This is the prototype for the stream open function
  119. //
  120. VOID CodecOpenStream(PHW_STREAM_REQUEST_BLOCK pSrb);
  121. //
  122. // This is the prototype for the stream close function
  123. //
  124. VOID CodecCloseStream(PHW_STREAM_REQUEST_BLOCK pSrb);
  125. //
  126. // This is the prototype for the CodecReceivePacket routine. This is the
  127. // entry point for command packets that are sent to the codec (not to a
  128. // specific open stream)
  129. //
  130. VOID STREAMAPI CodecReceivePacket(IN PHW_STREAM_REQUEST_BLOCK Srb);
  131. //
  132. // This is the protoype for the cancel packet routine. This routine enables
  133. // the stream class driver to cancel an outstanding packet.
  134. //
  135. VOID STREAMAPI CodecCancelPacket(IN PHW_STREAM_REQUEST_BLOCK Srb);
  136. //
  137. // This is the packet timeout function. The codec may choose to ignore a
  138. // packet timeout, or reset the codec and cancel the requests, as required.
  139. //
  140. VOID STREAMAPI CodecTimeoutPacket(IN PHW_STREAM_REQUEST_BLOCK Srb);
  141. VOID STREAMAPI CodecGetProperty(IN PHW_STREAM_REQUEST_BLOCK Srb);
  142. VOID STREAMAPI CodecSetProperty(IN PHW_STREAM_REQUEST_BLOCK Srb);
  143. BOOL
  144. CodecVerifyFormat(IN KSDATAFORMAT *pKSDataFormat,
  145. UINT StreamNumber,
  146. PKSDATARANGE pMatchedFormat);
  147. BOOL
  148. CodecFormatFromRange(
  149. IN PHW_STREAM_REQUEST_BLOCK pSrb);
  150. void
  151. CompleteStreamSRB (
  152. IN PHW_STREAM_REQUEST_BLOCK pSrb,
  153. STREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE NotificationType1,
  154. BOOL fUseNotification2,
  155. STREAM_MINIDRIVER_STREAM_NOTIFICATION_TYPE NotificationType2
  156. );
  157. void
  158. CompleteDeviceSRB (
  159. IN PHW_STREAM_REQUEST_BLOCK pSrb,
  160. IN STREAM_MINIDRIVER_DEVICE_NOTIFICATION_TYPE NotificationType,
  161. BOOL fReadyForNext
  162. );
  163. //
  164. // prototypes for data handling routines
  165. //
  166. void CompleteStreamIRP (IN PHW_STREAM_REQUEST_BLOCK pSrb, BOOLEAN ReadyForNext);
  167. VOID STREAMAPI VideoReceiveDataPacket(IN PHW_STREAM_REQUEST_BLOCK pSrb);
  168. VOID STREAMAPI VideoReceiveCtrlPacket(IN PHW_STREAM_REQUEST_BLOCK pSrb);
  169. void EnableIRQ(PHW_STREAM_OBJECT pstrm);
  170. void DisableIRQ(PHW_STREAM_OBJECT pstrm);
  171. //
  172. // prototypes for properties and states
  173. //
  174. VOID VideoSetState(PHW_STREAM_REQUEST_BLOCK pSrb);
  175. VOID VideoGetState(PHW_STREAM_REQUEST_BLOCK pSrb);
  176. VOID VideoSetProperty(PHW_STREAM_REQUEST_BLOCK pSrb);
  177. VOID VideoGetProperty(PHW_STREAM_REQUEST_BLOCK pSrb);
  178. //VOID VideoStreamSetConnectionProperty (PHW_STREAM_REQUEST_BLOCK pSrb); // Not implemented
  179. VOID VideoStreamGetConnectionProperty (PHW_STREAM_REQUEST_BLOCK pSrb);
  180. VOID VideoStreamSetVBIFilteringProperty (PHW_STREAM_REQUEST_BLOCK pSrb);
  181. VOID VideoStreamGetVBIFilteringProperty (PHW_STREAM_REQUEST_BLOCK pSrb);
  182. //
  183. // system time functions
  184. //
  185. ULONGLONG VideoGetSystemTime();
  186. //
  187. // stream clock functions
  188. //
  189. VOID VideoIndicateMasterClock(PHW_STREAM_REQUEST_BLOCK pSrb);
  190. //
  191. // SRB Queue Management functions
  192. //
  193. BOOL STREAMAPI QueueAddIfNotEmpty(
  194. IN PHW_STREAM_REQUEST_BLOCK,
  195. IN PKSPIN_LOCK,
  196. IN PLIST_ENTRY
  197. );
  198. BOOL STREAMAPI QueueAdd(
  199. IN PHW_STREAM_REQUEST_BLOCK,
  200. IN PKSPIN_LOCK,
  201. IN PLIST_ENTRY
  202. );
  203. BOOL STREAMAPI QueueRemove(
  204. IN OUT PHW_STREAM_REQUEST_BLOCK *,
  205. IN PKSPIN_LOCK,
  206. IN PLIST_ENTRY
  207. );
  208. BOOL STREAMAPI QueueRemoveSpecific(
  209. IN PHW_STREAM_REQUEST_BLOCK,
  210. IN PKSPIN_LOCK,
  211. IN PLIST_ENTRY
  212. );
  213. BOOL STREAMAPI QueueEmpty(
  214. IN PKSPIN_LOCK,
  215. IN PLIST_ENTRY
  216. );
  217. #ifdef __cplusplus
  218. }
  219. #endif // __cplusplus
  220. VOID
  221. STREAMAPI
  222. CodecReceivePacket(
  223. IN PHW_STREAM_REQUEST_BLOCK pSrb
  224. );
  225. BOOLEAN
  226. CodecInitialize (
  227. IN OUT PHW_STREAM_REQUEST_BLOCK pSrb
  228. );
  229. VOID
  230. STREAMAPI
  231. CodecCancelPacket(
  232. PHW_STREAM_REQUEST_BLOCK pSrb
  233. );
  234. VOID
  235. STREAMAPI
  236. CodecTimeoutPacket(
  237. PHW_STREAM_REQUEST_BLOCK pSrb
  238. );
  239. NTSTATUS
  240. LinkToNdisHandler (
  241. PVOID pvContext
  242. );
  243. BOOL
  244. CompareGUIDsAndFormatSize(
  245. IN PKSDATARANGE pDataRange1,
  246. IN PKSDATARANGE pDataRange2,
  247. BOOLEAN bCheckSize
  248. );
  249. BOOL
  250. CompareStreamFormat (
  251. IN PHW_STREAM_REQUEST_BLOCK pSrb
  252. );
  253. BOOLEAN
  254. VerifyFormat(
  255. IN KSDATAFORMAT *pKSDataFormat,
  256. UINT StreamNumber,
  257. PKSDATARANGE pMatchedFormat
  258. );
  259. VOID
  260. OpenStream (
  261. PHW_STREAM_REQUEST_BLOCK pSrb
  262. );
  263. VOID
  264. CloseStream (
  265. PHW_STREAM_REQUEST_BLOCK pSrb
  266. );
  267. VOID
  268. STREAMAPI
  269. ReceiveDataPacket (
  270. IN PHW_STREAM_REQUEST_BLOCK pSrb
  271. );
  272. NTSTATUS
  273. STREAMAPI
  274. EventHandler (
  275. IN PHW_EVENT_DESCRIPTOR pEventDesriptor
  276. );
  277. VOID
  278. STREAMAPI
  279. ReceiveCtrlPacket(
  280. IN PHW_STREAM_REQUEST_BLOCK pSrb
  281. );
  282. VOID
  283. IpSinkSetState(
  284. PHW_STREAM_REQUEST_BLOCK pSrb
  285. );
  286. #endif // _STREAM_IP_H_