1/*
2 * Copyright (c) 1998-2001 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License").  You may not use this file except in compliance with the
9 * License.  Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22#ifndef _IOKIT_IOFIREWIREAVCCONSTS_H
23#define _IOKIT_IOFIREWIREAVCCONSTS_H
24
25// Fields of AVC frame
26typedef enum {
27    kAVCCommandResponse = 0,
28    kAVCAddress = 1,
29    kAVCOpcode = 2,
30    kAVCOperand0 = 3,
31    kAVCOperand1 = 4,
32    kAVCOperand2 = 5,
33    kAVCOperand3 = 6,
34    kAVCOperand4 = 7,
35    kAVCOperand5 = 8,
36    kAVCOperand6 = 9,
37    kAVCOperand7 = 10,
38    kAVCOperand8 = 11
39} IOAVCFrameFields;
40
41// Command/Response values
42typedef enum {
43    kAVCControlCommand                      = 0x00,
44    kAVCStatusInquiryCommand                = 0x01,
45    kAVCSpecificInquiryCommand				= 0x02,
46    kAVCNotifyCommand						= 0x03,
47    kAVCGeneralInquiryCommand				= 0x04,
48    kAVCNotImplementedStatus				= 0x08,
49    kAVCAcceptedStatus						= 0x09,
50    kAVCRejectedStatus						= 0x0a,
51    kAVCInTransitionStatus					= 0x0b,
52    kAVCImplementedStatus					= 0x0c,
53    kAVCChangedStatus						= 0x0d,
54    kAVCInterimStatus						= 0x0f
55} IOAVCCommandResponse;
56
57// Opcodes
58typedef enum {
59
60    // Unit commands
61    kAVCPlugInfoOpcode						= 0x02,
62    kAVCOutputPlugSignalFormatOpcode		= 0x18,
63    kAVCInputPlugSignalFormatOpcode			= 0x19,
64    kAVCUnitInfoOpcode						= 0x30,
65    kAVCSubunitInfoOpcode					= 0x31,
66    kAVCConnectionsOpcode					= 0x22,
67    kAVCConnectOpcode						= 0x24,
68    kAVCDisconnectOpcode					= 0x25,
69    kAVCPowerOpcode							= 0xB2,
70	kAVCSignalSourceOpcode					= 0x1A,
71
72    // Vendor dependent commands
73    kAVCVendorDependentOpcode				= 0x00,
74
75    // Subunit commands
76    kAVCOutputSignalModeOpcode              = 0x78,
77    kAVCInputSignalModeOpcode               = 0x79,
78    kAVCSignalModeSD525_60                  = 0x00,
79    kAVCSignalModeSDL525_60                 = 0x04,
80    kAVCSignalModeHD1125_60                 = 0x08,
81    kAVCSignalModeSD625_50                  = 0x80,
82    kAVCSignalModeSDL625_50                 = 0x84,
83    kAVCSignalModeHD1250_50                 = 0x88,
84    kAVCSignalModeDVCPro525_60				= 0x78,
85    kAVCSignalModeDVCPro625_50				= 0xf8,
86
87    kAVCSignalModeDummyOperand              = 0xff,
88    kAVCSignalModeMask_50					= 0x80,
89    kAVCSignalModeMask_STYPE				= 0x7c,
90    kAVCSignalModeMask_SDL					= 0x04,
91    kAVCSignalModeMask_DVCPro25				= 0x78
92
93} IOAVCOpcodes;
94
95// Unit/Subunit types
96typedef enum {
97    kAVCVideoMonitor						= 0x00,
98    kAVCAudio								= 0x01,
99    kAVCPrinter								= 0x02,
100    kAVCDiskRecorder						= 0x03,
101    kAVCTapeRecorder						= 0x04,
102    kAVCTuner								= 0x05,
103    kAVCVideoCamera							= 0x07,
104    kAVCCameraStorage						= 0x0b,
105    kAVCVendorUnique						= 0x1c,
106    kAVCNumSubUnitTypes						= 0x20
107} IOAVCUnitTypes;
108
109#define kAVCAllOpcodes 0xFF
110#define kAVCAllSubunitsAndUnit 0xEE
111#define kAVCMaxNumPlugs 31
112#define kAVCAnyAvailableIsochPlug 0x7F
113#define kAVCAnyAvailableExternalPlug 0xFF
114#define kAVCAnyAvailableSubunitPlug 0xFF
115#define kAVCMultiplePlugs 0xFD
116#define kAVCInvalidPlug 0xFE
117
118
119#define IOAVCAddress(type, id) (((type) << 3) | (id))
120#define kAVCUnitAddress 0xff
121#define IOAVCType(address) ((address) >> 3)
122#define IOAVCId(address) ((address) & 0x7)
123
124// Macros for Plug Control Register field manipulation
125
126// Master control registers
127#define kIOFWPCRDataRate FWBitRange(0,1)
128#define kIOFWPCRDataRatePhase FWBitRangePhase(0,1)
129#define kIOFWPCRExtension FWBitRange(8,15)
130#define kIOFWPCRExtensionPhase FWBitRangePhase(8,15)
131#define kIOFWPCRNumPlugs FWBitRange(27,31)
132#define kIOFWPCRNumPlugsPhase FWBitRangePhase(27,31)
133
134// master output register
135#define kIOFWPCRBroadcastBase FWBitRange(2,7)
136#define kIOFWPCRBroadcastBasePhase FWBitRangePhase(2,7)
137
138// plug registers
139#define kIOFWPCROnline FWBitRange(0,0)
140#define kIOFWPCROnlinePhase FWBitRangePhase(0,0)
141#define kIOFWPCRBroadcast FWBitRange(1,1)
142#define kIOFWPCRBroadcastPhase FWBitRangePhase(1,1)
143#define kIOFWPCRP2PCount FWBitRange(2,7)
144#define kIOFWPCRP2PCountPhase FWBitRangePhase(2,7)
145#define kIOFWPCRChannel FWBitRange(10,15)
146#define kIOFWPCRChannelPhase FWBitRangePhase(10,15)
147
148// Extra fields for output plug registers
149#define kIOFWPCROutputDataRate FWBitRange(16,17)
150#define kIOFWPCROutputDataRatePhase FWBitRangePhase(16,17)
151#define kIOFWPCROutputOverhead FWBitRange(18,21)
152#define kIOFWPCROutputOverheadPhase FWBitRangePhase(18,21)
153#define kIOFWPCROutputPayload FWBitRange(22,31)
154#define kIOFWPCROutputPayloadPhase FWBitRangePhase(22,31)
155
156// async plug numbers
157
158enum
159{
160	kFWAVCAsyncPlug0 	= 0xa0,
161	kFWAVCAsyncPlug1 	= 0xa1,
162	kFWAVCAsyncPlug2 	= 0xa2,
163	kFWAVCAsyncPlug3 	= 0xa3,
164	kFWAVCAsyncPlug4 	= 0xa4,
165	kFWAVCAsyncPlug5 	= 0xa5,
166	kFWAVCAsyncPlug6 	= 0xa6,
167	kFWAVCAsyncPlug7 	= 0xa7,
168	kFWAVCAsyncPlug8 	= 0xa8,
169	kFWAVCAsyncPlug9 	= 0xa9,
170	kFWAVCAsyncPlug10 	= 0xa1,
171	kFWAVCAsyncPlug11	= 0xab,
172	kFWAVCAsyncPlug12 	= 0xac,
173	kFWAVCAsyncPlug13	= 0xad,
174	kFWAVCAsyncPlug14	= 0xae,
175	kFWAVCAsyncPlug15 	= 0xaf,
176	kFWAVCAsyncPlug16 	= 0xb0,
177	kFWAVCAsyncPlug17 	= 0xb1,
178	kFWAVCAsyncPlug18	= 0xb2,
179	kFWAVCAsyncPlug19 	= 0xb3,
180	kFWAVCAsyncPlug20 	= 0xb4,
181	kFWAVCAsyncPlug21 	= 0xb5,
182	kFWAVCAsyncPlug22 	= 0xb6,
183	kFWAVCAsyncPlug23 	= 0xb7,
184	kFWAVCAsyncPlug24 	= 0xb8,
185	kFWAVCAsyncPlug25 	= 0xb9,
186	kFWAVCAsyncPlug26 	= 0xba,
187	kFWAVCAsyncPlug27 	= 0xbb,
188	kFWAVCAsyncPlug28 	= 0xbc,
189	kFWAVCAsyncPlug29 	= 0xbd,
190	kFWAVCAsyncPlug30	= 0xbe,
191	kFWAVCAsyncPlugAny	= 0xbf
192};
193
194enum
195{
196    kFWAVCStateBusSuspended 	= 0,
197    kFWAVCStateBusResumed 		= 1,
198    kFWAVCStatePlugReconnected 	= 2,
199    kFWAVCStatePlugDisconnected = 3,
200    kFWAVCStateDeviceRemoved	= 4
201};
202
203enum
204{
205    kFWAVCConsumerMode_MORE		= 1,
206    kFWAVCConsumerMode_LAST		= 4,
207    kFWAVCConsumerMode_LESS		= 5,
208    kFWAVCConsumerMode_JUNK		= 6,
209    kFWAVCConsumerMode_LOST		= 7
210};
211
212enum
213{
214    kFWAVCProducerMode_SEND		= 5,
215    kFWAVCProducerMode_TOSS		= 7
216};
217
218
219typedef enum
220{
221	IOFWAVCPlugSubunitSourceType,
222	IOFWAVCPlugSubunitDestType,
223	IOFWAVCPlugIsochInputType,
224	IOFWAVCPlugIsochOutputType,
225	IOFWAVCPlugAsynchInputType,
226	IOFWAVCPlugAsynchOutputType,
227	IOFWAVCPlugExternalInputType,
228	IOFWAVCPlugExternalOutputType
229} IOFWAVCPlugTypes;
230
231typedef enum
232{
233	kIOFWAVCSubunitPlugMsgConnected,
234	kIOFWAVCSubunitPlugMsgDisconnected,
235	kIOFWAVCSubunitPlugMsgConnectedPlugModified,
236	kIOFWAVCSubunitPlugMsgSignalFormatModified
237} IOFWAVCSubunitPlugMessages;
238
239// Some plug signal formats
240#define kAVCPlugSignalFormatNTSCDV 0x80000000
241#define kAVCPlugSignalFormatPalDV 0x80800000
242#define kAVCPlugSignalFormatMPEGTS 0xA0000000
243
244// Possible states of an AVCAsynchronousCommand
245typedef enum
246{
247	kAVCAsyncCommandStatePendingRequest,
248	kAVCAsyncCommandStateRequestSent,
249	kAVCAsyncCommandStateRequestFailed,
250	kAVCAsyncCommandStateWaitingForResponse,
251	kAVCAsyncCommandStateReceivedInterimResponse,
252	kAVCAsyncCommandStateReceivedFinalResponse,
253	kAVCAsyncCommandStateTimeOutBeforeResponse,
254	kAVCAsyncCommandStateBusReset,
255	kAVCAsyncCommandStateOutOfMemory,
256	kAVCAsyncCommandStateCanceled
257} IOFWAVCAsyncCommandState;
258
259#endif // _IOKIT_IOFIREWIREAVCCONSTS_H
260