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);
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))
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;