Re-record the umockdev USB capture to include the new
GOODIX_VERIFY_WAIT_FINGER_UP state's USB exchanges during
verify and identify operations.
Captured on a Goodix MOC sensor (27c6:609c, Framework Laptop 13)
with FP_DEVICE_EMULATION=1 as required by the test framework.
The goodixmoc driver's verify state machine was missing a
WAIT_FINGER_UP state between IDENTIFY and PWR_BTN_SHIELD_OFF.
After the sensor reported a match/no-match result, the driver
immediately completed the verify operation without waiting for
the finger to be lifted from the sensor.
This caused problems when fprintd retried verification after a
no-match: the finger was still on the sensor, so the same
(wrong) finger was scanned again instantly. On fast match-on-chip
readers, all retry attempts could be exhausted in under a second,
giving the user no time to reposition their finger.
Add GOODIX_VERIFY_WAIT_FINGER_UP to the verify state machine,
mirroring the existing GOODIX_ENROLL_WAIT_FINGER_UP in the
enroll flow. The new state sends MOC_CMD0_FINGER_MODE /
MOC_CMD1_SET_FINGER_UP to the sensor and waits for the finger
to be removed before advancing to PWR_BTN_SHIELD_OFF.
The callback handles the same cases as the enroll equivalent:
- Timeout (5s): retry the finger-up wait
- Protocol error: fail the SSM
- Success: clear FINGER_STATUS_PRESENT and advance
Link: https://gitlab.freedesktop.org/libfprint/fprintd/-/issues/209
NBIS/bozorth3 cannot reliably detect minutiae at the sensor's
native resolution (64x80 pixels, ~250 DPI vs 500 DPI required).
The Windows driver solves this with a proprietary "mayflower"
matching engine.
Replace FpImageDevice (NBIS-based) with FpDevice implementing
custom pixel-correlation matching:
- Preprocessing: bitwise NOT + local mean subtraction (7x7
high-pass filter) to enhance ridge/valley contrast
- Enrollment: store 5 preprocessed images as GVariant templates
- Verification: Normalized Cross-Correlation (NCC) with
translation search (±3 pixels, 49 positions per template)
- NCC threshold: 0.30 (same finger: 0.31-0.47, different: 0.05-0.29)
Tested with fprintd-enroll, fprintd-verify, and GNOME lock screen.
Use change_state callback (nb1010 pattern) to start capture SSM
when framework transitions to AWAIT_FINGER_ON state. This enables
proper multi-stage enrollment (5 stages).
Add FPI_IMAGE_COLORS_INVERTED flag: the sensor outputs inverted
pixel values, matching the Windows driver behavior (~pixel
bitwise NOT inversion found in decompiled ftWbioUmdfDriverV2.dll).
Add 2x nearest-neighbor upscaling (64x80 -> 128x160) for NBIS
minutiae detection compatibility.
Poll vendor request 0x43 (INT_STATUS) to detect finger presence
before capturing. Byte 0: 0x00 = no finger, 0x01 = finger present.
Retry every 30ms until finger is detected.
Also add warmup skip on subsequent capture cycles to avoid
consuming stale data from the USB pipe.
Reverse-engineered USB protocol for FocalTech FT9201 (FT9338 chip,
VID:PID 2808:9338). Area fingerprint sensor, 64x80 pixels, 8-bit
grayscale, connected via USB SIU (Serial Interface Unit) bridge.
Protocol uses "New SIU" compound register addresses:
- 0x9180: chip status / OTP info
- 0x9080: image capture (5120 bytes)
- 0xFF00: sync / reset
Read sequence: 3 vendor control OUTs + 1 bulk IN.
First bulk read after USB reset returns garbage and must be discarded.
Implements 16-state capture SSM with warmup, finger polling,
sync, status check, and image read phases.
This FPreader was found on Minisforum X1 Pro MiniPC, and it is
listed by lsusb as "Generic Realtek USB2.0 Finger Print Bridge".
Though the VID is not the same as the well-known "0bda", we can
confirm it's from Realtek by analyzing Windows version driver.
Signed-off-by: Ryan Wong <colorfulshark@gmail.com>
If the button shield command cannot be executed due to an underlying
error then resp is NULL. Avoid the crash by adding the appropriate
check.
Closes: #694