An open source tslib solution for FriendlyARM 1-wire TouchScreen

mindee
hi, all

here is An open source tslib solution for FriendlyARM 1-wire TouchScreen.

please download from the friendlyarm ftp space:/src

file name: one-wire-ts-input-src-20111026.tar.gz
=====================================
an open source tslib for FriendlyARM one wire touch screen, only for Linux,
not Android


How to use
=====================================
by FriendlyARM, 2011-10-26

step1: unzip the source code tarball
    #make
   you will get one-wire-ts-input.so, put it into the mini6410/tiny6410
board: /usr/lib/ts/
Step2:
   vertify the first line in file "/etc/ts.conf"  to:
   module_raw one-wire-ts-input

Step3: Save an reboot,  Done


please try it.

Anna R. (Russia)
))) Better late then never.

Juergen Beisert
midee,

are you interested in a patch for your archive to autotoolize it?

mindee
to Juergen Beisert

I think it is not necessary. it's easy to make and setup.


mindee

deltaT
Hi mindee,

many thanks for the tslib-driver!
Are there any plans on releasing the kernel-mod that controls the
touchscreen- and backlight driver any time soon?

mindee
Hi deltaT

to control backlight, just type "echo 0-127 /dev/backlight-1wire" on the
console.

it is very easy.

mindee

sean_h
thank you

Ann R. (Russia)
I've tryed it and it really works. I can't believe my eyes. I had spent
many days trying to make this 1-wire TS working and now you suggested a
solution.

Ann R. (Russia)
Thanx

sean_h
Hi  Ann

I have run into a problem, Mini6410 platform, using this tslib:

My configuration:

mknod /dev/input/touchscreen-1wire c 10 181
so ts_calibrate, ts_test etc are working
cat /dev/input/touchscreen-1wire generates data when the screen is touched

I have set my environment as follows:
export TSLIB_TSDEVICE=/dev/input/touchscreen-1wire
export TSLIB_TSEVENTTYPE=INPUT
export TSLIB_FBDEVICE=/dev/fb
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/lib/ts
export QWS_MOUSE_PROTO="tslib:/dev/input/touchscreen-1wire
IntelliMouse:/dev/input/mouse1"

The mouse works in the qt application. I have enabled event debugging in
the kernel and touching the mouse generates evbug.c output. Touchscreen in
qt application does not work and evbug does not generate anything. 

Maybe this helps:

cat /proc/bus/input/devices
I: Bus=0013 Vendor=dead Product=beef Version=0101
N: Name="TouchScreen Pipe"
P: Phys=input(ts)
S: Sysfs=/class/input/input0
U: Uniq=
H: Handlers=mouse0 event0 evbug
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003

I: Bus=0003 Vendor=0458 Product=003a Version=0110
N: Name="Genius Optical Mouse"
P: Phys=usb-s3c24xx-1/input0
S: Sysfs=/class/input/input1
U: Uniq=
H: Handlers=mouse1 event1 evbug
B: EV=17
B: KEY=70000 0 0 0 0 0 0 0 0
B: REL=103
B: MSC=10

The following all output "data" only when the mouse is moved:
cat /dev/input/mouse0
cat /dev/input/mouse1
cat /dev/input/event0
cat /dev/input/event1

Ann R. (Russia)
>>Touchscreen in
>>qt application does not work and evbug does not generate anything. 

Check if your qt is built with -qt-mouse-tslib option.

deltaT
WOW HOLD THE PRESSES THERE!
Did I get that correctly from sean's post, that I don't need the
FA-Kernelmod that controls the backlight / touchscreen and just need to
create the nodes for TS / backlight!?

sean_h
Thanks Ann, the problem was kernel related, and that's why event debugging
did not work with the touchscreen.

deltaT, you need a driver and the open source solution mentioned above
works. The mknod command "makes the device driver behave as a file".

ivan_n
Thanks for the solution. It was the only way to make the TS work that I
could find. My board is a micro6410 + 7" LCD.

Currently I am using buildroot to build cross tools (gcc4.6.2), the kernel
(using the 2.6.38 supplied in the DVDs), and everything else from standard
buildroot sources. But just copying the friendlyarm-ts-input somehow did
not work.

For someone following this same route, dont't forget some of the exports
sean_h wrote above, otherwise neither ts_test, ts_calibrate nor QT (-qws)
will work.

Legath
i have error at run it.

[root@FriendlyARM /]# ts_calibrate 
open fbdevice: No such file or directory


My environment 
export TSLIB_TSDEVICE=/dev/touchscreen-1wire
export TSLIB_TSEVENTTYPE=INPUT
export TSLIB_FBDEVICE=/dev/fb
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/lib/ts

