Top |
void | (*FpiUsbTransferCallback) () |
FpiUsbTransfer * | fpi_usb_transfer_new () |
FpiUsbTransfer * | fpi_usb_transfer_ref () |
void | fpi_usb_transfer_unref () |
void | fpi_usb_transfer_set_short_error () |
void | fpi_usb_transfer_fill_bulk () |
void | fpi_usb_transfer_fill_bulk_full () |
void | fpi_usb_transfer_fill_control () |
void | fpi_usb_transfer_fill_interrupt () |
void | fpi_usb_transfer_fill_interrupt_full () |
void | fpi_usb_transfer_submit () |
gboolean | fpi_usb_transfer_submit_sync () |
#define | FPI_USB_ENDPOINT_IN |
#define | FPI_USB_ENDPOINT_OUT |
enum | FpiTransferType |
FpiUsbTransfer |
FpiUsbTransfer is a structure to simplify the USB transfer handling. The main goal is to ease memory management and provide more parameters to callbacks that are useful for libfprint drivers.
Drivers should use this API only rather than accessing the GUsbDevice directly in most cases.
void (*FpiUsbTransferCallback) (FpiUsbTransfer *transfer
,FpDevice *dev
,gpointer user_data
,GError *error
);
FpiUsbTransfer *
fpi_usb_transfer_new (FpDevice *device
);
Creates a new FpiUsbTransfer.
FpiUsbTransfer *
fpi_usb_transfer_ref (FpiUsbTransfer *self
);
Increments the reference count of self
by one.
void
fpi_usb_transfer_unref (FpiUsbTransfer *self
);
Decrements the reference count of self
by one, freeing the structure when
the reference count reaches zero.
void fpi_usb_transfer_set_short_error (FpiUsbTransfer *transfer
,gboolean short_is_error
);
void fpi_usb_transfer_fill_bulk (FpiUsbTransfer *transfer
,guint8 endpoint
,gsize length
);
Prepare a bulk transfer. A buffer will be created for you, use
fpi_usb_transfer_fill_bulk_full()
if you want to send a static buffer
or receive a pre-defined buffer.
transfer |
The FpiUsbTransfer |
|
endpoint |
The endpoint to send the transfer to |
|
length |
The buffer size to allocate |
void fpi_usb_transfer_fill_bulk_full (FpiUsbTransfer *transfer
,guint8 endpoint
,guint8 *buffer
,gsize length
,GDestroyNotify free_func
);
Prepare a bulk transfer.
transfer |
The FpiUsbTransfer |
|
endpoint |
The endpoint to send the transfer to |
|
buffer |
The data to send. |
|
length |
The size of |
|
free_func |
Destroy notify for |
[destroy buffer] |
void fpi_usb_transfer_fill_control (FpiUsbTransfer *transfer
,GUsbDeviceDirection direction
,GUsbDeviceRequestType request_type
,GUsbDeviceRecipient recipient
,guint8 request
,guint16 value
,guint16 idx
,gsize length
);
Prepare a control transfer. The function will create a new buffer, you can initialize the buffer after calling this function.
transfer |
The FpiUsbTransfer |
|
direction |
The direction of the control transfer |
|
request_type |
The request type |
|
recipient |
The recipient |
|
request |
The control transfer request |
|
value |
The control transfer value |
|
idx |
The control transfer index |
|
length |
The size of the transfer |
void fpi_usb_transfer_fill_interrupt (FpiUsbTransfer *transfer
,guint8 endpoint
,gsize length
);
Prepare an interrupt transfer. The function will create a new buffer, you can initialize the buffer after calling this function.
transfer |
The FpiUsbTransfer |
|
endpoint |
The endpoint to send the transfer to |
|
length |
The size of the transfer |
void fpi_usb_transfer_fill_interrupt_full (FpiUsbTransfer *transfer
,guint8 endpoint
,guint8 *buffer
,gsize length
,GDestroyNotify free_func
);
Prepare an interrupt transfer.
transfer |
The FpiUsbTransfer |
|
endpoint |
The endpoint to send the transfer to |
|
buffer |
The data to send. |
|
length |
The size of |
|
free_func |
Destroy notify for |
[destroy buffer] |
void fpi_usb_transfer_submit (FpiUsbTransfer *transfer
,guint timeout_ms
,GCancellable *cancellable
,FpiUsbTransferCallback callback
,gpointer user_data
);
Submit a USB transfer with a specific timeout and callback functions.
Note that FpiUsbTransfer 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] |
timeout_ms |
Timeout for the transfer in ms |
|
cancellable |
Cancellable to use, e.g. |
|
callback |
Callback on completion or error |
|
user_data |
Data to pass to callback |
gboolean fpi_usb_transfer_submit_sync (FpiUsbTransfer *transfer
,guint timeout_ms
,GError **error
);
Synchronously submit a USB transfer with a specific timeout. Only use this function with short timeouts as the application will be blocked otherwise.
Note that you still need to fpi_usb_transfer_unref()
the
FpiUsbTransfer afterwards.
typedef struct { FpDevice *device; FpiSsm *ssm; gssize length; gssize actual_length; guchar *buffer; } FpiUsbTransfer;
Helper for handling USB transfers.
FpDevice * |
The FpDevice that the transfer belongs to. |
|
FpiSsm * |
Storage slot to associate the transfer with a state machine.
Used by |
|
The requested length of the transfer in bytes. |
||
The actual length of the transfer
(see also |
||
The transferred data. |