Rework of AM335x Linux driver for resistive touchscreens
The existing driver for resistive touchscreens (in Linux 3.2.0) has several
limitations and weaknesses, so I had to enhance quality and performance.
Items covered:
1) The touch pressure was using the resistance of the foil as an input parameter.
However, since the output value do not need to be scaled to the resistance, this
parameter is not neccessary and was removed.
2) The interrupt function was triggered from the wrong interrupt source, so at
the time of execution, the last ADC sample was not ready. So the programmer has
inserted a udelay(315) inside the interrupt function (argh!). Using the EOS
interrupt removes this eating of CPU power.
3) "Pen Up" Events were not filtered in the driver. So, every spurious Pen Up
was sent to user space, which will interrupt gesture recognition.
A kernel timer with a default timeout of 100ms was used to filter such Pen Up
spikes.
4) Scaling from ADC to screen coordinates was implemented inside the touch
driver, in order to do calibration-on-the-fly, without having to reboot android.
5) The ADC state machine was running at full speed (24MHz), which would generate
MANY touch events and eating up CPU power. Use the CLKDIV register to reduce
clock by a factor of 20.
6) The filtering of the ADC samples was far from perfect. Spikes from the LCD
produced a position error of +/- 2mm. There was a constant jitter on the position.
Using a sorted array removed this problem. Position is stable now.
7) A simple filter was implemented to avoid sending events which do not differ
from previous events in X, Y, and Pressure data. This will free CPU power.
8) The Pen Up detection was not reliable, because of using the current state
machine value, and not the interrupt flag register. Pen Up events are missed
in user space, leading to missing action execution. This bug was fixed by
using the correct interrupt flag for "Pen Up".
These modifications lead to some improvements in android gui experience:
- Enhanced position precision == better usability of the virtual keyboard.
- Less CPU power == faster reaction on touch inputs.
- Big improvement in gesture recognition == better srolling of lists.
Driver source files appended.