synaptics: Send a cancel to sensor if it returns busy

fix #380
This commit is contained in:
Aris Lin 2021-05-14 16:55:24 +08:00 committed by Benjamin Berg
parent 82c406dace
commit 040d0d34fd

View file

@ -1096,14 +1096,18 @@ prob_msg_cb (FpiDeviceSynaptics *self,
{ {
GUsbDevice *usb_dev = NULL; GUsbDevice *usb_dev = NULL;
g_autofree gchar *serial = NULL; g_autofree gchar *serial = NULL;
GError *err = NULL;
usb_dev = fpi_device_get_usb_device (FP_DEVICE (self)); usb_dev = fpi_device_get_usb_device (FP_DEVICE (self));
if (error) 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); g_usb_device_close (usb_dev, NULL);
fpi_device_probe_complete (FP_DEVICE (self), NULL, NULL, fpi_device_probe_complete (FP_DEVICE (self), NULL, NULL, err);
fpi_device_error_new_msg (FP_DEVICE_ERROR_GENERAL, "unsupported firmware version")); g_clear_error (&error);
return; return;
} }
@ -1112,13 +1116,17 @@ prob_msg_cb (FpiDeviceSynaptics *self,
else else
serial = g_usb_device_get_string_descriptor (usb_dev, serial = g_usb_device_get_string_descriptor (usb_dev,
g_usb_device_get_serial_number_index (usb_dev), g_usb_device_get_serial_number_index (usb_dev),
&error); &err);
/* BMKT_OPERATION_DENIED is returned if the sensor is already initialized */ /* BMKT_OPERATION_DENIED is returned if the sensor is already initialized */
if (resp->result == BMKT_SUCCESS || resp->result == BMKT_OPERATION_DENIED) if (resp->result == BMKT_SUCCESS || resp->result == BMKT_OPERATION_DENIED)
{ {
g_usb_device_close (usb_dev, NULL); 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 else
{ {
@ -1241,6 +1249,9 @@ fps_init_msg_cb (FpiDeviceSynaptics *self,
{ {
if (error) 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); fpi_device_open_complete (FP_DEVICE (self), error);
return; return;
} }
@ -1250,6 +1261,10 @@ fps_init_msg_cb (FpiDeviceSynaptics *self,
{ {
fpi_device_open_complete (FP_DEVICE (self), NULL); 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 else
{ {
g_warning ("Initializing fingerprint sensor failed with %d!", resp->result); g_warning ("Initializing fingerprint sensor failed with %d!", resp->result);