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__)
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);
145 return NTV2Message (
reinterpret_cast<NTV2_HEADER*
>(&streamMsg));
155 return NTV2Message (
reinterpret_cast<NTV2_HEADER*
>(&streamMsg));
162 outAbsByteOffset = 0;
169 const ULWord EIGHT_MEGABYTES (0x800000);
171 const ULWord engineOffset (memSize - EIGHT_MEGABYTES *
ULWord(inAudioSystem+1));
172 outAbsByteOffset = inOffsetBytes + engineOffset;
178 if (!GetFrameGeometry (fg,
NTV2Channel(inAudioSystem)) || !GetFrameBufferFormat (
NTV2Channel(inAudioSystem), fbf))
186 {
ULWord rdBufOffset(0x400000);
187 GetAudioReadOffset (rdBufOffset, inAudioSystem);
188 outAbsByteOffset += rdBufOffset;
196 const ULWord inOffsetBytes,
199 if (!pOutAudioBuffer)
204 ULWord absoluteByteOffset (0);
205 if (!GetAudioMemoryOffset (inOffsetBytes, absoluteByteOffset, inAudioSystem))
213 const ULWord * pInAudioBuffer,
214 const ULWord inOffsetBytes,
222 ULWord absoluteByteOffset (0);
223 if (!GetAudioMemoryOffset (inOffsetBytes, absoluteByteOffset, inAudioSystem))
235 ULWord F1Offset(0), F2Offset(0), inByteCount(0), bytesToTransfer(0), byteOffsetToAncData(0);
246 if (!GetFrameBufferSize (inChannel, hwFrameSize))
250 bool quadEnabled(
false), quadQuadEnabled(
false);
251 GetQuadFrameEnable(quadEnabled, inChannel);
252 GetQuadQuadFrameEnable(quadQuadEnabled, inChannel);
254 frameSizeInBytes *= 4;
256 frameSizeInBytes *= 4;
260 bytesToTransfer = inByteCount > F1Offset ? F1Offset : inByteCount;
263 byteOffsetToAncData = frameSizeInBytes - F1Offset;
266 byteOffsetToAncData, bytesToTransfer,
true);
269 bytesToTransfer = inByteCount > F2Offset ? F2Offset : inByteCount;
270 if (result && bytesToTransfer)
272 byteOffsetToAncData = frameSizeInBytes - F2Offset;
275 byteOffsetToAncData, bytesToTransfer,
true);
281 S2110DeviceAncFromBuffers (inChannel, outAncF1Buffer, outAncF2Buffer);
291 ULWord F1Offset(0), F2Offset(0), inByteCount(0), bytesToTransfer(0), byteOffsetToAncData(0);
302 if (!GetFrameBufferSize (inChannel, hwFrameSize))
306 bool quadEnabled(
false), quadQuadEnabled(
false);
307 GetQuadFrameEnable(quadEnabled, inChannel);
308 GetQuadQuadFrameEnable(quadQuadEnabled, inChannel);
310 frameSizeInBytes *= 4;
312 frameSizeInBytes *= 4;
315 bool tmpLocalRP188F1AncBuffer(
false), tmpLocalRP188F2AncBuffer(
false);
323 if (inAncF1Buffer.
IsNULL())
324 tmpLocalRP188F1AncBuffer = inAncF1Buffer.
Allocate(2048);
325 if (inAncF2Buffer.
IsNULL())
326 tmpLocalRP188F2AncBuffer = inAncF2Buffer.
Allocate(2048);
327 S2110DeviceAncToBuffers (inChannel, inAncF1Buffer, inAncF2Buffer);
332 bytesToTransfer = inByteCount > F1Offset ? F1Offset : inByteCount;
335 byteOffsetToAncData = frameSizeInBytes - F1Offset;
337 inAncF1Buffer, byteOffsetToAncData, bytesToTransfer,
true);
340 bytesToTransfer = inByteCount > F2Offset ? F2Offset : inByteCount;
341 if (result && bytesToTransfer)
343 byteOffsetToAncData = frameSizeInBytes - F2Offset;
345 inAncF2Buffer, byteOffsetToAncData, bytesToTransfer,
true);
348 if (tmpLocalRP188F1AncBuffer) inAncF1Buffer.
Deallocate();
349 if (tmpLocalRP188F2AncBuffer) inAncF2Buffer.
Deallocate();
363 bool quadEnabled(
false), quadQuadEnabled(
false);
367 actualFrameSize *= 4;
369 actualFrameSize *= 4;
371 (inFrameNumber * actualFrameSize) + LUTIndexByteOffset, inByteCount,
true);
376 bool & outMultiFormat,
bool & outQuad,
bool & outQuadQuad,
bool & outSquares,
bool & outTSI,
377 uint64_t & outAddress, uint64_t & outLength)
379 outAddress = outLength = 0;
380 static const ULWord frameSizes[] = {2, 4, 8, 16};
381 UWord frameSizeNdx(0);
382 const bool isMRWidgetChannel(IsMultiRasterWidgetChannel(inChannel));
383 outIntrinsicSize = 0;
384 outMultiFormat = outQuad = outQuadQuad = outSquares = outTSI =
false;
388 else if (GetMultiFormatMode(outMultiFormat) && !outMultiFormat && !isMRWidgetChannel)
392 outIntrinsicSize = frameSizes[frameSizeNdx] * 1024 * 1024;
396 if (GetQuadFrameEnable(outQuad, chan) && outQuad)
398 if (GetQuadQuadFrameEnable(outQuadQuad, chan) && outQuadQuad)
400 outLength = outIntrinsicSize * quadMultiplier;
401 if (quadMultiplier > 1)
403 Get4kSquaresEnable (outSquares, chan);
404 GetTsiFrameEnable(outTSI, chan);
411 bool frameSizeSetBySW(
false);
413 if (!GetQuadFrameEnable(outQuad, chan) || !outQuad)
414 if (frameSizeSetBySW)
415 outLength = outIntrinsicSize;
417 Get4kSquaresEnable (outSquares, chan);
428 outAddress = uint64_t(inFrameNumber) * outLength;
435 bool isMultiFormat(
false), isQuad(
false), isQuadQuad(
false), isSquares(
false), isTSI(
false);
437 return GetDeviceFrameInfo (inFrameNumber, inChannel, intrinsicSize, isMultiFormat, isQuad, isQuadQuad, isSquares, isTSI, outAddr, outLgth);
442 static const ULWord frameSizes[] = {2, 4, 8, 16};
443 UWord frameSizeNdx(0);
444 bool quadEnabled(
false), isMultiFormatMode(
false);
445 uint64_t frameBytes(0);
449 else if (GetMultiFormatMode(isMultiFormatMode) && !isMultiFormatMode)
457 if (GetQuadFrameEnable(quadEnabled, chan) && quadEnabled)
459 if (GetQuadQuadFrameEnable(quadEnabled, chan) && quadEnabled)
461 frameBytes = frameSizes[frameSizeNdx] * 1024 * 1024 * quadMultiplier;
467 bool frameSizeSetBySW(
false);
469 if (!GetQuadFrameEnable(quadEnabled, chan) || !quadEnabled)
470 if (frameSizeSetBySW)
471 frameBytes = frameSizes[frameSizeNdx] * 1024 * 1024;
482 outFrameNumber =
UWord(inAddress / frameBytes);
498 return NTV2Message (
reinterpret_cast<NTV2_HEADER*
>(&lockMsg));
511 return NTV2Message (
reinterpret_cast<NTV2_HEADER*
>(&lockMsg));
521 return NTV2Message (
reinterpret_cast<NTV2_HEADER*
>(&unlockAllMsg));
540 return NTV2Message (
reinterpret_cast<NTV2_HEADER*
>(&autoMsg));
559 ULWord offsetInBytes(0), sizeInBytes(0);
560 if (!GetAncRegionOffsetAndSize(offsetInBytes, sizeInBytes, inAncRegion))
567 for (
UWord ndx(inStartFrameNumber); ndx < inEndFrameNumber + 1; ndx++)
568 if (!DMAWriteAnc (
ULWord(ndx), zeroBuffer, zeroBuffer, inChannel))
576 outByteOffset = outByteCount = 0;
594 ULWord bytesFromBottom(0);
595 if (GetAncRegionOffsetFromBottom(bytesFromBottom, ancRgn))
597 ancRgnOffsets.insert(
AncRgnOffset(ancRgn, bytesFromBottom));
598 offsetAncRgns.insert(
OffsetAncRgn(bytesFromBottom, ancRgn));
601 if (offsetAncRgns.empty())
608 if (ancRgnOffsetIter != ancRgnOffsets.end())
610 ULWord rgnSize(ancRgnOffsetIter->second);
612 if (offsetAncRgnIter != offsetAncRgns.end())
614 if (offsetAncRgnIter->second != ancRgn)
618 if (offsetAncRgnIter != offsetAncRgns.begin() && --offsetAncRgnIter != offsetAncRgns.end())
619 rgnSize -= offsetAncRgnIter->first;
620 ancRgnSizes.insert(
AncRgnSize(ancRgn, rgnSize));
633 if (rIter == offsetAncRgns.rend())
635 offsetFromEnd = rIter->first;
636 outByteOffset = frameSizeInBytes - offsetFromEnd;
637 outByteCount = offsetFromEnd;
642 if (offIter == ancRgnOffsets.end())
645 offsetFromEnd = offIter->second;
646 if (offsetFromEnd > frameSizeInBytes)
650 if (sizeIter == ancRgnSizes.end())
653 outByteOffset = frameSizeInBytes - offsetFromEnd;
654 outByteCount = sizeIter->second;
655 return outByteOffset && outByteCount;
667 UWord majV(0), minV(0), pt(0), bld(0);
668 GetDriverVersionComponents(majV, minV, pt, bld);
669 const bool is153OrLater ((majV > 15) || (majV == 15 && minV >= 3) || (!majV && !minV && !pt && !bld));
673 default:
return false;
684 bytesFromBottom = temp;
686 bytesFromBottom = temp;
692 bytesFromBottom = temp;
694 bytesFromBottom = temp;
696 return bytesFromBottom > 0;