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.

575 lines
13 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 2000 - 2001
  3. Module Name:
  4. MsTpDef.h
  5. Abstract:
  6. Header file for all of AV/C tape subunit
  7. Last changed by:
  8. $Author:: $
  9. Environment:
  10. Kernel mode only
  11. Revision History:
  12. $Revision:: $
  13. $Date:: $
  14. --*/
  15. #ifndef _DVCRDEF_INC
  16. #define _DVCRDEF_INC
  17. #include "AVCStrm.h"
  18. #define DRIVER_TAG (ULONG)'USpT' // Tape SubUnit
  19. #undef ExAllocatePool
  20. #define ExAllocatePool(type, size) \
  21. ExAllocatePoolWithTag (type, size, DRIVER_TAG)
  22. //
  23. // In order to send a request to lower driver, we need an irp and the request block.
  24. //
  25. typedef struct _DRIVER_REQUEST {
  26. //
  27. // Link with other request (in attach or detach list)
  28. //
  29. LIST_ENTRY ListEntry;
  30. //
  31. // Some context and reserved
  32. //
  33. PVOID Context1;
  34. PVOID Context2;
  35. #if DBG
  36. //
  37. // Unique id of this data request
  38. //
  39. LONGLONG cntDataRequestReceived;
  40. #endif
  41. //
  42. // Irp used to send down a reqest
  43. //
  44. PIRP pIrp;
  45. //
  46. // Request block
  47. //
  48. AVC_STREAM_REQUEST_BLOCK AVCStrmReq;
  49. } DRIVER_REQUEST, *PDRIVER_REQUEST;
  50. //
  51. // Need to reference this in PSTRMEX
  52. //
  53. typedef struct _DVCR_EXTENSION;
  54. //
  55. // The index MUST match
  56. //
  57. typedef enum {
  58. FMT_IDX_SD_DVCR_NTSC = 0,
  59. FMT_IDX_SD_DVCR_PAL,
  60. #ifdef MSDV_SUPPORT_HD_DVCR
  61. FMT_IDX_HD_DVCR_NTSC,
  62. FMT_IDX_HD_DVCR_PAL,
  63. #endif
  64. #ifdef MSDV_SUPPORT_SDL_DVCR
  65. FMT_IDX_SDL_DVCR_NTSC,
  66. FMT_IDX_SDL_DVCR_PAL,
  67. #endif
  68. } FMT_INDEX, *PFMT_INDEX;
  69. #define MAX_DATA_BUFFERS 32 // Max data buffer (allocator framing)
  70. #define MAX_DATA_REQUESTS (MAX_DATA_BUFFERS+2) // 2 extra for optional flags "data request", such as EndOfStream.
  71. //
  72. // this structure is our per stream extension structure. This stores
  73. // information that is relevant on a per stream basis. Whenever a new stream
  74. // is opened, the stream class driver will allocate whatever extension size
  75. // is specified in the HwInitData.PerStreamExtensionSize.
  76. //
  77. typedef struct _STREAMEX {
  78. // return stream exension (a context) if a stream is open successfully
  79. // This context is used for subsequent call after a stream is opened.
  80. PVOID AVCStreamContext;
  81. //
  82. // Point to pSrb->HwDeviceExtension
  83. //
  84. struct _DVCR_EXTENSION * pDevExt;
  85. //
  86. // Cache pSrb->StreamObject:
  87. // ->HwStreamExtension (pStrmExt)
  88. // ->StreamNumber
  89. // ->HwDeviceExtension (pDevExt)
  90. //
  91. PHW_STREAM_OBJECT pStrmObject;
  92. //
  93. // ->NumberOfPossibleInstances;
  94. // ->DataFlow;
  95. //
  96. PHW_STREAM_INFORMATION pStrmInfo;
  97. //
  98. // Holds state
  99. //
  100. KSSTATE StreamState;
  101. //
  102. // Holds whether or not the dvcr is listening or receiving
  103. //
  104. // TRUE: successful REQUEST_ISOCH_LISTEN and REQUEST_ISOCH_TALK
  105. // FALSE: successful INIT and REQUEST_ISOCH_STOP
  106. //
  107. BOOLEAN bIsochIsActive; // Close associated with StreamState
  108. //
  109. // Set to TRUE when receiving KSSTREAM_HEADER_OPTIONSF_ENDOFSTREAM for SRB_WRITE_DATA
  110. // For SRB_WRITE_DATA only since then this driver servers as a renderer.
  111. //
  112. BOOL bEOStream;
  113. //
  114. // Count number of SRB_READ/WRITE_DATA received since last transiting to PAUSE state from STOP
  115. //
  116. LONGLONG cntSRBReceived;
  117. //
  118. // Count number of Data buffer has submitted for receiving or transmitting.
  119. //
  120. LONGLONG cntDataSubmitted;
  121. //
  122. // Statistic of the frame information since last start stream
  123. // PictureNumber = FramesProcessed + FramesDropped + cndSRBCancelled.
  124. //
  125. LONGLONG FramesProcessed; // Frame sent (including repeated)
  126. LONGLONG FramesDropped; // SRB not sent
  127. LONGLONG PictureNumber; // Number of SRB_XXX_DATA made it to or from 1394 bus
  128. //
  129. // Count number of SRB_READ/WRITE_DATA that was incompleted and cancelled
  130. //
  131. LONGLONG cntSRBCancelled;
  132. //
  133. // The stream time (master clock or not) is "almost" or near 0
  134. // when setting to RUN state and start increment.
  135. //
  136. LONGLONG CurrentStreamTime;
  137. //
  138. // Holds the master clock
  139. //
  140. HANDLE hMyClock; // If set, we can be a clock provider.
  141. HANDLE hMasterClock; // If set, we are the master clock.
  142. HANDLE hClock; // If set, other device on the same graph is the master clock.
  143. //
  144. // 2nd CIP Quadlet: 01:Fmt, 50/60:STYPE:RSv, SYT
  145. //
  146. BYTE cipQuad2[4];
  147. //
  148. // Timecode, RecDate and RecTime are all in pack format (4 bytes)
  149. //
  150. BOOL bATNUpdated;
  151. DWORD AbsTrackNumber; // LSB:BlankField
  152. BOOL bTimecodeUpdated;
  153. BYTE Timecode[4]; // hh:mm:ss,ff
  154. //
  155. // Regulate flow between between setting to STOP state and SRB_XXX_DATA
  156. //
  157. KMUTEX * hMutexFlow;
  158. //
  159. // Counter used to indicate starting of an work item to cancel
  160. //
  161. LONG lCancelStateWorkItem;
  162. BOOL AbortInProgress;
  163. //
  164. // Hold the work item
  165. //
  166. #ifdef USE_WDM110 // Win2000 code base
  167. PIO_WORKITEM pIoWorkItem;
  168. #else
  169. WORK_QUEUE_ITEM IoWorkItem;
  170. #endif
  171. //
  172. // TO singal that an work item is completed.
  173. //
  174. KEVENT hCancelDoneEvent;
  175. //
  176. // Stream open format
  177. //
  178. AVCSTRM_FORMAT_INFO AVCFormatInfo;
  179. //
  180. // AVCStrm request for issuing synchronous request
  181. KMUTEX * hMutexReq;
  182. PIRP pIrpReq;
  183. AVC_STREAM_REQUEST_BLOCK AVCStrmReq;
  184. //
  185. // free list
  186. //
  187. LONG cntDataDetached;
  188. LIST_ENTRY DataDetachedListHead;
  189. //
  190. // busy list
  191. //
  192. LONG cntDataAttached;
  193. LIST_ENTRY DataAttachedListHead;
  194. //
  195. // AVCStrem request for asynchronous request, such as read and write data
  196. //
  197. DRIVER_REQUEST AsyncReq[MAX_DATA_REQUESTS];
  198. //
  199. // AVCStrm request for issuing synchronous request to abort at DISPATCH_LEVEL
  200. //
  201. PIRP pIrpAbort;
  202. AVC_STREAM_REQUEST_BLOCK AVCStrmReqAbort;
  203. //
  204. // Data list lock
  205. //
  206. KSPIN_LOCK * DataListLock;
  207. //
  208. // DPC and TIMER objects; this is used for the signal clock events.
  209. //
  210. KDPC DPCTimer;
  211. KTIMER Timer;
  212. } STREAMEX, *PSTREAMEX;
  213. //
  214. // Max number of input and output PCR an AVC can support
  215. //
  216. #define MAX_NUM_PCR 31
  217. #define MAX_PAYLOAD 1024
  218. //
  219. // Structure for a plug control register
  220. //
  221. typedef struct _AVC_DEV_PLUG {
  222. //
  223. // Plug handle of a PCR returned from 61883.sys
  224. //
  225. HANDLE hPlug;
  226. //
  227. // PCR's state; this is dynamic and is consider as a snap shot.
  228. //
  229. CMP_GET_PLUG_STATE PlugState;
  230. } AVC_DEV_PLUG, *PAVC_DEV_PLUG;
  231. //
  232. // Structure for a max (31) plug control registers
  233. //
  234. typedef struct _AVC_DEV_PLUGS {
  235. //
  236. // data rate of the device
  237. //
  238. ULONG MaxDataRate;
  239. //
  240. // Number of input or output plugs (as in i/oMPR)
  241. //
  242. ULONG NumPlugs;
  243. //
  244. // Array of plug handles and states;
  245. //
  246. AVC_DEV_PLUG DevPlug[MAX_NUM_PCR];
  247. } AVC_DEV_PLUGS, *PAVC_DEV_PLUGS;
  248. //
  249. // Device Extension for our Desktop Camera Driver
  250. //
  251. typedef struct _DVCR_EXTENSION {
  252. //
  253. // Holds video format supported by this device (presentaly allow only one format per device)
  254. //
  255. AVCSTRM_FORMAT VideoFormatIndex;
  256. //
  257. // Number of pin supported by this device; this usually equal to number of data range supported.
  258. //
  259. ULONG NumOfPins;
  260. //
  261. // Contain a table for the support formats (HW_STREAM_INFORMATION && HW_STREAM_OBJECT)
  262. //
  263. STREAM_INFO_AND_OBJ * pStreamInfoObject;
  264. //
  265. // Keep track of number of stream that is openned; in this driver, only one stream can be open at any time.
  266. //
  267. LONG cndStrmOpen; // [0..1]
  268. //
  269. // Count the stream index (pin index) that has been opened.
  270. //
  271. ULONG idxStreamNumber; // Index of current stream
  272. //
  273. // Can have only 1 Stream active at any time.
  274. // (Stream Class will allocate the stream extension at SRB_OPENSTREAM)
  275. //
  276. PSTREAMEX paStrmExt[3];
  277. //
  278. // Current Device Power State
  279. //
  280. DEVICE_POWER_STATE PowerState;
  281. //
  282. // TRUE only after SRB_SURPRISE_REMOVAL;
  283. //
  284. BOOL bDevRemoved;
  285. // The list of AVC commands that have been issued
  286. LIST_ENTRY AVCCmdList;
  287. // Number of completed commands waiting to be removed from the list
  288. // This includes:
  289. // Command response has returned and processed in the completion routine
  290. // Interim response awaiting final response
  291. LONG cntCommandQueued;
  292. // Protection for command processing
  293. KSPIN_LOCK AVCCmdLock;
  294. // The counted list of possible opcode values on response from Transport State status or notify
  295. UCHAR TransportModes[5]; // 0x4, [0xC1, 0xC2, 0xC3, 0xC4]
  296. UCHAR Reserved0[3];
  297. // Subunit type
  298. UCHAR Subunit_Type[4]; // There are only two subunits
  299. //
  300. // The device type (and its capabilities) cannot be determined until a tape is in
  301. //
  302. ULONG MediaType; // DVCR standard, small, medium; VHS; VHS-C; unknown
  303. ULONG ulDevType; // 0: undetermined, ED_DEVTYPE_CAMERA or ED_DEVTYPE_VCR
  304. BOOL bHasTape;
  305. BOOL bWriteProtected;
  306. BOOL bDVCPro;
  307. //
  308. // Save Unit capabilities:
  309. // Vendor and Model IDs
  310. //
  311. ULONG ulVendorID;
  312. ULONG ulModelID;
  313. LARGE_INTEGER UniqueID;
  314. //
  315. // AVC Device's output plugs
  316. //
  317. PAVC_DEV_PLUGS pDevOutPlugs;
  318. //
  319. // AVC Device's input plugs
  320. //
  321. PAVC_DEV_PLUGS pDevInPlugs;
  322. #ifdef SUPPORT_LOCAL_PLUGS
  323. //
  324. // Support local oPCR
  325. //
  326. AV_PCR OPCR;
  327. ULONG OutputPCRLocalNum;
  328. HANDLE hOutputPCRLocal;
  329. //
  330. // Support local iPCR
  331. //
  332. AV_PCR IPCR;
  333. ULONG InputPCRLocalNum;
  334. HANDLE hInputPCRLocal;
  335. #endif
  336. //
  337. // Holds the Device Object of our parent (1394 bus driver)
  338. //
  339. PDEVICE_OBJECT pBusDeviceObject; // IoCallDriver()
  340. //
  341. // Holds my Physical Device Object
  342. // pass it in PnP API, such as IoOpenDeviceRegistryKey()
  343. //
  344. PDEVICE_OBJECT pPhysicalDeviceObject;
  345. //
  346. // Cache device's Unit capa
  347. //
  348. GET_UNIT_IDS UnitIDs;
  349. #ifndef NT51_61883
  350. //
  351. // Add support for unit model text that 61883 does not support for its 1st version
  352. //
  353. //
  354. // 1394 generation count; used in 1394 asych operation.
  355. //
  356. ULONG GenerationCount;
  357. //
  358. // RootModelString
  359. //
  360. UNICODE_STRING UniRootModelString;
  361. //
  362. // UnitModelString
  363. //
  364. UNICODE_STRING UniUnitModelString;
  365. #endif
  366. //
  367. // Serialize in the event of getting two consecutive SRB_OPEN_STREAMs
  368. //
  369. KMUTEX hMutex;
  370. //
  371. // Irp for sychnonize call
  372. //
  373. PIRP pIrpSyncCall;
  374. #ifdef SUPPORT_NEW_AVC
  375. //
  376. // 61883 request
  377. //
  378. HANDLE hPlugLocalIn; // Generic i/oPLUG handle
  379. HANDLE hPlugLocalOut; // Generic i/oPLUG handle
  380. #endif
  381. AV_61883_REQUEST AVReq;
  382. // Pin and connection
  383. ULONG PinCount;
  384. AVC_MULTIFUNC_IRB AvcMultIrb;
  385. } DVCR_EXTENSION, *PDVCR_EXTENSION;
  386. //
  387. // Used to queue a SRB
  388. //
  389. typedef struct _SRB_ENTRY {
  390. LIST_ENTRY ListEntry;
  391. PHW_STREAM_REQUEST_BLOCK pSrb;
  392. BOOL bStale; // TRUE if it is marked stale but is the only Srb in the SrbQ
  393. // Audio Mute ?
  394. BOOL bAudioMute;
  395. #if DBG
  396. ULONG SrbNum;
  397. #endif
  398. } SRB_ENTRY, *PSRB_ENTRY;
  399. //
  400. // This is the context used to attach a frame
  401. //
  402. typedef struct _SRB_DATA_PACKET {
  403. // Build list
  404. LIST_ENTRY ListEntry;
  405. PHW_STREAM_REQUEST_BLOCK pSrb;
  406. PSTREAMEX pStrmExt; // Can get this from pSrb, here for convenience only!
  407. #if DBG
  408. BOOL bAttached; // TRUE if attached to 61883.
  409. #endif
  410. // Used to send 61883 request
  411. PIRP pIrp; // Use to attach and release.
  412. PCIP_FRAME Frame;
  413. PVOID FrameBuffer;
  414. //
  415. // Add debug related info here
  416. //
  417. LONGLONG FrameNumber;
  418. // Use to send 61883 AV data request
  419. AV_61883_REQUEST AVReq;
  420. } SRB_DATA_PACKET, *PSRB_DATA_PACKET;
  421. //
  422. // Wait time constants
  423. //
  424. #define DV_AVC_CMD_DELAY_STARTUP 500 // MSec
  425. #define DV_AVC_CMD_DELAY_INTER_CMD 20 // MSec
  426. #define DV_AVC_CMD_DELAY_DVCPRO 500 // MSec
  427. #endif