1/*
2 * Copyright (c) 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*
24	File:		IsochronousDataHandler.i
25
26	Contains:	Component Manager based Isochronous Data Handler
27
28	Copyright:	� 1997-2001 by Apple Computer, Inc., all rights reserved.
29
30		$Log: IsochronousDataHandler.i,v $
31		Revision 1.9  2010/08/05 20:59:16  calderon
32		<rdar://problem/6822618> IOFWDVComponents should add APSL headers to each source file
33
34		Revision 1.8  2002/12/20 22:33:25  wgulland
35		Fix radars 3118059 and 3071011
36
37		Revision 1.7  2002/10/15 19:05:39  ayanowit
38		Merged in changes to support DVCPro50.
39
40		Revision 1.6  2002/03/21 01:55:44  wgulland
41		Use IOFireWireFamily isoc user client instead of DV kext
42
43		Revision 1.5  2001/10/05 16:46:32  wgulland
44		Add inputFormat to IDHDeviceStatus structure
45
46		Revision 1.4  2001/09/27 00:43:29  wgulland
47		Keep retrying if starting write fails
48
49		Revision 1.22  2001/04/26 21:20:26  kledzik
50		Switch to cvs style header comment
51
52
53	Old History:
54
55		(ngk)	Nick Kledzik
56		(WG)	William Gulland
57		(dav)	Dave Chilson
58		(KW)	Kevin Williams
59		(jkl)	Jay Lloyd
60		(GDW)	George D. Wilson Jr.
61		(RS)	Richard Sepulveda
62		(SW)	Sean Williams
63
64		<21>	 4/17/01	WG		Remove incorrect exportset=IDHLib_10 for IDHGetDeviceTime
65		<20>	 4/17/01	ngk		Change uses of IDHNotificationProc to IDHNotificationUPP. Update
66									some usages of old syntax.
67		<19>	 4/17/01	WG		[2567324]  Added <nativeUPP,etc> for IDHNotificationProc Added
68									new X function IDHGetDeviceTime
69		<18>	12/20/00	dav		This is part of Quicktime, so the proper version set is
70									CarbonMultimedia_13
71		<17>	12/14/00	dav		[2567275]  Add CarbonMultimedia_13 export set
72		<16>	 12/7/99	RS		Added error code 'kIDHErrCallNotSupported' since all isoch calls
73									are not support in all implementations.
74		<15>	 12/7/99	jkl		Changed isocMediaType to isochMediaType. Added a default
75									configuration atom that can be set as a hint for a configuration
76									to use for clients that do not have an interface to allow users
77									to select a device. Added defines to support the default
78									configuration.
79		<14>	10/29/99	jkl		Added useCMP atom type.
80		<13>	 8/16/99	RS		Added kIDHIsochVersionAtomType to atom list.
81		<12>	  8/9/99	RS		Added IDHUpdateDeviceList() to Isoch API.
82		<11>	  8/6/99	jkl		Added kIDHInvalidDeviceID define.
83		<10>	  8/5/99	RS		Added kIDHErrDeviceBusy error to list.
84		 <9>	 7/15/99	RS		Changed error number assignments to avoid conflict with existing
85									DVFamily.h
86		 <8>	 6/28/99	RS		Moved IDHGetClientID() prototype to IsochPriv.i since it is a
87									priv function. Added deviceID atom. Added deviceTimeout error
88									code. Added IDHResolution and IDHDimension structures.
89		 <7>	 6/24/99	KW		Added IDHDeviceID as parameter to IDHNewNotification. Added some
90									reserved events.
91		 <6>	 6/23/99	jkl		Added error codes in DV range. Added IDHGetDeviceID routine.
92		 <5>	 6/20/99	RS		Made the notification flags match the DVFamily lib flags for
93									consistency.
94		 <4>	 6/18/99	RS		Added new atom type kIDHUniqueID to device atom list. Changed
95									type of status structure element from PsuedoFWID to PsuedoID to
96									remain bus independent.
97		 <3>	 6/16/99	GDW		Added get device component call.
98		 <2>	 6/14/99	RS		Added 'result' parameter to IDHParameterBlock structure.
99		 <1>	 6/11/99	SW		first checked in
100*/
101
102%if FRAMEWORKS
103	#include <CoreServices.i>
104%else
105    #include <MacTypes.i>
106%endif
107#include <MoviesFormat.i>
108#include <QuickTimeComponents.i>
109
110
111
112
113enum <rez>
114{
115	kIDHComponentType				= 'ihlr',		// Component type
116	kIDHSubtypeDV					= 'dv  ',		// Subtype for DV (over FireWire)
117	kIDHSubtypeFireWireConference	= 'fwc ',		// Subtype for FW Conference
118};
119
120
121//
122// Version of Isochronous Data Handler API
123//
124enum <rez>
125{
126	kIDHInterfaceVersion1			= 0x0001,		// Initial relase (Summer '99)
127};
128
129
130// atom types
131
132enum {
133	kIDHDeviceListAtomType		 		= 'dlst',
134	kIDHDeviceAtomType					= 'devc',	// to be defined elsewhere
135	kIDHIsochServiceAtomType			= 'isoc',
136	kIDHIsochModeAtomType				= 'mode',
137
138	kIDHDeviceIDType					= 'dvid',
139	kIDHDefaultIOType					= 'dfio',
140	kIDHIsochVersionAtomType			= 'iver',
141	kIDHUniqueIDType					= 'unid',
142	kIDHNameAtomType					= 'name',
143	kIDHUseCMPAtomType					= 'ucmp',
144	kIDHIsochMediaType					= 'av  ',
145
146	kIDHDataTypeAtomType				= 'dtyp',
147	kIDHDataSizeAtomType				= 'dsiz',	// ??? packet size vs. buffer size
148	kIDHDataBufferSizeAtomType			= 'dbuf',	// ??? packet size vs. buffer size
149	kIDHDataIntervalAtomType			= 'intv',
150	kIDHDataIODirectionAtomType			= 'ddir',
151
152	kIDHSoundMediaAtomType				= 'soun',
153	kIDHSoundTypeAtomType				= 'type',
154	kIDHSoundChannelCountAtomType		= 'ccnt',
155	kIDHSoundSampleSizeAtomType			= 'ssiz',
156	kIDHSoundSampleRateAtomType			= 'srat',
157
158	// same as video out... (what does this comment mean?)
159	kIDHVideoMediaAtomType				= 'vide',
160	kIDHVideoDimensionsAtomType			= 'dimn',
161	kIDHVideoResolutionAtomType			= 'resl',
162	kIDHVideoRefreshRateAtomType		= 'refr',
163	kIDHVideoPixelTypeAtomType			= 'pixl',
164
165	kIDHVideoDecompressorAtomType		= 'deco',
166	kIDHVideoDecompressorTypeAtomType	= 'dety',
167	kIDHVideoDecompressorContinuousAtomType	= 'cont',
168	kIDHVideoDecompressorComponentAtomType	= 'cmpt'
169
170};
171
172//
173// I/O Flags
174//
175enum
176{
177	kIDHDataTypeIsInput					= 1L << 0,
178	kIDHDataTypeIsOutput				= 1L << 1,
179	kIDHDataTypeIsInputAndOutput		= 1L << 2,
180};
181
182
183//
184// Permission Flags
185//
186enum
187{
188	kIDHOpenForReadTransactions			= 1L << 0,
189	kIDHOpenForWriteTransactions		= 1L << 1,
190	kIDHOpenWithExclusiveAccess			= 1L << 2,
191	kIDHOpenWithHeldBuffers				= 1L << 3, // IDH will hold buffer until ReleaseBuffer()
192	kIDHCloseForReadTransactions		= 1L << 4,
193	kIDHCloseForWriteTransactions		= 1L << 5,
194};
195
196
197//
198// Errors
199//	These REALLY need to be moved into Errors.h
200// ����needs officially assigned numbers
201enum
202{
203	kIDHErrDeviceDisconnected	= -14101,
204	kIDHErrInvalidDeviceID		= -14102,
205	kIDHErrDeviceInUse			= -14104,
206	kIDHErrDeviceNotOpened		= -14105,
207	kIDHErrDeviceBusy			= -14106,
208	kIDHErrDeviceReadError		= -14107,
209	kIDHErrDeviceWriteError		= -14108,
210	kIDHErrDeviceNotConfigured	= -14109,
211	kIDHErrDeviceList			= -14110,
212	kIDHErrCompletionPending	= -14111,
213	kIDHErrDeviceTimeout		= -14112,
214	kIDHErrInvalidIndex			= -14113,
215	kIDHErrDeviceCantRead		= -14114,
216	kIDHErrDeviceCantWrite		= -14115,
217	kIDHErrCallNotSupported		= -14116
218};
219
220
221
222
223//
224// Holds Device Identification...
225//
226typedef UInt32 IDHDeviceID;
227enum
228{
229	kIDHInvalidDeviceID			= 0,
230	kIDHDeviceIDEveryDevice		= 0xFFFFFFFF
231};
232
233//
234// Values for 5 bit STYPE part of CIP header
235enum
236{
237    kIDHDV_SD					= 0,
238    kIDHDV_SDL					= 1,
239    kIDHDV_HD					= 2,
240    kIDHDVCPro_25				= 0x1e,
241    kIDHDVCPro_50				= 0x1d
242
243};
244
245//
246//	Isoch Interval Atom Data
247//
248struct IDHIsochInterval
249{
250	SInt32			duration;
251	TimeScale		scale;
252};
253
254
255// Need to fix this.  For now, cast this as a FWReferenceID
256struct opaque PsuedoID;
257
258//
259// Isoch Device Status
260//	This is atom-like, but isn�t an atom
261//
262struct IDHDeviceStatus
263{
264	UInt32			version;
265	Boolean			physicallyConnected;
266	Boolean			readEnabled;
267	Boolean			writeEnabled;
268	Boolean			exclusiveAccess;
269	UInt32			currentBandwidth;
270	UInt32			currentChannel;
271	PsuedoID		localNodeID;				//����may go in atoms
272	SInt16			inputStandard;			// One of the QT input standards
273	Boolean			deviceActive;
274    UInt8			inputFormat;			// Expected STYPE of data from device
275    UInt32			outputFormats;			// Bitmask for supported STYPE values, if version > 0x200
276};
277
278//
279// Isochronous Data Handler Events
280//
281enum unsigned long IDHEvent
282{
283	kIDHEventInvalid			= 0,
284
285	kIDHEventDeviceAdded		= 1L << 0,		// A new device has been added to the bus
286	kIDHEventDeviceRemoved		= 1L << 1,		// A device has been removed from the bus
287	kIDHEventDeviceChanged		= 1L << 2,		// Some device has changed state on the bus
288	kIDHEventReadEnabled		= 1L << 3,		// A client has enabled a device for read
289	kIDHEventFrameDropped       = 1L << 4, 		// software failed to keep up with isoc data flow
290	kIDHEventReadDisabled	 	= 1L << 5,		// A client has disabled a device from read
291	kIDHEventWriteEnabled		= 1L << 6,		// A client has enabled a device for write
292	kIDHEventReserved2			= 1L << 7,		// Reserved for future use
293	kIDHEventWriteDisabled		= 1L << 8,		// A client has disabled a device for write
294
295	kIDHEventEveryEvent			= 0xFFFFFFFF,
296
297};
298
299typedef UInt32 IDHNotificationID;
300
301struct IDHEventHeader {
302	IDHDeviceID				deviceID;			// Device which generated event
303	IDHNotificationID		notificationID;
304	IDHEvent				event;				// What the event is
305};
306
307
308
309
310
311//
312// IDHGenericEvent
313//	An IDH will often have to post events from at interrupt time.  Since memory
314//	allocation cannot occur from the interrupt handler, the IDH can preallocate
315//	storage needed for handling the event by creating some IDHGenericEvent items.
316//	Subsequently, when an event is generated, the type of event (specified in the
317//	IDHEventHeader) will dictate how the IDHGenericEvent should be interpretted.
318//
319//	IMPORTANT NOTE : This means that a specific event structure can NEVER be greater
320//	than the size of the generic one.
321//
322struct IDHGenericEvent
323{
324	IDHEventHeader		eventHeader;
325	UInt32				pad[4];
326};
327
328
329//
330// IDHDeviceConnectionEvent
331//	For kIDHEventDeviceAdded or kIDHEventDeviceRemoved events.
332//
333struct IDHDeviceConnectionEvent
334{
335	IDHEventHeader	eventHeader;
336};
337
338
339//
340// IDHDeviceIOEnableEvent
341//	For kIDHEventReadEnabled, kIDHEventReadDisabled, kIDHEventWriteEnabled, or
342//	kIDHEventWriteDisabled.
343//
344struct IDHDeviceIOEnableEvent
345{
346	IDHEventHeader	eventHeader;
347};
348
349//
350// IDHDeviceFrameDroppedEvent
351//	For kIDHEventFrameDropped
352//
353struct IDHDeviceFrameDroppedEvent
354{
355	IDHEventHeader	eventHeader;
356	UInt32			totalDropped;
357	UInt32			newlyDropped;
358};
359
360
361typedef extern <nativeUPP, exportset=CarbonMultimedia_14, exportset=fw_DVComponentGlue_X>
362OSStatus (*IDHNotificationProcPtr)(IDHGenericEvent* event, void* userData);
363typedef IDHNotificationProcPtr IDHNotificationProc;	// old name
364#pragma UPPSuite emitUPPTypes
365
366struct IDHParameterBlock {
367	UInt32					reserved1;
368	UInt16					reserved2;
369	void*					buffer;
370	ByteCount				requestedCount;
371	ByteCount				actualCount;
372	IDHNotificationUPP		completionProc;
373	void*					refCon;
374	OSErr					result;
375};
376
377struct IDHResolution {
378	UInt32	x;
379	UInt32	y;
380};
381
382struct IDHDimension {
383	Fixed 	x;
384	Fixed 	y;
385};
386
387
388%TellEmitter "components" "prefix IDH";
389
390
391pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
392ComponentResult IDHGetDeviceList(ComponentInstance idh, QTAtomContainer* deviceList) = ComponentCall(1);
393
394pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
395ComponentResult IDHGetDeviceConfiguration(ComponentInstance idh, QTAtomSpec* configurationID) = ComponentCall(2);
396
397pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
398ComponentResult IDHSetDeviceConfiguration(ComponentInstance idh, const QTAtomSpec* configurationID) = ComponentCall(3);
399
400pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
401ComponentResult IDHGetDeviceStatus(ComponentInstance idh, const QTAtomSpec* configurationID, IDHDeviceStatus* status) = ComponentCall(4);
402
403pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
404ComponentResult IDHGetDeviceClock(ComponentInstance idh, Component* clock) = ComponentCall(5);
405
406pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
407ComponentResult IDHOpenDevice(ComponentInstance idh, UInt32 permissions) = ComponentCall(6);
408
409pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
410ComponentResult IDHCloseDevice(ComponentInstance idh) = ComponentCall(7);
411
412pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
413ComponentResult IDHRead(ComponentInstance idh, IDHParameterBlock* pb) = ComponentCall(8);
414
415pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
416ComponentResult IDHWrite(ComponentInstance idh, IDHParameterBlock* pb) = ComponentCall(9);
417
418pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
419ComponentResult IDHNewNotification(ComponentInstance idh, IDHDeviceID deviceID, IDHNotificationUPP notificationProc, void* userData, IDHNotificationID* notificationID) = ComponentCall(10);
420
421pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
422ComponentResult IDHNotifyMeWhen(ComponentInstance idh, IDHNotificationID	notificationID, IDHEvent events) = ComponentCall(11);
423
424pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
425ComponentResult IDHCancelNotification(ComponentInstance idh, IDHNotificationID notificationID)  = ComponentCall(12);
426
427pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
428ComponentResult IDHDisposeNotification(ComponentInstance idh, IDHNotificationID notificationID) = ComponentCall(13);
429
430pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
431ComponentResult IDHReleaseBuffer(ComponentInstance idh, IDHParameterBlock* pb) = ComponentCall(14);
432
433pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
434ComponentResult IDHCancelPendingIO(ComponentInstance idh, IDHParameterBlock* pb) = ComponentCall(15);
435
436pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
437ComponentResult IDHGetDeviceControl(ComponentInstance idh, ComponentInstance *deviceControl) = ComponentCall(16);
438pascal <exportset=IDHLib_10, exportset=CarbonMultimedia_13, exportset=fw_DVComponentGlue_X>
439ComponentResult IDHUpdateDeviceList(ComponentInstance idh, QTAtomContainer* deviceList) = ComponentCall(17);
440
441pascal <exportset=CarbonMultimedia_14, exportset=fw_DVComponentGlue_X>
442ComponentResult IDHGetDeviceTime(ComponentInstance idh, TimeRecord* deviceTime) = ComponentCall(18);
443
444pascal <exportset=CarbonMultimedia_15, exportset=fw_DVComponentGlue_X>
445ComponentResult IDHSetFormat(ComponentInstance idh, UInt32 format) = ComponentCall(19);
446
447pascal <exportset=CarbonMultimedia_15, exportset=fw_DVComponentGlue_X>
448ComponentResult IDHGetFormat(ComponentInstance idh, UInt32 *format) = ComponentCall(20);
449
450
451#pragma UPPSuite emitAll
452
453%TellEmitter "components" "emitProcInfos";
454%TellEmitter "c" "emitComponentSelectors";
455
456
457