-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fpc: Add support for devices that use FPC FF2
- Loading branch information
Showing
6 changed files
with
287 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2024 Richard Hughes <richard@hughsie.com> | ||
* | ||
* SPDX-License-Identifier: LGPL-2.1-or-later | ||
*/ | ||
|
||
#include "config.h" | ||
|
||
#include <fwupdplugin.h> | ||
|
||
#include "fu-fpc-ff2-firmware.h" | ||
#include "fu-fpc-struct.h" | ||
|
||
struct _FuFpcFf2Firmware { | ||
FuFirmware parent_instance; | ||
guint32 blocks_num; | ||
}; | ||
|
||
G_DEFINE_TYPE(FuFpcFf2Firmware, fu_fpc_ff2_firmware, FU_TYPE_FIRMWARE) | ||
|
||
static void | ||
fu_fpc_ff2_firmware_export(FuFirmware *firmware, FuFirmwareExportFlags flags, XbBuilderNode *bn) | ||
{ | ||
FuFpcFf2Firmware *self = FU_FPC_FF2_FIRMWARE(firmware); | ||
fu_xmlb_builder_insert_kx(bn, "blocks_num", self->blocks_num); | ||
} | ||
|
||
static gboolean | ||
fu_fpc_ff2_validate(FuFirmware *firmware, GInputStream *stream, gsize offset, GError **error) | ||
{ | ||
return fu_struct_fpc_ff2_hdr_validate_stream(stream, offset, error); | ||
} | ||
|
||
static gboolean | ||
fu_fpc_ff2_firmware_parse(FuFirmware *firmware, | ||
GInputStream *stream, | ||
gsize offset, | ||
FwupdInstallFlags flags, | ||
GError **error) | ||
{ | ||
FuFpcFf2Firmware *self = FU_FPC_FF2_FIRMWARE(firmware); | ||
g_autoptr(FuStructFpcFf2Hdr) st_hdr = NULL; | ||
|
||
st_hdr = fu_struct_fpc_ff2_hdr_parse_stream(stream, offset, error); | ||
if (st_hdr == NULL) | ||
return FALSE; | ||
self->blocks_num = fu_struct_fpc_ff2_hdr_get_blocks_num(st_hdr); | ||
|
||
/* success */ | ||
return TRUE; | ||
} | ||
|
||
guint32 | ||
fu_fpc_ff2_firmware_get_blocks_num(FuFpcFf2Firmware *self) | ||
{ | ||
g_return_val_if_fail(FU_IS_FPC_FF2_FIRMWARE(self), G_MAXUINT16); | ||
return self->blocks_num; | ||
} | ||
|
||
static void | ||
fu_fpc_ff2_firmware_init(FuFpcFf2Firmware *self) | ||
{ | ||
} | ||
|
||
static void | ||
fu_fpc_ff2_firmware_class_init(FuFpcFf2FirmwareClass *klass) | ||
{ | ||
FuFirmwareClass *firmware_class = FU_FIRMWARE_CLASS(klass); | ||
firmware_class->validate = fu_fpc_ff2_validate; | ||
firmware_class->parse = fu_fpc_ff2_firmware_parse; | ||
firmware_class->export = fu_fpc_ff2_firmware_export; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright 2024 Richard Hughes <richard@hughsie.com> | ||
* | ||
* SPDX-License-Identifier: LGPL-2.1-or-later | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <fwupdplugin.h> | ||
|
||
#define FU_TYPE_FPC_FF2_FIRMWARE (fu_fpc_ff2_firmware_get_type()) | ||
G_DECLARE_FINAL_TYPE(FuFpcFf2Firmware, fu_fpc_ff2_firmware, FU, FPC_FF2_FIRMWARE, FuFirmware) | ||
|
||
guint32 | ||
fu_fpc_ff2_firmware_get_blocks_num(FuFpcFf2Firmware *self); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters