From linux-sunxi.org
Jump to: navigation, search



Cedrus is a project intended for fully open source hardware video-decoding stack, replacing the proprietary library that has a history of GPL violating and license ambiguity issues, shipped with sunxi devices. The name is derived from the Cedrus tree, which commonly is known as Cedar.

Cedrus support is currently implemented as a vdpau driver backend for the vdpau framework.

The main project is located on Github: https://github.com/linux-sunxi/libvdpau-sunxi

Proof of Concept (PoC) code (simple snippets to test out various codecs) can be found here: https://github.com/jemk/cedrus

Current status

Currently the driver is in alpha status or Proof of Concept (PoC) phase. The driver is quite useable, but does by far not possess production quality and is a security risk. It's confirmed to work with A10, A13 and A20.

SECURITY NOTE: Currently the open source driver is implemented as replacement of the blob. Blob and current open source replacement driver (libvdpau-sunxi) use Allwinner's kernel driver that remaps registers for use in userspace, with Allwinner's display driver used for hardware overlay. Together with access to physical memory, and dangerous VE DMA ability it makes a serious security problem.

That should be replaced in a proper way in ongoing mainline process.

Supported codec matrix

Codec libvdpau-sunxi PoC Hardware supported
Decoding support
MPEG1 Yes(only progressive) Yes Yes
MPEG2 Yes(only progressive) Yes Yes
MPEG4[1] Limited [2] Yes
MS-MPEG4[1] No No Yes
H263[1] [3] No Yes
VP6[1] [3] No Yes
JPEG/MJPEG[4] [3] Yes Yes
XDIV[1] [3] No Unconfirmed[5]
DIVX[1] No No Unconfirmed[5]
Sorenson[1] [3] No Unconfirmed[5]
WMV9/VC1[1] No No Yes
RMVB[1] [3] No Unconfirmed[5]
H264 Yes [2] Yes
AVS [3] No Unconfirmed[5]
VP8 [3] Yes Yes
H265[6] Yes [2] Yes(only in newer versions)
Encoding support
JPEG/MJPEG[4] [7] Yes Yes
H264 [7] (No B frames) Yes(only baseline profile)
  1. 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 This is old and obsolete codec with low priority to add support
  2. 2.0 2.1 2.2 The work was add to libvdpau-sunxi, without going through a PoC (Proof of Concept)
  3. 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 VDPAU API does not support this codec
  4. 4.0 4.1 MJPEG is JPEG images in a video container
  5. 5.0 5.1 5.2 5.3 5.4 There are indices that hardware supports, but wasnt possible to find software that worked correctly.
  6. Hardware only supports this codec in newer video engine versions (H3)
  7. 7.0 7.1 VDPAU API doesn't have support for encoding.


Cedrus/libvdpau_integration_matrix gives an overview about the VDPAU API functions currently supported in libvdpau-sunxi. It also lists the required functions for various programs.



Various things are required to get cedrus to play back video. This list can act as a quick start.

  • Proper memory reservation
  • cedar module either compiled in or the module loaded
  • write access permissions on /dev/disp and /dev/cedar_dev (on A33 or H3, add /dev/ion)
  • libvdpau-sunxi library installed
  • enviroment variable telling libvdpau which library to use

Reserve memory for the VPU

The VE needs a block of memory to store (de)coded frames in. The kernel needs to be informed about this before booting. To do so, the kernel command line needs to be modified. This can be done at compiletime or by modifying the bootloaders Kernel_arguments. By default Allwinner reserves 80 Megabytes but depending on the player being used and video being decoded, less can suffice or more can be necessary. Feel free to experiment with the amount, but if available, 128 MiB is a nice number to test things with. This can be set by the following kernel argument.


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.

Cedar module

Depending on where the kernel came from, the Cedar kernel driver is either available as module or built in. To see whether it is available, check whether /dev/cedar_dev exists. If not, run modprobe sun4i_cedar_dev (in future versions this should be called sunxi_cedar_dev, and for official kernel of A33 or H3 it's called cedar_dev). There should now be a /dev/cedar_dev.

Write access persmissions

To be able to pass data to the VE, proper permission to /dev/cedar_dev is required.

For testing, manually setting permissions is fine.

chown <username>:<usergroup> /dev/cedar_dev
chmod 666 /dev/cedar_dev

The VE only decodes the video codec. To have it appear on the display, write access permission to /dev/disp is required.

chown <username>:<usergroup> /dev/disp
chmod 666 /dev/disp

For the official kernel of A33 or H3, cedar do not allocate memory by itself, but it uses ion. So for these devices, write and read permission to /dev/ion is needed.

chown <username>:<usergroup> /dev/ion
chmod 666 /dev/ion

To do this properly with udev rules, create files for each under /etc/udev/rules.d/


KERNEL=="disp", MODE="0660", GROUP="video"


KERNEL=="cedar_dev", MODE="0660", GROUP="video"


KERNEL=="ion", MODE="0660", GROUP="video"

Installing sunxi-vdpau library

There are currently no pre-compiled binaries available and have to be compiled from source. This most likely has to be performed on the target device, while possible to be cross compiled.


  • git (yum install git | apt-get install git | emerge git)
  • gcc (yum group-install "Development Tools" | apt-get install build-essential)
  • libvdpau-dev >= 0.9 (yum install libvdpau-dev | apt-get install libvdpau-dev | emerge libvdpau)

Compiling source

The current libvdpau-sunxi code is stored on github.

git clone https://github.com/linux-sunxi/libvdpau-sunxi.git
cd libvdpau-sunxi
sudo make install

Pay close attention as to where these libraries get installed. Depending on the distro in use, it's most likely they will need to be put in /usr/lib/vdpau. If they are not put there, manually copy them there. With the driver now installed, it is important to tell vdpau to use this library. By default it will try to load and use the nVidia vdpau implementation.

export VDPAU_DRIVER=sunxi

The latest git version of Xorg#fbturbo_driver can report the DRI2 VDPAU name as 'sunxi', if 'sunxi_cedar_mod' kernel module loaded successfully. See commit

Playing video

With everything setup properly, it should now be possible to playback hardware accelerated media!

The best test file would be one of the well known sample media's. The big buck bunny is an often used one. http://samplemedia.linaro.org/H264/big_buck_bunny_1080p_H264_AAC_25fps_7200K.MP4

Depending if you use mpv or mplayer2, the following options are required. For mplayer2:

 mplayer -vo vdpau -vc ffmpeg12vdpau,ffh264vdpau, [filename]

For mpv:

 mpv --vo=vdpau --hwdec=vdpau --hwdec-codecs=all [filename]

Note: There have been reports that some mplayer versions in certain repositories are not compiled with vdpau support.

Now you can also try to use other files, but note it has to be mpeg1, mpeg2 or h264 encoded!

A prebuilt package of mpv: http://public.perdmann.de/orangepi/mpv_0.13.0_armhf.deb

OSD support

Now we have simple OSD implementation, using g2d hardware.

Access to g2d (as xorg turbo driver) is also required.

chmod 666 /dev/g2d

To do this properly with udev rules, create a file under /etc/udev/rules.d/


KERNEL=="g2d", MODE="0660", GROUP="video"

and make sure that the user wanting to decode video is in the video group!

To turn on OSD support during runtime:

export VDPAU_OSD=1

Note: mplayer's "-ass" osd not currently supported, due to lack of 'alpha only' surfaces support in current g2d driver

Personal tools