elan: Add support for 0x0c58 sensor response codes

The Elan 04f3:0c58 sensor returns 0xaf during capture which indicates
finger removed or sensor busy. Also 0x00 can occur meaning not ready.
These responses should trigger a retry instead of failing.

To avoid changing behavior for other Elan devices, limit the new retry
logic to the 0x0c58 device type and add a small 10ms delay between
retries.

Additionally, increase calibration attempts from 10 to 30 for 0x0c58
as this sensor needs more time to complete calibration.

Source: https://gitlab.freedesktop.org/libfprint/libfprint/-/work_items/763

Signed-off-by: lichenggang <lichenggang@uniontech.com>

Co-Authored-By: Marco Trevisan (Treviño) <mail@3v1n0.net>
This commit is contained in:
lichenggang 2026-04-16 15:53:45 +08:00 committed by Marco Trevisan (Treviño)
parent 5b01f0b7c1
commit 4610f2285e
2 changed files with 13 additions and 3 deletions

View file

@ -547,6 +547,13 @@ capture_run_state (FpiSsm *ssm, FpDevice *dev)
fpi_image_device_report_finger_status (idev, TRUE);
elan_run_cmd (ssm, dev, &get_image_cmd, ELAN_CMD_TIMEOUT);
}
else if (self->dev_type == ELAN_0C58 && self->last_read &&
(self->last_read[0] == 0x00 || self->last_read[0] == 0xaf))
{
/* 0x00 - not ready
* 0xaf - finger removed or sensor busy (seen on 0x0c58) */
fpi_ssm_jump_to_state_delayed (ssm, CAPTURE_WAIT_FINGER, 10);
}
else
{
/* XXX: The timeout is emulated incorrectly, resulting in a zero byte read. */
@ -795,7 +802,7 @@ elan_calibrate (FpiDeviceElan *self)
g_return_if_fail (!self->active);
self->active = TRUE;
self->calib_atts_left = ELAN_CALIBRATION_ATTEMPTS;
self->calib_atts_left = ELAN_CALIBRATION_ATTEMPTS (self->dev_type);
FpiSsm *ssm = fpi_ssm_new (FP_DEVICE (self), calibrate_run_state,
CALIBRATE_NUM_STATES);

View file

@ -31,6 +31,7 @@
#define ELAN_0907 (1 << 0)
#define ELAN_0C03 (1 << 1)
#define ELAN_0C42 (1 << 2)
#define ELAN_0C58 (1 << 3)
/* devices which don't require frame rotation before assembling */
#define ELAN_NOT_ROTATED ELAN_0C03
@ -44,7 +45,9 @@
/* times to retry reading calibration status during one session
* generally prevents calibration from looping indefinitely */
#define ELAN_CALIBRATION_ATTEMPTS 10
#define ELAN_DEFAULT_CALIBRATION_ATTEMPTS 10
#define ELAN_CALIBRATION_ATTEMPTS(dev_type) \
((dev_type) == ELAN_0C58 ? 30 : ELAN_DEFAULT_CALIBRATION_ATTEMPTS)
/* min and max frames in a capture */
#define ELAN_MIN_FRAMES 7
@ -220,7 +223,7 @@ static const FpIdEntry elan_id_table[] = {
{.vid = ELAN_VEND_ID, .pid = 0x0c4f, .driver_data = ELAN_ALL_DEV},
{.vid = ELAN_VEND_ID, .pid = 0x0c63, .driver_data = ELAN_ALL_DEV},
{.vid = ELAN_VEND_ID, .pid = 0x0c6e, .driver_data = ELAN_ALL_DEV},
{.vid = ELAN_VEND_ID, .pid = 0x0c58, .driver_data = ELAN_ALL_DEV},
{.vid = ELAN_VEND_ID, .pid = 0x0c58, .driver_data = ELAN_0C58},
{.vid = 0, .pid = 0, .driver_data = 0},
};