summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2015-03-03 15:14:54 +0000
committerRichard Hughes <richard@hughsie.com>2015-03-03 15:14:54 +0000
commit7fba4c4968beb228f9f5bbb9fbf13e0d0b7d4b82 (patch)
tree998f403acf4337f9df8499b2ae1102d1e1329983
parentac67f811f0b55b8adf4e35b822be91b8f72a64a4 (diff)
downloadcolord-7fba4c4968beb228f9f5bbb9fbf13e0d0b7d4b82.tar.gz
colorhug: Add GUIDs for each device
This is required to write fwupd-compatible update descriptions.
-rw-r--r--lib/colorhug/ch-common.h5
-rw-r--r--lib/colorhug/ch-device.c30
-rw-r--r--lib/colorhug/ch-device.h1
3 files changed, 36 insertions, 0 deletions
diff --git a/lib/colorhug/ch-common.h b/lib/colorhug/ch-common.h
index 30265bf..f58abce 100644
--- a/lib/colorhug/ch-common.h
+++ b/lib/colorhug/ch-common.h
@@ -1293,6 +1293,11 @@ G_BEGIN_DECLS
#define CH_FIRMWARE_ID_TOKEN_ALS "84f40464" /* since 1.2.9 */
#define CH_FIRMWARE_ID_TOKEN_PLUS "6d6f05a9"
+#define CH_DEVICE_GUID_COLORHUG "40338ceb-b966-4eae-adae-9c32edfcc484" /* since 1.2.9 */
+#define CH_DEVICE_GUID_COLORHUG2 "2082b5e0-7a64-478a-b1b2-e3404fab6dad" /* since 1.2.9 */
+#define CH_DEVICE_GUID_COLORHUG_ALS "84f40464-9272-4ef7-9399-cd95f12da696" /* since 1.2.9 */
+#define CH_DEVICE_GUID_COLORHUG_PLUS "6d6f05a9-3ecb-43a2-bcbb-3844f1825366" /* since 1.2.9 */
+
/* input and output buffer offsets */
#define CH_BUFFER_INPUT_CMD 0x00
#define CH_BUFFER_INPUT_DATA 0x01
diff --git a/lib/colorhug/ch-device.c b/lib/colorhug/ch-device.c
index 83d7359..0ef05b8 100644
--- a/lib/colorhug/ch-device.c
+++ b/lib/colorhug/ch-device.c
@@ -661,3 +661,33 @@ ch_device_get_runcode_address (GUsbDevice *device)
}
return 0;
}
+
+/**
+ * ch_device_get_guid:
+ * @device: A #GUsbDevice
+ *
+ * Returns the GUID for the connected ColorHug device.
+ *
+ * Return value: the GUID address, or %NULL for error
+ *
+ * Since: 1.2.9
+ **/
+const gchar *
+ch_device_get_guid (GUsbDevice *device)
+{
+ ChDeviceMode mode = ch_device_get_mode (device);
+ if (mode == CH_DEVICE_MODE_LEGACY ||
+ mode == CH_DEVICE_MODE_FIRMWARE ||
+ mode == CH_DEVICE_MODE_BOOTLOADER)
+ return CH_DEVICE_GUID_COLORHUG;
+ if (mode == CH_DEVICE_MODE_FIRMWARE2 ||
+ mode == CH_DEVICE_MODE_BOOTLOADER2)
+ return CH_DEVICE_GUID_COLORHUG2;
+ if (mode == CH_DEVICE_MODE_FIRMWARE_PLUS ||
+ mode == CH_DEVICE_MODE_BOOTLOADER_PLUS)
+ return CH_DEVICE_GUID_COLORHUG_PLUS;
+ if (mode == CH_DEVICE_MODE_FIRMWARE_ALS ||
+ mode == CH_DEVICE_MODE_BOOTLOADER_ALS)
+ return CH_DEVICE_GUID_COLORHUG_ALS;
+ return NULL;
+}
diff --git a/lib/colorhug/ch-device.h b/lib/colorhug/ch-device.h
index 9faf1ce..9d27790 100644
--- a/lib/colorhug/ch-device.h
+++ b/lib/colorhug/ch-device.h
@@ -69,6 +69,7 @@ gboolean ch_device_check_firmware (GUsbDevice *device,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
guint16 ch_device_get_runcode_address (GUsbDevice *device);
+const gchar *ch_device_get_guid (GUsbDevice *device);
G_END_DECLS