mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-27 15:03:59 +00:00
analogix: Be more accurate when reporting percentage progress
This commit is contained in:
parent
912a578411
commit
22928ac52a
@ -242,6 +242,40 @@ fu_analogix_device_probe(FuDevice *device, GError **error)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fu_analogix_device_write_chunks(FuAnalogixDevice *self,
|
||||||
|
GPtrArray *chunks,
|
||||||
|
guint16 req_val,
|
||||||
|
FuProgress *progress,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
/* progress */
|
||||||
|
fu_progress_set_id(progress, G_STRLOC);
|
||||||
|
fu_progress_set_steps(progress, chunks->len);
|
||||||
|
for (guint i = 0; i < chunks->len; i++) {
|
||||||
|
AnxUpdateStatus status = UPDATE_STATUS_INVALID;
|
||||||
|
FuChunk *chk = g_ptr_array_index(chunks, i);
|
||||||
|
if (!fu_analogix_device_send(self,
|
||||||
|
ANX_BB_RQT_SEND_UPDATE_DATA,
|
||||||
|
req_val,
|
||||||
|
i + 1,
|
||||||
|
fu_chunk_get_data(chk),
|
||||||
|
fu_chunk_get_data_sz(chk),
|
||||||
|
error)) {
|
||||||
|
g_prefix_error(error, "failed send on chk %u: ", i);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!fu_analogix_device_get_update_status(self, &status, error)) {
|
||||||
|
g_prefix_error(error, "failed status on chk %u: ", i);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
fu_progress_step_done(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* success */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_analogix_device_write_image(FuAnalogixDevice *self,
|
fu_analogix_device_write_image(FuAnalogixDevice *self,
|
||||||
FuFirmware *image,
|
FuFirmware *image,
|
||||||
@ -256,9 +290,8 @@ fu_analogix_device_write_image(FuAnalogixDevice *self,
|
|||||||
|
|
||||||
/* progress */
|
/* progress */
|
||||||
fu_progress_set_id(progress, G_STRLOC);
|
fu_progress_set_id(progress, G_STRLOC);
|
||||||
fu_progress_add_flag(progress, FU_PROGRESS_FLAG_GUESSED);
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 2, "initialization");
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 10, "initialization");
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 98, NULL);
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 90, NULL);
|
|
||||||
|
|
||||||
/* offset into firmware */
|
/* offset into firmware */
|
||||||
block_bytes = fu_firmware_get_bytes(image, error);
|
block_bytes = fu_firmware_get_bytes(image, error);
|
||||||
@ -283,26 +316,12 @@ fu_analogix_device_write_image(FuAnalogixDevice *self,
|
|||||||
|
|
||||||
/* write data */
|
/* write data */
|
||||||
chunks = fu_chunk_array_new_from_bytes(block_bytes, 0x00, 0x00, BILLBOARD_MAX_PACKET_SIZE);
|
chunks = fu_chunk_array_new_from_bytes(block_bytes, 0x00, 0x00, BILLBOARD_MAX_PACKET_SIZE);
|
||||||
for (guint i = 0; i < chunks->len; i++) {
|
if (!fu_analogix_device_write_chunks(self,
|
||||||
FuChunk *chk = g_ptr_array_index(chunks, i);
|
chunks,
|
||||||
if (!fu_analogix_device_send(self,
|
|
||||||
ANX_BB_RQT_SEND_UPDATE_DATA,
|
|
||||||
req_val,
|
req_val,
|
||||||
i + 1,
|
fu_progress_get_child(progress),
|
||||||
fu_chunk_get_data(chk),
|
error))
|
||||||
fu_chunk_get_data_sz(chk),
|
|
||||||
error)) {
|
|
||||||
g_prefix_error(error, "failed send on chk %u: ", i);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
if (!fu_analogix_device_get_update_status(self, &status, error)) {
|
|
||||||
g_prefix_error(error, "failed status on chk %u: ", i);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
fu_progress_set_percentage_full(fu_progress_get_child(progress),
|
|
||||||
i + 1,
|
|
||||||
chunks->len);
|
|
||||||
}
|
|
||||||
fu_progress_step_done(progress);
|
fu_progress_step_done(progress);
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
@ -317,21 +336,54 @@ fu_analogix_device_write_firmware(FuDevice *device,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
FuAnalogixDevice *self = FU_ANALOGIX_DEVICE(device);
|
FuAnalogixDevice *self = FU_ANALOGIX_DEVICE(device);
|
||||||
|
gsize totalsz = 0;
|
||||||
g_autoptr(FuFirmware) fw_cus = NULL;
|
g_autoptr(FuFirmware) fw_cus = NULL;
|
||||||
g_autoptr(FuFirmware) fw_ocm = NULL;
|
g_autoptr(FuFirmware) fw_ocm = NULL;
|
||||||
g_autoptr(FuFirmware) fw_srx = NULL;
|
g_autoptr(FuFirmware) fw_srx = NULL;
|
||||||
g_autoptr(FuFirmware) fw_stx = NULL;
|
g_autoptr(FuFirmware) fw_stx = NULL;
|
||||||
|
|
||||||
|
/* these are all optional */
|
||||||
|
fw_cus = fu_firmware_get_image_by_id(firmware, "custom", NULL);
|
||||||
|
fw_stx = fu_firmware_get_image_by_id(firmware, "stx", NULL);
|
||||||
|
fw_srx = fu_firmware_get_image_by_id(firmware, "srx", NULL);
|
||||||
|
fw_ocm = fu_firmware_get_image_by_id(firmware, "ocm", NULL);
|
||||||
|
|
||||||
/* progress */
|
/* progress */
|
||||||
fu_progress_set_id(progress, G_STRLOC);
|
fu_progress_set_id(progress, G_STRLOC);
|
||||||
fu_progress_add_flag(progress, FU_PROGRESS_FLAG_GUESSED);
|
if (fw_cus != NULL)
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 25, "cus");
|
totalsz += fu_firmware_get_size(fw_cus);
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 25, "stx");
|
if (fw_stx != NULL)
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 25, "srx");
|
totalsz += fu_firmware_get_size(fw_stx);
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 25, "ocm");
|
if (fw_srx != NULL)
|
||||||
|
totalsz += fu_firmware_get_size(fw_srx);
|
||||||
|
if (fw_ocm != NULL)
|
||||||
|
totalsz += fu_firmware_get_size(fw_ocm);
|
||||||
|
if (fw_cus != NULL) {
|
||||||
|
fu_progress_add_step(progress,
|
||||||
|
FWUPD_STATUS_DEVICE_WRITE,
|
||||||
|
(100 * fu_firmware_get_size(fw_cus) / totalsz),
|
||||||
|
"cus");
|
||||||
|
}
|
||||||
|
if (fw_stx != NULL) {
|
||||||
|
fu_progress_add_step(progress,
|
||||||
|
FWUPD_STATUS_DEVICE_WRITE,
|
||||||
|
(100 * fu_firmware_get_size(fw_stx) / totalsz),
|
||||||
|
"stx");
|
||||||
|
}
|
||||||
|
if (fw_srx != NULL) {
|
||||||
|
fu_progress_add_step(progress,
|
||||||
|
FWUPD_STATUS_DEVICE_WRITE,
|
||||||
|
(100 * fu_firmware_get_size(fw_srx) / totalsz),
|
||||||
|
"srx");
|
||||||
|
}
|
||||||
|
if (fw_ocm != NULL) {
|
||||||
|
fu_progress_add_step(progress,
|
||||||
|
FWUPD_STATUS_DEVICE_WRITE,
|
||||||
|
(100 * fu_firmware_get_size(fw_ocm) / totalsz),
|
||||||
|
"ocm");
|
||||||
|
}
|
||||||
|
|
||||||
/* CUSTOM_DEF */
|
/* CUSTOM_DEF */
|
||||||
fw_cus = fu_firmware_get_image_by_id(firmware, "custom", NULL);
|
|
||||||
if (fw_cus != NULL) {
|
if (fw_cus != NULL) {
|
||||||
if (!fu_analogix_device_write_image(self,
|
if (!fu_analogix_device_write_image(self,
|
||||||
fw_cus,
|
fw_cus,
|
||||||
@ -341,11 +393,10 @@ fu_analogix_device_write_firmware(FuDevice *device,
|
|||||||
g_prefix_error(error, "program custom define failed: ");
|
g_prefix_error(error, "program custom define failed: ");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fu_progress_step_done(progress);
|
fu_progress_step_done(progress);
|
||||||
|
}
|
||||||
|
|
||||||
/* SECURE_TX */
|
/* SECURE_TX */
|
||||||
fw_stx = fu_firmware_get_image_by_id(firmware, "stx", NULL);
|
|
||||||
if (fw_stx != NULL) {
|
if (fw_stx != NULL) {
|
||||||
if (!fu_analogix_device_write_image(self,
|
if (!fu_analogix_device_write_image(self,
|
||||||
fw_stx,
|
fw_stx,
|
||||||
@ -355,11 +406,10 @@ fu_analogix_device_write_firmware(FuDevice *device,
|
|||||||
g_prefix_error(error, "program secure TX failed: ");
|
g_prefix_error(error, "program secure TX failed: ");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fu_progress_step_done(progress);
|
fu_progress_step_done(progress);
|
||||||
|
}
|
||||||
|
|
||||||
/* SECURE_RX */
|
/* SECURE_RX */
|
||||||
fw_srx = fu_firmware_get_image_by_id(firmware, "srx", NULL);
|
|
||||||
if (fw_srx != NULL) {
|
if (fw_srx != NULL) {
|
||||||
if (!fu_analogix_device_write_image(self,
|
if (!fu_analogix_device_write_image(self,
|
||||||
fw_srx,
|
fw_srx,
|
||||||
@ -369,11 +419,10 @@ fu_analogix_device_write_firmware(FuDevice *device,
|
|||||||
g_prefix_error(error, "program secure RX failed: ");
|
g_prefix_error(error, "program secure RX failed: ");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fu_progress_step_done(progress);
|
fu_progress_step_done(progress);
|
||||||
|
}
|
||||||
|
|
||||||
/* OCM */
|
/* OCM */
|
||||||
fw_ocm = fu_firmware_get_image_by_id(firmware, "ocm", NULL);
|
|
||||||
if (fw_ocm != NULL) {
|
if (fw_ocm != NULL) {
|
||||||
if (!fu_analogix_device_write_image(self,
|
if (!fu_analogix_device_write_image(self,
|
||||||
fw_ocm,
|
fw_ocm,
|
||||||
@ -383,8 +432,8 @@ fu_analogix_device_write_firmware(FuDevice *device,
|
|||||||
g_prefix_error(error, "program OCM failed: ");
|
g_prefix_error(error, "program OCM failed: ");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fu_progress_step_done(progress);
|
fu_progress_step_done(progress);
|
||||||
|
}
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -394,11 +443,10 @@ static void
|
|||||||
fu_analogix_device_set_progress(FuDevice *self, FuProgress *progress)
|
fu_analogix_device_set_progress(FuDevice *self, FuProgress *progress)
|
||||||
{
|
{
|
||||||
fu_progress_set_id(progress, G_STRLOC);
|
fu_progress_set_id(progress, G_STRLOC);
|
||||||
fu_progress_add_flag(progress, FU_PROGRESS_FLAG_GUESSED);
|
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_RESTART, 0, "detach");
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_RESTART, 0, "detach");
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 98, "write");
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 99, "write");
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_RESTART, 0, "attach");
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_RESTART, 0, "attach");
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 2, "reload");
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 1, "reload");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user