Cedrus

Overview
Cedrus is a project intended for fully opensource hardware video-decoding stack, replacing the proprietary, GPL violating CedarX shipped with sunxi devices. The name stems from the Cedrus tree, which commonly is known as Cedar.

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

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

Current status
Currently the driver is in alpha status or Proof of Concept (PoC) phase. The driver is quite usable, but by far not production quality and a security risk. Supported H264, MPEG1, MPEG2, basic mpeg4 and JPEG decoding. Confirmed work with A10, A13 and A20.

Now all support based on allwinner's kernel driver that remap registers for use in userspace, together with allwinner disp driver for hardware overlay buffer. Thats should be replaced proper way in ongoing mainline project.

Prerequisites
Various things are required to get cedrus to play back video. This list can act as a quick start.
 * Proper memory reservation
 * cedarX module either compiled in or the module loaded
 * write access permissions on /dev/disp and /dev/cedar_dev
 * sunxi-vdpau library installed
 * enviroment variable telling libvdpau which library to use

Reserve memory for the VPU
The VPU 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 compiletime or by modifying the bootloaders Kernel_arguments. By default Allwinner reserves 80 Megabytes but depending on the video being decoded, less can suffice. 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. sunxi_ve_mem_reserve=128

CedarX module
Depending on where the kernel came from, the cedarX kernel 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). There should now be a /dev/cedar_dev

Write access persmissions
To be able to pass data to the VPU, proper permission to /dev/cedar_dev is required.

For testing, manually setting permissions is fine. chown : /dev/cedar_dev, chmod 666 /dev/cedar_dev The VPU only decodes the video codec. To have it appear on the display, write access permissions to /dev/disp is required. chown : /dev/disp, chmod 666 /dev/disp

To do this properly with udev rules, create files for each under /etc/udev/rules.d/ 50-disp.rules KERNEL=="disp", MODE="0660", GROUP="video" 50-cedar.rules KERNEL=="cedar_dev", MODE="0660", GROUP="video"

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

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 cross compiled.

Prerequisites

 * git (yum install git | apt-get install git | emerge git)
 * gcc (yum group-install "Development Tools" | apt-get install build-essentials)
 * libvdpau-dev (yum install libvdpau-dev | apt-get install libvdpau-dev | emerge libvdpau)

Compiling source
The current libvdpau code is stored on github and gitorious. git clone https://github.com/linux-sunxi/libvdpau-sunxi.git make 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

Playing video
With everything setup properly, it should now be possible to playback 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: For mpv:
 * mplayer -vo vdpau -vc ffmpeg12vdpau,ffh264vdpau, [filename]
 * 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!