NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.17k stars 13.43k forks source link

Kodi + raspberrypi3 + hw acceleration #53124

Open domenkozar opened 5 years ago

domenkozar commented 5 years ago

I've played around trying to get it to work, but it seems that raspberrypi firmware doesn't ship 64bit blobs so it can't work on aarch64.

diff --git a/pkgs/applications/video/kodi/default.nix b/pkgs/applications/video/kodi/default.nix
index 9272d3c8e26..c88343b1d16 100644
--- a/pkgs/applications/video/kodi/default.nix
+++ b/pkgs/applications/video/kodi/default.nix
@@ -16,7 +16,7 @@
 , sqlite, mysql, nasm, gnutls, libva, libdrm, wayland
 , curl, bzip2, zip, unzip, glxinfo, xdpyinfo
 , libcec, libcec_platform, dcadec, libuuid
-, libcrossguid, libmicrohttpd
+, libcrossguid, libmicrohttpd, raspberrypifw
 , bluez, doxygen, giflib, glib, harfbuzz, lcms2, libidn, libpthreadstubs, libtasn1, libXdmcp
 , libplist, p11-kit, zlib
 , dbusSupport ? true, dbus ? null
@@ -167,6 +167,17 @@ in stdenv.mkDerivation rec {
       "-DENABLE_INTERNAL_CROSSGUID=OFF"
       "-DENABLE_OPTICAL=ON"
       "-DLIRC_DEVICE=/run/lirc/lircd"
+      "-DPLATFORM=rbpi"
+      "-DCORE_SYSTEM_NAME=rbpi"
+      "-DCMAKE_PREFIX_PATH=${raspberrypifw}/vc"
+      "-DWITH_ARCH=arm"
+      "-DENABLE_VAAPI=OFF"
+      "-DENABLE_OPENGL=OFF"
+      "-DENABLE_X11=OFF"
+      "-DENABLE_VDPAU=OFF"
+      "-DENABLE_EVENTCLIENTS=ON"
+      "-DCPU=cortex-a53"
+      "-DENABLE_INTERNAL_CROSSGUID=ON"
     ];

     enableParallelBuilding = true;
diff --git a/pkgs/os-specific/linux/firmware/raspberrypi/default.nix b/pkgs/os-specific/linux/firmware/raspberrypi/default.nix
index 8965e5d60d7..d06823130a4 100644
--- a/pkgs/os-specific/linux/firmware/raspberrypi/default.nix
+++ b/pkgs/os-specific/linux/firmware/raspberrypi/default.nix
@@ -14,6 +14,9 @@ stdenv.mkDerivation rec {
   installPhase = ''
     mkdir -p $out/share/raspberrypi/boot
     cp -R boot/* $out/share/raspberrypi/boot
+
+    mkdir -p $out/vc
+    cp -R opt/vc/* $out/vc
   '';

   meta = with stdenv.lib; {

There's also an issue with compilation, but that can probably be fixed with a simple cast patch.

For upstream work on 64bit hw accel see https://github.com/raspberrypi/firmware/issues/550?fbclid=IwAR14Z4nQFJwvt8TYp44HaSCdA949oBn1oDRcKmTQ3af8FMviD_IaaLvOaTU#issuecomment-450623596

Note that this will also require bumping kodi to 18 with ffmpeg, etc.

domenkozar commented 4 years ago

Upstream now supports 64bit passing arm_64bit=1 to config.txt

Only need to bump kernel and give it a try.

purcell commented 4 years ago

Hey! Thanks for sharing what you discovered. I've been looking at this myself, for a Pi 4, and I was hoping to get hardware acceleration of encoding/decoding in ffmpeg by enabling MMAL and OMX. Turns out what I tried was similar to the above, in order to link with the corresponding userland .so, only to discover - like you - that all those userland libs are 32-bit only. That seems to be the case even with the latest versions, so I'm guessing that the only acceleration that will be available under NixOS aarch64 will be via V4L2. I've got the vc4-fkms-v3d.dtbo device overlay enabled but it doesn't seem to offer any superpowers to ffmpeg-full afaict.

It's all a bit confusing and disappointing, really: the people claiming full support for accelerated h264, h265 and HEVC encoding/decoding appear to be running 32-bit kernels with the 32-bit userland libs, plus versions of ffmpeg / vlc / kodi etc. compiled with support for apparently-outdated acceleration methods and linked to those userland libs. Trying really hard to avoid resorting to Raspbian. :-)

Only need to bump kernel and give it a try.

What would be the process for this? There's a 5.x kernel now, and the stuff in the firmware repo is a mix of 5.x and 4.x stuff from what I can see. I expect they have to match up to some extent.

purcell commented 4 years ago

It's all a bit confusing and disappointing, really

In case it's not clear, I'm ranting a bit about the Pi ecosystem here, not NixOS. 😄

purcell commented 4 years ago

Also, I came across a great summary of the situation with hardware encoding/decoding on the Rpi4, which others might find helpful.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info