FBCP for Mali?

Post Reply
jakogut
Posts: 26
Joined: Fri Apr 08, 2016 6:28 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, VU7+
Contact:

FBCP for Mali?

Unread post by jakogut » Fri Oct 28, 2016 1:23 am

There's a well known program for the Raspberry Pi that copies the framebuffer contents rendered from the integrated GPU to the framebuffer of SPI or I2C connected FBTFT displays. However, it depends on Broadcom code, and only works with Videocore GPUs. Is there a similar program available for general purpose use, or even specific to the Mali GPUs?

I did a bit of reading about the Linux framebuffer, and it seems to me that it would be possible to create a kernel module to sync frames from one buffer to another. If this doesn't already exist, I'm interested in creating it.

User avatar
mad_ady
Posts: 5261
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Contact:

Re: FBCP for Mali?

Unread post by mad_ady » Sat Oct 29, 2016 3:32 pm

I don't think one exists, but there is work by crashoverride using mali to process video output as textures.
However what is your end goal? The display can do max 10-15fps due to the gpio max speed

crashoverride
Posts: 4272
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Contact:

Re: FBCP for Mali?

Unread post by crashoverride » Sat Oct 29, 2016 9:18 pm

This is something I am interested in creating too. I am still in the planning stages. Currently, I intend to write a user space program that manipulates the display directly (no /dev/fb2 or kernel module/driver). It is also my intent to use GE2D to hardware accelerate the color space (R8G8B8A8 to R5G6B5) and scaling (1080p to 320x480).

User avatar
mad_ady
Posts: 5261
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Contact:

Re: FBCP for Mali?

Unread post by mad_ady » Sat Oct 29, 2016 11:33 pm

Pardon my pragmatism, but what would the benefits be? Lower cpu usage? Faster fps? Accelerated chrome/video?
One thing that might be nice in order to increase fps would be to update only changed regions of the x server (I believe the xdamage extension does this), but most likely the kernel driver/framebuffer are not aware of this and refresh the whole display lowering fps

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: FBCP for Mali?

Unread post by mdrjr » Tue Nov 01, 2016 5:58 am

Is your goal to use Mali on the 3.5" LCD?

crashoverride
Posts: 4272
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Contact:

Re: FBCP for Mali?

Unread post by crashoverride » Tue Nov 01, 2016 10:22 am

I can only speak for myself. For me, its about compatibility. When using X11 with a 480x320 resolution, it attempts to fit everything in a window into the constrained space. With a mirror driver, it will instead layout as it would on HDMI, just without as much detail. Its obviously unsuitable for detailed work, but something like a video game emulator is tolerable.

User avatar
mad_ady
Posts: 5261
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Contact:

Re: FBCP for Mali?

Unread post by mad_ady » Tue Nov 01, 2016 2:56 pm

I see. I agree, downscaling would be nice...

User avatar
odroid
Site Admin
Posts: 29736
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: FBCP for Mali?

Unread post by odroid » Tue Nov 01, 2016 3:21 pm

Mali EGL works on the 3.5inch LCD with latest kernel update 3.14.29-92.
https://github.com/hardkernel/linux/com ... 509beec4ce

Time to play PSP emulation. :)

jakogut
Posts: 26
Joined: Fri Apr 08, 2016 6:28 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, VU7+
Contact:

Re: FBCP for Mali?

Unread post by jakogut » Thu Nov 03, 2016 5:53 am

> Mali EGL works on the 3.5inch LCD

Really? That's cool, I'll have to try it out. I'm looking to run Kivy on the little display, which requires EGL and GLES.

EDIT: Also, I'm using the 3.2" TFT. Does that make a difference?

EDIT 2: I see now that the patch is for the c2 tree, but it seems to apply fine to the c1 tree.

User avatar
odroid
Site Admin
Posts: 29736
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: FBCP for Mali?

Unread post by odroid » Thu Nov 03, 2016 8:53 am

Please try the patch on C1 kernel and share the result.

jakogut
Posts: 26
Joined: Fri Apr 08, 2016 6:28 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, VU7+
Contact:

Re: FBCP for Mali?

Unread post by jakogut » Sat Nov 05, 2016 7:33 am

I compiled the C1 kernel with the Mali integration patch applied, and when I run "sudo startx /usr/bin/es2_info", I get "Error: eglGetDisplay() failed".

/etc/X11/xorg.conf.d/99-odroidc-tftlcd.conf

Code: Select all

Section "Device"
    Identifier    "C1 fbdev"
    Driver        "fbdev"
    Option        "fbdev" "/dev/fb2"
EndSection

User avatar
memeka
Posts: 4169
Joined: Mon May 20, 2013 10:22 am
languages_spoken: english
ODROIDs: XU rev2 + eMMC + UART
U3 + eMMC + IO Shield + UART
Contact:

Re: FBCP for Mali?

Unread post by memeka » Sat Nov 05, 2016 8:09 am

Fbdev doesn't support Mali. You have to use the Mali DDX for X11.

jakogut
Posts: 26
Joined: Fri Apr 08, 2016 6:28 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, VU7+
Contact:

