Author Topic: Sdl With Directfb Packages  (Read 13893 times)

danboid

  • Hero Member
  • *****
  • Posts: 881
    • View Profile
    • http://
Sdl With Directfb Packages
« on: November 08, 2015, 06:54:34 pm »
There are two main reasons you may need to use SDL's directfb output. You may want to run an SDL2 program from the console or you may wish to run an SDL program such as an emulator or a game at QVGA resolution from the console. SDL1 supports fbcon output but fbcon output has been dropped from SDL2 where directfb is your only real option for displaying graphics outside of X. QVGA fbcon output doesn't seem to work for SDL1 under recent kernels. To make matters more complicated, both the SDL1 and SDL2 packages in the ALARM repositories don't include directfb support and even if you do build SDL yourself with directfb enabled (without using the patched PKGBUILD below) it still won't work properly because the display isn't aligned for the Zaurus' display and your pointers orientation will be skewed using the directfb version currently in the ALARM repos, directfb 1.7.7.

Thankfully forum member daalnroti patched the directfb code of SDL 1.2.14 so that we can use directfb and see the full screen and he also patched directfb so that you can use a pointer device correctly up/down will be up/down instead of left/right. I have built ALARM packages and PKGBUILD tarballs that integrate these patches to simplify the install process.

So far we only have the previous stable release of SDL1 (1.2.14) patched so that the directfb display works properly and an older directfb with the pointer patch applied. SDL2 apps will suffer from a misaligned display until we have a similar patch for SDL2. daal's original directfb patch was for directfb 1.4.11 but it still applied cleanly to 1.4.16 which was the oldest version I could get to build under Arch. I have not yet looked into if this patch works under the latest directfb but its a very small patch so it should be trivial to update it if required.

The SDL package here was built against the directfb 1.4.16 package below.

[size=]Installing sdl and directfb[/size]

To install the attached packages you will first need to uncompress their tarballs to get the Arch .tar.xz package as well as uninstall your existing SDL and everything that depends on SDL (if you've already installed SDL1 from the ALARM repo) like so:

Code: [Select]
pacman -Rcn sdl
After installing the attached sdl and directfb packages, you will need to add both 'sdl' and 'directfb' to your IgnorePkg statement in /etc/pacman.conf. Don't forget to uncomment the IgnorePkg line as it's commented out by default!

[size=]Configuring sdl and directfb[/size]

If you wanted directfb to default to QVGA, you would create an /etc/directfbrc file like this:

Code: [Select]
fbdev=/dev/fb0
mode=240x320
force-windowed
layer-rotate=270
no-vt-switch

You can also temporarily switch DFB settings by exporting them in a comma separated list to DFBARGS by running a command like this:
Code: [Select]
export DFBARGS="force-windowed,layer-rotate=270,mode=240x320,no-vt-switch"
Note that layer-rotate is required to use directfb in landscape display mode and it doesn't work without the force-windowed option.

You need to export your choice of video driver othewise SDL1 defaults to fbcon output:

Code: [Select]
export SDL_VIDEODRIVER=directfb
Finally you also need to export one of the following EVs to correct the displays offset:

Code: [Select]
export SDL_VIDEO_DIRECTFB_POS=qvga
export SDL_VIDEO_DIRECTFB_POS=vga
export SDL_VIDEO_DIRECTFB_POS=topleft

If you want any of these exported automatically on boot, add them to /etc/profile .
« Last Edit: November 12, 2015, 10:36:30 am by danboid »
Zaurus SL-C3000 w/ MD swapped for a Kingston 32GB Ultimate 266X CF running ALARM
Banana Pi running ALARM on a WD Scorpio SATA II HD
System76 Gazelle Pro i7 laptop w/ SAMSUNG 840 EVO SSD running Arch x64

How to install Arch on your C3x00 Zaurus https://github.com/danboid/ZALARM-install

greguu

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 433
    • View Profile
    • http://github.com/greguu
Sdl With Directfb Packages
« Reply #1 on: November 08, 2015, 11:04:58 pm »
Quote from: danboid
There are two main reasons you may want to use SDL's directfb output - you may want to run an SDL2 program from the console or you may wish to run an SDL program such as an emulator or a game at QVGA resolution from the console. SDL1 supports fbcon output but fbcon output has been dropped from SDL2 where directfb is your only real option for displaying graphics outside of X and QVGA fbcon output doesn't seem to work for SDL1 under recent kernels. To make matters more complicated, both the SDL1 and SDL2 packages in the ALARM repositories don't include directfb support and even if you do build SDL yourself with directfb enabled it still won't work properly because the display isn't aligned properly for the Zaurus' display!

Thankfully daalnroti has patched the directfb code of SDL 1.2.14 so that we can use directfb properly - well we almost can! I have created and built an ALARM package and PKGBUILD tarball to simplify the install process (both of which are attached) although as it stands, despite having spent hours today trying various directfb input options, I have not been able to get the keyboard to work under MAME4ALL when using directfb so far but at least it has proved to me that QVGA directfb output does work with daal's patch.

So far we only have the previous stable release of SDL1 (1.2.14) patched so that the directfb display works properly. I'll update this post when keyboard input works and/or any progress is made on supporting newer versions of SDL.

[size=]Installing sdl-directfb[/size]

To install the attached SDL package you will first need to uncompress the tarball to get the Arch .tar.xz package as well as uninstall your existing SDL and everything that depends on SDL (if you've already installed SDL1 from the ALARM repo)  like so:

Code: [Select]
pacman -Rcn sdl
After installing the attached package, you will need to add 'sdl' to your IgnorePkg statement in /etc/pacman.conf. Don't forget to uncomment the IgnorePkg line as it's commented out by default!

[size=]Configuring sdl-directfb[/size]

If you wanted directfb to default to QVGA, you would create an /etc/directfbrc file like this:

Code: [Select]
fbdev=/dev/fb0
mode=240x320
force-windowed
layer-rotate=270

You can also temporarily switch DFB settings by exporting them in a comma separated list to DFBARGS by running a command like this:
Code: [Select]
export DFBARGS="force-windowed,layer-rotate=270,mode=240x320"
Note that layer-rotate is required to use directfb in landscape display mode and it doesn't work without the force-windowed option.

You need to export your choice of video driver othewise SDL1 defaults to fbcon output:

Code: [Select]
export SDL_VIDEODRIVER=directfb
Finally you also need to export one of the following EVs to correct the displays offset:

Code: [Select]
export SDL_VIDEO_DIRECTFB_POS=qvga
export SDL_VIDEO_DIRECTFB_POS=vga
export SDL_VIDEO_DIRECTFB_POS=topleft

If you want any of these exported automatically on boot, add them to /etc/profile .

Great work for writing this how-to.

In regards to the keyboard not working under MAME4ALL :

Does it work for other SDL applications using DirectFB as the back-end ?

If not, you may need a custom DirectFB build to support the Z keyboard. Back on Debian there were no DirectFB packages and I always compiled my own.
Test with a USB keyboard if that works, too.

My configure parameters for DirectFB 1.4.11 were :

Code: [Select]
/configure --prefix=/opt/dfb/ --enable-fbdev --with-gfxdrivers=none --disable-osx --disable-x11 --disable-network --disable-voodoo --disable-vnc --disable-sysfs --enable-multi --enable-zlib --with-inputdrivers="keyboard,linuxinput,ps2mouse,tslib" --disable-debug-support --disable-sdl --disable-unique --disable-video4linux --with-dither-rgb16=none --with-dither=none
make

(keep in mind for  --enable-multi and tslib (touchscreen) will require extra packages to be build before DirectFB.)
« Last Edit: November 08, 2015, 11:11:48 pm by daalnroti »
Gemini-PDA (Sailfish X and Android) / LG Nexus 5 (Android 11) / Nokia N9 (MeeGo/Harmattan)
Sharp Zaurus C3100 (Borzoi) - Void Linux (voidz) Kernel 5.0.0 - Hardware (Buffalo CF LAN, DLink 660 CF WiFi, ASIX AX88772 USB Ethernet)

danboid

  • Hero Member
  • *****
  • Posts: 881
    • View Profile
    • http://
Sdl With Directfb Packages
« Reply #2 on: November 09, 2015, 11:34:19 am »
Hi daal!

I've tried directfb with chocolate-doom from the repos and it behaves the same as MAME. Using a USB keyboard made no difference - I get the same probs as using the integrated keyboard which is that either directfb spawns a terminal under the window I want to use (which is semi-transparent by default) and that captures keyboard input instead of MAME/DOOM or the keyboard doesn't work at all, depending on what options I feed to DFB.

I've just tried recompiling directfb 1.7.7 using most of the same options you used, most notably using the same input options (minus tslib whch I'm not bothering with yet) but unlike you I didn't disable SDL. Why did you disable SDL when you built directfb?

I built dfb today against the patched SDL package I've posted in the SDL thread as I suspected my probs could've been down to me running a directfb that was compiled against a slightly newer SDL (the one in the repos) but my new dfb package doesn't work any better than the one from the repos despite being built with SDL enabled and only the patched 1.2.14 version of SDL being installed, no SDL2.

If I run `dfbinfo` it shows dfb recognises the Z's keyboard and mouse (the touchscreen). If I run `dfbinput` I get logged out and it opens a new QVGA VT. It's definitely got issues somewhere!
« Last Edit: November 09, 2015, 12:09:46 pm by danboid »
Zaurus SL-C3000 w/ MD swapped for a Kingston 32GB Ultimate 266X CF running ALARM
Banana Pi running ALARM on a WD Scorpio SATA II HD
System76 Gazelle Pro i7 laptop w/ SAMSUNG 840 EVO SSD running Arch x64

How to install Arch on your C3x00 Zaurus https://github.com/danboid/ZALARM-install

danboid

  • Hero Member
  • *****
  • Posts: 881
    • View Profile
    • http://
Sdl With Directfb Packages
« Reply #3 on: November 09, 2015, 12:26:23 pm »
I've updated the OP with my experimental PKGBUILD for directfb for anyone who wants to help try get it to work.

The resultant package from using this PKGBUILD doesnt work any better or worse than the directfb in the repos so don't expect it to fix anything in its current state.
Zaurus SL-C3000 w/ MD swapped for a Kingston 32GB Ultimate 266X CF running ALARM
Banana Pi running ALARM on a WD Scorpio SATA II HD
System76 Gazelle Pro i7 laptop w/ SAMSUNG 840 EVO SSD running Arch x64

How to install Arch on your C3x00 Zaurus https://github.com/danboid/ZALARM-install

greguu

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 433
    • View Profile
    • http://github.com/greguu
Sdl With Directfb Packages
« Reply #4 on: November 10, 2015, 12:38:29 am »
Quote from: danboid
Hi daal!

I've tried directfb with chocolate-doom from the repos and it behaves the same as MAME. Using a USB keyboard made no difference - I get the same probs as using the integrated keyboard which is that either directfb spawns a terminal under the window I want to use (which is semi-transparent by default) and that captures keyboard input instead of MAME/DOOM or the keyboard doesn't work at all, depending on what options I feed to DFB.

I've just tried recompiling directfb 1.7.7 using most of the same options you used, most notably using the same input options (minus tslib whch I'm not bothering with yet) but unlike you I didn't disable SDL. Why did you disable SDL when you built directfb?

I built dfb today against the patched SDL package I've posted in the SDL thread as I suspected my probs could've been down to me running a directfb that was compiled against a slightly newer SDL (the one in the repos) but my new dfb package doesn't work any better than the one from the repos despite being built with SDL enabled and only the patched 1.2.14 version of SDL being installed, no SDL2.

If I run `dfbinfo` it shows dfb recognises the Z's keyboard and mouse (the touchscreen). If I run `dfbinput` I get logged out and it opens a new QVGA VT. It's definitely got issues somewhere!

When compiling DirectFB there is no need to include SDL.

The SDL backend on DirectFB makes DirectFB apps run via SDL (mostly used for developing and not what you want).

In theory you could run SDL apps on DirectFB using SDL again and causing a indefinite loop

You only need DirectFB support in SDL to make things work for your purpose.( run SDL apps on DirectFB using FBDEV)

No need for SDL support in DirectFB (hope this makes sense)

So to clarify, SDL is build against DirectFB as a back-end, in your case, not the other way around. Its a bit confusing I know.

I would suggest to build the older DirectFB source I included in the post, then after that, build my SDL source using that DirectFB library and try again.

I did not have these issues back then, and things may have changed with DirectFB newer versions.
« Last Edit: November 10, 2015, 12:45:55 am by daalnroti »
Gemini-PDA (Sailfish X and Android) / LG Nexus 5 (Android 11) / Nokia N9 (MeeGo/Harmattan)
Sharp Zaurus C3100 (Borzoi) - Void Linux (voidz) Kernel 5.0.0 - Hardware (Buffalo CF LAN, DLink 660 CF WiFi, ASIX AX88772 USB Ethernet)

