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.

389 lines
13 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. avc.h
  5. Abstract
  6. MS AVC Driver
  7. Author:
  8. PB 9/24/99
  9. Revision History:
  10. Date Who What
  11. -------- --------- ------------------------------------------------------------
  12. 9/24/99 PB created
  13. 10/13/99 DG added avc protocol support
  14. --*/
  15. #ifndef _AVC_H_
  16. #define _AVC_H_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #ifndef CTL_CODE
  21. #pragma message ("CTL_CODE undefined. Include winioctl.h or wdm.h")
  22. #endif
  23. // ctype values from AVC Digital Interface General Specification, Rev 3.0, Section 5.3.1
  24. typedef enum _tagAvcCommandType {
  25. AVC_CTYPE_CONTROL = 0x00,
  26. AVC_CTYPE_STATUS = 0x01,
  27. AVC_CTYPE_SPEC_INQ = 0x02,
  28. AVC_CTYPE_NOTIFY = 0x03,
  29. AVC_CTYPE_GEN_INQ = 0x04
  30. } AvcCommandType;
  31. // response values from AVC Digital Interface General Specification, Rev 3.0, Section 5.3.2
  32. typedef enum _tagAvcResponseCode {
  33. AVC_RESPONSE_NOTIMPL = 0x08,
  34. AVC_RESPONSE_ACCEPTED = 0x09,
  35. AVC_RESPONSE_REJECTED = 0x0a,
  36. AVC_RESPONSE_IN_TRANSITION = 0x0b,
  37. AVC_RESPONSE_STABLE = 0x0c,
  38. AVC_RESPONSE_IMPLEMENTED = 0x0c,
  39. AVC_RESPONSE_CHANGED = 0x0d,
  40. AVC_RESPONSE_INTERIM = 0x0f
  41. } AvcResponseCode;
  42. // subunit type values from Enhancements to AV/C General Specification 3.0, Version 1.1, Section 7.
  43. typedef enum _tagAvcSubunitType {
  44. AVC_SUBUNITTYPE_VIDEO_MONITOR = 0x00,
  45. AVC_SUBUNITTYPE_AUDIO = 0x01,
  46. AVC_SUBUNITTYPE_PRINTER = 0x02,
  47. AVC_SUBUNITTYPE_DISC_PLAYER = 0x03,
  48. AVC_SUBUNITTYPE_TAPE_PLAYER = 0x04,
  49. AVC_SUBUNITTYPE_TUNER = 0x05,
  50. AVC_SUBUNITTYPE_CA = 0x06,
  51. AVC_SUBUNITTYPE_VIDEO_CAMERA = 0x07,
  52. AVC_SUBUNITTYPE_PANEL = 0x09,
  53. AVC_SUBUNITTYPE_BULLETINBOARD = 0x0A,
  54. AVC_SUBUNITTYPE_CAMERASTORAGE = 0x0B,
  55. AVC_SUBUNITTYPE_VENDOR_UNIQUE = 0x1c,
  56. AVC_SUBUNITTYPE_EXTENDED = 0x1e,
  57. AVC_SUBUNITTYPE_EXTENDED_FULL = 0xff, // This is used only in extension bytes
  58. AVC_SUBUNITTYPE_UNIT = 0x1f
  59. } AvcSubunitType;
  60. #ifdef _NTDDK_
  61. #define STATIC_KSMEDIUMSETID_1394SerialBus\
  62. 0x9D46279FL, 0x3432, 0x48F3, 0x88, 0x8A, 0xEE, 0xFF, 0x1B, 0x7E, 0xEE, 0x71
  63. DEFINE_GUIDSTRUCT("9D46279F-3432-48F3-888A-EEFF1B7EEE71", KSMEDIUMSETID_1394SerialBus);
  64. #define KSMEDIUMSETID_1394SerialBus DEFINE_GUIDNAMED(KSMEDIUMSETID_1394SerialBus)
  65. #define DEFAULT_AVC_TIMEOUT (1000000L) // 100ms in 100 nanosecond units
  66. #define DEFAULT_AVC_RETRIES 9 // 10 tries altogether
  67. // Max pages available via the SUBUNIT INFO command
  68. #define MAX_AVC_SUBUNITINFO_PAGES 8
  69. // Max number of bytes of subunit address information per page
  70. #define MAX_AVC_SUBUNITINFO_BYTES 4
  71. // Combined subunit address byte count for all pages
  72. #define AVC_SUBUNITINFO_BYTES (MAX_AVC_SUBUNITINFO_PAGES * MAX_AVC_SUBUNITINFO_BYTES)
  73. //
  74. // IOCTL definitions
  75. //
  76. #define IOCTL_AVC_CLASS CTL_CODE( \
  77. FILE_DEVICE_UNKNOWN, \
  78. 0x92, \
  79. METHOD_BUFFERED, \
  80. FILE_ANY_ACCESS \
  81. )
  82. typedef enum _tagAVC_FUNCTION {
  83. AVC_FUNCTION_COMMAND = 0, // struct AVC_COMMAND_IRB
  84. AVC_FUNCTION_GET_PIN_COUNT = 1, // struct AVC_PIN_COUNT
  85. AVC_FUNCTION_GET_PIN_DESCRIPTOR = 2, // struct AVC_PIN_DESCRIPTOR
  86. AVC_FUNCTION_GET_CONNECTINFO = 3, // struct AVC_PRECONNECT_INFO
  87. AVC_FUNCTION_SET_CONNECTINFO = 4, // struct AVC_SETCONNECT_INFO
  88. AVC_FUNCTION_ACQUIRE = 5, // struct AVC_PIN_ID
  89. AVC_FUNCTION_RELEASE = 6, // struct AVC_PIN_ID
  90. AVC_FUNCTION_CLR_CONNECTINFO = 7, // struct AVC_PIN_ID
  91. AVC_FUNCTION_GET_EXT_PLUG_COUNTS = 8, // struct AVC_EXT_PLUG_COUNTS
  92. AVC_FUNCTION_GET_UNIQUE_ID = 9, // struct AVC_UNIQUE_ID
  93. AVC_FUNCTION_GET_REQUEST = 10, // struct AVC_COMMAND_IRB
  94. AVC_FUNCTION_SEND_RESPONSE = 11, // struct AVC_COMMAND_IRB
  95. AVC_FUNCTION_FIND_PEER_DO = 12, // struct AVC_PEER_DO_LOCATOR
  96. AVC_FUNCTION_PEER_DO_LIST = 13, // struct AVC_PEER_DO_LIST
  97. AVC_FUNCTION_GET_SUBUNIT_INFO = 14, // struct AVC_SUBUNIT_INFO_BLOCK
  98. } AVC_FUNCTION;
  99. // Ensure that packing is consistent (/Zp8)
  100. #include <pshpack8.h>
  101. // This structure is to be included at the head of a more specific AVC function structure
  102. typedef struct _AVC_IRB {
  103. AVC_FUNCTION Function;
  104. } AVC_IRB, *PAVC_IRB;
  105. // The maximum number of bytes available for an operand list
  106. #define MAX_AVC_OPERAND_BYTES 509
  107. // AVC_COMMAND_IRB
  108. //
  109. // This structure defines the common components of an AVC command request. It
  110. // holds the opcode and operands of a request, and the opcode and operands
  111. // of a response (upon completion). The size of the operand list is fixed at
  112. // the maximum allowable number of operands given a one-byte Subunit Address.
  113. // If the Subunit Address is extended in any way, the maximum permissible
  114. // number of operand bytes will be reduced accordingly.
  115. // (supported by peer and virtual instances)
  116. typedef struct _AVC_COMMAND_IRB {
  117. // AVC_FUNCTION_COMMAND
  118. #ifdef __cplusplus
  119. AVC_IRB Common;
  120. #else
  121. AVC_IRB;
  122. #endif
  123. UCHAR SubunitAddrFlag : 1; // set to 1 if a SubunitAddr address is specified
  124. UCHAR AlternateOpcodesFlag : 1; // set to 1 if the AlternateOpcodes address is specified
  125. UCHAR TimeoutFlag : 1; // set to 1 if Timeout specified
  126. UCHAR RetryFlag : 1; // set to 1 if Retries specified
  127. // On command request, this struct will use the CommandType
  128. // On command response, this struct will use ResponseCode
  129. union {
  130. UCHAR CommandType;
  131. UCHAR ResponseCode;
  132. };
  133. PUCHAR SubunitAddr; // set according to the target device object if not specified
  134. PUCHAR AlternateOpcodes; // set to the address of an array of alternate opcodes (byte 0
  135. // is the count of alternate opcodes that follow)
  136. LARGE_INTEGER Timeout; // Defaults to DEFAULT_AVC_TIMEOUT if not specified
  137. UCHAR Retries; // Defaults to DEFAULT_AVC_RETRIES if not specified
  138. // The total amount of time a request will wait if the subunit is not responsive is:
  139. // Timeout * (Retries+1)
  140. UCHAR Opcode;
  141. ULONG OperandLength; // set to the actual length of the operand list
  142. UCHAR Operands[MAX_AVC_OPERAND_BYTES];
  143. NODE_ADDRESS NodeAddress; // Used by virtual devices, ignored otherwise
  144. ULONG Generation; // Used by virtual devices, ignored otherwise
  145. } AVC_COMMAND_IRB, *PAVC_COMMAND_IRB;
  146. // For AVC_FUNCTION_GET_PIN_COUNT (supported by peer instance only)
  147. //
  148. typedef struct _AVC_PIN_COUNT {
  149. OUT ULONG PinCount; // The pin count
  150. } AVC_PIN_COUNT, *PAVC_PIN_COUNT;
  151. // Dataformat Intersection handler used in struct AVC_PIN_DESCRIPTOR
  152. typedef
  153. NTSTATUS
  154. (*PFNAVCINTERSECTHANDLER)(
  155. IN PVOID Context,
  156. IN ULONG PinId,
  157. IN PKSDATARANGE DataRange,
  158. IN PKSDATARANGE MatchingDataRange,
  159. IN ULONG DataBufferSize,
  160. OUT PVOID Data OPTIONAL,
  161. OUT PULONG DataSize
  162. );
  163. // For AVC_FUNCTION_GET_PIN_DESCRIPTOR (supported by peer instance only)
  164. //
  165. typedef struct _AVC_PIN_DESCRIPTOR {
  166. IN ULONG PinId; // The pin number
  167. OUT KSPIN_DESCRIPTOR PinDescriptor;
  168. OUT PFNAVCINTERSECTHANDLER IntersectHandler;
  169. OUT PVOID Context;
  170. } AVC_PIN_DESCRIPTOR, *PAVC_PIN_DESCRIPTOR;
  171. #define AVCCONNECTINFO_MAX_SUBUNITADDR_LEN AVC_SUBUNITINFO_BYTES
  172. typedef enum _KSPIN_FLAG_AVC {
  173. KSPIN_FLAG_AVCMASK = 0x03, // the mask to isolate the AV/C defined bit flags
  174. KSPIN_FLAG_AVC_PERMANENT = 0x01, // part of the AV/C Connect Status bit flag
  175. KSPIN_FLAG_AVC_CONNECTED = 0x02, // part of the AV/C Connect Status bit flag
  176. KSPIN_FLAG_AVC_PCRONLY = 0x04, // no subunit plug control
  177. KSPIN_FLAG_AVC_FIXEDPCR = 0x08, // implies KSPIN_FLAG_AVC_PERMANENT
  178. } KSPIN_FLAG_AVC;
  179. typedef struct _AVCPRECONNECTINFO {
  180. // Unique ID of the target unit
  181. GUID DeviceID;
  182. UCHAR SubunitAddress[AVCCONNECTINFO_MAX_SUBUNITADDR_LEN];
  183. ULONG SubunitPlugNumber;
  184. KSPIN_DATAFLOW DataFlow;
  185. // KSPIN_FLAG_AVC_...
  186. ULONG Flags;
  187. // Undefined if !(Flags & KSPIN_FLAG_AVC_FIXEDPCR)
  188. ULONG UnitPlugNumber;
  189. } AVCPRECONNECTINFO, *PAVCPRECONNECTINFO;
  190. // For AVC_FUNCTION_GET_CONNECTINFO (supported by peer instance only)
  191. //
  192. typedef struct _AVC_PRECONNECT_INFO {
  193. IN ULONG PinId; // The pin number
  194. OUT AVCPRECONNECTINFO ConnectInfo;
  195. } AVC_PRECONNECT_INFO, *PAVC_PRECONNECT_INFO;
  196. typedef struct _AVCCONNECTINFO {
  197. // Unique ID of the target unit
  198. GUID DeviceID;
  199. UCHAR SubunitAddress[AVCCONNECTINFO_MAX_SUBUNITADDR_LEN];
  200. ULONG SubunitPlugNumber;
  201. KSPIN_DATAFLOW DataFlow;
  202. // NULL if intra-unit connection
  203. HANDLE hPlug;
  204. // Undefined if hPlug == NULL
  205. ULONG UnitPlugNumber;
  206. } AVCCONNECTINFO, *PAVCCONNECTINFO;
  207. // For AVC_FUNCTION_SET_CONNECTINFO (supported by peer instance only)
  208. //
  209. typedef struct _AVC_SETCONNECT_INFO {
  210. IN ULONG PinId; // The pin number
  211. IN AVCCONNECTINFO ConnectInfo;
  212. } AVC_SETCONNECT_INFO, *PAVC_SETCONNECT_INFO;
  213. // For AVC_FUNCTION_ACQUIRE or AVC_FUNCTION_RELEASE or AVC_FUNCTION_CLR_CONNECTINFO (supported by peer instance only)
  214. //
  215. typedef struct _AVC_PIN_ID {
  216. IN ULONG PinId; // The pin ID
  217. } AVC_PIN_ID, *PAVC_PIN_ID;
  218. // For AVC_FUNCTION_GET_EXT_PLUG_COUNTS (supported by peer instance only)
  219. //
  220. typedef struct _AVC_EXT_PLUG_COUNTS {
  221. OUT ULONG ExtInputs;
  222. OUT ULONG ExtOutputs;
  223. } AVC_EXT_PLUG_COUNTS, *PAVC_EXT_PLUG_COUNTS;
  224. // For AVC_FUNCTION_GET_UNIQUE_ID (supported by peer instance only)
  225. //
  226. typedef struct _AVC_UNIQUE_ID {
  227. // Unique ID of the target unit
  228. OUT GUID DeviceID;
  229. } AVC_UNIQUE_ID, *PAVC_UNIQUE_ID;
  230. // For AVC_FUNCTION_FIND_PEER_DO
  231. //
  232. typedef struct _AVC_PEER_DO_LOCATOR {
  233. // 1394 NodeAddress identifying target for query
  234. IN NODE_ADDRESS NodeAddress;
  235. IN ULONG Generation;
  236. OUT PDEVICE_OBJECT DeviceObject;
  237. } AVC_PEER_DO_LOCATOR, *PAVC_PEER_DO_LOCATOR;
  238. // For AVC_FUNCTION_PEER_DO_LIST
  239. //
  240. typedef struct _AVC_PEER_DO_LIST {
  241. // Counted array of referenced device objects (allocated by target)
  242. OUT ULONG Count;
  243. OUT PDEVICE_OBJECT *Objects;
  244. } AVC_PEER_DO_LIST, *PAVC_PEER_DO_LIST;
  245. // For AVC_FUNCTION_GET_SUBUNIT_INFO
  246. //
  247. typedef struct _AVC_SUBUNIT_INFO_BLOCK {
  248. // Array of bytes to hold subunit info (see AV/C SUBUNIT_INFO unit command for format)
  249. OUT UCHAR Info[AVC_SUBUNITINFO_BYTES];
  250. } AVC_SUBUNIT_INFO_BLOCK, *PAVC_SUBUNIT_INFO_BLOCK;
  251. typedef struct _AVC_MULTIFUNC_IRB {
  252. #ifdef __cplusplus
  253. AVC_IRB Common;
  254. #else
  255. AVC_IRB;
  256. #endif
  257. union {
  258. AVC_PIN_COUNT PinCount; // AVC_FUNCTION_GET_PIN_COUNT
  259. AVC_PIN_DESCRIPTOR PinDescriptor; // AVC_FUNCTION_GET_PIN_DESCRIPTOR
  260. AVC_PRECONNECT_INFO PreConnectInfo; // AVC_FUNCTION_GET_CONNECTINFO
  261. AVC_SETCONNECT_INFO SetConnectInfo; // AVC_FUNCTION_SET_CONNECTINFO
  262. AVC_PIN_ID PinId; // AVC_FUNCTION_ACQUIRE or
  263. // AVC_FUNCTION_RELEASE or
  264. // AVC_FUNCTION_CLR_CONNECTINFO
  265. AVC_EXT_PLUG_COUNTS ExtPlugCounts; // AVC_FUNCTION_GET_EXT_PLUG_COUNTS
  266. AVC_UNIQUE_ID UniqueID; // AVC_FUNCTION_GET_UNIQUE_ID
  267. AVC_PEER_DO_LOCATOR PeerLocator; // AVC_FUNCTION_FIND_PEER_DO
  268. AVC_PEER_DO_LIST PeerList; // AVC_FUNCTION_PEER_DO_LIST
  269. AVC_SUBUNIT_INFO_BLOCK Subunits; // AVC_FUNCTION_GET_SUBUNIT_INFO
  270. };
  271. } AVC_MULTIFUNC_IRB, *PAVC_MULTIFUNC_IRB;
  272. #include <poppack.h>
  273. #endif // _NTDDK_
  274. //
  275. // IOCTL definitions for Virtual Unit control (from user mode)
  276. //
  277. #define IOCTL_AVC_UPDATE_VIRTUAL_SUBUNIT_INFO CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x000, METHOD_BUFFERED, FILE_ANY_ACCESS)
  278. #define IOCTL_AVC_REMOVE_VIRTUAL_SUBUNIT_INFO CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x001, METHOD_BUFFERED, FILE_ANY_ACCESS)
  279. #define IOCTL_AVC_BUS_RESET CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x002, METHOD_BUFFERED, FILE_ANY_ACCESS)
  280. // Ensure that packing is consistent (/Zp8)
  281. #include <pshpack8.h>
  282. typedef struct _AVC_SUBUNIT_ADDR_SPEC {
  283. ULONG Flags;
  284. UCHAR SubunitAddress[1];
  285. } AVC_SUBUNIT_ADDR_SPEC, *PAVC_SUBUNIT_ADDR_SPEC;
  286. // Flags, when used with IOCTL_AVC_UPDATE_VIRTUAL_SUBUNIT_INFO
  287. // and IOCTL_AVC_REMOVE_VIRTUAL_SUBUNIT_INFO
  288. #define AVC_SUBUNIT_ADDR_PERSISTENT 0x00000001
  289. #define AVC_SUBUNIT_ADDR_TRIGGERBUSRESET 0x00000002
  290. #include <poppack.h>
  291. #ifdef __cplusplus
  292. }
  293. #endif
  294. #endif // _AVC_H_
  295. #ifndef AVC_GUIDS_DEFINED
  296. #define AVC_GUIDS_DEFINED
  297. // {616EF4D0-23CE-446d-A568-C31EB01913D0}
  298. DEFINE_GUID(GUID_VIRTUAL_AVC_CLASS, 0x616ef4d0, 0x23ce, 0x446d, 0xa5, 0x68, 0xc3, 0x1e, 0xb0, 0x19, 0x13, 0xd0);
  299. // {095780C3-48A1-4570-BD95-46707F78C2DC}
  300. DEFINE_GUID(GUID_AVC_CLASS, 0x095780c3, 0x48a1, 0x4570, 0xbd, 0x95, 0x46, 0x70, 0x7f, 0x78, 0xc2, 0xdc);
  301. #endif