Reprinted 1:
Tslib ported to Android for touchscreen calibration.Since Android doesn' t provide a calibration tool, tslib
Can be used to calibrate the touchscreen. The values obtained from
Ts_calibrate in pointercal file can be used in Android
Frameworks/services/Java/COM/Android/Server/inputdevice. Java to have
Correct screen coordinates.
Ts_calibrate can be run from
Serial console along with Android with the proper environment variables
Set (these variables are supported ented in Android. mk too), the default
Values are:
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_CONFFILE=/system/etc/ts.conf
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_PLUGINDIR=/system/lib
export TSLIB_CONSOLEDEVICE=/dev/tty
export TSLIB_FBDEVICE=/dev/graphics/fb0
To
Compile tslib for your device make a link
Bionic/libc/include/fcntl. h to Bionic/libc/include/sys/fcntl. h Import
Build/envsetup. SH and execute make or M.
To make tslib build everytime you build your android distribution copy the Android-tslib folder to Android external/folder.
Download:
Git: git clone git: // git. linuxconsulting. ro/android-tslib.git
HTTP: http://git.linuxconsulting.ro
Reprinted 2:
Android
Porting (touch screen) I found there are so far questions of touch screen aksedAndroid
Engineers, I have made the wm9713 touch screen work OK, so shared my
Experience out. This blog page is written by English, hope all
Engineers can read it. Hardware: PXA270, wm9713 touch screen, LCD 480x272my kernel is the offical kernel fromAndroid
(2.6.25 ),
But it does not support the wm97xx touch screen. It is luck that
Kernel 2.6.26 is merged the wm97xx touch screen driver. So I shold
Porting the wm97xx touch screen driver from 2.6.26 to 2.6.25. First step, diff the other touch screen drivers in
Drivers/input/touchscreen, I found there are almost no changes, so it is
Safe to copy the wm97xx drivers from 2.6.26 to 2.6.25. Modify
Drivers/input/touchscreen/kconfig and makefile, copy
Linux/wm97xx. H. But there is anothor problem, the wm9713 touch
Screen is dependent the ac97, so the ac97 Sound Bus shocould be
Configured. It is easy to complie the driver successfully. (the mainstone
Accelate driver does not compiled in... it is the result of Processing
Tries !) Booting the kernel, the device for touch screen can be foud in
/Dev/event1 (event0 for the keypad). Write a test program for touch
Screen: # include <stdio. h>
# Include <unistd. h>
# Include <sys/types. h>
# Include <fcntl. h>
# Include <Linux/input. h> # define ts_dev "/dev/event1" static int ts_fd =-1; static int init_device ()
{
If (ts_fd = open (ts_dev, o_rdonly) <0)
{
Printf ("error open % s/n", ts_dev );
Return-1;
} Return ts_fd;
} Int main ()
{
Int I; struct input_event data; If (init_device () <0)
Return-1; while (1)
{
Read (ts_fd, & Data, sizeof (data ));
If (data. type = ev_key)
{
Printf ("type: ev_key, event = % s, value = % d/N ",
Data. Code = btn_touch? "Btn_touch": "unkown", Data. value );
}
Else if (data. type = ev_abs)
{
Printf ("type: ev_abs, event = % s, value = % d/N ",
Data. Code = abs_x? "Abs_x ":
Data. Code = abs_y? "Abs_y ":
Data. Code = abs_pressure? "Abs_pressure ":
"Unkown", Data. value );
}
Else if (data. type = ev_syn)
{
Printf ("type: ev_syn, event = % s, value = % d/N ",
Data. Code = syn_report? "Syn_report": "unkown", Data. value );
}
Else
{Printf ("type: 0x % x, event = 0x % x, value = % d/N", Data. type, Data. Code, Data. value );
}
} Return 0;
} The test program can catch the touch screen data (X, Y, pressure), The dirver seems work OK. RunAndroid
System, but the system does not response to the touch screen .... according to the Google search, check/dev/input/event1,/proc/bus/input/devices... all seem OK. some very important hints from the talk between twoAndroid
Hackers: http://androidzaurus.seesaa.net/article/90045743.htmlAnd some important words: "It seemsAndroid
Wants to know not only pressure becomes zero but also pendown becomes zero. Only two lines but very precious lines
. "From http://androidzaurus.seesaa.net/article/96581331.html so check my driver and test again. The test program reports that the x y coordinate is very
Large (350-3900 for X, 320-3750 for Y, defined in driver), but the LCD is
480x270, and the adroid use the abusolute touch screen coordinate,
Which is same to LCD. Calibrate shocould be done, butAndroid
Doe not do this. downloadTslib
-1.4.tar.gz,
Compile, run the ts_calibrate, and run ts_test, the touch screen works
OK. And calibrate coefficent is record in/etc/pointercal. But how to use the calibrate resultAndroid
? Confused for hours... I cann't change the adroid input action, so I shocould do the calibrate in my driver. ReadingTslib
Source code, got the idea. I found a formula inTslib
/Plugins/linear. c xtemp = samp-> X; ytemp = samp-> Y;
Samp-> X = (Lin-> A [2] +
Lin-> A [0] * xtemp +
Lin-> A [1] * ytemp)/Lin-> A [6];
Samp-> Y = (Lin-> A [5] +
Lin-> A [3] * xtemp +
Lin-> A [4] * ytemp)/Lin-> A [6];
And
The Lin-> A [] is read from the/etc/pointercal. But the Division
"/" Is hard for Linux kernel. surprised that the [6] Is 65536, and can
Do the/65536 by> 16. coding in wm9713 DRIVER: Drivers/input/touchscreen/wm97xx-core.c
, Function: static int wm97xx_read_samples (struct wm97xx * WM) define the Coeficient table, change the last variable valure from 65536 to 16.int axis_table [] = {-8360, 32,327 53552, 24,498 3, -1685240, 16}; // from/etc/pointercal by ts_calibrate # ifdef ts_abs_xy
Int xraw, yraw, xtmp, ytmp; dev_dbg (WM-> Dev,
"Pen down: x = % x: % d, y = % x: % d, pressure = % x: % d/N ",
Data. x> 12, Data. X & 0 xfff, Data. Y> 12,
Data. Y & 0 xfff, Data. P> 12, Data. P & 0 xfff );
Xraw = (data. X & 0 xfff );
Yraw = (data. Y & 0 xfff );
Xtmp = (axis_table [2] + axis_table [0] * xraw + axis_table [1] * yraw)
> Axis_table [6];
Ytmp = (axis_table [5] + axis_table [3] * xraw + axis_table [4] * yraw)
> Axis_table [6];
Input_report_abs (WM-> input_dev, abs_x, xtmp );
Input_report_abs (WM-> input_dev, abs_y, ytmp );
# Else
Input_report_abs (WM-> input_dev, abs_x, Data. X & 0 xfff );
Input_report_abs (WM-> input_dev, abs_y, Data. Y & 0 xfff );
# Endif run the test program again, it is great that the touch screen coordinate is same to the LCD, runAndroid
System, but the system does not response to the touch screen. hear broken... check driver, input_report_key... is not added according to http://androidzaurus.seesaa.net/article/96581331.html (1) if (RC & rc_penup ){
If (WM-> pen_is_down ){
Wm-> pen_is_down = 0;
Dev_dbg (WM-> Dev, "pen up/N ");
Input_report_abs (WM-> input_dev, abs_pressure, 0 );
Input_report_key (WM-> input_dev, btn_touch, Wm-> pen_is_down );
Input_sync (WM-> input_dev); (2) input_report_abs (WM-> input_dev, abs_pressure, Data. P & 0 xfff );
Wm-> pen_is_down = 1;
Input_report_key (WM-> input_dev, btn_touch, Wm-> pen_is_down );
Input_sync (WM-> input_dev); run test program again, but can't catch the ev_key event, confused
... Trace the kernel source code, found some bit map shoshould be masked. and in static int wm97xx_probe (struct device * Dev) set_bit (ev_abs, Wm-> input_dev-> evbit );
Set_bit (abs_x, Wm-> input_dev-> absbit );
Set_bit (abs_y, Wm-> input_dev-> absbit );
Set_bit (abs_pressure, Wm-> input_dev-> absbit); so, the bit mask shocould be done for ev_key set_bit (ev_key, Wm-> input_dev-> evbit );
Set_bit (btn_touch, Wm-> input_dev-> keybit );
Run the test program, the ev_key can be catched now. Run Android,
Touch the screen, the icon can be actived by touch... great successfully
... Good lucky to all android workers!