danboid

  • Hero Member
  • *****
  • Posts: 881
    • View Profile
    • http://
Sdl With Directfb Packages
« Reply #5 on: November 10, 2015, 08:33:47 am »
Here's the error I got when trying to build DFB 1.4.11 for ALARM:

Code: [Select]
gcc -DHAVE_CONFIG_H -I. -I.. -I../lib -I../include -I../include -I../lib -I../src -DDATADIR=\"/usr/share/directfb-1.4.11\" -D_REENTRANT -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libpng16 -O3 -ffast-math -pipe -march=armv5te -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_GNU_SOURCE  -std=gnu99 -Werror-implicit-function-declaration -MT directfb-csource.o -MD -MP -MF .deps/directfb-csource.Tpo -c -o directfb-csource.o directfb-csource.c
In file included from /usr/include/libpng16/pngconf.h:50:0,
                 from /usr/include/libpng16/png.h:489,
                 from directfb-csource.c:43:
directfb-csource.c: In function 'load_image':
directfb-csource.c:341:25: error: dereferencing pointer to incomplete type 'png_struct {aka struct png_struct_def}'
      if (setjmp (png_ptr->jmpbuf)) {
                         ^
directfb-csource.c:409:28: error: dereferencing pointer to incomplete type 'png_info {aka struct png_info_def}'
                if (info_ptr->num_palette) {
                            ^
directfb-csource.c: In function 'main':
directfb-csource.c:223:21: warning: ignoring return value of 'fread', declared with attribute warn_unused_result [-Wunused-result]
                     fread(data, statbuf.st_size, 1, f);
                     ^
Makefile:640: recipe for target 'directfb-csource.o' failed
make[2]: *** [directfb-csource.o] Error 1
make[2]: Leaving directory '/root/src/directfb-1.4.11-ALARMZ-PKGBUILD/src/DirectFB-1.4.11/tools'
Makefile:504: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/root/src/directfb-1.4.11-ALARMZ-PKGBUILD/src/DirectFB-1.4.11'
Makefile:371: recipe for target 'all' failed
make: *** [all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
Zaurus SL-C3000 w/ MD swapped for a Kingston 32GB Ultimate 266X CF running ALARM
Banana Pi running ALARM on a WD Scorpio SATA II HD
System76 Gazelle Pro i7 laptop w/ SAMSUNG 840 EVO SSD running Arch x64

How to install Arch on your C3x00 Zaurus https://github.com/danboid/ZALARM-install

danboid

  • Hero Member
  • *****
  • Posts: 881
    • View Profile
    • http://
Sdl With Directfb Packages
« Reply #6 on: November 10, 2015, 12:02:50 pm »
IT'S FIXED!

I can now run MAME4ALL at QVGA fullscreen with working Zaurus keybord input! 11 years I've waited for this!

I've updated the OP with the required packages, PKGBUILD tarballs and instructions!

Thank's again to daal for the orignal patches!

 
Zaurus SL-C3000 w/ MD swapped for a Kingston 32GB Ultimate 266X CF running ALARM
Banana Pi running ALARM on a WD Scorpio SATA II HD
System76 Gazelle Pro i7 laptop w/ SAMSUNG 840 EVO SSD running Arch x64

How to install Arch on your C3x00 Zaurus https://github.com/danboid/ZALARM-install

danboid

  • Hero Member
  • *****
  • Posts: 881
    • View Profile
    • http://
Sdl With Directfb Packages
« Reply #7 on: November 10, 2015, 02:11:15 pm »
NO ITS NOT!

it looks like I celebrated too soon and I'm back to not knowing what is causing the keyboard not to work under directfb because its broke again even though I'm still running the same kernel, sdl and directfb 1.4.16 I was running an hour ago when it was working. Yes, I did remember to add sdl and directfb to the IgnorePkg line before you ask!

Whilst I had my network adapter and cable connected up to my Z, I thought I'd download a few packages. Something I installed today or one of its deps causes keyboard issues with directfb so I may not have needed to rebuild directfb to get the keyboard to work after all although it did still need to be patched anyway to fix the pointer orientation.

Getting really close now at least!
« Last Edit: November 10, 2015, 02:36:53 pm by danboid »
Zaurus SL-C3000 w/ MD swapped for a Kingston 32GB Ultimate 266X CF running ALARM
Banana Pi running ALARM on a WD Scorpio SATA II HD
System76 Gazelle Pro i7 laptop w/ SAMSUNG 840 EVO SSD running Arch x64

How to install Arch on your C3x00 Zaurus https://github.com/danboid/ZALARM-install

danboid

  • Hero Member
  • *****
  • Posts: 881
    • View Profile
    • http://
Sdl With Directfb Packages
« Reply #8 on: November 10, 2015, 03:49:53 pm »
OH YES IT IS WORKING!

It's getting a bit pantomime this now isn't it?

I've fixed my keyboard problem - I 'just' had to add:

Code: [Select]
no-vt-switch
To my /etc/directfbrc so I've updated the SDL guide appropriately.

I don't know why that option became auto-enabled the first few times I ran directfb 1.4.16?  
« Last Edit: November 10, 2015, 03:50:30 pm by danboid »
Zaurus SL-C3000 w/ MD swapped for a Kingston 32GB Ultimate 266X CF running ALARM
Banana Pi running ALARM on a WD Scorpio SATA II HD
System76 Gazelle Pro i7 laptop w/ SAMSUNG 840 EVO SSD running Arch x64

How to install Arch on your C3x00 Zaurus https://github.com/danboid/ZALARM-install

greguu

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 433
    • View Profile
    • http://github.com/greguu
Sdl With Directfb Packages
« Reply #9 on: November 10, 2015, 10:46:47 pm »
Quote from: danboid
IT'S FIXED!

I can now run MAME4ALL at QVGA fullscreen with working Zaurus keybord input! 11 years I've waited for this!

I've updated the OP with the required packages, PKGBUILD tarballs and instructions!

Thank's again to daal for the orignal patches!

 

Hi Dan,

good news.

How is performance ? Sound smooth ? Upload some new  video ?

Cheers!
Gemini-PDA (Sailfish X and Android) / LG Nexus 5 (Android 11) / Nokia N9 (MeeGo/Harmattan)
Sharp Zaurus C3100 (Borzoi) - Void Linux (voidz) Kernel 5.0.0 - Hardware (Buffalo CF LAN, DLink 660 CF WiFi, ASIX AX88772 USB Ethernet)

danboid

  • Hero Member
  • *****
  • Posts: 881
    • View Profile
    • http://
Sdl With Directfb Packages
« Reply #10 on: November 11, 2015, 05:18:22 am »
Whilst MAME does tend to intermittently experience brief slow downs on some 16 bit games, everything I've tried runs full speed and full screen with sound. Finally - usable MAME and SSH in my pocket!

In almost 20 years as a Linux user,  I have never had to put so much effort into getting a program to run properly (and that includes all sorts of servers and server transitions) so damn right I'm going to do a video to let everyone know what I had to go through to get here!

I'll be back soon to post one...
« Last Edit: November 11, 2015, 05:29:43 am by danboid »
Zaurus SL-C3000 w/ MD swapped for a Kingston 32GB Ultimate 266X CF running ALARM
Banana Pi running ALARM on a WD Scorpio SATA II HD
System76 Gazelle Pro i7 laptop w/ SAMSUNG 840 EVO SSD running Arch x64

How to install Arch on your C3x00 Zaurus https://github.com/danboid/ZALARM-install

danboid

  • Hero Member
  • *****
  • Posts: 881
    • View Profile
    • http://
Sdl With Directfb Packages
« Reply #11 on: November 12, 2015, 10:37:32 am »
I've just added some extra info to the intro and cleaned the guide up a bit.
Zaurus SL-C3000 w/ MD swapped for a Kingston 32GB Ultimate 266X CF running ALARM
Banana Pi running ALARM on a WD Scorpio SATA II HD
System76 Gazelle Pro i7 laptop w/ SAMSUNG 840 EVO SSD running Arch x64

How to install Arch on your C3x00 Zaurus https://github.com/danboid/ZALARM-install

greguu

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 433
    • View Profile
    • http://github.com/greguu
Sdl With Directfb Packages
« Reply #12 on: December 08, 2015, 04:23:27 am »
Quote from: danboid
I've just added some extra info to the intro and cleaned the guide up a bit.

Hi danboid,

I was afk, and also currently changed my build machine.

Once I am back up and running and find some time I will continue with a DirectFB/SDL upgrade and get more apps build that use these.

Cheers,
Gemini-PDA (Sailfish X and Android) / LG Nexus 5 (Android 11) / Nokia N9 (MeeGo/Harmattan)
Sharp Zaurus C3100 (Borzoi) - Void Linux (voidz) Kernel 5.0.0 - Hardware (Buffalo CF LAN, DLink 660 CF WiFi, ASIX AX88772 USB Ethernet)

greguu

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 433
    • View Profile
    • http://github.com/greguu
Sdl With Directfb Packages
« Reply #13 on: January 20, 2016, 02:25:18 am »
Hi Dan,

not sure you still follow this thread but I have started with a new build of DirectFB and SDL.
The latest kernel 4.4.0 v0.5 does include a linux-fusion module. This allows multiple DirectFB apps to run at the same time.
Once I got more I will open a new thread. Hope you are interested. Join the chat or PM me if you like.

Cheers!
Gemini-PDA (Sailfish X and Android) / LG Nexus 5 (Android 11) / Nokia N9 (MeeGo/Harmattan)
Sharp Zaurus C3100 (Borzoi) - Void Linux (voidz) Kernel 5.0.0 - Hardware (Buffalo CF LAN, DLink 660 CF WiFi, ASIX AX88772 USB Ethernet)

danboid

  • Hero Member
  • *****
  • Posts: 881
    • View Profile
    • http://
Sdl With Directfb Packages
« Reply #14 on: January 24, 2016, 04:07:08 pm »
Good news daal!

Do you need fusion to have DFB on one VT and a regular console on another?

What do you want to use DFB Fusion for exactly? The the Z even got enough RAM to run more than one interesting DFB app at once?

If I don't do it tonight I'll try the latest kernel out in the next few days.
Zaurus SL-C3000 w/ MD swapped for a Kingston 32GB Ultimate 266X CF running ALARM
Banana Pi running ALARM on a WD Scorpio SATA II HD
System76 Gazelle Pro i7 laptop w/ SAMSUNG 840 EVO SSD running Arch x64

How to install Arch on your C3x00 Zaurus https://github.com/danboid/ZALARM-install