diff --git a/libfwupdplugin/fu-dfu-firmware-private.h b/libfwupdplugin/fu-dfu-firmware-private.h index 4a2b9aeef..1cad6bc48 100644 --- a/libfwupdplugin/fu-dfu-firmware-private.h +++ b/libfwupdplugin/fu-dfu-firmware-private.h @@ -8,26 +8,6 @@ #include "fu-dfu-firmware.h" -/** - * DfuVersion: - * @DFU_VERSION_UNKNOWN: Format unknown - * @DFU_VERSION_DFU_1_0: DFU 1.0 - * @DFU_VERSION_DFU_1_1: DFU 1.1 - * @DFU_VERSION_DFUSE: DfuSe - * @DFU_VERSION_ATMEL_AVR: Atmel AVR - * - * The known versions of the DFU standard in BCD format. - **/ -typedef enum { - DFU_VERSION_UNKNOWN = 0, - DFU_VERSION_DFU_1_0 = 0x0100, - DFU_VERSION_DFU_1_1 = 0x0110, - DFU_VERSION_DFUSE = 0x011a, /* defined by ST */ - DFU_VERSION_ATMEL_AVR = 0xff01, /* made up */ - /*< private >*/ - DFU_VERSION_LAST -} DfuVersion; - guint8 fu_dfu_firmware_get_footer_len (FuDfuFirmware *self); GBytes *fu_dfu_firmware_append_footer (FuDfuFirmware *self, GBytes *contents, diff --git a/libfwupdplugin/fu-dfu-firmware.c b/libfwupdplugin/fu-dfu-firmware.c index 92ac58e3c..ece27e98e 100644 --- a/libfwupdplugin/fu-dfu-firmware.c +++ b/libfwupdplugin/fu-dfu-firmware.c @@ -379,7 +379,7 @@ fu_dfu_firmware_init (FuDfuFirmware *self) priv->vid = 0xffff; priv->pid = 0xffff; priv->release = 0xffff; - priv->dfu_version = DFU_VERSION_DFU_1_0; + priv->dfu_version = FU_DFU_FIRMARE_VERSION_DFU_1_0; fu_firmware_add_flag (FU_FIRMWARE (self), FU_FIRMWARE_FLAG_HAS_CHECKSUM); fu_firmware_add_flag (FU_FIRMWARE (self), FU_FIRMWARE_FLAG_HAS_VID_PID); } diff --git a/libfwupdplugin/fu-dfu-firmware.h b/libfwupdplugin/fu-dfu-firmware.h index 872b23a30..c4eb38940 100644 --- a/libfwupdplugin/fu-dfu-firmware.h +++ b/libfwupdplugin/fu-dfu-firmware.h @@ -16,6 +16,51 @@ struct _FuDfuFirmwareClass FuFirmwareClass parent_class; }; +/** + * FU_DFU_FIRMARE_VERSION_UNKNOWN: + * + * Unknown version of the DFU standard in BCD format. + * + * Since: 1.6.1 + **/ +#define FU_DFU_FIRMARE_VERSION_UNKNOWN (0u) + +/** + * FU_DFU_FIRMARE_VERSION_DFU_1_0: + * + * The 1.0 version of the DFU standard in BCD format. + * + * Since: 1.6.1 + **/ +#define FU_DFU_FIRMARE_VERSION_DFU_1_0 (0x0100) + +/** + * FU_DFU_FIRMARE_VERSION_DFU_1_1: + * + * The 1.1 version of the DFU standard in BCD format. + * + * Since: 1.6.1 + **/ +#define FU_DFU_FIRMARE_VERSION_DFU_1_1 (0x0110) + +/** + * FU_DFU_FIRMARE_VERSION_DFUSE: + * + * The DfuSe version of the DFU standard in BCD format, defined by ST. + * + * Since: 1.6.1 + **/ +#define FU_DFU_FIRMARE_VERSION_DFUSE (0x011a) + +/** + * FU_DFU_FIRMARE_VERSION_ATMEL_AVR: + * + * The Atmel AVR version of the DFU standard in BCD format. + * + * Since: 1.6.1 + **/ +#define FU_DFU_FIRMARE_VERSION_ATMEL_AVR (0xff01) + FuFirmware *fu_dfu_firmware_new (void); guint16 fu_dfu_firmware_get_vid (FuDfuFirmware *self); guint16 fu_dfu_firmware_get_pid (FuDfuFirmware *self); diff --git a/libfwupdplugin/fu-dfuse-firmware.c b/libfwupdplugin/fu-dfuse-firmware.c index 7e7b773aa..aec592120 100644 --- a/libfwupdplugin/fu-dfuse-firmware.c +++ b/libfwupdplugin/fu-dfuse-firmware.c @@ -330,7 +330,7 @@ fu_dfuse_firmware_write (FuFirmware *firmware, GError **error) static void fu_dfuse_firmware_init (FuDfuseFirmware *self) { - fu_dfu_firmware_set_version (FU_DFU_FIRMWARE (self), DFU_VERSION_DFUSE); + fu_dfu_firmware_set_version (FU_DFU_FIRMWARE (self), FU_DFU_FIRMARE_VERSION_DFUSE); } static void diff --git a/plugins/dfu/fu-dfu-device.c b/plugins/dfu/fu-dfu-device.c index 599e172ef..a760089ea 100644 --- a/plugins/dfu/fu-dfu-device.c +++ b/plugins/dfu/fu-dfu-device.c @@ -78,8 +78,6 @@ #include "fu-dfu-target-private.h" #include "fu-dfu-target-stm.h" -#include "fu-dfu-firmware-private.h" - static void fu_dfu_device_finalize (GObject *object); typedef struct { @@ -159,7 +157,7 @@ fu_dfu_device_get_transfer_size (FuDfuDevice *self) * * Gets the DFU specification version supported by the device. * - * Returns: integer, or 0 for unknown, e.g. %DFU_VERSION_DFU_1_1 + * Returns: integer, or 0 for unknown, e.g. %FU_DFU_FIRMARE_VERSION_DFU_1_1 **/ guint16 fu_dfu_device_get_version (FuDfuDevice *self) @@ -228,7 +226,7 @@ fu_dfu_device_parse_iface_data (FuDfuDevice *self, GBytes *iface_data, GError ** } else if (sz == sizeof(DfuFuncDescriptor) - 2) { g_warning ("truncated DFU interface data, no bcdDFUVersion"); memcpy (&desc, buf, sz); - desc.bcdDFUVersion = DFU_VERSION_DFU_1_1; + desc.bcdDFUVersion = FU_DFU_FIRMARE_VERSION_DFU_1_1; } else { g_autoptr(GString) bufstr = g_string_new (NULL); for (gsize i = 0; i < sz; i++) @@ -249,7 +247,7 @@ fu_dfu_device_parse_iface_data (FuDfuDevice *self, GBytes *iface_data, GError ** priv->version = GUINT16_FROM_LE (desc.bcdDFUVersion); /* ST-specific */ - if (priv->version == DFU_VERSION_DFUSE && + if (priv->version == FU_DFU_FIRMARE_VERSION_DFUSE && desc.bmAttributes & FU_DFU_DEVICE_ATTR_CAN_ACCELERATE) priv->transfer_size = 0x1000; @@ -327,24 +325,24 @@ fu_dfu_device_add_targets (FuDfuDevice *self, GError **error) /* fix up the version */ if (priv->force_version > 0) priv->version = priv->force_version; - if (priv->version == DFU_VERSION_DFU_1_0 || - priv->version == DFU_VERSION_DFU_1_1) { + if (priv->version == FU_DFU_FIRMARE_VERSION_DFU_1_0 || + priv->version == FU_DFU_FIRMARE_VERSION_DFU_1_1) { g_debug ("DFU v1.1"); - } else if (priv->version == DFU_VERSION_ATMEL_AVR) { + } else if (priv->version == FU_DFU_FIRMARE_VERSION_ATMEL_AVR) { g_debug ("AVR-DFU support"); - priv->version = DFU_VERSION_ATMEL_AVR; - } else if (priv->version == DFU_VERSION_DFUSE) { + priv->version = FU_DFU_FIRMARE_VERSION_ATMEL_AVR; + } else if (priv->version == FU_DFU_FIRMARE_VERSION_DFUSE) { g_debug ("STM-DFU support"); } else if (priv->version == 0x0101) { g_debug ("DFU v1.1 assumed"); - priv->version = DFU_VERSION_DFU_1_1; + priv->version = FU_DFU_FIRMARE_VERSION_DFU_1_1; } else { g_warning ("DFU version 0x%04x invalid, v1.1 assumed", priv->version); - priv->version = DFU_VERSION_DFU_1_1; + priv->version = FU_DFU_FIRMARE_VERSION_DFU_1_1; } /* set expected protocol */ - if (priv->version == DFU_VERSION_DFUSE) { + if (priv->version == FU_DFU_FIRMARE_VERSION_DFUSE) { fu_device_add_protocol (FU_DEVICE (self), "com.st.dfuse"); } else { fu_device_add_protocol (FU_DEVICE (self), "org.usb.dfu"); @@ -367,10 +365,10 @@ fu_dfu_device_add_targets (FuDfuDevice *self, GError **error) /* create a target of the required type */ switch (priv->version) { - case DFU_VERSION_DFUSE: + case FU_DFU_FIRMARE_VERSION_DFUSE: target = fu_dfu_target_stm_new (); break; - case DFU_VERSION_ATMEL_AVR: + case FU_DFU_FIRMARE_VERSION_ATMEL_AVR: target = fu_dfu_target_avr_new (); break; default: diff --git a/plugins/dfu/fu-dfu-target.c b/plugins/dfu/fu-dfu-target.c index 53fc4e6cd..972df5625 100644 --- a/plugins/dfu/fu-dfu-target.c +++ b/plugins/dfu/fu-dfu-target.c @@ -28,8 +28,6 @@ #include "fu-dfu-sector.h" #include "fu-dfu-target-private.h" -#include "fu-dfu-firmware-private.h" - #define DFU_TARGET_MANIFEST_MAX_POLLING_TRIES 200 static void fu_dfu_target_finalize (GObject *object); @@ -550,7 +548,7 @@ fu_dfu_target_check_status (FuDfuTarget *self, GError **error) /* STM32-specific long errors */ status = fu_dfu_device_get_status (priv->device); - if (fu_dfu_device_get_version (priv->device) == DFU_VERSION_DFUSE) { + if (fu_dfu_device_get_version (priv->device) == FU_DFU_FIRMARE_VERSION_DFUSE) { if (status == FU_DFU_STATUS_ERR_VENDOR) { g_set_error (error, FWUPD_ERROR, @@ -806,7 +804,7 @@ fu_dfu_target_download_chunk (FuDfuTarget *self, guint16 index, GBytes *bytes, G } /* for STM32 devices, the action only occurs when we do GetStatus */ - if (fu_dfu_device_get_version (priv->device) == DFU_VERSION_DFUSE) { + if (fu_dfu_device_get_version (priv->device) == FU_DFU_FIRMARE_VERSION_DFUSE) { if (!fu_dfu_device_refresh (priv->device, error)) return FALSE; }