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

#include "config.h"

#include <glib.h>

#include "fu-goodixtp-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_struct_goodix_tp_cfg_item_ref: (skip):
 **/
FuStructGoodixTpCfgItem *
fu_struct_goodix_tp_cfg_item_ref(FuStructGoodixTpCfgItem *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_goodix_tp_cfg_item_unref: (skip):
 **/
void
fu_struct_goodix_tp_cfg_item_unref(FuStructGoodixTpCfgItem *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructGoodixTpCfgItem refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_goodix_tp_cfg_item_new_internal: (skip):
 **/
static FuStructGoodixTpCfgItem *
fu_struct_goodix_tp_cfg_item_new_internal(void)
{
    FuStructGoodixTpCfgItem *st = g_new0(FuStructGoodixTpCfgItem, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_goodix_tp_cfg_item_get_id: (skip):
 **/
guint8
fu_struct_goodix_tp_cfg_item_get_id(const FuStructGoodixTpCfgItem *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_goodix_tp_cfg_item_get_len: (skip):
 **/
guint16
fu_struct_goodix_tp_cfg_item_get_len(const FuStructGoodixTpCfgItem *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 1, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_goodix_tp_cfg_item_to_string: (skip):
 **/
static gchar *
fu_struct_goodix_tp_cfg_item_to_string(const FuStructGoodixTpCfgItem *st)
{
    g_autoptr(GString) str = g_string_new("FuStructGoodixTpCfgItem:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  id: 0x%x\n",
                           (guint) fu_struct_goodix_tp_cfg_item_get_id(st));
    g_string_append_printf(str, "  len: 0x%x\n",
                           (guint) fu_struct_goodix_tp_cfg_item_get_len(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_goodix_tp_cfg_item_validate_internal(FuStructGoodixTpCfgItem *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_goodix_tp_cfg_item_parse_internal(FuStructGoodixTpCfgItem *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_goodix_tp_cfg_item_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_goodix_tp_cfg_item_validate_internal(st, error))
        return FALSE;
    return TRUE;
}
/**
 * fu_struct_goodix_tp_cfg_item_parse_stream: (skip):
 **/
FuStructGoodixTpCfgItem *
fu_struct_goodix_tp_cfg_item_parse_stream(GInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructGoodixTpCfgItem) st = fu_struct_goodix_tp_cfg_item_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 3, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructGoodixTpCfgItem failed read of 0x%x: ", (guint) 3);
        return NULL;
    }
    if (st->buf->len != 3) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructGoodixTpCfgItem requested 0x%x and got 0x%x",
                    (guint) 3,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_goodix_tp_cfg_item_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_goodix_tp_cfg_group_ref: (skip):
 **/
FuStructGoodixTpCfgGroup *
fu_struct_goodix_tp_cfg_group_ref(FuStructGoodixTpCfgGroup *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_goodix_tp_cfg_group_unref: (skip):
 **/
void
fu_struct_goodix_tp_cfg_group_unref(FuStructGoodixTpCfgGroup *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructGoodixTpCfgGroup refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_goodix_tp_cfg_group_new_internal: (skip):
 **/
static FuStructGoodixTpCfgGroup *
fu_struct_goodix_tp_cfg_group_new_internal(void)
{
    FuStructGoodixTpCfgGroup *st = g_new0(FuStructGoodixTpCfgGroup, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_goodix_tp_cfg_group_get_total_size: (skip):
 **/
guint16
fu_struct_goodix_tp_cfg_group_get_total_size(const FuStructGoodixTpCfgGroup *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_goodix_tp_cfg_group_get_update_flag: (skip):
 **/
guint8
fu_struct_goodix_tp_cfg_group_get_update_flag(const FuStructGoodixTpCfgGroup *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_goodix_tp_cfg_group_get_cfg_num: (skip):
 **/
guint8
fu_struct_goodix_tp_cfg_group_get_cfg_num(const FuStructGoodixTpCfgGroup *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_goodix_tp_cfg_group_get_checksum: (skip):
 **/
guint16
fu_struct_goodix_tp_cfg_group_get_checksum(const FuStructGoodixTpCfgGroup *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 4, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_goodix_tp_cfg_group_to_string: (skip):
 **/
static gchar *
fu_struct_goodix_tp_cfg_group_to_string(const FuStructGoodixTpCfgGroup *st)
{
    g_autoptr(GString) str = g_string_new("FuStructGoodixTpCfgGroup:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  total_size: 0x%x\n",
                           (guint) fu_struct_goodix_tp_cfg_group_get_total_size(st));
    g_string_append_printf(str, "  update_flag: 0x%x\n",
                           (guint) fu_struct_goodix_tp_cfg_group_get_update_flag(st));
    g_string_append_printf(str, "  cfg_num: 0x%x\n",
                           (guint) fu_struct_goodix_tp_cfg_group_get_cfg_num(st));
    g_string_append_printf(str, "  checksum: 0x%x\n",
                           (guint) fu_struct_goodix_tp_cfg_group_get_checksum(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_goodix_tp_cfg_group_validate_internal(FuStructGoodixTpCfgGroup *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_goodix_tp_cfg_group_parse_internal(FuStructGoodixTpCfgGroup *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_goodix_tp_cfg_group_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_goodix_tp_cfg_group_validate_internal(st, error))
        return FALSE;
    return TRUE;
}
/**
 * fu_struct_goodix_tp_cfg_group_parse_stream: (skip):
 **/
FuStructGoodixTpCfgGroup *
fu_struct_goodix_tp_cfg_group_parse_stream(GInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructGoodixTpCfgGroup) st = fu_struct_goodix_tp_cfg_group_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 6, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructGoodixTpCfgGroup failed read of 0x%x: ", (guint) 6);
        return NULL;
    }
    if (st->buf->len != 6) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructGoodixTpCfgGroup requested 0x%x and got 0x%x",
                    (guint) 6,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_goodix_tp_cfg_group_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_goodix_brlb_hdr_ref: (skip):
 **/
FuStructGoodixBrlbHdr *
fu_struct_goodix_brlb_hdr_ref(FuStructGoodixBrlbHdr *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_goodix_brlb_hdr_unref: (skip):
 **/
void
fu_struct_goodix_brlb_hdr_unref(FuStructGoodixBrlbHdr *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructGoodixBrlbHdr refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_goodix_brlb_hdr_new_internal: (skip):
 **/
static FuStructGoodixBrlbHdr *
fu_struct_goodix_brlb_hdr_new_internal(void)
{
    FuStructGoodixBrlbHdr *st = g_new0(FuStructGoodixBrlbHdr, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_goodix_brlb_hdr_get_firmware_size: (skip):
 **/
guint32
fu_struct_goodix_brlb_hdr_get_firmware_size(const FuStructGoodixBrlbHdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_goodix_brlb_hdr_get_checksum: (skip):
 **/
guint32
fu_struct_goodix_brlb_hdr_get_checksum(const FuStructGoodixBrlbHdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_goodix_brlb_hdr_get_vid: (skip):
 **/
guint32
fu_struct_goodix_brlb_hdr_get_vid(const FuStructGoodixBrlbHdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 25, G_BIG_ENDIAN);
}
/**
 * fu_struct_goodix_brlb_hdr_get_subsys_num: (skip):
 **/
guint8
fu_struct_goodix_brlb_hdr_get_subsys_num(const FuStructGoodixBrlbHdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[29];
}

/* setters */
/**
 * fu_struct_goodix_brlb_hdr_to_string: (skip):
 **/
static gchar *
fu_struct_goodix_brlb_hdr_to_string(const FuStructGoodixBrlbHdr *st)
{
    g_autoptr(GString) str = g_string_new("FuStructGoodixBrlbHdr:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  firmware_size: 0x%x\n",
                           (guint) fu_struct_goodix_brlb_hdr_get_firmware_size(st));
    g_string_append_printf(str, "  checksum: 0x%x\n",
                           (guint) fu_struct_goodix_brlb_hdr_get_checksum(st));
    g_string_append_printf(str, "  vid: 0x%x\n",
                           (guint) fu_struct_goodix_brlb_hdr_get_vid(st));
    g_string_append_printf(str, "  subsys_num: 0x%x\n",
                           (guint) fu_struct_goodix_brlb_hdr_get_subsys_num(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_goodix_brlb_hdr_validate_internal(FuStructGoodixBrlbHdr *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_goodix_brlb_hdr_parse_internal(FuStructGoodixBrlbHdr *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_goodix_brlb_hdr_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_goodix_brlb_hdr_validate_internal(st, error))
        return FALSE;
    return TRUE;
}
/**
 * fu_struct_goodix_brlb_hdr_parse_stream: (skip):
 **/
FuStructGoodixBrlbHdr *
fu_struct_goodix_brlb_hdr_parse_stream(GInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructGoodixBrlbHdr) st = fu_struct_goodix_brlb_hdr_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 42, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructGoodixBrlbHdr failed read of 0x%x: ", (guint) 42);
        return NULL;
    }
    if (st->buf->len != 42) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructGoodixBrlbHdr requested 0x%x and got 0x%x",
                    (guint) 42,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_goodix_brlb_hdr_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_goodix_brlb_img_ref: (skip):
 **/
FuStructGoodixBrlbImg *
fu_struct_goodix_brlb_img_ref(FuStructGoodixBrlbImg *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_goodix_brlb_img_unref: (skip):
 **/
void
fu_struct_goodix_brlb_img_unref(FuStructGoodixBrlbImg *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructGoodixBrlbImg refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_goodix_brlb_img_new_internal: (skip):
 **/
static FuStructGoodixBrlbImg *
fu_struct_goodix_brlb_img_new_internal(void)
{
    FuStructGoodixBrlbImg *st = g_new0(FuStructGoodixBrlbImg, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_goodix_brlb_img_get_kind: (skip):
 **/
guint8
fu_struct_goodix_brlb_img_get_kind(const FuStructGoodixBrlbImg *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_goodix_brlb_img_get_size: (skip):
 **/
guint32
fu_struct_goodix_brlb_img_get_size(const FuStructGoodixBrlbImg *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 1, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_goodix_brlb_img_get_addr: (skip):
 **/
guint32
fu_struct_goodix_brlb_img_get_addr(const FuStructGoodixBrlbImg *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 5, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_goodix_brlb_img_to_string: (skip):
 **/
static gchar *
fu_struct_goodix_brlb_img_to_string(const FuStructGoodixBrlbImg *st)
{
    g_autoptr(GString) str = g_string_new("FuStructGoodixBrlbImg:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  kind: 0x%x\n",
                           (guint) fu_struct_goodix_brlb_img_get_kind(st));
    g_string_append_printf(str, "  size: 0x%x\n",
                           (guint) fu_struct_goodix_brlb_img_get_size(st));
    g_string_append_printf(str, "  addr: 0x%x\n",
                           (guint) fu_struct_goodix_brlb_img_get_addr(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_goodix_brlb_img_validate_internal(FuStructGoodixBrlbImg *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_goodix_brlb_img_parse_internal(FuStructGoodixBrlbImg *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_goodix_brlb_img_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_goodix_brlb_img_validate_internal(st, error))
        return FALSE;
    return TRUE;
}
/**
 * fu_struct_goodix_brlb_img_parse_stream: (skip):
 **/
FuStructGoodixBrlbImg *
fu_struct_goodix_brlb_img_parse_stream(GInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructGoodixBrlbImg) st = fu_struct_goodix_brlb_img_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 10, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructGoodixBrlbImg failed read of 0x%x: ", (guint) 10);
        return NULL;
    }
    if (st->buf->len != 10) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructGoodixBrlbImg requested 0x%x and got 0x%x",
                    (guint) 10,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_goodix_brlb_img_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_goodix_gtx8_hdr_ref: (skip):
 **/
FuStructGoodixGtx8Hdr *
fu_struct_goodix_gtx8_hdr_ref(FuStructGoodixGtx8Hdr *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_goodix_gtx8_hdr_unref: (skip):
 **/
void
fu_struct_goodix_gtx8_hdr_unref(FuStructGoodixGtx8Hdr *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructGoodixGtx8Hdr refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_goodix_gtx8_hdr_new_internal: (skip):
 **/
static FuStructGoodixGtx8Hdr *
fu_struct_goodix_gtx8_hdr_new_internal(void)
{
    FuStructGoodixGtx8Hdr *st = g_new0(FuStructGoodixGtx8Hdr, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_goodix_gtx8_hdr_get_firmware_size: (skip):
 **/
guint32
fu_struct_goodix_gtx8_hdr_get_firmware_size(const FuStructGoodixGtx8Hdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_goodix_gtx8_hdr_get_checksum: (skip):
 **/
guint16
fu_struct_goodix_gtx8_hdr_get_checksum(const FuStructGoodixGtx8Hdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 4, G_BIG_ENDIAN);
}
/**
 * fu_struct_goodix_gtx8_hdr_get_vid: (skip):
 **/
guint32
fu_struct_goodix_gtx8_hdr_get_vid(const FuStructGoodixGtx8Hdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 23, G_BIG_ENDIAN);
}
/**
 * fu_struct_goodix_gtx8_hdr_get_subsys_num: (skip):
 **/
guint8
fu_struct_goodix_gtx8_hdr_get_subsys_num(const FuStructGoodixGtx8Hdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[27];
}

/* setters */
/**
 * fu_struct_goodix_gtx8_hdr_to_string: (skip):
 **/
static gchar *
fu_struct_goodix_gtx8_hdr_to_string(const FuStructGoodixGtx8Hdr *st)
{
    g_autoptr(GString) str = g_string_new("FuStructGoodixGtx8Hdr:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  firmware_size: 0x%x\n",
                           (guint) fu_struct_goodix_gtx8_hdr_get_firmware_size(st));
    g_string_append_printf(str, "  checksum: 0x%x\n",
                           (guint) fu_struct_goodix_gtx8_hdr_get_checksum(st));
    g_string_append_printf(str, "  vid: 0x%x\n",
                           (guint) fu_struct_goodix_gtx8_hdr_get_vid(st));
    g_string_append_printf(str, "  subsys_num: 0x%x\n",
                           (guint) fu_struct_goodix_gtx8_hdr_get_subsys_num(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_goodix_gtx8_hdr_validate_internal(FuStructGoodixGtx8Hdr *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_goodix_gtx8_hdr_parse_internal(FuStructGoodixGtx8Hdr *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_goodix_gtx8_hdr_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_goodix_gtx8_hdr_validate_internal(st, error))
        return FALSE;
    return TRUE;
}
/**
 * fu_struct_goodix_gtx8_hdr_parse_stream: (skip):
 **/
FuStructGoodixGtx8Hdr *
fu_struct_goodix_gtx8_hdr_parse_stream(GInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructGoodixGtx8Hdr) st = fu_struct_goodix_gtx8_hdr_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructGoodixGtx8Hdr failed read of 0x%x: ", (guint) 32);
        return NULL;
    }
    if (st->buf->len != 32) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructGoodixGtx8Hdr requested 0x%x and got 0x%x",
                    (guint) 32,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_goodix_gtx8_hdr_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_goodix_gtx8_img_ref: (skip):
 **/
FuStructGoodixGtx8Img *
fu_struct_goodix_gtx8_img_ref(FuStructGoodixGtx8Img *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_goodix_gtx8_img_unref: (skip):
 **/
void
fu_struct_goodix_gtx8_img_unref(FuStructGoodixGtx8Img *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructGoodixGtx8Img refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_goodix_gtx8_img_new_internal: (skip):
 **/
static FuStructGoodixGtx8Img *
fu_struct_goodix_gtx8_img_new_internal(void)
{
    FuStructGoodixGtx8Img *st = g_new0(FuStructGoodixGtx8Img, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_goodix_gtx8_img_get_kind: (skip):
 **/
guint8
fu_struct_goodix_gtx8_img_get_kind(const FuStructGoodixGtx8Img *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_goodix_gtx8_img_get_size: (skip):
 **/
guint32
fu_struct_goodix_gtx8_img_get_size(const FuStructGoodixGtx8Img *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 1, G_BIG_ENDIAN);
}
/**
 * fu_struct_goodix_gtx8_img_get_addr: (skip):
 **/
guint16
fu_struct_goodix_gtx8_img_get_addr(const FuStructGoodixGtx8Img *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 5, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_goodix_gtx8_img_to_string: (skip):
 **/
static gchar *
fu_struct_goodix_gtx8_img_to_string(const FuStructGoodixGtx8Img *st)
{
    g_autoptr(GString) str = g_string_new("FuStructGoodixGtx8Img:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  kind: 0x%x\n",
                           (guint) fu_struct_goodix_gtx8_img_get_kind(st));
    g_string_append_printf(str, "  size: 0x%x\n",
                           (guint) fu_struct_goodix_gtx8_img_get_size(st));
    g_string_append_printf(str, "  addr: 0x%x\n",
                           (guint) fu_struct_goodix_gtx8_img_get_addr(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_goodix_gtx8_img_validate_internal(FuStructGoodixGtx8Img *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_goodix_gtx8_img_parse_internal(FuStructGoodixGtx8Img *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_goodix_gtx8_img_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_goodix_gtx8_img_validate_internal(st, error))
        return FALSE;
    return TRUE;
}
/**
 * fu_struct_goodix_gtx8_img_parse_stream: (skip):
 **/
FuStructGoodixGtx8Img *
fu_struct_goodix_gtx8_img_parse_stream(GInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructGoodixGtx8Img) st = fu_struct_goodix_gtx8_img_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 8, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructGoodixGtx8Img failed read of 0x%x: ", (guint) 8);
        return NULL;
    }
    if (st->buf->len != 8) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructGoodixGtx8Img requested 0x%x and got 0x%x",
                    (guint) 8,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_goodix_gtx8_img_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
