Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blackmagic decklink: init pkg and module at 12.2 #102512

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4661,6 +4661,12 @@
githubId = 222664;
name = "Matthew Leach";
};
hexchen = {
hexchen marked this conversation as resolved.
Show resolved Hide resolved
email = "nix@lilwit.ch";
github = "hexchen";
githubId = 41522204;
name = "hexchen";
};
hh = {
email = "hh@m-labs.hk";
github = "HarryMakes";
Expand Down
17 changes: 17 additions & 0 deletions nixos/modules/hardware/decklink.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }:

with lib;

let
cfg = config.hardware.decklink;
kernelPackages = config.boot.kernelPackages;
in
{
options.hardware.decklink.enable = mkEnableOption "hardware support for the Blackmagic Design Decklink audio/video interfaces";

config = mkIf cfg.enable {
boot.kernelModules = [ "blackmagic" "blackmagic-io" "snd_blackmagic-io" ];
boot.extraModulePackages = [ kernelPackages.decklink ];
systemd.packages = [ pkgs.blackmagicDesktopVideo ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
systemd.packages = [ pkgs.blackmagicDesktopVideo ];
systemd.packages = [ pkgs.blackmagicDesktopVideo ];
systemd.services.DecklinkVideoHelper.wantedBy = [ "multi-user.target" ];

See #81138 for details.

Copy link
Member

@davidak davidak Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seem not to work yet.

[root@gaming:~]# lspci | grep Blackmagic
05:00.0 Multimedia video controller: Blackmagic Design Intensity Pro 4K
(this did work without the driver)
[root@gaming:~]# lsmod | grep blackmagic

[root@gaming:~]# systemctl status DecklinkVideoHelper
Unit DecklinkVideoHelper.service could not be found.

I do not see DesktopVideoHelper.service in /var/run/current-system/sw/lib/systemd/system:

[root@gaming:~]# ll /var/run/current-system/sw/lib/systemd/system | grep DesktopVideoHelper

I see the kernel modules in /var/run/current-system/kernel-modules/lib/modules/5.10.81/extra/:

[root@gaming:~]# ll /nix/store/x71rnsfknvga3hb7rhg3j889a0wc1cvn-nixos-system-gaming-22.05.git.aa691f07224/kernel-modules/lib/modules/5.10.81/extra/
total 1080
-r--r--r-- 1 root root 621372 Jan  1  1970 blackmagic-io.ko.xz
-r--r--r-- 1 root root 402860 Jan  1  1970 blackmagic.ko.xz
-r--r--r-- 1 root root  73992 Jan  1  1970 snd_blackmagic-io.ko.xz

};
}
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
./hardware/cpu/intel-microcode.nix
./hardware/corectrl.nix
./hardware/digitalbitbox.nix
./hardware/decklink.nix
./hardware/device-tree.nix
./hardware/gkraken.nix
./hardware/flirc.nix
Expand Down
49 changes: 49 additions & 0 deletions pkgs/os-specific/linux/decklink/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{ stdenv, lib, requireFile, fetchpatch, kernel }:

stdenv.mkDerivation rec {
pname = "decklink";
major = "12.2";
version = "${major}a12";

src = requireFile {
name = "Blackmagic_Desktop_Video_Linux_${major}.tar.gz";
davidak marked this conversation as resolved.
Show resolved Hide resolved
url = "https://www.blackmagicdesign.com/support/download/33abc1034cd54cf99101f9acd2edd93d/Linux";
sha256 = "62954a18b60d9040aa4a959dff30ac9c260218ef78d6a63cbb243788f7abc05f";
Copy link
Member

@davidak davidak Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sha256 = "62954a18b60d9040aa4a959dff30ac9c260218ef78d6a63cbb243788f7abc05f";
sha256 = "62954a18b60d9040aa4a959dff30ac9c260218ef78d6a63cbb243788f7abc05f";
message = ''
Please download the file manually from the developers website:
https://www.blackmagicdesign.com/support/download/33abc1034cd54cf99101f9acd2edd93d/Linux
They want you to register your product, but you can also download
the file without registration by clicking 'Download Only' in the
bottom left corner of the dialog.
Then add the downloaded file to the Nix store using:
nix-store --add-fixed sha256 Blackmagic_Desktop_Video_Linux_12.2.tar.gz
If you use Google Chrome or Chromium, you have to rename the
file to end with tar.gz first.
'';
# Chromium specific issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1275694
# Remove hint when fixed.

Those instructions seem helpful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In https://github.com/NixOS/nixpkgs/pull/152113/files is a script to download files from blackmagicdesign.com. Maybe that would work here too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It indeed works. Thanks for the pointer, I was finally able to implement that 1.5 years later...

};

KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
INSTALL_MOD_PATH = placeholder "out";

nativeBuildInputs = kernel.moduleBuildDependencies;

setSourceRoot = ''
tar xf Blackmagic_Desktop_Video_Linux_${major}/other/x86_64/desktopvideo-${version}-x86_64.tar.gz
sourceRoot=$NIX_BUILD_TOP/desktopvideo-${version}-x86_64/usr/src
'';

buildPhase = ''
runHook preBuild

make -C $sourceRoot/blackmagic-${version} -j$NIX_BUILD_CORES
make -C $sourceRoot/blackmagic-io-${version} -j$NIX_BUILD_CORES

runHook postBuild
'';

installPhase = ''
hexchen marked this conversation as resolved.
Show resolved Hide resolved
runHook preInstall

make -C $KERNELDIR M=$sourceRoot/blackmagic-${version} modules_install
make -C $KERNELDIR M=$sourceRoot/blackmagic-io-${version} modules_install

runHook postInstall
'';

meta = with lib; {
homepage = "https://www.blackmagicdesign.com/support/family/capture-and-playback";
maintainers = [ maintainers.hexchen ];
license = licenses.unfree;
description = "Kernel module for the Blackmagic Design Decklink cards";
platforms = platforms.linux;
};
}
55 changes: 55 additions & 0 deletions pkgs/tools/video/blackmagic-desktop-video/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{ stdenv, requireFile, lib,
libcxx, libcxxabi
}:

stdenv.mkDerivation rec {
pname = "blackmagic-desktop-video";
major = "12.2";
version = "${major}a12";

buildInputs = [
libcxx libcxxabi
];

src = requireFile {
name = "Blackmagic_Desktop_Video_Linux_${major}.tar.gz";
url = "https://www.blackmagicdesign.com/support/download/33abc1034cd54cf99101f9acd2edd93d/Linux";
sha256 = "62954a18b60d9040aa4a959dff30ac9c260218ef78d6a63cbb243788f7abc05f";
};

setSourceRoot = ''
tar xf Blackmagic_Desktop_Video_Linux_${major}/other/x86_64/desktopvideo-${version}-x86_64.tar.gz
sourceRoot=$NIX_BUILD_TOP/desktopvideo-${version}-x86_64
'';

installPhase = ''
hexchen marked this conversation as resolved.
Show resolved Hide resolved
runHook preInstall

mkdir -p $out/{bin,share/doc,lib/systemd/system}
cp -r $sourceRoot/usr/share/doc/desktopvideo $out/share/doc
cp $sourceRoot/usr/lib/*.so $out/lib
cp $sourceRoot/usr/lib/systemd/system/DesktopVideoHelper.service $out/lib/systemd/system
ln -s ${libcxx}/lib/* ${libcxxabi}/lib/* $out/lib
cp $sourceRoot/usr/lib/blackmagic/DesktopVideo/libgcc_s.so.1 $out/lib/
cp $sourceRoot/usr/lib/blackmagic/DesktopVideo/DesktopVideoHelper $out/bin/

substituteInPlace $out/lib/systemd/system/DesktopVideoHelper.service --replace "/usr/lib/blackmagic/DesktopVideo/DesktopVideoHelper" "$out/bin/DesktopVideoHelper"

runHook postInstall
'';
hexchen marked this conversation as resolved.
Show resolved Hide resolved


postFixup = ''
patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} \
--set-rpath "$out/lib:${lib.makeLibraryPath [ libcxx libcxxabi ]}" \
$out/bin/DesktopVideoHelper
'';

meta = with lib; {
homepage = "https://www.blackmagicdesign.com/support/family/capture-and-playback";
maintainers = [ maintainers.hexchen ];
license = licenses.unfree;
description = "Supporting applications for Blackmagic Decklink. Doesn't include the desktop applications, only the helper required to make the driver work.";
platforms = platforms.linux;
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,8 @@ with pkgs;

bklk = callPackage ../applications/misc/bklk { };

blackmagicDesktopVideo = callPackage ../tools/video/blackmagic-desktop-video { };

bkyml = callPackage ../tools/misc/bkyml { };

blockbench-electron = callPackage ../applications/graphics/blockbench-electron { };
Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/linux-kernels.nix
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ in {

ddcci-driver = callPackage ../os-specific/linux/ddcci { };

decklink = callPackage ../os-specific/linux/decklink { };

digimend = callPackage ../os-specific/linux/digimend { };

dpdk-kmods = callPackage ../os-specific/linux/dpdk-kmods { };
Expand Down