New Blog over at root42.de/blog

Blogger is out -- long live the new Blog! Head now over to http://www.root42.de/blog and get all the same content you had here!


ScummVM fullscreen on a Raspberry Pi TFT touchscreen

I managed to get ScummVM running on the 3.5" Waveshare touchscreen. This is obviously only nice, if it runs fullscreen. Have a look:

For this to work, you need to adjust your openbox configuration, assuming you are running a default Raspbian with LXDE / openbox. Edit .config/openbox/lxde-pi-rc.xml and add the following to the applications section:

   <application class="scummvm" name="scummvm">  

You can switch between fullscreen and windowed mode by pressing Alt+F11, in the default openbox configuration.

Next, you need to install scummvm and the OpenGL software rasterizer, since the touch screen frame buffer does not support the hardware OpenGL engine that the Pi provides:

$ sudo apt-get install scummvm mesa-utils libgl1-mesa-dri libgl1-mesa-swx11

This will also install dri drivers and some OpenGL utilities, such as glxgears to test performance.

Now you want to tell ScummVM to actually use the OpenGL backend driver, or else it will not scale to, but rather use the default 2x scaler, which is too large for the 480x320 display. Easiest way to do this is to edit ~/.scummvmrc (you have to have run ScummVM at least once for this) and edit the [scummvm] section to have these lines:


If gfx_mode or the other lines already exist, edit them to your liking.

Installing an ads7864 based Raspberry Pi TFT touchscreen (Waveshare 3.5" LCD)

I have a Waveshare 3.5" TFT touch screen for the Raspberry Pi. Those displays come with some software to help set it up. Sadly, this only works for Raspbian based on Debian 7. The new Raspbian Debian 8 (Jessie) does not play well with this setup. So here is what I did to make it work.

First of all, you need to upgrade the kernel on your brand new Jessie installation:

$ sudo rpi-update
$ sudo power off

I had to do the power off, or else the Pi would show only a black screen after reboot. YMMV.

Next up, we need to change the boot parameters, i.e. the /boot/config.txt and /boot/cmdline.txt. Add the following to the end of /boot/cmdline.txt:

fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo

This chooses a smaller font for the framebuffer console and turns off the boot logo.

Second, add the following lines to the end of /boot/config.txt:


Next step is setting up all the kernel modules. Make sure /etc/modules contains exactly these line:


The options for these modules have to be put in a file called /etc/modprobe.d/lcd.conf:

options flexfb  width=320  height=480  regwidth=16 init=-1,0xb0,0x0,-1,0x11,-2,250,-1,0x3A,0x55,-1,0xC2,0x44,-1,0xC5,0x00,0x00,0x00,0x00,-1,0xE0,0x0F,0x1F,0x1C,0x0C,0x0F,0x08,0x48,0x98,0x37,0x0A,0x13,0x04,0x11,0x0D,0x00,-1,0xE1,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0xE2,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0x36,0x28,-1,0x11,-1,0x29,-3
options fbtft_device debug=3 rotate=90 name=flexfb speed=16000000 gpios=reset:25,dc:24
options ads7846_device model=7846 cs=1 gpio_pendown=17  keep_vref_on=1 swap_xy=1 pressure_max=255 x_plate_ohms=60 x_min=200 x_max=3900 y_min=200 y_max=3900

Next up are the X11 configurations. First, add a file /etc/X11/xorg.conf.d/99-calibration.conf with the following content:
Section "InputClass"
    Identifier "calibration"
    MatchProduct "ADS7846 Touchscreen"
    Option "Calibration" "126, 3734, 3892, 199"
    Option "SwapAxes" "1"

You also need to edit /usr/share/X11/xorg.conf.d/99-fbturbo.conf. It should already exist, and you need to make it have this content:

Section "Device"
        Identifier      "Allwinner A10/A13 FBDEV"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb1"
        Option          "SwapbuffersWait" "true"

The change is setting the fbdev to /dev/fb1, which is the touchscreen, instead of /dev/fb0, which is the HDMI output.

Last but not least, you may want to install the input calibration tool:

$ sudo apt-get install xinput-calibrator

After all this, reboot and hopefully the Pi will reboot into a tiny X11 session on the touch screen.

You can calibrate the display by running this, e.g. via an ssh session:

$ DISPLAY=:0 xinput_calibrator 
Calibrating EVDEV driver for "ADS7846 Touchscreen" id=6
        current calibration values (from XInput): min_x=3932, max_x=300 and min_y=294, max_y=3801

Doing dynamic recalibration:
        Swapping X and Y axis...
        Setting calibration data: 2763, 2763, 2942, 2978
        --> Making the calibration permanent <-- span="">
  copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's)
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "2763 2763 2942 2978"
        Option  "SwapAxes"      "1"

You simply have to replace the calibration and swap axes lines into your /etc/X11/xorg.conf.d/99-calibration.conf, which we created earlier.