How-To, non-X11: Get 4K (>2560x1600) framebuffer, DRM, GBM, Kodi on HDMI
#1
Lightbulb 
This is not about X11/xorg, this is text mode/framebuffer stuff only.
You should be at an init level that doesn't have X running.
Sorry, I don't actually know if this will mess up your X configuration as I do not use X.

I've cut down all the steps for brevity; one should know how to compile kernels and move around the system already, etc.

EDIT: THIS IS THE WRONG WAY TO DO THIS.
THE CORRECT WAY IS TO SET THE DTS TO USE "VOPB" INSTEAD OF "VOPL", *NOT* FORCING VOPL TO USE A HIGHER OUTPUT RES.
I WILL REPLACE THE FOLLOWING STEPS WITH THE CORRECT FIX ASAP:

1) Grab the source to your current ayufan kernel
(I'm using linux-kernel-4.4.138-1094-rockchip-ayufan in this demo)
2) tar xf linux-kernel-4.4.138-1094-rockchip-ayufan.tar.gz
3) cd linux-kernel-4.4.138-1094-rockchip-ayufan/drivers/gpu/drm/rockchip
4) Use your favorite editor on rockchip_vop_reg.c
5) Now change the hardcoded limit for rk3399_vop_lit.
Find the vop_data struct for rk3399_vop_lit which starts with this text:  static const struct vop_data rk3399_vop_lit {
The property to find and edit within that struct  is:  .max_output = {2560, 1600}
6) I changed my max_output to this:  .max_output = {3840, 2160}
7) Then I recompiled the kernel. For me, that's: make all modules modules_install dtbs_install firmware_install headers_install install -j6
8) Then I manually clean up the mess that postinst.d makes within /boot/extlinux/extlinux.conf
(I literally delete all the lines except for the timeout, menu, label, kernel, initrd, devicetreedir, and append lines for this kernel I just installed)

Worked instantly when I rebooted into the new kernel.
Framebuffer came up in 4K mode and it was GIANT!
Then, when I launched Kodi (which I compiled for DRM with GBM), I was able to whitelist my TV's 4K resolutions (which were never listed before) or even switch the interface to use 4K (I don't suggest doing that) and when I go to play a 4K video, it switches resolution to 4K.

rkmpv at the command line now also switches to 4K resolution for me!

Next up would be for one of us to get some of the VPU pieces working and the rkmpp kernel side working so that 4K and HEVC/x265 videos stop dropping frames.
#2
A follow-up - I got RKMPP hardware acceleration codec working on my system right after this.

WARNING: Your system could crash if you edit your DTB, please back up everything that you edit and leave yourself a way to go back.
* I'm using 4.4.138-1100 now
* Note: I previously deleted every bit of PCIE out of my DTB (and turned off the rockchip pcie phy kernel driver) before making the following change, so your mileage may vary.
* I ran dtedit and set "status = 'okay'" for the RGA, VPU, and RKVDEC objects and rebooted and they WORKED.
(RKVDEC is the most important one.)

Now when I use rkmpv, it decodes HEVC/x265 using the RKMPP codec and I was able to finally play this 4K music video I have that constantly drops frames. Now it doesn't drop any!
#3
Great to hear you're having success! As a test for us, in KODI, when you play back Big Buck Bunny at 60fps, does the audio and video stay in sync or do they start to be out of sync? Any change if you run via CLI? I haven't yet seen a patch or a kernel update that fixes this, and I believe I've also done these steps you've outlined. Would be awesome if you find you have no a/v sync issues on this particular video, as it's an excellent test.
#4
Once I got RKMPP working for everything, Kodi turns out to be the only thing that DOESN'T use it.
So Kodi still plays videos for me the same way as before, which is to say, without codec assistance, terribly.

4K videos skip hundreds of frames per minute, and 1080 HEVC videos skip 1 or 2 frames every second or two.

