Skip to content
Advertisement

can’t get tslib to work with FT5x06

I have a arm based board with embedded linux on it and I believe it has a FT5x06 touch screen controller but seems like tslib has some problems with multitouch capacitive touch screen controllers. I cross compiled tslib with arm-linux-gcc4.5.1 and when after copying necessary files and setting necassary environmental variables for tslib on the target when I ran ts_calibrate a window shows up and it says that:

tslib: Selected device is not a touchscreen (must support ABS_X and ABS_Y events)

And it doesn’t accept my touches. Now I think somehow I’m supposed to get tslib to work with the controller as a single touch device but I’m not sure how to do that or which file to change. Do I have to edit driver file in kernel and rebuild it too?

Do you have any ideas?

I want to use tslib as an input for my Qt4 program.

Advertisement

Answer

Tslib will require the setup of several files and/or environment variables to work out of the box. Here is a sample of some environment variables,

 TSLIB_CONSOLEDEVICE=none
 TSLIB_FBDEVICE=/dev/fb0
 TSLIB_TSDEVICE=/dev/input/touch
 TSLIB_CALIBFILE=/etc/pointercal
 TSLIB_CONFFILE=/etc/ts.conf

Many variables are not needed to run Qt with tslib. However, you will need the TSLIB_TSDEVICE, TSLIB_CALIBFILE, and TSLIB_CONFFILE to use with Qt. The binaries ts_calibrate will use the TSLIB_FBDEVICE device to display some text. This will then write a configuration to the TSLIB_CALIBFILE.

To determine the correct TSLIB_TSDEVICE to use, the files /sys/class/input/input*/name can be examined. The name should be something like FT5202 Touchscreen. I use this information at boot time to soft link /dev/input/inputX to /dev/input/touch in the example above. The inputX file may change as other input drivers are plugged into a system, such as a USB mouse, etc. These file locations may depend on the type of udev or mdev you use for the /dev directory population in user space.

The ts.conf file is a list of modules to load. Here is an example for the ‘Focal Tech’ device,

module_raw input
module linear

Tslib is structured with several modules (shared libraries) which are loaded dynamically at run time. Typically, these modules need to be loaded to /usr/lib/ts and your kernel and filesystem (libc) need to support shared libraries. Specifically, the linear module will use the output of the ts_calibrate program to map touch co-ordinates to screen co-ordinates. This was much more useful with resistive touch technology where x and y parameters may inter-mix, including sheering, etc.

Note: it is possible to avoid this calibration step, which is highly desirable if you are manufacturing large quantities.

The numbers in the /etc/pointercal are read into an array a[0] -> a[7]. The formula is like this,

x' = (a2 + a0 *x + a1 * y) / a6;
y' = (a5 + a3 *x + a4 * y) / a6;

For the capacitive case, there is no sheer. Moreover, the values for the FocalTech devices seem to be restricted so that screen position (0,0) is touch position (0,0) and all the devices give the same maximum (x,y) values. So the equations reduce to,

x' = (a1 * x) / a6;
y' = (a4 * y) / a6;

So the only purpose of the pointercal file is to map touch to screen co-ordinates AND the same for each device. So you can manual hex-edit a pointercal file when you back solve the equations for the maximum screen positions. You can get this information via the ts_print_raw binary.

Finally, the Qt Mouse Calibration class can be used to completely avoid tslib. You only need code with the fixed three constants that will transform the co-ordinates. You avoid the tslib package entirely.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement