From 040d0d34fdbc3b1d244be9949298ede2ded1817c Mon Sep 17 00:00:00 2001 From: Aris Lin Date: Fri, 14 May 2021 16:55:24 +0800 Subject: [PATCH] synaptics: Send a cancel to sensor if it returns busy fix #380 --- libfprint/drivers/synaptics/synaptics.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/libfprint/drivers/synaptics/synaptics.c b/libfprint/drivers/synaptics/synaptics.c index 7a20d06..afde4b1 100644 --- a/libfprint/drivers/synaptics/synaptics.c +++ b/libfprint/drivers/synaptics/synaptics.c @@ -1096,14 +1096,18 @@ prob_msg_cb (FpiDeviceSynaptics *self, { GUsbDevice *usb_dev = NULL; g_autofree gchar *serial = NULL; + GError *err = NULL; usb_dev = fpi_device_get_usb_device (FP_DEVICE (self)); if (error) { + if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + err = fpi_device_error_new_msg (FP_DEVICE_ERROR_GENERAL, "unsupported firmware version"); + g_usb_device_close (usb_dev, NULL); - fpi_device_probe_complete (FP_DEVICE (self), NULL, NULL, - fpi_device_error_new_msg (FP_DEVICE_ERROR_GENERAL, "unsupported firmware version")); + fpi_device_probe_complete (FP_DEVICE (self), NULL, NULL, err); + g_clear_error (&error); return; } @@ -1112,13 +1116,17 @@ prob_msg_cb (FpiDeviceSynaptics *self, else serial = g_usb_device_get_string_descriptor (usb_dev, g_usb_device_get_serial_number_index (usb_dev), - &error); + &err); /* BMKT_OPERATION_DENIED is returned if the sensor is already initialized */ if (resp->result == BMKT_SUCCESS || resp->result == BMKT_OPERATION_DENIED) { g_usb_device_close (usb_dev, NULL); - fpi_device_probe_complete (FP_DEVICE (self), serial, NULL, error); + fpi_device_probe_complete (FP_DEVICE (self), serial, NULL, err); + } + else if (resp->result == BMKT_FP_SYSTEM_BUSY) + { + synaptics_sensor_cmd (self, self->cmd_seq_num, BMKT_CMD_CANCEL_OP, NULL, 0, NULL); } else { @@ -1241,6 +1249,9 @@ fps_init_msg_cb (FpiDeviceSynaptics *self, { if (error) { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_clear_error (&error); + fpi_device_open_complete (FP_DEVICE (self), error); return; } @@ -1250,6 +1261,10 @@ fps_init_msg_cb (FpiDeviceSynaptics *self, { fpi_device_open_complete (FP_DEVICE (self), NULL); } + else if (resp->result == BMKT_FP_SYSTEM_BUSY) + { + synaptics_sensor_cmd (self, self->cmd_seq_num, BMKT_CMD_CANCEL_OP, NULL, 0, NULL); + } else { g_warning ("Initializing fingerprint sensor failed with %d!", resp->result);