[root@FriendlyARM /]# ls usr/lib/ts/
arctic2.so            corgi.so              h3600.so              linear.so
            mk712.so              pthres.so             ucb1x00.so
collie.so             dejitter.so           input.so             
linear_h2200.so       one-wire-ts-input.so  tatung.so            
variance.so

when i try 
cat /dev/touchscreen-1wire
data present on terminal

Legath
im sorry, my bug. resolved

armax
>> im sorry, my bug. resolved

How did you fixed it ?

Legath
use TSLIB_FBDEVICE=/dev/fb0 instead TSLIB_FBDEVICE=/dev/fb

armax
thanks :)
Gonna try this

Legath
patch on last ts-lib. apply and make ./configure. one-wire-ts-input.c
inside. 

diff -Naur tslib-412d99d8b92c/configure.ac
tslib-412d99d8b92c-patched/configure.ac
--- tslib-412d99d8b92c/configure.ac     2011-01-24 19:50:56.000000000 +0000
+++ tslib-412d99d8b92c-patched/configure.ac     2011-12-25
19:07:48.080550732 +0000
@@ -66,6 +66,7 @@
 TSLIB_CHECK_MODULE([arctic2], [yes], [Enable building of arctic2 raw
module (IBM Arctic II support)])
 TSLIB_CHECK_MODULE([tatung], [yes], [Enable building of tatung raw module
(Tatung Webpad support)])
 TSLIB_CHECK_MODULE([input], [yes], [Enable building of generic input raw
module (Linux /dev/input/eventN support)])
+TSLIB_CHECK_MODULE([one-wire-ts-input], [yes], [Enable building of one
wire ts input (Linux /dev/touchscreen-1wire support)])
 
 AC_MSG_CHECKING([where to place modules])
 AC_ARG_WITH(plugindir,
diff -Naur tslib-412d99d8b92c/etc/ts.conf
tslib-412d99d8b92c-patched/etc/ts.conf
--- tslib-412d99d8b92c/etc/ts.conf      2011-01-24 19:50:56.000000000 +0000
+++ tslib-412d99d8b92c-patched/etc/ts.conf      2011-12-25
22:54:06.150193008 +0000
@@ -19,6 +19,9 @@
 # Uncomment if you're using an IBM Arctic II
 # module_raw arctic2
 
+# Uncomment if you're using an Friendlyarm
+module_raw one_wire_ts_input
+
 module pthres pmin=1
 module variance delta=30
 module dejitter delta=100
diff -Naur tslib-412d99d8b92c/plugins/Makefile.am
tslib-412d99d8b92c-patched/plugins/Makefile.am
--- tslib-412d99d8b92c/plugins/Makefile.am      2011-01-24
19:50:56.000000000 +0000
+++ tslib-412d99d8b92c-patched/plugins/Makefile.am      2011-12-25
19:10:56.000545781 +0000
@@ -102,6 +102,12 @@
 CY8MRLN_PALMPRE_MODULE =
 endif
 
+if ENABLE_ONE_WIRE_TS_INPUT_MODULE
+ONE_WIRE_TS_INPUT_MODULE = one_wire_ts_input.la
+else
+ONE_WIRE_TS_INPUT_MODULE =
+endif
+
 pluginexec_LTLIBRARIES = \
        $(LINEAR_MODULE) \
        $(DEJITTER_MODULE) \
@@ -116,7 +122,8 @@
        $(TATUNG_MODULE) \
        $(H2200_LINEAR_MODULE) \
        $(INPUT_MODULE) \
-       $(CY8MRLN_PALMPRE_MODULE)
+       $(CY8MRLN_PALMPRE_MODULE) \
+       $(ONE_WIRE_TS_INPUT_MODULE)
   
 variance_la_SOURCES    = variance.c
 variance_la_LDFLAGS    = -module $(LTVSN)
@@ -165,3 +172,6 @@
 
 cy8mrln_palmpre_la_SOURCES = cy8mrln-palmpre.c
 cy8mrln_palmpre_la_LDFLAGS = -module $(LTVSN)
+
+one_wire_ts_input_la_SOURCES = one-wire-ts-input.c
+one_wire_ts_input_la_LDFLAGS = -module $(LTVSN)
diff -Naur tslib-412d99d8b92c/plugins/one-wire-ts-input.c
tslib-412d99d8b92c-patched/plugins/one-wire-ts-input.c
--- tslib-412d99d8b92c/plugins/one-wire-ts-input.c      1970-01-01
00:00:00.000000000 +0000
+++ tslib-412d99d8b92c-patched/plugins/one-wire-ts-input.c      2011-10-26
06:17:11.000000000 +0000
@@ -0,0 +1,66 @@
+#include <termios.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <linux/fs.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/utsname.h>
+#include <time.h>
+
+
+#include "tslib-private.h"
+
+static int misc_read(struct tslib_module_info *inf, struct ts_sample
*samp, int nr)
+{
+       struct tsdev *ts = inf->dev;
+
+       int ret;
+       unsigned ts_status;
+       ret = read(ts->fd, &ts_status, sizeof ts_status);
+       if (ret < 0) {
+               return 0;
+       }
+       if (ret == 0) {
+               return 0;
+       }
+
+       samp->x = ((ts_status) >> 16) & 0x7FFF;
+       samp->y = ts_status & 0x7FFF;
+       samp->pressure = ts_status >> 31;
+       gettimeofday(&samp->tv,NULL);
+       nr = nr;
+
+       return 1;
+}
+static int ts_fini(struct tslib_module_info *inf)
+{
+        free(inf);
+        return 0;
+}
+
+static const struct tslib_ops misc_ops =
+{
+       .read   = misc_read,
+        .fini   = ts_fini,
+};
+
+TSAPI struct tslib_module_info *one_wire_ts_mod_init(struct tsdev *dev,
const char *params)
+{
+       struct tslib_module_info *m;
+
+       m = malloc(sizeof(struct tslib_module_info));
+       if (m == NULL)
+               return NULL;
+
+       m->ops = &misc_ops;
+       return m;
+}
+
+#ifndef TSLIB_STATIC_FRIENDLYARM_TS_MODULE
+TSLIB_MODULE_INIT(one_wire_ts_mod_init);
+#endif
diff -Naur tslib-412d99d8b92c/plugins/plugins.h
tslib-412d99d8b92c-patched/plugins/plugins.h
--- tslib-412d99d8b92c/plugins/plugins.h        2011-01-24
19:50:56.000000000 +0000
+++ tslib-412d99d8b92c-patched/plugins/plugins.h        2011-12-25
19:01:13.380561130 +0000
@@ -16,3 +16,4 @@
 TSLIB_DECLARE_MODULE(tatung);
 TSLIB_DECLARE_MODULE(input);
 TSLIB_DECLARE_MODULE(cy8mrln_palmpre);
+TSLIB_DECLARE_MODULE(one_wire_ts);

Mohammad Foroughi
Hi,

I tried to compile it for mini210s:

These are steps I done:

    tar -xvf one-wire-ts-input-src-20111026.tar.gz    
    open Makefile and change arm-linux-gcc to gcc
    make
    cp one-wire-ts-input.so /usr/lib/arm-linux-gnueabihf/ts0/
    reboot
    export TSLIB_TSDEVICE=/dev/touchscreen-1wire
    ts_test

But unfortunately I got Segmentation Fault :(

Juergen Beisert
You must keep "arm-linux-gcc" as your cross compiler. "gcc" is your host
compiler and creates wrong code.

Mohammad Foroughi
@ Juergen Beisert :

I am compiling on the board itself, so my gcc is arm-linux-gcc ;)

Mohammad Foroughi
Here gdb output:

root@mini210s:~# gdb ts_test 
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>;...
Reading symbols from /usr/bin/ts_test...(no debugging symbols
found)...done.
(gdb) run
Starting program: /usr/bin/ts_test 

Program received signal SIGSEGV, Segmentation fault.
0x4012c034 in mod_init () from
/usr/lib/arm-linux-gnueabihf/ts0/one-wire-ts-input.so
(gdb)

Mohammad Foroughi
any idea? I really need the touch...

Reggie
try running it with strace or compiling with debugging turned on, you might
get some more meaningful information about the error.

Mohammad Foroughi
Hi,

 I can not recompile with -g3 option, because I am using ubuntu's ts_test
package (compiled package)

 Instead I tried strace:

root@mini210s:~/one-wire-ts-input# strace ts_test
execve("/usr/bin/ts_test", ["ts_test"], [/* 20 vars */]) = 0
brk(0)                                  = 0x14000
uname({sys="Linux", node="mini210s", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or
directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40017000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=33068, ...}) = 0
mmap2(NULL, 33068, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40020000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or
directory)
open("/usr/lib/arm-linux-gnueabihf/libts-0.0.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3,
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\220\n\0\0004\0\0\0"...,
512) = 512
lseek(3, 8636, SEEK_SET)                = 8636
read(3,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
1000) = 1000
lseek(3, 8332, SEEK_SET)                = 8332
read(3, "A6\0\0\0aeabi\0\1,\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\4\22"..., 55)
= 55
fstat64(3, {st_mode=S_IFREG|0644, st_size=9636, ...}) = 0
mmap2(NULL, 42128, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) =
0x40029000
mprotect(0x4002b000, 28672, PROT_NONE)  = 0
mmap2(0x40032000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0x40032000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or
directory)
open("/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3,
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\355p\1\0004\0\0\0"..., 512)
= 512
lseek(3, 888764, SEEK_SET)              = 888764
read(3,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
1360) = 1360
lseek(3, 888324, SEEK_SET)              = 888324
read(3, "A4\0\0\0aeabi\0\1*\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\4\22"..., 53)
= 53
fstat64(3, {st_mode=S_IFREG|0755, st_size=890124, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x40019000
mmap2(NULL, 931200, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) =
0x40034000
mprotect(0x4010a000, 32768, PROT_NONE)  = 0
mmap2(0x40112000, 12288, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xd6) = 0x40112000
mmap2(0x40115000, 9600, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40115000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or
directory)
open("/lib/arm-linux-gnueabihf/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3,
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0<\t\0\0004\0\0\0"..., 512) =
512
lseek(3, 8656, SEEK_SET)                = 8656
read(3,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
1160) = 1160
lseek(3, 8320, SEEK_SET)                = 8320
read(3, "A6\0\0\0aeabi\0\1,\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\4\22"..., 55)
= 55
fstat64(3, {st_mode=S_IFREG|0644, st_size=9816, ...}) = 0
mmap2(NULL, 41136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) =
0x40118000
mprotect(0x4011a000, 28672, PROT_NONE)  = 0
mmap2(0x40121000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0x40121000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4001a000
set_tls(0x40019e60, 0x4001a538, 0x4001f048, 0x40019e60, 0x400197a0) = 0
mprotect(0x40112000, 8192, PROT_READ)   = 0
mprotect(0x40121000, 4096, PROT_READ)   = 0
mprotect(0x40032000, 4096, PROT_READ)   = 0
mprotect(0x11000, 4096, PROT_READ)      = 0
mprotect(0x4001e000, 4096, PROT_READ)   = 0
munmap(0x40020000, 33068)               = 0
rt_sigaction(SIGSEGV, {0x8d61, [SEGV], SA_RESTART|0x4000000}, {SIG_DFL, [],
0}, 8) = 0
rt_sigaction(SIGINT, {0x8d61, [INT], SA_RESTART|0x4000000}, {SIG_DFL, [],
0}, 8) = 0
rt_sigaction(SIGTERM, {0x8d61, [TERM], SA_RESTART|0x4000000}, {SIG_DFL, [],
0}, 8) = 0
brk(0)                                  = 0x14000
brk(0x35000)                            = 0x35000
open("/dev/touchscreen-1wire", O_RDONLY) = 3
open("/etc/ts.conf", O_RDONLY)          = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=676, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4001b000
read(4, "# Uncomment if you wish to use t"..., 4096) = 676
open("/usr/lib/arm-linux-gnueabihf/ts0/one-wire-ts-input.so",
O_RDONLY|O_CLOEXEC) = 5
read(5,
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\240\4\0\0004\0\0\0"...,
512) = 512
lseek(5, 81204, SEEK_SET)               = 81204
read(5,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
1440) = 1440
lseek(5, 4194, SEEK_SET)                = 4194
read(5, "A6\0\0\0aeabi\0\1,\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\4\22"..., 55)
= 55
fstat64(5, {st_mode=S_IFREG|0755, st_size=84712, ...}) = 0
mmap2(NULL, 36924, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 5, 0) =
0x40123000
mprotect(0x40124000, 28672, PROT_NONE)  = 0
mmap2(0x4012b000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 5, 0) = 0x4012b000
close(5)                                = 0
mprotect(0x4012b000, 4096, PROT_READ)   = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
munmap(0, 0)                            = -1 EINVAL (Invalid argument)
close(0)                                = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Segmentation fault
root@mini210s:~/one-wire-ts-input#

Erik
Hi Mohammad,

I had the exact same segault as you both trying to cross compile the
one-wire driver on an x86 host and the 210s as a drop-in patch on a working
ts-lib I was using on a Mini2440 (210s should be able to read arm4v
binaries just fine). I think the segfault is caused by using a different
compiler for tslib and one-wire-ts-input.

I got everything to play nice by recompiling with FriendlyArm's arm-linux
GCC 4.5.1 form the ftp server on my x86. Interestingly this served as a
'drop in' replacement and worked well with a previously compiled
Qt4.7(against an earlier tslib version) running on X11. I guess it means
the tslib1.0 is backwards compatible with tslib0.0...

Hope this saves some people time in the future upgrading from Mini2440s!

Sudhanshu Mehta
anybody able to use touch screen tiny 6410.

please provide your solve

Sudhanshu Mehta
Hi Mindee ,

please provide following files

profile
rcS
ts.conf

Sudhanshu Mehta
http://www.friendlyarm.net/forum/topic/5609
see my tutorial