Description
If you open /dev/input/event0
directly, repeatedly read from it, and measure the interval between individual reads, you'll find that this interval is around 40ms, so 25 touch events per second / 25Hz.
However, the specs of the FT5406 say it can do up to 100Hz (in practice probably around 60Hz), and the source code of the official raspberry pi touchscreen driver says it polls the touchscreen with an interval of about 17ms, or 60Hz.
This doesn't seem to be the case. 60Hz and 25Hz touchscreen report rate is a huge difference for responsive touch applications. If you drag some object in a touch application, but your finger position only updates 25 times per second, then that object only redraws at 25fps too. The whole application will feel laggy.
To reproduce
Run this:
#include <linux/input.h>
#include <fcntl.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
int main(int argc, char** argv) {
int fd;
struct input_event touch_event[8];
struct timespec last_poll, this_poll;
fd = open("/dev/input/event0", O_RDONLY);
while (1) {
ssize_t ok = read(fd, &touch_event, sizeof(touch_event));
clock_gettime(CLOCK_MONOTONIC, &this_poll);
printf(
"Polling Frequency: %02.2fHz\n",
1.0 / ((this_poll.tv_sec - last_poll.tv_sec) + (this_poll.tv_nsec - last_poll.tv_nsec) / 1000000000.0)
);
last_poll = this_poll;
}
}
Expected behaviour
Expected is a 60Hz polling rate, as specified in the driver and in the FT5406 specs.
Actual behaviour
In reality the polling rate is 25Hz.
System
System Information
------------------
Raspberry Pi 3 Model A Plus Rev 1.0
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
Raspberry Pi reference 2019-06-20
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 150e25c4f8123a4c9c63e8dca1b4737fa6c1135c, stage5
Linux hpi 4.19.50-v7+ #896 SMP Thu Jun 20 16:11:44 BST 2019 armv7l GNU/Linux
Hardware : BCM2835
Revision : 9020e0
Serial : 00000000e9058473
Throttled flag : throttled=0x0
Camera : supported=0 detected=0
Videocore information
---------------------
Jun 20 2019 16:13:08
Copyright (c) 2012 Broadcom
version a59fb7a74180be0111dbc5c18a37ec6df86f14a3 (clean) (release) (start_cd)
alloc failures: 0
compactions: 0
legacy block fails: 0
When the FT5406 is in Monitor mode, it polls at 25Hz. However, if it then detects an input, it immediately switches to Active mode for a configurable time and polls at 60Hz. Maybe the time in active mode is somehow set too low, so that it in practice never really gets out of Monitor mode?