Thursday, April 18, 2013

Compiling the Mali HW accelerated driver (xf86-video-fbdev for RK3066)


Expert Linux developer olegk0 has made a framebuffer driver for the RK30 HDMI with Mali acceleration (rk30fb_drv.so). You can just download and use his .so to have 3D acceleration, or you can follow these instructions to compile it yourself and help debug it.

Among other things, like 2D/3D, it allows playing fullscreen videos with far less CPU usage, leaving the processor just for what your app requires to decode the videos. With "app" I mean Parole, VLC or, my strong recommendation, the excellent commandline utility: mplayer (which immediately takes advantage of the HW acceleration).

The downside is that it still has some bugs, like turning everything in the screen black (except the played video). Just move the mouse or a window around and everything gets redrawn again.
Another bug is that the video output becomes mangled when the video window touches the left or right sides of the screen.

In any case I love to be able to watch movies/videos on this stick with Linux, so what I do is open a terminal and type:
mplayer whatever-video.avi
And screen turns black except the video, I move the mouse a bit around (which causes the black parts to be redrawn) to find the corners of the mplayer video window and make it big enough to cover most of the screen, just without touching either left or right sides of the screen.


In any case, if you would like to give us a helping hand debugging the XVideo implementation (my suspect is ./xf86-video-fbdev/src/video.c) just follow these steps to tinker with the code and compile the driver to see the changes:

git clone git://github.com/olegk0/xf86-video-fbdev.git
sudo apt-get install xserver-xorg-dev

We must then fix a dangling symlinked folder at "./xf86-video-fbdev/src/ump" pointing to "../../../../../r3p1/ump/include/ump"

So go to http://malideveloper.arm.com/develop-for-mali/drivers/open-source-mali-gpus-ump-user-space-drivers-source-code-2/ and download the same revision (r3p1, until we get a first working driver; then we can try with a newer version), that is: Linux Kernel Device Driver r3p1-01rel1

Copy or symlink the uncompressed folder "./DX910-SW-99006-r3p1-01rel1/driver/src/ump/include/ump" to "./xf86-video-fbdev/src/ump"

And now just do:
./configure --prefix=/usr
make
sudo make install
There is a lot of debug information printed on /var/log/syslog every time you play a video with mplayer, which should help in the debugging.

6 comments:

  1. When I'm trying to use .so file, I'm getting '/usr/lib/xorg/modules/drivers/rk30fb_drv.so: cannot open shared object file: No such file or directory' in Xorg.0.log. When file is there even with 0777 rights.

    When trying to compile the driver I got errors:
    /tmp/ccA1tnRK.s:62: Error: invalid constant (ff00ff) after fixup
    /tmp/ccA1tnRK.s:66: Error: invalid constant (ff00ff00) after fixup

    I'm using Slackware ARM 14.1

    ReplyDelete
    Replies
    1. Thanks to jdetring from #armedslack on IRC freenode patch was prepared:

      --- xf86-video-fbdev/src/video.c.orig 2014-02-15 11:46:53.000000000 -0600
      +++ xf86-video-fbdev/src/video.c 2014-02-15 11:53:26.000000000 -0600
      @@ -136,12 +136,16 @@
      "bic v2,v1,#0xFFFFFF00\n\t"
      "bic v3,v1,#0xFF00FFFF\n\t"
      "orr v3,v2,v3,lsr #8\n\t"
      - "bic v1,v1,#0x00FF00FF\n\t"
      + "ldr v7,=0x00FF00FF\n\t"
      + "bic v1,v1,v7\n\t"
      +// "bic v1,v1,#0x00FF00FF\n\t"
      "orr v1,v1,v1,lsl #8\n\t"
      "mov v6,v1,lsr #16\n\t"
      //
      "ldr v1,[%[Src],#4]\n\t"//4byte skip
      - "bic v2,v1,#0xFF00FF00\n\t"
      + "ldr v7,=0xFF00FF00\n\t"
      + "bic v1,v1,v7\n\t"
      +// "bic v2,v1,#0xFF00FF00\n\t"
      "orr v2,v2,v2,lsr #8\n\t"
      "orr v3,v3,v2,lsl #16\n\t"
      "str v3,[%[Yvar]]\n\t"

      WARNING:
      - v4 can be used instead of v7 for added lines.
      - video acceleration still doesn't work

      Delete
  2. Is this project getting any further? Should I be looking elsewhere for current active development?

    ReplyDelete
    Replies
    1. I ran out of time, you could look for omegamoon's blog

      Delete
  3. root@miniyo-terreno-ubuntu:/home/miniyo/picuntu/mali/xf86-video-fbdev# make
    make all-recursive
    make[1]: se ingresa al directorio «/home/miniyo/picuntu/mali/xf86-video-fbdev»
    Making all in src
    make[2]: se ingresa al directorio «/home/miniyo/picuntu/mali/xf86-video-fbdev/src»
    CC fbdev.lo
    CC mali_dri2.lo
    CC disp_hwcursor.lo
    CC video.lo
    video.c: In function 'XVInitAdaptor':
    video.c:508:18: warning: assignment from incompatible pointer type [enabled by default]
    adapt->PutImage = XVPutImage;
    ^
    video.c: In function 'XVCopyPackedToFb':
    video.c:134:9: error: unknown register name 'v5' in 'asm'
    asm volatile (
    ^
    video.c:134:9: error: unknown register name 'v6' in 'asm'
    video.c:134:9: error: unknown register name 'v3' in 'asm'
    video.c:134:9: error: unknown register name 'v2' in 'asm'
    video.c:134:9: error: unknown register name 'v1' in 'asm'
    video.c: In function 'XVCopyPlanarToFb':
    video.c:195:9: error: unknown register name 'v6' in 'asm'
    asm volatile (
    ^
    video.c:195:9: error: unknown register name 'v5' in 'asm'
    video.c:195:9: error: unknown register name 'v3' in 'asm'
    video.c:195:9: error: unknown register name 'v2' in 'asm'
    video.c:195:9: error: unknown register name 'v1' in 'asm'
    video.c:195:9: error: unknown register name 'a1' in 'asm'
    make[2]: *** [video.lo] Error 1
    make[2]: se sale del directorio «/home/miniyo/picuntu/mali/xf86-video-fbdev/src»
    make[1]: *** [all-recursive] Error 1
    make[1]: se sale del directorio «/home/miniyo/picuntu/mali/xf86-video-fbdev»
    make: *** [all] Error 2

    how i can fix this to finally compile

    ReplyDelete
  4. I'm getting this error in xorg.log, can anyone help?

    20.989] (II) RK30FB(0): HW:Main setup ovl
    [ 20.989] (II) RK30FB(0): Overlay memory pages
    [ 20.989] (II) RK30FB(0): --------------------
    [ 21.011] (EE) RK30FB(0): HW:Error overlay mem block size:0
    [ 21.011] (EE) RK30FB(0): HW:Error init ovl
    [ 21.011] (II) RK30FB(0): XV:Init begin
    [ 21.011] (II) RK30FB(0): XV:Init complete
    [ 21.205] (II) Loading sub module "dri2"
    [ 21.205] (II) LoadModule: "dri2"
    [ 21.205] (II) Module "dri2" already built-in
    [ 21.206] (II) RK30FB(0): Alloc fb buf failed
    [ 21.206] (==) RandR enabled
    [ 21.461] (II) SELinux: Disabled on system
    [ 21.521] (II) AIGLX: Screen 0 is not DRI2 capable
    [ 21.522] (EE) AIGLX: reverting to software rendering

    ReplyDelete