Letux Kernel

Issue 470: Touchscreen for Android

Reported by Nikolaus Schaller, Jul 29, 2013

It appears (citing a mail from Radek Polak on the gta04-devel list) 
that we need:

"I backported patch for android to use monotonic clock for 
input events, reverted y axis and hardcoded calibration for my 
touchscreen."

I assume that this does not harm Xorg (except a different 
calibration set) since a pre-calibrated touch can also be handled 
and Xorg can revert the y axis in any way it needs.

Comment 1 by Nikolaus Schaller, Jul 30, 2013

working on it - some patch from GNUtoo / PaulK appears to be a good 
basis.
Owner: hns

Comment 2 by Nikolaus Schaller, Jul 30, 2013

Essentially this are two issues.

Issue 1: touch screen on Android has no calibration, i.e. a 
reasonably good precalibration (and flipping the y axis) must be 
done in the kernel.

Issue 2: monotonic event timestamps are expected by the Android 
input driver. This can be either enabled by some ioctl already 
supported by the kernel (but not from Android user space) or by a 
kernel patch (which is unlikely to be accepted upstream).

Comment 3 by Nikolaus Schaller, Jul 30, 2013

Issue 1 is fixed by:

http://git.goldelico.com/?p=gta04-kernel.git;a=commit;h=772f8bdb1e9b8
da80e38306d77b215b18bf770ab

Comment 4 by Alexandre Roumiantsev, Sep 13, 2013

Just to kick on subj solution - semi-working touchscreen ( move 
pointer to place / double click to effect ): 
https://docs.google.com/file/d/0B-rRgKAzYyoBYkxOdGdVc3V4VFk/edit?usp=
sharing
Build from current Replicant repo, nail-3.1x-plus kernel repo from 
goldelico and small patch:
project frameworks/base/
diff --git a/services/input/EventHub.cpp 
b/services/input/EventHub.cpp
index c527bfc..a6a93a6 100644
--- a/services/input/EventHub.cpp
+++ b/services/input/EventHub.cpp
@@ -669,7 +669,7 @@ size_t EventHub::getEvents(int timeoutMillis, 
RawEvent* buff
                                 (int) iev.time.tv_sec, (int) 
iev.time.tv_usec,
                                 iev.type, iev.code, iev.value);
 
-#ifdef HAVE_POSIX_CLOCKS
+#if 0 /* def HAVE_POSIX_CLOCKS*/
                         // Use the time specified in the event 
instead of the c
                         // so that downstream code can get more 
accurate estima
                         // event dispatch latency from the time the 
event is en

Comment 5 by Alexandre Roumiantsev, Sep 14, 2013

New build  
https://docs.google.com/file/d/0B-rRgKAzYyoBdU1WRjRXRUMtYkk/edit?usp=
sharing of semi-working touchscreen with more correct patch:
project frameworks/base/
diff --git a/services/input/EventHub.cpp 
b/services/input/EventHub.cpp
index c527bfc..1d5b37e 100644
--- a/services/input/EventHub.cpp
+++ b/services/input/EventHub.cpp
@@ -684,6 +684,25 @@ size_t EventHub::getEvents(int timeoutMillis, 
RawEvent* buf
fer, size_t bufferSiz
                         event->when = nsecs_t(iev.time.tv_sec) * 
1000000000LL
                                 + nsecs_t(iev.time.tv_usec) * 
1000LL;
                         LOGV("event time %lld, now %lld", 
event->when, now);
+
+                            // Double-check.  Time may have moved 
on.
+                            nsecs_t time = 
systemTime(SYSTEM_TIME_MONOTONIC);
+                            if (event->when > time) {
+                                LOGW("An input event from %s 
has a timestamp th
at appears to "
+                                        "have been generated 
using the wrong cl
ock source "
+                                        "(expected 
CLOCK_MONOTONIC): "
+                                        "event time %lld, 
current time %lld, call time %lld.  "
+                                        "Using current time 
instead.",
+                                        device->path.string(), 
event->when, time, now);
+                                event->when = time;
+                            } else {
+                                LOGV("Event time is ok but 
failed the fast path and required "
+                                        "an extra call to 
systemTime: "
+                                        "event time %lld, 
current time %lld, call time %lld.",
+                                        event->when, time, now);
+                            }
+                        
+
 #else
                         event->when = now;
 #endif

Comment 6 by Nikolaus Schaller, Oct 1, 2013

Reassigned since it needs to be tested/integrated with Replicant.

NOTE: there was also somebody saying that the latest kernels support 
the monotonic input events if initialized correctly through some 
ioctl(). Thsi ioctl() was rumoured to be in Android 4.x (maybe not 
yet in 4.0).
Owner: slyon

Comment 7 by Nikolaus Schaller, Oct 1, 2013

Reassigned since it needs to be tested/integrated with Replicant.

NOTE: there was also somebody saying that the latest kernels support 
the monotonic input events if initialized correctly through some 
ioctl(). Thsi ioctl() was rumoured to be in Android 4.x (maybe not 
yet in 4.0).
Owner: slyon

Comment 8 by Lukas M, Oct 28, 2013

2nd issue is fixed in 3.12-wip-replicant4 branch, by making the 
kernel always send monotonic input events. This HACK can probably be 
dropped at some point in the future, when we use an Android 
uerspace, which makes use of the ioctl() (Android-4.0 doesn't).

Furthermore, the TSC2007-GTA04's name had to be changed to 
"tsc2007", to make Android recognize it as an absolute 
pointing device:

    - input_dev->name = "TSC2007 Touchscreen";
    + input_dev->name = "tsc2007";
Status: Fixed

Created: 11 years 9 months ago by Nikolaus Schaller

Updated: 11 years 6 months ago

Status: Fixed

Owner: Lukas M

Followed by: 1 person

Labels:
Type:Defect
Priority:Medium
Milestone:3.1x