LibSDL

From OpenTom
Jump to: navigation, search

Contents

libSDL

After not having any luck with the standard libSDL drivers, I finally bit the bullet and decided to write my own. While the "fbcon" video driver originally seemed the correct driver to use, it's dependency on a virtual console meant it would not play on my TomTom. While others seem to have tried compiling this into the kernel, it hasn't seemed to have helped.

I began by making a copy of the fbcon video driver and hacking out alot of code, I ended up with a tomtomfb SDL driver. At the moment, software surfaces are supported only (I've only just begun to look at the kernel source, but is there any hardware accel?), but it now works with tslib! When I figure out how to make a patch file I'll stick it up here (as this is a hobby project, it might take a day or two). In the mean time, here are my notes on the process.

Requirements

It is assumed that the golinux kernel source is available and has been built at least once. The tslib library and header also need to be accessible and, if so, should be picked up automagically by the configure script. Again, the assumption is that a development environment similar to this one is being used.

Compiling and Installing

After patching the SDL source directory, execute the following:

./configure --prefix=$TT_INSTALLDIR  --host=arm-linux --target=arm-linux \
 --disable-audio --disable-joystick --disable-cdrom --disable-video-x11 \
 --disable-x11-vm --disable-dga --disable-video-x11-dgamouse \
 --disable-video-x11-xv --disable-video-x11-xinerama --disable-video-directfb \
 --disable-video-fbcon --enable-video-tomtomfb \
 CPPFLAGS="-I${TT_INCLUDEDIR} -I${TT_LINUXINCLUDEDIR}" LDFLAGS="-L${TT_LIBDIR}"
make
make install
cd test
CC=arm-linux-gcc ./configure --with-sdl-prefix=$TT_INSTALLDIR \
 --host=arm-linux --target=arm-linux

Testing and Using SDL

Most of the SDL test applications take "-width", "-height", "-bpp" and "-fullscreen" arguments, so can be configured for different platforms via a launch script, however "testvidinfo" has these values hardcoded and thus required some editing. Aside from that, there seems to be an issue with calling the function "SDL_ShowCursor" before "SDL_SetVideoMode" which was causing the original "testvidinfo" to abort. Moving the "SDL_ShowCursor" call to right after "SDL_SetVideoMode" fixed this.

Like tslib, SDL requires some environmental variables to be set, prior to use. A shell script to do this, as well as call an SDL application is as follows:

#!/bin/sh

export ROOT_DIR=/mnt/sdcard/root

export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb
export TSLIB_TSDEVICE=/dev/ts
export TSLIB_CALIBFILE=$ROOT_DIR/etc/pointercal
export TSLIB_CONFFILE=$ROOT_DIR/etc/ts.conf
export TSLIB_PLUGINDIR=$ROOT_DIR/usr/lib/ts

export SDL_MOUSEDRV=TSLIB
export SDL_MOUSEDEV=$TSLIB_TSDEVICE
export SDL_NOMOUSE=1
export SDL_FBDEV=/dev/fb
export SDL_VIDEODRIVER=tomtomfb

export PATH=$ROOT_DIR/usr/bin:$PATH
export LD_LIBRARY_PATH=$ROOT_DIR/usr/lib

export LOGFILE=$ROOT_DIR/sdllog.txt
cd $ROOT_DIR

echo "=================" >> $LOGFILE
echo "Starting sdl test" >> $LOGFILE

#echo "Running ts_calibrate..." >> $LOGFILE
#ts_calibrate 2>&1 >> $LOGFILE
#echo "done." >> $LOGFILE

echo "Running testvidinfo..." >> $LOGFILE
./testvidinfo -benchmark 2>&1 >> $LOGFILE
echo "done." >> $LOGFILE

#echo "Running testsprite..." >> $LOGFILE
#./testsprite -width 480 -height 272 -bpp 16 -fullscreen 100 >> $LOGFILE
#echo "done." >> $LOGFILE

echo "Exiting..." >> $LOGFILE

tslib functionality within SDL was verified using SDL test applications which did not hide the "mouse" cursor. Mouse button "click" functionality needs to be verified.

Test Results

The result of the most recent execution of testvidinfo is as follows (unsure on the accuracy of the hardware surfaces line, since it is a hacked driver):

Video driver: tomtomfb
Current display: 480x272, 16 bits-per-pixel
	Red Mask = 0x0000f800
	Green Mask = 0x000007e0
	Blue Mask = 0x0000001f
Fullscreen video modes:
	480x272x16
Hardware surfaces are available (510K video memory)
===================================
Setting video mode: 480x272 at 16 bpp, flags: 0x80000000 SDL_SWSURFACE | SDL_FULLSCREEN
Running color fill and fullscreen update test
768 fills and flips in 5.92 seconds, 129.80 FPS
Running freshly loaded blit test: 408x167 at 8 bpp, flags: 0x00000000 SDL_SWSURFACE
5000 blits / 500 updates in 27.72 seconds, 18.04 FPS
Running freshly loaded cc blit test: 408x167 at 8 bpp, flags: 0x00003000 SDL_SWSURFACE | SDL_SRCCOLORKEY | SDL_RLEACCELOK
5000 cc blits / 500 updates in 24.36 seconds, 20.53 FPS
Running display format blit test: 408x167 at 16 bpp, flags: 0x00000000 SDL_SWSURFACE
5000 blits / 500 updates in 18.13 seconds, 27.58 FPS
Running display format cc blit test: 408x167 at 16 bpp, flags: 0x00003000 SDL_SWSURFACE | SDL_SRCCOLORKEY | SDL_RLEACCELOK
5000 cc blits / 500 updates in 12.87 seconds, 38.86 FPS
Running display format alpha blit test: 408x167 at 16 bpp, flags: 0x00010000 SDL_SWSURFACE | SDL_SRCALPHA
5000 alpha blits / 500 updates in 47.98 seconds, 10.42 FPS
Running display format cc+alpha blit test: 408x167 at 16 bpp, flags: 0x00013000 SDL_SWSURFACE | SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCELOK
5000 cc+alpha blits / 500 updates in 32.81 seconds, 15.24 FPS
Personal tools