/*
 * This file is auto-generated, do not modify!
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "config.h"

#include <glib.h>

#include "fu-elan-ts-struct.h"
#include "fu-byte-array.h"
#include "fu-bytes.h"
#include "fu-mem-private.h"
#include "fu-string.h"

#ifdef G_LOG_DOMAIN
  #undef G_LOG_DOMAIN
#endif
#define G_LOG_DOMAIN "FuStruct"


/**
 * fu_elan_ts_report_id_to_string:
 * @val: value, e.g. %FU_ELAN_TS_REPORT_ID_INPUT
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_elan_ts_report_id_to_string(FuElanTsReportId val)
{
    if (val == FU_ELAN_TS_REPORT_ID_FINGER)
        return "finger";
    if (val == FU_ELAN_TS_REPORT_ID_INPUT)
        return "input";
    if (val == FU_ELAN_TS_REPORT_ID_OUTPUT)
        return "output";
    if (val == FU_ELAN_TS_REPORT_ID_PEN)
        return "pen";
    if (val == FU_ELAN_TS_REPORT_ID_PEN_DEBUG)
        return "pen-debug";
    return NULL;
}


/**
 * fu_elan_ts_fw_type_to_string:
 * @val: value, e.g. %FU_ELAN_TS_FW_TYPE_EKT
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_elan_ts_fw_type_to_string(FuElanTsFwType val)
{
    if (val == FU_ELAN_TS_FW_TYPE_EKT)
        return "ekt";
    if (val == FU_ELAN_TS_FW_TYPE_EKTL)
        return "ektl";
    return NULL;
}





/**
 * fu_elan_ts_vendor_cmd_to_string:
 * @val: value, e.g. %FU_ELAN_TS_VENDOR_CMD_FLASH_WRITE
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_elan_ts_vendor_cmd_to_string(FuElanTsVendorCmd val)
{
    if (val == FU_ELAN_TS_VENDOR_CMD_READ_HELLO_PKT_AND_BC_VER)
        return "read-hello-pkt-and-bc-ver";
    if (val == FU_ELAN_TS_VENDOR_CMD_FLASH_WRITE)
        return "flash-write";
    return NULL;
}

/**
 * fu_elan_ts_hello_packet_to_string:
 * @val: value, e.g. %FU_ELAN_TS_HELLO_PACKET_RECOVERY_MODE
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_elan_ts_hello_packet_to_string(FuElanTsHelloPacket val)
{
    if (val == FU_ELAN_TS_HELLO_PACKET_NORMAL_MODE)
        return "normal-mode";
    if (val == FU_ELAN_TS_HELLO_PACKET_RECOVERY_MODE)
        return "recovery-mode";
    return NULL;
}

/**
 * fu_elan_ts_cmd_type_to_string:
 * @val: value, e.g. %FU_ELAN_TS_CMD_TYPE_WRITE_CMD
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_elan_ts_cmd_type_to_string(FuElanTsCmdType val)
{
    if (val == FU_ELAN_TS_CMD_TYPE_READ_CMD)
        return "read-cmd";
    if (val == FU_ELAN_TS_CMD_TYPE_WRITE_CMD)
        return "write-cmd";
    if (val == FU_ELAN_TS_CMD_TYPE_SHOW_BULK_ROM_DATA_CMD)
        return "show-bulk-rom-data-cmd";
    if (val == FU_ELAN_TS_CMD_TYPE_READ_ROM_DATA_CMD)
        return "read-rom-data-cmd";
    return NULL;
}

/**
 * fu_elan_ts_write_cmd_id_to_string:
 * @val: value, e.g. %FU_ELAN_TS_WRITE_CMD_ID_REK
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_elan_ts_write_cmd_id_to_string(FuElanTsWriteCmdId val)
{
    if (val == FU_ELAN_TS_WRITE_CMD_ID_ENTER_IAP)
        return "enter-iap";
    if (val == FU_ELAN_TS_WRITE_CMD_ID_REK)
        return "rek";
    if (val == FU_ELAN_TS_WRITE_CMD_ID_WRITE_FLASH_KEY)
        return "write-flash-key";
    return NULL;
}

/**
 * fu_elan_ts_rsp_type_to_string:
 * @val: value, e.g. %FU_ELAN_TS_RSP_TYPE_READ_ROM_CMD_RSP
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_elan_ts_rsp_type_to_string(FuElanTsRspType val)
{
    if (val == FU_ELAN_TS_RSP_TYPE_READ_CMD_RSP)
        return "read-cmd-rsp";
    if (val == FU_ELAN_TS_RSP_TYPE_READ_ROM_CMD_RSP)
        return "read-rom-cmd-rsp";
    if (val == FU_ELAN_TS_RSP_TYPE_SHOW_BULK_ROM_DATA_CMD_RSP)
        return "show-bulk-rom-data-cmd-rsp";
    return NULL;
}

/**
 * fu_elan_ts_read_cmd_id_to_string:
 * @val: value, e.g. %FU_ELAN_TS_READ_CMD_ID_BOOT_CODE_VERSION
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_elan_ts_read_cmd_id_to_string(FuElanTsReadCmdId val)
{
    if (val == FU_ELAN_TS_READ_CMD_ID_FW_VERSION)
        return "fw-version";
    if (val == FU_ELAN_TS_READ_CMD_ID_BOOT_CODE_VERSION)
        return "boot-code-version";
    if (val == FU_ELAN_TS_READ_CMD_ID_TEST_SOLUTION_VERSION)
        return "test-solution-version";
    if (val == FU_ELAN_TS_READ_CMD_ID_FW_ID)
        return "fw-id";
    return NULL;
}

/**
 * fu_elan_ts_read_rom_cmd_mode_to_string:
 * @val: value, e.g. %FU_ELAN_TS_READ_ROM_CMD_MODE_EKTH63XX_73XX
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_elan_ts_read_rom_cmd_mode_to_string(FuElanTsReadRomCmdMode val)
{
    if (val == FU_ELAN_TS_READ_ROM_CMD_MODE_EKTH53XX)
        return "ekth53xx";
    if (val == FU_ELAN_TS_READ_ROM_CMD_MODE_EKTH63XX_73XX)
        return "ekth63xx-73xx";
    return NULL;
}

/**
 * fu_elan_ts_show_bulk_rom_mode_to_string:
 * @val: value, e.g. %FU_ELAN_TS_SHOW_BULK_ROM_MODE_MAIN_CODE
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_elan_ts_show_bulk_rom_mode_to_string(FuElanTsShowBulkRomMode val)
{
    if (val == FU_ELAN_TS_SHOW_BULK_ROM_MODE_BOOT_CODE)
        return "boot-code";
    if (val == FU_ELAN_TS_SHOW_BULK_ROM_MODE_MAIN_CODE)
        return "main-code";
    return NULL;
}
/**
 * fu_struct_elan_ts_info_page_ref: (skip):
 **/
