device: Implement suspend/resume methods

The assumption here is that in most cases, we will just cancel any
ongoing operation. However, if the device choses to implement
suspend/resume handling and it returns success, then operations will not
be cancelled.

Note that suspend/resume requests cannot be cancelled.

Closes: #256
This commit is contained in:
Benjamin Berg
2021-04-23 15:55:05 +02:00
parent 968331c383
commit 43336a204f
5 changed files with 560 additions and 25 deletions

View File

@@ -53,6 +53,7 @@ typedef struct
gboolean is_removed;
gboolean is_open;
gboolean is_suspended;
gchar *device_id;
gchar *device_name;
@@ -83,6 +84,12 @@ typedef struct
guint critical_section;
GSource *critical_section_flush_source;
gboolean cancel_queued;
gboolean suspend_queued;
gboolean resume_queued;
/* Suspend/resume tasks */
GTask *suspend_resume_task;
GError *suspend_error;
/* Device temperature model information and state */
GSource *temp_timeout;
@@ -123,5 +130,7 @@ typedef struct
void match_data_free (FpMatchData *match_data);
void fpi_device_configure_wakeup (FpDevice *device,
gboolean enabled);
void fpi_device_update_temp (FpDevice *device,
gboolean is_active);