Jump to content
  • 0

4kp30 video on Orange Pi Lite and mainline hardware acceleration


genesys
 Share

Question

I‘m using an OrangePi Lite with the intent to display a 4kp30 video to a 4k TV over hdmi.

 

from reading through the forums I saw that mainline kernel does not support video acceleration - is this information current?

 

after installing the Xenial Image with 3.4 kernel I manage to play 1440p video smoothly two ways with mpv:

 

- windowed if display resolution is set to 4k

-fullscreen if display resolution is set to 1080p

 

if I try to run the 1440p video at 4k display resolution in fullscreen, the app crashes with messages about ‚not enough resources to create surface‘ and the framebuffer stays corrupted after that and I have to reboot.

 

The same happens if I try to play the 4k30p video (independently of whether I run it fullscreen or windowed, 4k or 1080p display res. I also tried both h264 and h265).

 

I Played around with extraargs=cma=... sunxi_ve_mem_reserve=... in ArmbianEnv.txt but it didn‘t seem to have effect. The docs state that in the 3.4 kernel the video memory is hardcoded to 80MB (not sure if I understood that correctly though) which probably would prevent 4k playback with that kernel.

 

on https://linux-sunxi.org/Cedrus/libvdpau-sunxi it's stated that:

This can be set by the following kernel argument.

sunxi_ve_mem_reserve=128
NOTE: This kernel parameter is ignored in recent linux-sunxi 3.4 kernels, if CMA is enabled in kernel configuration. If CONFIG_CMA=y, ve_size is hardcoded to 80MB in sunxi_cedar kernel module.

For A33 or H3, if you use the kernel from official SDK, you should modify the memory reservation configuration of ion memory allocator. 32 MB seems to be enough for 720p H.264 decoding, and 64MB is enough for 1080p H.264 decoding.

But I don't know what it means to modify the memory reservation configuration of ion memory allocator and how to do that?

 

Is there any kernel available which can playback hardware accelerated 4k30p video on Orange Pi Lite (H3) and if so, how do I need to go about to setup my Xenial installation to make use of it?

Link to comment
Share on other sites

Recommended Posts

Open source development is fun. Join Armbian Linux development team today!

  • 0

@ubobrov, 

Thanks for the work on https://github.com/uboborov/sunxi-cedar-mainline

it works pretty good on 4.20.17.

To install it on mainline Armbian ( 5.4.16+), follow the dts patch, 

when the kernel module installed, it showed 

"could not assign reserved memory" in dmesg.

This message comes from "of_reserved_mem_device_init"

do you have any clue ?

 

 

Link to comment
Share on other sites

  • 0

that happens because of the kernel you're using.

be careful with the node:

reserved-memory {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		cma_pool: cma@43c00000 {
			compatible = "shared-dma-pool";
			reusable;
			reg = <0x43c00000 0x6000000>;
			linux,cma-default;
		};
	};

it should look like above.

to check everything is alright with the CMA, you should check CMA on kernel boot:

 dmesg | grep CMA
[    0.000000] Reserved memory: created CMA memory pool at 0x43c00000, size 96 MiB

it must look like above

good luck

Link to comment
Share on other sites

  • 0

Thanks @ubobrov,  tried but did not see dmesg reporting CMA,  do you think there is anything conflicted  

with the built-in Cedrus driver in menuconfig ?  my platform is nanopi-duo2 of 512M.  

 

--- Media staging drivers                                                 │ │

  │ │    [*]   Allwinner sunXi family Video Devices                                │ │

  │ │    <M>     Allwinner Cedrus VPU driver                                       │ │

  │ │          *** soc_camera sensor drivers ***

 

Also, may I know the reason cma change from cma@4a000000 to cma@43c00000 at kernel 5.4.

Link to comment
Share on other sites

  • 0

response my post , also to @ubobrov,

I found that node reserved-memory should be outside of SOC, 

after fixing it , the CMA creating works now.

But when installing the sunxi_cedar.ko, it reports 

"sunxi-cedar 1c0e000.video-engine: syscon failed..."

I found the syscon entry is different inside sun8i-h3.dtsi at kernel 5.4.16.

 

Link to comment
Share on other sites

  • 0

  

1 minute ago, andydj said:

