I love my ThinkPad X240. It’s light, tough, and runs Arch like a champ. But there’s one thing that’s always annoyed me: the fingerprint sensor.
Out of the box, it was technically supported by libfprint, but in practice
it was slow, inconsistent, and sometimes just refused to scan. I decided to stop complaining and fix it.
The Problem
The X240 uses a Validity Sensors VFS5011 reader.
libfprint had basic support, but:
- Scans took 3-4 seconds
- False negatives were common
- Sometimes the device wouldn’t wake up after suspend
I dug into the libfprint source and found that the driver for this sensor had
very conservative timing values and no proper power management handling. Convenient.
Step 1 - Reproducing the Bug
Before touching code, I wanted to reliably trigger the issue.
I wrote a quick loop to test scan times. This confirmed the average scan time was ~3.2s, with occasional failures. I would provide the code but it was just a test file i quickly deleted and I don't care enough to rewrite it.
Step 2 - Reading the Driver Code
The driver lived in:
libfprint/drivers/vfs5011.c
I noticed:
- A
usleepcall after every scan - No explicit USB resume call after suspend
- A fixed retry count of 5, even for clean scans (??????)
Step 3 - The Patch
I made three changes:
- Reduced the post-scan delay
- Added a USB resume call in the
open()function - Lowered retry count from 5 to 2 for successful scans
/* Old delay */ usleep(500000); /* New delay */ usleep(100000); /* Added after device open */ libusb_control_transfer(dev->usb_dev, 0x21, 0x22, 0, 0, NULL, 0, 0);
Step 4 - Testing
I rebuilt libfprint locally:
meson builddir ninja -C builddir sudo ninja -C builddir install
Then re-ran my scan loop.
Average scan time dropped to 0.9s, and the sensor woke up fine after
suspend.
Step 5 - Upstreaming
I submitted the patch to the libfprint repo with an explanation of the issue, steps to reproduce it and the test results.
The maintainer asked me to make the delay configurable via a driver option,
which I did.
A week later, it was merged.
w, wish i was that smart
i gooned to this
Just so yk your lowk seem cool as hell :)
Just so yk your lowk seem cool as hell :)
roxy is mid