Re: FBCP for Mali?

Unread post by jakogut » Mon Nov 07, 2016 8:25 am

odroid: It seems actually that the patch is already part of the C1 tree, I just didn't realize it.

memeka: Thanks for the pointer. I installed the Mali DDX, and X11 with GLES now works on the FBTFT screen. Now I just have to figure out how to compile Kivy to work with it.

jakogut
Posts: 26
Joined: Fri Apr 08, 2016 6:28 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, VU7+
Contact:

Re: FBCP for Mali?

Unread post by jakogut » Tue Nov 08, 2016 9:34 am

Well, I was going to post today about the additional troubles I was having getting Kivy to run, but I ended up getting it working! :D

For anyone else that tries the same thing I did, Kivy at the moment requires a window that supports 32-bit color through both SDL2 and X11, but some, if not all, FBTFT displays only support 16-bit color depth. (I'm going to submit a patch to fix Kivy)

To fix SDL2 support, edit kivy/core/window/_window_sdl2.pyx, and comment out lines 97-105 calling SDL_GL_SetAttribute(). These lines set the minimum color depth and buffer requirements to create the window. You do need to have SDL2 compiled and installed with the proper support for GLES, and the proper path for the Mali userspace driver.

To fix X11 support, edit kivy/core/window/window_x11_core.c, and replace the values from lines 50-54 in egl_config_attribs[] with EGL_DONT_CARE, just like EGL_DEPTH_SIZE and EGL_STENCIL_SIZE below.

Here are some pictures!

User avatar
odroid
Site Admin
Posts: 29736
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: FBCP for Mali?

Unread post by odroid » Tue Nov 08, 2016 10:33 am

Great to see the nice Kivy GUI on the small TFT LCD. :D

I really hope your patch will be merged soon.

henners
Posts: 12
Joined: Thu Dec 01, 2016 4:04 am
languages_spoken: english
ODROIDs: C1+
Contact:

Re: FBCP for Mali?

Unread post by henners » Thu Dec 01, 2016 4:37 pm

@jakogut How did you compile kivy from source? what where your commands?

moon.linux
Posts: 1162
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english
Contact:

Re: FBCP for Mali?

Unread post by moon.linux » Fri Dec 02, 2016 2:27 am

@henners

I feel you dont need to compile and install the kivy package.

You can install by ubuntu debian package.
You can find the instructions to install kivy using apt-get

https://kivy.org/docs/installation/inst ... linux.html#

Here is the summary of command to install kivy

Code: Select all

sudo add-apt-repository ppa:kivy-team/kivy
sudo apt-get update
sudo apt-get install python-kivy
sudo apt-get install python-kivy-examples
sudo apt-get install -y  python-pip build-essential git python python-dev ffmpeg libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev libswscale-dev libavformat-dev   libavcodec-dev  zlib1g-dev
sudo pip install --upgrade pip virtualenv setuptools
virtualenv --no-site-packages kivyinstall
virtualenv --no-site-packages -p /usr/bin/python2.7 kivyinstall
pip install Cython==0.23
pip install kivy
pip install pygame
I just tried a small example fro the tutorial and it worked for me.

But if you want to install develper version that you want to compile and install follow the instruction in below link.

https://kivy.org/docs/installation/installation.html section Development Version

If you want to compile and install the kivy

https://kivy.org/docs/installation/inst ... n-rpi.html section Manual installation

I think @jakogut was referring to the git source code before compiling.

User avatar
odroid
Site Admin
Posts: 29736
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: FBCP for Mali?

Unread post by odroid » Fri Dec 02, 2016 10:08 am

@moon.linux
Can you check the OpenGL-ES HW acceleration with above installation?
It seems to be using the soft-gl(mesa stuff) instead of Mali GPU.

moon.linux
Posts: 1162
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english
Contact:

Re: FBCP for Mali?

Unread post by moon.linux » Fri Dec 02, 2016 2:19 pm

Well I dont know how to test OpenGL-ES HW,

We can test example for 3d rendering with following kivy example.

odroid@odroid64:/usr/share/kivy-examples/3Drendering$ python main.py

Code: Select all

[INFO   ] [Logger      ] Record log in /home/odroid/.kivy/logs/kivy_16-12-01_9.txt
[INFO   ] [Kivy        ] v1.9.0
[INFO   ] [Python      ] v2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609]
[INFO   ] [Factory     ] 173 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [OSC         ] using <multiprocessing> for socket
[INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
libGL error: unable to load driver: mali_drm_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: mali_drm
[INFO   ] [GL          ] OpenGL version <3.0 Mesa 11.2.0>
[INFO   ] [GL          ] OpenGL vendor <VMware, Inc.>
[INFO   ] [GL          ] OpenGL renderer <Gallium 0.4 on llvmpipe (LLVM 3.8, 128 bits)>
[INFO   ] [GL          ] OpenGL parsed version: 3, 0
[INFO   ] [GL          ] Shading version <1.30>
[INFO   ] [GL          ] Texture max size <8192>
[INFO   ] [GL          ] Texture max units <18>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Shader      ] Read <simple.glsl>
[INFO   ] [Base        ] Start application main loop
[INFO   ] [Base        ] Leaving application in progress...
odroid@odroid64:/usr/share/kivy-examples/3Drendering$
On debugging using strace above application, it likely to look for mali events via /sys filesystem, but I an not sure on this.
Attached is the logs.

