Search by Tags

Resistive Touch Screen (Linux)

 

Compare with Revision


Subscribe for this article updates

The Colibri T20/T30 and Apalis T30 modules include a driver for resistive touch screens.

Colibri T20

[    6.865817] wm97xx-ts 0-0:WM9711,WM9712,WM9715: detected a wm9712 codec
[    6.880561] input: wm97xx touchscreen as /devices/platform/tegra-ac97/0-0:WM9711,WM9712,WM9715/input/input2

Colibri VF61

The Colibri VF61 uses the Wolfson WM9712 AC97 audio codec for resistive touch support. The driver has several kernel parameters which can be tuned:

Parameter Data type Description
rpu int Set internal pull up resistor for pen detect.
pil int Set current used for pressure measurement.
pressure int Set threshold for pressure measurement.
delay int Set adc sample delay.
abs_x array of int Touchscreen absolute X min, max, fuzz
abs_y array of int Touchscreen absolute X min, max, fuzz
abs_p array of int Touchscreen absolute Pressure min, max, fuzz

The source file in drivers/input/touchscreen/wm9712.c has some more hints to the exact meaning of the values.

The WM9712 driver module is built-in, to set a module parameter the kernel command line needs to be altered. Use the module name wm97xx-ts as prefix so set a parameter:

setenv defargs wm97xx-ts.pil=1

Touch Calibration

The touch calibration can be done using the xinput_calibrator application. BSP 2.x automatically performs a calibration upon first boot so no further action is required. For BSP 1.x to automatically apply the calibration settings upon boot proceed as follows:

root@colibri_t20:~# mkdir /etc/X11/xorg.conf.d
root@colibri_t20:~# xinput_calibrator
Calibrating EVDEV driver for "wm97xx touchscreen" id=6
        current calibration values (from XInput): min_x=3991, max_x=58 and min_y=3932, max_y=351

Doing dynamic recalibration:
        Setting new calibration data: 3999, 74, 4016, 296

--> Making the calibration permanent <--
  copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf'
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "wm97xx touchscreen"
        Option  "Calibration"   "3999 74 4016 296"
EndSection

Now just create the 99-calibration.conf file according to the xinput_calibrator output above:

root@colibri_t20:~# vi /etc/X11/xorg.conf.d/99-calibration.conf
:i
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "wm97xx touchscreen"
        Option  "Calibration"   "3999 74 4016 296"
EndSection
~
:wq
root@colibri_t20:~#

Alternative way to make Touch Calibration Persistent (BSP 1.x)

To automatically apply the calibration settings upon boot one can also proceed as follows:

System - Preferences - Startup Applications
Add
Name: Touch Calibration
Command: xinput set-int-prop "wm97xx touchscreen" "Evdev Axis Calibration" 32 3995 88 3861 304
Comment: Apply touch calibration

As command one can just use the xinput command as output by the xinput_calibrator application. Alternatively if you require more than one xinput command for proper calibration (e.g. due to swapped axes) you can create a script /usr/bin/touch.sh and use this as above command:

#!/bin/sh
export DISPLAY=:0
xinput set-int-prop "wm97xx touchscreen" "Evdev Axes Swap" 8 1
xinput set-int-prop "wm97xx touchscreen" "Evdev Axis Calibration" 32 3957 148 197 3295
xinput set-int-prop "wm97xx touchscreen" "Evdev Axis Calibration" 32 137 4130 3147 179

Colibri Evaluation Board with Toradex 4.3" Sharp WQVGA Touch TFT (V1.0a)

Note (BSP 1.x): Somehow due to swapped axes the calibration needs to be run twice in order to get the desired result.

root@colibri_t20:~# export DISPLAY=:0
root@colibri_t20:~# xinput_calibrator
Calibrating EVDEV driver for "wm97xx touchscreen" id=6
        current calibration values (from XInput): min_x=3995, max_x=88 and min_y=3861, max_y=304

Doing dynamic recalibration:
        Swapping X and Y axis...
        Setting new calibration data: 3957, 148, 197, 3295

Making the calibration permanent (EvalBoard with WQVGA BSP 1.x)