Hi , hardware encoding is possible on a H6 board whit mainline kernel ? My board is an orange pi one plus

 

 

Well the module is enabled in sunxi-dev. Just give it  a try.

Link to comment
Share on other sites

  • 0

Decoding H264 and X11 rendering using vdpau_sunxi, libcedrus, kernel 4.20.17, mpv, vncserver and Armbian Bionic on Orange PI Zero

libvdpau: https://github.com/uboborov/libvdpau-sunxi-H3.git

libcedrus: https://github.com/uboborov/libcedrus-H3.git

cedar_dev: https://github.com/uboborov/sunxi-cedar-mainline.git

 

mpv, ffmpeg, x11 installed using apt

 

It works extremely slow but it's just a beginning  )

video: https://www.youtube.com/watch?v=9O7L_kaEDdk

UPD:

video on Orange PI One 1280x720 HDMI (works pretty fine)

https://www.youtube.com/watch?v=8qPyOG-yJIw

 

Link to comment
Share on other sites

  • 0
On 4/23/2020 at 5:46 AM, Werner said:

I think you can use armbian-config to switch kernel branch to dev and you should get an Linux 5.6.5 kernel which should have cedrus module shipped with.

When i try ti update kernel , i got this message

 

Test install failed. Can't change firmware

Link to comment
Share on other sites

  • 0
9 minutes ago, andydj said:

When i try ti update kernel , i got this message

 

Test install failed. Can't change firmware

I just noticed you don't even have to go to dev branch. In current it is enabled already. If your 5.4.x-current kernel is halfway up-to-date you should be able to modprobe cedrus.

Link to comment
Share on other sites

  • 0
15 hours ago, ubobrov said:

Decoding H264 and X11 rendering using vdpau_sunxi, libcedrus, kernel 4.20.17, mpv, vncserver and Armbian Bionic on Orange PI Zero

libvdpau: https://github.com/uboborov/libvdpau-sunxi-H3.git

libcedrus: https://github.com/uboborov/libcedrus-H3.git

cedar_dev: https://github.com/uboborov/sunxi-cedar-mainline.git

 

mpv, ffmpeg, x11 installed using apt

 

It works extremely slow but it's just a beginning  )

video: https://www.youtube.com/watch?v=9O7L_kaEDdk

 

 

you enable legacy driver in mainline kernel... great job.

Link to comment
Share on other sites

  • 0
30 minutes ago, Werner said:

I just noticed you don't even have to go to dev branch. In current it is enabled already. If your 5.4.x-current kernel is halfway up-to-date you should be able to modprobe cedrus.

Modulo cedrus not found in ...../5.4.28-sunxi64

 

I think i have to move in h6 board forum

Link to comment
Share on other sites

  • 0
5 minutes ago, andydj said:

Modulo cedrus not found in ...../5.4.28-sunxi64

 

 

Check apt-cache search linux-image | grep sunxi

I think there should be a newer image available. It is definitly enabled:https://github.com/armbian/build/blob/887ef462fc18a6b91050a1bb1dd46b0e6114087f/config/kernel/linux-sunxi-current.config#L5602

 

Quote

I think i have to move in h6 board forum

Not sure how the H6 forums would help in this case since the the OPi Lite is based on the H3.

Link to comment
Share on other sites

  • 0

Hi there! Im not familiar with linux systems, but can someone explain me - why  libreelec build for orangepi works fine on opi lite even with 1080 videos, when kodi on last armbian lags and uses only cpu time? 

Link to comment
Share on other sites

  • 0

