summaryrefslogtreecommitdiff
path: root/gusb
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2019-11-15 16:10:23 +0000
committerRichard Hughes <richard@hughsie.com>2019-11-15 16:44:35 +0000
commit13233c38eed954baf0ca3a95a23bd28ae02c8ba7 (patch)
tree51504e90ddc18d0282a01603f2e1458edc974027 /gusb
parent22d3321aeadfa77054653a1a092a5ffb053692e6 (diff)
downloadgusb-13233c38eed954baf0ca3a95a23bd28ae02c8ba7.tar.gz
Add g_usb_device_get_spec()
Sometimes we do care about the USB version number of the device.
Diffstat (limited to 'gusb')
-rw-r--r--gusb/gusb-device.c19
-rw-r--r--gusb/gusb-device.h1
-rw-r--r--gusb/libgusb.ver5
3 files changed, 25 insertions, 0 deletions
diff --git a/gusb/gusb-device.c b/gusb/gusb-device.c
index 9b06ed4..0490164 100644
--- a/gusb/gusb-device.c
+++ b/gusb/gusb-device.c
@@ -1733,6 +1733,25 @@ g_usb_device_get_release (GUsbDevice *device)
}
/**
+ * g_usb_device_get_spec:
+ * @device: a #GUsbDevice
+ *
+ * Gets the BCD specification revision for the device. For example,
+ * `0x0110` indicates USB 1.1 and 0x0320 indicates USB 3.2
+ *
+ * Return value: a specification revision in BCD format.
+ *
+ * Since: 0.3.1
+ **/
+guint16
+g_usb_device_get_spec (GUsbDevice *device)
+{
+ g_return_val_if_fail (G_USB_IS_DEVICE (device), 0);
+
+ return device->priv->desc.bcdUSB;
+}
+
+/**
* g_usb_device_get_vid_as_str:
* @device: a #GUsbDevice
*
diff --git a/gusb/gusb-device.h b/gusb/gusb-device.h
index 660b0e3..7635829 100644
--- a/gusb/gusb-device.h
+++ b/gusb/gusb-device.h
@@ -162,6 +162,7 @@ guint8 g_usb_device_get_port_number (GUsbDevice *device);
guint16 g_usb_device_get_vid (GUsbDevice *device);
guint16 g_usb_device_get_pid (GUsbDevice *device);
guint16 g_usb_device_get_release (GUsbDevice *device);
+guint16 g_usb_device_get_spec (GUsbDevice *device);
const gchar *g_usb_device_get_vid_as_str (GUsbDevice *device);
const gchar *g_usb_device_get_pid_as_str (GUsbDevice *device);
guint8 g_usb_device_get_device_class (GUsbDevice *device);
diff --git a/gusb/libgusb.ver b/gusb/libgusb.ver
index c4f9181..a2e07eb 100644
--- a/gusb/libgusb.ver
+++ b/gusb/libgusb.ver
@@ -68,3 +68,8 @@ LIBGUSB_0.2.11 {
g_usb_context_set_flags;
g_usb_context_get_flags;
} LIBGUSB_0.2.9;
+
+LIBGUSB_0.3.1 {
+ global:
+ g_usb_device_get_spec;
+} LIBGUSB_0.2.11;