FuStructElanTsInfoPage *
fu_struct_elan_ts_info_page_ref(FuStructElanTsInfoPage *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_info_page_unref: (skip):
 **/
void
fu_struct_elan_ts_info_page_unref(FuStructElanTsInfoPage *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsInfoPage refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_info_page_new_internal: (skip):
 **/
static FuStructElanTsInfoPage *
fu_struct_elan_ts_info_page_new_internal(void)
{
    FuStructElanTsInfoPage *st = g_new0(FuStructElanTsInfoPage, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_info_page_get_update_counter: (skip):
 **/
guint16
fu_struct_elan_ts_info_page_get_update_counter(const FuStructElanTsInfoPage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 64, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_elan_ts_info_page_get_update_year: (skip):
 **/
guint16
fu_struct_elan_ts_info_page_get_update_year(const FuStructElanTsInfoPage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 66, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_elan_ts_info_page_get_update_month: (skip):
 **/
guint8
fu_struct_elan_ts_info_page_get_update_month(const FuStructElanTsInfoPage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[68];
}
/**
 * fu_struct_elan_ts_info_page_get_update_day: (skip):
 **/
guint8
fu_struct_elan_ts_info_page_get_update_day(const FuStructElanTsInfoPage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[69];
}
/**
 * fu_struct_elan_ts_info_page_get_update_hour: (skip):
 **/
guint8
fu_struct_elan_ts_info_page_get_update_hour(const FuStructElanTsInfoPage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[70];
}
/**
 * fu_struct_elan_ts_info_page_get_update_minute: (skip):
 **/
guint8
fu_struct_elan_ts_info_page_get_update_minute(const FuStructElanTsInfoPage *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[71];
}

/* setters */
/**
 * fu_struct_elan_ts_info_page_set_update_counter: (skip):
 **/
void
fu_struct_elan_ts_info_page_set_update_counter(FuStructElanTsInfoPage *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 64, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_elan_ts_info_page_set_update_year: (skip):
 **/
void
fu_struct_elan_ts_info_page_set_update_year(FuStructElanTsInfoPage *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 66, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_elan_ts_info_page_set_update_month: (skip):
 **/
void
fu_struct_elan_ts_info_page_set_update_month(FuStructElanTsInfoPage *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[68] = value;
}
/**
 * fu_struct_elan_ts_info_page_set_update_day: (skip):
 **/
void
fu_struct_elan_ts_info_page_set_update_day(FuStructElanTsInfoPage *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[69] = value;
}
/**
 * fu_struct_elan_ts_info_page_set_update_hour: (skip):
 **/
void
fu_struct_elan_ts_info_page_set_update_hour(FuStructElanTsInfoPage *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[70] = value;
}
/**
 * fu_struct_elan_ts_info_page_set_update_minute: (skip):
 **/
void
fu_struct_elan_ts_info_page_set_update_minute(FuStructElanTsInfoPage *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[71] = value;
}
/**
 * fu_struct_elan_ts_info_page_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_info_page_to_string(const FuStructElanTsInfoPage *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsInfoPage:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  update_counter: 0x%x\n",
                           (guint) fu_struct_elan_ts_info_page_get_update_counter(st));
    g_string_append_printf(str, "  update_year: 0x%x\n",
                           (guint) fu_struct_elan_ts_info_page_get_update_year(st));
    g_string_append_printf(str, "  update_month: 0x%x\n",
                           (guint) fu_struct_elan_ts_info_page_get_update_month(st));
    g_string_append_printf(str, "  update_day: 0x%x\n",
                           (guint) fu_struct_elan_ts_info_page_get_update_day(st));
    g_string_append_printf(str, "  update_hour: 0x%x\n",
                           (guint) fu_struct_elan_ts_info_page_get_update_hour(st));
    g_string_append_printf(str, "  update_minute: 0x%x\n",
                           (guint) fu_struct_elan_ts_info_page_get_update_minute(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_info_page_parse_internal(FuStructElanTsInfoPage *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_info_page_to_string(st);
        g_debug("%s", str);
    }
    return TRUE;
}

/**
 * fu_struct_elan_ts_info_page_parse: (skip):
 **/
FuStructElanTsInfoPage *
fu_struct_elan_ts_info_page_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsInfoPage) st = fu_struct_elan_ts_info_page_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 128, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsInfoPage: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 128);
    if (!fu_struct_elan_ts_info_page_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_fw_bin_header_lvfs_type1_ref: (skip):
 **/
FuStructElanTsFwBinHeaderLvfsType1 *
fu_struct_elan_ts_fw_bin_header_lvfs_type1_ref(FuStructElanTsFwBinHeaderLvfsType1 *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_fw_bin_header_lvfs_type1_unref: (skip):
 **/
void
fu_struct_elan_ts_fw_bin_header_lvfs_type1_unref(FuStructElanTsFwBinHeaderLvfsType1 *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsFwBinHeaderLvfsType1 refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_fw_bin_header_lvfs_type1_new_internal: (skip):
 **/
static FuStructElanTsFwBinHeaderLvfsType1 *
fu_struct_elan_ts_fw_bin_header_lvfs_type1_new_internal(void)
{
    FuStructElanTsFwBinHeaderLvfsType1 *st = g_new0(FuStructElanTsFwBinHeaderLvfsType1, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_fw_bin_header_guid: (skip):
 **/
static const fwupd_guid_t *
fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_fw_bin_header_guid(const FuStructElanTsFwBinHeaderLvfsType1 *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    return (const fwupd_guid_t *) (st->buf->data + 0);
}
/**
 * fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_fw_type: (skip):
 **/
FuElanTsFwType
fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_fw_type(const FuStructElanTsFwBinHeaderLvfsType1 *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[16];
}
/**
 * fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_debug: (skip):
 **/
guint32
fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_debug(const FuStructElanTsFwBinHeaderLvfsType1 *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 17, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_security_code: (skip):
 **/
const guint8 *
fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_security_code(const FuStructElanTsFwBinHeaderLvfsType1 *st, gsize *bufsz)
{
    g_return_val_if_fail(st != NULL, NULL);
    if (bufsz != NULL)
        *bufsz = 32;
    return st->buf->data + 21;
}
/**
 * fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_bin_size: (skip):
 **/
guint32
fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_bin_size(const FuStructElanTsFwBinHeaderLvfsType1 *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 53, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_elan_ts_fw_bin_header_lvfs_type1_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_fw_bin_header_lvfs_type1_to_string(const FuStructElanTsFwBinHeaderLvfsType1 *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsFwBinHeaderLvfsType1:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        g_autofree gchar *tmp = fwupd_guid_to_string(fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_fw_bin_header_guid(st), FWUPD_GUID_FLAG_MIXED_ENDIAN);
        g_string_append_printf(str, "  fw_bin_header_guid: %s\n", tmp);
    }
    {
        const gchar *tmp = fu_elan_ts_fw_type_to_string(fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_fw_type(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  fw_type: 0x%x [%s]\n", (guint) fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_fw_type(st), tmp);
        } else {
            g_string_append_printf(str, "  fw_type: 0x%x\n", (guint) fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_fw_type(st));
        }
    }
    g_string_append_printf(str, "  debug: 0x%x\n",
                           (guint) fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_debug(st));
    {
        gsize bufsz = 0;
        const guint8 *buf = fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_security_code(st, &bufsz);
        g_autoptr(GString) tmp = g_string_new(NULL);
        for (gsize i = 0; i < bufsz; i++)
            g_string_append_printf(tmp, "%02X", buf[i]);
        g_string_append_printf(str, "  security_code: 0x%s\n", tmp->str);
    }
    g_string_append_printf(str, "  bin_size: 0x%x\n",
                           (guint) fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_bin_size(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_fw_bin_header_lvfs_type1_validate_internal(FuStructElanTsFwBinHeaderLvfsType1 *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (memcmp(fu_struct_elan_ts_fw_bin_header_lvfs_type1_get_fw_bin_header_guid(st), "\x10\xe2\x8d\x99\x81\x19\xbf\x4e\x87\x4f\x27\xbd\x6c\x26\x44\x84", 16) != 0) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructElanTsFwBinHeaderLvfsType1.fw_bin_header_guid was not valid");
        return FALSE;
    }
    return TRUE;
}
/**
 * fu_struct_elan_ts_fw_bin_header_lvfs_type1_validate_stream: (skip):
 **/
gboolean
fu_struct_elan_ts_fw_bin_header_lvfs_type1_validate_stream(FuInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsFwBinHeaderLvfsType1) st = fu_struct_elan_ts_fw_bin_header_lvfs_type1_new_internal();
    g_return_val_if_fail(FU_IS_INPUT_STREAM(stream), FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
    st->buf = fu_input_stream_read_byte_array(stream, offset, 1081, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructElanTsFwBinHeaderLvfsType1 failed read of 0x%x: ", (guint) 1081);
        return FALSE;
    }
    if (st->buf->len != 1081) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructElanTsFwBinHeaderLvfsType1 requested 0x%x and got 0x%x",
                    (guint) 1081,
                    (guint) st->buf->len);
        return FALSE;
    }
    return fu_struct_elan_ts_fw_bin_header_lvfs_type1_validate_internal(st, error);
}
static gboolean
fu_struct_elan_ts_fw_bin_header_lvfs_type1_parse_internal(FuStructElanTsFwBinHeaderLvfsType1 *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_fw_bin_header_lvfs_type1_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_elan_ts_fw_bin_header_lvfs_type1_validate_internal(st, error))
        return FALSE;
    return TRUE;
}
/**
 * fu_struct_elan_ts_fw_bin_header_lvfs_type1_parse_stream: (skip):
 **/
FuStructElanTsFwBinHeaderLvfsType1 *
fu_struct_elan_ts_fw_bin_header_lvfs_type1_parse_stream(FuInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsFwBinHeaderLvfsType1) st = fu_struct_elan_ts_fw_bin_header_lvfs_type1_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 1081, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructElanTsFwBinHeaderLvfsType1 failed read of 0x%x: ", (guint) 1081);
        return NULL;
    }
    if (st->buf->len != 1081) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructElanTsFwBinHeaderLvfsType1 requested 0x%x and got 0x%x",
                    (guint) 1081,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_elan_ts_fw_bin_header_lvfs_type1_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_input_report_ref: (skip):
 **/
FuStructElanTsInputReport *
fu_struct_elan_ts_input_report_ref(FuStructElanTsInputReport *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_input_report_unref: (skip):
 **/
void
fu_struct_elan_ts_input_report_unref(FuStructElanTsInputReport *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsInputReport refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_input_report_new_internal: (skip):
 **/
static FuStructElanTsInputReport *
fu_struct_elan_ts_input_report_new_internal(void)
{
    FuStructElanTsInputReport *st = g_new0(FuStructElanTsInputReport, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_input_report_get_report_id: (skip):
 **/
FuElanTsReportId
fu_struct_elan_ts_input_report_get_report_id(const FuStructElanTsInputReport *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_elan_ts_input_report_get_data_len: (skip):
 **/
guint8
fu_struct_elan_ts_input_report_get_data_len(const FuStructElanTsInputReport *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_elan_ts_input_report_get_payload: (skip):
 **/
const guint8 *
fu_struct_elan_ts_input_report_get_payload(const FuStructElanTsInputReport *st, gsize *bufsz)
{
    g_return_val_if_fail(st != NULL, NULL);
    if (bufsz != NULL)
        *bufsz = 63;
    return st->buf->data + 2;
}

/* setters */
/**
 * fu_struct_elan_ts_input_report_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_input_report_to_string(const FuStructElanTsInputReport *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsInputReport:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_elan_ts_report_id_to_string(fu_struct_elan_ts_input_report_get_report_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  report_id: 0x%x [%s]\n", (guint) fu_struct_elan_ts_input_report_get_report_id(st), tmp);
        } else {
            g_string_append_printf(str, "  report_id: 0x%x\n", (guint) fu_struct_elan_ts_input_report_get_report_id(st));
        }
    }
    g_string_append_printf(str, "  data_len: 0x%x\n",
                           (guint) fu_struct_elan_ts_input_report_get_data_len(st));
    {
        gsize bufsz = 0;
        const guint8 *buf = fu_struct_elan_ts_input_report_get_payload(st, &bufsz);
        g_autoptr(GString) tmp = g_string_new(NULL);
        for (gsize i = 0; i < bufsz; i++)
            g_string_append_printf(tmp, "%02X", buf[i]);
        g_string_append_printf(str, "  payload: 0x%s\n", tmp->str);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_input_report_parse_internal(FuStructElanTsInputReport *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_input_report_to_string(st);
        g_debug("%s", str);
    }
    return TRUE;
}

/**
 * fu_struct_elan_ts_input_report_parse: (skip):
 **/
FuStructElanTsInputReport *
fu_struct_elan_ts_input_report_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsInputReport) st = fu_struct_elan_ts_input_report_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 65, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsInputReport: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 65);
    if (!fu_struct_elan_ts_input_report_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_hid_write_frame_data_ref: (skip):
 **/
FuStructElanTsHidWriteFrameData *
fu_struct_elan_ts_hid_write_frame_data_ref(FuStructElanTsHidWriteFrameData *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_hid_write_frame_data_unref: (skip):
 **/
void
fu_struct_elan_ts_hid_write_frame_data_unref(FuStructElanTsHidWriteFrameData *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsHidWriteFrameData refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_hid_write_frame_data_new_internal: (skip):
 **/
static FuStructElanTsHidWriteFrameData *
fu_struct_elan_ts_hid_write_frame_data_new_internal(void)
{
    FuStructElanTsHidWriteFrameData *st = g_new0(FuStructElanTsHidWriteFrameData, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_hid_write_frame_data_set_report_id: (skip):
 **/
static void
fu_struct_elan_ts_hid_write_frame_data_set_report_id(FuStructElanTsHidWriteFrameData *st, FuElanTsReportId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_hid_write_frame_data_set_subcommand: (skip):
 **/
static void
fu_struct_elan_ts_hid_write_frame_data_set_subcommand(FuStructElanTsHidWriteFrameData *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_hid_write_frame_data_set_offset: (skip):
 **/
void
fu_struct_elan_ts_hid_write_frame_data_set_offset(FuStructElanTsHidWriteFrameData *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_hid_write_frame_data_set_data_len: (skip):
 **/
void
fu_struct_elan_ts_hid_write_frame_data_set_data_len(FuStructElanTsHidWriteFrameData *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_elan_ts_hid_write_frame_data_new: (skip):
 **/
FuStructElanTsHidWriteFrameData *
fu_struct_elan_ts_hid_write_frame_data_new(void)
{
    FuStructElanTsHidWriteFrameData *st = fu_struct_elan_ts_hid_write_frame_data_new_internal();
    st->buf = g_byte_array_sized_new(5);
    fu_byte_array_set_size(st->buf, 5, 0x0);
    fu_struct_elan_ts_hid_write_frame_data_set_report_id(st, FU_ELAN_TS_REPORT_ID_OUTPUT);
    fu_struct_elan_ts_hid_write_frame_data_set_subcommand(st, 0x21);
    return st;
}
/**
 * fu_struct_elan_ts_hid_write_command_ref: (skip):
 **/
FuStructElanTsHidWriteCommand *
fu_struct_elan_ts_hid_write_command_ref(FuStructElanTsHidWriteCommand *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_hid_write_command_unref: (skip):
 **/
void
fu_struct_elan_ts_hid_write_command_unref(FuStructElanTsHidWriteCommand *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsHidWriteCommand refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_hid_write_command_new_internal: (skip):
 **/
static FuStructElanTsHidWriteCommand *
fu_struct_elan_ts_hid_write_command_new_internal(void)
{
    FuStructElanTsHidWriteCommand *st = g_new0(FuStructElanTsHidWriteCommand, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_hid_write_command_set_report_id: (skip):
 **/
void
fu_struct_elan_ts_hid_write_command_set_report_id(FuStructElanTsHidWriteCommand *st, FuElanTsReportId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_hid_write_command_set_subcommand: (skip):
 **/
static void
fu_struct_elan_ts_hid_write_command_set_subcommand(FuStructElanTsHidWriteCommand *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_hid_write_command_set_data_len: (skip):
 **/
void
fu_struct_elan_ts_hid_write_command_set_data_len(FuStructElanTsHidWriteCommand *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_elan_ts_hid_write_command_new: (skip):
 **/
FuStructElanTsHidWriteCommand *
fu_struct_elan_ts_hid_write_command_new(void)
{
    FuStructElanTsHidWriteCommand *st = fu_struct_elan_ts_hid_write_command_new_internal();
    st->buf = g_byte_array_sized_new(3);
    fu_byte_array_set_size(st->buf, 3, 0x0);
    fu_struct_elan_ts_hid_write_command_set_report_id(st, FU_ELAN_TS_REPORT_ID_OUTPUT);
    fu_struct_elan_ts_hid_write_command_set_subcommand(st, 0x00);
    return st;
}
/**
 * fu_struct_elan_ts_vendor_cmd_ref: (skip):
 **/
FuStructElanTsVendorCmd *
fu_struct_elan_ts_vendor_cmd_ref(FuStructElanTsVendorCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_vendor_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_vendor_cmd_unref(FuStructElanTsVendorCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsVendorCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_vendor_cmd_new_internal: (skip):
 **/
static FuStructElanTsVendorCmd *
fu_struct_elan_ts_vendor_cmd_new_internal(void)
{
    FuStructElanTsVendorCmd *st = g_new0(FuStructElanTsVendorCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_vendor_cmd_set_report_id: (skip):
 **/
static void
fu_struct_elan_ts_vendor_cmd_set_report_id(FuStructElanTsVendorCmd *st, FuElanTsReportId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_vendor_cmd_set_cmd: (skip):
 **/
void
fu_struct_elan_ts_vendor_cmd_set_cmd(FuStructElanTsVendorCmd *st, FuElanTsVendorCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_vendor_cmd_new: (skip):
 **/
FuStructElanTsVendorCmd *
fu_struct_elan_ts_vendor_cmd_new(void)
{
    FuStructElanTsVendorCmd *st = fu_struct_elan_ts_vendor_cmd_new_internal();
    st->buf = g_byte_array_sized_new(2);
    fu_byte_array_set_size(st->buf, 2, 0x0);
    fu_struct_elan_ts_vendor_cmd_set_report_id(st, FU_ELAN_TS_REPORT_ID_OUTPUT);
    return st;
}
/**
 * fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_ref: (skip):
 **/
FuStructElanTsHelloPktAndBcVerRsp *
fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_ref(FuStructElanTsHelloPktAndBcVerRsp *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_unref: (skip):
 **/
void
fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_unref(FuStructElanTsHelloPktAndBcVerRsp *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsHelloPktAndBcVerRsp refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_new_internal: (skip):
 **/
static FuStructElanTsHelloPktAndBcVerRsp *
fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_new_internal(void)
{
    FuStructElanTsHelloPktAndBcVerRsp *st = g_new0(FuStructElanTsHelloPktAndBcVerRsp, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_get_hello_packet: (skip):
 **/
FuElanTsHelloPacket
fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_get_hello_packet(const FuStructElanTsHelloPktAndBcVerRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_get_bc_version: (skip):
 **/
guint16
fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_get_bc_version(const FuStructElanTsHelloPktAndBcVerRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_to_string(const FuStructElanTsHelloPktAndBcVerRsp *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsHelloPktAndBcVerRsp:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_elan_ts_hello_packet_to_string(fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_get_hello_packet(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  hello_packet: 0x%x [%s]\n", (guint) fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_get_hello_packet(st), tmp);
        } else {
            g_string_append_printf(str, "  hello_packet: 0x%x\n", (guint) fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_get_hello_packet(st));
        }
    }
    g_string_append_printf(str, "  bc_version: 0x%x\n",
                           (guint) fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_get_bc_version(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_parse_internal(FuStructElanTsHelloPktAndBcVerRsp *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_to_string(st);
        g_debug("%s", str);
    }
    return TRUE;
}

/**
 * fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_parse: (skip):
 **/
static FuStructElanTsHelloPktAndBcVerRsp *
fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsHelloPktAndBcVerRsp) st = fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsHelloPktAndBcVerRsp: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_parse_bytes: (skip):
 **/
FuStructElanTsHelloPktAndBcVerRsp *
fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_elan_ts_hello_pkt_and_bc_ver_rsp_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_elan_ts_flash_write_rsp_ref: (skip):
 **/
FuStructElanTsFlashWriteRsp *
fu_struct_elan_ts_flash_write_rsp_ref(FuStructElanTsFlashWriteRsp *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_flash_write_rsp_unref: (skip):
 **/
void
fu_struct_elan_ts_flash_write_rsp_unref(FuStructElanTsFlashWriteRsp *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsFlashWriteRsp refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_flash_write_rsp_new_internal: (skip):
 **/
static FuStructElanTsFlashWriteRsp *
fu_struct_elan_ts_flash_write_rsp_new_internal(void)
{
    FuStructElanTsFlashWriteRsp *st = g_new0(FuStructElanTsFlashWriteRsp, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_flash_write_rsp_get_payload: (skip):
 **/
static guint16
fu_struct_elan_ts_flash_write_rsp_get_payload(const FuStructElanTsFlashWriteRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_elan_ts_flash_write_rsp_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_flash_write_rsp_to_string(const FuStructElanTsFlashWriteRsp *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsFlashWriteRsp:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  payload: 0x%x\n",
                           (guint) fu_struct_elan_ts_flash_write_rsp_get_payload(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_flash_write_rsp_validate_internal(FuStructElanTsFlashWriteRsp *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_elan_ts_flash_write_rsp_get_payload(st) != 0xAAAA) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructElanTsFlashWriteRsp.payload was not valid, "
                    "expected 0x%x and got 0x%x",
                    (guint) 0xAAAA,
                    (guint) fu_struct_elan_ts_flash_write_rsp_get_payload(st));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_elan_ts_flash_write_rsp_parse_internal(FuStructElanTsFlashWriteRsp *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_flash_write_rsp_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_elan_ts_flash_write_rsp_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_elan_ts_flash_write_rsp_parse: (skip):
 **/
static FuStructElanTsFlashWriteRsp *
fu_struct_elan_ts_flash_write_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsFlashWriteRsp) st = fu_struct_elan_ts_flash_write_rsp_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 2, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsFlashWriteRsp: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 2);
    if (!fu_struct_elan_ts_flash_write_rsp_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_flash_write_rsp_parse_bytes: (skip):
 **/
FuStructElanTsFlashWriteRsp *
fu_struct_elan_ts_flash_write_rsp_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_elan_ts_flash_write_rsp_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_elan_ts_i2c_addr_cmd_ref: (skip):
 **/
FuStructElanTsI2cAddrCmd *
fu_struct_elan_ts_i2c_addr_cmd_ref(FuStructElanTsI2cAddrCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_i2c_addr_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_i2c_addr_cmd_unref(FuStructElanTsI2cAddrCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsI2cAddrCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_i2c_addr_cmd_new_internal: (skip):
 **/
static FuStructElanTsI2cAddrCmd *
fu_struct_elan_ts_i2c_addr_cmd_new_internal(void)
{
    FuStructElanTsI2cAddrCmd *st = g_new0(FuStructElanTsI2cAddrCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_i2c_addr_cmd_set_addr_7bit: (skip):
 **/
static void
fu_struct_elan_ts_i2c_addr_cmd_set_addr_7bit(FuStructElanTsI2cAddrCmd *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_i2c_addr_cmd_new: (skip):
 **/
FuStructElanTsI2cAddrCmd *
fu_struct_elan_ts_i2c_addr_cmd_new(void)
{
    FuStructElanTsI2cAddrCmd *st = fu_struct_elan_ts_i2c_addr_cmd_new_internal();
    st->buf = g_byte_array_sized_new(1);
    fu_byte_array_set_size(st->buf, 1, 0x0);
    fu_struct_elan_ts_i2c_addr_cmd_set_addr_7bit(st, 0x10);
    return st;
}
/**
 * fu_struct_elan_ts_i2c_addr_rsp_ref: (skip):
 **/
FuStructElanTsI2cAddrRsp *
fu_struct_elan_ts_i2c_addr_rsp_ref(FuStructElanTsI2cAddrRsp *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_i2c_addr_rsp_unref: (skip):
 **/
void
fu_struct_elan_ts_i2c_addr_rsp_unref(FuStructElanTsI2cAddrRsp *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsI2cAddrRsp refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_i2c_addr_rsp_new_internal: (skip):
 **/
static FuStructElanTsI2cAddrRsp *
fu_struct_elan_ts_i2c_addr_rsp_new_internal(void)
{
    FuStructElanTsI2cAddrRsp *st = g_new0(FuStructElanTsI2cAddrRsp, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_i2c_addr_rsp_get_addr_8bit: (skip):
 **/
static guint8
fu_struct_elan_ts_i2c_addr_rsp_get_addr_8bit(const FuStructElanTsI2cAddrRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}

/* setters */
/**
 * fu_struct_elan_ts_i2c_addr_rsp_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_i2c_addr_rsp_to_string(const FuStructElanTsI2cAddrRsp *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsI2cAddrRsp:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  addr_8bit: 0x%x\n",
                           (guint) fu_struct_elan_ts_i2c_addr_rsp_get_addr_8bit(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_i2c_addr_rsp_validate_internal(FuStructElanTsI2cAddrRsp *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_elan_ts_i2c_addr_rsp_get_addr_8bit(st) != 0x20) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructElanTsI2cAddrRsp.addr_8bit was not valid");
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_elan_ts_i2c_addr_rsp_parse_internal(FuStructElanTsI2cAddrRsp *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_i2c_addr_rsp_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_elan_ts_i2c_addr_rsp_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_elan_ts_i2c_addr_rsp_parse: (skip):
 **/
static FuStructElanTsI2cAddrRsp *
fu_struct_elan_ts_i2c_addr_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsI2cAddrRsp) st = fu_struct_elan_ts_i2c_addr_rsp_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 1, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsI2cAddrRsp: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 1);
    if (!fu_struct_elan_ts_i2c_addr_rsp_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_i2c_addr_rsp_parse_bytes: (skip):
 **/
FuStructElanTsI2cAddrRsp *
fu_struct_elan_ts_i2c_addr_rsp_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_elan_ts_i2c_addr_rsp_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_elan_ts_write_cmd_ref: (skip):
 **/
FuStructElanTsWriteCmd *
fu_struct_elan_ts_write_cmd_ref(FuStructElanTsWriteCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_write_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_write_cmd_unref(FuStructElanTsWriteCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsWriteCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_write_cmd_new_internal: (skip):
 **/
static FuStructElanTsWriteCmd *
fu_struct_elan_ts_write_cmd_new_internal(void)
{
    FuStructElanTsWriteCmd *st = g_new0(FuStructElanTsWriteCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_write_cmd_set_cmd_type: (skip):
 **/
static void
fu_struct_elan_ts_write_cmd_set_cmd_type(FuStructElanTsWriteCmd *st, FuElanTsCmdType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_write_cmd_set_cmd_id: (skip):
 **/
void
fu_struct_elan_ts_write_cmd_set_cmd_id(FuStructElanTsWriteCmd *st, FuElanTsWriteCmdId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_write_cmd_set_payload: (skip):
 **/
static void
fu_struct_elan_ts_write_cmd_set_payload(FuStructElanTsWriteCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_write_cmd_new: (skip):
 **/
FuStructElanTsWriteCmd *
fu_struct_elan_ts_write_cmd_new(void)
{
    FuStructElanTsWriteCmd *st = fu_struct_elan_ts_write_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_elan_ts_write_cmd_set_cmd_type(st, FU_ELAN_TS_CMD_TYPE_WRITE_CMD);
    fu_struct_elan_ts_write_cmd_set_payload(st, 0x0001);
    return st;
}
/**
 * fu_struct_elan_ts_read_cmd_ref: (skip):
 **/
FuStructElanTsReadCmd *
fu_struct_elan_ts_read_cmd_ref(FuStructElanTsReadCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_read_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_read_cmd_unref(FuStructElanTsReadCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsReadCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_read_cmd_new_internal: (skip):
 **/
static FuStructElanTsReadCmd *
fu_struct_elan_ts_read_cmd_new_internal(void)
{
    FuStructElanTsReadCmd *st = g_new0(FuStructElanTsReadCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_read_cmd_set_cmd_type: (skip):
 **/
static void
fu_struct_elan_ts_read_cmd_set_cmd_type(FuStructElanTsReadCmd *st, FuElanTsCmdType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_read_cmd_set_cmd_id: (skip):
 **/
void
fu_struct_elan_ts_read_cmd_set_cmd_id(FuStructElanTsReadCmd *st, FuElanTsReadCmdId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_read_cmd_set_payload: (skip):
 **/
static void
fu_struct_elan_ts_read_cmd_set_payload(FuStructElanTsReadCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_read_cmd_new: (skip):
 **/
FuStructElanTsReadCmd *
fu_struct_elan_ts_read_cmd_new(void)
{
    FuStructElanTsReadCmd *st = fu_struct_elan_ts_read_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_elan_ts_read_cmd_set_cmd_type(st, FU_ELAN_TS_CMD_TYPE_READ_CMD);
    fu_struct_elan_ts_read_cmd_set_payload(st, 0x0001);
    return st;
}
/**
 * fu_struct_elan_ts_enter_iap_cmd_ref: (skip):
 **/
FuStructElanTsEnterIapCmd *
fu_struct_elan_ts_enter_iap_cmd_ref(FuStructElanTsEnterIapCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_enter_iap_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_enter_iap_cmd_unref(FuStructElanTsEnterIapCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsEnterIapCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_enter_iap_cmd_new_internal: (skip):
 **/
static FuStructElanTsEnterIapCmd *
fu_struct_elan_ts_enter_iap_cmd_new_internal(void)
{
    FuStructElanTsEnterIapCmd *st = g_new0(FuStructElanTsEnterIapCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_enter_iap_cmd_set_cmd_type: (skip):
 **/
static void
fu_struct_elan_ts_enter_iap_cmd_set_cmd_type(FuStructElanTsEnterIapCmd *st, FuElanTsCmdType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_enter_iap_cmd_set_cmd_id: (skip):
 **/
static void
fu_struct_elan_ts_enter_iap_cmd_set_cmd_id(FuStructElanTsEnterIapCmd *st, FuElanTsWriteCmdId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_enter_iap_cmd_set_payload: (skip):
 **/
static void
fu_struct_elan_ts_enter_iap_cmd_set_payload(FuStructElanTsEnterIapCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_enter_iap_cmd_new: (skip):
 **/
FuStructElanTsEnterIapCmd *
fu_struct_elan_ts_enter_iap_cmd_new(void)
{
    FuStructElanTsEnterIapCmd *st = fu_struct_elan_ts_enter_iap_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_elan_ts_enter_iap_cmd_set_cmd_type(st, FU_ELAN_TS_CMD_TYPE_WRITE_CMD);
    fu_struct_elan_ts_enter_iap_cmd_set_cmd_id(st, FU_ELAN_TS_WRITE_CMD_ID_ENTER_IAP);
    fu_struct_elan_ts_enter_iap_cmd_set_payload(st, 0x1234);
    return st;
}
/**
 * fu_struct_elan_ts_write_flash_key_cmd_ref: (skip):
 **/
FuStructElanTsWriteFlashKeyCmd *
fu_struct_elan_ts_write_flash_key_cmd_ref(FuStructElanTsWriteFlashKeyCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_write_flash_key_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_write_flash_key_cmd_unref(FuStructElanTsWriteFlashKeyCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsWriteFlashKeyCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_write_flash_key_cmd_new_internal: (skip):
 **/
static FuStructElanTsWriteFlashKeyCmd *
fu_struct_elan_ts_write_flash_key_cmd_new_internal(void)
{
    FuStructElanTsWriteFlashKeyCmd *st = g_new0(FuStructElanTsWriteFlashKeyCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_write_flash_key_cmd_set_cmd_type: (skip):
 **/
static void
fu_struct_elan_ts_write_flash_key_cmd_set_cmd_type(FuStructElanTsWriteFlashKeyCmd *st, FuElanTsCmdType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_write_flash_key_cmd_set_cmd_id: (skip):
 **/
static void
fu_struct_elan_ts_write_flash_key_cmd_set_cmd_id(FuStructElanTsWriteFlashKeyCmd *st, FuElanTsWriteCmdId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_write_flash_key_cmd_set_payload: (skip):
 **/
static void
fu_struct_elan_ts_write_flash_key_cmd_set_payload(FuStructElanTsWriteFlashKeyCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_write_flash_key_cmd_new: (skip):
 **/
FuStructElanTsWriteFlashKeyCmd *
fu_struct_elan_ts_write_flash_key_cmd_new(void)
{
    FuStructElanTsWriteFlashKeyCmd *st = fu_struct_elan_ts_write_flash_key_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_elan_ts_write_flash_key_cmd_set_cmd_type(st, FU_ELAN_TS_CMD_TYPE_WRITE_CMD);
    fu_struct_elan_ts_write_flash_key_cmd_set_cmd_id(st, FU_ELAN_TS_WRITE_CMD_ID_WRITE_FLASH_KEY);
    fu_struct_elan_ts_write_flash_key_cmd_set_payload(st, 0xE15A);
    return st;
}
/**
 * fu_struct_elan_ts_rek_cmd_ref: (skip):
 **/
FuStructElanTsRekCmd *
fu_struct_elan_ts_rek_cmd_ref(FuStructElanTsRekCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_rek_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_rek_cmd_unref(FuStructElanTsRekCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsRekCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_rek_cmd_new_internal: (skip):
 **/
static FuStructElanTsRekCmd *
fu_struct_elan_ts_rek_cmd_new_internal(void)
{
    FuStructElanTsRekCmd *st = g_new0(FuStructElanTsRekCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_rek_cmd_set_cmd_type: (skip):
 **/
static void
fu_struct_elan_ts_rek_cmd_set_cmd_type(FuStructElanTsRekCmd *st, FuElanTsCmdType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_rek_cmd_set_cmd_id: (skip):
 **/
static void
fu_struct_elan_ts_rek_cmd_set_cmd_id(FuStructElanTsRekCmd *st, FuElanTsWriteCmdId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_rek_cmd_set_payload: (skip):
 **/
static void
fu_struct_elan_ts_rek_cmd_set_payload(FuStructElanTsRekCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_rek_cmd_new: (skip):
 **/
FuStructElanTsRekCmd *
fu_struct_elan_ts_rek_cmd_new(void)
{
    FuStructElanTsRekCmd *st = fu_struct_elan_ts_rek_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_elan_ts_rek_cmd_set_cmd_type(st, FU_ELAN_TS_CMD_TYPE_WRITE_CMD);
    fu_struct_elan_ts_rek_cmd_set_cmd_id(st, FU_ELAN_TS_WRITE_CMD_ID_REK);
    fu_struct_elan_ts_rek_cmd_set_payload(st, 0x0001);
    return st;
}
/**
 * fu_struct_elan_ts_calibration_rsp_ref: (skip):
 **/
FuStructElanTsCalibrationRsp *
fu_struct_elan_ts_calibration_rsp_ref(FuStructElanTsCalibrationRsp *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_calibration_rsp_unref: (skip):
 **/
void
fu_struct_elan_ts_calibration_rsp_unref(FuStructElanTsCalibrationRsp *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsCalibrationRsp refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_calibration_rsp_new_internal: (skip):
 **/
static FuStructElanTsCalibrationRsp *
fu_struct_elan_ts_calibration_rsp_new_internal(void)
{
    FuStructElanTsCalibrationRsp *st = g_new0(FuStructElanTsCalibrationRsp, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_calibration_rsp_get_payload: (skip):
 **/
static guint32
fu_struct_elan_ts_calibration_rsp_get_payload(const FuStructElanTsCalibrationRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 0, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_elan_ts_calibration_rsp_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_calibration_rsp_to_string(const FuStructElanTsCalibrationRsp *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsCalibrationRsp:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  payload: 0x%x\n",
                           (guint) fu_struct_elan_ts_calibration_rsp_get_payload(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_calibration_rsp_validate_internal(FuStructElanTsCalibrationRsp *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_elan_ts_calibration_rsp_get_payload(st) != 0x66666666) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructElanTsCalibrationRsp.payload was not valid, "
                    "expected 0x%x and got 0x%x",
                    (guint) 0x66666666,
                    (guint) fu_struct_elan_ts_calibration_rsp_get_payload(st));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_elan_ts_calibration_rsp_parse_internal(FuStructElanTsCalibrationRsp *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_calibration_rsp_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_elan_ts_calibration_rsp_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_elan_ts_calibration_rsp_parse: (skip):
 **/
static FuStructElanTsCalibrationRsp *
fu_struct_elan_ts_calibration_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsCalibrationRsp) st = fu_struct_elan_ts_calibration_rsp_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsCalibrationRsp: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_struct_elan_ts_calibration_rsp_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_calibration_rsp_parse_bytes: (skip):
 **/
FuStructElanTsCalibrationRsp *
fu_struct_elan_ts_calibration_rsp_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_elan_ts_calibration_rsp_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_elan_ts_bc_version_cmd_ref: (skip):
 **/
FuStructElanTsBcVersionCmd *
fu_struct_elan_ts_bc_version_cmd_ref(FuStructElanTsBcVersionCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_bc_version_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_bc_version_cmd_unref(FuStructElanTsBcVersionCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsBcVersionCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_bc_version_cmd_new_internal: (skip):
 **/
static FuStructElanTsBcVersionCmd *
fu_struct_elan_ts_bc_version_cmd_new_internal(void)
{
    FuStructElanTsBcVersionCmd *st = g_new0(FuStructElanTsBcVersionCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_bc_version_cmd_set_cmd_type: (skip):
 **/
static void
fu_struct_elan_ts_bc_version_cmd_set_cmd_type(FuStructElanTsBcVersionCmd *st, FuElanTsCmdType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_bc_version_cmd_set_cmd_id: (skip):
 **/
static void
fu_struct_elan_ts_bc_version_cmd_set_cmd_id(FuStructElanTsBcVersionCmd *st, FuElanTsReadCmdId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_bc_version_cmd_set_payload: (skip):
 **/
static void
fu_struct_elan_ts_bc_version_cmd_set_payload(FuStructElanTsBcVersionCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_bc_version_cmd_new: (skip):
 **/
FuStructElanTsBcVersionCmd *
fu_struct_elan_ts_bc_version_cmd_new(void)
{
    FuStructElanTsBcVersionCmd *st = fu_struct_elan_ts_bc_version_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_elan_ts_bc_version_cmd_set_cmd_type(st, FU_ELAN_TS_CMD_TYPE_READ_CMD);
    fu_struct_elan_ts_bc_version_cmd_set_cmd_id(st, FU_ELAN_TS_READ_CMD_ID_BOOT_CODE_VERSION);
    fu_struct_elan_ts_bc_version_cmd_set_payload(st, 0x0001);
    return st;
}
/**
 * fu_struct_elan_ts_bc_version_rsp_ref: (skip):
 **/
FuStructElanTsBcVersionRsp *
fu_struct_elan_ts_bc_version_rsp_ref(FuStructElanTsBcVersionRsp *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_bc_version_rsp_unref: (skip):
 **/
void
fu_struct_elan_ts_bc_version_rsp_unref(FuStructElanTsBcVersionRsp *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsBcVersionRsp refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_bc_version_rsp_new_internal: (skip):
 **/
static FuStructElanTsBcVersionRsp *
fu_struct_elan_ts_bc_version_rsp_new_internal(void)
{
    FuStructElanTsBcVersionRsp *st = g_new0(FuStructElanTsBcVersionRsp, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_bc_version_rsp_get_rsp_type: (skip):
 **/
static FuElanTsRspType
fu_struct_elan_ts_bc_version_rsp_get_rsp_type(const FuStructElanTsBcVersionRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_elan_ts_bc_version_rsp_get_payload: (skip):
 **/
const guint8 *
fu_struct_elan_ts_bc_version_rsp_get_payload(const FuStructElanTsBcVersionRsp *st, gsize *bufsz)
{
    g_return_val_if_fail(st != NULL, NULL);
    if (bufsz != NULL)
        *bufsz = 3;
    return st->buf->data + 1;
}

/* setters */
/**
 * fu_struct_elan_ts_bc_version_rsp_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_bc_version_rsp_to_string(const FuStructElanTsBcVersionRsp *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsBcVersionRsp:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_bc_version_rsp_get_rsp_type(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  rsp_type: 0x%x [%s]\n", (guint) fu_struct_elan_ts_bc_version_rsp_get_rsp_type(st), tmp);
        } else {
            g_string_append_printf(str, "  rsp_type: 0x%x\n", (guint) fu_struct_elan_ts_bc_version_rsp_get_rsp_type(st));
        }
    }
    {
        gsize bufsz = 0;
        const guint8 *buf = fu_struct_elan_ts_bc_version_rsp_get_payload(st, &bufsz);
        g_autoptr(GString) tmp = g_string_new(NULL);
        for (gsize i = 0; i < bufsz; i++)
            g_string_append_printf(tmp, "%02X", buf[i]);
        g_string_append_printf(str, "  payload: 0x%s\n", tmp->str);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_bc_version_rsp_validate_internal(FuStructElanTsBcVersionRsp *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_elan_ts_bc_version_rsp_get_rsp_type(st) != FU_ELAN_TS_RSP_TYPE_READ_CMD_RSP) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructElanTsBcVersionRsp.rsp_type was not valid, "
                    "expected 'FU_ELAN_TS_RSP_TYPE_READ_CMD_RSP' and got 0x%x '%s'",
                    fu_struct_elan_ts_bc_version_rsp_get_rsp_type(st),
                    fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_bc_version_rsp_get_rsp_type(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_elan_ts_bc_version_rsp_parse_internal(FuStructElanTsBcVersionRsp *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_bc_version_rsp_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_elan_ts_bc_version_rsp_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_elan_ts_bc_version_rsp_parse: (skip):
 **/
static FuStructElanTsBcVersionRsp *
fu_struct_elan_ts_bc_version_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsBcVersionRsp) st = fu_struct_elan_ts_bc_version_rsp_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsBcVersionRsp: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_struct_elan_ts_bc_version_rsp_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_bc_version_rsp_parse_bytes: (skip):
 **/
FuStructElanTsBcVersionRsp *
fu_struct_elan_ts_bc_version_rsp_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_elan_ts_bc_version_rsp_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_elan_ts_fw_id_cmd_ref: (skip):
 **/
FuStructElanTsFwIdCmd *
fu_struct_elan_ts_fw_id_cmd_ref(FuStructElanTsFwIdCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_fw_id_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_fw_id_cmd_unref(FuStructElanTsFwIdCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsFwIdCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_fw_id_cmd_new_internal: (skip):
 **/
static FuStructElanTsFwIdCmd *
fu_struct_elan_ts_fw_id_cmd_new_internal(void)
{
    FuStructElanTsFwIdCmd *st = g_new0(FuStructElanTsFwIdCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_fw_id_cmd_set_cmd_type: (skip):
 **/
static void
fu_struct_elan_ts_fw_id_cmd_set_cmd_type(FuStructElanTsFwIdCmd *st, FuElanTsCmdType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_fw_id_cmd_set_cmd_id: (skip):
 **/
static void
fu_struct_elan_ts_fw_id_cmd_set_cmd_id(FuStructElanTsFwIdCmd *st, FuElanTsReadCmdId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_fw_id_cmd_set_payload: (skip):
 **/
static void
fu_struct_elan_ts_fw_id_cmd_set_payload(FuStructElanTsFwIdCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_fw_id_cmd_new: (skip):
 **/
FuStructElanTsFwIdCmd *
fu_struct_elan_ts_fw_id_cmd_new(void)
{
    FuStructElanTsFwIdCmd *st = fu_struct_elan_ts_fw_id_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_elan_ts_fw_id_cmd_set_cmd_type(st, FU_ELAN_TS_CMD_TYPE_READ_CMD);
    fu_struct_elan_ts_fw_id_cmd_set_cmd_id(st, FU_ELAN_TS_READ_CMD_ID_FW_ID);
    fu_struct_elan_ts_fw_id_cmd_set_payload(st, 0x0001);
    return st;
}
/**
 * fu_struct_elan_ts_fw_id_rsp_ref: (skip):
 **/
FuStructElanTsFwIdRsp *
fu_struct_elan_ts_fw_id_rsp_ref(FuStructElanTsFwIdRsp *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_fw_id_rsp_unref: (skip):
 **/
void
fu_struct_elan_ts_fw_id_rsp_unref(FuStructElanTsFwIdRsp *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsFwIdRsp refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_fw_id_rsp_new_internal: (skip):
 **/
static FuStructElanTsFwIdRsp *
fu_struct_elan_ts_fw_id_rsp_new_internal(void)
{
    FuStructElanTsFwIdRsp *st = g_new0(FuStructElanTsFwIdRsp, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_fw_id_rsp_get_rsp_type: (skip):
 **/
static FuElanTsRspType
fu_struct_elan_ts_fw_id_rsp_get_rsp_type(const FuStructElanTsFwIdRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_elan_ts_fw_id_rsp_get_payload: (skip):
 **/
const guint8 *
fu_struct_elan_ts_fw_id_rsp_get_payload(const FuStructElanTsFwIdRsp *st, gsize *bufsz)
{
    g_return_val_if_fail(st != NULL, NULL);
    if (bufsz != NULL)
        *bufsz = 3;
    return st->buf->data + 1;
}

/* setters */
/**
 * fu_struct_elan_ts_fw_id_rsp_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_fw_id_rsp_to_string(const FuStructElanTsFwIdRsp *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsFwIdRsp:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_fw_id_rsp_get_rsp_type(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  rsp_type: 0x%x [%s]\n", (guint) fu_struct_elan_ts_fw_id_rsp_get_rsp_type(st), tmp);
        } else {
            g_string_append_printf(str, "  rsp_type: 0x%x\n", (guint) fu_struct_elan_ts_fw_id_rsp_get_rsp_type(st));
        }
    }
    {
        gsize bufsz = 0;
        const guint8 *buf = fu_struct_elan_ts_fw_id_rsp_get_payload(st, &bufsz);
        g_autoptr(GString) tmp = g_string_new(NULL);
        for (gsize i = 0; i < bufsz; i++)
            g_string_append_printf(tmp, "%02X", buf[i]);
        g_string_append_printf(str, "  payload: 0x%s\n", tmp->str);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_fw_id_rsp_validate_internal(FuStructElanTsFwIdRsp *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_elan_ts_fw_id_rsp_get_rsp_type(st) != FU_ELAN_TS_RSP_TYPE_READ_CMD_RSP) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructElanTsFwIdRsp.rsp_type was not valid, "
                    "expected 'FU_ELAN_TS_RSP_TYPE_READ_CMD_RSP' and got 0x%x '%s'",
                    fu_struct_elan_ts_fw_id_rsp_get_rsp_type(st),
                    fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_fw_id_rsp_get_rsp_type(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_elan_ts_fw_id_rsp_parse_internal(FuStructElanTsFwIdRsp *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_fw_id_rsp_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_elan_ts_fw_id_rsp_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_elan_ts_fw_id_rsp_parse: (skip):
 **/
static FuStructElanTsFwIdRsp *
fu_struct_elan_ts_fw_id_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsFwIdRsp) st = fu_struct_elan_ts_fw_id_rsp_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsFwIdRsp: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_struct_elan_ts_fw_id_rsp_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_fw_id_rsp_parse_bytes: (skip):
 **/
FuStructElanTsFwIdRsp *
fu_struct_elan_ts_fw_id_rsp_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_elan_ts_fw_id_rsp_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_elan_ts_fw_version_cmd_ref: (skip):
 **/
FuStructElanTsFwVersionCmd *
fu_struct_elan_ts_fw_version_cmd_ref(FuStructElanTsFwVersionCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_fw_version_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_fw_version_cmd_unref(FuStructElanTsFwVersionCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsFwVersionCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_fw_version_cmd_new_internal: (skip):
 **/
static FuStructElanTsFwVersionCmd *
fu_struct_elan_ts_fw_version_cmd_new_internal(void)
{
    FuStructElanTsFwVersionCmd *st = g_new0(FuStructElanTsFwVersionCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_fw_version_cmd_set_cmd_type: (skip):
 **/
static void
fu_struct_elan_ts_fw_version_cmd_set_cmd_type(FuStructElanTsFwVersionCmd *st, FuElanTsCmdType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_fw_version_cmd_set_cmd_id: (skip):
 **/
static void
fu_struct_elan_ts_fw_version_cmd_set_cmd_id(FuStructElanTsFwVersionCmd *st, FuElanTsReadCmdId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_fw_version_cmd_set_payload: (skip):
 **/
static void
fu_struct_elan_ts_fw_version_cmd_set_payload(FuStructElanTsFwVersionCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_fw_version_cmd_new: (skip):
 **/
FuStructElanTsFwVersionCmd *
fu_struct_elan_ts_fw_version_cmd_new(void)
{
    FuStructElanTsFwVersionCmd *st = fu_struct_elan_ts_fw_version_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_elan_ts_fw_version_cmd_set_cmd_type(st, FU_ELAN_TS_CMD_TYPE_READ_CMD);
    fu_struct_elan_ts_fw_version_cmd_set_cmd_id(st, FU_ELAN_TS_READ_CMD_ID_FW_VERSION);
    fu_struct_elan_ts_fw_version_cmd_set_payload(st, 0x0001);
    return st;
}
/**
 * fu_struct_elan_ts_fw_version_rsp_ref: (skip):
 **/
FuStructElanTsFwVersionRsp *
fu_struct_elan_ts_fw_version_rsp_ref(FuStructElanTsFwVersionRsp *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_fw_version_rsp_unref: (skip):
 **/
void
fu_struct_elan_ts_fw_version_rsp_unref(FuStructElanTsFwVersionRsp *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsFwVersionRsp refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_fw_version_rsp_new_internal: (skip):
 **/
static FuStructElanTsFwVersionRsp *
fu_struct_elan_ts_fw_version_rsp_new_internal(void)
{
    FuStructElanTsFwVersionRsp *st = g_new0(FuStructElanTsFwVersionRsp, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_fw_version_rsp_get_rsp_type: (skip):
 **/
static FuElanTsRspType
fu_struct_elan_ts_fw_version_rsp_get_rsp_type(const FuStructElanTsFwVersionRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_elan_ts_fw_version_rsp_get_payload: (skip):
 **/
const guint8 *
fu_struct_elan_ts_fw_version_rsp_get_payload(const FuStructElanTsFwVersionRsp *st, gsize *bufsz)
{
    g_return_val_if_fail(st != NULL, NULL);
    if (bufsz != NULL)
        *bufsz = 3;
    return st->buf->data + 1;
}

/* setters */
/**
 * fu_struct_elan_ts_fw_version_rsp_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_fw_version_rsp_to_string(const FuStructElanTsFwVersionRsp *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsFwVersionRsp:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_fw_version_rsp_get_rsp_type(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  rsp_type: 0x%x [%s]\n", (guint) fu_struct_elan_ts_fw_version_rsp_get_rsp_type(st), tmp);
        } else {
            g_string_append_printf(str, "  rsp_type: 0x%x\n", (guint) fu_struct_elan_ts_fw_version_rsp_get_rsp_type(st));
        }
    }
    {
        gsize bufsz = 0;
        const guint8 *buf = fu_struct_elan_ts_fw_version_rsp_get_payload(st, &bufsz);
        g_autoptr(GString) tmp = g_string_new(NULL);
        for (gsize i = 0; i < bufsz; i++)
            g_string_append_printf(tmp, "%02X", buf[i]);
        g_string_append_printf(str, "  payload: 0x%s\n", tmp->str);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_fw_version_rsp_validate_internal(FuStructElanTsFwVersionRsp *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_elan_ts_fw_version_rsp_get_rsp_type(st) != FU_ELAN_TS_RSP_TYPE_READ_CMD_RSP) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructElanTsFwVersionRsp.rsp_type was not valid, "
                    "expected 'FU_ELAN_TS_RSP_TYPE_READ_CMD_RSP' and got 0x%x '%s'",
                    fu_struct_elan_ts_fw_version_rsp_get_rsp_type(st),
                    fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_fw_version_rsp_get_rsp_type(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_elan_ts_fw_version_rsp_parse_internal(FuStructElanTsFwVersionRsp *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_fw_version_rsp_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_elan_ts_fw_version_rsp_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_elan_ts_fw_version_rsp_parse: (skip):
 **/
static FuStructElanTsFwVersionRsp *
fu_struct_elan_ts_fw_version_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsFwVersionRsp) st = fu_struct_elan_ts_fw_version_rsp_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsFwVersionRsp: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_struct_elan_ts_fw_version_rsp_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_fw_version_rsp_parse_bytes: (skip):
 **/
FuStructElanTsFwVersionRsp *
fu_struct_elan_ts_fw_version_rsp_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_elan_ts_fw_version_rsp_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_elan_ts_test_solution_version_cmd_ref: (skip):
 **/
FuStructElanTsTestSolutionVersionCmd *
fu_struct_elan_ts_test_solution_version_cmd_ref(FuStructElanTsTestSolutionVersionCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_test_solution_version_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_test_solution_version_cmd_unref(FuStructElanTsTestSolutionVersionCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsTestSolutionVersionCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_test_solution_version_cmd_new_internal: (skip):
 **/
static FuStructElanTsTestSolutionVersionCmd *
fu_struct_elan_ts_test_solution_version_cmd_new_internal(void)
{
    FuStructElanTsTestSolutionVersionCmd *st = g_new0(FuStructElanTsTestSolutionVersionCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_test_solution_version_cmd_set_cmd_type: (skip):
 **/
static void
fu_struct_elan_ts_test_solution_version_cmd_set_cmd_type(FuStructElanTsTestSolutionVersionCmd *st, FuElanTsCmdType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_test_solution_version_cmd_set_cmd_id: (skip):
 **/
static void
fu_struct_elan_ts_test_solution_version_cmd_set_cmd_id(FuStructElanTsTestSolutionVersionCmd *st, FuElanTsReadCmdId value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_test_solution_version_cmd_set_payload: (skip):
 **/
static void
fu_struct_elan_ts_test_solution_version_cmd_set_payload(FuStructElanTsTestSolutionVersionCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_test_solution_version_cmd_new: (skip):
 **/
FuStructElanTsTestSolutionVersionCmd *
fu_struct_elan_ts_test_solution_version_cmd_new(void)
{
    FuStructElanTsTestSolutionVersionCmd *st = fu_struct_elan_ts_test_solution_version_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_elan_ts_test_solution_version_cmd_set_cmd_type(st, FU_ELAN_TS_CMD_TYPE_READ_CMD);
    fu_struct_elan_ts_test_solution_version_cmd_set_cmd_id(st, FU_ELAN_TS_READ_CMD_ID_TEST_SOLUTION_VERSION);
    fu_struct_elan_ts_test_solution_version_cmd_set_payload(st, 0x0001);
    return st;
}
/**
 * fu_struct_elan_ts_test_solution_version_rsp_ref: (skip):
 **/
FuStructElanTsTestSolutionVersionRsp *
fu_struct_elan_ts_test_solution_version_rsp_ref(FuStructElanTsTestSolutionVersionRsp *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_test_solution_version_rsp_unref: (skip):
 **/
void
fu_struct_elan_ts_test_solution_version_rsp_unref(FuStructElanTsTestSolutionVersionRsp *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsTestSolutionVersionRsp refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_test_solution_version_rsp_new_internal: (skip):
 **/
static FuStructElanTsTestSolutionVersionRsp *
fu_struct_elan_ts_test_solution_version_rsp_new_internal(void)
{
    FuStructElanTsTestSolutionVersionRsp *st = g_new0(FuStructElanTsTestSolutionVersionRsp, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_test_solution_version_rsp_get_rsp_type: (skip):
 **/
static FuElanTsRspType
fu_struct_elan_ts_test_solution_version_rsp_get_rsp_type(const FuStructElanTsTestSolutionVersionRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_elan_ts_test_solution_version_rsp_get_payload: (skip):
 **/
const guint8 *
fu_struct_elan_ts_test_solution_version_rsp_get_payload(const FuStructElanTsTestSolutionVersionRsp *st, gsize *bufsz)
{
    g_return_val_if_fail(st != NULL, NULL);
    if (bufsz != NULL)
        *bufsz = 3;
    return st->buf->data + 1;
}

/* setters */
/**
 * fu_struct_elan_ts_test_solution_version_rsp_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_test_solution_version_rsp_to_string(const FuStructElanTsTestSolutionVersionRsp *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsTestSolutionVersionRsp:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_test_solution_version_rsp_get_rsp_type(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  rsp_type: 0x%x [%s]\n", (guint) fu_struct_elan_ts_test_solution_version_rsp_get_rsp_type(st), tmp);
        } else {
            g_string_append_printf(str, "  rsp_type: 0x%x\n", (guint) fu_struct_elan_ts_test_solution_version_rsp_get_rsp_type(st));
        }
    }
    {
        gsize bufsz = 0;
        const guint8 *buf = fu_struct_elan_ts_test_solution_version_rsp_get_payload(st, &bufsz);
        g_autoptr(GString) tmp = g_string_new(NULL);
        for (gsize i = 0; i < bufsz; i++)
            g_string_append_printf(tmp, "%02X", buf[i]);
        g_string_append_printf(str, "  payload: 0x%s\n", tmp->str);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_test_solution_version_rsp_validate_internal(FuStructElanTsTestSolutionVersionRsp *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_elan_ts_test_solution_version_rsp_get_rsp_type(st) != FU_ELAN_TS_RSP_TYPE_READ_CMD_RSP) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructElanTsTestSolutionVersionRsp.rsp_type was not valid, "
                    "expected 'FU_ELAN_TS_RSP_TYPE_READ_CMD_RSP' and got 0x%x '%s'",
                    fu_struct_elan_ts_test_solution_version_rsp_get_rsp_type(st),
                    fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_test_solution_version_rsp_get_rsp_type(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_elan_ts_test_solution_version_rsp_parse_internal(FuStructElanTsTestSolutionVersionRsp *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_test_solution_version_rsp_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_elan_ts_test_solution_version_rsp_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_elan_ts_test_solution_version_rsp_parse: (skip):
 **/
static FuStructElanTsTestSolutionVersionRsp *
fu_struct_elan_ts_test_solution_version_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsTestSolutionVersionRsp) st = fu_struct_elan_ts_test_solution_version_rsp_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsTestSolutionVersionRsp: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_struct_elan_ts_test_solution_version_rsp_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_test_solution_version_rsp_parse_bytes: (skip):
 **/
FuStructElanTsTestSolutionVersionRsp *
fu_struct_elan_ts_test_solution_version_rsp_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_elan_ts_test_solution_version_rsp_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_elan_ts_enter_test_mode_cmd_ref: (skip):
 **/
FuStructElanTsEnterTestModeCmd *
fu_struct_elan_ts_enter_test_mode_cmd_ref(FuStructElanTsEnterTestModeCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_enter_test_mode_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_enter_test_mode_cmd_unref(FuStructElanTsEnterTestModeCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsEnterTestModeCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_enter_test_mode_cmd_new_internal: (skip):
 **/
static FuStructElanTsEnterTestModeCmd *
fu_struct_elan_ts_enter_test_mode_cmd_new_internal(void)
{
    FuStructElanTsEnterTestModeCmd *st = g_new0(FuStructElanTsEnterTestModeCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_enter_test_mode_cmd_set_payload: (skip):
 **/
static void
fu_struct_elan_ts_enter_test_mode_cmd_set_payload(FuStructElanTsEnterTestModeCmd *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_enter_test_mode_cmd_new: (skip):
 **/
FuStructElanTsEnterTestModeCmd *
fu_struct_elan_ts_enter_test_mode_cmd_new(void)
{
    FuStructElanTsEnterTestModeCmd *st = fu_struct_elan_ts_enter_test_mode_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_elan_ts_enter_test_mode_cmd_set_payload(st, 0x55555555);
    return st;
}
/**
 * fu_struct_elan_ts_exit_test_mode_cmd_ref: (skip):
 **/
FuStructElanTsExitTestModeCmd *
fu_struct_elan_ts_exit_test_mode_cmd_ref(FuStructElanTsExitTestModeCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_exit_test_mode_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_exit_test_mode_cmd_unref(FuStructElanTsExitTestModeCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsExitTestModeCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_exit_test_mode_cmd_new_internal: (skip):
 **/
static FuStructElanTsExitTestModeCmd *
fu_struct_elan_ts_exit_test_mode_cmd_new_internal(void)
{
    FuStructElanTsExitTestModeCmd *st = g_new0(FuStructElanTsExitTestModeCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_exit_test_mode_cmd_set_payload: (skip):
 **/
static void
fu_struct_elan_ts_exit_test_mode_cmd_set_payload(FuStructElanTsExitTestModeCmd *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_exit_test_mode_cmd_new: (skip):
 **/
FuStructElanTsExitTestModeCmd *
fu_struct_elan_ts_exit_test_mode_cmd_new(void)
{
    FuStructElanTsExitTestModeCmd *st = fu_struct_elan_ts_exit_test_mode_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_elan_ts_exit_test_mode_cmd_set_payload(st, 0xA5A5A5A5);
    return st;
}
/**
 * fu_struct_elan_ts_read_rom_cmd_ref: (skip):
 **/
FuStructElanTsReadRomCmd *
fu_struct_elan_ts_read_rom_cmd_ref(FuStructElanTsReadRomCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_read_rom_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_read_rom_cmd_unref(FuStructElanTsReadRomCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsReadRomCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_read_rom_cmd_new_internal: (skip):
 **/
static FuStructElanTsReadRomCmd *
fu_struct_elan_ts_read_rom_cmd_new_internal(void)
{
    FuStructElanTsReadRomCmd *st = g_new0(FuStructElanTsReadRomCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_read_rom_cmd_set_cmd_type: (skip):
 **/
static void
fu_struct_elan_ts_read_rom_cmd_set_cmd_type(FuStructElanTsReadRomCmd *st, FuElanTsCmdType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_read_rom_cmd_set_mem_addr: (skip):
 **/
void
fu_struct_elan_ts_read_rom_cmd_set_mem_addr(FuStructElanTsReadRomCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 1, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_read_rom_cmd_set_pad: (skip):
 **/
static void
fu_struct_elan_ts_read_rom_cmd_set_pad(FuStructElanTsReadRomCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 3, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_read_rom_cmd_set_mode: (skip):
 **/
void
fu_struct_elan_ts_read_rom_cmd_set_mode(FuStructElanTsReadRomCmd *st, FuElanTsReadRomCmdMode value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[5] = value;
}
/**
 * fu_struct_elan_ts_read_rom_cmd_new: (skip):
 **/
FuStructElanTsReadRomCmd *
fu_struct_elan_ts_read_rom_cmd_new(void)
{
    FuStructElanTsReadRomCmd *st = fu_struct_elan_ts_read_rom_cmd_new_internal();
    st->buf = g_byte_array_sized_new(6);
    fu_byte_array_set_size(st->buf, 6, 0x0);
    fu_struct_elan_ts_read_rom_cmd_set_cmd_type(st, FU_ELAN_TS_CMD_TYPE_READ_ROM_DATA_CMD);
    fu_struct_elan_ts_read_rom_cmd_set_pad(st, 0x0000);
    fu_struct_elan_ts_read_rom_cmd_set_mode(st, FU_ELAN_TS_READ_ROM_CMD_MODE_EKTH53XX);
    return st;
}
/**
 * fu_struct_elan_ts_read_rom_rsp_ref: (skip):
 **/
FuStructElanTsReadRomRsp *
fu_struct_elan_ts_read_rom_rsp_ref(FuStructElanTsReadRomRsp *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_read_rom_rsp_unref: (skip):
 **/
void
fu_struct_elan_ts_read_rom_rsp_unref(FuStructElanTsReadRomRsp *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsReadRomRsp refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_read_rom_rsp_new_internal: (skip):
 **/
static FuStructElanTsReadRomRsp *
fu_struct_elan_ts_read_rom_rsp_new_internal(void)
{
    FuStructElanTsReadRomRsp *st = g_new0(FuStructElanTsReadRomRsp, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_read_rom_rsp_get_header: (skip):
 **/
static FuElanTsRspType
fu_struct_elan_ts_read_rom_rsp_get_header(const FuStructElanTsReadRomRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_elan_ts_read_rom_rsp_get_mem_addr: (skip):
 **/
guint16
fu_struct_elan_ts_read_rom_rsp_get_mem_addr(const FuStructElanTsReadRomRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 1, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_read_rom_rsp_get_rom_data: (skip):
 **/
guint16
fu_struct_elan_ts_read_rom_rsp_get_rom_data(const FuStructElanTsReadRomRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 3, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_read_rom_rsp_get_mode: (skip):
 **/
FuElanTsReadRomCmdMode
fu_struct_elan_ts_read_rom_rsp_get_mode(const FuStructElanTsReadRomRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[5];
}

/* setters */
/**
 * fu_struct_elan_ts_read_rom_rsp_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_read_rom_rsp_to_string(const FuStructElanTsReadRomRsp *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsReadRomRsp:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_read_rom_rsp_get_header(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  header: 0x%x [%s]\n", (guint) fu_struct_elan_ts_read_rom_rsp_get_header(st), tmp);
        } else {
            g_string_append_printf(str, "  header: 0x%x\n", (guint) fu_struct_elan_ts_read_rom_rsp_get_header(st));
        }
    }
    g_string_append_printf(str, "  mem_addr: 0x%x\n",
                           (guint) fu_struct_elan_ts_read_rom_rsp_get_mem_addr(st));
    g_string_append_printf(str, "  rom_data: 0x%x\n",
                           (guint) fu_struct_elan_ts_read_rom_rsp_get_rom_data(st));
    {
        const gchar *tmp = fu_elan_ts_read_rom_cmd_mode_to_string(fu_struct_elan_ts_read_rom_rsp_get_mode(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  mode: 0x%x [%s]\n", (guint) fu_struct_elan_ts_read_rom_rsp_get_mode(st), tmp);
        } else {
            g_string_append_printf(str, "  mode: 0x%x\n", (guint) fu_struct_elan_ts_read_rom_rsp_get_mode(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_read_rom_rsp_validate_internal(FuStructElanTsReadRomRsp *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_elan_ts_read_rom_rsp_get_header(st) != FU_ELAN_TS_RSP_TYPE_READ_ROM_CMD_RSP) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructElanTsReadRomRsp.header was not valid, "
                    "expected 'FU_ELAN_TS_RSP_TYPE_READ_ROM_CMD_RSP' and got 0x%x '%s'",
                    fu_struct_elan_ts_read_rom_rsp_get_header(st),
                    fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_read_rom_rsp_get_header(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_elan_ts_read_rom_rsp_parse_internal(FuStructElanTsReadRomRsp *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_read_rom_rsp_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_elan_ts_read_rom_rsp_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_elan_ts_read_rom_rsp_parse: (skip):
 **/
static FuStructElanTsReadRomRsp *
fu_struct_elan_ts_read_rom_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsReadRomRsp) st = fu_struct_elan_ts_read_rom_rsp_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 6, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsReadRomRsp: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 6);
    if (!fu_struct_elan_ts_read_rom_rsp_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_read_rom_rsp_parse_bytes: (skip):
 **/
FuStructElanTsReadRomRsp *
fu_struct_elan_ts_read_rom_rsp_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_elan_ts_read_rom_rsp_parse(buf, bufsz, offset, error);
}
/**
 * fu_struct_elan_ts_show_bulk_rom_data_cmd_ref: (skip):
 **/
FuStructElanTsShowBulkRomDataCmd *
fu_struct_elan_ts_show_bulk_rom_data_cmd_ref(FuStructElanTsShowBulkRomDataCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_show_bulk_rom_data_cmd_unref: (skip):
 **/
void
fu_struct_elan_ts_show_bulk_rom_data_cmd_unref(FuStructElanTsShowBulkRomDataCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsShowBulkRomDataCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_show_bulk_rom_data_cmd_new_internal: (skip):
 **/
static FuStructElanTsShowBulkRomDataCmd *
fu_struct_elan_ts_show_bulk_rom_data_cmd_new_internal(void)
{
    FuStructElanTsShowBulkRomDataCmd *st = g_new0(FuStructElanTsShowBulkRomDataCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_elan_ts_show_bulk_rom_data_cmd_set_cmd_type: (skip):
 **/
static void
fu_struct_elan_ts_show_bulk_rom_data_cmd_set_cmd_type(FuStructElanTsShowBulkRomDataCmd *st, FuElanTsCmdType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_elan_ts_show_bulk_rom_data_cmd_set_mode: (skip):
 **/
void
fu_struct_elan_ts_show_bulk_rom_data_cmd_set_mode(FuStructElanTsShowBulkRomDataCmd *st, FuElanTsShowBulkRomMode value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_elan_ts_show_bulk_rom_data_cmd_set_mem_addr: (skip):
 **/
void
fu_struct_elan_ts_show_bulk_rom_data_cmd_set_mem_addr(FuStructElanTsShowBulkRomDataCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_show_bulk_rom_data_cmd_set_data_size_words: (skip):
 **/
void
fu_struct_elan_ts_show_bulk_rom_data_cmd_set_data_size_words(FuStructElanTsShowBulkRomDataCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 4, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_elan_ts_show_bulk_rom_data_cmd_new: (skip):
 **/
FuStructElanTsShowBulkRomDataCmd *
fu_struct_elan_ts_show_bulk_rom_data_cmd_new(void)
{
    FuStructElanTsShowBulkRomDataCmd *st = fu_struct_elan_ts_show_bulk_rom_data_cmd_new_internal();
    st->buf = g_byte_array_sized_new(6);
    fu_byte_array_set_size(st->buf, 6, 0x0);
    fu_struct_elan_ts_show_bulk_rom_data_cmd_set_cmd_type(st, FU_ELAN_TS_CMD_TYPE_SHOW_BULK_ROM_DATA_CMD);
    fu_struct_elan_ts_show_bulk_rom_data_cmd_set_mode(st, FU_ELAN_TS_SHOW_BULK_ROM_MODE_MAIN_CODE);
    return st;
}
/**
 * fu_struct_elan_ts_show_bulk_rom_rsp_ref: (skip):
 **/
FuStructElanTsShowBulkRomRsp *
fu_struct_elan_ts_show_bulk_rom_rsp_ref(FuStructElanTsShowBulkRomRsp *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_elan_ts_show_bulk_rom_rsp_unref: (skip):
 **/
void
fu_struct_elan_ts_show_bulk_rom_rsp_unref(FuStructElanTsShowBulkRomRsp *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructElanTsShowBulkRomRsp refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_elan_ts_show_bulk_rom_rsp_new_internal: (skip):
 **/
static FuStructElanTsShowBulkRomRsp *
fu_struct_elan_ts_show_bulk_rom_rsp_new_internal(void)
{
    FuStructElanTsShowBulkRomRsp *st = g_new0(FuStructElanTsShowBulkRomRsp, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_elan_ts_show_bulk_rom_rsp_get_header: (skip):
 **/
static FuElanTsRspType
fu_struct_elan_ts_show_bulk_rom_rsp_get_header(const FuStructElanTsShowBulkRomRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_elan_ts_show_bulk_rom_rsp_get_frame_index: (skip):
 **/
guint8
fu_struct_elan_ts_show_bulk_rom_rsp_get_frame_index(const FuStructElanTsShowBulkRomRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_elan_ts_show_bulk_rom_rsp_get_data_size_words: (skip):
 **/
guint8
fu_struct_elan_ts_show_bulk_rom_rsp_get_data_size_words(const FuStructElanTsShowBulkRomRsp *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_elan_ts_show_bulk_rom_rsp_get_data: (skip):
 **/
const guint8 *
fu_struct_elan_ts_show_bulk_rom_rsp_get_data(const FuStructElanTsShowBulkRomRsp *st, gsize *bufsz)
{
    g_return_val_if_fail(st != NULL, NULL);
    if (bufsz != NULL)
        *bufsz = 60;
    return st->buf->data + 3;
}

/* setters */
/**
 * fu_struct_elan_ts_show_bulk_rom_rsp_to_string: (skip):
 **/
static gchar *
fu_struct_elan_ts_show_bulk_rom_rsp_to_string(const FuStructElanTsShowBulkRomRsp *st)
{
    g_autoptr(GString) str = g_string_new("FuStructElanTsShowBulkRomRsp:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_show_bulk_rom_rsp_get_header(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  header: 0x%x [%s]\n", (guint) fu_struct_elan_ts_show_bulk_rom_rsp_get_header(st), tmp);
        } else {
            g_string_append_printf(str, "  header: 0x%x\n", (guint) fu_struct_elan_ts_show_bulk_rom_rsp_get_header(st));
        }
    }
    g_string_append_printf(str, "  frame_index: 0x%x\n",
                           (guint) fu_struct_elan_ts_show_bulk_rom_rsp_get_frame_index(st));
    g_string_append_printf(str, "  data_size_words: 0x%x\n",
                           (guint) fu_struct_elan_ts_show_bulk_rom_rsp_get_data_size_words(st));
    {
        gsize bufsz = 0;
        const guint8 *buf = fu_struct_elan_ts_show_bulk_rom_rsp_get_data(st, &bufsz);
        g_autoptr(GString) tmp = g_string_new(NULL);
        for (gsize i = 0; i < bufsz; i++)
            g_string_append_printf(tmp, "%02X", buf[i]);
        g_string_append_printf(str, "  data: 0x%s\n", tmp->str);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_elan_ts_show_bulk_rom_rsp_validate_internal(FuStructElanTsShowBulkRomRsp *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_elan_ts_show_bulk_rom_rsp_get_header(st) != FU_ELAN_TS_RSP_TYPE_SHOW_BULK_ROM_DATA_CMD_RSP) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructElanTsShowBulkRomRsp.header was not valid, "
                    "expected 'FU_ELAN_TS_RSP_TYPE_SHOW_BULK_ROM_DATA_CMD_RSP' and got 0x%x '%s'",
                    fu_struct_elan_ts_show_bulk_rom_rsp_get_header(st),
                    fu_elan_ts_rsp_type_to_string(fu_struct_elan_ts_show_bulk_rom_rsp_get_header(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_elan_ts_show_bulk_rom_rsp_parse_internal(FuStructElanTsShowBulkRomRsp *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_elan_ts_show_bulk_rom_rsp_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_elan_ts_show_bulk_rom_rsp_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_elan_ts_show_bulk_rom_rsp_parse: (skip):
 **/
static FuStructElanTsShowBulkRomRsp *
fu_struct_elan_ts_show_bulk_rom_rsp_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructElanTsShowBulkRomRsp) st = fu_struct_elan_ts_show_bulk_rom_rsp_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 63, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructElanTsShowBulkRomRsp: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 63);
    if (!fu_struct_elan_ts_show_bulk_rom_rsp_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_elan_ts_show_bulk_rom_rsp_parse_bytes: (skip):
 **/
FuStructElanTsShowBulkRomRsp *
fu_struct_elan_ts_show_bulk_rom_rsp_parse_bytes(GBytes *blob, gsize offset, GError **error)
{
    gsize bufsz = 0;
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
    if (buf == NULL)
        return NULL;
    return fu_struct_elan_ts_show_bulk_rom_rsp_parse(buf, bufsz, offset, error);
}
