initial commit
This commit is contained in:
commit
0f54e0d915
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
stdenv,
|
||||||
|
callPackage,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
buildApps ? true,
|
||||||
|
}:
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "ajantv2-dev";
|
||||||
|
src = callPackage ./src.nix {};
|
||||||
|
nativeBuildInputs = [pkgs.cmake];
|
||||||
|
|
||||||
|
cmakeFlags =
|
||||||
|
[
|
||||||
|
"-DAJA_BUILD_DRIVER=OFF"
|
||||||
|
"-DAJA_BUILD_QT_BASED=OFF"
|
||||||
|
]
|
||||||
|
++ lib.optional (!buildApps) "-DAJA_BUILD_APPS=off";
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
callPackage,
|
||||||
|
stdenv,
|
||||||
|
nukeReferences,
|
||||||
|
kernel,
|
||||||
|
}:
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "ajantv2-driver-${kernel.version}";
|
||||||
|
src = callPackage ./src.nix {};
|
||||||
|
patches = [./lol.patch ./newkernels.patch];
|
||||||
|
nativeBuildInputs = kernel.moduleBuildDependencies;
|
||||||
|
buildInputs = [nukeReferences];
|
||||||
|
|
||||||
|
# the makefile symlinks some files, which can't be done at build time, so do it here
|
||||||
|
# and patch out the offending bits of makefile (lol.patch)
|
||||||
|
postUnpack = ''
|
||||||
|
cp source/ajalibraries/ajantv2/src/ntv2devicefeatures.cpp source/ajadriver/linux/ntv2devicefeatures.c
|
||||||
|
cp source/ajalibraries/ajantv2/src/ntv2driverprocamp.cpp source/ajadriver/linux/ntv2driverprocamp.c
|
||||||
|
cp source/ajalibraries/ajantv2/src/ntv2vpidfromspec.cpp source/ajadriver/linux/ntv2vpidfromspec.c
|
||||||
|
'';
|
||||||
|
# AJA_CREATE_DEVICE_NODES causes the driver to automatically create /dev nodes rather
|
||||||
|
# than need to use the weird load_ajantv2 script
|
||||||
|
makeFlags = [
|
||||||
|
"AJA_CREATE_DEVICE_NODES=1"
|
||||||
|
"KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
|
||||||
|
"--directory=ajadriver/linux"
|
||||||
|
];
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/lib/modules/${kernel.modDirVersion}/misc
|
||||||
|
for x in $(find . -name '*.ko'); do
|
||||||
|
nuke-refs $x
|
||||||
|
cp $x $out/lib/modules/${kernel.modDirVersion}/misc/
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
diff --git a/ajadriver/linux/Makefile b/ajadriver/linux/Makefile
|
||||||
|
index 710951b..6fde2b4 100644
|
||||||
|
--- a/ajadriver/linux/Makefile
|
||||||
|
+++ b/ajadriver/linux/Makefile
|
||||||
|
@@ -177,15 +177,6 @@ all: $(DRIVERINCS) $(DRIVERSRCS) $(HEVCINCS) $(HEVCSRCS) $(RDMAINCS)
|
||||||
|
|
||||||
|
# Make a symlink to the C-only CPP files we need in classes.
|
||||||
|
|
||||||
|
-ntv2devicefeatures.c:
|
||||||
|
- ln -sf $(A_LIB_NTV2_SRC)/ntv2devicefeatures.cpp $(A_LINUX_DRIVER_PATH)/ntv2devicefeatures.c
|
||||||
|
-
|
||||||
|
-ntv2driverprocamp.c:
|
||||||
|
- ln -sf $(A_LIB_NTV2_SRC)/ntv2driverprocamp.cpp $(A_LINUX_DRIVER_PATH)/ntv2driverprocamp.c
|
||||||
|
-
|
||||||
|
-ntv2vpidfromspec.c:
|
||||||
|
- ln -sf $(A_LIB_NTV2_SRC)/ntv2vpidfromspec.cpp $(A_LINUX_DRIVER_PATH)/ntv2vpidfromspec.c
|
||||||
|
-
|
||||||
|
.PHONY: clean cleandeps realclean
|
||||||
|
|
||||||
|
clean:
|
|
@ -0,0 +1,151 @@
|
||||||
|
Fixes for newer kernels
|
||||||
|
Includes:
|
||||||
|
https://github.com/nvidia-holoscan/ntv2/commit/70f44cea11560316714ab382bf6799d09ae51b74
|
||||||
|
|
||||||
|
diff --git a/ajadriver/linux/ntv2dma.c b/ajadriver/linux/ntv2dma.c
|
||||||
|
index 8d0aa23..83a73b4 100644
|
||||||
|
--- a/ajadriver/linux/ntv2dma.c
|
||||||
|
+++ b/ajadriver/linux/ntv2dma.c
|
||||||
|
@@ -473,9 +473,10 @@ int dmaInit(ULWord deviceNumber)
|
||||||
|
for (iDes = 0; iDes < pDmaEngine->numDescriptorPages; iDes++)
|
||||||
|
{
|
||||||
|
pDmaEngine->pDescriptorVirtual[iDes] =
|
||||||
|
- pci_alloc_consistent(pNTV2Params->pci_dev,
|
||||||
|
+ dma_alloc_coherent(&pNTV2Params->pci_dev->dev,
|
||||||
|
PAGE_SIZE,
|
||||||
|
- &pDmaEngine->descriptorPhysical[iDes]);
|
||||||
|
+ &pDmaEngine->descriptorPhysical[iDes],
|
||||||
|
+ GFP_ATOMIC);
|
||||||
|
if ((pDmaEngine->pDescriptorVirtual[iDes] == NULL) ||
|
||||||
|
(pDmaEngine->descriptorPhysical[iDes] == 0))
|
||||||
|
{
|
||||||
|
@@ -556,7 +557,7 @@ static void dmaFreeEngine(PDMA_ENGINE pDmaEngine)
|
||||||
|
if ((pDmaEngine->pDescriptorVirtual[iDes] != NULL) &&
|
||||||
|
(pDmaEngine->descriptorPhysical[iDes] != 0))
|
||||||
|
{
|
||||||
|
- pci_free_consistent(pNTV2Params->pci_dev,
|
||||||
|
+ dma_free_coherent(&pNTV2Params->pci_dev->dev,
|
||||||
|
PAGE_SIZE,
|
||||||
|
pDmaEngine->pDescriptorVirtual[iDes],
|
||||||
|
pDmaEngine->descriptorPhysical[iDes]);
|
||||||
|
@@ -914,7 +915,7 @@ int dmaTransfer(PDMA_PARAMS pDmaParams)
|
||||||
|
pDmaContext->dmaC2H = pDmaParams->toHost;
|
||||||
|
}
|
||||||
|
dmaC2H = pDmaContext->dmaC2H;
|
||||||
|
- direction = dmaC2H? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE;
|
||||||
|
+ direction = dmaC2H? DMA_FROM_DEVICE : DMA_TO_DEVICE;
|
||||||
|
|
||||||
|
// do nothing by default
|
||||||
|
pDmaContext->pVideoPageBuffer = NULL;
|
||||||
|
@@ -2282,7 +2283,7 @@ int dmaPageRootAdd(ULWord deviceNumber, PDMA_PAGE_ROOT pRoot,
|
||||||
|
}
|
||||||
|
|
||||||
|
// lock buffer
|
||||||
|
- ret = dmaPageLock(deviceNumber, pBuffer, pAddress, size, PCI_DMA_BIDIRECTIONAL);
|
||||||
|
+ ret = dmaPageLock(deviceNumber, pBuffer, pAddress, size, DMA_BIDIRECTIONAL);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
kfree(pBuffer);
|
||||||
|
@@ -2655,7 +2656,7 @@ static int dmaPageLock(ULWord deviceNumber, PDMA_PAGE_BUFFER pBuffer,
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine if buffer will be written
|
||||||
|
- write = (direction == PCI_DMA_BIDIRECTIONAL) || (direction == PCI_DMA_FROMDEVICE);
|
||||||
|
+ write = (direction == DMA_BIDIRECTIONAL) || (direction == DMA_FROM_DEVICE);
|
||||||
|
|
||||||
|
// get the map semaphore
|
||||||
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0))
|
||||||
|
@@ -2785,7 +2786,7 @@ static void dmaPageUnlock(ULWord deviceNumber, PDMA_PAGE_BUFFER pBuffer)
|
||||||
|
// release the locked pages
|
||||||
|
for (i = 0; i < pBuffer->numPages; i++)
|
||||||
|
{
|
||||||
|
- if ((pBuffer->direction == PCI_DMA_FROMDEVICE) &&
|
||||||
|
+ if ((pBuffer->direction == DMA_FROM_DEVICE) &&
|
||||||
|
!PageReserved(pBuffer->pPageList[i]))
|
||||||
|
{
|
||||||
|
set_page_dirty(pBuffer->pPageList[i]);
|
||||||
|
@@ -2907,7 +2908,7 @@ static int dmaSgMap(ULWord deviceNumber, PDMA_PAGE_BUFFER pBuffer)
|
||||||
|
ret = nvidia_p2p_dma_map_pages(&(pNTV2Params->pci_dev)->dev,
|
||||||
|
pBuffer->rdmaPage,
|
||||||
|
&pBuffer->rdmaMap,
|
||||||
|
- (pBuffer->direction == PCI_DMA_TODEVICE)? DMA_TO_DEVICE : DMA_FROM_DEVICE);
|
||||||
|
+ (pBuffer->direction == DMA_TO_DEVICE)? DMA_TO_DEVICE : DMA_FROM_DEVICE);
|
||||||
|
#else
|
||||||
|
ret = nvidia_p2p_dma_map_pages(pNTV2Params->pci_dev,
|
||||||
|
pBuffer->rdmaPage,
|
||||||
|
diff --git a/ajadriver/linux/ntv2driver.c b/ajadriver/linux/ntv2driver.c
|
||||||
|
index d97e242..a1569aa 100644
|
||||||
|
--- a/ajadriver/linux/ntv2driver.c
|
||||||
|
+++ b/ajadriver/linux/ntv2driver.c
|
||||||
|
@@ -4398,9 +4398,9 @@ pci_resources_config (struct pci_dev *pdev, NTV2PrivateParams * ntv2pp)
|
||||||
|
// a 64-bit mask from a previous driver load.
|
||||||
|
|
||||||
|
#if defined(DMA_BIT_MASK)
|
||||||
|
- if((res = pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) != 0)
|
||||||
|
+ if((res = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) != 0)
|
||||||
|
#else
|
||||||
|
- if((res = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) != 0)
|
||||||
|
+ if((res = dma_set_mask(&pdev->dev, DMA_32BIT_MASK)) != 0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
MSG("%s: Unable to set DMA mask. Disabling this board.\n",
|
||||||
|
@@ -4704,9 +4704,9 @@ dma_registers_init (struct pci_dev *pdev, NTV2PrivateParams * ntv2pp)
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(DMA_BIT_MASK)
|
||||||
|
- if(!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)))
|
||||||
|
+ if(!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)))
|
||||||
|
#else
|
||||||
|
- if(!pci_set_dma_mask(pdev, DMA_64BIT_MASK))
|
||||||
|
+ if(!dma_set_mask(&pdev->dev, DMA_64BIT_MASK))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
MSG("%s: Using 64-bit DMA mask with 64-bit capable firmware\n",
|
||||||
|
diff --git a/ajadriver/ntv2system.c b/ajadriver/ntv2system.c
|
||||||
|
index 0859239..0c723fc 100644
|
||||||
|
--- a/ajadriver/ntv2system.c
|
||||||
|
+++ b/ajadriver/ntv2system.c
|
||||||
|
@@ -1513,7 +1513,7 @@ bool ntv2DmaMemoryAlloc(Ntv2DmaMemory* pDmaMemory, Ntv2SystemContext* pSysCon, u
|
||||||
|
(pSysCon->pDevice == NULL) ||
|
||||||
|
(size == 0)) return false;
|
||||||
|
|
||||||
|
- pAddress = pci_alloc_consistent(pSysCon->pDevice, size, &dmaAddress);
|
||||||
|
+ pAddress = dma_alloc_coherent(&pSysCon->pDevice->dev, size, &dmaAddress, GFP_ATOMIC);
|
||||||
|
if((pAddress == NULL) || (dmaAddress == 0)) return false;
|
||||||
|
|
||||||
|
// initialize memory data structure
|
||||||
|
@@ -1534,7 +1534,7 @@ void ntv2DmaMemoryFree(Ntv2DmaMemory* pDmaMemory)
|
||||||
|
(pDmaMemory->dmaAddress == 0) ||
|
||||||
|
(pDmaMemory->size == 0)) return;
|
||||||
|
|
||||||
|
- pci_free_consistent(pDmaMemory->pDevice,
|
||||||
|
+ dma_free_coherent(&pDmaMemory->pDevice->dev,
|
||||||
|
pDmaMemory->size,
|
||||||
|
pDmaMemory->pAddress,
|
||||||
|
pDmaMemory->dmaAddress);
|
||||||
|
diff --git a/ajalibraries/ajantv2/includes/ntv2devicefeatures.h b/ajalibraries/ajantv2/includes/ntv2devicefeatures.h
|
||||||
|
index 4dc2bd5..cd1972e 100644
|
||||||
|
--- a/ajalibraries/ajantv2/includes/ntv2devicefeatures.h
|
||||||
|
+++ b/ajalibraries/ajantv2/includes/ntv2devicefeatures.h
|
||||||
|
@@ -10,7 +10,7 @@
|
||||||
|
#define NTV2DEVICEFEATURES_H
|
||||||
|
|
||||||
|
#if defined(AJALinux) || defined(AJA_LINUX)
|
||||||
|
- #include <stddef.h> // For size_t
|
||||||
|
+ #include <linux/stddef.h> // For size_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ajaexport.h"
|
||||||
|
diff --git a/ajadriver/linux/ntv2serial.c b/ajadriver/linux/ntv2serial.c
|
||||||
|
index 3ba5ea6..8d9e483 100644
|
||||||
|
--- a/ajadriver/linux/ntv2serial.c
|
||||||
|
+++ b/ajadriver/linux/ntv2serial.c
|
||||||
|
@@ -170,7 +170,7 @@ static void ntv2_uartops_shutdown(struct uart_port *port)
|
||||||
|
|
||||||
|
static void ntv2_uartops_set_termios(struct uart_port *port,
|
||||||
|
struct ktermios *termios,
|
||||||
|
- struct ktermios *old)
|
||||||
|
+ const struct ktermios *old)
|
||||||
|
{
|
||||||
|
struct ntv2_serial *ntv2_ser = container_of(port, struct ntv2_serial, uart_port);
|
||||||
|
u32 valid = ntv2_kona_fld_serial_rx_valid;
|
|
@ -0,0 +1,6 @@
|
||||||
|
{ pkgs }: pkgs.fetchFromGitHub {
|
||||||
|
owner = "aja-video";
|
||||||
|
repo = "ntv2";
|
||||||
|
rev = "refs/heads/main";
|
||||||
|
hash = "sha256-rXjKDhQcZwAxsMjCoL21gpWeLWyIXyK/1y+78mhKgeo=";
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
diff --git a/ajalibraries/ajantv2/includes/ntv2devicefeatures.h b/ajalibraries/ajantv2/includes/ntv2devicefeatures.h
|
||||||
|
index 4dc2bd5..cd1972e 100644
|
||||||
|
--- a/ajalibraries/ajantv2/includes/ntv2devicefeatures.h
|
||||||
|
+++ b/ajalibraries/ajantv2/includes/ntv2devicefeatures.h
|
||||||
|
@@ -10,7 +10,7 @@
|
||||||
|
#define NTV2DEVICEFEATURES_H
|
||||||
|
|
||||||
|
#if defined(AJALinux) || defined(AJA_LINUX)
|
||||||
|
- #include <stddef.h> // For size_t
|
||||||
|
+ #include <linux/stddef.h> // For size_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ajaexport.h"
|
|
@ -0,0 +1,58 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1694499547,
|
||||||
|
"narHash": "sha256-R7xMz1Iia6JthWRHDn36s/E248WB1/je62ovC/dUVKI=",
|
||||||
|
"path": "/nix/store/zxh6mqr25a59giy1a0ca37njv92lv9hy-source",
|
||||||
|
"rev": "e5f018cf150e29aac26c61dac0790ea023c46b24",
|
||||||
|
"type": "path"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"utils": "utils"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1694529238,
|
||||||
|
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
description = "AJA video card software";
|
||||||
|
inputs.utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
utils,
|
||||||
|
}: (
|
||||||
|
utils.lib.eachSystem ["x86_64-linux"] (system: let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
packages.aja-ntv2-gst = pkgs.callPackage ./ntv2-gst.nix {
|
||||||
|
ajantv2 = pkgs.callPackage ./aja-ntv2/default.nix { buildApps = false; };
|
||||||
|
};
|
||||||
|
formatter = pkgs.alejandra;
|
||||||
|
})
|
||||||
|
) // {
|
||||||
|
overlays.default = (final: prev: {
|
||||||
|
ajantv-utils = final.callPackage ./aja-ntv2/default.nix {};
|
||||||
|
ajantv-driver = final.linuxPackages.callPackage ./aja-ntv2/driver.nix {};
|
||||||
|
aja-ntv2-gst = self.packages.${prev.system}.aja-ntv2-gst;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
diff --git a/gst-plugin/aja/gstntv2.h b/gst-plugin/aja/gstntv2.h
|
||||||
|
index 53906e9..0e287df 100644
|
||||||
|
--- a/aja/gstntv2.h
|
||||||
|
+++ b/aja/gstntv2.h
|
||||||
|
@@ -23,8 +23,6 @@
|
||||||
|
#include "ajabase/common/timebase.h"
|
||||||
|
#include "ajabase/system/thread.h"
|
||||||
|
|
||||||
|
-#include "ntv2m31.h"
|
||||||
|
-
|
||||||
|
#define VIDEO_RING_SIZE 16
|
||||||
|
#define VIDEO_ARRAY_SIZE 60
|
||||||
|
#define AUDIO_RING_SIZE (3*VIDEO_RING_SIZE)
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
stdenv,
|
||||||
|
pkgs,
|
||||||
|
fetchFromGitHub,
|
||||||
|
ajantv2,
|
||||||
|
}:
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "aja-ntv2-gst";
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "aja-video";
|
||||||
|
repo = "ntv2-gst";
|
||||||
|
rev = "refs/heads/master";
|
||||||
|
hash = "sha256-90TdrsnO5LatLD4dwivOnZG4tGJmNs2tdAsrL7eQF8g=";
|
||||||
|
};
|
||||||
|
sourceRoot = "source/gst-plugin";
|
||||||
|
patches = [./no.patch];
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [autoconf automake pkgconfig libtool gst_all_1.gst-plugins-base ajantv2];
|
||||||
|
GST_NTV2 = "${ajantv2}/include";
|
||||||
|
preConfigure = ''
|
||||||
|
./autogen.sh
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in New Issue