mainline kernel hardware acceleration - Printable Version +- PINE64 (https://forum.pine64.org) +-- Forum: Pinebook Pro (https://forum.pine64.org/forumdisplay.php?fid=111) +--- Forum: Linux on Pinebook Pro (https://forum.pine64.org/forumdisplay.php?fid=114) +--- Thread: mainline kernel hardware acceleration (/showthread.php?tid=9171) |
RE: mainline kernel hardware acceleration - xmixahlx - 04-20-2020 fyi you can apply rkvdec h264 and vp9 kernel patches to 5.7-rcX. rk3399 is currently dependent upon improved vaapi and v4l2 solutions for any media decoding to be utilized by chromium or firefox. firefox 75 (and improved in 76) DOES allow for vaapi on wayland, and this seems to be the most likely early testbed, but dependent on the comment above. RE: mainline kernel hardware acceleration - xmixahlx - 05-15-2020 an update: kwiboo has added hevc/h265 decoding to rkvdec and is available in his linux-rockchip and ffmpeg repositories. with the two rk3399 vpu decoders (hantro, rkvdec) this means we have the following hardware decoding support: hantro: mpeg2, vp8, h264 rkvdec: h264, h265, vp9 both hantro and rkvdec support h264 decoding, but hantro is limited to 1080p. rkvdec is the better solution. all hardware decoders roughly require 50% compute power of one of the big cores. ffmpeg works directly with v4l2-request api i.e. vaapi and libva-v4l2-request are not utilized. a desktop solution for improved firefox and chrome support requires improved vaapi handling, likely building upon ph5's libva hantro work. vaapi support already exists in firefox on wayland with v75 (h264) and expanded with v76 (all). if you want to test this yourself i am using tsys 5.7-rc2 patched to rc5 + LibreElec pull requests for 5.6 support (only including next/list), plus hevc specific patches for linux-rockchip and ffmpeg with something like: ffmpeg -report -re -hwaccel drm -hwaccel_device /dev/dri/card0 -i $FILE -pix_fmt bgra -f null - RE: mainline kernel hardware acceleration - xmixahlx - 05-16-2020 @termac from the mainline kernel thread Quote:... i tried my hands on getting hardware decoding working, for that I added the rkvdec kernel patches from https://patchwork.kernel.org/project/lin...ter=179601 and patched libva and libva-v4l2-request as per Your instructions in the other thread. vainfo still would only show support for MPEG2. At that point I did give up. So now it is either waiting for full mainline support or have enough time and motivation to figure out where I went wrong.vainfo will display a single media decoder module, and it defaults to /dev/video0 or whatever you have set as LIBVA_V4L2_REQUEST_VIDEO_PATH (see first few posts). since rk3399 has two (hantro and rkvdec) you need to select them with vainfo separately. with mpeg2 you are seeing hantro. check devices with v4l2-ctl --list-devices. check each device with v4l2-ctl -d /dev/video# --all. it's notable that ffmpeg currently doesn't list the v4l2request hwaccel decoders in runtime ((ffmpeg -decoders|grep v4l2), but does list v4l2request codecs as detected during build. it's also notable that these patches handle drm hwaccel because that is what LibreElec uses for kodi. kernel patch info: Kwiboo's LibreElec Rockchip 5.6 patches and pull request: https://github.com/Kwiboo/LibreELEC.tv/tree/rk-5.6/projects/Rockchip/patches/linux/default https://github.com/LibreELEC/LibreELEC.tv/pull/4377 Kwiboo hevc kernel repo branch: https://github.com/Kwiboo/linux-rockchip/tree/v4l2-5.6-from-list-v5.6.6 https://github.com/Kwiboo/linux-rockchip/tree/v4l2-5.6-from-list-v5.6.6-hevc make a diff of these two above repositories (exclude=.git exclude=sunxi) Kwiboo's ffmpeg branch supporting rkvdec: https://github.com/Kwiboo/FFmpeg/tree/v4l2-request-hwaccel-4.2.2-rkvdec build: ./configure --prefix=/usr/local --libdir=/usr/local/lib/aarch64-linux-gnu --shlibdir=/usr/local/lib/aarch64-linux-gnu --enable-shared --enable-pic --enable-v4l2-request --enable-libdrm --enable-libudev && make -j6 && sudo make install pbp linux 5.7-rc5 hwaccel patch sequence: tsys 5.7.0-rc2 branch 5.7.0-rc3 incremental patch 5.7.0-rc4 incremental patch 5.7.0-rc5 incremental patch LibreElec 002, 0012, 0013, 0021, 0022, 1000 patches Kwiboo hevc patch RE: mainline kernel hardware acceleration - termac - 05-17-2020 (05-16-2020, 06:40 PM)xmixahlx Wrote: vainfo will display a single media decoder module, and it defaults to /dev/video0 or whatever you have set as LIBVA_V4L2_REQUEST_VIDEO_PATH (see first few posts). since rk3399 has two (hantro and rkvdec) you need to select them with vainfo separately. with mpeg2 you are seeing hantro. check devices with v4l2-ctl --list-devices. check each device with v4l2-ctl -d /dev/video# --all. Thanks for pointing that out. I only checked video0 and video1. With LIBVA_V4L2_REQUEST_VIDEO_PATH=/dev/video4 I get: Code: $>vainfo Code: $>v4l2-ctl -d /dev/video4 --all To me that seems like from the driver and v4l2 side everything is in place. I tried playing video with mpv (unpatched) and the --hwdec options "vaapi" and "v4l2m2m-copy". In the first case I get no error, but the playback drops quite alot of frames and in the second case I get the error Code: [ffmpeg/video] h264_v4l2m2m: Could not find a valid device So maybe I am just missing a patched ffmpeg now. I will give that a try next. If that does not work out, I will try the exact patches You listed, as currently I have gotten here using the patches mentioned in the quote from the other thread. Thank You for looking into it! (05-16-2020, 06:40 PM)xmixahlx Wrote: pbp linux 5.7-rc5 hwaccel patch sequence: RE: mainline kernel hardware acceleration - xmixahlx - 05-17-2020 confirmed kodi-gbm from git supports all hantro and rkvdec codecs flawlessly. significantly less processing power is required even compared to ffmpeg drm hwaccel testing (50% of ~1 core, but multithreaded using small cores, so 1-7% total cpu during playback. example decoding (total cpu %) of a x265 1080p file: ffmpeg sw decoding = 60% total cpu ffmpeg drm hwaccel = 7% total cpu kodi-gbm drm+gles hwaccel = 2% total cpu i've added a kodi-git build script in another thread: https://forum.pine64.org/showthread.php?tid=9877 RE: mainline kernel hardware acceleration - xmixahlx - 05-17-2020 also: @termac vaapi is only working with mpeg2 as far as i can tell. it was one of the first tests months ago. RE: mainline kernel hardware acceleration - AndreVallestero - 05-21-2020 @xmixahlx Just a headsup, Armbian has an active thread for trying to get all the patches together and into mainline: https://forum.armbian.com/topic/13622-mainline-vpu/?tab=comments. I mentioned this post in that thread so they might be able to learn from your work. RE: mainline kernel hardware acceleration - xmixahlx - 05-21-2020 excellent. i'll jump over there, too. some random updates: ffmpeg 4.2.3 working with v4l2-request-hwaccel-4.2.2-rkvdec patch (4.2.2 diff) x265 10bit hwaccel is working NOT working: vp9 10/12 bit, h264 10bit, h265 12bit h264 10bit gives kernel hard lock jellyfin-kodi is working kodi-youtube is wip updated the first post with most relevant info added the armbian thread RE: mainline kernel hardware acceleration - xmixahlx - 05-26-2020 h264 10bit hwaccel now working thanks to kwiboo. see his recent linux-rockchip and ffmpeg repo branches. RE: mainline kernel hardware acceleration - termac - 05-31-2020 @xmixahlx On the armbian forum thread you wrote: (05-26-2020, 08:03 AM)xmixahlx Wrote: confirmed x264 10bit hwaccel is working. thanks so much, @Kwiboo I can't figure out against what to diff the two branches "linuxtv WIP" and "drm-next". Just to make sure: "linuxtv WIP" == "linuxtv-rkvdec-work-in-progress" and "drm-next" == "next-20200501-drm-rockchip"? It seems I would only need the most recent commits. Using the common ancestor of the two branches e51759f56d314d28c25be7606b03791f048e44c7 seems too far back, as I get a diff that does not apply cleanly against 5.7-rc7 with the librelec rochchip patches applied. For the librelec patches I used Code: linux-0002-rockchip-from-next.patch |