20 #define HEX2(__x__) "0x" << hex << setw(2) << setfill('0') << (0xFF & uint8_t (__x__)) << dec 21 #define HEX4(__x__) "0x" << hex << setw(4) << setfill('0') << (0xFFFF & uint16_t(__x__)) << dec 22 #define HEX8(__x__) "0x" << hex << setw(8) << setfill('0') << (0xFFFFFFFF & uint32_t(__x__)) << dec 23 #define HEX16(__x__) "0x" << hex << setw(16) << setfill('0') << uint64_t(__x__) << dec 24 #define INSTP(_p_) HEX16(uint64_t(_p_)) 26 #define LDIFAIL(__x__) AJA_sERROR (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 27 #define LDIWARN(__x__) AJA_sWARNING(AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 28 #define LDINOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 29 #define LDIINFO(__x__) AJA_sINFO (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 30 #define LDIDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_DriverInterface, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 32 #define AsFrameStampStructPtr(_p_) reinterpret_cast<FRAME_STAMP_STRUCT*>(_p_) 33 #define AsStatusStructPtr(_p_) reinterpret_cast<AUTOCIRCULATE_STATUS_STRUCT*>(_p_) 34 #define AsTransferStatusStruct(_p_) reinterpret_cast<PAUTOCIRCULATE_TRANSFER_STATUS_STRUCT>(_p_) 35 #define AsRoutingTablePtr(_p_) reinterpret_cast<NTV2RoutingTable*>(_p_) 36 #define AsPTaskStruct(_p_) reinterpret_cast<PAUTOCIRCULATE_TASK_STRUCT>(_p_) 37 #define AsPTransferStruct(_p_) reinterpret_cast<PAUTOCIRCULATE_TRANSFER_STRUCT>(_p_) 38 #define AsVoidPtr(_p_) reinterpret_cast<void*>(_p_) 42 : _bitfileDirectory (
"../xilinx")
44 #
if !defined(NTV2_DEPRECATE_16_0)
61 #if !defined(NTV2_NULL_DEVICE) 70 if (inDeviceIndex != 0) {
71 LDIFAIL(
"Invalid device index " << inDeviceIndex);
87 if (legalDeviceIDs.find(
_boardID) == legalDeviceIDs.end())
106 #if !defined(NTV2_DEPRECATE_16_0) 109 #endif // !defined(NTV2_DEPRECATE_16_0) 119 #endif // !defined(NTV2_NULL_DEVICE) 131 LDIFAIL(
"Shift " <<
DEC(inShift) <<
" > 31, reg=" <<
DEC(inRegNum) <<
" msk=" <<
xHEX0N(inMask,8));
134 outValue = (*(uint32_t *)(0x80000000+4*inRegNum) & inMask) >> inShift;
145 LDIFAIL(
"Shift " <<
DEC(inShift) <<
" > 31, reg=" <<
DEC(inRegNum) <<
" msk=" <<
xHEX0N(inMask,8));
148 uint32_t val = *(uint32_t *)(0x80000000+4*inRegNum);
150 val |= (inValue << inShift) & inMask;
153 *(uint32_t *)(0x80000000+4*inRegNum) = val;
164 {
LDIFAIL(
"IOCTL_NTV2_RESTORE_HARDWARE_PROCAMP_REGISTERS failed");
return false;}
184 intrControlStruct.
enable = bEnable;
187 LDIFAIL(
"IOCTL_NTV2_INTERRUPT_CONTROL failed");
222 LDIFAIL(
"Unsupported interrupt count request. Only vertical input interrupts counted.");
235 {
LDIFAIL(
"IOCTL_NTV2_INTERRUPT_CONTROL failed");
return false;}
248 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,
282 {
LDIFAIL(
"IOCTL_NTV2_WAITFOR_INTERRUPT failed");
return false;}
284 return waitIntrStruct.
success != 0;
297 cddmStruct.
msgSet = msgSet;
298 cddmStruct.
enable = enable;
301 LDIFAIL(
"IOCTL_NTV2_CONTROL_DRIVER_DEBUG_MESSAGES failed");
304 return cddmStruct.
success != 0;
318 LDIFAIL(
"IOCTL_NTV2_SETUP_BOARD failed");
331 #if !defined(NTV2_DEPRECATE_16_0) 346 LDIFAIL (
"MapFrameBuffers failed - couldn't get BA1MemorySize");
350 if (BA1MemorySize == 0)
352 LDIFAIL (
"BA1MemorySize is 0 -- module loaded with MapFrameBuffers=0?");
353 LDIFAIL (
"PIO mode not available, only driverbuffer DMA.");
369 LDIFAIL (
"MapFrameBuffers failed in call to mmap()");
398 LDIFAIL (
"UnmapFrameBuffers failed - couldn't get BA1MemorySize");
421 LDIFAIL (
"MapRegisters failed - couldn't get BA0MemorySize");
428 LDIFAIL (
"BA0MemorySize is 0, registers not mapped.");
494 LDIFAIL (
"MapXena2Flash failed - couldn't get BA4MemorySize");
500 LDIFAIL (
"MapXena2Flash failed - BA4MemorySize == 0");
507 PROT_READ | PROT_WRITE, MAP_SHARED,
512 LDIFAIL (
"MapXena2Flash(): mmap of BAR4 for PCI Flash failed");
547 LDIFAIL (
"MapDNXRegisters failed - couldn't get BA2MemorySize");
552 LDIFAIL (
"MapDNXRegisters failed - BA2MemorySize == 0");
560 PROT_READ | PROT_WRITE, MAP_SHARED,
566 LDIFAIL (
"MapDNXRegisters failed - couldn't map BAR2");
590 #endif // !defined(NTV2_DEPRECATE_16_0) 600 const ULWord inFrameNumber,
602 const ULWord inOffsetBytes,
604 const bool inSynchronous)
606 uint8_t *mem = (uint8_t *)*(uint32_t *)(0x80000000+4*0x3442);
607 printf(
"%08lx\n", mem);
608 memcpy(mem, pFrameBuffer, inByteCount);
612 inOffsetBytes, inByteCount, inSynchronous);
617 dmaControlBuf.
engine = inDMAEngine;
623 dmaControlBuf.
numBytes = inByteCount;
629 dmaControlBuf.
poll = 0;
630 #if defined(NTV2_DRIVER_ALLOCATED_BUFFERS) 631 ULWord numDmaDriverBuffers;
638 dmaControlBuf.
poll = 0;
640 #endif // defined(NTV2_DRIVER_ALLOCATED_BUFFERS) 644 #define ERRMSG(s) #s " failed" 649 if (inOffsetBytes == 0)
662 if (inOffsetBytes == 0)
676 const int result (ioctl(
int(
_hDevice), request, &dmaControlBuf));
689 const ULWord inFrameNumber,
691 const ULWord inOffsetBytes,
693 const ULWord inNumSegments,
696 const bool inIsSynchronous)
702 LDIDBG(
"FRM=" << inFrameNumber <<
" ENG=" << inDMAEngine <<
" NB=" << inByteCount << (inIsRead?
" Rd":
" Wr"));
706 dmaControlBuf.
engine = inDMAEngine;
711 dmaControlBuf.
numBytes = inByteCount;
715 dmaControlBuf.
poll = 0;
716 #if defined(NTV2_DRIVER_ALLOCATED_BUFFERS) 717 ULWord numDmaDriverBuffers(0);
721 if (!inIsSynchronous)
724 #endif // defined(NTV2_DRIVER_ALLOCATED_BUFFERS) 728 #define ERRMSG(s) #s " failed" 760 const int result (ioctl(
int(
_hDevice), request, &dmaControlBuf));
774 const bool inIsTarget,
775 const ULWord inFrameNumber,
776 const ULWord inCardOffsetBytes,
778 const ULWord inNumSegments,
779 const ULWord inSegmentHostPitch,
780 const ULWord inSegmentCardPitch,
788 inNumSegments, inSegmentHostPitch, inSegmentCardPitch, inP2PData);
797 ::memset (
AsVoidPtr(&dmaP2PStruct), 0,
sizeof(dmaP2PStruct));
814 dmaP2PStruct.
bRead = inIsTarget;
831 {
LDIFAIL(
"IOCTL error");
return false;}
870 {
LDIFAIL(
"IOCTL_NTV2_AUTOCIRCULATE_CONTROL failed");
return false;}
881 {
LDIFAIL(
"IOCTL_NTV2_AUTOCIRCULATE_STATUS, failed");
return false;}
891 memset(&acFrameStampCombo, 0,
sizeof acFrameStampCombo);
898 {
LDIFAIL(
"IOCTL_NTV2_AUTOCIRCULATE_FRAMESTAMP failed");
return false;}
910 memset(&acFrameStampCombo, 0,
sizeof acFrameStampCombo);
915 acFrameStampCombo.
acTask = *pTask;
920 {
LDIFAIL(
"IOCTL_NTV2_AUTOCIRCULATE_FRAMESTAMP failed");
return false;}
923 *pTask = acFrameStampCombo.
acTask;
934 {
LDIFAIL (
"TransferAutoCirculate failed - audio buffer size not mod 4");
return false;}
935 #if defined(NTV2_DRIVER_ALLOCATED_BUFFERS) 936 ULWord numDmaDriverBuffers;
939 {
LDIFAIL (
"TransferAutoCirculate failed - audio buffer address not mod 4");
return false;}
940 #endif // defined(NTV2_DRIVER_ALLOCATED_BUFFERS) 946 memset((
void*)&acXferCombo, 0,
sizeof acXferCombo);
949 acXferCombo.channelSpec = autoCircData.
channelSpec;
950 acXferCombo.acTransfer = *acTransfer;
951 acXferCombo.acStatus = *acStatus;
952 if (!pXena2RoutingTable)
953 memset(&acXferCombo.acXena2RoutingTable, 0,
sizeof(acXferCombo.acXena2RoutingTable));
955 acXferCombo.acXena2RoutingTable = *pXena2RoutingTable;
962 {
LDIFAIL(
"IOCTL_NTV2_AUTOCIRCULATE_TRANSFER failed");
return false;}
964 *acStatus = acXferCombo.acStatus;
975 {
LDIFAIL (
"TransferAutoCirculate failed - audio buffer size not mod 4");
return false;}
976 #if defined(NTV2_DRIVER_ALLOCATED_BUFFERS) 977 ULWord numDmaDriverBuffers;
979 if ((
unsigned long)acTransfer->
audioBuffer >= numDmaDriverBuffers && (
unsigned long)acTransfer->
audioBuffer % 4)
980 {
LDIFAIL (
"TransferAutoCirculate failed - audio buffer address not mod 4");
return false;}
981 #endif // defined(NTV2_DRIVER_ALLOCATED_BUFFERS) 987 memset((
void*)&acXferCombo, 0,
sizeof acXferCombo);
990 acXferCombo.channelSpec = autoCircData.
channelSpec;
991 acXferCombo.acTransfer = *acTransfer;
992 acXferCombo.acStatus = *acStatus;
993 if (!pXena2RoutingTable)
994 memset(&acXferCombo.acXena2RoutingTable, 0,
sizeof(acXferCombo.acXena2RoutingTable));
996 acXferCombo.acXena2RoutingTable = *pXena2RoutingTable;
1003 {
LDIFAIL(
"IOCTL_NTV2_AUTOCIRCULATE_TRANSFER failed");
return false;}
1005 *acStatus = acXferCombo.acStatus;
1016 {
LDIFAIL (
"TransferAutoCirculate failed - audio buffer size not mod 4");
return false;}
1017 #if defined(NTV2_DRIVER_ALLOCATED_BUFFERS) 1018 ULWord numDmaDriverBuffers;
1021 {
LDIFAIL (
"TransferAutoCirculate failed - audio buffer address not mod 4");
return false;}
1022 #endif // defined(NTV2_DRIVER_ALLOCATED_BUFFERS) 1028 ::memset(
AsVoidPtr(&acXferCombo), 0,
sizeof(acXferCombo));
1035 if (pXena2RoutingTable)
1038 acXferCombo.
acTask = *pTask;
1045 {
LDIFAIL(
"IOCTL_NTV2_AUTOCIRCULATE_TRANSFER failed");
return false;}
1054 memset(&acFrameStampCombo, 0,
sizeof acFrameStampCombo);
1057 acFrameStampCombo.
acTask = *pTask;
1062 {
LDIFAIL(
"IOCTL_NTV2_AUTOCIRCULATE_CAPTURETASK failed");
return false;}
1067 LDIFAIL(
"Unsupported AC command type in AutoCirculate()");
1089 {
LDIFAIL(
"IOCTL_AJANTV2_MESSAGE failed");
return false;}
1095 #if !defined(NTV2_DEPRECATE_16_0) 1114 ULWord numDmaDriverBuffers;
1117 LDIFAIL(
"GetDMANumDriverBuffers() failed");
1121 if (!numDmaDriverBuffers)
1123 LDIFAIL(
"numDmaDriverBuffers == 0");
1131 PROT_READ | PROT_WRITE,MAP_SHARED,
1162 ULWord numDmaDriverBuffers;
1165 LDIFAIL(
"GetDMANumDriverBuffers() failed");
1168 if (!numDmaDriverBuffers)
1171 LDIFAIL(
"numDmaDriverBuffers == 0");
1180 #endif // !defined(NTV2_DEPRECATE_16_0) 1192 #if !defined(NTV2_DEPRECATE_16_0) 1222 dmaControlBuf.
poll = poll;
1224 {
LDIFAIL(
"IOCTL_NTV2_DMA_WRITE_FRAME failed");
return false;}
1258 dmaControlBuf.
poll = poll;
1260 {
LDIFAIL(
"IOCTL_NTV2_DMA_WRITE_FRAME failed");
return false;}
1294 dmaControlBuf.
linePitch = linePitch == 0 ? 1 : linePitch;
1295 dmaControlBuf.
poll = poll;
1297 static bool bPrintedDownsampleDeprecatedMsg =
false;
1298 if (downSample && !bPrintedDownsampleDeprecatedMsg)
1299 {
LDIWARN(
"downSample is deprecated"); bPrintedDownsampleDeprecatedMsg =
true;}
1302 {
LDIFAIL(
"IOCTL_NTV2_DMA_READ_FRAME failed");
return false;}
1337 if( linePitch == 0 ) linePitch = 1;
1339 dmaControlBuf.
poll = poll;
1341 static bool bPrintedDownsampleDeprecatedMsg =
false;
1342 if (downSample && !bPrintedDownsampleDeprecatedMsg)
1343 {
LDIWARN(
"downSample is deprecated"); bPrintedDownsampleDeprecatedMsg =
true;}
1346 {
LDIFAIL(
"IOCTL_NTV2_DMA_READ_FRAME failed");
return false;}
1350 #endif // !defined(NTV2_DEPRECATE_16_0) 1376 dmaControlBuf.
poll = 0;
1380 #define ERRMSG(s) #s " failed" 1383 if (offsetSrc == 0 && offsetDest == 0)
1394 if (ioctl(
int(
_hDevice), request, &dmaControlBuf))
1395 {
LDIFAIL(errMsg);
return false;}
1425 dmaControlBuf.
poll = 0;
1428 #define ERRMSG(s) #s " failed" 1431 if (offsetSrc == 0 && offsetDest == 0)
1442 if (ioctl(
int(
_hDevice), request, &dmaControlBuf))
1443 {
LDIFAIL(errMsg);
return false;}
AUTOCIRCULATE_TRANSFER_STRUCT acTransfer
ULWord * _pRegisterBaseAddress
NTV2DeviceIDSet NTV2GetSupportedDevices(const NTV2DeviceKinds inKinds=NTV2_DEVICEKIND_ALL)
Returns an NTV2DeviceIDSet of devices supported by the SDK.
Declares the AJADebug class.
virtual UWord GetIndexNumber(void) const
void setDeviceIndexNumber(const UWord num)
ULWord ulVidSegmentCardPitch
virtual bool Close(void)
Closes me, releasing host resources that may have been allocated in a previous Open call...
if(!(riid==IID_IUnknown) &&!(riid==IID_IClassFactory))
NTV2_DriverDebugMessageSet
virtual ULWord GetFrameBufferSize(void) const
virtual bool DmaTransfer(const NTV2DMAEngine inDMAEngine, const bool inIsRead, const ULWord inFrameNumber, ULWord *pFrameBuffer, const ULWord inCardOffsetBytes, const ULWord inTotalByteCount, const bool inSynchronous=(!(0)))
Transfers data between the AJA device and the host. This function will block and not return to the ca...
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
#define NTV2_ASSERT(_expr_)
static AJAStatus StatTimerStop(const uint32_t inKey)
virtual bool IsRemote(void) const
AUTOCIRCULATE_TASK_STRUCT acTask
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
NTV2DeviceID _boardID
My cached device ID.
virtual bool IsOpen(void) const
bool _boardOpened
True if I'm open and connected to the device.
virtual void BumpEventCount(const INTERRUPT_ENUMS eInterruptType)
Atomically increments the event count tally for the given interrupt type.
ULWord64 ullVideoBusAddress
AUTOCIRCULATE_TRANSFER_STATUS_STRUCT acStatus
Declares the AJAFileIO class.
virtual bool ReadRegister(const ULWord inRegNum, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Reads all or part of the 32-bit contents of a specific register (real or virtual) on the AJA device...
enum _INTERRUPT_ENUMS_ INTERRUPT_ENUMS
All new NTV2 structs start with this common header.
INTERRUPT_ENUMS eInterruptType
NTV2_GlobalAudioPlaybackMode
NTV2Crosspoint channelSpec
virtual bool NTV2Message(NTV2_HEADER *pInMessage)
Sends a message to the NTV2 driver (the new, improved, preferred way).
static AJAStatus StatTimerStart(const uint32_t inKey)
std::string NTV2DeviceIDToString(const NTV2DeviceID inValue, const bool inForRetailDisplay=false)
ULWord * _pXena2FlashBaseAddress
NTV2_DriverDebugMessageSet msgSet
struct AUTOCIRCULATE_P2P_STRUCT CHANNEL_P2P_STRUCT
FRAME_STAMP_STRUCT acFrameStamp
bool NTV2DeviceIsDirectAddressable(const NTV2DeviceID inDeviceID)
ULWord * _pFrameBaseAddress
ULWord64 messageBusAddress
INTERRUPT_ENUMS eInterruptType
ULWord ulVidSegmentHostPitch
Declares numerous NTV2 utility functions.
ULWord videoSegmentHostPitch
ULWord * _pCh1FrameBaseAddress
AUTO_CIRC_COMMAND eCommand
Specifies channel or FrameStore 1 (or the first item).
ULWord64 ullMessageBusAddress
#define xHEX0N(__x__, __n__)
virtual bool WaitForInterrupt(const INTERRUPT_ENUMS eInterrupt, const ULWord timeOutMs=68)
#define INVALID_HANDLE_VALUE
NTV2RoutingTable acXena2RoutingTable
std::set< NTV2DeviceID > NTV2DeviceIDSet
A set of NTV2DeviceIDs.
AUTOCIRCULATE_TASK_STRUCT acTask
NTV2Crosspoint channelSpec
NTV2Crosspoint channelSpec
ULWord videoSegmentCardPitch
virtual bool AutoCirculate(AUTOCIRCULATE_DATA &pAutoCircData)
Sends an AutoCirculate command to the NTV2 driver.