Top |
void | (*FpiSpiTransferCallback) () |
FpiSpiTransfer * | fpi_spi_transfer_new () |
FpiSpiTransfer * | fpi_spi_transfer_ref () |
void | fpi_spi_transfer_unref () |
void | fpi_spi_transfer_write () |
void | fpi_spi_transfer_write_full () |
void | fpi_spi_transfer_read () |
void | fpi_spi_transfer_read_full () |
void | fpi_spi_transfer_submit () |
gboolean | fpi_spi_transfer_submit_sync () |
FpiSpiTransfer is a structure to simplify the SPI transfer handling for the linux spidev device. The main goal are to ease memory management and provide a usable asynchronous API to libfprint drivers.
Currently only transfers with a write and subsequent read are supported.
Drivers should always use this API rather than calling read/write/ioctl on the spidev device.
Setting G_MESSAGES_DEBUG and FP_DEBUG_TRANSFER will result in the message content to be dumped.
void (*FpiSpiTransferCallback) (FpiSpiTransfer *transfer
,FpDevice *dev
,gpointer user_data
,GError *error
);
FpiSpiTransfer * fpi_spi_transfer_new (FpDevice *device
,int spidev_fd
);
Creates a new FpiSpiTransfer.
device |
The FpDevice the transfer is for |
|
spidev_fd |
The file descriptor for the spidev device |
FpiSpiTransfer *
fpi_spi_transfer_ref (FpiSpiTransfer *self
);
Increments the reference count of self
by one.
void
fpi_spi_transfer_unref (FpiSpiTransfer *self
);
Decrements the reference count of self
by one, freeing the structure when
the reference count reaches zero.
void fpi_spi_transfer_write (FpiSpiTransfer *transfer
,gsize length
);
Prepare the write part of an SPI transfer allocating a new buffer internally that will be free'ed automatically.
void fpi_spi_transfer_write_full (FpiSpiTransfer *transfer
,guint8 *buffer
,gsize length
,GDestroyNotify free_func
);
Prepare the write part of an SPI transfer.
transfer |
The FpiSpiTransfer |
|
buffer |
The data to write. |
|
length |
The size of |
|
free_func |
Destroy notify for |
[destroy buffer] |
void fpi_spi_transfer_read (FpiSpiTransfer *transfer
,gsize length
);
Prepare the read part of an SPI transfer allocating a new buffer internally that will be free'ed automatically.
void fpi_spi_transfer_read_full (FpiSpiTransfer *transfer
,guint8 *buffer
,gsize length
,GDestroyNotify free_func
);
Prepare the read part of an SPI transfer.
transfer |
The FpiSpiTransfer |
|
buffer |
Buffer to read data into. |
|
length |
The size of |
|
free_func |
Destroy notify for |
[destroy buffer] |
void fpi_spi_transfer_submit (FpiSpiTransfer *transfer
,GCancellable *cancellable
,FpiSpiTransferCallback callback
,gpointer user_data
);
Submit an SPI transfer with a specific timeout and callback functions.
The underlying transfer cannot be cancelled. The current implementation
will only call callback
after the transfer has been completed.
Note that FpiSpiTransfer will be stolen when this function is called.
So that all associated data will be free'ed automatically, after the
callback ran unless fpi_usb_transfer_ref()
is explicitly called.
transfer |
The transfer to submit, must have been filled. |
[transfer full] |
cancellable |
Cancellable to use, e.g. |
|
callback |
Callback on completion or error |
|
user_data |
Data to pass to callback |
gboolean fpi_spi_transfer_submit_sync (FpiSpiTransfer *transfer
,GError **error
);
Synchronously submit an SPI transfer. Use of this function is discouraged as it will block all other operations in the application.
Note that you still need to fpi_spi_transfer_unref()
the
FpiSpiTransfer afterwards.
typedef struct { FpDevice *device; FpiSsm *ssm; gssize length_wr; gssize length_rd; guchar *buffer_wr; guchar *buffer_rd; } FpiSpiTransfer;
Helper for handling SPI transfers. Currently transfers can either be pure write/read transfers or a write followed by a read (full duplex support can easily be added if desired).
FpDevice * |
The FpDevice that the transfer belongs to. |
|
FpiSsm * |
Storage slot to associate the transfer with a state machine.
Used by |
|
The length of the write buffer |
||
The length of the read buffer |
||
The write buffer. |
||
The read buffer. |