1/* 2 * Copyright (c) 2009 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: DVFamily.h 25 26 Copyright: � 2001 by Apple Computer, Inc., all rights reserved. 27 28*/ 29// 30// DVFamily.h 31// 32 33#ifndef __DVFAMILY__ 34#define __DVFAMILY__ 35 36#include <IOKit/avc/IOFireWireAVCConsts.h> 37#ifdef __cplusplus 38extern "C" { 39#endif 40 41/////////////////////////////////////////////////////////////////////// 42// 43// constants 44// 45/////////////////////////////////////////////////////////////////////// 46 47enum 48{ 49 kInvalidDVDeviceID = 0, 50 kEveryDVDeviceID = 0xFFFFFFFF, 51 kInvalidDVConnectionID = 0, 52 kInvalidDVDeviceRefNum = 0, 53 kEveryDVDeviceRefNum = 0xFFFFFFFF 54}; 55 56enum 57{ 58 kDVDisconnectedErr = -14101, 59 kDVBadIDErr = -14102, 60 kUnknownStandardErr = -14103, 61 kAlreadyEnabledErr = -14104, 62 kNotEnabledErr = -14105, 63 kDVDeviceBusyErr = -14106, 64 kDVNoNotificationsErr = -14107 65}; 66 67enum 68{ 69 kUnknownStandard = 0, 70 kNTSCStandard = 1, 71 kPALStandard = 2 72}; 73 74// DV events 75enum 76{ 77 kInvalidDVDeviceEvent = 0, 78 79 kDVDeviceAdded = 1 << 0, 80 kDVDeviceRemoved = 1 << 1, 81 KDVDeviceInfoChanged = 1 << 2, 82 83 kDVIsochReadEnabled = 1 << 3, 84 kDVIsochReadComplete = 1 << 4, 85 kDVIsochReadDisabled = 1 << 5, 86 87 kDVIsochWriteEnabled = 1 << 6, 88 kDVIsochWriteComplete = 1 << 7, 89 kDVIsochWriteDisabled = 1 << 8, 90 91 kDVAVCEnabled = 1 << 9, 92 kDVAVCDisabled = 1 << 10, 93 kDVAVCTransactionComplete = 1 << 11, 94 95 // Tempory new event for input. Goes away DVFamily is dead. 96 kDVInputEvent = 1 << 12, 97 98 kDVEveryEvent = 0x00001fff 99}; 100 101enum 102{ 103 kDVGlobalEventConnectionID = 0xffffffff, 104 kEventSpecificDataSize = 16 105}; 106 107/////////////////////////////////////////////////////////////////////// 108// 109// types 110// 111/////////////////////////////////////////////////////////////////////// 112 113// holds our device identification... 114typedef UInt32 DVDeviceID; 115 116// holds our device connection identification... 117typedef UInt32 DVDeviceRefNum; 118 119typedef UInt32 DVClientID; 120 121// AVC 122enum { 123 kAVCSupportInquiryCommand = 0x02, 124 kAVCReportInquiryCommand = 0x03, 125 126 // Opcodes and parameters 127 kAVCWindOpcode = 0xc4, 128 kAVCWindHighSpeedRewind = 0x45, 129 kAVCWindStop = 0x60, 130 kAVCWindRewind = 0x65, 131 kAVCWindFastForward = 0x75, 132 133 kAVCPlayOpcode = 0xc3, 134 kAVCPlayNextFrame = 0x30, 135 kAVCPlaySlowest = 0x31, 136 kAVCPlaySlow6 = 0x32, 137 kAVCPlaySlow5 = 0x33, 138 kAVCPlaySlow4 = 0x34, 139 kAVCPlaySlow3 = 0x35, 140 kAVCPlaySlow2 = 0x36, 141 kAVCPlaySlow1 = 0x37, 142 kAVCPlay1x = 0x38, 143 kAVCPlayFast1 = 0x39, 144 kAVCPlayFast2 = 0x3a, 145 kAVCPlayFast3 = 0x3b, 146 kAVCPlayFast4 = 0x3c, 147 kAVCPlayFast5 = 0x3d, 148 kAVCPlayFast6 = 0x3e, 149 kAVCPlayFastest = 0x3f, 150 kAVCPlayPreviousFrame = 0x40, 151 kAVCPlayRevSlowest = 0x41, 152 kAVCPlayRevSlow6 = 0x42, 153 kAVCPlayRevSlow5 = 0x43, 154 kAVCPlayRevSlow4 = 0x44, 155 kAVCPlayRevSlow3 = 0x45, 156 kAVCPlayRevSlow2 = 0x46, 157 kAVCPlayRevSlow1 = 0x47, 158 kAVCPlayRev1x = 0x48, 159 kAVCPlayRevFast1 = 0x49, 160 kAVCPlayRevFast2 = 0x4a, 161 kAVCPlayRevFast3 = 0x4b, 162 kAVCPlayRevFast4 = 0x4c, 163 kAVCPlayRevFast5 = 0x4d, 164 kAVCPlayRevFast6 = 0x4e, 165 kAVCPlayRevFastest = 0x4f, 166 kAVCPlayForward = 0x75, 167 kAVCPlayForwardPause = 0x7d, 168 kAVCPlayReverse = 0x65, 169 kAVCPlayReversePause = 0x6d, 170 171 kAVCMediumOpcode = 0xc1, 172 kAVCMediumEject = 0x60, 173 kAVCMediumTrayOpen = 0x31, 174 kAVCMediumTrayClose = 0x32, 175 176 kAVCRecordOpcode = 0xc2, 177 kAVCRecVideoInsert = 0x31, 178 kAVCRecAudioInsert = 0x32, 179 kAVCRecAVInsert = 0x33, 180 kAVCRecSubcodeInsert = 0x34, 181 kAVCRecord = 0x75, 182 kAVCRecPause = 0x7d, 183 kAVCRecVideoInsertPause = 0x41, 184 kAVCRecAudioInsertPause = 0x42, 185 kAVCRecAVInsertPause = 0x43, 186 kAVCRecSubcodeInsertPause = 0x44, 187 188 kAVCRecSpeedOpcode = 0xdb, 189 kAVCRecSpeedLowSpeed = 0x00, 190 kAVCRecSpeed32 = 0x20, 191 kAVCRecSpeedStandard = 0x6f, 192 kAVCRecSpeedHighSpeed = 0xfe, 193 kAVCRecSpeedDummyOperand = 0x7f, 194 195 kAVCEditPresetOpcode = 0x45, 196 kAVCEditPreRollAndStandby = 0x00, 197 kAVCEditVideoInsert = 0x21, 198 kAVCEditAudioInsert = 0x22, 199 kAVCEditAVInsert = 0x23, 200 kAVCEditSubcodeInsert = 0x24, 201 kAVCEditSyncRecord = 0x25, 202 kAVCEditSyncPlay = 0x35, 203 kAVCEditOtherMode = 0x60, 204 kAVCEditInPoint = 0x00, 205 kAVCEditOutPoint = 0x01, 206 kAVCEditPreRollTime = 0x02, 207 kAVCEditDummyOperand = 0xff, 208 209 kAVCPositionDummyOperand = 0xff, 210 211 kAVCPositionTimeCodeOpcode = 0x51, 212 kAVCPositionValueInquiry = 0x71, 213 214 kAVCMechaModeInquiryOpcode = 0xd0, 215 kAVCMechaModeDummyOperand = 0x7f 216 217}; 218 219typedef struct AVCCTSFrameStruct { 220 UInt8 cmdType_respCode; // cmd type/resp onse code 221 UInt8 headerAddress; 222 UInt8 opcode; 223 UInt8 operand[5]; 224} AVCCTSFrameStruct, *AVCCTSFrameStructPtr; 225 226// for sending AVC commands 227typedef struct AVCTransactionParamsStruct { 228 Ptr commandBufferPtr; 229 UInt32 commandLength; 230 Ptr responseBufferPtr; 231 UInt32 responseBufferSize; 232 void * responseHandler; // Obsolete 233} AVCTransactionParams, *AVCTransactionParamsPtr; 234 235/////////////////////////////////////////////////////////////////////// 236// 237// DV Event Notification 238// 239 240typedef struct OpaqueRef *DVNotificationID; 241 242typedef struct DVEventHeaderStruct { 243 DVDeviceID deviceID; // who it's from 244 DVNotificationID notifID; 245 UInt32 theEvent; // what the event was 246} DVEventHeader, *DVEventHeaderPtr; 247 248typedef struct DVEventRecordStruct { // generalized form 249 DVEventHeader eventHeader; 250 UInt8 eventData[kEventSpecificDataSize]; 251} DVEventRecord, *DVEventRecordPtr; 252 253typedef struct DVConnectionEventStruct { 254 DVEventHeader eventHeader; 255} DVConnectionEvent, *DVConnectionEventPtr; 256 257typedef struct DVIsochCompleteEventStruct { 258 DVEventHeader eventHeader; 259 Ptr pFrameBuffer; 260 unsigned long bufferSize; 261 UInt32 fwCycleTime; 262} DVIsochCompleteEvent, *DVIsochCompleteEventPtr; 263 264typedef struct DVAVTransactionCompleteEventStruct { 265 DVEventHeader eventHeader; 266 Ptr commandBufferPtr; 267 UInt32 commandLength; 268 Ptr responseBufferPtr; 269 UInt32 responseBufferSize; 270} DVAVCTransactionCompleteEvent, *DVAVCTransactionCompleteEventPtr; 271 272// DV notification proc 273typedef OSStatus (*DVNotifyProc)(DVEventRecordPtr event, void *userData ); 274 275/////////////////////////////////////////////////////////////////////// 276// 277// external prototypes 278// 279/////////////////////////////////////////////////////////////////////// 280 281/////////////////////////////////////////////////////////////////////// 282// 283// general device management 284// 285UInt32 DVCountDevices( void ); 286OSErr DVGetIndDevice( DVDeviceID * pDVDevice, UInt32 index ); 287 288OSErr DVSetDeviceName( DVDeviceID deviceID, char * str ); 289OSErr DVGetDeviceName( DVDeviceID deviceID, char * str ); 290 291OSErr DVOpenDriver( DVDeviceID deviceID, DVDeviceRefNum *pRefNum ); 292OSErr DVCloseDriver( DVDeviceRefNum refNum ); 293 294//OSErr DVGetDeviceInfo( DVDeviceID deviceID, DVDeviceInfoPtr pInfo ); 295//OSErr DVGetDeviceClock( DVDeviceID deviceID, Component *clock ); 296 297/////////////////////////////////////////////////////////////////////// 298// 299// DV event notification 300// 301// kEveryDVDeviceRefNum can be used as a wild card refNum, for notifications about all 302// devices - especially handy when there aren't any yet! 303// 304OSErr DVNewNotification( DVDeviceRefNum refNum, DVNotifyProc notifyProc, 305 void *userData, DVNotificationID *pNotifyID ); 306 307OSErr DVNotifyMeWhen( DVDeviceRefNum refNum, DVNotificationID notifyID, UInt32 events); 308OSErr DVCancelNotification( DVDeviceRefNum refNum, DVNotificationID notifyID ); 309OSErr DVDisposeNotification( DVDeviceRefNum refNum, DVNotificationID notifyID ); 310 311/////////////////////////////////////////////////////////////////////// 312// 313// DV Isoch Read 314// 315OSErr DVEnableRead( DVDeviceRefNum refNum ); 316OSErr DVDisableRead( DVDeviceRefNum refNum ); 317OSErr DVReadFrame( DVDeviceRefNum refNum, Ptr *ppReadBuffer, UInt32 * pSize ); 318OSErr DVReleaseFrame( DVDeviceRefNum refNum, Ptr pReadBuffer ); 319 320/////////////////////////////////////////////////////////////////////// 321// 322// DV Isoch Write 323// 324OSErr DVEnableWrite( DVDeviceRefNum refNum ); 325OSErr DVDisableWrite( DVDeviceRefNum refNum ); 326OSErr DVGetEmptyFrame( DVDeviceRefNum refNum, Ptr *ppEmptyFrameBuffer, UInt32 * pSize ); 327OSErr DVWriteFrame( DVDeviceRefNum refNum, Ptr pWriteBuffer ); 328OSErr DVSetWriteSignalMode( DVDeviceRefNum refNum, UInt8 mode); 329 330/////////////////////////////////////////////////////////////////////// 331// 332// AVC transactions 333// 334OSErr DVDoAVCTransaction( DVDeviceRefNum refNum, AVCTransactionParamsPtr pParams ); 335 336OSErr DVIsEnabled( DVDeviceRefNum refNum, Boolean *isEnabled); 337OSErr DVGetDeviceStandard( DVDeviceRefNum refNum, UInt32 * pStandard ); 338 339 340 341 342#ifdef __cplusplus 343} 344#endif 345 346#endif __DVFAMILY__ 347 348 349