But if I make kodi shell out to external player mpv, it plays fine because mpv supports rkvdec (but then I can't control mpv while kodi is running - keyboard/mouse input still go to kodi-gbm process instead of newly spawned mpv process).
Some more effort is needed.

I need to figure out how come my ffmpeg with rkmpp support isn't helping Kodi at all, especially since I don't want to shell out to an external player just to watch 1080p videos without framerate issues. I must have built my Kodi wrong.
#5
Hmm, sounds like you're on the right track!! So good job!

Just so some of us can test as well and stay on the same page, what's the command at CLI you're using to run the 4K 60fps with rkmpp without any AV sync issues?

If you reference LibreElec's KODI patches for Rockchip you'll find a good handful to help. Everything plays acceleratored but still doesn't do 60fps at 4K HDR without falling out of sync.
#6
I have not yet tested Big Buck Bunny, was not aware of that as a thing, but now I am.
I will download it tonight and see if the rockpro64 can handle it!

---

rkmpv is an included script in the ayufan images that launches mpv for you with the proper switches on the end.

I edit that script and add my own enhancements/changes.

do this:


Code:
cat `whereis rkmpv`


That will show you what is passed to mpv.
I am remote and can't see mine right now to tell you, so if you cat that script you'll get it.


I also edited the LD library path line in there and removed the '/gbm' part from the end of the path because that wasn't right for my setup.
(My mali libs are not inside sub-directory "gbm" because I don't need multi-lib here)

The part that most people don't have activated is rkvdec, which is disabled in all of the ayufan kernels I've tried so far.
If you do not have rkvdec enabled, then your rkmpv will perform exactly as you described.
If you DO have rkvdec enabled, then your rkmpv should not lose any frames, even at 3840x2160@60.


Enable rkvdec by editing the DTB, then you can use rkmpv.
#7
https://forum.kodi.tv/showthread.php?tid...pid2319272

Apparently one just needs to build kodi using: --with-ffmpeg=shared

I already built my ffmpeg to use rkmpp (so did ayufan) so this should theoretically make my videos accelerate using rkvdec/rkmpp.
Kodi takes like 45 minutes to build so I'll try that sometime this week if I get a chance.
#8
Thanks for providing all this details to folks! Smile I've got my own build with a custom kernel compiled with patches and modified DTS to enable all the hardware video decoding, including rkmpp and KODI all built. Unfortunately, 60fps still has large av sync issues. Looking forward to hearing if you have more luck!
#9
Okay, recompiling Kodi fixed it.
Now kodi also plays videos without stuttering.
Haven't downloaded Big Buck Bunny yet, wireless not so stable, will have to transfer it manually another time.
But all my videos that were stuttering are no longer dropping any frames at all.

I played a 4K video from kodi-gbm while compiling advance mame from a remote SSH session using 6 parallel jobs ("-j6") and it didn't stutter the video even once!

- - -

When I first compiled kodi 18rc1, it kernel paniced in the DRM driver, so I went back to 18.0b5.
Then 18.0rc2 came out, but same thing - kernel panic in DRM when I tried to launch it.
I am currently only able to build 18.0b5.



Here's what I run to build kodi 18.0b5. This is assuming you ALREADY have EVERY needed dependency installed ("package" and/or "package-dev" version(s)).
 I used "apt install" to install literally every dependency and library except for flatbuffers I think. I didn't make a list, but I should have, and will one day.
But anyway, ayufan's repository has 99% of the needed packages.
When doing the very first cmake step below, it will tell you if it can't find things, you can 'apt install' whatever is missing if you understand the package naming conventions.
The second cmake line can also tell you about missing items through undefined references, but it's harder to interpret. Still, I was successful. I'll definitely have to make that whole 'apt install' list to help this out.

Also, personally, I am NOT building it for X11 at all; GBM only. Your mileage may vary if you do something different, etc.

Code:
cd /home/rock64/
mkdir kodi-build

wget https://github.com/xbmc/xbmc/archive/18.0b5-Leia.tar.gz
tar xf 18.0b5-Leia.tar.gz
mv xbmc-18.0b5-Leia kodi

cd kodi-build
cmake -j10 ../kodi -DCMAKE_INSTALL_PREFIX=/usr/local -DCORE_PLATFORM_NAME=gbm -DGBM_RENDER_SYSTEM=gles -Dwith-ffmpeg=shared -Ddisable-x11=true
cmake --build . -- VERBOSE=0 -j10
make install

cd ../kodi
make -j10 -C tools/depends/target/binary-addons PREFIX=/usr/local
#10
Hi thanks for quick guide, Im interested in trying out your method but im stuck at this comand:

cmake --build . -- VERBOSE=0 -j10

get:

make: *** No targets specified and no makefile found.  Stop.

Tried looking for it, and I cant find it, obviously im missing something. Would love to see if once built it works.


Possibly Related Threads…
Thread Author Replies Views Last Post
  RockPro64 - HDMI and higher resolutions PakoSt 0 1,609 11-16-2021, 03:48 PM
Last Post: PakoSt
  OMV to Kodi Streaming Issues cogito808 12 18,966 05-25-2021, 08:30 AM
Last Post: helpmerock
  RockPro64 Linux Manjaro HDMI 4K mkne 12 16,470 05-03-2020, 07:23 AM
Last Post: PakoSt
  Debian, Kodi and the Spotify plugin. Pineapple 1 3,186 10-14-2019, 10:02 PM
Last Post: SBCraok
  Linux distro that will work with Kodi? SBCraok 9 13,390 09-18-2019, 02:12 AM
Last Post: mtrcycllvr
  Does anyone have kodi working? blahblahblah 6 8,281 07-19-2019, 08:09 AM
Last Post: PackElend
  issue with kodi freezing randomly Slam 3 4,432 05-24-2019, 03:53 PM
Last Post: mknawabi
  HDMI audio solved yoramro 2 6,041 01-29-2019, 10:01 PM
Last Post: fczuardi
  kodi and /dev/rkdev catalinii 0 2,595 08-09-2018, 10:38 PM
Last Post: catalinii

Forum Jump:


Users browsing this thread: 2 Guest(s)