17 #define INSTP(_p_) xHEX0N(uint64_t(_p_),16) 18 #define LOGGING_DMA_ANC (AJADebug::IsActive(AJA_DebugUnit_AncGeneric)) 19 #define DMAANCFAIL(__x__) AJA_sERROR (AJA_DebugUnit_AncGeneric, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 20 #define DMAANCWARN(__x__) AJA_sWARNING(AJA_DebugUnit_AncGeneric, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 21 #define DMAANCNOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_AncGeneric, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 22 #define DMAANCINFO(__x__) AJA_sINFO (AJA_DebugUnit_AncGeneric, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 23 #define DMAANCDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_AncGeneric, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 37 return DmaTransfer (
NTV2_DMA_FIRST_AVAILABLE,
false, inFrameNumber, const_cast<ULWord*>(pFrameBuffer), inOffsetBytes, inByteCount,
true);
49 return DMAReadFrame (inFrameNumber, pFrameBuffer, inByteCount);
52 GetFrameBufferSize(inChannel, hwFrameSize);
54 bool quadEnabled(
false), quadQuadEnabled(
false);
55 GetQuadFrameEnable(quadEnabled, inChannel);
56 GetQuadQuadFrameEnable(quadQuadEnabled, inChannel);
61 return DmaTransfer (
NTV2_DMA_FIRST_AVAILABLE,
true, 0, pFrameBuffer, inFrameNumber * actualFrameSize, inByteCount,
true);
73 return DMAWriteFrame (inFrameNumber, pFrameBuffer, inByteCount);
76 GetFrameBufferSize(inChannel, hwFrameSize);
78 bool quadEnabled(
false), quadQuadEnabled(
false);
79 GetQuadFrameEnable(quadEnabled, inChannel);
80 GetQuadQuadFrameEnable(quadQuadEnabled, inChannel);
86 inFrameNumber * actualFrameSize, inByteCount,
true);
92 const ULWord inOffsetBytes,
93 const ULWord inTotalByteCount,
94 const ULWord inNumSegments,
95 const ULWord inSegmentHostPitch,
96 const ULWord inSegmentCardPitch)
99 inNumSegments, inSegmentHostPitch, inSegmentCardPitch,
true);
104 const ULWord * pFrameBuffer,
105 const ULWord inOffsetBytes,
106 const ULWord inTotalByteCount,
107 const ULWord inNumSegments,
108 const ULWord inSegmentHostPitch,
109 const ULWord inSegmentCardPitch)
112 inOffsetBytes, inTotalByteCount, inNumSegments, inSegmentHostPitch, inSegmentCardPitch,
true);
118 return DmaTransfer (
NTV2_PIO, channel,
true, frameNumber, frameOffset, 0, 0, 0, 0, pP2PData);
127 ULWord segmentTargetPitch,
132 segmentTargetPitch, segmentCardPitch, pP2PData);
138 const ULWord inOffsetBytes,
141 if (!pOutAudioBuffer)
146 ULWord absoluteByteOffset (0);
147 if (!GetAudioMemoryOffset (inOffsetBytes, absoluteByteOffset, inAudioSystem))
155 const ULWord * pInAudioBuffer,
156 const ULWord inOffsetBytes,
164 ULWord absoluteByteOffset (0);
165 if (!GetAudioMemoryOffset (inOffsetBytes, absoluteByteOffset, inAudioSystem))
168 return DmaTransfer (
NTV2_DMA_FIRST_AVAILABLE,
false, 0, const_cast <ULWord *> (pInAudioBuffer), absoluteByteOffset, inByteCount,
true);
177 ULWord F1Offset(0), F2Offset(0), inByteCount(0), bytesToTransfer(0), byteOffsetToAncData(0);
188 if (!GetFrameBufferSize (inChannel, hwFrameSize))
192 bool quadEnabled(
false), quadQuadEnabled(
false);
193 GetQuadFrameEnable(quadEnabled, inChannel);
194 GetQuadQuadFrameEnable(quadQuadEnabled, inChannel);
196 frameSizeInBytes *= 4;
198 frameSizeInBytes *= 4;
202 bytesToTransfer = inByteCount > F1Offset ? F1Offset : inByteCount;
205 byteOffsetToAncData = frameSizeInBytes - F1Offset;
208 byteOffsetToAncData, bytesToTransfer,
true);
211 bytesToTransfer = inByteCount > F2Offset ? F2Offset : inByteCount;
212 if (result && bytesToTransfer)
214 byteOffsetToAncData = frameSizeInBytes - F2Offset;
217 byteOffsetToAncData, bytesToTransfer,
true);
223 S2110DeviceAncFromBuffers (inChannel, outAncF1Buffer, outAncF2Buffer);
233 ULWord F1Offset(0), F2Offset(0), inByteCount(0), bytesToTransfer(0), byteOffsetToAncData(0);
244 if (!GetFrameBufferSize (inChannel, hwFrameSize))
248 bool quadEnabled(
false), quadQuadEnabled(
false);
249 GetQuadFrameEnable(quadEnabled, inChannel);
250 GetQuadQuadFrameEnable(quadQuadEnabled, inChannel);
252 frameSizeInBytes *= 4;
254 frameSizeInBytes *= 4;
257 bool tmpLocalRP188F1AncBuffer(
false), tmpLocalRP188F2AncBuffer(
false);
265 if (inAncF1Buffer.
IsNULL())
266 tmpLocalRP188F1AncBuffer = inAncF1Buffer.
Allocate(2048);
267 if (inAncF2Buffer.
IsNULL())
268 tmpLocalRP188F2AncBuffer = inAncF2Buffer.
Allocate(2048);
269 S2110DeviceAncToBuffers (inChannel, inAncF1Buffer, inAncF2Buffer);
274 bytesToTransfer = inByteCount > F1Offset ? F1Offset : inByteCount;
277 byteOffsetToAncData = frameSizeInBytes - F1Offset;
279 inAncF1Buffer, byteOffsetToAncData, bytesToTransfer,
true);
282 bytesToTransfer = inByteCount > F2Offset ? F2Offset : inByteCount;
283 if (result && bytesToTransfer)
285 byteOffsetToAncData = frameSizeInBytes - F2Offset;
287 inAncF2Buffer, byteOffsetToAncData, bytesToTransfer,
true);
290 if (tmpLocalRP188F1AncBuffer) inAncF1Buffer.
Deallocate();
291 if (tmpLocalRP188F2AncBuffer) inAncF2Buffer.
Deallocate();
305 bool quadEnabled(
false), quadQuadEnabled(
false);
309 actualFrameSize *= 4;
311 actualFrameSize *= 4;
313 (inFrameNumber * actualFrameSize) + LUTIndexByteOffset, inByteCount,
true);
318 bool & outMultiFormat,
bool & outQuad,
bool & outQuadQuad,
bool & outSquares,
bool & outTSI,
319 uint64_t & outAddress, uint64_t & outLength)
321 outAddress = outLength = 0;
322 static const ULWord frameSizes[] = {2, 4, 8, 16};
323 UWord frameSizeNdx(0);
324 const bool isMRWidgetChannel(IsMultiRasterWidgetChannel(inChannel));
325 outIntrinsicSize = 0;
326 outMultiFormat = outQuad = outQuadQuad = outSquares = outTSI =
false;
330 else if (GetMultiFormatMode(outMultiFormat) && !outMultiFormat && !isMRWidgetChannel)
334 outIntrinsicSize = frameSizes[frameSizeNdx] * 1024 * 1024;
338 if (GetQuadFrameEnable(outQuad, chan) && outQuad)
340 if (GetQuadQuadFrameEnable(outQuadQuad, chan) && outQuadQuad)
342 outLength = outIntrinsicSize * quadMultiplier;
343 if (quadMultiplier > 1)
345 Get4kSquaresEnable (outSquares, chan);
346 GetTsiFrameEnable(outTSI, chan);
353 bool frameSizeSetBySW(
false);
355 if (!GetQuadFrameEnable(outQuad, chan) || !outQuad)
356 if (frameSizeSetBySW)
357 outLength = outIntrinsicSize;
359 Get4kSquaresEnable (outSquares, chan);
370 outAddress = uint64_t(inFrameNumber) * outLength;
377 bool isMultiFormat(
false), isQuad(
false), isQuadQuad(
false), isSquares(
false), isTSI(
false);
379 return GetDeviceFrameInfo (inFrameNumber, inChannel, intrinsicSize, isMultiFormat, isQuad, isQuadQuad, isSquares, isTSI, outAddr, outLgth);
384 static const ULWord frameSizes[] = {2, 4, 8, 16};
385 UWord frameSizeNdx(0);
386 bool quadEnabled(
false), isMultiFormatMode(
false);
387 uint64_t frameBytes(0);
391 else if (GetMultiFormatMode(isMultiFormatMode) && !isMultiFormatMode)
399 if (GetQuadFrameEnable(quadEnabled, chan) && quadEnabled)
401 if (GetQuadQuadFrameEnable(quadEnabled, chan) && quadEnabled)
403 frameBytes = frameSizes[frameSizeNdx] * 1024 * 1024 * quadMultiplier;
409 bool frameSizeSetBySW(
false);
411 if (!GetQuadFrameEnable(quadEnabled, chan) || !quadEnabled)
412 if (frameSizeSetBySW)
413 frameBytes = frameSizes[frameSizeNdx] * 1024 * 1024;
424 outFrameNumber =
UWord(inAddress / frameBytes);
440 return NTV2Message (reinterpret_cast<NTV2_HEADER*>(&lockMsg));
453 return NTV2Message (reinterpret_cast<NTV2_HEADER*>(&lockMsg));
463 return NTV2Message (reinterpret_cast<NTV2_HEADER*>(&unlockAllMsg));
482 return NTV2Message (reinterpret_cast<NTV2_HEADER*>(&autoMsg));
501 ULWord offsetInBytes(0), sizeInBytes(0);
502 if (!GetAncRegionOffsetAndSize(offsetInBytes, sizeInBytes, inAncRegion))
509 for (
UWord ndx(inStartFrameNumber); ndx < inEndFrameNumber + 1; ndx++)
510 if (!DMAWriteAnc (
ULWord(ndx), zeroBuffer, zeroBuffer, inChannel))
518 outByteOffset = outByteCount = 0;
536 ULWord bytesFromBottom(0);
537 if (GetAncRegionOffsetFromBottom(bytesFromBottom, ancRgn))
539 ancRgnOffsets.insert(
AncRgnOffset(ancRgn, bytesFromBottom));
540 offsetAncRgns.insert(
OffsetAncRgn(bytesFromBottom, ancRgn));
543 if (offsetAncRgns.empty())
550 if (ancRgnOffsetIter != ancRgnOffsets.end())
552 ULWord rgnSize(ancRgnOffsetIter->second);
554 if (offsetAncRgnIter != offsetAncRgns.end())
556 if (offsetAncRgnIter->second != ancRgn)
560 if (offsetAncRgnIter != offsetAncRgns.begin() && --offsetAncRgnIter != offsetAncRgns.end())
561 rgnSize -= offsetAncRgnIter->first;
562 ancRgnSizes.insert(
AncRgnSize(ancRgn, rgnSize));
575 if (rIter == offsetAncRgns.rend())
577 offsetFromEnd = rIter->first;
578 outByteOffset = frameSizeInBytes - offsetFromEnd;
579 outByteCount = offsetFromEnd;
584 if (offIter == ancRgnOffsets.end())
587 offsetFromEnd = offIter->second;
588 if (offsetFromEnd > frameSizeInBytes)
592 if (sizeIter == ancRgnSizes.end())
595 outByteOffset = frameSizeInBytes - offsetFromEnd;
596 outByteCount = sizeIter->second;
597 return outByteOffset && outByteCount;
609 UWord majV(0), minV(0), pt(0), bld(0);
610 GetDriverVersionComponents(majV, minV, pt, bld);
611 const bool is153OrLater ((majV > 15) || (majV == 15 && minV >= 3) || (!majV && !minV && !pt && !bld));
615 default:
return false;
626 bytesFromBottom = temp;
628 bytesFromBottom = temp;
634 bytesFromBottom = temp;
636 bytesFromBottom = temp;
638 return bytesFromBottom > 0;
Anc Field2 byte offset from end of frame buffer (GUMP on all boards except RTP for SMPTE2022/IP) ...
virtual bool DmaP2PTargetFrame(NTV2Channel channel, ULWord frameNumber, ULWord frameOffset, PCHANNEL_P2P_STRUCT pP2PData)
DirectGMA p2p transfers (not GPUDirect: see DMABufferLock)
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information...
OffsetAncRgns::const_reverse_iterator OffsetAncRgnsConstRIter
bool Allocate(const size_t inByteCount, const bool inPageAligned=false)
Allocates (or re-allocates) my user-space storage using the given byte count. I assume full responsib...
#define DMABUFFERLOCK_MANUAL
Used in NTV2BufferLock to manual page lock buffers.
OffsetAncRgns::const_iterator OffsetAncRgnsConstIter
NTV2FrameBufferFormat
Identifies a particular video frame buffer pixel format. See Device Frame Buffer Formats for details...
virtual bool DMAWrite(const ULWord inFrameNumber, const ULWord *pFrameBuffer, const ULWord inOffsetBytes, const ULWord inByteCount)
Transfers data from the host to the AJA device.
#define DMABUFFERLOCK_LOCK
Used in NTV2BufferLock to page lock a buffer.
virtual bool DMARead(const ULWord inFrameNumber, ULWord *pFrameBuffer, const ULWord inOffsetBytes, const ULWord inByteCount)
Transfers data from the AJA device to the host.
Declares the AJADebug class.
pair< NTV2AncDataRgn, ULWord > AncRgnOffset
map< ULWord, NTV2AncDataRgn > OffsetAncRgns
#define DMABUFFERLOCK_UNLOCK_ALL
Used in NTV2BufferLock to unlock all locked buffers.
pair< ULWord, NTV2AncDataRgn > OffsetAncRgn
Identifies the "monitor" or "auxiliary" Field 2 ancillary data region.
void SetMaxLockSize(const ULWord64 inNumBytes)
Sets the maximum lock size for use in a subsequent call to CNTV2Card::DMABufferLock.
#define DMABUFFERLOCK_RDMA
Used in NTV2BufferLock to page lock a rdma buffer.
std::string NTV2AncDataRgnToStr(const NTV2AncDataRgn inValue, const bool inCompactDisplay=false)
ULWord GetByteCount(void) const
virtual bool DMAWriteFrame(const ULWord inFrameNumber, const ULWord *pInFrameBuffer, const ULWord inByteCount)
Transfers a single frame from the host to the AJA device.
map< NTV2AncDataRgn, ULWord > AncRgnSizes
#define DMABUFFERLOCK_MAP
Used in NTV2BufferLock to IO map a buffer.
virtual bool DMAReadSegments(const ULWord inFrameNumber, ULWord *pFrameBuffer, const ULWord inCardOffsetBytes, const ULWord inSegmentByteCount, const ULWord inNumSegments, const ULWord inSegmentHostPitch, const ULWord inSegmentCardPitch)
Performs a segmented data transfer from the AJA device to the host.
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
virtual bool GetAncRegionOffsetFromBottom(ULWord &outByteOffsetFromBottom, const NTV2AncillaryDataRegion inAncRegion=NTV2_AncRgn_All)
Answers with the byte offset to the start of an ancillary data region within a device frame buffer...
virtual bool DMAReadAnc(const ULWord inFrameNumber, NTV2Buffer &outAncF1Buffer, NTV2Buffer &outAncF2Buffer=NULL_POINTER, const NTV2Channel inChannel=NTV2_CHANNEL1)
Transfers the contents of the ancillary data buffer(s) from a given frame on the AJA device to the ho...
bool NTV2DeviceSoftwareCanChangeFrameBufferSize(const NTV2DeviceID inDeviceID)
Anc Field1 byte offset from end of frame buffer (GUMP on all boards except RTP for SMPTE2022/IP) ...
#define NTV2_IS_VALID_ANC_RGN(_x_)
virtual bool DMAWriteAudio(const NTV2AudioSystem inAudioSystem, const ULWord *pInAudioBuffer, const ULWord inOffsetBytes, const ULWord inByteCount)
Synchronously transfers audio data from the specified host buffer to the given Audio System's buffer ...
bool Fill(const T &inValue)
Fills me with the given scalar value.
bool Deallocate(void)
Deallocates my user-space storage (if I own it – i.e. from a prior call to Allocate).
virtual bool DMAClearAncRegion(const UWord inStartFrameNumber, const UWord inEndFrameNumber, const NTV2AncillaryDataRegion inAncRegion=NTV2_AncRgn_All, const NTV2Channel inChannel=NTV2_CHANNEL1)
Clears the ancillary data region in the device frame buffer for the specified frames.
virtual bool DMABufferUnlock(const NTV2Buffer &inBuffer)
Unlocks the given host buffer that was previously locked using CNTV2Card::DMABufferLock.
Monitor Anc Field2 byte offset from end of frame buffer (IoIP only, GUMP)
Identifies "all" ancillary data regions.
void SetFlags(const ULWord inFlags)
Sets the action flags for use in a subsequent call to CNTV2Card::DMABufferLock.
virtual bool DMABufferLock(const NTV2Buffer &inBuffer, bool inMap=(0), bool inRDMA=(0))
Page-locks the given host buffer to reduce transfer time and CPU usage of DMA transfers.
enum NTV2AncillaryDataRegion NTV2AncDataRgn
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 NTV2FramesizeToByteCount(const NTV2Framesize inFrameSize)
Converts the given NTV2Framesize value into an exact byte count.
virtual bool DMAWriteAnc(const ULWord inFrameNumber, NTV2Buffer &inAncF1Buffer, NTV2Buffer &inAncF2Buffer=NULL_POINTER, const NTV2Channel inChannel=NTV2_CHANNEL1)
Transfers the contents of the ancillary data buffer(s) from the host to a given frame on the AJA devi...
virtual bool DMAWriteSegments(const ULWord inFrameNumber, const ULWord *pFrameBuffer, const ULWord inOffsetBytes, const ULWord inSegmentByteCount, const ULWord inNumSegments, const ULWord inSegmentHostPitch, const ULWord inSegmentCardPitch)
Performs a segmented data transfer from the host to the AJA device.
map< NTV2AncDataRgn, ULWord > AncRgnOffsets
virtual bool GetDeviceFrameInfo(const UWord inFrameNumber, const NTV2Channel inChannel, uint64_t &outAddress, uint64_t &outLength)
Answers with the address and size of the given frame.
virtual bool DMABufferUnlockAll()
Unlocks all previously-locked buffers used for DMA transfers.
virtual bool GetAncRegionOffsetAndSize(ULWord &outByteOffset, ULWord &outByteCount, const NTV2AncillaryDataRegion inAncRegion=NTV2_AncRgn_All)
Answers with the offset and size of an ancillary data region within a device frame buffer...
True if device can report its frame size.
This is used to prelock a video/audio/anc buffer used as the source or target of DMA transfers...
NTV2Framesize
Kona2/Xena2 specific enums.
#define NTV2_IS_VALID_CHANNEL(__x__)
Describes a user-space buffer on the host computer. I have an address and a length, plus some optional attributes (allocated by SDK?, page-aligned? etc.).
#define DMAANCWARN(__x__)
Monitor Anc Field1 byte offset from end of frame buffer (IoIP only, GUMP)
const ULWord LUTTablePartitionSize
NTV2FrameGeometry
Identifies a particular video frame geometry.
Declares numerous NTV2 utility functions.
Identifies the "normal" Field 2 ancillary data region.
True if device supports SMPTE ST2110.
virtual bool DMAReadAudio(const NTV2AudioSystem inAudioSystem, ULWord *pOutAudioBuffer, const ULWord inOffsetBytes, const ULWord inByteCount)
Synchronously transfers audio data from a given Audio System's buffer memory on the AJA device to the...
True if device has SDI ANC inserter/extractor firmware.
AncRgnSizes::const_iterator AncRgnSizesConstIter
Specifies channel or FrameStore 1 (or the first item).
NTV2AncillaryDataRegion
These enumerations identify the various ancillary data regions located at the bottom of each frame bu...
#define xHEX0N(__x__, __n__)
virtual bool DMABufferAutoLock(const bool inEnable, const bool inMap=(0), const ULWord64 inMaxLockSize=0)
Enables or disables automatic buffer locking.
virtual bool DMAWriteLUTTable(const ULWord inFrameNumber, const ULWord *pInLUTBuffer, const ULWord inLUTIndex, const ULWord inByteCount=LUTTablePartitionSize)
Synchronously transfers LUT data from the specified host buffer to the given buffer memory on the AJA...
#define NTV2_IS_ALL_ANC_RGNS(_x_)
#define DMABUFFERLOCK_UNLOCK
Used in NTV2BufferLock to unlock a buffer.
#define DMABUFFERLOCK_MAX_SIZE
Used in NTV2BufferLock to set max locked size.
Declares the CNTV2Card class.
Identifies the "monitor" or "auxiliary" Field 1 ancillary data region.
virtual bool DmaP2PTransferFrame(NTV2DMAEngine DMAEngine, ULWord frameNumber, ULWord frameOffset, ULWord transferSize, ULWord numSegments, ULWord segmentTargetPitch, ULWord segmentCardPitch, PCHANNEL_P2P_STRUCT pP2PData)
map< ULWord, NTV2AncDataRgn > SizeAncRgns
ULWord NTV2DeviceGetFrameBufferSize(NTV2DeviceID id, NTV2FrameGeometry fg, NTV2FrameBufferFormat fbf)
#define DMABUFFERLOCK_AUTO
Used in NTV2BufferLock to auto page lock buffers.
virtual bool DMAReadFrame(const ULWord inFrameNumber, ULWord *pOutFrameBuffer, const ULWord inByteCount)
Transfers a single frame from the AJA device to the host.
virtual bool DeviceAddressToFrameNumber(const uint64_t inAddress, UWord &outFrameNumber, const NTV2Channel inChannel=NTV2_CHANNEL1)
Answers with the frame number that contains the given address.
void * GetHostPointer(void) const
pair< ULWord, NTV2AncDataRgn > SizeAncRgn
Identifies the "normal" Field 1 ancillary data region.
AncRgnOffsets::const_iterator AncRgnOffsetsConstIter
Declares device capability functions.
pair< NTV2AncDataRgn, ULWord > AncRgnSize
True if device can simultaneously handle different video formats on more than one SDI input or output...