19 #ifdef _AJA_COMPILE_WIN2K_SOFT_LINK
23 pfcnSetupDiGetClassDevsA)(
24 IN CONST GUID *ClassGuid, OPTIONAL
25 IN PCSTR Enumerator, OPTIONAL
26 IN HWND hwndParent, OPTIONAL
33 pfcnSetupDiGetClassDevsW)(
34 IN CONST GUID *ClassGuid, OPTIONAL
35 IN PCWSTR Enumerator, OPTIONAL
36 IN HWND hwndParent, OPTIONAL
40 #define pfcnSetupDiGetClassDevs pfcnSetupDiGetClassDevsW
42 #define pfcnSetupDiGetClassDevs pfcnSetupDiGetClassDevsA
48 pfcnSetupDiEnumDeviceInterfaces)(
49 IN HDEVINFO DeviceInfoSet,
50 IN PSP_DEVINFO_DATA DeviceInfoData, OPTIONAL
51 IN CONST GUID *InterfaceClassGuid,
53 OUT PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData
60 pfcnSetupDiGetDeviceInterfaceDetailA)(
61 IN HDEVINFO DeviceInfoSet,
62 IN PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
63 OUT PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData, OPTIONAL
64 IN DWORD DeviceInterfaceDetailDataSize,
65 OUT PDWORD RequiredSize, OPTIONAL
66 OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
72 pfcnSetupDiGetDeviceInterfaceDetailW)(
73 IN HDEVINFO DeviceInfoSet,
74 IN PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
75 OUT PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData, OPTIONAL
76 IN DWORD DeviceInterfaceDetailDataSize,
77 OUT PDWORD RequiredSize, OPTIONAL
78 OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
81 #define pfcnSetupDiGetDeviceInterfaceDetail pfcnSetupDiGetDeviceInterfaceDetailW
83 #define pfcnSetupDiGetDeviceInterfaceDetail pfcnSetupDiGetDeviceInterfaceDetailA
89 pfcnSetupDiDestroyDeviceInfoList)(
90 IN HDEVINFO DeviceInfoSet
96 pfcnSetupDiDestroyDriverInfoList)(
97 IN HDEVINFO DeviceInfoSet,
98 IN PSP_DEVINFO_DATA DeviceInfoData, OPTIONAL
102 static pfcnSetupDiGetClassDevs pSetupDiGetClassDevs =
NULL;
103 static pfcnSetupDiEnumDeviceInterfaces pSetupDiEnumDeviceInterfaces =
NULL;
104 static pfcnSetupDiGetDeviceInterfaceDetail pSetupDiGetDeviceInterfaceDetail =
NULL;
105 static pfcnSetupDiDestroyDeviceInfoList pSetupDiDestroyDeviceInfoList =
NULL;
106 static pfcnSetupDiDestroyDriverInfoList pSetupDiDestroyDriverInfoList =
NULL;
108 HINSTANCE hSetupAPI =
NULL;
114 LPVOID lpMsgBuf(
NULL);
115 FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
118 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
122 string result (lpMsgBuf ?
reinterpret_cast<const char*
>(lpMsgBuf) :
"");
123 LocalFree (lpMsgBuf);
125 const size_t crPos(result.find(
".\r"));
126 if (crPos != string::npos)
127 result.resize(crPos);
133 #define HEX2(__x__) "0x" << hex << setw(2) << setfill('0') << (0xFF & uint8_t (__x__)) << dec
134 #define HEX4(__x__) "0x" << hex << setw(4) << setfill('0') << (0xFFFF & uint16_t(__x__)) << dec
135 #define HEX8(__x__) "0x" << hex << setw(8) << setfill('0') << (0xFFFFFFFF & uint32_t(__x__)) << dec
136 #define HEX16(__x__) "0x" << hex << setw(16) << setfill('0') << uint64_t(__x__) << dec
137 #define KR(_kr_) "kernResult=" << HEX8(_kr_) << "(" << GetKernErrStr(_kr_) << ")"
138 #define INSTP(_p_) HEX16(uint64_t(_p_))
140 #define WDIFAIL(__x__) AJA_sERROR (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
141 #define WDIWARN(__x__) AJA_sWARNING(AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
142 #define WDINOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
143 #define WDIINFO(__x__) AJA_sINFO (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
144 #define WDIDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__)
151 ,_previousAudioState (0)
152 ,_previousAudioSelection (0)
153 #if !defined(NTV2_DEPRECATE_16_0)
168 #if !defined(NTV2_NULL_DEVICE)
182 #define AJAVIDEO_NTV2_PROPSET DEFINE_GUIDNAMED(AJAVIDEO_NTV2_PROPSET)
189 DWORD dwShareMode (
GetShareMode() ? FILE_SHARE_READ | FILE_SHARE_WRITE : 0);
190 DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED;
192 SP_DEVICE_INTERFACE_DATA spDevIFaceData;
193 memset(&spDevIFaceData, 0,
sizeof(SP_DEVICE_INTERFACE_DATA));
194 GUID myguid = refguid;
198 spDevIFaceData.cbSize =
sizeof(SP_DEVICE_INTERFACE_DATA);
211 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
235 ULONG deviceInstanceSize = 0;
236 CM_Get_Device_ID_Size(&deviceInstanceSize,
_spDevInfoData.DevInst, 0);
237 char* deviceInstance = (
char*)
new BYTE[deviceInstanceSize*2];
238 CM_Get_Device_IDA(
_spDevInfoData.DevInst, deviceInstance, deviceInstanceSize*2, 0);
239 boardStr = deviceInstance;
240 delete [] deviceInstance;
245 WDIFAIL(
"CreateFile failed for '" << boardStr <<
"'");
274 #ifndef _AJA_COMPILE_WIN2K_SOFT_LINK
277 if (pSetupDiDestroyDeviceInfoList)
291 #endif // !defined(NTV2_NULL_DEVICE)
303 WDIFAIL(
"Shift " <<
DEC(inShift) <<
" > 31, reg=" <<
DEC(inRegNum) <<
" msk=" <<
xHEX0N(inMask,8));
306 #if defined(NTV2_NUB_CLIENT_SUPPORT)
309 #endif // defined(NTV2_NUB_CLIENT_SUPPORT)
316 DWORD dwBytesReturned = 0;
320 propStruct.
Property.Flags = KSPROPERTY_TYPE_GET;
342 WDIFAIL(
"Shift " <<
DEC(inShift) <<
" > 31, reg=" <<
DEC(inRegNum) <<
" msk=" <<
xHEX0N(inMask,8));
345 #if defined(NTV2_WRITEREG_PROFILING) // Register Write Profiling
353 #endif // defined(NTV2_WRITEREG_PROFILING) // Register Write Profiling
354 #if defined(NTV2_NUB_CLIENT_SUPPORT)
357 #endif // defined(NTV2_NUB_CLIENT_SUPPORT)
361 DWORD dwBytesReturned = 0;
367 propStruct.
Property.Flags = KSPROPERTY_TYPE_SET;
399 DWORD dwBytesReturned = 0;
403 propStruct.
Property.Flags = bEnable ? KSPROPERTY_TYPE_GET : KSPROPERTY_TYPE_SET;
409 WDIFAIL(
"interruptType=" <<
DEC(eInterruptType) <<
" enable=" << (bEnable?
"Y":
"N") <<
" failed: " << ::
GetKernErrStr(GetLastError()));
422 if (!IsOpen() && !IsRemote())
428 if (bSubscribe && outSubscriptionHdl)
432 if (!bSubscribe && !outSubscriptionHdl)
436 HANDLE hSubscription = bSubscribe ? CreateEvent (
NULL, FALSE, FALSE,
NULL) :
HANDLE(outSubscriptionHdl);
438 DWORD dwBytesReturned = 0;
443 propStruct.
Property.Flags = bSubscribe ? KSPROPERTY_TYPE_GET : KSPROPERTY_TYPE_SET;
444 propStruct.
Handle = hSubscription;
449 if ((!bSubscribe && bRet) || (bSubscribe && !bRet))
451 CloseHandle(hSubscription);
452 outSubscriptionHdl = 0;
457 WDIFAIL(
"interruptType=" <<
DEC(eInterruptType) <<
" subscribe=" << (bSubscribe?
"Y":
"N") <<
" failed: " << ::
GetKernErrStr(GetLastError()));
461 outSubscriptionHdl =
PULWord(hSubscription);
470 #if defined(NTV2_NUB_CLIENT_SUPPORT)
473 #endif // defined(NTV2_NUB_CLIENT_SUPPORT)
477 DWORD dwBytesReturned = 0;
481 propStruct.
Property.Flags = KSPROPERTY_TYPE_GET;
483 propStruct.
ulIntCount = ULONG(eInterruptType);
501 AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
AJA_DebugStat_WaitForInterruptOthers,
518 #if defined(NTV2_NUB_CLIENT_SUPPORT)
521 #endif // defined(NTV2_NUB_CLIENT_SUPPORT)
526 bool bInterruptHappened =
false;
538 DWORD status = WaitForSingleObject(hEvent, timeOutMs);
540 if ( status == WAIT_OBJECT_0 )
542 bInterruptHappened =
true;
550 return bInterruptHappened;
557 #if !defined(NTV2_DEPRECATE_16_0)
566 DWORD dwBytesReturned = 0;
572 propStruct.
Property.Flags = KSPROPERTY_TYPE_GET;
598 ULWord * pFrameBaseAddress;
600 if (!pFrameBaseAddress)
604 DWORD dwBytesReturned = 0;
608 propStruct.
Property.Flags = KSPROPERTY_TYPE_SET;
631 DWORD dwBytesReturned = 0;
637 propStruct.
Property.Flags = KSPROPERTY_TYPE_GET;
662 DWORD dwBytesReturned = 0;
666 propStruct.
Property.Flags = KSPROPERTY_TYPE_SET;
687 DWORD dwBytesReturned = 0;
693 propStruct.
Property.Flags = KSPROPERTY_TYPE_GET;
717 DWORD dwBytesReturned = 0;
721 propStruct.
Property.Flags = KSPROPERTY_TYPE_SET;
742 DWORD dwBytesReturned = 0;
746 propStruct.
Property.Flags = bMap ? KSPROPERTY_TYPE_GET : KSPROPERTY_TYPE_SET;
753 WDIFAIL (
KR(GetLastError()) <<
" -- numBytes=" << ulNumBytes <<
" map=" << (bMap?
"Y":
"N"));
819 if (*vecIter == pFrameBuffer)
826 #endif // !defined(NTV2_DEPRECATE_16_0)
834 const ULWord inFrameNumber,
836 const ULWord inOffsetBytes,
838 const bool inSynchronous)
842 inOffsetBytes, inByteCount, inSynchronous);
847 DWORD dwBytesReturned = 0;
851 propStruct.
Property.Flags = inIsRead ? KSPROPERTY_TYPE_GET : KSPROPERTY_TYPE_SET;
858 propStruct.
bSync = inSynchronous;
865 WDIFAIL (
"failed: " << ::
GetKernErrStr(GetLastError()) <<
": eng=" << inDMAEngine <<
" frm=" << inFrameNumber
866 <<
" off=" <<
HEX8(inOffsetBytes) <<
" len=" <<
HEX8(inByteCount) <<
" " << (inIsRead ?
"Rd" :
"Wr"));
875 const ULWord inFrameNumber,
877 const ULWord inOffsetBytes,
879 const ULWord inNumSegments,
882 const bool inSynchronous)
886 inNumSegments, inHostPitch, inCardPitch, inSynchronous);
891 DWORD dwBytesReturned = 0;
895 propStruct.
Property.Flags = inIsRead ? KSPROPERTY_TYPE_GET : KSPROPERTY_TYPE_SET;
905 propStruct.
bSync = inSynchronous;
912 WDIFAIL (
"failed: " << ::
GetKernErrStr(GetLastError()) <<
": eng=" << inDMAEngine <<
" frm=" << inFrameNumber
913 <<
" off=" <<
HEX8(inOffsetBytes) <<
" len=" <<
HEX8(inByteCount) <<
" " << (inIsRead ?
"Rd" :
"Wr"));
921 const bool inIsTarget,
922 const ULWord inFrameNumber,
923 const ULWord inCardOffsetBytes,
925 const ULWord inNumSegments,
932 inNumSegments, inHostPitch, inCardPitch, inP2PData);
941 DWORD dwBytesReturned(0);
951 propStruct.
Property.Flags = KSPROPERTY_TYPE_GET;
960 propStruct.
Property.Flags = KSPROPERTY_TYPE_SET;
981 WDIFAIL (
"Failed: " << ::
GetKernErrStr(GetLastError()) <<
": eng=" << inDMAEngine <<
" ch=" << inDMAChannel
982 <<
" frm=" << inFrameNumber <<
" off=" <<
HEX8(inCardOffsetBytes) <<
" siz=" <<
HEX8(inByteCount)
983 <<
" #segs=" << inNumSegments <<
" hostPitch=" << inHostPitch <<
" cardPitch=" << inCardPitch
984 <<
" target=" << (inIsTarget?
"Y":
"N"));
992 WDIFAIL (
"Target failed: " << ::
GetKernErrStr(GetLastError()) <<
" eng=" << inDMAEngine <<
" ch=" << inDMAChannel
993 <<
" frm=" << inFrameNumber <<
" off=" <<
HEX8(inCardOffsetBytes) <<
" vSiz=" <<
HEX8(inByteCount)
994 <<
" segs=" << inNumSegments <<
" hostPitch=" << inHostPitch <<
" cardPitch=" << inCardPitch
995 <<
" target=" << (inIsTarget?
"Y":
"N") <<
" p2pBytesRet=" <<
HEX8(dwBytesReturned)
1017 DWORD dwBytesReturned(0);
1023 if (autoCircData.
lVal4 <= 1 && autoCircData.
lVal5 == 0 && autoCircData.
lVal6 == 0)
1029 autoCircControl.
Property.Flags = KSPROPERTY_TYPE_SET;
1057 autoCircControl.
Property.Flags = KSPROPERTY_TYPE_SET;
1097 autoCircControl.
Property.Flags = KSPROPERTY_TYPE_SET;
1133 autoCircStatus.
Property.Flags = KSPROPERTY_TYPE_GET;
1148 {bRes =
false;
WDIFAIL(
"GetAC failed: NULL pvVal1");}
1158 autoCircFrame.
Property.Flags = KSPROPERTY_TYPE_GET;
1176 {bRes =
false;
WDIFAIL(
"GetFrameStamp failed: NULL pvVal1");}
1186 autoCircFrame.
Property.Flags = KSPROPERTY_TYPE_GET;
1211 {bRes =
false;
WDIFAIL(
"GetFrameStampEx2 failed: NULL pvVal1");}
1221 acXfer.
Property.Flags = KSPROPERTY_TYPE_GET;
1225 {bRes =
false;
WDIFAIL(
"ACXfer failed: pvVal1 or pvVal2 NULL");
break;}
1252 acXfer.
Property.Flags = KSPROPERTY_TYPE_GET;
1256 {bRes =
false;
WDIFAIL(
"ACXferEx failed: NULL XferStruct or XferStatusStruct");
break;}
1285 acXfer.
Property.Flags = KSPROPERTY_TYPE_GET;
1289 {bRes =
false;
WDIFAIL(
"ACXferEx2 failed: NULL XferStruct or RoutingTable");
break;}
1321 autoCircFrame.
Property.Flags = KSPROPERTY_TYPE_SET;
1326 if (!autoCircData.
pvVal1)
1327 {bRes =
false;
WDIFAIL(
"ACSetCaptureTask failed: NULL TaskStruct");
break;}
1353 {
WDIFAIL(
"Failed: NULL pointer");
return false;}
1354 DWORD dwBytesReturned(0);
1356 const bool ok = DeviceIoControl(
_hDevice,
IOCTL_AJANTV2_MESSAGE, pInMessage, pInMessage->GetSizeInBytes (), pInMessage, pInMessage->GetSizeInBytes(), &dwBytesReturned,
NULL);
1367 {
WDIFAIL(
"Failed: NULL pointer");
return false;}
1368 DWORD dwBytesReturned(0);
1401 DWORD dwBytesReturned(0);
1406 propStruct.
Property.Flags = KSPROPERTY_TYPE_GET;
1419 DWORD dwBytesReturned(0);
1424 propStruct.
Property.Flags = KSPROPERTY_TYPE_SET;