-
Notifications
You must be signed in to change notification settings - Fork 23
Mali Opengl on the libretech cc s905x using GBM with LibreELEC Kodi
Author: Neil Armstrong
This technical note is focused on enabling the opengl acceleration provided by the mali on the libretech-cc s905x, within the LibreELEC distribution enabling the GBM OpenGL interface with Kodi.
The GBM (Graphic Buffer Management) API is a thin layer over DRM KMS (Linux Direct Rendering Manager - Kernel ModeSetting API) to handle the OpenGL buffers allocation without the overhead of having a compositor/desktop in between (X11 or Wayland Compositor for example). This can be resumed as a modern OpenGL FBDEV, because it permits full usage of the DRM KMS API with OpenGL acceleration.
A very few project uses GBM, except some demos like KMSCube. But recently, the Kodi Project added a DRM KMS support for compositing, permitting it to support modern DRM KMS Graphics Drivers (like the mainline Amlogic Meson driver) and the GBM OpenGL API.
We won't explain in details the DRM KMS/GBM Kodi implementation nor the LibreELEC build system, but we will explain what was added and how to rebuild such SDCard Image.
If you want to play with this LibreELEC image using GBM, please download this image and flash it on an sdcard:
zcat your-image.img.gz | sudo dd of=<path-to-your-sdcard> bs=4M
Plug the sdcard, power on the board and the LibreELEC splash screen should appear on the screen a few seconds later. The system will reboot once after preparing the SDCard data partition, then the Kodi interface will appear !
If you have a HDMI CEC Enabled TV, you can wait until Kodi connects to the TV and control Kodi from the TV remote, or you can plug a Mouse to control the interface.
Please note there is some limitations :
- Video decoding will be smooth for videos up to 720p
- Some audio cuts can be heard, we are still investigating the issue
But the rendering of the Kodi interface will be done using the Mali GBM library, enabling very good performances with low overhead.
The build scripts used to build LibreELEC are available here: [LibreELEC build system.
The build system is custom, bash scripts based, and based on the OpenELEC project.
Please refer to https://libreelec.wiki/compile to prepare your host machine for building the LibreELEC distribution.
A feature branch was created by the LibreELEC project to host a full-mainline based Amlogic support, the branch is called Amlogic. The temporary Project name is : Amlogic_GX
You can download it by using GIT :
git clone https://github.com/LibreELEC/LibreELEC.tv.git -b amlogic
The branch is based using the following :
- linux mainline 4.16 (was 4.14 initially) with patches to support USB, Audio and WiP/Recently Merged feature
- U-boot mainline v2018.01, no patches
- Amlogic GBM Mali Library distribution in their Buildroot package on http://openlinux.amlogic.com
- Linux Mainline compatible ARM Mali driver from https://github.com/superna9999/meson_gx_mali_450
- libCEC with support for Linux Mainline CEC framework
In the source, you will find the package files in : projects/Amlogic_GX
One more thing, the scripts can generate a 32bit or 64bit image ! This means you can build a LibreELEC image build in 32bit ARM (for compatibility for some Kodi extensions for example) or 64bit to leverage the new 64bit AArch64 ARM Architecture !
To build, you will simply need to run :
make ARCH=arm PROJECT=Amlogic_GX DEVICE=LePotato image
OR
make ARCH=aarch64 PROJECT=Amlogic_GX DEVICE=LePotato image
And wait ! Be careful to have enough free disk space, the build directory can take up to 20Gbytes since everything is rebuilt from source : compilers, kernel, ...
When finished, the SDCard image will be available in the target/ directory, for example :
LibreELEC-LePotato.arm-9.0-devel-20180302173250-r28232-gcbf4d97-libretech-cc.img.gz
Simply copy the file on the SDCard using (if your SDCard is on /dev/mmcblk0) :
zcat target/LibreELEC-LePotato.arm-9.0-devel-*.img.gz | sudo dd of=/dev/mmcblk0
Remove the eventual eMMC of the boardm insert the microSDCard, wait the second reboot and enjoy !
That's it folks !
You can stop reading here, unless you want details on how integrating the GBM libMali in your Linux distribution !
This section is the same for fbdev and gbm. It is described here
We will build other components on top of these libraries so we need to install the headers, including the gbm platform headers:
cp -ar buildroot_openlinux/buildroot/package/meson-mali/include/* <path-to-your-rootfs>/usr/include/
pushd <path-to-your-rootfs>/usr/include/EGL
ln -s ../EGL_platform/platform_dummy/* .
popd
echo /usr/lib/mali > <path-to-your-rootfs>/etc/ld.so.conf.d/mali.conf
The necessary bits to enable opengl acceleration using the mali are now available ! An example is the KMSCube demo, using GBM !