AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
ntv2baremetaldriverinterface.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
7 #ifndef NTV2BAREMETALDRIVERINTERFACE_H
8 #define NTV2BAREMETALDRIVERINTERFACE_H
9 
10 #include "ntv2driverinterface.h"
11 #include <assert.h>
12 #include <stdio.h>
13 #include <string.h>
14 #include <string>
15 
16 #define CopyMemory(a,b,c) memcpy((a),(b),(c))
17 
18 // oem dma: save locked pages in a stl::vector
19 #include <vector>
20 typedef std::vector<ULWord *> DMA_LOCKED_VEC;
21 
26 {
27  public:
30 
31  AJA_VIRTUAL bool WriteRegister (const ULWord inRegNum, const ULWord inValue, const ULWord inMask = 0xFFFFFFFF, const ULWord inShift = 0);
32  AJA_VIRTUAL bool ReadRegister (const ULWord inRegNum, ULWord & outValue, const ULWord inMask = 0xFFFFFFFF, const ULWord inShift = 0);
33 #if !defined(NTV2_DEPRECATE_14_3)
34  AJA_VIRTUAL inline NTV2_DEPRECATED_f(bool ReadRegister (const ULWord inRegNum, ULWord * pOutValue, const ULWord inRegMask = 0xFFFFFFFF, const ULWord inRegShift = 0x0))
35  {return pOutValue && ReadRegister(inRegNum, *pOutValue, inRegMask, inRegShift);}
36 #endif // !defined(NTV2_DEPRECATE_14_3)
37 
39 
40  AJA_VIRTUAL bool DmaTransfer (const NTV2DMAEngine inDMAEngine,
41  const bool inIsRead,
42  const ULWord inFrameNumber,
43  ULWord * pFrameBuffer,
44  const ULWord inCardOffsetBytes,
45  const ULWord inTotalByteCount,
46  const bool inSynchronous = true);
47 
48  AJA_VIRTUAL bool DmaTransfer (const NTV2DMAEngine inDMAEngine,
49  const bool inIsRead,
50  const ULWord inFrameNumber,
51  ULWord * pFrameBuffer,
52  const ULWord inCardOffsetBytes,
53  const ULWord inTotalByteCount,
54  const ULWord inNumSegments,
55  const ULWord inHostPitchPerSeg,
56  const ULWord inCardPitchPerSeg,
57  const bool inSynchronous = true);
58 
59  AJA_VIRTUAL bool DmaTransfer (const NTV2DMAEngine inDMAEngine,
60  const NTV2Channel inDMAChannel,
61  const bool inTarget,
62  const ULWord inFrameNumber,
63  const ULWord inCardOffsetBytes,
64  const ULWord inByteCount,
65  const ULWord inNumSegments,
66  const ULWord inSegmentHostPitch,
67  const ULWord inSegmentCardPitch,
68  const PCHANNEL_P2P_STRUCT & inP2PData);
69 
70  AJA_VIRTUAL bool ConfigureSubscription (const bool bSubscribe, const INTERRUPT_ENUMS eInterruptType, PULWord & hSubcription)
71  {(void)bSubscribe; (void)eInterruptType; (void)hSubcription; return true;}
72  AJA_VIRTUAL bool ConfigureInterrupt (const bool bEnable, const INTERRUPT_ENUMS eInterruptType);
73  AJA_VIRTUAL bool GetInterruptCount (const INTERRUPT_ENUMS eInterrupt, ULWord & outCount);
74  AJA_VIRTUAL bool WaitForInterrupt (INTERRUPT_ENUMS eInterrupt, ULWord timeOutMs = 68); // default of 68 ms timeout is enough time for 2K at 14.98 HZ
75 
76  AJA_VIRTUAL bool AutoCirculate (AUTOCIRCULATE_DATA &autoCircData);
77  AJA_VIRTUAL bool NTV2Message (NTV2_HEADER * pInOutMessage);
79  bool enable);
81 
82  AJA_VIRTUAL bool SetupBoard(void);
83 
84  // User allocated buffer methods. Not as fast as driverbuffer methods, but no kernel patch required.
85  AJA_VIRTUAL bool DmaWriteWithOffsets (NTV2DMAEngine DMAEngine, ULWord frameNumber, ULWord * pFrameBuffer,
86  ULWord offsetSrc, ULWord offsetDest, ULWord bytes);
87  AJA_VIRTUAL bool DmaReadWithOffsets (NTV2DMAEngine DMAEngine, ULWord frameNumber, ULWord * pFrameBuffer,
88  ULWord offsetSrc, ULWord offsetDest, ULWord bytes);
89 
90 public:
91 #if !defined(NTV2_DEPRECATE_13_0)
92  AJA_VIRTUAL NTV2_DEPRECATED_f(bool SetRelativeVideoPlaybackDelay (ULWord frmDelay)) {(void)frmDelay; return false;}
93  AJA_VIRTUAL NTV2_DEPRECATED_f(bool GetRelativeVideoPlaybackDelay (ULWord* frmDelay)){(void)frmDelay; return false;}
94  AJA_VIRTUAL NTV2_DEPRECATED_f(bool SetAudioPlaybackPinDelay (ULWord msDelay)) {(void)msDelay; return false;}
95  AJA_VIRTUAL NTV2_DEPRECATED_f(bool GetAudioPlaybackPinDelay (ULWord* msDelay)) {(void)msDelay; return false;}
96  AJA_VIRTUAL NTV2_DEPRECATED_f(bool SetAudioRecordPinDelay (ULWord msDelay)) {(void)msDelay; return false;}
97  AJA_VIRTUAL NTV2_DEPRECATED_f(bool GetAudioRecordPinDelay (ULWord* msDelay)) {(void)msDelay; return false;}
98 #endif // !defined(NTV2_DEPRECATE_13_0)
99 #if !defined(NTV2_DEPRECATE_16_0)
100  AJA_VIRTUAL inline NTV2_SHOULD_BE_DEPRECATED(bool GetStreamingApplication(ULWord & outAppType, int32_t & outPID)) {return CNTV2DriverInterface::GetStreamingApplication(outAppType,outPID);}
101  AJA_VIRTUAL inline NTV2_SHOULD_BE_DEPRECATED(bool GetStreamingApplication(ULWord * pAppType, int32_t * pPID)) {return pAppType && pPID ? CNTV2DriverInterface::GetStreamingApplication(*pAppType,*pPID) : false;}
114  // Driver allocated buffer (DMA performance enhancement, requires bigphysarea patch to kernel)
117 
118  AJA_VIRTUAL NTV2_SHOULD_BE_DEPRECATED(bool DmaReadFrameDriverBuffer (NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame,
119  ULWord bytes, ULWord downSample, ULWord linePitch, ULWord poll));
120 
121  AJA_VIRTUAL NTV2_SHOULD_BE_DEPRECATED(bool DmaReadFrameDriverBuffer (NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame,
122  ULWord offsetSrc, ULWord offsetDest, ULWord bytes,
123  ULWord downSample, ULWord linePitch, ULWord poll));
124 
125  AJA_VIRTUAL NTV2_SHOULD_BE_DEPRECATED(bool DmaWriteFrameDriverBuffer (NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame,
126  ULWord bytes, ULWord poll));
127  AJA_VIRTUAL NTV2_SHOULD_BE_DEPRECATED(bool DmaWriteFrameDriverBuffer (NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame,
128  ULWord offsetSrc, ULWord offsetDest, ULWord bytes, ULWord poll));
132 #endif // defined(NTV2_DRIVER_ALLOCATED_BUFFERS)
135 
136 #if !defined(NTV2_NULL_DEVICE)
137 protected: // PRIVATE METHODS
138  AJA_VIRTUAL bool OpenLocalPhysical (const UWord inDeviceIndex);
139  AJA_VIRTUAL bool CloseLocalPhysical (void);
140 #endif // !defined(NTV2_NULL_DEVICE)
141 
142 protected: // INSTANCE DATA
143  std::string _bitfileDirectory;
145 #if !defined(NTV2_DEPRECATE_16_0)
150  ULWord _BA4MemorySize; // XENA2 only
151 #endif // !defined(NTV2_DEPRECATE_16_0)
152 }; // CNTV2BareMetalDriverInterface
153 
154 #endif // NTV2BAREMETALDRIVERINTERFACE_H
CNTV2BareMetalDriverInterface::OpenLocalPhysical
virtual bool OpenLocalPhysical(const UWord inDeviceIndex)
Opens the local/physical device connection.
Definition: ntv2baremetaldriverinterface.cpp:65
CNTV2BareMetalDriverInterface::_bitfileDirectory
std::string _bitfileDirectory
Definition: ntv2baremetaldriverinterface.h:143
CNTV2BareMetalDriverInterface::GetBA0MemorySize
virtual bool GetBA0MemorySize(ULWord *memSize)
Definition: ntv2baremetaldriverinterface.cpp:464
CNTV2BareMetalDriverInterface::NTV2Message
virtual bool NTV2Message(NTV2_HEADER *pInOutMessage)
Sends a message to the NTV2 driver (the new, improved, preferred way).
Definition: ntv2baremetaldriverinterface.cpp:1075
HANDLE
short HANDLE
Definition: ajatypes.h:304
INTERRUPT_ENUMS
enum _INTERRUPT_ENUMS_ INTERRUPT_ENUMS
CNTV2BareMetalDriverInterface::MapDMADriverBuffer
virtual bool MapDMADriverBuffer()
Definition: ntv2baremetaldriverinterface.cpp:1127
CNTV2BareMetalDriverInterface::UnmapDMADriverBuffer
virtual bool UnmapDMADriverBuffer()
Definition: ntv2baremetaldriverinterface.cpp:1175
NTV2_DriverDebugMessageSet
NTV2_DriverDebugMessageSet
Definition: ntv2enums.h:3743
CNTV2BareMetalDriverInterface::GetInterruptCount
virtual bool GetInterruptCount(const INTERRUPT_ENUMS eInterrupt, ULWord &outCount)
Answers with the number of interrupts of the given type processed by the driver.
Definition: ntv2baremetaldriverinterface.cpp:199
NTV2Channel
NTV2Channel
These enum values are mostly used to identify a specific Frame Store. They're also commonly used to i...
Definition: ntv2enums.h:1305
CNTV2BareMetalDriverInterface::_pDMADriverBufferAddress
ULWord * _pDMADriverBufferAddress
Definition: ntv2baremetaldriverinterface.h:146
CNTV2BareMetalDriverInterface::UnmapDNXRegisters
virtual bool UnmapDNXRegisters(void)
Definition: ntv2baremetaldriverinterface.cpp:574
CNTV2BareMetalDriverInterface::_pDNXRegisterBaseAddress
ULWord * _pDNXRegisterBaseAddress
Definition: ntv2baremetaldriverinterface.h:148
CNTV2BareMetalDriverInterface
BareMetal implementation of CNTV2DriverInterface.
Definition: ntv2baremetaldriverinterface.h:25
CNTV2BareMetalDriverInterface::UnmapFrameBuffers
virtual bool UnmapFrameBuffers(void)
Definition: ntv2baremetaldriverinterface.cpp:386
CNTV2BareMetalDriverInterface::_BA4MemorySize
ULWord _BA4MemorySize
Definition: ntv2baremetaldriverinterface.h:150
CNTV2BareMetalDriverInterface::RestoreHardwareProcampRegisters
virtual bool RestoreHardwareProcampRegisters(void)
Definition: ntv2baremetaldriverinterface.cpp:157
CNTV2BareMetalDriverInterface::_BA0MemorySize
ULWord _BA0MemorySize
Definition: ntv2baremetaldriverinterface.h:147
PULWord
uint32_t * PULWord
Definition: ajatypes.h:247
CNTV2BareMetalDriverInterface::MapXena2Flash
virtual bool MapXena2Flash(void)
Definition: ntv2baremetaldriverinterface.cpp:484
CNTV2BareMetalDriverInterface::_hDevice
HANDLE _hDevice
Definition: ntv2baremetaldriverinterface.h:144
CNTV2BareMetalDriverInterface::UnmapXena2Flash
virtual bool UnmapXena2Flash(void)
Definition: ntv2baremetaldriverinterface.cpp:520
CNTV2BareMetalDriverInterface::UnmapRegisters
virtual bool UnmapRegisters(void)
Definition: ntv2baremetaldriverinterface.cpp:450
CNTV2BareMetalDriverInterface::ConfigureSubscription
virtual bool ConfigureSubscription(const bool bSubscribe, const INTERRUPT_ENUMS eInterruptType, PULWord &hSubcription)
Definition: ntv2baremetaldriverinterface.h:70
CNTV2BareMetalDriverInterface::~CNTV2BareMetalDriverInterface
virtual ~CNTV2BareMetalDriverInterface()
Definition: ntv2baremetaldriverinterface.cpp:54
NTV2_GlobalAudioPlaybackMode
NTV2_GlobalAudioPlaybackMode
Definition: ntv2enums.h:2047
CNTV2BareMetalDriverInterface::_BA2MemorySize
ULWord _BA2MemorySize
Definition: ntv2baremetaldriverinterface.h:149
NTV2DMAEngine
NTV2DMAEngine
Definition: ntv2enums.h:1801
CNTV2BareMetalDriverInterface::DmaWriteWithOffsets
virtual bool DmaWriteWithOffsets(NTV2DMAEngine DMAEngine, ULWord frameNumber, ULWord *pFrameBuffer, ULWord offsetSrc, ULWord offsetDest, ULWord bytes)
Definition: ntv2baremetaldriverinterface.cpp:1370
CNTV2BareMetalDriverInterface::GetDMANumDriverBuffers
virtual bool GetDMANumDriverBuffers(ULWord *pNumDmaDriverBuffers)
Definition: ntv2baremetaldriverinterface.cpp:1119
CNTV2DriverInterface::GetStreamingApplication
virtual bool GetStreamingApplication(ULWord &outAppType, int32_t &outProcessID)
Answers with the four-CC type and process ID of the application that currently "owns" the AJA device ...
Definition: ntv2driverinterface.cpp:1097
CNTV2BareMetalDriverInterface::CloseLocalPhysical
virtual bool CloseLocalPhysical(void)
Releases host resources associated with the local/physical device connection.
Definition: ntv2baremetaldriverinterface.cpp:99
ULWord
uint32_t ULWord
Definition: ajatypes.h:246
CNTV2BareMetalDriverInterface::SetupBoard
virtual bool SetupBoard(void)
Definition: ntv2baremetaldriverinterface.cpp:312
CNTV2BareMetalDriverInterface::HevcSendMessage
virtual bool HevcSendMessage(HevcMessageHeader *pMessage)
Sends an HEVC message to the NTV2 driver.
Definition: ntv2baremetaldriverinterface.cpp:1094
CNTV2BareMetalDriverInterface::WaitForInterrupt
virtual bool WaitForInterrupt(INTERRUPT_ENUMS eInterrupt, ULWord timeOutMs=68)
Definition: ntv2baremetaldriverinterface.cpp:265
CNTV2BareMetalDriverInterface::AutoCirculate
virtual bool AutoCirculate(AUTOCIRCULATE_DATA &autoCircData)
Sends an AutoCirculate command to the NTV2 driver.
Definition: ntv2baremetaldriverinterface.cpp:844
DMA_LOCKED_VEC
std::vector< ULWord * > DMA_LOCKED_VEC
Definition: ntv2baremetaldriverinterface.h:20
NTV2_HEADER
All new NTV2 structs start with this common header.
Definition: ntv2publicinterface.h:6899
UWord
uint16_t UWord
Definition: ajatypes.h:244
CNTV2BareMetalDriverInterface::DmaReadFrameDriverBuffer
virtual bool DmaReadFrameDriverBuffer(NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame, ULWord bytes, ULWord downSample, ULWord linePitch, ULWord poll)
Definition: ntv2baremetaldriverinterface.cpp:1295
DMAEngine
DMAEngine
Definition: ntv2macpublicinterface.h:103
CNTV2BareMetalDriverInterface::CNTV2BareMetalDriverInterface
CNTV2BareMetalDriverInterface()
Definition: ntv2baremetaldriverinterface.cpp:41
AJA_VIRTUAL
#define AJA_VIRTUAL
Definition: ajatypes.h:153
CNTV2BareMetalDriverInterface::WriteRegister
virtual bool WriteRegister(const ULWord inRegNum, const ULWord inValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Updates or replaces all or part of the 32-bit contents of a specific register (real or virtual) on th...
Definition: ntv2baremetaldriverinterface.cpp:141
CNTV2BareMetalDriverInterface::DmaReadWithOffsets
virtual bool DmaReadWithOffsets(NTV2DMAEngine DMAEngine, ULWord frameNumber, ULWord *pFrameBuffer, ULWord offsetSrc, ULWord offsetDest, ULWord bytes)
Definition: ntv2baremetaldriverinterface.cpp:1418
hevcMessageHeader
Definition: ntv2publicinterface.h:9761
NTV2_SHOULD_BE_DEPRECATED
#define NTV2_SHOULD_BE_DEPRECATED(__f__)
Definition: ajatypes.h:616
NTV2_DEPRECATED_f
#define NTV2_DEPRECATED_f(__f__)
Definition: ajatypes.h:646
CNTV2BareMetalDriverInterface::GetAudioOutputMode
virtual bool GetAudioOutputMode(NTV2_GlobalAudioPlaybackMode *mode)
Definition: ntv2baremetaldriverinterface.cpp:1205
false
#define false
Definition: ntv2devicefeatures.h:25
CNTV2BareMetalDriverInterface::ReadRegister
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....
Definition: ntv2baremetaldriverinterface.cpp:127
CNTV2BareMetalDriverInterface::DmaWriteFrameDriverBuffer
virtual bool DmaWriteFrameDriverBuffer(NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame, ULWord bytes, ULWord poll)
Definition: ntv2baremetaldriverinterface.cpp:1222
AUTOCIRCULATE_P2P_STRUCT
Definition: ntv2publicinterface.h:4626
CNTV2BareMetalDriverInterface::DmaTransfer
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...
Definition: ntv2baremetaldriverinterface.cpp:598
CNTV2BareMetalDriverInterface::GetBA1MemorySize
virtual bool GetBA1MemorySize(ULWord *memSize)
Definition: ntv2baremetaldriverinterface.cpp:469
CNTV2BareMetalDriverInterface::MapRegisters
virtual bool MapRegisters(void)
Definition: ntv2baremetaldriverinterface.cpp:411
CNTV2BareMetalDriverInterface::MapDNXRegisters
virtual bool MapDNXRegisters(void)
Definition: ntv2baremetaldriverinterface.cpp:537
CNTV2BareMetalDriverInterface::ControlDriverDebugMessages
virtual bool ControlDriverDebugMessages(NTV2_DriverDebugMessageSet msgSet, bool enable)
Definition: ntv2baremetaldriverinterface.cpp:292
CNTV2BareMetalDriverInterface::ConfigureInterrupt
virtual bool ConfigureInterrupt(const bool bEnable, const INTERRUPT_ENUMS eInterruptType)
Definition: ntv2baremetaldriverinterface.cpp:177
CNTV2BareMetalDriverInterface::MapFrameBuffers
virtual bool MapFrameBuffers(void)
Definition: ntv2baremetaldriverinterface.cpp:335
CNTV2BareMetalDriverInterface::GetBA2MemorySize
virtual bool GetBA2MemorySize(ULWord *memSize)
Definition: ntv2baremetaldriverinterface.cpp:474
CNTV2DriverInterface
I'm the base class that undergirds the platform-specific derived classes (from which CNTV2Card is ult...
Definition: ntv2driverinterface.h:64
CNTV2BareMetalDriverInterface::GetDMADriverBufferAddress
virtual bool GetDMADriverBufferAddress(ULWord **pDMADriverBuffer)
Definition: ntv2baremetaldriverinterface.cpp:1161
ntv2driverinterface.h
Declares the CNTV2DriverInterface base class.
CNTV2BareMetalDriverInterface::GetDMADriverBufferPhysicalAddress
virtual bool GetDMADriverBufferPhysicalAddress(ULWord *physAddr)
Definition: ntv2baremetaldriverinterface.cpp:1114
CNTV2BareMetalDriverInterface::GetBA4MemorySize
virtual bool GetBA4MemorySize(ULWord *memSize)
Definition: ntv2baremetaldriverinterface.cpp:479
AUTOCIRCULATE_DATA
Definition: ntv2publicinterface.h:4338
CNTV2BareMetalDriverInterface::SetAudioOutputMode
virtual bool SetAudioOutputMode(NTV2_GlobalAudioPlaybackMode mode)
Definition: ntv2baremetaldriverinterface.cpp:1200