|
AJA NTV2 SDK
17.1.3.1410
NTV2 SDK 17.1.3.1410
|
Go to the documentation of this file.
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;}
1107 {
LDIFAIL(
"IOCTL_AJANTV2_MESSAGE failed");
return false;}
1113 #if !defined(NTV2_DEPRECATE_16_0)
1132 ULWord numDmaDriverBuffers;
1135 LDIFAIL(
"GetDMANumDriverBuffers() failed");
1139 if (!numDmaDriverBuffers)
1141 LDIFAIL(
"numDmaDriverBuffers == 0");
1149 PROT_READ | PROT_WRITE,MAP_SHARED,
1180 ULWord numDmaDriverBuffers;
1183 LDIFAIL(
"GetDMANumDriverBuffers() failed");
1186 if (!numDmaDriverBuffers)
1189 LDIFAIL(
"numDmaDriverBuffers == 0");
1198 #endif // !defined(NTV2_DEPRECATE_16_0)
1210 #if !defined(NTV2_DEPRECATE_16_0)
1240 dmaControlBuf.
poll = poll;
1242 {
LDIFAIL(
"IOCTL_NTV2_DMA_WRITE_FRAME failed");
return false;}
1276 dmaControlBuf.
poll = poll;
1278 {
LDIFAIL(
"IOCTL_NTV2_DMA_WRITE_FRAME failed");
return false;}
1312 dmaControlBuf.
linePitch = linePitch == 0 ? 1 : linePitch;
1313 dmaControlBuf.
poll = poll;
1315 static bool bPrintedDownsampleDeprecatedMsg =
false;
1316 if (downSample && !bPrintedDownsampleDeprecatedMsg)
1317 {
LDIWARN(
"downSample is deprecated"); bPrintedDownsampleDeprecatedMsg =
true;}
1320 {
LDIFAIL(
"IOCTL_NTV2_DMA_READ_FRAME failed");
return false;}
1355 if( linePitch == 0 ) linePitch = 1;
1357 dmaControlBuf.
poll = poll;
1359 static bool bPrintedDownsampleDeprecatedMsg =
false;
1360 if (downSample && !bPrintedDownsampleDeprecatedMsg)
1361 {
LDIWARN(
"downSample is deprecated"); bPrintedDownsampleDeprecatedMsg =
true;}
1364 {
LDIFAIL(
"IOCTL_NTV2_DMA_READ_FRAME failed");
return false;}
1368 #endif // !defined(NTV2_DEPRECATE_16_0)
1394 dmaControlBuf.
poll = 0;
1398 #define ERRMSG(s) #s " failed"
1401 if (offsetSrc == 0 && offsetDest == 0)
1412 if (ioctl(
int(
_hDevice), request, &dmaControlBuf))
1413 {
LDIFAIL(errMsg);
return false;}
1443 dmaControlBuf.
poll = 0;
1446 #define ERRMSG(s) #s " failed"
1449 if (offsetSrc == 0 && offsetDest == 0)
1460 if (ioctl(
int(
_hDevice), request, &dmaControlBuf))
1461 {
LDIFAIL(errMsg);
return false;}
@ AJA_DebugStat_GetInterruptCount
@ AJA_DebugStat_DMATransferEx
static AJAStatus StatTimerStop(const uint32_t inKey)
NTV2Crosspoint channelSpec
NTV2Crosspoint channelSpec
INTERRUPT_ENUMS eInterruptType
enum _INTERRUPT_ENUMS_ INTERRUPT_ENUMS
INTERRUPT_ENUMS eInterruptType
NTV2_DriverDebugMessageSet
ULWord * _pXena2FlashBaseAddress
@ AJA_DebugStat_HEVCSendMessage
NTV2DeviceIDSet NTV2GetSupportedDevices(const NTV2DeviceKinds inKinds=NTV2_DEVICEKIND_ALL)
Returns an NTV2DeviceIDSet of devices supported by the SDK.
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
bool _boardOpened
True if I'm open and connected to the device.
ULWord64 ullVideoBusAddress
@ AJA_DebugStat_NTV2Message
static AJAStatus StatTimerStart(const uint32_t inKey)
#define NTV2_ASSERT(_expr_)
@ AJA_DebugStat_AutoCirculate
@ AJA_DebugStat_WaitForInterruptOthers
virtual bool WaitForInterrupt(const INTERRUPT_ENUMS eInterrupt, const ULWord timeOutMs=68)
@ AJA_DebugStat_WaitForInterruptIn2
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
UWord _boardNumber
My device index number.
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
@ kVRegGlobalAudioPlaybackMode
NTV2DeviceID _boardID
My cached device ID.
@ AJA_DebugStat_WaitForInterruptIn8
NTV2_DriverDebugMessageSet msgSet
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....
ULWord videoSegmentHostPitch
@ AJA_DebugStat_DMATransferP2P
NTV2_GlobalAudioPlaybackMode
AUTOCIRCULATE_TASK_STRUCT acTask
ULWord ulVidSegmentCardPitch
AUTO_CIRC_COMMAND eCommand
struct AUTOCIRCULATE_P2P_STRUCT CHANNEL_P2P_STRUCT
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...
@ AJA_DebugStat_WaitForInterruptUartTx1
ULWord64 messageBusAddress
ULWord ulVidSegmentHostPitch
@ AJA_DebugStat_AutoCirculateXfer
std::string NTV2DeviceIDToString(const NTV2DeviceID inValue, const bool inForRetailDisplay=false)
@ kVRegNumDmaDriverBuffers
@ AJA_DebugStat_WaitForInterruptUartTx2
All new NTV2 structs start with this common header.
ULWord videoSegmentCardPitch
Declares numerous NTV2 utility functions.
ULWord64 ullMessageBusAddress
@ eTransferAutoCirculateEx
bool NTV2DeviceIsDirectAddressable(const NTV2DeviceID inDeviceID)
AUTOCIRCULATE_TRANSFER_STATUS_STRUCT acStatus
@ AJA_DebugStat_WaitForInterruptUartRx2
Declares the AJAFileIO class.
@ AJA_DebugStat_WaitForInterruptIn7
@ AJA_DebugStat_WaitForInterruptIn6
@ AJA_DebugStat_WaitForInterruptUartRx1
FRAME_STAMP_STRUCT acFrameStamp
@ kVRegDMADriverBufferPhysicalAddress
@ AJA_DebugStat_WaitForInterruptOut1
NTV2Crosspoint channelSpec
ULWord * _pCh1FrameBaseAddress
virtual ULWord GetFrameBufferSize(void) const
std::set< NTV2DeviceID > NTV2DeviceIDSet
A set of NTV2DeviceIDs.
@ AJA_DebugStat_DMATransfer
NTV2RoutingTable acXena2RoutingTable
virtual bool AutoCirculate(AUTOCIRCULATE_DATA &pAutoCircData)
Sends an AutoCirculate command to the NTV2 driver.
ULWord * _pRegisterBaseAddress
@ eTransferAutoCirculateEx2
#define xHEX0N(__x__, __n__)
virtual void BumpEventCount(const INTERRUPT_ENUMS eInterruptType)
Atomically increments the event count tally for the given interrupt type.
@ AJA_DebugStat_WaitForInterruptIn1
@ AJA_DebugStat_WaitForInterruptIn3
#define INVALID_HANDLE_VALUE
virtual bool NTV2Message(NTV2_HEADER *pInMessage)
Sends a message to the NTV2 driver (the new, improved, preferred way).
@ AJA_DebugStat_WaitForInterruptIn4
ULWord * _pFrameBaseAddress
AUTOCIRCULATE_TASK_STRUCT acTask
virtual bool Close(void)
Closes me, releasing host resources that may have been allocated in a previous Open call.
Declares the AJADebug class.
AUTOCIRCULATE_TRANSFER_STRUCT acTransfer
@ AJA_DebugStat_WaitForInterruptIn5