summaryrefslogtreecommitdiff
path: root/gusb/gusb-device.h
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2011-09-06 12:40:47 +0200
committerHans de Goede <hdegoede@redhat.com>2011-09-06 14:08:28 +0200
commit4819d1362b550d88afcbdb1bd35704c34bf619ef (patch)
tree04622c55ddcbb1d103d44c44a3a8ed4db33166e5 /gusb/gusb-device.h
parent230127c0c15b6e2407cc25e82b91abc8c5a915f8 (diff)
downloadgusb-4819d1362b550d88afcbdb1bd35704c34bf619ef.tar.gz
gusb-device: Move setting config / claiming of interface to their own methods
Always doing a set-config on device open is not a good idea, see: http://libusb.sourceforge.net/api-1.0/caveats.html So remove the configuration parameter from g_usb_device_open and add a g_usb_device_set_configuration instead which apps can use if they really want to do a set_configuration (which most apps should not do). Also add a g_usb_device_get_configuration method for completeness. Likewise remove the interface parameter, an app may want to claim more then one interface. And may even want to do some things which require the device to be open without claiming any interfaces, like getting the active configuration. And add a g_usb_device_claim_interface method to replace the interface parameter to g_usb_device_open. The new g_usb_device_claim_interface can also automatically unbind any kernel drivers which are bound to the interface before claiming it, this is controlled through the flags parameter, by specifying the G_USB_DEVICE_CLAIM_INTERFACE_BIND_KERNEL_DRIVER flag. Also add a g_usb_device_release_interface method for completeness. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'gusb/gusb-device.h')
-rw-r--r--gusb/gusb-device.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/gusb/gusb-device.h b/gusb/gusb-device.h
index acb6572..f10a9c0 100644
--- a/gusb/gusb-device.h
+++ b/gusb/gusb-device.h
@@ -87,6 +87,16 @@ typedef enum {
G_USB_DEVICE_ERROR_LAST
} GUsbDeviceError;
+/**
+ * GUsbDeviceClaimInterfaceFlags:
+ *
+ * Flags for the g_usb_device_claim_interface and
+ * g_usb_device_release_interface methods flags parameters.
+ **/
+typedef enum {
+ G_USB_DEVICE_CLAIM_INTERFACE_BIND_KERNEL_DRIVER = 1 << 0,
+} GUsbDeviceClaimInterfaceFlags;
+
struct _GUsbDevice
{
GObject parent;
@@ -109,13 +119,25 @@ guint16 g_usb_device_get_vid (GUsbDevice *device);
guint16 g_usb_device_get_pid (GUsbDevice *device);
gboolean g_usb_device_open (GUsbDevice *device,
- guint configuration,
- guint interface,
- GCancellable *cancellable,
GError **error);
gboolean g_usb_device_close (GUsbDevice *device,
GError **error);
+gint g_usb_device_get_configuration (GUsbDevice *device,
+ GError **error);
+gboolean g_usb_device_set_configuration (GUsbDevice *device,
+ gint configuration,
+ GError **error);
+
+gboolean g_usb_device_claim_interface (GUsbDevice *device,
+ gint interface,
+ GUsbDeviceClaimInterfaceFlags flags,
+ GError **error);
+gboolean g_usb_device_release_interface (GUsbDevice *device,
+ gint interface,
+ GUsbDeviceClaimInterfaceFlags flags,
+ GError **error);
+
/* sync -- TODO: use GCancellable and GUsbSource */
gboolean g_usb_device_control_transfer (GUsbDevice *device,
GUsbDeviceDirection direction,