If you have the 'xinput' tool installed, a simple way is to create a script that starts with your X session, containing the following command(s):

    xinput set-int-prop "wm97xx touchscreen" "Evdev Axes Swap" 8 1
    xinput set-int-prop "wm97xx touchscreen" "Evdev Axis Calibration" 32 3957 148 197 3295

If you have evdev version 2.3.0 or higher, there are 2 more ways: the traditional way (xorg.conf) and the new way (udev rule):

xorg.conf: edit /etc/X11/xorg.conf and add in the 'Section "InputDevice"' of your device:
    Option      "Calibration"           "3957 148 197 3295"
    Option      "SwapAxes"      "1" # unless it was already set to 1
udev rule: create the file '/etc/udev/rules.d/99_touchscreen.rules' with:
    ACTION!="add|change", GOTO="xorg_touchscreen_end"
    KERNEL!="event*", GOTO="xorg_touchscreen_end"
    ATTRS{product}!="wm97xx touchscreen", GOTO="xorg_touchscreen_end"
    ENV{x11_options.calibration}="3957 148 197 3295"
    ENV{x11_options.swapxy}="1"
    LABEL="xorg_touchscreen_end"

Iris with EDT ET070080DH6


root@colibri_t20:~# export DISPLAY=:0
root@colibri_t20:~# xinput_calibrator
Calibrating EVDEV driver for "wm97xx touchscreen" id=6
        current calibration values (from XInput): min_x=350, max_x=3900 and min_y=320, max_y=3750

Doing dynamic recalibration:
        Setting new calibration data: 3995, 88, 3861, 304

Making the calibration permanent (Iris with EDT BSP 1.x)

If you have the 'xinput' tool installed, a simple way is to create a script that starts with your X session, containing the following command(s):

    xinput set-int-prop "wm97xx touchscreen" "Evdev Axis Calibration" 32 3995 88 3861 304

If you have evdev version 2.3.0 or higher, there are 2 more ways: the traditional way (xorg.conf) and the new way (udev rule):

xorg.conf: edit /etc/X11/xorg.conf and add in the 'Section "InputDevice"' of your device:
    Option      "Calibration"           "3995 88 3861 304"
udev rule: create the file '/etc/udev/rules.d/99_touchscreen.rules' with:
    ACTION!="add|change", GOTO="xorg_touchscreen_end"
    KERNEL!="event*", GOTO="xorg_touchscreen_end"
    ATTRS{product}!="wm97xx touchscreen", GOTO="xorg_touchscreen_end"
    ENV{x11_options.calibration}="3995 88 3861 304"
    LABEL="xorg_touchscreen_end"

MECS Tellurium with Ampire 5.7" LED VGA Touch TFT

Please note that instead of PWM A the Tellurium uses PWM C aka PWFM2 for back light control requiring a custom kernel to be built with MECS_TELLURIUM being defined (see arch/arm/mach-tegra/board-colibri_t20-panel.c).


root@colibri_t20:~# export DISPLAY=:0
root@colibri_t20:~# xinput_calibrator
Calibrating EVDEV driver for "wm97xx touchscreen" id=6
        current calibration values (from XInput): min_x=350, max_x=3900 and min_
y=320, max_y=3750

Doing dynamic recalibration:
        Setting new calibration data: 107, 3959, 3939, 137

Making the calibration permanent (MECS with Ampire BSP 1.x)

If you have the 'xinput' tool installed, a simple way is to create a script that starts with your X session, containing the following command(s):

    xinput set-int-prop "wm97xx touchscreen" "Evdev Axis Calibration" 32 107 3959 3939 137

If you have evdev version 2.3.0 or higher, there are 2 more ways: the traditional way (xorg.conf) and the new way (udev rule):

xorg.conf: edit /etc/X11/xorg.conf and add in the 'Section "InputDevice"' of your device:
    Option      "Calibration"           "107 3959 3939 137"
udev rule: create the file '/etc/udev/rules.d/99_touchscreen.rules' with:
    ACTION!="add|change", GOTO="xorg_touchscreen_end"
    KERNEL!="event*", GOTO="xorg_touchscreen_end"
    ATTRS{product}!="wm97xx touchscreen", GOTO="xorg_touchscreen_end"
    ENV{x11_options.calibration}="107 3959 3939 137"
    LABEL="xorg_touchscreen_end"