Debugging UART Touchscreens on Android

Currently, the commonly used touchscreens on Android devices include interfaces such as UART, USB, and I2C. This article mainly documents the use of UART touchscreens within the Android system:1. Kernel Configuration To use a UART touchscreen in the Android system, it involves the SERIO framework of the Linux kernel, and the following configuration options need to be enabled:

CONFIG_SERIO=y
CONFIG_SERIO_SERPORT=y

2. Linux Driver Once the above kernel configurations are enabled, the required Linux driver code will usemodule_serio_driver() to register the driver. Correspondingly, in the kernel source code under thedrivers/input/touchscreen directory, you can find drivers that include the SERIO_RS232 keyword. Based on the specifications of the touchscreen, determine its serial protocol, find a corresponding driver to modify, and compile it into the kernel or compile it as a KO module to load after the system starts, such ashampshire.c,touchit213.c,egalax_ts_serial.c,wacom_w8001.c, etc.3. Application Service Program With the relevant drivers for the UART touchscreen, an application service program is needed to associate the actual serial device with the touchscreen driver. This will involve using the inputattach program, which will callioctl(fd, SPIOCSTYPE, &devt) function to bind the actual UART Port with the Linux TouchScreen Driver for operation. The source code for this program can be downloaded from the following link:

http://sourceforge.net/p/linuxwacom/input-wacom/ci/master/tree/inputattach/

4. Boot Startup Service Once the above conditions are prepared, it is necessary to modify the Android system’s init*.rc file and add the following service configuration statement to start the corresponding service at boot, allowing the touchscreen to successfully report touch coordinates and events:

service irtouch /system/bin/inputattach --baud 9600 --boray /dev/ttyS1    class main    oneshot

As can be seen, the configuration includes the serial port baud rate, SERIO protocol name, and the actual serial device used.5. References https://lwn.net/Articles/122577/

Leave a Comment