Simple, LibreELEC heavily patches kernel and ffmpeg for better experience. Patches are slowly getting in kernel but ffmpeg patches will need far more time to be accepted (kernel must first declare this API stable which won't happen anytime soon). You also need Kodi master (e.g. Kodi 19 pre-alpha), because it has a lot of important improvements. Last but not least, only Kodi GBM (e.g no desktop environment) version really works well (zero copy playback) and soon wayland. X11 has no chances to work well.

 

TL;DR: LibreELEC uses features which are in development and not present in any stable version yet.

 

BTW, also 4K HEVC videos work well.

Link to comment
Share on other sites

  • 0
16 hours ago, jernej said:

Simple, LibreELEC heavily patches kernel and ffmpeg for better experience.

 

16 hours ago, jernej said:

Last but not least, only Kodi GBM (e.g no desktop environment) version really works well (zero copy playback) and soon wayland. X11 has no chances to work well.

sounds too hard for me lol. but thanks for explanation anyway!

Link to comment
Share on other sites

  • 0

@ubobrov Really big thanks, I have spend a lot of time to force Orange Pi Zero encode video with no luck. With you instruction I got a chance to make it works. Tried to do the same as you wrote step-by-step carefully, but kernel module fails with the error in `dmesg`:

```
[    0.000000] Reserved memory: created CMA memory pool at 0x4a000000, size 96 MiB
...
[ 1948.521206] sunxi_cedar: loading out-of-tree module taints kernel.
[ 1948.522324] sunxi cedar version 0.1 
[ 1948.522598] [cedar]: install start!!!
[ 1948.522768] cedar_ve: cedar-ve the get irq is 40
[ 1948.522798] sunxi-cedar 1c0e000.video-engine: assigned reserved memory node cma@4a000000
[ 1949.529005] alloc_contig_range: [4a100, 4f100) PFNs busy
[ 1949.531714] alloc_contig_range: [4a200, 4f200) PFNs busy
[ 1949.533825] alloc_contig_range: [4a200, 4f300) PFNs busy
[ 1949.535770] alloc_contig_range: [4a400, 4f400) PFNs busy
[ 1949.537915] alloc_contig_range: [4a400, 4f500) PFNs busy
[ 1949.540066] alloc_contig_range: [4a400, 4f600) PFNs busy
[ 1949.542753] alloc_contig_range: [4a400, 4f700) PFNs busy
[ 1949.544955] alloc_contig_range: [4a800, 4f800) PFNs busy
[ 1949.547059] alloc_contig_range: [4a800, 4f900) PFNs busy
[ 1949.549338] alloc_contig_range: [4a800, 4fa00) PFNs busy
[ 1949.563811] cma: cma_alloc: alloc failed, req-size: 20480 pages, ret: -16
[ 1949.563843] sunxi-cedar 1c0e000.video-engine: cedar: failed to allocate memory buffer
```

 

Could you please tell the direction in which to dig? Thanks.
 

Link to comment
Share on other sites

  • 0

Your problem is in Pi Zero's memory. To make driver loaded without errors you should load it on startup.

#! /bin/sh

### BEGIN INIT INFO
# Provides:          cedrus
# Required-Start:    $syslog
# Required-Stop:     $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

/sbin/insmod /lib/modules/sunxi_cedar.ko

exit 0

 

Link to comment
Share on other sites

  • 0
On 8/15/2020 at 4:19 AM, marine1988 said:

Hi there for a noob guy is it possible to install the armbian witth hw deconding working on kodi just like on raspberry or i need to do all this stuff? Im don´t know how to compile!

If you only want to use Kodi, take a look at LibreElec: https://forum.libreelec.tv/thread/17565-nightly-images-for-a20-a64-h3-h5-and-h6-boards/

It's got more hardware decoding features than mainline or Armbian thanks to various custom patches for both the kernel and Kodi, but it doesn't do anything other than run Kodi.

Link to comment
Share on other sites

  • 0

Note that ffmpeg patches for request API are important - without patched ffmpeg, all kernel patches have no meaning. Second important thing is that LibreELEC runs Kodi without X11 for ARM boards - this allows to use display more efficiently. On X11 it would be needed to render video through GPU which is less efficient. Note that I never actually tried that.

Link to comment
Share on other sites

  • 0
21 hours ago, jernej said:

Note that ffmpeg patches for request API are important - without patched ffmpeg, all kernel patches have no meaning. Second important thing is that LibreELEC runs Kodi without X11 for ARM boards - this allows to use display more efficiently. On X11 it would be needed to render video through GPU which is less efficient. Note that I never actually tried that.

Am I understanding it correctly that it works as follows?

LibreElec patches the kernel to make use of the SoC's VPU. (Some of these patches make their way upstream eventually, but that's a slow process.) It also forks ffmpeg, which is patched to recognise these new kernel features & to make use of them. Kodi then refers to ffmpeg to access them.

What would be necessary for players other than Kodi—mpv or VLC for example—to benefit from this as well? And what is the role of libva, VAAPI, and these other things in this process?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...