Commit 8aebd444 authored by Richard Hughes's avatar Richard Hughes
Browse files

dfu: Modernize the coding style to match the other plugings

Use a Fu prefix for source objects and files and use @self.

No logic changes.
parent f8387d8b
......@@ -11,8 +11,7 @@
#include "fu-chunk.h"
#include "fu-dfu-csr-device.h"
#include "fu-dfu-firmware.h"
#include "dfu-common.h"
#include "fu-dfu-common.h"
/**
* FU_DFU_CSR_DEVICE_QUIRK_FLAG_REQUIRE_DELAY:
......@@ -34,7 +33,7 @@ struct _FuDfuCsrDevice
{
FuHidDevice parent_instance;
FuDfuCsrDeviceQuirks quirks;
DfuState dfu_state;
FuDfuState dfu_state;
guint32 dnload_timeout;
};
......@@ -62,7 +61,7 @@ static void
fu_dfu_csr_device_to_string (FuDevice *device, guint idt, GString *str)
{
FuDfuCsrDevice *self = FU_DFU_CSR_DEVICE (device);
fu_common_string_append_kv (str, idt, "State", dfu_state_to_string (self->dfu_state));
fu_common_string_append_kv (str, idt, "State", fu_dfu_state_to_string (self->dfu_state));
fu_common_string_append_ku (str, idt, "DownloadTimeout", self->dnload_timeout);
}
......@@ -112,8 +111,8 @@ fu_dfu_csr_device_get_status (FuDfuCsrDevice *self, GError **error)
self->dfu_state = buf[5];
self->dnload_timeout = buf[2] + (((guint32) buf[3]) << 8) + (((guint32) buf[4]) << 16);
g_debug ("timeout=%" G_GUINT32_FORMAT, self->dnload_timeout);
g_debug ("state=%s", dfu_state_to_string (self->dfu_state));
g_debug ("status=%s", dfu_status_to_string (buf[6]));
g_debug ("state=%s", fu_dfu_state_to_string (self->dfu_state));
g_debug ("status=%s", fu_dfu_status_to_string (buf[6]));
return TRUE;
}
......@@ -127,7 +126,7 @@ fu_dfu_csr_device_clear_status (FuDfuCsrDevice *self, GError **error)
/* only clear the status if the state is error */
if (!fu_dfu_csr_device_get_status (self, error))
return FALSE;
if (self->dfu_state != DFU_STATE_DFU_ERROR)
if (self->dfu_state != FU_DFU_STATE_DFU_ERROR)
return TRUE;
/* hit hardware */
......@@ -261,7 +260,7 @@ fu_dfu_csr_device_upload (FuDevice *device, GError **error)
}
/* notify UI */
return dfu_utils_bytes_join_array (chunks);
return fu_dfu_utils_bytes_join_array (chunks);
}
static gboolean
......@@ -314,7 +313,7 @@ fu_dfu_csr_device_download_chunk (FuDfuCsrDevice *self, guint16 idx, GBytes *chu
return FALSE;
/* is still busy */
if (self->dfu_state == DFU_STATE_DFU_DNBUSY) {
if (self->dfu_state == FU_DFU_STATE_DFU_DNBUSY) {
g_debug ("busy, so sleeping a bit longer");
g_usleep (G_USEC_PER_SEC);
if (!fu_dfu_csr_device_get_status (self, error))
......@@ -322,8 +321,8 @@ fu_dfu_csr_device_download_chunk (FuDfuCsrDevice *self, guint16 idx, GBytes *chu
}
/* not correct */
if (self->dfu_state != DFU_STATE_DFU_DNLOAD_IDLE &&
self->dfu_state != DFU_STATE_DFU_IDLE) {
if (self->dfu_state != FU_DFU_STATE_DFU_DNLOAD_IDLE &&
self->dfu_state != FU_DFU_STATE_DFU_IDLE) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_INTERNAL,
......
/*
* Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <glib.h>
/**
* DfuRequest:
* @DFU_REQUEST_DETACH: Detach
* @DFU_REQUEST_DNLOAD: Download host-to-device
* @DFU_REQUEST_UPLOAD: Upload device-to-host
* @DFU_REQUEST_GETSTATUS: Get the device status
* @DFU_REQUEST_CLRSTATUS: Clear the device status
* @DFU_REQUEST_GETSTATE: Get the last set state
* @DFU_REQUEST_ABORT: Abort the current transfer
*
* The DFU request kinds.
**/
typedef enum {
DFU_REQUEST_DETACH = 0x00,
DFU_REQUEST_DNLOAD = 0x01,
DFU_REQUEST_UPLOAD = 0x02,
DFU_REQUEST_GETSTATUS = 0x03,
DFU_REQUEST_CLRSTATUS = 0x04,
DFU_REQUEST_GETSTATE = 0x05,
DFU_REQUEST_ABORT = 0x06,
/*< private >*/
DFU_REQUEST_LAST
} DfuRequest;
/**
* DfuStatus:
* @DFU_STATUS_OK: No error condition is present
* @DFU_STATUS_ERR_TARGET: File is not targeted for use by this device
* @DFU_STATUS_ERR_FILE: File is for this device but fails a verification test
* @DFU_STATUS_ERR_WRITE: Device is unable to write memory
* @DFU_STATUS_ERR_ERASE: Memory erase function failed
* @DFU_STATUS_ERR_CHECK_ERASED: Memory erase check failed
* @DFU_STATUS_ERR_PROG: Program memory function failed
* @DFU_STATUS_ERR_VERIFY: Programmed memory failed verification
* @DFU_STATUS_ERR_ADDRESS: Cannot program memory due to received address that isout of range
* @DFU_STATUS_ERR_NOTDONE: Received DFU_DNLOAD with wLength = 0 but data is incomplete
* @DFU_STATUS_ERR_FIRMWARE: Device firmware is corrupt
* @DFU_STATUS_ERR_VENDOR: iString indicates a vendor-specific error
* @DFU_STATUS_ERR_USBR: Device detected unexpected USB reset signaling
* @DFU_STATUS_ERR_POR: Device detected unexpected power on reset
* @DFU_STATUS_ERR_UNKNOWN: Something unexpected went wrong
* @DFU_STATUS_ERR_STALLDPKT: Device stalled an unexpected request
*
* The status enumerated kind.
**/
typedef enum {
DFU_STATUS_OK = 0x00,
DFU_STATUS_ERR_TARGET = 0x01,
DFU_STATUS_ERR_FILE = 0x02,
DFU_STATUS_ERR_WRITE = 0x03,
DFU_STATUS_ERR_ERASE = 0x04,
DFU_STATUS_ERR_CHECK_ERASED = 0x05,
DFU_STATUS_ERR_PROG = 0x06,
DFU_STATUS_ERR_VERIFY = 0x07,
DFU_STATUS_ERR_ADDRESS = 0x08,
DFU_STATUS_ERR_NOTDONE = 0x09,
DFU_STATUS_ERR_FIRMWARE = 0x0a,
DFU_STATUS_ERR_VENDOR = 0x0b,
DFU_STATUS_ERR_USBR = 0x0c,
DFU_STATUS_ERR_POR = 0x0d,
DFU_STATUS_ERR_UNKNOWN = 0x0e,
DFU_STATUS_ERR_STALLDPKT = 0x0f,
/*< private >*/
DFU_STATUS_LAST
} DfuStatus;
/**
* DfuState:
* @DFU_STATE_APP_IDLE: State 0
* @DFU_STATE_APP_DETACH: State 1
* @DFU_STATE_DFU_IDLE: State 2
* @DFU_STATE_DFU_DNLOAD_SYNC: State 3
* @DFU_STATE_DFU_DNBUSY: State 4
* @DFU_STATE_DFU_DNLOAD_IDLE: State 5
* @DFU_STATE_DFU_MANIFEST_SYNC: State 6
* @DFU_STATE_DFU_MANIFEST: State 7
* @DFU_STATE_DFU_MANIFEST_WAIT_RESET: State 8
* @DFU_STATE_DFU_UPLOAD_IDLE: State 9
* @DFU_STATE_DFU_ERROR: State 10
*
* The state enumerated kind.
**/
typedef enum {
DFU_STATE_APP_IDLE = 0x00,
DFU_STATE_APP_DETACH = 0x01,
DFU_STATE_DFU_IDLE = 0x02,
DFU_STATE_DFU_DNLOAD_SYNC = 0x03,
DFU_STATE_DFU_DNBUSY = 0x04,
DFU_STATE_DFU_DNLOAD_IDLE = 0x05,
DFU_STATE_DFU_MANIFEST_SYNC = 0x06,
DFU_STATE_DFU_MANIFEST = 0x07,
DFU_STATE_DFU_MANIFEST_WAIT_RESET = 0x08,
DFU_STATE_DFU_UPLOAD_IDLE = 0x09,
DFU_STATE_DFU_ERROR = 0x0a,
/*< private >*/
DFU_STATE_LAST
} DfuState;
const gchar *dfu_state_to_string (DfuState state);
const gchar *dfu_status_to_string (DfuStatus status);
/* helpers */
GBytes *dfu_utils_bytes_join_array (GPtrArray *chunks);
/*
* Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <glib-object.h>
#include <gio/gio.h>
#include <gusb.h>
#include "fu-usb-device.h"
#include "dfu-common.h"
#include "dfu-target.h"
#define DFU_TYPE_DEVICE (dfu_device_get_type ())
G_DECLARE_DERIVABLE_TYPE (DfuDevice, dfu_device, DFU, DEVICE, FuUsbDevice)
/**
* DfuDeviceAttributes:
* @DFU_DEVICE_ATTRIBUTE_NONE: No attributes set
* @DFU_DEVICE_ATTRIBUTE_CAN_DOWNLOAD: Can download from host->device
* @DFU_DEVICE_ATTRIBUTE_CAN_UPLOAD: Can upload from device->host
* @DFU_DEVICE_ATTRIBUTE_MANIFEST_TOL: Can answer GetStatus in manifest
* @DFU_DEVICE_ATTRIBUTE_WILL_DETACH: Will self-detach
* @DFU_DEVICE_ATTRIBUTE_CAN_ACCELERATE: Use a larger transfer size for speed
*
* The device DFU attributes.
**/
typedef enum {
DFU_DEVICE_ATTRIBUTE_NONE = 0,
DFU_DEVICE_ATTRIBUTE_CAN_DOWNLOAD = (1 << 0),
DFU_DEVICE_ATTRIBUTE_CAN_UPLOAD = (1 << 1),
DFU_DEVICE_ATTRIBUTE_MANIFEST_TOL = (1 << 2),
DFU_DEVICE_ATTRIBUTE_WILL_DETACH = (1 << 3),
DFU_DEVICE_ATTRIBUTE_CAN_ACCELERATE = (1 << 7),
/*< private >*/
DFU_DEVICE_ATTRIBUTE_LAST
} DfuDeviceAttributes;
struct _DfuDeviceClass
{
FuUsbDeviceClass parent_class;
};
DfuDevice *dfu_device_new (GUsbDevice *usb_device);
const gchar *dfu_device_get_platform_id (DfuDevice *device);
GPtrArray *dfu_device_get_targets (DfuDevice *device);
DfuTarget *dfu_device_get_target_by_alt_setting (DfuDevice *device,
guint8 alt_setting,
GError **error);
DfuTarget *dfu_device_get_target_by_alt_name (DfuDevice *device,
const gchar *alt_name,
GError **error);
const gchar *dfu_device_get_chip_id (DfuDevice *device);
void dfu_device_set_chip_id (DfuDevice *device,
const gchar *chip_id);
guint16 dfu_device_get_runtime_vid (DfuDevice *device);
guint16 dfu_device_get_runtime_pid (DfuDevice *device);
guint16 dfu_device_get_runtime_release (DfuDevice *device);
gboolean dfu_device_reset (DfuDevice *device,
GError **error);
FuFirmware *dfu_device_upload (DfuDevice *device,
DfuTargetTransferFlags flags,
GError **error);
gboolean dfu_device_refresh (DfuDevice *device,
GError **error);
gboolean dfu_device_refresh_and_clear (DfuDevice *device,
GError **error);
gboolean dfu_device_abort (DfuDevice *device,
GError **error);
gboolean dfu_device_clear_status (DfuDevice *device,
GError **error);
guint8 dfu_device_get_interface (DfuDevice *device);
DfuState dfu_device_get_state (DfuDevice *device);
DfuStatus dfu_device_get_status (DfuDevice *device);
guint16 dfu_device_get_transfer_size (DfuDevice *device);
guint16 dfu_device_get_version (DfuDevice *device);
guint dfu_device_get_timeout (DfuDevice *device);
gboolean dfu_device_can_upload (DfuDevice *device);
gboolean dfu_device_can_download (DfuDevice *device);
gboolean dfu_device_has_attribute (DfuDevice *device,
DfuDeviceAttributes attribute);
void dfu_device_remove_attribute (DfuDevice *device,
DfuDeviceAttributes attribute);
void dfu_device_set_transfer_size (DfuDevice *device,
guint16 transfer_size);
void dfu_device_set_timeout (DfuDevice *device,
guint timeout_ms);
void dfu_device_error_fixup (DfuDevice *device,
GError **error);
guint dfu_device_get_download_timeout (DfuDevice *device);
gchar *dfu_device_get_attributes_as_string (DfuDevice *device);
gboolean dfu_device_ensure_interface (DfuDevice *device,
GError **error);
......@@ -20,7 +20,7 @@ Flags = detach-for-attach
# Openmoko Freerunner / GTA02
[DeviceInstanceId=USB\VID_1D50&PID_5119]
Plugin = dfu
Flags = ignore-polltimeout,no-pid-change,no-dfu-runtime,needs-bootloader,no-get-status-upload
Flags = ignore-polltimeout,no-pid-change,no-fu-dfu-runtime,needs-bootloader,no-get-status-upload
# OpenPCD Reader
[DeviceInstanceId=USB\VID_16C0&PID_076B]
......@@ -68,7 +68,7 @@ Flags = attach-upload-download
# HydraBus
[DeviceInstanceId=USB\VID_1D50&PID_60A7]
Plugin = dfu
Flags = no-dfu-runtime,needs-bootloader
Flags = no-fu-dfu-runtime,needs-bootloader
# Jabra 410 [appIDLE & dfuIDLE]
[DeviceInstanceId=USB\VID_0B0E&PID_0411]
......
......@@ -5,7 +5,7 @@
*/
/**
* SECTION:dfu-common
* SECTION:fu-dfu-common
* @short_description: Common functions for DFU
*
* These helper objects allow converting from enum values to strings.
......@@ -15,92 +15,92 @@
#include <string.h>
#include "dfu-common.h"
#include "fu-dfu-common.h"
/**
* dfu_state_to_string:
* @state: a #DfuState, e.g. %DFU_STATE_DFU_MANIFEST
* fu_dfu_state_to_string:
* @state: a #FuDfuState, e.g. %FU_DFU_STATE_DFU_MANIFEST
*
* Converts an enumerated value to a string.
*
* Return value: a string
**/
const gchar *
dfu_state_to_string (DfuState state)
fu_dfu_state_to_string (FuDfuState state)
{
if (state == DFU_STATE_APP_IDLE)
if (state == FU_DFU_STATE_APP_IDLE)
return "appIDLE";
if (state == DFU_STATE_APP_DETACH)
if (state == FU_DFU_STATE_APP_DETACH)
return "appDETACH";
if (state == DFU_STATE_DFU_IDLE)
if (state == FU_DFU_STATE_DFU_IDLE)
return "dfuIDLE";
if (state == DFU_STATE_DFU_DNLOAD_SYNC)
if (state == FU_DFU_STATE_DFU_DNLOAD_SYNC)
return "dfuDNLOAD-SYNC";
if (state == DFU_STATE_DFU_DNBUSY)
if (state == FU_DFU_STATE_DFU_DNBUSY)
return "dfuDNBUSY";
if (state == DFU_STATE_DFU_DNLOAD_IDLE)
if (state == FU_DFU_STATE_DFU_DNLOAD_IDLE)
return "dfuDNLOAD-IDLE";
if (state == DFU_STATE_DFU_MANIFEST_SYNC)
if (state == FU_DFU_STATE_DFU_MANIFEST_SYNC)
return "dfuMANIFEST-SYNC";
if (state == DFU_STATE_DFU_MANIFEST)
if (state == FU_DFU_STATE_DFU_MANIFEST)
return "dfuMANIFEST";
if (state == DFU_STATE_DFU_MANIFEST_WAIT_RESET)
if (state == FU_DFU_STATE_DFU_MANIFEST_WAIT_RESET)
return "dfuMANIFEST-WAIT-RESET";
if (state == DFU_STATE_DFU_UPLOAD_IDLE)
if (state == FU_DFU_STATE_DFU_UPLOAD_IDLE)
return "dfuUPLOAD-IDLE";
if (state == DFU_STATE_DFU_ERROR)
if (state == FU_DFU_STATE_DFU_ERROR)
return "dfuERROR";
return NULL;
}
/**
* dfu_status_to_string:
* @status: a #DfuStatus, e.g. %DFU_STATUS_ERR_ERASE
* fu_dfu_status_to_string:
* @status: a #FuDfuStatus, e.g. %FU_DFU_STATUS_ERR_ERASE
*
* Converts an enumerated value to a string.
*
* Return value: a string
**/
const gchar *
dfu_status_to_string (DfuStatus status)
fu_dfu_status_to_string (FuDfuStatus status)
{
if (status == DFU_STATUS_OK)
if (status == FU_DFU_STATUS_OK)
return "OK";
if (status == DFU_STATUS_ERR_TARGET)
if (status == FU_DFU_STATUS_ERR_TARGET)
return "errTARGET";
if (status == DFU_STATUS_ERR_FILE)
if (status == FU_DFU_STATUS_ERR_FILE)
return "errFILE";
if (status == DFU_STATUS_ERR_WRITE)
if (status == FU_DFU_STATUS_ERR_WRITE)
return "errwrite";
if (status == DFU_STATUS_ERR_ERASE)
if (status == FU_DFU_STATUS_ERR_ERASE)
return "errERASE";
if (status == DFU_STATUS_ERR_CHECK_ERASED)
if (status == FU_DFU_STATUS_ERR_CHECK_ERASED)
return "errCHECK_ERASED";
if (status == DFU_STATUS_ERR_PROG)
if (status == FU_DFU_STATUS_ERR_PROG)
return "errPROG";
if (status == DFU_STATUS_ERR_VERIFY)
if (status == FU_DFU_STATUS_ERR_VERIFY)
return "errVERIFY";
if (status == DFU_STATUS_ERR_ADDRESS)
if (status == FU_DFU_STATUS_ERR_ADDRESS)
return "errADDRESS";
if (status == DFU_STATUS_ERR_NOTDONE)
if (status == FU_DFU_STATUS_ERR_NOTDONE)
return "errNOTDONE";
if (status == DFU_STATUS_ERR_FIRMWARE)
if (status == FU_DFU_STATUS_ERR_FIRMWARE)
return "errFIRMWARE";
if (status == DFU_STATUS_ERR_VENDOR)
if (status == FU_DFU_STATUS_ERR_VENDOR)
return "errVENDOR";
if (status == DFU_STATUS_ERR_USBR)
if (status == FU_DFU_STATUS_ERR_USBR)
return "errUSBR";
if (status == DFU_STATUS_ERR_POR)
if (status == FU_DFU_STATUS_ERR_POR)
return "errPOR";
if (status == DFU_STATUS_ERR_UNKNOWN)
if (status == FU_DFU_STATUS_ERR_UNKNOWN)
return "errUNKNOWN";
if (status == DFU_STATUS_ERR_STALLDPKT)
if (status == FU_DFU_STATUS_ERR_STALLDPKT)
return "errSTALLDPKT";
return NULL;
}
/**
* dfu_utils_bytes_join_array:
* fu_dfu_utils_bytes_join_array:
* @chunks: (element-type GBytes): bytes
*
* Creates a monolithic block of memory from an array of #GBytes.
......@@ -108,7 +108,7 @@ dfu_status_to_string (DfuStatus status)
* Return value: (transfer full): a new GBytes
**/
GBytes *
dfu_utils_bytes_join_array (GPtrArray *chunks)
fu_dfu_utils_bytes_join_array (GPtrArray *chunks)
{
gsize total_size = 0;
guint32 offset = 0;
......
/*
* Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <glib.h>
/**
* FuDfuRequest:
* @FU_DFU_REQUEST_DETACH: Detach
* @FU_DFU_REQUEST_DNLOAD: Download host-to-device
* @FU_DFU_REQUEST_UPLOAD: Upload device-to-host
* @FU_DFU_REQUEST_GETSTATUS: Get the device status
* @FU_DFU_REQUEST_CLRSTATUS: Clear the device status
* @FU_DFU_REQUEST_GETSTATE: Get the last set state
* @FU_DFU_REQUEST_ABORT: Abort the current transfer
*
* The DFU request kinds.
**/
typedef enum {
FU_DFU_REQUEST_DETACH = 0x00,
FU_DFU_REQUEST_DNLOAD = 0x01,
FU_DFU_REQUEST_UPLOAD = 0x02,
FU_DFU_REQUEST_GETSTATUS = 0x03,
FU_DFU_REQUEST_CLRSTATUS = 0x04,
FU_DFU_REQUEST_GETSTATE = 0x05,
FU_DFU_REQUEST_ABORT = 0x06,
/*< private >*/
FU_DFU_REQUEST_LAST
} FuDfuRequest;
/**
* FuDfuStatus:
* @FU_DFU_STATUS_OK: No error condition is present
* @FU_DFU_STATUS_ERR_TARGET: File is not targeted for use by this device
* @FU_DFU_STATUS_ERR_FILE: File is for this device but fails a verification test
* @FU_DFU_STATUS_ERR_WRITE: Device is unable to write memory
* @FU_DFU_STATUS_ERR_ERASE: Memory erase function failed
* @FU_DFU_STATUS_ERR_CHECK_ERASED: Memory erase check failed
* @FU_DFU_STATUS_ERR_PROG: Program memory function failed
* @FU_DFU_STATUS_ERR_VERIFY: Programmed memory failed verification
* @FU_DFU_STATUS_ERR_ADDRESS: Cannot program memory due to received address that isout of range
* @FU_DFU_STATUS_ERR_NOTDONE: Received DFU_DNLOAD with wLength = 0 but data is incomplete
* @FU_DFU_STATUS_ERR_FIRMWARE: Device firmware is corrupt
* @FU_DFU_STATUS_ERR_VENDOR: iString indicates a vendor-specific error
* @FU_DFU_STATUS_ERR_USBR: Device detected unexpected USB reset signaling
* @FU_DFU_STATUS_ERR_POR: Device detected unexpected power on reset
* @FU_DFU_STATUS_ERR_UNKNOWN: Something unexpected went wrong
* @FU_DFU_STATUS_ERR_STALLDPKT: Device stalled an unexpected request
*
* The status enumerated kind.
**/
typedef enum {
FU_DFU_STATUS_OK = 0x00,
FU_DFU_STATUS_ERR_TARGET = 0x01,
FU_DFU_STATUS_ERR_FILE = 0x02,
FU_DFU_STATUS_ERR_WRITE = 0x03,
FU_DFU_STATUS_ERR_ERASE = 0x04,
FU_DFU_STATUS_ERR_CHECK_ERASED = 0x05,
FU_DFU_STATUS_ERR_PROG = 0x06,
FU_DFU_STATUS_ERR_VERIFY = 0x07,
FU_DFU_STATUS_ERR_ADDRESS = 0x08,
FU_DFU_STATUS_ERR_NOTDONE = 0x09,
FU_DFU_STATUS_ERR_FIRMWARE = 0x0a,
FU_DFU_STATUS_ERR_VENDOR = 0x0b,
FU_DFU_STATUS_ERR_USBR = 0x0c,
FU_DFU_STATUS_ERR_POR = 0x0d,
FU_DFU_STATUS_ERR_UNKNOWN = 0x0e,
FU_DFU_STATUS_ERR_STALLDPKT = 0x0f,
/*< private >*/
FU_DFU_STATUS_LAST
} FuDfuStatus;
/**
* FuDfuState:
* @FU_DFU_STATE_APP_IDLE: State 0
* @FU_DFU_STATE_APP_DETACH: State 1
* @FU_DFU_STATE_DFU_IDLE: State 2
* @FU_DFU_STATE_DFU_DNLOAD_SYNC: State 3
* @FU_DFU_STATE_DFU_DNBUSY: State 4
* @FU_DFU_STATE_DFU_DNLOAD_IDLE: State 5
* @FU_DFU_STATE_DFU_MANIFEST_SYNC: State 6
* @FU_DFU_STATE_DFU_MANIFEST: State 7
* @FU_DFU_STATE_DFU_MANIFEST_WAIT_RESET: State 8
* @FU_DFU_STATE_DFU_UPLOAD_IDLE: State 9
* @FU_DFU_STATE_DFU_ERROR: State 10
*
* The state enumerated kind.
**/
typedef enum {
FU_DFU_STATE_APP_IDLE = 0x00,
FU_DFU_STATE_APP_DETACH = 0x01,
FU_DFU_STATE_DFU_IDLE = 0x02,
FU_DFU_STATE_DFU_DNLOAD_SYNC = 0x03,
FU_DFU_STATE_DFU_DNBUSY = 0x04,
FU_DFU_STATE_DFU_DNLOAD_IDLE = 0x05,
FU_DFU_STATE_DFU_MANIFEST_SYNC = 0x06,
FU_DFU_STATE_DFU_MANIFEST = 0x07,
FU_DFU_STATE_DFU_MANIFEST_WAIT_RESET = 0x08,
FU_DFU_STATE_DFU_UPLOAD_IDLE = 0x09,
FU_DFU_STATE_DFU_ERROR = 0x0a,
/*< private >*/
FU_DFU_STATE_LAST
} FuDfuState;
const gchar *fu_dfu_state_to_string (FuDfuState state);
const gchar *fu_dfu_status_to_string (FuDfuStatus status);
/* helpers */
GBytes *fu_dfu_utils_bytes_join_array (GPtrArray *chunks);
/*
* Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <glib-object.h>
#include <gio/gio.h>
#include <gusb.h>
#include "fu-usb-device.h"
#include "fu-dfu-common.h"
#include "fu-dfu-target.h"
#define FU_TYPE_DFU_DEVICE (fu_dfu_device_get_type ())
G_DECLARE_DERIVABLE_TYPE (FuDfuDevice, fu_dfu_device, FU, DFU_DEVICE, FuUsbDevice)
/**
* FuDfuDeviceAttrs:
* @FU_DFU_DEVICE_ATTR_NONE: No attributes set
* @FU_DFU_DEVICE_ATTR_CAN_DOWNLOAD: Can download from host->device
* @FU_DFU_DEVICE_ATTR_CAN_UPLOAD: Can upload from device->host
* @FU_DFU_DEVICE_ATTR_MANIFEST_TOL: Can answer GetStatus in manifest
* @FU_DFU_DEVICE_ATTR_WILL_DETACH: Will self-detach
* @FU_DFU_DEVICE_ATTR_CAN_ACCELERATE: Use a larger transfer size for speed
*
* The device DFU attributes.
**/
typedef enum {
FU_DFU_DEVICE_ATTR_NONE = 0,
FU_DFU_DEVICE_ATTR_CAN_DOWNLOAD = (1 << 0),
FU_DFU_DEVICE_ATTR_CAN_UPLOAD = (1 << 1),
FU_DFU_DEVICE_ATTR_MANIFEST_TOL = (1 << 2),
FU_DFU_DEVICE_ATTR_WILL_DETACH = (1 << 3),
FU_DFU_DEVICE_ATTR_CAN_ACCELERATE = (1 << 7),
/*< private >*/
FU_DFU_DEVICE_ATTR_LAST
} FuDfuDeviceAttrs;
struct _FuDfuDeviceClass
{
FuUsbDeviceClass parent_class;
};
FuDfuDevice *fu_dfu_device_new (GUsbDevice *usb_device);
const gchar *fu_dfu_device_get_platform_id (FuDfuDevice *self);
GPtrArray *fu_dfu_device_get_targets (FuDfuDevice *self);
FuDfuTarget *fu_dfu_device_get_target_by_alt_setting(FuDfuDevice *self,
guint8 alt_setting,
GError **error);
FuDfuTarget *fu_dfu_device_get_target_by_alt_name (FuDfuDevice *self,
const gchar *alt_name,
GError **error);