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.

388 lines
13 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1999 - 2000
  3. Module Name:
  4. msdvfmt.h
  5. Abstract:
  6. Header file for DV format data.
  7. Last changed by:
  8. $Author:: $
  9. Environment:
  10. Kernel mode only
  11. Revision History:
  12. $Revision:: $
  13. $Date:: $
  14. --*/
  15. #ifndef _DVFORMAT_INC
  16. #define _DVFORMAT_INC
  17. // ****************
  18. // Support switches
  19. // ****************
  20. //
  21. // Differnt level of WDM supports may use different API
  22. //
  23. // e.g. MmGetSystemAddressForMdl (win9x)
  24. // Return NULL for Win9x; bugcheck for Win2000 if NULL would have returned.
  25. //
  26. // MmGetSystemAddressForMdlSafe (win2000)
  27. // Not supported in Win9x or Millen
  28. //
  29. // #define USE_WDM110 // Define this if WDM1.10 is used; e.g. Win2000 code base // Define in SOURCES if needed
  30. //
  31. // Turn this on to support HD DVCR
  32. //#define MSDV_SUPPORT_HD_DVCR
  33. //
  34. // Turn this on to support SDL DVCR
  35. //
  36. #define MSDV_SUPPORT_SDL_DVCR
  37. //
  38. // Turn on this switch to support bus reset KS event
  39. // #define MSDVDV_SUPPORT_BUSRESET_EVENT
  40. //
  41. // Turn this define to extract timecode from a video frame
  42. // Advantage: faster turn around compare to an AVC status command
  43. // #define MSDV_SUPPORT_EXTRACT_SUBCODE_DATA
  44. //
  45. // To get recorded date and time
  46. // #define MSDV_SUPPORT_EXTRACT_DV_DATE_TIME
  47. //
  48. // Mute audio when in pause state while transmitting to DV
  49. #define MSDV_SUPPORT_MUTE_AUDIO
  50. //
  51. // Support getting regitry value for this device
  52. // WORKITEM: enable this for Whistler
  53. // #define READ_CUTOMIZE_REG_VALUES
  54. //
  55. // Support wait a little until transport state control command is stabled before return
  56. //
  57. // #define SUPPORT_XPRT_STATE_WAIT_FOR_STABLE
  58. //
  59. // Support IQulityControl for the in pin
  60. //
  61. #define SUPPORT_QUALITY_CONTROL
  62. //
  63. // Suppoprt wait to preroll data at the RUN state
  64. //
  65. #define SUPPORT_PREROLL_AT_RUN_STATE
  66. //
  67. // Support a change in KsProxy to return "not ready" while transmitioning into the PAUSE state
  68. //
  69. #define SUPPORT_KSPROXY_PREROLL_CHANGE
  70. //
  71. // Support using AVC connect info for device to device connection
  72. //
  73. // #define SUPPORT_NEW_AVC
  74. //
  75. // Support Optimizing number of AVC Command retries for non-compliant devices
  76. //
  77. #define SUPPORT_OPTIMIZE_AVCCMD_RETRIES
  78. typedef struct _DV_FORMAT_INFO {
  79. // 2nd quadlet of the CIP header
  80. // cipQuad[0] = 10:[FMT]
  81. // cipQuad[1] = 50/60:STYPE:00
  82. // cipQuad[2]+cipQuad[3] = SYT
  83. UCHAR cipQuad[4];
  84. //
  85. // Holds the number of DIF sequences per vid format
  86. //
  87. ULONG ulNumOfDIFSequences;
  88. //
  89. // Number of receiving buffers
  90. //
  91. ULONG ulNumOfRcvBuffers;
  92. //
  93. // Number of transmitting buffers
  94. //
  95. ULONG ulNumOfXmtBuffers;
  96. //
  97. // Holds DV (audio and video) frame size
  98. //
  99. ULONG ulFrameSize;
  100. //
  101. // Approximate time per frame
  102. //
  103. ULONG ulAvgTimePerFrame;
  104. //
  105. // Number of source packet per frame
  106. //
  107. ULONG ulSrcPackets;
  108. //
  109. // Maximun number of source packets per frame
  110. //
  111. ULONG ulMaxSrcPackets;
  112. //
  113. // Holds the number of quadlets in each data block
  114. //
  115. ULONG DataBlockSize; // 00(256),01(01)...,ff(255) quadlets
  116. //
  117. // Holds the number of data blocks into which a source packet is divided.
  118. //
  119. ULONG FractionNumber; // 00(not divided), 01 (2 DataBlks), 10 (4), 11 (8)
  120. //
  121. // Quadlet padding count (0..7)
  122. //
  123. ULONG QuadPadCount;
  124. //
  125. // SourcePacketHeader: 0 (FALSE); else (TRUE)
  126. //
  127. ULONG SrcPktHeader;
  128. } DV_FORMAT_INFO, *PDV_FORMAT_INFO;
  129. //
  130. // DV format tables
  131. //
  132. typedef struct _ALL_STREAM_INFO {
  133. HW_STREAM_INFORMATION hwStreamInfo;
  134. HW_STREAM_OBJECT hwStreamObject;
  135. } ALL_STREAM_INFO, *PALL_STREAM_INFO;
  136. // All CIP sizes are in quads. The upper third byte is the size.
  137. #define CIP_HDR_FMT_DV 0x00
  138. #define CIP_HDR_FMT_DVCPRO 0x1e
  139. //
  140. // 1394 stuff
  141. //
  142. #define SPEED_100_INDEX 0
  143. #define SPEED_200_INDEX 1
  144. #define SPEED_400_INDEX 2
  145. #define CIP_DBS_SD_DVCR 120 // quadlets in a data block of the SD DVCR; BlueBook Part 2
  146. #define CIP_DBS_HD_DVCR 240 // quadlets in a data block of the HD DVCR; BlueBook Part 3
  147. #define CIP_DBS_SDL_DVCR 60 // quadlets in a data block of the SDL DVCR; BlueBook Part 5
  148. #define CIP_FN_SD_DVCR 0 // Data blocks in a source pacaket of SD DVCR; BlueBook Part 2
  149. #define CIP_FN_HD_DVCR 0 // Data blocks in a source pacaket of HD DVCR; BlueBook Part 3
  150. #define CIP_FN_SDL_DVCR 0 // Data blocks in a source pacaket of SDL DVCR; BlueBook Part 5
  151. #define MAX_FCP_PAYLOAD_SIZE 512
  152. // CIP header definition:
  153. // FMT: "Blue book" Part 1, page 25, Table 3; DVCR:000000
  154. #define FMT_DVCR 0x80 // 10:FMT(00:0000)
  155. #define FMT_DVCR_CANON 0x20 // 10:FMT(00:0000); but Canon return 00:FMT(10:0000)
  156. #define FMT_MPEG 0xa0 // 10:FMT(10:0000)
  157. // FDF
  158. #define FDF0_50_60_MASK 0x80
  159. #define FDF0_50_60_PAL 0x80
  160. #define FDF0_50_60_NTSC 0x00
  161. #define FDF0_STYPE_MASK 0x7c
  162. #define FDF0_STYPE_SD_DVCR 0x00 // STYPE: 000:00
  163. #define FDF0_STYPE_SDL_DVCR 0x04 // STYPE: 000:01
  164. #define FDF0_STYPE_HD_DVCR 0x08 // STYPE: 000:10
  165. #define FDF0_STYPE_SD_DVCPRO 0x78 // STYPE: 111:10
  166. //
  167. // FCP and AVCC stuff. Used in conjunction with defs in 1394.h
  168. //
  169. // DVCR:
  170. #define SUBUNIT_TYPE_CAMCORDER 4
  171. #define SUBUNIT_ID_CAMCORDER 0
  172. #define DIF_SEQS_PER_NTSC_FRAME 10 // SDDV
  173. #define DIF_SEQS_PER_PAL_FRAME 12 // SDDV
  174. #define DIF_SEQS_PER_NTSC_FRAME_SDL 5 // SDLDV
  175. #define DIF_SEQS_PER_PAL_FRAME_SDL 6 // SDLDV
  176. #define DIF_SEQS_PER_NTSC_FRAME_HD 10 // HDDV: same as SDDV but source packet is twice as big
  177. #define DIF_SEQS_PER_PAL_FRAME_HD 12 // HDDV: same as SDDV but source packet is twice as big
  178. #define SRC_PACKETS_PER_NTSC_FRAME 250
  179. #define SRC_PACKETS_PER_PAL_FRAME 300
  180. #define MAX_SRC_PACKETS_PER_NTSC_FRAME 267 // packets for a NTSC DV frame; "about" 29.97 FPS
  181. #define MAX_SRC_PACKETS_PER_PAL_FRAME 320 // packets for a PAL DV frame; exactly 25FPS
  182. #define MAX_SRC_PACKETS_PER_NTSC_FRAME_PAE 100 // SRC_PACKETS_PER_NTSC_FRAME/5
  183. #define MAX_SRC_PACKETS_PER_PAL_FRAME_PAE 120 // SRC_PACKETS_PER_PAL_FRAME/5
  184. #define FRAME_SIZE_SD_DVCR_NTSC 120000
  185. #define FRAME_SIZE_SD_DVCR_PAL 144000
  186. #define FRAME_SIZE_HD_DVCR_NTSC 240000
  187. #define FRAME_SIZE_HD_DVCR_PAL 288000
  188. #define FRAME_SIZE_SDL_DVCR_NTSC 60000
  189. #define FRAME_SIZE_SDL_DVCR_PAL 72000
  190. #define FRAME_TIME_NTSC 333667 // "about" 29.97
  191. #define FRAME_TIME_PAL 400000 // exactly 25
  192. #define PCR_OVERHEAD_ID_SDDV 0xf // 480; delays caused by IEEE 1394 bus parmeters
  193. #define PCR_PAYLOAD_SDDV (CIP_DBS_SD_DVCR + 2) // 120 * 4 + 2 * 4 = 480 + 8 = 488; 488/4 = 122 quadlet
  194. #define PCR_PAYLOAD_HDDV (CIP_DBS_HD_DVCR + 2) // 240 * 4 + 2 * 4 = 960 + 8 = 968; 968/4 = 242 quadlets
  195. #define PCR_PAYLOAD_SDLDV (CIP_DBS_SDL_DVCR + 2) // 60 * 4 + 2 * 4 = 240 + 8 = 248; 248/4 = 62 quadlets
  196. //
  197. // These definition and macros are used to calculate the picture numbers.
  198. // With OHCI spec, the data is returned with the 16bit Cycle time, which includes
  199. // 3 bits of SecondCount and 13 bits of the CycleCount. This "timer" will wrap in 8 seconds.
  200. //
  201. #define TIME_PER_CYCLE 1250 // One 1394 cycle; unit = 100 nsec
  202. #define CYCLES_PER_SECOND 8000
  203. #define MAX_SECOND_COUNTS 7 // The returned CycleTime contains 3 bits of SecondCount; that is 0..7
  204. #define MAX_CYCLES (MAX_SECOND_COUNTS + 1) * CYCLES_PER_SECOND // 0..MAX_CYCLES-1
  205. #define MAX_CYCLES_TIME (MAX_CYCLES * TIME_PER_CYCLE) // unit = 100nsec
  206. #define VALIDATE_CYCLE_COUNTS(CT) ASSERT(CT.CL_SecondCount <= 7 && CT.CL_CycleCount < CYCLES_PER_SECOND && CT.CL_CycleOffset == 0);
  207. #define CALCULATE_CYCLE_COUNTS(CT) (CT.CL_SecondCount * CYCLES_PER_SECOND + CT.CL_CycleCount);
  208. #define CALCULATE_DELTA_CYCLE_COUNT(prev, now) ((now > prev) ? now - prev : now + MAX_CYCLES - prev)
  209. //
  210. // Return avg time per frame in the unit of 100 nsec;
  211. // for calculation accuracy using only integer calculation,
  212. // we should do do multimplcation before division.
  213. // That is why the application can request to get numerator and denominator separately.
  214. //
  215. #define GET_AVG_TIME_PER_FRAME(format) ((format == FMT_IDX_SD_DVCR_NTSC || format == FMT_IDX_SDL_DVCR_NTSC) ? (1001000/3) : FRAME_TIME_PAL)
  216. #define GET_AVG_TIME_PER_FRAME_NUM(format) ((format == FMT_IDX_SD_DVCR_NTSC || format == FMT_IDX_SDL_DVCR_NTSC) ? 1001000 : 400000)
  217. #define GET_AVG_TIME_PER_FRAME_DENOM(format) ((format == FMT_IDX_SD_DVCR_NTSC || format == FMT_IDX_SDL_DVCR_NTSC) ? 3 : 1)
  218. #define GET_NUM_PACKETS_PER_FRAME(format) ((format == FMT_IDX_SD_DVCR_NTSC || format == FMT_IDX_SDL_DVCR_NTSC) ? 4004/15 /* 100100/375 */ : MAX_SRC_PACKETS_PER_PAL_FRAME)
  219. #define GET_NUM_PACKETS_PER_FRAME_NUM(format) ((format == FMT_IDX_SD_DVCR_NTSC || format == FMT_IDX_SDL_DVCR_NTSC) ? 4004 : MAX_SRC_PACKETS_PER_PAL_FRAME)
  220. #define GET_NUM_PACKETS_PER_FRAME_DENOM(format) ((format == FMT_IDX_SD_DVCR_NTSC || format == FMT_IDX_SDL_DVCR_NTSC) ? 15 : 1)
  221. //
  222. // Data buffers
  223. //
  224. #define DV_NUM_OF_RCV_BUFFERS 16 // Same as number of transmit buffer
  225. #define NUM_BUF_ATTACHED_THEN_ISOCH 4 // number of buffers attached before streaming and also as the water mark.
  226. #define NUM_BUFFER_BEFORE_TRANSMIT_BEGIN (NUM_BUF_ATTACHED_THEN_ISOCH + 1) // One extra to avoid repeat frame
  227. #define DV_NUM_EXTRA_USER_XMT_BUFFERS 12 // Extra user buffers that the data source can send to us as a read ahead.
  228. #define DV_NUM_OF_XMT_BUFFERS (NUM_BUF_ATTACHED_THEN_ISOCH + DV_NUM_EXTRA_USER_XMT_BUFFERS)
  229. //
  230. // The "signature" of the header section of Seq0 of incoming source packets:
  231. //
  232. // "Blue" book, Part2, 11.4 (page 50); Figure 66, table 36 (page 111)
  233. //
  234. // ID0 = {SCT2,SCT1,SCT0,RSV,Seq3,Seq2,Seq1,Seq0}
  235. //
  236. // SCT2-0 = {0,0,0} = Header Section Type
  237. // RSV = {1}
  238. // Seq3-0 = {1,1,1,1} for NoInfo or {0,0,0,} for Sequence 0
  239. //
  240. // ID1 = {DSeq3-0, 0, RSV, RSV, RSV}
  241. // DSeq3-0 = {0, 0, 0, 0} = Beginning of a DV frame
  242. //
  243. // ID2 = {DBN7,DBN6,DBN5,DBN4,DBN3,DBN2,DBN1,DBN0}
  244. // DBB7-0 = {0,0,0,0,0,0,0,0,0} = Beginning of a DV frame
  245. //
  246. #define DIF_BLK_ID0_SCT_MASK 0xe0 // 11100000b; Section Type (SCT)2-0 are all 0's for the Header section
  247. #define DIF_BLK_ID1_DSEQ_MASK 0xf0 // 11110000b; DIF Sequence Number(DSEQ)3-0 are all 0's
  248. #define DIF_BLK_ID2_DBN_MASK 0xff // 11111111b; Data Block Number (DBN)7-0 are all 0's
  249. #define DIF_HEADER_DSF 0x80 // 10000000b; DSF=0; 10 DIF Sequences (525-60)
  250. // DSF=1; 12 DIF Sequences (625-50)
  251. #define DIF_HEADER_TFn 0x80 // 10000000b; TFn=0; DIF bloick of area N are transmitted in the current DIF sequence.
  252. // TFn=1; DIF bloick of area N are NOT transmitted in the current DIF sequence.
  253. //
  254. // AV/C command response data definition
  255. //
  256. #define AVC_DEVICE_TAPE_REC 0x20 // 00100:000
  257. #define AVC_DEVICE_CAMERA 0x38 // 00111:000
  258. #define AVC_DEVICE_TUNER 0x28 // 00101:000
  259. //
  260. // GUID definitions for pins and DV format types.
  261. //
  262. // DV vid only output pin
  263. #define STATIC_PINNAME_DV_VID_OUTPUT \
  264. 0x5b21c540L, 0x7aee, 0x11d1, 0x88, 0x3b, 0x00, 0x60, 0x97, 0xf0, 0x5c, 0x70
  265. DEFINE_GUIDSTRUCT("5b21c540-7aee-11d1-883b-006097f05c70", PINNAME_DV_VID_OUTPUT);
  266. #define PINNAME_DV_VID_OUTPUT DEFINE_GUIDNAMED(PINNAME_DV_VID_OUTPUT)
  267. #define PINNAME_VID_OUT PINNAME_DV_VID_OUTPUT
  268. // DV A/V output pin
  269. #define STATIC_PINNAME_DV_AV_OUTPUT \
  270. 0x5b21c541L, 0x7aee, 0x11d1, 0x88, 0x3b, 0x00, 0x60, 0x97, 0xf0, 0x5c, 0x70
  271. DEFINE_GUIDSTRUCT("5b21c540-7aee-11d1-883b-006097f05c70", PINNAME_DV_AV_OUTPUT);
  272. #define PINNAME_DV_AV_OUTPUT DEFINE_GUIDNAMED(PINNAME_DV_AV_OUTPUT)
  273. #define PINNAME_AV_OUTPUT PINNAME_DV_AV_OUTPUT
  274. // DV A/V input pin
  275. #define STATIC_PINNAME_DV_AV_INPUT \
  276. 0x5b21c543L, 0x7aee, 0x11d1, 0x88, 0x3b, 0x00, 0x60, 0x97, 0xf0, 0x5c, 0x70
  277. DEFINE_GUIDSTRUCT("5b21c543-7aee-11d1-883b-006097f05c70", PINNAME_DV_AV_INPUT);
  278. #define PINNAME_DV_AV_INPUT DEFINE_GUIDNAMED(PINNAME_DV_AV_INPUT)
  279. #define PINNAME_AV_INPUT PINNAME_DV_AV_INPUT
  280. #endif