AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
ntv2linuxdriverinterface.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
7 #ifndef NTV2LINUXDRIVERINTERFACE_H
8 #define NTV2LINUXDRIVERINTERFACE_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 
35 
36  AJA_VIRTUAL bool DmaTransfer (const NTV2DMAEngine inDMAEngine,
37  const bool inIsRead,
38  const ULWord inFrameNumber,
39  ULWord * pFrameBuffer,
40  const ULWord inCardOffsetBytes,
41  const ULWord inTotalByteCount,
42  const bool inSynchronous = true);
43 
44  AJA_VIRTUAL bool DmaTransfer (const NTV2DMAEngine inDMAEngine,
45  const bool inIsRead,
46  const ULWord inFrameNumber,
47  ULWord * pFrameBuffer,
48  const ULWord inCardOffsetBytes,
49  const ULWord inTotalByteCount,
50  const ULWord inNumSegments,
51  const ULWord inHostPitchPerSeg,
52  const ULWord inCardPitchPerSeg,
53  const bool inSynchronous = true);
54 
55  AJA_VIRTUAL bool DmaTransfer (const NTV2DMAEngine inDMAEngine,
56  const NTV2Channel inDMAChannel,
57  const bool inTarget,
58  const ULWord inFrameNumber,
59  const ULWord inCardOffsetBytes,
60  const ULWord inByteCount,
61  const ULWord inNumSegments,
62  const ULWord inSegmentHostPitch,
63  const ULWord inSegmentCardPitch,
64  const PCHANNEL_P2P_STRUCT & inP2PData);
65 
66  AJA_VIRTUAL bool ConfigureSubscription (const bool bSubscribe, const INTERRUPT_ENUMS eInterruptType, PULWord & hSubcription)
67  {(void)bSubscribe; (void)eInterruptType; (void)hSubcription; return true;}
68  AJA_VIRTUAL bool ConfigureInterrupt (const bool bEnable, const INTERRUPT_ENUMS eInterruptType);
69  AJA_VIRTUAL bool GetInterruptCount (const INTERRUPT_ENUMS eInterrupt, ULWord & outCount);
70  AJA_VIRTUAL bool WaitForInterrupt (INTERRUPT_ENUMS eInterrupt, ULWord timeOutMs = 68); // default of 68 ms timeout is enough time for 2K at 14.98 HZ
71 
72  AJA_VIRTUAL bool AutoCirculate (AUTOCIRCULATE_DATA &autoCircData);
73  AJA_VIRTUAL bool NTV2Message (NTV2_HEADER * pInOutMessage);
75  bool enable);
76 #if !defined(NTV2_DEPRECATE_17_6)
77  AJA_VIRTUAL inline bool NTV2_DEPRECATED_17_6(HevcSendMessage(HevcMessageHeader* pMsg)) {(void)pMsg; return false;}
78 #endif
79 
80  AJA_VIRTUAL bool SetupBoard(void);
81 
82  // User allocated buffer methods. Not as fast as driverbuffer methods, but no kernel patch required.
83  AJA_VIRTUAL bool DmaWriteWithOffsets (NTV2DMAEngine DMAEngine, ULWord frameNumber, ULWord * pFrameBuffer,
84  ULWord offsetSrc, ULWord offsetDest, ULWord bytes);
85  AJA_VIRTUAL bool DmaReadWithOffsets (NTV2DMAEngine DMAEngine, ULWord frameNumber, ULWord * pFrameBuffer,
86  ULWord offsetSrc, ULWord offsetDest, ULWord bytes);
87 
88 public:
89 #if !defined(NTV2_DEPRECATE_16_0)
90  AJA_VIRTUAL inline NTV2_DEPRECATED_16_0(bool GetStreamingApplication(ULWord & outAppType, int32_t & outPID)) {return CNTV2DriverInterface::GetStreamingApplication(outAppType,outPID);}
91  AJA_VIRTUAL inline NTV2_DEPRECATED_16_0(bool GetStreamingApplication(ULWord * pAppType, int32_t * pPID)) {return pAppType && pPID ? CNTV2DriverInterface::GetStreamingApplication(*pAppType,*pPID) : false;}
104  // Driver allocated buffer (DMA performance enhancement, requires bigphysarea patch to kernel)
107 
108  AJA_VIRTUAL NTV2_DEPRECATED_16_0(bool DmaReadFrameDriverBuffer (NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame,
109  ULWord bytes, ULWord downSample, ULWord linePitch, ULWord poll));
110 
111  AJA_VIRTUAL NTV2_DEPRECATED_16_0(bool DmaReadFrameDriverBuffer (NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame,
112  ULWord offsetSrc, ULWord offsetDest, ULWord bytes,
113  ULWord downSample, ULWord linePitch, ULWord poll));
114 
115  AJA_VIRTUAL NTV2_DEPRECATED_16_0(bool DmaWriteFrameDriverBuffer (NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame,
116  ULWord bytes, ULWord poll));
117  AJA_VIRTUAL NTV2_DEPRECATED_16_0(bool DmaWriteFrameDriverBuffer (NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame,
118  ULWord offsetSrc, ULWord offsetDest, ULWord bytes, ULWord poll));
121  AJA_VIRTUAL NTV2_DEPRECATED_16_0(bool GetDMANumDriverBuffers(ULWord* pNumDmaDriverBuffers));
122 #endif // defined(NTV2_DRIVER_ALLOCATED_BUFFERS)
125 
126 #if !defined(NTV2_NULL_DEVICE)
127 protected: // PRIVATE METHODS
128  AJA_VIRTUAL bool OpenLocalPhysical (const UWord inDeviceIndex);
129  AJA_VIRTUAL bool CloseLocalPhysical (void);
130 #endif // !defined(NTV2_NULL_DEVICE)
131 
132 protected: // INSTANCE DATA
133  std::string _bitfileDirectory;
135 #if !defined(NTV2_DEPRECATE_16_0)
140  ULWord _BA4MemorySize; // XENA2 only
141 #endif // !defined(NTV2_DEPRECATE_16_0)
142 }; // CNTV2LinuxDriverInterface
143 
144 #endif // NTV2LINUXDRIVERINTERFACE_H
virtual bool CloseLocalPhysical(void)
Releases host resources associated with the local/physical device connection.
virtual bool DmaReadWithOffsets(NTV2DMAEngine DMAEngine, ULWord frameNumber, ULWord *pFrameBuffer, ULWord offsetSrc, ULWord offsetDest, ULWord bytes)
virtual bool SetupBoard(void)
defined(NTV2_DEPRECATE_17_6)
Declares the CNTV2DriverInterface base class.
uint32_t * PULWord
Definition: ajatypes.h:224
virtual bool NTV2Message(NTV2_HEADER *pInOutMessage)
Sends a message to the NTV2 driver (the new, improved, preferred way).
#define NTV2_DEPRECATED_17_6(__f__)
Definition: ajatypes.h:568
virtual bool GetDMANumDriverBuffers(ULWord *pNumDmaDriverBuffers)
virtual bool GetStreamingApplication(ULWord &outAppType, int32_t &outPID)
NTV2_DriverDebugMessageSet
Definition: ntv2enums.h:3829
uint32_t ULWord
Definition: ajatypes.h:223
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1357
short HANDLE
Definition: ajatypes.h:285
virtual bool DmaReadFrameDriverBuffer(NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame, ULWord bytes, ULWord downSample, ULWord linePitch, ULWord poll)
virtual bool RestoreHardwareProcampRegisters(void)
virtual bool ConfigureSubscription(const bool bSubscribe, const INTERRUPT_ENUMS eInterruptType, PULWord &hSubcription)
virtual bool GetInterruptCount(const INTERRUPT_ENUMS eInterrupt, ULWord &outCount)
Answers with the number of interrupts of the given type processed by the driver.
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 ...
I&#39;m the base class that undergirds the platform-specific derived classes (from which CNTV2Card is ult...
#define AJA_VIRTUAL
Definition: ajatypes.h:130
NTV2DMAEngine
Definition: ntv2enums.h:1856
virtual bool GetStreamingApplication(ULWord *pAppType, int32_t *pPID)
virtual bool GetDMADriverBufferPhysicalAddress(ULWord *physAddr)
virtual bool ControlDriverDebugMessages(NTV2_DriverDebugMessageSet msgSet, bool enable)
enum _INTERRUPT_ENUMS_ INTERRUPT_ENUMS
virtual bool AutoCirculate(AUTOCIRCULATE_DATA &autoCircData)
Sends an AutoCirculate command to the NTV2 driver.
All new NTV2 structs start with this common header.
virtual bool DmaWriteWithOffsets(NTV2DMAEngine DMAEngine, ULWord frameNumber, ULWord *pFrameBuffer, ULWord offsetSrc, ULWord offsetDest, ULWord bytes)
virtual bool HevcSendMessage(HevcMessageHeader *pMsg)
NTV2_GlobalAudioPlaybackMode
Definition: ntv2enums.h:2106
virtual bool GetBA4MemorySize(ULWord *memSize)
virtual bool GetBA0MemorySize(ULWord *memSize)
virtual bool ConfigureInterrupt(const bool bEnable, const INTERRUPT_ENUMS eInterruptType)
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...
virtual bool WaitForInterrupt(INTERRUPT_ENUMS eInterrupt, ULWord timeOutMs=68)
uint16_t UWord
Definition: ajatypes.h:221
std::vector< ULWord * > DMA_LOCKED_VEC
virtual bool GetBA2MemorySize(ULWord *memSize)
virtual bool SetAudioOutputMode(NTV2_GlobalAudioPlaybackMode mode)
virtual bool GetBA1MemorySize(ULWord *memSize)
#define NTV2_DEPRECATED_16_0(__f__)
Definition: ajatypes.h:529
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...
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...
virtual bool OpenLocalPhysical(const UWord inDeviceIndex)
Opens the local/physical device connection.
virtual bool GetDMADriverBufferAddress(ULWord **pDMADriverBuffer)
virtual bool DmaWriteFrameDriverBuffer(NTV2DMAEngine DMAEngine, ULWord frameNumber, unsigned long dmaBufferFrame, ULWord bytes, ULWord poll)
Linux implementation of CNTV2DriverInterface.
virtual bool GetAudioOutputMode(NTV2_GlobalAudioPlaybackMode *mode)