Hi,
I did an experiment to remove all other parts of the system like epdc driver, wifi, etc so that the only variable that is relevant is the uart. I wrote a single file test program for the wacom. I have attached the source. I got some unexpected results. In this test, I just wanted to see how long it takes for the serial_mxc driver to notify userspace about uart data. The test procedure is just to run the test, and then hold the pen/stylus continuously on the wacom and then see the first message latency.
a) with wacom set to our normal speed (133 samples/sec)
# WACOM_SR=1 ./wacomtest
Elapsed 3418ms, Point 0 : 0xa0 4 d a 4a 0, touched point count 0
Elapsed 0ms, Point 1 : 0xa0 4 14 a 4a 0, touched point count 0
...
Elapsed 0ms, Point 507 : 0x80 6 64 a 5b 0, touched point count 466
So it took 3.4s for the first 9 bytes to be received after the uart first byte interrupt was passed to userspace. The number 3418ms is consistent. If I repeat the test 10 times, it is always 3418ms so it looks like that is a timeout that is controlled somewhere. However it is not the options.c_cc[VMIN] parameter as I tried different values there and it is still 3418ms.
If I change the test and touch the panel with the stylus, wait 1s, then lift the stylus, then I get:
Elapsed 984ms, Point 135 : 0xa0 7 1a 9 1f 0, touched point count 101
...
Elapsed 0ms, Point 267 : 0x80 6 4f 8 2a 0, touched point count 208
This is consistent with a separate behavior we observed where the wacom data seems to be buffered at the uart and only passed to userspace after the wacom stops generating data (ie: when the pen is lifted out of range) or the 3418ms timeout occurs.
If I wait 2s before lifting the pen, then I get:
Elapsed 1773ms, Point 0 : 0xa0 7 6b 8 36 0, touched point count 0
...
Elapsed 0ms, Point 237 : 0x80 9 38 7 26 0, touched point count 218
So that latency being correlated with wait time or timeout is consistent.
The key observation is that if I change the wacom's sampling rate to 40 samples/second, then this causes both the latency issue and the overflow issue to go away. Eg:
WACOM_SR=3 ./wacomtest
Elapsed 6ms, Point 0 : 0xa0 4 19 6 51 0, touched point count 0
Elapsed 6ms, Point 1 : 0xa0 4 1a 6 57 0, touched point count 0
...
Elapsed 7ms, Point 164 : 0x80 4 5d 6 63 0, touched point count 156
In above, we can see that the latency for the same test procedure dropped from 3418ms to 6ms. The other difference is that there is a latency between samples of about 6ms.
If I change the sample rate to 80 samples/second, then the latency remains good.
WACOM_SR=2 ./wacomtest
Elapsed 6ms, Point 0 : 0xa0 5 7b 6 12 0, touched point count 0
Elapsed 6ms, Point 1 : 0xa0 5 7b 6 12 0, touched point count 0
...
Elapsed 7ms, Point 155 : 0x80 5 6c 7 55 0, touched point count 133
Since the 6ms latency seems unaffected by the sample rate change between 80 to 40 samples/second, it would look like the latency is due to some interaction between uart driver and application.
At the moment, I'd be happy if I could get the 6ms latency with the normal 133 samples/sec but I can't seem to figure out what uart configuration or parameter controls that latency.
Please let me know if you have any suggestions/ideas.
Thanks!