Edited: We can set some parameter via following config to enable HW acceleration via graphics, but I didn't know much details.

https://kivy.org/docs/api-kivy.config.h ... ivy.config

odroid@odroid64:~$ vi .kivy/config.ini
Attachments
malitest.txt
malitest
(1.97 MiB) Downloaded 94 times

User avatar
odroid
Site Admin
Posts: 29736
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: FBCP for Mali?

Unread post by odroid » Fri Dec 02, 2016 4:44 pm

It uses the soft-GL instead of Mali GPU. :(

Code: Select all

libGL error: unable to load driver: mali_drm_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: mali_drm
You needed to build the source code to enable the Mali GPU acceleration.

jakogut
Posts: 26
Joined: Fri Apr 08, 2016 6:28 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, VU7+
Contact:

Re: FBCP for Mali?

Unread post by jakogut » Sat Dec 03, 2016 7:52 am

It's actually a bit of work to compile Kivy to run with Mali on the little screen, but it's not difficult.

The first thing you need to do is compile and install SDL2 with flags to disable OpenGL ("./configure --disable-video-opengl ..."). OpenGLES should be enabled by default, but if for whatever reason it's not, you need to enable it. There's more information on how to do this here: https://www.solarianprogrammer.com/2015 ... ted-sdl-2/

The second step is to modify the Kivy setup.py script to point to your libMali.so library. The default location is setup for Debian and Ubuntu.
I made a pull request for these changes here: https://github.com/kivy/kivy/pull/4661

The last step is to modify Kivy's window provider code to allow window creation with color depth less than 32-bit.
Again, these changes are here: https://github.com/kivy/kivy/pull/4716

User avatar
mad_ady
Posts: 5261
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Contact:

Re: FBCP for Mali?

Unread post by mad_ady » Thu Dec 22, 2016 4:31 pm

I'd like to ask - has anybody worked on rendering higher resolutions downscaled on this display? How does the end result look?

crashoverride
Posts: 4272
Joined: Tue Dec 30, 2014 8:42 pm
languages_spoken: english
ODROIDs: C1
Contact:

Re: FBCP for Mali?

Unread post by crashoverride » Sun Jan 29, 2017 7:57 am

[edit]
I have moved this to the C2 sub-forum:
http://forum.odroid.com/viewtopic.php?f=139&t=25700

The original posted content remains below. Issues should be reported in the above thread or on the github page.

[Original content follows]
-----------------------------
crashoverride wrote:This is something I am interested in creating too.
I created a program for the Odroid C2 that mirrors the /dev/fb0 content to the LCD display. It uses GE2D for color space conversion and scaling. This is still very experimental:
https://github.com/OtherCrashOverride/c2screen2lcd

To use it, initialize the LCD display as shown in the wiki:
http://odroid.com/dokuwiki/doku.php?id= ... lcd_shield

Code: Select all

sudo modprobe aml_i2c
sudo modprobe pwm-meson
sudo modprobe pwm-ctrl
sudo modprobe fbtft_device name=flexpfb rotate=270
sudo modprobe flexfb chip=ili9488
sudo modprobe sx865x
echo 500000 | sudo tee /sys/devices/platform/pwm-ctrl/freq0
echo 1 | sudo tee /sys/devices/platform/pwm-ctrl/enable0
echo 1023 | sudo tee /sys/devices/platform/pwm-ctrl/duty0
You will also need to set permissions for ge2d and ion or use sudo:

Code: Select all

sudo chmod a+rw /dev/ge2d
sudo chmod a+rw /dev/ion
Then run the mirror program:

Code: Select all

./c2screen2lcd
As long as the program is running, whatever is seen on HDMI is scaled and displayed on the LCD. This works for both console and X11. Lowering your display resolution in boot.ini will make the LCD display more legible.
mad_ady wrote:has anybody worked on rendering higher resolutions downscaled on this display?
It works quite well from my testing!

[edit]
The touch screen also works under X11. You will likely need to calibrate as noted in the wiki.

[edit2]
Note that the LCD display has a 4:3 aspect ratio which is different from a TV's 16:9. A 800x600 resolution in boot.ini works well for legibility and correct aspect.

[edit3]
VT switching also works. For example, you can switch between console and X11.
Last edited by crashoverride on Mon Jan 30, 2017 6:10 am, edited 2 times in total.

User avatar
mad_ady
Posts: 5261
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Contact:

Re: FBCP for Mali?

Unread post by mad_ady » Sun Jan 29, 2017 5:15 pm

Great work crash! I'll play with it on monday

Post Reply

Return to “3.5inch LCD Shield”

Who is online

Users browsing this forum: No registered users and 2 guests