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

#include "config.h"

#include <glib.h>

#include "fu-novatek-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_struct_novatek_ts_hid_read_req_ref: (skip):
 **/
FuStructNovatekTsHidReadReq *
fu_struct_novatek_ts_hid_read_req_ref(FuStructNovatekTsHidReadReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_novatek_ts_hid_read_req_unref: (skip):
 **/
void
fu_struct_novatek_ts_hid_read_req_unref(FuStructNovatekTsHidReadReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructNovatekTsHidReadReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_novatek_ts_hid_read_req_new_internal: (skip):
 **/
static FuStructNovatekTsHidReadReq *
fu_struct_novatek_ts_hid_read_req_new_internal(void)
{
    FuStructNovatekTsHidReadReq *st = g_new0(FuStructNovatekTsHidReadReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_novatek_ts_hid_read_req_get_i2c_hid_eng_report_id: (skip):
 **/
guint8
fu_struct_novatek_ts_hid_read_req_get_i2c_hid_eng_report_id(const FuStructNovatekTsHidReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_novatek_ts_hid_read_req_get_i2c_eng_addr: (skip):
 **/
guint32
fu_struct_novatek_ts_hid_read_req_get_i2c_eng_addr(const FuStructNovatekTsHidReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint24(st->buf->data + 3, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_hid_read_req_get_target_addr: (skip):
 **/
guint32
fu_struct_novatek_ts_hid_read_req_get_target_addr(const FuStructNovatekTsHidReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint24(st->buf->data + 6, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_hid_read_req_get_len: (skip):
 **/
guint16
fu_struct_novatek_ts_hid_read_req_get_len(const FuStructNovatekTsHidReadReq *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 10, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_novatek_ts_hid_read_req_set_i2c_hid_eng_report_id: (skip):
 **/
void
fu_struct_novatek_ts_hid_read_req_set_i2c_hid_eng_report_id(FuStructNovatekTsHidReadReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_novatek_ts_hid_read_req_set_write_len: (skip):
 **/
static void
fu_struct_novatek_ts_hid_read_req_set_write_len(FuStructNovatekTsHidReadReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 1, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_hid_read_req_set_i2c_eng_addr: (skip):
 **/
void
fu_struct_novatek_ts_hid_read_req_set_i2c_eng_addr(FuStructNovatekTsHidReadReq *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint24(st->buf->data + 3, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_hid_read_req_set_target_addr: (skip):
 **/
void
fu_struct_novatek_ts_hid_read_req_set_target_addr(FuStructNovatekTsHidReadReq *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint24(st->buf->data + 6, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_hid_read_req_set_len: (skip):
 **/
void
fu_struct_novatek_ts_hid_read_req_set_len(FuStructNovatekTsHidReadReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 10, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_hid_read_req_new: (skip):
 **/
FuStructNovatekTsHidReadReq *
fu_struct_novatek_ts_hid_read_req_new(void)
{
    FuStructNovatekTsHidReadReq *st = fu_struct_novatek_ts_hid_read_req_new_internal();
    st->buf = g_byte_array_sized_new(12);
    fu_byte_array_set_size(st->buf, 12, 0x0);
    fu_struct_novatek_ts_hid_read_req_set_write_len(st, 0x000B);
    return st;
}
/**
 * fu_struct_novatek_ts_hid_write_hdr_ref: (skip):
 **/
FuStructNovatekTsHidWriteHdr *
fu_struct_novatek_ts_hid_write_hdr_ref(FuStructNovatekTsHidWriteHdr *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_novatek_ts_hid_write_hdr_unref: (skip):
 **/
void
fu_struct_novatek_ts_hid_write_hdr_unref(FuStructNovatekTsHidWriteHdr *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructNovatekTsHidWriteHdr refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_novatek_ts_hid_write_hdr_new_internal: (skip):
 **/
static FuStructNovatekTsHidWriteHdr *
fu_struct_novatek_ts_hid_write_hdr_new_internal(void)
{
    FuStructNovatekTsHidWriteHdr *st = g_new0(FuStructNovatekTsHidWriteHdr, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_novatek_ts_hid_write_hdr_get_i2c_hid_eng_report_id: (skip):
 **/
guint8
fu_struct_novatek_ts_hid_write_hdr_get_i2c_hid_eng_report_id(const FuStructNovatekTsHidWriteHdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_novatek_ts_hid_write_hdr_get_write_len: (skip):
 **/
guint16
fu_struct_novatek_ts_hid_write_hdr_get_write_len(const FuStructNovatekTsHidWriteHdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 1, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_hid_write_hdr_get_target_addr: (skip):
 **/
guint32
fu_struct_novatek_ts_hid_write_hdr_get_target_addr(const FuStructNovatekTsHidWriteHdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint24(st->buf->data + 3, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_novatek_ts_hid_write_hdr_set_i2c_hid_eng_report_id: (skip):
 **/
void
fu_struct_novatek_ts_hid_write_hdr_set_i2c_hid_eng_report_id(FuStructNovatekTsHidWriteHdr *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_novatek_ts_hid_write_hdr_set_write_len: (skip):
 **/
void
fu_struct_novatek_ts_hid_write_hdr_set_write_len(FuStructNovatekTsHidWriteHdr *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 1, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_hid_write_hdr_set_target_addr: (skip):
 **/
void
fu_struct_novatek_ts_hid_write_hdr_set_target_addr(FuStructNovatekTsHidWriteHdr *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint24(st->buf->data + 3, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_hid_write_hdr_new: (skip):
 **/
FuStructNovatekTsHidWriteHdr *
fu_struct_novatek_ts_hid_write_hdr_new(void)
{
    FuStructNovatekTsHidWriteHdr *st = fu_struct_novatek_ts_hid_write_hdr_new_internal();
    st->buf = g_byte_array_sized_new(6);
    fu_byte_array_set_size(st->buf, 6, 0x0);
    return st;
}
/**
 * fu_struct_novatek_ts_gcm_cmd_ref: (skip):
 **/
FuStructNovatekTsGcmCmd *
fu_struct_novatek_ts_gcm_cmd_ref(FuStructNovatekTsGcmCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_novatek_ts_gcm_cmd_unref: (skip):
 **/
void
fu_struct_novatek_ts_gcm_cmd_unref(FuStructNovatekTsGcmCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructNovatekTsGcmCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_novatek_ts_gcm_cmd_new_internal: (skip):
 **/
static FuStructNovatekTsGcmCmd *
fu_struct_novatek_ts_gcm_cmd_new_internal(void)
{
    FuStructNovatekTsGcmCmd *st = g_new0(FuStructNovatekTsGcmCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_novatek_ts_gcm_cmd_get_flash_cmd: (skip):
 **/
guint8
fu_struct_novatek_ts_gcm_cmd_get_flash_cmd(const FuStructNovatekTsGcmCmd *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_novatek_ts_gcm_cmd_get_flash_addr: (skip):
 **/
guint32
fu_struct_novatek_ts_gcm_cmd_get_flash_addr(const FuStructNovatekTsGcmCmd *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint24(st->buf->data + 1, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_gcm_cmd_get_write_len: (skip):
 **/
guint16
fu_struct_novatek_ts_gcm_cmd_get_write_len(const FuStructNovatekTsGcmCmd *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 5, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_gcm_cmd_get_read_len: (skip):
 **/
guint16
fu_struct_novatek_ts_gcm_cmd_get_read_len(const FuStructNovatekTsGcmCmd *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 7, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_gcm_cmd_get_flash_checksum: (skip):
 **/
guint16
fu_struct_novatek_ts_gcm_cmd_get_flash_checksum(const FuStructNovatekTsGcmCmd *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 9, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_novatek_ts_gcm_cmd_set_flash_cmd: (skip):
 **/
void
fu_struct_novatek_ts_gcm_cmd_set_flash_cmd(FuStructNovatekTsGcmCmd *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_novatek_ts_gcm_cmd_set_flash_addr: (skip):
 **/
void
fu_struct_novatek_ts_gcm_cmd_set_flash_addr(FuStructNovatekTsGcmCmd *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint24(st->buf->data + 1, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_gcm_cmd_set_write_len: (skip):
 **/
void
fu_struct_novatek_ts_gcm_cmd_set_write_len(FuStructNovatekTsGcmCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 5, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_gcm_cmd_set_read_len: (skip):
 **/
void
fu_struct_novatek_ts_gcm_cmd_set_read_len(FuStructNovatekTsGcmCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 7, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_gcm_cmd_set_flash_checksum: (skip):
 **/
void
fu_struct_novatek_ts_gcm_cmd_set_flash_checksum(FuStructNovatekTsGcmCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 9, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_novatek_ts_gcm_cmd_set_magic: (skip):
 **/
static void
fu_struct_novatek_ts_gcm_cmd_set_magic(FuStructNovatekTsGcmCmd *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[11] = value;
}
/**
 * fu_struct_novatek_ts_gcm_cmd_new: (skip):
 **/
FuStructNovatekTsGcmCmd *
fu_struct_novatek_ts_gcm_cmd_new(void)
{
    FuStructNovatekTsGcmCmd *st = fu_struct_novatek_ts_gcm_cmd_new_internal();
    st->buf = g_byte_array_sized_new(12);
    fu_byte_array_set_size(st->buf, 12, 0x0);
    fu_struct_novatek_ts_gcm_cmd_set_magic(st, 0xC2);
    return st;
}
