Coverage Report

Created: 2026-06-15 06:54

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/fu-ccgx-dmc-struct.c
Line
Count
Source
1
/*
2
 * This file is auto-generated, do not modify!
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
7
#include "config.h"
8
9
#include <glib.h>
10
11
#include "fu-ccgx-dmc-struct.h"
12
#include "fu-byte-array.h"
13
#include "fu-bytes.h"
14
#include "fu-mem-private.h"
15
#include "fu-string.h"
16
17
#ifdef G_LOG_DOMAIN
18
  #undef G_LOG_DOMAIN
19
#endif
20
0
#define G_LOG_DOMAIN "FuStruct"
21
22
23
/**
24
 * fu_ccgx_dmc_img_status_to_string:
25
 * @val: value, e.g. %FU_CCGX_DMC_IMG_STATUS_VALID
26
 *
27
 * Converts an enumerated value to a string.
28
 *
29
 * Returns: identifier string
30
 **/
31
const gchar *
32
fu_ccgx_dmc_img_status_to_string(FuCcgxDmcImgStatus val)
33
0
{
34
0
    if (val == FU_CCGX_DMC_IMG_STATUS_VALID)
35
0
        return "valid";
36
0
    if (val == FU_CCGX_DMC_IMG_STATUS_INVALID)
37
0
        return "invalid";
38
0
    if (val == FU_CCGX_DMC_IMG_STATUS_RECOVERY)
39
0
        return "recovery";
40
0
    if (val == FU_CCGX_DMC_IMG_STATUS_RECOVERED_FROM_SECONDARY)
41
0
        return "recovered-from-secondary";
42
0
    if (val == FU_CCGX_DMC_IMG_STATUS_NOT_SUPPORTED)
43
0
        return "not-supported";
44
0
    return NULL;
45
0
}
46
47
/**
48
 * fu_ccgx_dmc_img_mode_to_string:
49
 * @val: value, e.g. %FU_CCGX_DMC_IMG_MODE_DUAL_IMG_SYM
50
 *
51
 * Converts an enumerated value to a string.
52
 *
53
 * Returns: identifier string
54
 **/
55
const gchar *
56
fu_ccgx_dmc_img_mode_to_string(FuCcgxDmcImgMode val)
57
0
{
58
0
    if (val == FU_CCGX_DMC_IMG_MODE_SINGLE_IMG)
59
0
        return "single-img";
60
0
    if (val == FU_CCGX_DMC_IMG_MODE_DUAL_IMG_SYM)
61
0
        return "dual-img-sym";
62
0
    if (val == FU_CCGX_DMC_IMG_MODE_DUAL_IMG_ASYM)
63
0
        return "dual-img-asym";
64
0
    if (val == FU_CCGX_DMC_IMG_MODE_SINGLE_IMG_WITH_RAM_IMG)
65
0
        return "single-img-with-ram-img";
66
0
    return NULL;
67
0
}
68
69
/**
70
 * fu_ccgx_dmc_device_status_to_string:
71
 * @val: value, e.g. %FU_CCGX_DMC_DEVICE_STATUS_UPDATE_PHASE1_IN_PROGRESS
72
 *
73
 * Converts an enumerated value to a string.
74
 *
75
 * Returns: identifier string
76
 **/
77
const gchar *
78
fu_ccgx_dmc_device_status_to_string(FuCcgxDmcDeviceStatus val)
79
0
{
80
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_IDLE)
81
0
        return "idle";
82
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_PHASE1_IN_PROGRESS)
83
0
        return "update-phase1-in-progress";
84
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_PHASE1_PARTIAL)
85
0
        return "update-phase1-partial";
86
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_COMPLETE_FULL)
87
0
        return "update-complete-full";
88
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_PHASE1_COMPLETE_PARTIAL)
89
0
        return "update-phase1-complete-partial";
90
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_PHASE1_COMPLETE_FULL_PHASE2_NOT_DONE)
91
0
        return "update-phase1-complete-full-phase2-not-done";
92
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_FW_DOWNLOADED_UPDATE_PEND)
93
0
        return "fw-downloaded-update-pend";
94
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_FW_DOWNLOADED_PARTIAL_UPDATE_PEND)
95
0
        return "fw-downloaded-partial-update-pend";
96
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_IN_PROGRESS)
97
0
        return "phase2-update-in-progress";
98
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_PARTIAL)
99
0
        return "phase2-update-partial";
100
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FACTORY_BACKUP)
101
0
        return "phase2-update-factory-backup";
102
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_COMPLETE_PARTIAL)
103
0
        return "phase2-update-complete-partial";
104
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_COMPLETE_FULL)
105
0
        return "phase2-update-complete-full";
106
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_INVALID_FWCT)
107
0
        return "phase2-update-fail-invalid-fwct";
108
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_INVALID_DOCK_IDENTITY)
109
0
        return "phase2-update-fail-invalid-dock-identity";
110
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_INVALID_COMPOSITE_VER)
111
0
        return "phase2-update-fail-invalid-composite-ver";
112
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_AUTHENTICATION_FAILED)
113
0
        return "phase2-update-fail-authentication-failed";
114
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_INVALID_ALGORITHM)
115
0
        return "phase2-update-fail-invalid-algorithm";
116
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_SPI_READ_FAILED)
117
0
        return "phase2-update-fail-spi-read-failed";
118
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_NO_VALID_KEY)
119
0
        return "phase2-update-fail-no-valid-key";
120
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_NO_VALID_SPI_PACKAGE)
121
0
        return "phase2-update-fail-no-valid-spi-package";
122
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_RAM_INIT_FAILED)
123
0
        return "phase2-update-fail-ram-init-failed";
124
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_FACTORY_BACKUP_FAILED)
125
0
        return "phase2-update-fail-factory-backup-failed";
126
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_NO_VALID_FACTORY_PACKAGE)
127
0
        return "phase2-update-fail-no-valid-factory-package";
128
0
    if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_FAIL)
129
0
        return "update-fail";
130
0
    return NULL;
131
0
}
132
133
/**
134
 * fu_ccgx_dmc_devx_device_type_to_string:
135
 * @val: value, e.g. %FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG3
136
 *
137
 * Converts an enumerated value to a string.
138
 *
139
 * Returns: identifier string
140
 **/
141
const gchar *
142
fu_ccgx_dmc_devx_device_type_to_string(FuCcgxDmcDevxDeviceType val)
143
0
{
144
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_INVALID)
145
0
        return "invalid";
146
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG3)
147
0
        return "ccg3";
148
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_DMC)
149
0
        return "dmc";
150
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG4)
151
0
        return "ccg4";
152
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG5)
153
0
        return "ccg5";
154
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_HX3)
155
0
        return "hx3";
156
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_HX3_PD)
157
0
        return "hx3-pd";
158
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_DMC_PD)
159
0
        return "dmc-pd";
160
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG6)
161
0
        return "ccg6";
162
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_PMG1S3)
163
0
        return "pmg1s3";
164
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG7SC)
165
0
        return "ccg7sc";
166
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG6SF)
167
0
        return "ccg6sf";
168
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG8)
169
0
        return "ccg8";
170
0
    if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_SPI)
171
0
        return "spi";
172
0
    return NULL;
173
0
}
174
175
176
/**
177
 * fu_ccgx_dmc_int_opcode_to_string:
178
 * @val: value, e.g. %FU_CCGX_DMC_INT_OPCODE_FW_UPGRADE_STATUS
179
 *
180
 * Converts an enumerated value to a string.
181
 *
182
 * Returns: identifier string
183
 **/
184
const gchar *
185
fu_ccgx_dmc_int_opcode_to_string(FuCcgxDmcIntOpcode val)
186
0
{
187
0
    if (val == FU_CCGX_DMC_INT_OPCODE_FW_UPGRADE_RQT)
188
0
        return "fw-upgrade-rqt";
189
0
    if (val == FU_CCGX_DMC_INT_OPCODE_FW_UPGRADE_STATUS)
190
0
        return "fw-upgrade-status";
191
0
    if (val == FU_CCGX_DMC_INT_OPCODE_IMG_WRITE_STATUS)
192
0
        return "img-write-status";
193
0
    if (val == FU_CCGX_DMC_INT_OPCODE_REENUM)
194
0
        return "reenum";
195
0
    if (val == FU_CCGX_DMC_INT_OPCODE_FWCT_ANALYSIS_STATUS)
196
0
        return "fwct-analysis-status";
197
0
    return NULL;
198
0
}
199
200
/**
201
 * fu_ccgx_dmc_fwct_analysis_status_to_string:
202
 * @val: value, e.g. %FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_DOCK_IDENTITY
203
 *
204
 * Converts an enumerated value to a string.
205
 *
206
 * Returns: identifier string
207
 **/
208
const gchar *
209
fu_ccgx_dmc_fwct_analysis_status_to_string(FuCcgxDmcFwctAnalysisStatus val)
210
0
{
211
0
    if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_FWCT)
212
0
        return "invalid-fwct";
213
0
    if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_DOCK_IDENTITY)
214
0
        return "invalid-dock-identity";
215
0
    if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_COMPOSITE_VERSION)
216
0
        return "invalid-composite-version";
217
0
    if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_AUTHENTICATION_FAILED)
218
0
        return "authentication-failed";
219
0
    if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_ALGORITHM)
220
0
        return "invalid-algorithm";
221
0
    if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_FENCE)
222
0
        return "invalid-fence";
223
0
    return NULL;
224
0
}
225
226
/**
227
 * fu_ccgx_dmc_update_model_to_string:
228
 * @val: value, e.g. %FU_CCGX_DMC_UPDATE_MODEL_DOWNLOAD_TRIGGER
229
 *
230
 * Converts an enumerated value to a string.
231
 *
232
 * Returns: identifier string
233
 **/
234
const gchar *
235
fu_ccgx_dmc_update_model_to_string(FuCcgxDmcUpdateModel val)
236
0
{
237
0
    if (val == FU_CCGX_DMC_UPDATE_MODEL_NONE)
238
0
        return "none";
239
0
    if (val == FU_CCGX_DMC_UPDATE_MODEL_DOWNLOAD_TRIGGER)
240
0
        return "download-trigger";
241
0
    if (val == FU_CCGX_DMC_UPDATE_MODEL_PENDING_RESET)
242
0
        return "pending-reset";
243
0
    return NULL;
244
0
}
245
/**
246
 * fu_struct_ccgx_dmc_dock_identity_ref: (skip):
247
 **/
248
FuStructCcgxDmcDockIdentity *
249
fu_struct_ccgx_dmc_dock_identity_ref(FuStructCcgxDmcDockIdentity *st)
250
0
{
251
0
    g_return_val_if_fail(st != NULL, NULL);
252
0
    st->refcount++;
253
0
    return st;
254
0
}
255
/**
256
 * fu_struct_ccgx_dmc_dock_identity_unref: (skip):
257
 **/
258
void
259
fu_struct_ccgx_dmc_dock_identity_unref(FuStructCcgxDmcDockIdentity *st)
260
0
{
261
0
    g_return_if_fail(st != NULL);
262
0
    if (st->refcount == 0) {
263
0
        g_critical("FuStructCcgxDmcDockIdentity refcount already zero");
264
0
        return;
265
0
    }
266
0
    if (--st->refcount > 0)
267
0
        return;
268
0
    if (st->buf != NULL)
269
0
        g_byte_array_unref(st->buf);
270
0
    g_free(st);
271
0
}
272
/**
273
 * fu_struct_ccgx_dmc_dock_identity_new_internal: (skip):
274
 **/
275
static FuStructCcgxDmcDockIdentity *
276
fu_struct_ccgx_dmc_dock_identity_new_internal(void)
277
0
{
278
0
    FuStructCcgxDmcDockIdentity *st = g_new0(FuStructCcgxDmcDockIdentity, 1);
279
0
    st->refcount = 1;
280
0
    return st;
281
0
}
282
283
/* getters */
284
/**
285
 * fu_struct_ccgx_dmc_dock_identity_get_structure_version: (skip):
286
 **/
287
guint8
288
fu_struct_ccgx_dmc_dock_identity_get_structure_version(const FuStructCcgxDmcDockIdentity *st)
289
0
{
290
0
    g_return_val_if_fail(st != NULL, 0x0);
291
0
    return st->buf->data[0];
292
0
}
293
/**
294
 * fu_struct_ccgx_dmc_dock_identity_get_cdtt_version: (skip):
295
 **/
296
guint8
297
fu_struct_ccgx_dmc_dock_identity_get_cdtt_version(const FuStructCcgxDmcDockIdentity *st)
298
0
{
299
0
    g_return_val_if_fail(st != NULL, 0x0);
300
0
    return st->buf->data[1];
301
0
}
302
/**
303
 * fu_struct_ccgx_dmc_dock_identity_get_vid: (skip):
304
 **/
305
guint16
306
fu_struct_ccgx_dmc_dock_identity_get_vid(const FuStructCcgxDmcDockIdentity *st)
307
0
{
308
0
    g_return_val_if_fail(st != NULL, 0x0);
309
0
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
310
0
}
311
/**
312
 * fu_struct_ccgx_dmc_dock_identity_get_pid: (skip):
313
 **/
314
guint16
315
fu_struct_ccgx_dmc_dock_identity_get_pid(const FuStructCcgxDmcDockIdentity *st)
316
0
{
317
0
    g_return_val_if_fail(st != NULL, 0x0);
318
0
    return fu_memread_uint16(st->buf->data + 4, G_LITTLE_ENDIAN);
319
0
}
320
/**
321
 * fu_struct_ccgx_dmc_dock_identity_get_device_id: (skip):
322
 **/
323
guint16
324
fu_struct_ccgx_dmc_dock_identity_get_device_id(const FuStructCcgxDmcDockIdentity *st)
325
0
{
326
0
    g_return_val_if_fail(st != NULL, 0x0);
327
0
    return fu_memread_uint16(st->buf->data + 6, G_LITTLE_ENDIAN);
328
0
}
329
/**
330
 * fu_struct_ccgx_dmc_dock_identity_get_vendor_string: (skip):
331
 **/
332
gchar *
333
fu_struct_ccgx_dmc_dock_identity_get_vendor_string(const FuStructCcgxDmcDockIdentity *st)
334
0
{
335
0
    g_return_val_if_fail(st != NULL, NULL);
336
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 8, 32, NULL);
337
0
}
338
/**
339
 * fu_struct_ccgx_dmc_dock_identity_get_product_string: (skip):
340
 **/
341
gchar *
342
fu_struct_ccgx_dmc_dock_identity_get_product_string(const FuStructCcgxDmcDockIdentity *st)
343
0
{
344
0
    g_return_val_if_fail(st != NULL, NULL);
345
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 40, 32, NULL);
346
0
}
347
/**
348
 * fu_struct_ccgx_dmc_dock_identity_get_custom_meta_data_flag: (skip):
349
 **/
350
guint8
351
fu_struct_ccgx_dmc_dock_identity_get_custom_meta_data_flag(const FuStructCcgxDmcDockIdentity *st)
352
0
{
353
0
    g_return_val_if_fail(st != NULL, 0x0);
354
0
    return st->buf->data[72];
355
0
}
356
/**
357
 * fu_struct_ccgx_dmc_dock_identity_get_model: (skip):
358
 **/
359
guint8
360
fu_struct_ccgx_dmc_dock_identity_get_model(const FuStructCcgxDmcDockIdentity *st)
361
0
{
362
0
    g_return_val_if_fail(st != NULL, 0x0);
363
0
    return st->buf->data[73];
364
0
}
365
366
/* setters */
367
/**
368
 * fu_struct_ccgx_dmc_dock_identity_set_structure_version: (skip):
369
 **/
370
void
371
fu_struct_ccgx_dmc_dock_identity_set_structure_version(FuStructCcgxDmcDockIdentity *st, guint8 value)
372
0
{
373
0
    g_return_if_fail(st != NULL);
374
0
    st->buf->data[0] = value;
375
0
}
376
/**
377
 * fu_struct_ccgx_dmc_dock_identity_set_cdtt_version: (skip):
378
 **/
379
void
380
fu_struct_ccgx_dmc_dock_identity_set_cdtt_version(FuStructCcgxDmcDockIdentity *st, guint8 value)
381
0
{
382
0
    g_return_if_fail(st != NULL);
383
0
    st->buf->data[1] = value;
384
0
}
385
/**
386
 * fu_struct_ccgx_dmc_dock_identity_set_vid: (skip):
387
 **/
388
void
389
fu_struct_ccgx_dmc_dock_identity_set_vid(FuStructCcgxDmcDockIdentity *st, guint16 value)
390
0
{
391
0
    g_return_if_fail(st != NULL);
392
0
    fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN);
393
0
}
394
/**
395
 * fu_struct_ccgx_dmc_dock_identity_set_pid: (skip):
396
 **/
397
void
398
fu_struct_ccgx_dmc_dock_identity_set_pid(FuStructCcgxDmcDockIdentity *st, guint16 value)
399
0
{
400
0
    g_return_if_fail(st != NULL);
401
0
    fu_memwrite_uint16(st->buf->data + 4, value, G_LITTLE_ENDIAN);
402
0
}
403
/**
404
 * fu_struct_ccgx_dmc_dock_identity_set_device_id: (skip):
405
 **/
406
void
407
fu_struct_ccgx_dmc_dock_identity_set_device_id(FuStructCcgxDmcDockIdentity *st, guint16 value)
408
0
{
409
0
    g_return_if_fail(st != NULL);
410
0
    fu_memwrite_uint16(st->buf->data + 6, value, G_LITTLE_ENDIAN);
411
0
}
412
/**
413
 * fu_struct_ccgx_dmc_dock_identity_set_vendor_string: (skip):
414
 **/
415
gboolean
416
fu_struct_ccgx_dmc_dock_identity_set_vendor_string(FuStructCcgxDmcDockIdentity *st, const gchar *value, GError **error)
417
0
{
418
0
    gsize len;
419
0
    g_return_val_if_fail(st != NULL, FALSE);
420
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
421
0
    if (value == NULL) {
422
0
        memset(st->buf->data + 8, 0x0, 32);
423
0
        return TRUE;
424
0
    }
425
0
    len = strlen(value);
426
0
    if (len > 32) {
427
0
        g_set_error(error,
428
0
                    FWUPD_ERROR,
429
0
                    FWUPD_ERROR_INVALID_DATA,
430
0
                    "string '%s' (0x%x bytes) does not fit in FuStructCcgxDmcDockIdentity.vendor_string (0x%x bytes)",
431
0
                    value, (guint) len, (guint) 32);
432
0
        return FALSE;
433
0
    }
434
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 8, (const guint8 *)value, len, 0x0, len, error);
435
0
}
436
/**
437
 * fu_struct_ccgx_dmc_dock_identity_set_product_string: (skip):
438
 **/
439
gboolean
440
fu_struct_ccgx_dmc_dock_identity_set_product_string(FuStructCcgxDmcDockIdentity *st, const gchar *value, GError **error)
441
0
{
442
0
    gsize len;
443
0
    g_return_val_if_fail(st != NULL, FALSE);
444
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
445
0
    if (value == NULL) {
446
0
        memset(st->buf->data + 40, 0x0, 32);
447
0
        return TRUE;
448
0
    }
449
0
    len = strlen(value);
450
0
    if (len > 32) {
451
0
        g_set_error(error,
452
0
                    FWUPD_ERROR,
453
0
                    FWUPD_ERROR_INVALID_DATA,
454
0
                    "string '%s' (0x%x bytes) does not fit in FuStructCcgxDmcDockIdentity.product_string (0x%x bytes)",
455
0
                    value, (guint) len, (guint) 32);
456
0
        return FALSE;
457
0
    }
458
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 40, (const guint8 *)value, len, 0x0, len, error);
459
0
}
460
/**
461
 * fu_struct_ccgx_dmc_dock_identity_set_custom_meta_data_flag: (skip):
462
 **/
463
void
464
fu_struct_ccgx_dmc_dock_identity_set_custom_meta_data_flag(FuStructCcgxDmcDockIdentity *st, guint8 value)
465
0
{
466
0
    g_return_if_fail(st != NULL);
467
0
    st->buf->data[72] = value;
468
0
}
469
/**
470
 * fu_struct_ccgx_dmc_dock_identity_set_model: (skip):
471
 **/
472
void
473
fu_struct_ccgx_dmc_dock_identity_set_model(FuStructCcgxDmcDockIdentity *st, guint8 value)
474
0
{
475
0
    g_return_if_fail(st != NULL);
476
0
    st->buf->data[73] = value;
477
0
}
478
/**
479
 * fu_struct_ccgx_dmc_dock_identity_new: (skip):
480
 **/
481
FuStructCcgxDmcDockIdentity *
482
fu_struct_ccgx_dmc_dock_identity_new(void)
483
0
{
484
0
    FuStructCcgxDmcDockIdentity *st = fu_struct_ccgx_dmc_dock_identity_new_internal();
485
0
    st->buf = g_byte_array_sized_new(74);
486
0
    fu_byte_array_set_size(st->buf, 74, 0x0);
487
0
    return st;
488
0
}
489
/**
490
 * fu_struct_ccgx_dmc_devx_status_ref: (skip):
491
 **/
492
FuStructCcgxDmcDevxStatus *
493
fu_struct_ccgx_dmc_devx_status_ref(FuStructCcgxDmcDevxStatus *st)
494
0
{
495
0
    g_return_val_if_fail(st != NULL, NULL);
496
0
    st->refcount++;
497
0
    return st;
498
0
}
499
/**
500
 * fu_struct_ccgx_dmc_devx_status_unref: (skip):
501
 **/
502
void
503
fu_struct_ccgx_dmc_devx_status_unref(FuStructCcgxDmcDevxStatus *st)
504
0
{
505
0
    g_return_if_fail(st != NULL);
506
0
    if (st->refcount == 0) {
507
0
        g_critical("FuStructCcgxDmcDevxStatus refcount already zero");
508
0
        return;
509
0
    }
510
0
    if (--st->refcount > 0)
511
0
        return;
512
0
    if (st->buf != NULL)
513
0
        g_byte_array_unref(st->buf);
514
0
    g_free(st);
515
0
}
516
/**
517
 * fu_struct_ccgx_dmc_devx_status_new_internal: (skip):
518
 **/
519
static FuStructCcgxDmcDevxStatus *
520
fu_struct_ccgx_dmc_devx_status_new_internal(void)
521
0
{
522
0
    FuStructCcgxDmcDevxStatus *st = g_new0(FuStructCcgxDmcDevxStatus, 1);
523
0
    st->refcount = 1;
524
0
    return st;
525
0
}
526
527
/* getters */
528
/**
529
 * fu_struct_ccgx_dmc_devx_status_get_device_type: (skip):
530
 **/
531
FuCcgxDmcDevxDeviceType
532
fu_struct_ccgx_dmc_devx_status_get_device_type(const FuStructCcgxDmcDevxStatus *st)
533
0
{
534
0
    g_return_val_if_fail(st != NULL, 0x0);
535
0
    return st->buf->data[0];
536
0
}
537
/**
538
 * fu_struct_ccgx_dmc_devx_status_get_component_id: (skip):
539
 **/
540
guint8
541
fu_struct_ccgx_dmc_devx_status_get_component_id(const FuStructCcgxDmcDevxStatus *st)
542
0
{
543
0
    g_return_val_if_fail(st != NULL, 0x0);
544
0
    return st->buf->data[1];
545
0
}
546
/**
547
 * fu_struct_ccgx_dmc_devx_status_get_image_mode: (skip):
548
 **/
549
FuCcgxDmcImgMode
550
fu_struct_ccgx_dmc_devx_status_get_image_mode(const FuStructCcgxDmcDevxStatus *st)
551
0
{
552
0
    g_return_val_if_fail(st != NULL, 0x0);
553
0
    return st->buf->data[2];
554
0
}
555
/**
556
 * fu_struct_ccgx_dmc_devx_status_get_current_image: (skip):
557
 **/
558
guint8
559
fu_struct_ccgx_dmc_devx_status_get_current_image(const FuStructCcgxDmcDevxStatus *st)
560
0
{
561
0
    g_return_val_if_fail(st != NULL, 0x0);
562
0
    return st->buf->data[3];
563
0
}
564
/**
565
 * fu_struct_ccgx_dmc_devx_status_get_img_status: (skip):
566
 **/
567
guint8
568
fu_struct_ccgx_dmc_devx_status_get_img_status(const FuStructCcgxDmcDevxStatus *st)
569
0
{
570
0
    g_return_val_if_fail(st != NULL, 0x0);
571
0
    return st->buf->data[4];
572
0
}
573
/**
574
 * fu_struct_ccgx_dmc_devx_status_get_fw_version: (skip):
575
 **/
576
const guint8 *
577
fu_struct_ccgx_dmc_devx_status_get_fw_version(const FuStructCcgxDmcDevxStatus *st, gsize *bufsz)
578
0
{
579
0
    g_return_val_if_fail(st != NULL, NULL);
580
0
    if (bufsz != NULL)
581
0
        *bufsz = 24;
582
0
    return st->buf->data + 8;
583
0
}
584
585
/* setters */
586
/**
587
 * fu_struct_ccgx_dmc_devx_status_to_string: (skip):
588
 **/
589
static gchar *
590
fu_struct_ccgx_dmc_devx_status_to_string(const FuStructCcgxDmcDevxStatus *st)
591
0
{
592
0
    g_autoptr(GString) str = g_string_new("FuStructCcgxDmcDevxStatus:\n");
593
0
    g_return_val_if_fail(st != NULL, NULL);
594
0
    {
595
0
        const gchar *tmp = fu_ccgx_dmc_devx_device_type_to_string(fu_struct_ccgx_dmc_devx_status_get_device_type(st));
596
0
        if (tmp != NULL) {
597
0
            g_string_append_printf(str, "  device_type: 0x%x [%s]\n", (guint) fu_struct_ccgx_dmc_devx_status_get_device_type(st), tmp);
598
0
        } else {
599
0
            g_string_append_printf(str, "  device_type: 0x%x\n", (guint) fu_struct_ccgx_dmc_devx_status_get_device_type(st));
600
0
        }
601
0
    }
602
0
    g_string_append_printf(str, "  component_id: 0x%x\n",
603
0
                           (guint) fu_struct_ccgx_dmc_devx_status_get_component_id(st));
604
0
    {
605
0
        const gchar *tmp = fu_ccgx_dmc_img_mode_to_string(fu_struct_ccgx_dmc_devx_status_get_image_mode(st));
606
0
        if (tmp != NULL) {
607
0
            g_string_append_printf(str, "  image_mode: 0x%x [%s]\n", (guint) fu_struct_ccgx_dmc_devx_status_get_image_mode(st), tmp);
608
0
        } else {
609
0
            g_string_append_printf(str, "  image_mode: 0x%x\n", (guint) fu_struct_ccgx_dmc_devx_status_get_image_mode(st));
610
0
        }
611
0
    }
612
0
    g_string_append_printf(str, "  current_image: 0x%x\n",
613
0
                           (guint) fu_struct_ccgx_dmc_devx_status_get_current_image(st));
614
0
    g_string_append_printf(str, "  img_status: 0x%x\n",
615
0
                           (guint) fu_struct_ccgx_dmc_devx_status_get_img_status(st));
616
0
    {
617
0
        gsize bufsz = 0;
618
0
        const guint8 *buf = fu_struct_ccgx_dmc_devx_status_get_fw_version(st, &bufsz);
619
0
        g_autoptr(GString) tmp = g_string_new(NULL);
620
0
        for (gsize i = 0; i < bufsz; i++)
621
0
            g_string_append_printf(tmp, "%02X", buf[i]);
622
0
        g_string_append_printf(str, "  fw_version: 0x%s\n", tmp->str);
623
0
    }
624
0
    if (str->len > 0)
625
0
        g_string_set_size(str, str->len - 1);
626
0
    return g_string_free(g_steal_pointer(&str), FALSE);
627
0
}
628
static gboolean
629
fu_struct_ccgx_dmc_devx_status_parse_internal(FuStructCcgxDmcDevxStatus *st, GError **error)
630
0
{
631
0
    if (g_log_get_debug_enabled()) {
632
0
        g_autofree gchar *str = fu_struct_ccgx_dmc_devx_status_to_string(st);
633
0
        g_debug("%s", str);
634
0
    }
635
0
    return TRUE;
636
0
}
637
638
/**
639
 * fu_struct_ccgx_dmc_devx_status_parse: (skip):
640
 **/
641
FuStructCcgxDmcDevxStatus *
642
fu_struct_ccgx_dmc_devx_status_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
643
0
{
644
0
    g_autoptr(FuStructCcgxDmcDevxStatus) st = fu_struct_ccgx_dmc_devx_status_new_internal();
645
0
    g_return_val_if_fail(buf != NULL, NULL);
646
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
647
0
    if (!fu_memchk_read(bufsz, offset, 32, error)) {
648
0
        g_prefix_error_literal(error, "invalid struct FuStructCcgxDmcDevxStatus: ");
649
0
        return NULL;
650
0
    }
651
0
    st->buf = g_byte_array_new();
652
0
    g_byte_array_append(st->buf, buf + offset, 32);
653
0
    if (!fu_struct_ccgx_dmc_devx_status_parse_internal(st, error))
654
0
        return NULL;
655
0
    return g_steal_pointer(&st);
656
0
}
657
/**
658
 * fu_struct_ccgx_dmc_dock_status_ref: (skip):
659
 **/
660
FuStructCcgxDmcDockStatus *
661
fu_struct_ccgx_dmc_dock_status_ref(FuStructCcgxDmcDockStatus *st)
662
0
{
663
0
    g_return_val_if_fail(st != NULL, NULL);
664
0
    st->refcount++;
665
0
    return st;
666
0
}
667
/**
668
 * fu_struct_ccgx_dmc_dock_status_unref: (skip):
669
 **/
670
void
671
fu_struct_ccgx_dmc_dock_status_unref(FuStructCcgxDmcDockStatus *st)
672
0
{
673
0
    g_return_if_fail(st != NULL);
674
0
    if (st->refcount == 0) {
675
0
        g_critical("FuStructCcgxDmcDockStatus refcount already zero");
676
0
        return;
677
0
    }
678
0
    if (--st->refcount > 0)
679
0
        return;
680
0
    if (st->buf != NULL)
681
0
        g_byte_array_unref(st->buf);
682
0
    g_free(st);
683
0
}
684
/**
685
 * fu_struct_ccgx_dmc_dock_status_new_internal: (skip):
686
 **/
687
static FuStructCcgxDmcDockStatus *
688
fu_struct_ccgx_dmc_dock_status_new_internal(void)
689
0
{
690
0
    FuStructCcgxDmcDockStatus *st = g_new0(FuStructCcgxDmcDockStatus, 1);
691
0
    st->refcount = 1;
692
0
    return st;
693
0
}
694
695
/* getters */
696
/**
697
 * fu_struct_ccgx_dmc_dock_status_get_device_status: (skip):
698
 **/
699
FuCcgxDmcDeviceStatus
700
fu_struct_ccgx_dmc_dock_status_get_device_status(const FuStructCcgxDmcDockStatus *st)
701
0
{
702
0
    g_return_val_if_fail(st != NULL, 0x0);
703
0
    return st->buf->data[0];
704
0
}
705
/**
706
 * fu_struct_ccgx_dmc_dock_status_get_device_count: (skip):
707
 **/
708
guint8
709
fu_struct_ccgx_dmc_dock_status_get_device_count(const FuStructCcgxDmcDockStatus *st)
710
0
{
711
0
    g_return_val_if_fail(st != NULL, 0x0);
712
0
    return st->buf->data[1];
713
0
}
714
/**
715
 * fu_struct_ccgx_dmc_dock_status_get_status_length: (skip):
716
 **/
717
guint16
718
fu_struct_ccgx_dmc_dock_status_get_status_length(const FuStructCcgxDmcDockStatus *st)
719
0
{
720
0
    g_return_val_if_fail(st != NULL, 0x0);
721
0
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
722
0
}
723
/**
724
 * fu_struct_ccgx_dmc_dock_status_get_composite_version: (skip):
725
 **/
726
guint32
727
fu_struct_ccgx_dmc_dock_status_get_composite_version(const FuStructCcgxDmcDockStatus *st)
728
0
{
729
0
    g_return_val_if_fail(st != NULL, 0x0);
730
0
    return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN);
731
0
}
732
733
/* setters */
734
/**
735
 * fu_struct_ccgx_dmc_dock_status_set_device_status: (skip):
736
 **/
737
void
738
fu_struct_ccgx_dmc_dock_status_set_device_status(FuStructCcgxDmcDockStatus *st, FuCcgxDmcDeviceStatus value)
739
0
{
740
0
    g_return_if_fail(st != NULL);
741
0
    st->buf->data[0] = value;
742
0
}
743
/**
744
 * fu_struct_ccgx_dmc_dock_status_set_device_count: (skip):
745
 **/
746
void
747
fu_struct_ccgx_dmc_dock_status_set_device_count(FuStructCcgxDmcDockStatus *st, guint8 value)
748
0
{
749
0
    g_return_if_fail(st != NULL);
750
0
    st->buf->data[1] = value;
751
0
}
752
/**
753
 * fu_struct_ccgx_dmc_dock_status_set_status_length: (skip):
754
 **/
755
void
756
fu_struct_ccgx_dmc_dock_status_set_status_length(FuStructCcgxDmcDockStatus *st, guint16 value)
757
0
{
758
0
    g_return_if_fail(st != NULL);
759
0
    fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN);
760
0
}
761
/**
762
 * fu_struct_ccgx_dmc_dock_status_set_composite_version: (skip):
763
 **/
764
void
765
fu_struct_ccgx_dmc_dock_status_set_composite_version(FuStructCcgxDmcDockStatus *st, guint32 value)
766
0
{
767
0
    g_return_if_fail(st != NULL);
768
0
    fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN);
769
0
}
770
/**
771
 * fu_struct_ccgx_dmc_dock_status_new: (skip):
772
 **/
773
FuStructCcgxDmcDockStatus *
774
fu_struct_ccgx_dmc_dock_status_new(void)
775
0
{
776
0
    FuStructCcgxDmcDockStatus *st = fu_struct_ccgx_dmc_dock_status_new_internal();
777
0
    st->buf = g_byte_array_sized_new(8);
778
0
    fu_byte_array_set_size(st->buf, 8, 0x0);
779
0
    return st;
780
0
}
781
/**
782
 * fu_struct_ccgx_dmc_int_rqt_ref: (skip):
783
 **/
784
FuStructCcgxDmcIntRqt *
785
fu_struct_ccgx_dmc_int_rqt_ref(FuStructCcgxDmcIntRqt *st)
786
0
{
787
0
    g_return_val_if_fail(st != NULL, NULL);
788
0
    st->refcount++;
789
0
    return st;
790
0
}
791
/**
792
 * fu_struct_ccgx_dmc_int_rqt_unref: (skip):
793
 **/
794
void
795
fu_struct_ccgx_dmc_int_rqt_unref(FuStructCcgxDmcIntRqt *st)
796
0
{
797
0
    g_return_if_fail(st != NULL);
798
0
    if (st->refcount == 0) {
799
0
        g_critical("FuStructCcgxDmcIntRqt refcount already zero");
800
0
        return;
801
0
    }
802
0
    if (--st->refcount > 0)
803
0
        return;
804
0
    if (st->buf != NULL)
805
0
        g_byte_array_unref(st->buf);
806
0
    g_free(st);
807
0
}
808
/**
809
 * fu_struct_ccgx_dmc_int_rqt_new_internal: (skip):
810
 **/
811
static FuStructCcgxDmcIntRqt *
812
fu_struct_ccgx_dmc_int_rqt_new_internal(void)
813
0
{
814
0
    FuStructCcgxDmcIntRqt *st = g_new0(FuStructCcgxDmcIntRqt, 1);
815
0
    st->refcount = 1;
816
0
    return st;
817
0
}
818
819
/* getters */
820
/**
821
 * fu_struct_ccgx_dmc_int_rqt_get_opcode: (skip):
822
 **/
823
FuCcgxDmcIntOpcode
824
fu_struct_ccgx_dmc_int_rqt_get_opcode(const FuStructCcgxDmcIntRqt *st)
825
0
{
826
0
    g_return_val_if_fail(st != NULL, 0x0);
827
0
    return st->buf->data[0];
828
0
}
829
/**
830
 * fu_struct_ccgx_dmc_int_rqt_get_length: (skip):
831
 **/
832
guint8
833
fu_struct_ccgx_dmc_int_rqt_get_length(const FuStructCcgxDmcIntRqt *st)
834
0
{
835
0
    g_return_val_if_fail(st != NULL, 0x0);
836
0
    return st->buf->data[1];
837
0
}
838
/**
839
 * fu_struct_ccgx_dmc_int_rqt_get_data: (skip):
840
 **/
841
const guint8 *
842
fu_struct_ccgx_dmc_int_rqt_get_data(const FuStructCcgxDmcIntRqt *st, gsize *bufsz)
843
0
{
844
0
    g_return_val_if_fail(st != NULL, NULL);
845
0
    if (bufsz != NULL)
846
0
        *bufsz = 8;
847
0
    return st->buf->data + 2;
848
0
}
849
850
/* setters */
851
/**
852
 * fu_struct_ccgx_dmc_int_rqt_set_opcode: (skip):
853
 **/
854
void
855
fu_struct_ccgx_dmc_int_rqt_set_opcode(FuStructCcgxDmcIntRqt *st, FuCcgxDmcIntOpcode value)
856
0
{
857
0
    g_return_if_fail(st != NULL);
858
0
    st->buf->data[0] = value;
859
0
}
860
/**
861
 * fu_struct_ccgx_dmc_int_rqt_set_length: (skip):
862
 **/
863
void
864
fu_struct_ccgx_dmc_int_rqt_set_length(FuStructCcgxDmcIntRqt *st, guint8 value)
865
0
{
866
0
    g_return_if_fail(st != NULL);
867
0
    st->buf->data[1] = value;
868
0
}
869
/**
870
 * fu_struct_ccgx_dmc_int_rqt_set_data: (skip):
871
 **/
872
gboolean
873
fu_struct_ccgx_dmc_int_rqt_set_data(FuStructCcgxDmcIntRqt *st, const guint8 *buf, gsize bufsz, GError **error)
874
0
{
875
0
    g_return_val_if_fail(st != NULL, FALSE);
876
0
    g_return_val_if_fail(buf != NULL, FALSE);
877
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
878
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 2, buf, bufsz, 0x0, bufsz, error);
879
0
}
880
/**
881
 * fu_struct_ccgx_dmc_int_rqt_new: (skip):
882
 **/
883
FuStructCcgxDmcIntRqt *
884
fu_struct_ccgx_dmc_int_rqt_new(void)
885
0
{
886
0
    FuStructCcgxDmcIntRqt *st = fu_struct_ccgx_dmc_int_rqt_new_internal();
887
0
    st->buf = g_byte_array_sized_new(10);
888
0
    fu_byte_array_set_size(st->buf, 10, 0x0);
889
0
    return st;
890
0
}
891
/**
892
 * fu_struct_ccgx_dmc_fwct_info_ref: (skip):
893
 **/
894
FuStructCcgxDmcFwctInfo *
895
fu_struct_ccgx_dmc_fwct_info_ref(FuStructCcgxDmcFwctInfo *st)
896
0
{
897
0
    g_return_val_if_fail(st != NULL, NULL);
898
0
    st->refcount++;
899
0
    return st;
900
0
}
901
/**
902
 * fu_struct_ccgx_dmc_fwct_info_unref: (skip):
903
 **/
904
void
905
fu_struct_ccgx_dmc_fwct_info_unref(FuStructCcgxDmcFwctInfo *st)
906
1.02k
{
907
1.02k
    g_return_if_fail(st != NULL);
908
1.02k
    if (st->refcount == 0) {
909
0
        g_critical("FuStructCcgxDmcFwctInfo refcount already zero");
910
0
        return;
911
0
    }
912
1.02k
    if (--st->refcount > 0)
913
0
        return;
914
1.02k
    if (st->buf != NULL)
915
1.02k
        g_byte_array_unref(st->buf);
916
1.02k
    g_free(st);
917
1.02k
}
918
/**
919
 * fu_struct_ccgx_dmc_fwct_info_new_internal: (skip):
920
 **/
921
static FuStructCcgxDmcFwctInfo *
922
fu_struct_ccgx_dmc_fwct_info_new_internal(void)
923
1.02k
{
924
1.02k
    FuStructCcgxDmcFwctInfo *st = g_new0(FuStructCcgxDmcFwctInfo, 1);
925
1.02k
    st->refcount = 1;
926
1.02k
    return st;
927
1.02k
}
928
929
/* getters */
930
/**
931
 * fu_struct_ccgx_dmc_fwct_info_get_signature: (skip):
932
 **/
933
static gchar *
934
fu_struct_ccgx_dmc_fwct_info_get_signature(const FuStructCcgxDmcFwctInfo *st)
935
44
{
936
44
    g_return_val_if_fail(st != NULL, NULL);
937
44
    return fu_memstrsafe(st->buf->data, st->buf->len, 0, 4, NULL);
938
44
}
939
/**
940
 * fu_struct_ccgx_dmc_fwct_info_get_size: (skip):
941
 **/
942
guint16
943
fu_struct_ccgx_dmc_fwct_info_get_size(const FuStructCcgxDmcFwctInfo *st)
944
457
{
945
457
    g_return_val_if_fail(st != NULL, 0x0);
946
457
    return fu_memread_uint16(st->buf->data + 4, G_LITTLE_ENDIAN);
947
457
}
948
/**
949
 * fu_struct_ccgx_dmc_fwct_info_get_checksum: (skip):
950
 **/
951
guint8
952
fu_struct_ccgx_dmc_fwct_info_get_checksum(const FuStructCcgxDmcFwctInfo *st)
953
0
{
954
0
    g_return_val_if_fail(st != NULL, 0x0);
955
0
    return st->buf->data[6];
956
0
}
957
/**
958
 * fu_struct_ccgx_dmc_fwct_info_get_version: (skip):
959
 **/
960
guint8
961
fu_struct_ccgx_dmc_fwct_info_get_version(const FuStructCcgxDmcFwctInfo *st)
962
0
{
963
0
    g_return_val_if_fail(st != NULL, 0x0);
964
0
    return st->buf->data[7];
965
0
}
966
/**
967
 * fu_struct_ccgx_dmc_fwct_info_get_custom_meta_type: (skip):
968
 **/
969
guint8
970
fu_struct_ccgx_dmc_fwct_info_get_custom_meta_type(const FuStructCcgxDmcFwctInfo *st)
971
0
{
972
0
    g_return_val_if_fail(st != NULL, 0x0);
973
0
    return st->buf->data[8];
974
0
}
975
/**
976
 * fu_struct_ccgx_dmc_fwct_info_get_cdtt_version: (skip):
977
 **/
978
guint8
979
fu_struct_ccgx_dmc_fwct_info_get_cdtt_version(const FuStructCcgxDmcFwctInfo *st)
980
0
{
981
0
    g_return_val_if_fail(st != NULL, 0x0);
982
0
    return st->buf->data[9];
983
0
}
984
/**
985
 * fu_struct_ccgx_dmc_fwct_info_get_vid: (skip):
986
 **/
987
guint16
988
fu_struct_ccgx_dmc_fwct_info_get_vid(const FuStructCcgxDmcFwctInfo *st)
989
0
{
990
0
    g_return_val_if_fail(st != NULL, 0x0);
991
0
    return fu_memread_uint16(st->buf->data + 10, G_LITTLE_ENDIAN);
992
0
}
993
/**
994
 * fu_struct_ccgx_dmc_fwct_info_get_pid: (skip):
995
 **/
996
guint16
997
fu_struct_ccgx_dmc_fwct_info_get_pid(const FuStructCcgxDmcFwctInfo *st)
998
0
{
999
0
    g_return_val_if_fail(st != NULL, 0x0);
1000
0
    return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN);
1001
0
}
1002
/**
1003
 * fu_struct_ccgx_dmc_fwct_info_get_device_id: (skip):
1004
 **/
1005
guint16
1006
fu_struct_ccgx_dmc_fwct_info_get_device_id(const FuStructCcgxDmcFwctInfo *st)
1007
0
{
1008
0
    g_return_val_if_fail(st != NULL, 0x0);
1009
0
    return fu_memread_uint16(st->buf->data + 14, G_LITTLE_ENDIAN);
1010
0
}
1011
/**
1012
 * fu_struct_ccgx_dmc_fwct_info_get_composite_version: (skip):
1013
 **/
1014
guint32
1015
fu_struct_ccgx_dmc_fwct_info_get_composite_version(const FuStructCcgxDmcFwctInfo *st)
1016
451
{
1017
451
    g_return_val_if_fail(st != NULL, 0x0);
1018
451
    return fu_memread_uint32(st->buf->data + 32, G_LITTLE_ENDIAN);
1019
451
}
1020
/**
1021
 * fu_struct_ccgx_dmc_fwct_info_get_image_count: (skip):
1022
 **/
1023
guint8
1024
fu_struct_ccgx_dmc_fwct_info_get_image_count(const FuStructCcgxDmcFwctInfo *st)
1025
384
{
1026
384
    g_return_val_if_fail(st != NULL, 0x0);
1027
384
    return st->buf->data[36];
1028
384
}
1029
1030
/* setters */
1031
/**
1032
 * fu_struct_ccgx_dmc_fwct_info_set_signature: (skip):
1033
 **/
1034
static gboolean
1035
fu_struct_ccgx_dmc_fwct_info_set_signature(FuStructCcgxDmcFwctInfo *st, const gchar *value, GError **error)
1036
42
{
1037
42
    gsize len;
1038
42
    g_return_val_if_fail(st != NULL, FALSE);
1039
42
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
1040
42
    if (value == NULL) {
1041
0
        memset(st->buf->data + 0, 0x0, 4);
1042
0
        return TRUE;
1043
0
    }
1044
42
    len = strlen(value);
1045
42
    if (len > 4) {
1046
0
        g_set_error(error,
1047
0
                    FWUPD_ERROR,
1048
0
                    FWUPD_ERROR_INVALID_DATA,
1049
0
                    "string '%s' (0x%x bytes) does not fit in FuStructCcgxDmcFwctInfo.signature (0x%x bytes)",
1050
0
                    value, (guint) len, (guint) 4);
1051
0
        return FALSE;
1052
0
    }
1053
42
    return fu_memcpy_safe(st->buf->data, st->buf->len, 0, (const guint8 *)value, len, 0x0, len, error);
1054
42
}
1055
/**
1056
 * fu_struct_ccgx_dmc_fwct_info_set_size: (skip):
1057
 **/
1058
void
1059
fu_struct_ccgx_dmc_fwct_info_set_size(FuStructCcgxDmcFwctInfo *st, guint16 value)
1060
42
{
1061
42
    g_return_if_fail(st != NULL);
1062
42
    fu_memwrite_uint16(st->buf->data + 4, value, G_LITTLE_ENDIAN);
1063
42
}
1064
/**
1065
 * fu_struct_ccgx_dmc_fwct_info_set_checksum: (skip):
1066
 **/
1067
void
1068
fu_struct_ccgx_dmc_fwct_info_set_checksum(FuStructCcgxDmcFwctInfo *st, guint8 value)
1069
0
{
1070
0
    g_return_if_fail(st != NULL);
1071
0
    st->buf->data[6] = value;
1072
0
}
1073
/**
1074
 * fu_struct_ccgx_dmc_fwct_info_set_version: (skip):
1075
 **/
1076
void
1077
fu_struct_ccgx_dmc_fwct_info_set_version(FuStructCcgxDmcFwctInfo *st, guint8 value)
1078
42
{
1079
42
    g_return_if_fail(st != NULL);
1080
42
    st->buf->data[7] = value;
1081
42
}
1082
/**
1083
 * fu_struct_ccgx_dmc_fwct_info_set_custom_meta_type: (skip):
1084
 **/
1085
void
1086
fu_struct_ccgx_dmc_fwct_info_set_custom_meta_type(FuStructCcgxDmcFwctInfo *st, guint8 value)
1087
42
{
1088
42
    g_return_if_fail(st != NULL);
1089
42
    st->buf->data[8] = value;
1090
42
}
1091
/**
1092
 * fu_struct_ccgx_dmc_fwct_info_set_cdtt_version: (skip):
1093
 **/
1094
void
1095
fu_struct_ccgx_dmc_fwct_info_set_cdtt_version(FuStructCcgxDmcFwctInfo *st, guint8 value)
1096
42
{
1097
42
    g_return_if_fail(st != NULL);
1098
42
    st->buf->data[9] = value;
1099
42
}
1100
/**
1101
 * fu_struct_ccgx_dmc_fwct_info_set_vid: (skip):
1102
 **/
1103
void
1104
fu_struct_ccgx_dmc_fwct_info_set_vid(FuStructCcgxDmcFwctInfo *st, guint16 value)
1105
0
{
1106
0
    g_return_if_fail(st != NULL);
1107
0
    fu_memwrite_uint16(st->buf->data + 10, value, G_LITTLE_ENDIAN);
1108
0
}
1109
/**
1110
 * fu_struct_ccgx_dmc_fwct_info_set_pid: (skip):
1111
 **/
1112
void
1113
fu_struct_ccgx_dmc_fwct_info_set_pid(FuStructCcgxDmcFwctInfo *st, guint16 value)
1114
0
{
1115
0
    g_return_if_fail(st != NULL);
1116
0
    fu_memwrite_uint16(st->buf->data + 12, value, G_LITTLE_ENDIAN);
1117
0
}
1118
/**
1119
 * fu_struct_ccgx_dmc_fwct_info_set_device_id: (skip):
1120
 **/
1121
void
1122
fu_struct_ccgx_dmc_fwct_info_set_device_id(FuStructCcgxDmcFwctInfo *st, guint16 value)
1123
42
{
1124
42
    g_return_if_fail(st != NULL);
1125
42
    fu_memwrite_uint16(st->buf->data + 14, value, G_LITTLE_ENDIAN);
1126
42
}
1127
/**
1128
 * fu_struct_ccgx_dmc_fwct_info_set_composite_version: (skip):
1129
 **/
1130
void
1131
fu_struct_ccgx_dmc_fwct_info_set_composite_version(FuStructCcgxDmcFwctInfo *st, guint32 value)
1132
42
{
1133
42
    g_return_if_fail(st != NULL);
1134
42
    fu_memwrite_uint32(st->buf->data + 32, value, G_LITTLE_ENDIAN);
1135
42
}
1136
/**
1137
 * fu_struct_ccgx_dmc_fwct_info_set_image_count: (skip):
1138
 **/
1139
void
1140
fu_struct_ccgx_dmc_fwct_info_set_image_count(FuStructCcgxDmcFwctInfo *st, guint8 value)
1141
42
{
1142
42
    g_return_if_fail(st != NULL);
1143
42
    st->buf->data[36] = value;
1144
42
}
1145
/**
1146
 * fu_struct_ccgx_dmc_fwct_info_new: (skip):
1147
 **/
1148
FuStructCcgxDmcFwctInfo *
1149
fu_struct_ccgx_dmc_fwct_info_new(void)
1150
42
{
1151
42
    FuStructCcgxDmcFwctInfo *st = fu_struct_ccgx_dmc_fwct_info_new_internal();
1152
42
    st->buf = g_byte_array_sized_new(40);
1153
42
    fu_byte_array_set_size(st->buf, 40, 0x0);
1154
42
    fu_struct_ccgx_dmc_fwct_info_set_signature(st, "FWCT", NULL);
1155
42
    return st;
1156
42
}
1157
/**
1158
 * fu_struct_ccgx_dmc_fwct_info_to_string: (skip):
1159
 **/
1160
static gchar *
1161
fu_struct_ccgx_dmc_fwct_info_to_string(const FuStructCcgxDmcFwctInfo *st)
1162
0
{
1163
0
    g_autoptr(GString) str = g_string_new("FuStructCcgxDmcFwctInfo:\n");
1164
0
    g_return_val_if_fail(st != NULL, NULL);
1165
0
    {
1166
0
        g_autofree gchar *tmp = fu_struct_ccgx_dmc_fwct_info_get_signature(st);
1167
0
        if (tmp != NULL)
1168
0
            g_string_append_printf(str, "  signature: %s\n", tmp);
1169
0
    }
1170
0
    g_string_append_printf(str, "  size: 0x%x\n",
1171
0
                           (guint) fu_struct_ccgx_dmc_fwct_info_get_size(st));
1172
0
    g_string_append_printf(str, "  checksum: 0x%x\n",
1173
0
                           (guint) fu_struct_ccgx_dmc_fwct_info_get_checksum(st));
1174
0
    g_string_append_printf(str, "  version: 0x%x\n",
1175
0
                           (guint) fu_struct_ccgx_dmc_fwct_info_get_version(st));
1176
0
    g_string_append_printf(str, "  custom_meta_type: 0x%x\n",
1177
0
                           (guint) fu_struct_ccgx_dmc_fwct_info_get_custom_meta_type(st));
1178
0
    g_string_append_printf(str, "  cdtt_version: 0x%x\n",
1179
0
                           (guint) fu_struct_ccgx_dmc_fwct_info_get_cdtt_version(st));
1180
0
    g_string_append_printf(str, "  vid: 0x%x\n",
1181
0
                           (guint) fu_struct_ccgx_dmc_fwct_info_get_vid(st));
1182
0
    g_string_append_printf(str, "  pid: 0x%x\n",
1183
0
                           (guint) fu_struct_ccgx_dmc_fwct_info_get_pid(st));
1184
0
    g_string_append_printf(str, "  device_id: 0x%x\n",
1185
0
                           (guint) fu_struct_ccgx_dmc_fwct_info_get_device_id(st));
1186
0
    g_string_append_printf(str, "  composite_version: 0x%x\n",
1187
0
                           (guint) fu_struct_ccgx_dmc_fwct_info_get_composite_version(st));
1188
0
    g_string_append_printf(str, "  image_count: 0x%x\n",
1189
0
                           (guint) fu_struct_ccgx_dmc_fwct_info_get_image_count(st));
1190
0
    if (str->len > 0)
1191
0
        g_string_set_size(str, str->len - 1);
1192
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1193
0
}
1194
static gboolean
1195
fu_struct_ccgx_dmc_fwct_info_validate_internal(FuStructCcgxDmcFwctInfo *st, GError **error)
1196
958
{
1197
958
    g_return_val_if_fail(st != NULL, FALSE);
1198
958
    if (strncmp((const gchar *) (st->buf->data + 0), "FWCT", 4) != 0) {
1199
44
        g_autofree gchar *str = fu_struct_ccgx_dmc_fwct_info_get_signature(st);
1200
44
        g_set_error(error,
1201
44
                    FWUPD_ERROR,
1202
44
                    FWUPD_ERROR_INVALID_DATA,
1203
44
                    "constant FuStructCcgxDmcFwctInfo.signature was not valid, "
1204
44
                    "expected 'FWCT' and got '%s'",
1205
44
                    str);
1206
44
        return FALSE;
1207
44
    }
1208
914
    return TRUE;
1209
958
}
1210
/**
1211
 * fu_struct_ccgx_dmc_fwct_info_validate_stream: (skip):
1212
 **/
1213
gboolean
1214
fu_struct_ccgx_dmc_fwct_info_validate_stream(GInputStream *stream, gsize offset, GError **error)
1215
523
{
1216
523
    g_autoptr(FuStructCcgxDmcFwctInfo) st = fu_struct_ccgx_dmc_fwct_info_new_internal();
1217
523
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
1218
523
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
1219
523
    st->buf = fu_input_stream_read_byte_array(stream, offset, 40, NULL, error);
1220
523
    if (st->buf == NULL) {
1221
0
        g_prefix_error(error, "FuStructCcgxDmcFwctInfo failed read of 0x%x: ", (guint) 40);
1222
0
        return FALSE;
1223
0
    }
1224
523
    if (st->buf->len != 40) {
1225
22
        g_set_error(error,
1226
22
                    FWUPD_ERROR,
1227
22
                    FWUPD_ERROR_INVALID_DATA,
1228
22
                    "FuStructCcgxDmcFwctInfo requested 0x%x and got 0x%x",
1229
22
                    (guint) 40,
1230
22
                    (guint) st->buf->len);
1231
22
        return FALSE;
1232
22
    }
1233
501
    return fu_struct_ccgx_dmc_fwct_info_validate_internal(st, error);
1234
523
}
1235
static gboolean
1236
fu_struct_ccgx_dmc_fwct_info_parse_internal(FuStructCcgxDmcFwctInfo *st, GError **error)
1237
457
{
1238
457
    if (g_log_get_debug_enabled()) {
1239
0
        g_autofree gchar *str = fu_struct_ccgx_dmc_fwct_info_to_string(st);
1240
0
        g_debug("%s", str);
1241
0
    }
1242
457
    if (!fu_struct_ccgx_dmc_fwct_info_validate_internal(st, error))
1243
0
        return FALSE;
1244
457
    return TRUE;
1245
457
}
1246
/**
1247
 * fu_struct_ccgx_dmc_fwct_info_parse_stream: (skip):
1248
 **/
1249
FuStructCcgxDmcFwctInfo *
1250
fu_struct_ccgx_dmc_fwct_info_parse_stream(GInputStream *stream, gsize offset, GError **error)
1251
457
{
1252
457
    g_autoptr(FuStructCcgxDmcFwctInfo) st = fu_struct_ccgx_dmc_fwct_info_new_internal();
1253
457
    st->buf = fu_input_stream_read_byte_array(stream, offset, 40, NULL, error);
1254
457
    if (st->buf == NULL) {
1255
0
        g_prefix_error(error, "FuStructCcgxDmcFwctInfo failed read of 0x%x: ", (guint) 40);
1256
0
        return NULL;
1257
0
    }
1258
457
    if (st->buf->len != 40) {
1259
0
        g_set_error(error,
1260
0
                    FWUPD_ERROR,
1261
0
                    FWUPD_ERROR_INVALID_DATA,
1262
0
                    "FuStructCcgxDmcFwctInfo requested 0x%x and got 0x%x",
1263
0
                    (guint) 40,
1264
0
                    (guint) st->buf->len);
1265
0
        return NULL;
1266
0
    }
1267
457
    if (!fu_struct_ccgx_dmc_fwct_info_parse_internal(st, error))
1268
0
        return NULL;
1269
457
    return g_steal_pointer(&st);
1270
457
}
1271
/**
1272
 * fu_struct_ccgx_dmc_fwct_image_info_ref: (skip):
1273
 **/
1274
FuStructCcgxDmcFwctImageInfo *
1275
fu_struct_ccgx_dmc_fwct_image_info_ref(FuStructCcgxDmcFwctImageInfo *st)
1276
0
{
1277
0
    g_return_val_if_fail(st != NULL, NULL);
1278
0
    st->refcount++;
1279
0
    return st;
1280
0
}
1281
/**
1282
 * fu_struct_ccgx_dmc_fwct_image_info_unref: (skip):
1283
 **/
1284
void
1285
fu_struct_ccgx_dmc_fwct_image_info_unref(FuStructCcgxDmcFwctImageInfo *st)
1286
1.48k
{
1287
1.48k
    g_return_if_fail(st != NULL);
1288
1.48k
    if (st->refcount == 0) {
1289
0
        g_critical("FuStructCcgxDmcFwctImageInfo refcount already zero");
1290
0
        return;
1291
0
    }
1292
1.48k
    if (--st->refcount > 0)
1293
0
        return;
1294
1.48k
    if (st->buf != NULL)
1295
1.45k
        g_byte_array_unref(st->buf);
1296
1.48k
    g_free(st);
1297
1.48k
}
1298
/**
1299
 * fu_struct_ccgx_dmc_fwct_image_info_new_internal: (skip):
1300
 **/
1301
static FuStructCcgxDmcFwctImageInfo *
1302
fu_struct_ccgx_dmc_fwct_image_info_new_internal(void)
1303
1.48k
{
1304
1.48k
    FuStructCcgxDmcFwctImageInfo *st = g_new0(FuStructCcgxDmcFwctImageInfo, 1);
1305
1.48k
    st->refcount = 1;
1306
1.48k
    return st;
1307
1.48k
}
1308
1309
/* getters */
1310
/**
1311
 * fu_struct_ccgx_dmc_fwct_image_info_get_device_type: (skip):
1312
 **/
1313
guint8
1314
fu_struct_ccgx_dmc_fwct_image_info_get_device_type(const FuStructCcgxDmcFwctImageInfo *st)
1315
0
{
1316
0
    g_return_val_if_fail(st != NULL, 0x0);
1317
0
    return st->buf->data[0];
1318
0
}
1319
/**
1320
 * fu_struct_ccgx_dmc_fwct_image_info_get_img_type: (skip):
1321
 **/
1322
guint8
1323
fu_struct_ccgx_dmc_fwct_image_info_get_img_type(const FuStructCcgxDmcFwctImageInfo *st)
1324
0
{
1325
0
    g_return_val_if_fail(st != NULL, 0x0);
1326
0
    return st->buf->data[1];
1327
0
}
1328
/**
1329
 * fu_struct_ccgx_dmc_fwct_image_info_get_comp_id: (skip):
1330
 **/
1331
guint8
1332
fu_struct_ccgx_dmc_fwct_image_info_get_comp_id(const FuStructCcgxDmcFwctImageInfo *st)
1333
0
{
1334
0
    g_return_val_if_fail(st != NULL, 0x0);
1335
0
    return st->buf->data[2];
1336
0
}
1337
/**
1338
 * fu_struct_ccgx_dmc_fwct_image_info_get_row_size: (skip):
1339
 **/
1340
guint8
1341
fu_struct_ccgx_dmc_fwct_image_info_get_row_size(const FuStructCcgxDmcFwctImageInfo *st)
1342
1.44k
{
1343
1.44k
    g_return_val_if_fail(st != NULL, 0x0);
1344
1.44k
    return st->buf->data[3];
1345
1.44k
}
1346
/**
1347
 * fu_struct_ccgx_dmc_fwct_image_info_get_fw_version: (skip):
1348
 **/
1349
guint32
1350
fu_struct_ccgx_dmc_fwct_image_info_get_fw_version(const FuStructCcgxDmcFwctImageInfo *st)
1351
0
{
1352
0
    g_return_val_if_fail(st != NULL, 0x0);
1353
0
    return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN);
1354
0
}
1355
/**
1356
 * fu_struct_ccgx_dmc_fwct_image_info_get_app_version: (skip):
1357
 **/
1358
guint32
1359
fu_struct_ccgx_dmc_fwct_image_info_get_app_version(const FuStructCcgxDmcFwctImageInfo *st)
1360
0
{
1361
0
    g_return_val_if_fail(st != NULL, 0x0);
1362
0
    return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN);
1363
0
}
1364
/**
1365
 * fu_struct_ccgx_dmc_fwct_image_info_get_img_offset: (skip):
1366
 **/
1367
guint32
1368
fu_struct_ccgx_dmc_fwct_image_info_get_img_offset(const FuStructCcgxDmcFwctImageInfo *st)
1369
1.44k
{
1370
1.44k
    g_return_val_if_fail(st != NULL, 0x0);
1371
1.44k
    return fu_memread_uint32(st->buf->data + 16, G_LITTLE_ENDIAN);
1372
1.44k
}
1373
/**
1374
 * fu_struct_ccgx_dmc_fwct_image_info_get_img_size: (skip):
1375
 **/
1376
guint32
1377
fu_struct_ccgx_dmc_fwct_image_info_get_img_size(const FuStructCcgxDmcFwctImageInfo *st)
1378
0
{
1379
0
    g_return_val_if_fail(st != NULL, 0x0);
1380
0
    return fu_memread_uint32(st->buf->data + 20, G_LITTLE_ENDIAN);
1381
0
}
1382
/**
1383
 * fu_struct_ccgx_dmc_fwct_image_info_get_img_digest: (skip):
1384
 **/
1385
const guint8 *
1386
fu_struct_ccgx_dmc_fwct_image_info_get_img_digest(const FuStructCcgxDmcFwctImageInfo *st, gsize *bufsz)
1387
1.03k
{
1388
1.03k
    g_return_val_if_fail(st != NULL, NULL);
1389
1.03k
    if (bufsz != NULL)
1390
1.03k
        *bufsz = 32;
1391
1.03k
    return st->buf->data + 24;
1392
1.03k
}
1393
/**
1394
 * fu_struct_ccgx_dmc_fwct_image_info_get_num_img_segments: (skip):
1395
 **/
1396
guint8
1397
fu_struct_ccgx_dmc_fwct_image_info_get_num_img_segments(const FuStructCcgxDmcFwctImageInfo *st)
1398
1.44k
{
1399
1.44k
    g_return_val_if_fail(st != NULL, 0x0);
1400
1.44k
    return st->buf->data[56];
1401
1.44k
}
1402
1403
/* setters */
1404
/**
1405
 * fu_struct_ccgx_dmc_fwct_image_info_set_device_type: (skip):
1406
 **/
1407
void
1408
fu_struct_ccgx_dmc_fwct_image_info_set_device_type(FuStructCcgxDmcFwctImageInfo *st, guint8 value)
1409
0
{
1410
0
    g_return_if_fail(st != NULL);
1411
0
    st->buf->data[0] = value;
1412
0
}
1413
/**
1414
 * fu_struct_ccgx_dmc_fwct_image_info_set_img_type: (skip):
1415
 **/
1416
void
1417
fu_struct_ccgx_dmc_fwct_image_info_set_img_type(FuStructCcgxDmcFwctImageInfo *st, guint8 value)
1418
0
{
1419
0
    g_return_if_fail(st != NULL);
1420
0
    st->buf->data[1] = value;
1421
0
}
1422
/**
1423
 * fu_struct_ccgx_dmc_fwct_image_info_set_comp_id: (skip):
1424
 **/
1425
void
1426
fu_struct_ccgx_dmc_fwct_image_info_set_comp_id(FuStructCcgxDmcFwctImageInfo *st, guint8 value)
1427
0
{
1428
0
    g_return_if_fail(st != NULL);
1429
0
    st->buf->data[2] = value;
1430
0
}
1431
/**
1432
 * fu_struct_ccgx_dmc_fwct_image_info_set_row_size: (skip):
1433
 **/
1434
void
1435
fu_struct_ccgx_dmc_fwct_image_info_set_row_size(FuStructCcgxDmcFwctImageInfo *st, guint8 value)
1436
0
{
1437
0
    g_return_if_fail(st != NULL);
1438
0
    st->buf->data[3] = value;
1439
0
}
1440
/**
1441
 * fu_struct_ccgx_dmc_fwct_image_info_set_fw_version: (skip):
1442
 **/
1443
void
1444
fu_struct_ccgx_dmc_fwct_image_info_set_fw_version(FuStructCcgxDmcFwctImageInfo *st, guint32 value)
1445
0
{
1446
0
    g_return_if_fail(st != NULL);
1447
0
    fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN);
1448
0
}
1449
/**
1450
 * fu_struct_ccgx_dmc_fwct_image_info_set_app_version: (skip):
1451
 **/
1452
void
1453
fu_struct_ccgx_dmc_fwct_image_info_set_app_version(FuStructCcgxDmcFwctImageInfo *st, guint32 value)
1454
0
{
1455
0
    g_return_if_fail(st != NULL);
1456
0
    fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN);
1457
0
}
1458
/**
1459
 * fu_struct_ccgx_dmc_fwct_image_info_set_img_offset: (skip):
1460
 **/
1461
void
1462
fu_struct_ccgx_dmc_fwct_image_info_set_img_offset(FuStructCcgxDmcFwctImageInfo *st, guint32 value)
1463
0
{
1464
0
    g_return_if_fail(st != NULL);
1465
0
    fu_memwrite_uint32(st->buf->data + 16, value, G_LITTLE_ENDIAN);
1466
0
}
1467
/**
1468
 * fu_struct_ccgx_dmc_fwct_image_info_set_img_size: (skip):
1469
 **/
1470
void
1471
fu_struct_ccgx_dmc_fwct_image_info_set_img_size(FuStructCcgxDmcFwctImageInfo *st, guint32 value)
1472
0
{
1473
0
    g_return_if_fail(st != NULL);
1474
0
    fu_memwrite_uint32(st->buf->data + 20, value, G_LITTLE_ENDIAN);
1475
0
}
1476
/**
1477
 * fu_struct_ccgx_dmc_fwct_image_info_set_img_digest: (skip):
1478
 **/
1479
gboolean
1480
fu_struct_ccgx_dmc_fwct_image_info_set_img_digest(FuStructCcgxDmcFwctImageInfo *st, const guint8 *buf, gsize bufsz, GError **error)
1481
0
{
1482
0
    g_return_val_if_fail(st != NULL, FALSE);
1483
0
    g_return_val_if_fail(buf != NULL, FALSE);
1484
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
1485
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 24, buf, bufsz, 0x0, bufsz, error);
1486
0
}
1487
/**
1488
 * fu_struct_ccgx_dmc_fwct_image_info_set_num_img_segments: (skip):
1489
 **/
1490
void
1491
fu_struct_ccgx_dmc_fwct_image_info_set_num_img_segments(FuStructCcgxDmcFwctImageInfo *st, guint8 value)
1492
0
{
1493
0
    g_return_if_fail(st != NULL);
1494
0
    st->buf->data[56] = value;
1495
0
}
1496
/**
1497
 * fu_struct_ccgx_dmc_fwct_image_info_new: (skip):
1498
 **/
1499
FuStructCcgxDmcFwctImageInfo *
1500
fu_struct_ccgx_dmc_fwct_image_info_new(void)
1501
0
{
1502
0
    FuStructCcgxDmcFwctImageInfo *st = fu_struct_ccgx_dmc_fwct_image_info_new_internal();
1503
0
    st->buf = g_byte_array_sized_new(60);
1504
0
    fu_byte_array_set_size(st->buf, 60, 0x0);
1505
0
    return st;
1506
0
}
1507
/**
1508
 * fu_struct_ccgx_dmc_fwct_image_info_to_string: (skip):
1509
 **/
1510
static gchar *
1511
fu_struct_ccgx_dmc_fwct_image_info_to_string(const FuStructCcgxDmcFwctImageInfo *st)
1512
0
{
1513
0
    g_autoptr(GString) str = g_string_new("FuStructCcgxDmcFwctImageInfo:\n");
1514
0
    g_return_val_if_fail(st != NULL, NULL);
1515
0
    g_string_append_printf(str, "  device_type: 0x%x\n",
1516
0
                           (guint) fu_struct_ccgx_dmc_fwct_image_info_get_device_type(st));
1517
0
    g_string_append_printf(str, "  img_type: 0x%x\n",
1518
0
                           (guint) fu_struct_ccgx_dmc_fwct_image_info_get_img_type(st));
1519
0
    g_string_append_printf(str, "  comp_id: 0x%x\n",
1520
0
                           (guint) fu_struct_ccgx_dmc_fwct_image_info_get_comp_id(st));
1521
0
    g_string_append_printf(str, "  row_size: 0x%x\n",
1522
0
                           (guint) fu_struct_ccgx_dmc_fwct_image_info_get_row_size(st));
1523
0
    g_string_append_printf(str, "  fw_version: 0x%x\n",
1524
0
                           (guint) fu_struct_ccgx_dmc_fwct_image_info_get_fw_version(st));
1525
0
    g_string_append_printf(str, "  app_version: 0x%x\n",
1526
0
                           (guint) fu_struct_ccgx_dmc_fwct_image_info_get_app_version(st));
1527
0
    g_string_append_printf(str, "  img_offset: 0x%x\n",
1528
0
                           (guint) fu_struct_ccgx_dmc_fwct_image_info_get_img_offset(st));
1529
0
    g_string_append_printf(str, "  img_size: 0x%x\n",
1530
0
                           (guint) fu_struct_ccgx_dmc_fwct_image_info_get_img_size(st));
1531
0
    {
1532
0
        gsize bufsz = 0;
1533
0
        const guint8 *buf = fu_struct_ccgx_dmc_fwct_image_info_get_img_digest(st, &bufsz);
1534
0
        g_autoptr(GString) tmp = g_string_new(NULL);
1535
0
        for (gsize i = 0; i < bufsz; i++)
1536
0
            g_string_append_printf(tmp, "%02X", buf[i]);
1537
0
        g_string_append_printf(str, "  img_digest: 0x%s\n", tmp->str);
1538
0
    }
1539
0
    g_string_append_printf(str, "  num_img_segments: 0x%x\n",
1540
0
                           (guint) fu_struct_ccgx_dmc_fwct_image_info_get_num_img_segments(st));
1541
0
    if (str->len > 0)
1542
0
        g_string_set_size(str, str->len - 1);
1543
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1544
0
}
1545
static gboolean
1546
fu_struct_ccgx_dmc_fwct_image_info_parse_internal(FuStructCcgxDmcFwctImageInfo *st, GError **error)
1547
1.44k
{
1548
1.44k
    if (g_log_get_debug_enabled()) {
1549
0
        g_autofree gchar *str = fu_struct_ccgx_dmc_fwct_image_info_to_string(st);
1550
0
        g_debug("%s", str);
1551
0
    }
1552
1.44k
    return TRUE;
1553
1.44k
}
1554
/**
1555
 * fu_struct_ccgx_dmc_fwct_image_info_parse_stream: (skip):
1556
 **/
1557
FuStructCcgxDmcFwctImageInfo *
1558
fu_struct_ccgx_dmc_fwct_image_info_parse_stream(GInputStream *stream, gsize offset, GError **error)
1559
1.48k
{
1560
1.48k
    g_autoptr(FuStructCcgxDmcFwctImageInfo) st = fu_struct_ccgx_dmc_fwct_image_info_new_internal();
1561
1.48k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 60, NULL, error);
1562
1.48k
    if (st->buf == NULL) {
1563
22
        g_prefix_error(error, "FuStructCcgxDmcFwctImageInfo failed read of 0x%x: ", (guint) 60);
1564
22
        return NULL;
1565
22
    }
1566
1.45k
    if (st->buf->len != 60) {
1567
12
        g_set_error(error,
1568
12
                    FWUPD_ERROR,
1569
12
                    FWUPD_ERROR_INVALID_DATA,
1570
12
                    "FuStructCcgxDmcFwctImageInfo requested 0x%x and got 0x%x",
1571
12
                    (guint) 60,
1572
12
                    (guint) st->buf->len);
1573
12
        return NULL;
1574
12
    }
1575
1.44k
    if (!fu_struct_ccgx_dmc_fwct_image_info_parse_internal(st, error))
1576
0
        return NULL;
1577
1.44k
    return g_steal_pointer(&st);
1578
1.44k
}
1579
/**
1580
 * fu_struct_ccgx_dmc_fwct_segmentation_info_ref: (skip):
1581
 **/
1582
FuStructCcgxDmcFwctSegmentationInfo *
1583
fu_struct_ccgx_dmc_fwct_segmentation_info_ref(FuStructCcgxDmcFwctSegmentationInfo *st)
1584
0
{
1585
0
    g_return_val_if_fail(st != NULL, NULL);
1586
0
    st->refcount++;
1587
0
    return st;
1588
0
}
1589
/**
1590
 * fu_struct_ccgx_dmc_fwct_segmentation_info_unref: (skip):
1591
 **/
1592
void
1593
fu_struct_ccgx_dmc_fwct_segmentation_info_unref(FuStructCcgxDmcFwctSegmentationInfo *st)
1594
16.7k
{
1595
16.7k
    g_return_if_fail(st != NULL);
1596
16.7k
    if (st->refcount == 0) {
1597
0
        g_critical("FuStructCcgxDmcFwctSegmentationInfo refcount already zero");
1598
0
        return;
1599
0
    }
1600
16.7k
    if (--st->refcount > 0)
1601
0
        return;
1602
16.7k
    if (st->buf != NULL)
1603
16.7k
        g_byte_array_unref(st->buf);
1604
16.7k
    g_free(st);
1605
16.7k
}
1606
/**
1607
 * fu_struct_ccgx_dmc_fwct_segmentation_info_new_internal: (skip):
1608
 **/
1609
static FuStructCcgxDmcFwctSegmentationInfo *
1610
fu_struct_ccgx_dmc_fwct_segmentation_info_new_internal(void)
1611
16.7k
{
1612
16.7k
    FuStructCcgxDmcFwctSegmentationInfo *st = g_new0(FuStructCcgxDmcFwctSegmentationInfo, 1);
1613
16.7k
    st->refcount = 1;
1614
16.7k
    return st;
1615
16.7k
}
1616
1617
/* getters */
1618
/**
1619
 * fu_struct_ccgx_dmc_fwct_segmentation_info_get_img_id: (skip):
1620
 **/
1621
guint8
1622
fu_struct_ccgx_dmc_fwct_segmentation_info_get_img_id(const FuStructCcgxDmcFwctSegmentationInfo *st)
1623
0
{
1624
0
    g_return_val_if_fail(st != NULL, 0x0);
1625
0
    return st->buf->data[0];
1626
0
}
1627
/**
1628
 * fu_struct_ccgx_dmc_fwct_segmentation_info_get_type: (skip):
1629
 **/
1630
guint8
1631
fu_struct_ccgx_dmc_fwct_segmentation_info_get_type(const FuStructCcgxDmcFwctSegmentationInfo *st)
1632
0
{
1633
0
    g_return_val_if_fail(st != NULL, 0x0);
1634
0
    return st->buf->data[1];
1635
0
}
1636
/**
1637
 * fu_struct_ccgx_dmc_fwct_segmentation_info_get_start_row: (skip):
1638
 **/
1639
guint16
1640
fu_struct_ccgx_dmc_fwct_segmentation_info_get_start_row(const FuStructCcgxDmcFwctSegmentationInfo *st)
1641
16.6k
{
1642
16.6k
    g_return_val_if_fail(st != NULL, 0x0);
1643
16.6k
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
1644
16.6k
}
1645
/**
1646
 * fu_struct_ccgx_dmc_fwct_segmentation_info_get_num_rows: (skip):
1647
 **/
1648
guint16
1649
fu_struct_ccgx_dmc_fwct_segmentation_info_get_num_rows(const FuStructCcgxDmcFwctSegmentationInfo *st)
1650
16.6k
{
1651
16.6k
    g_return_val_if_fail(st != NULL, 0x0);
1652
16.6k
    return fu_memread_uint16(st->buf->data + 4, G_LITTLE_ENDIAN);
1653
16.6k
}
1654
1655
/* setters */
1656
/**
1657
 * fu_struct_ccgx_dmc_fwct_segmentation_info_set_img_id: (skip):
1658
 **/
1659
void
1660
fu_struct_ccgx_dmc_fwct_segmentation_info_set_img_id(FuStructCcgxDmcFwctSegmentationInfo *st, guint8 value)
1661
0
{
1662
0
    g_return_if_fail(st != NULL);
1663
0
    st->buf->data[0] = value;
1664
0
}
1665
/**
1666
 * fu_struct_ccgx_dmc_fwct_segmentation_info_set_type: (skip):
1667
 **/
1668
void
1669
fu_struct_ccgx_dmc_fwct_segmentation_info_set_type(FuStructCcgxDmcFwctSegmentationInfo *st, guint8 value)
1670
0
{
1671
0
    g_return_if_fail(st != NULL);
1672
0
    st->buf->data[1] = value;
1673
0
}
1674
/**
1675
 * fu_struct_ccgx_dmc_fwct_segmentation_info_set_start_row: (skip):
1676
 **/
1677
void
1678
fu_struct_ccgx_dmc_fwct_segmentation_info_set_start_row(FuStructCcgxDmcFwctSegmentationInfo *st, guint16 value)
1679
0
{
1680
0
    g_return_if_fail(st != NULL);
1681
0
    fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN);
1682
0
}
1683
/**
1684
 * fu_struct_ccgx_dmc_fwct_segmentation_info_set_num_rows: (skip):
1685
 **/
1686
void
1687
fu_struct_ccgx_dmc_fwct_segmentation_info_set_num_rows(FuStructCcgxDmcFwctSegmentationInfo *st, guint16 value)
1688
0
{
1689
0
    g_return_if_fail(st != NULL);
1690
0
    fu_memwrite_uint16(st->buf->data + 4, value, G_LITTLE_ENDIAN);
1691
0
}
1692
/**
1693
 * fu_struct_ccgx_dmc_fwct_segmentation_info_new: (skip):
1694
 **/
1695
FuStructCcgxDmcFwctSegmentationInfo *
1696
fu_struct_ccgx_dmc_fwct_segmentation_info_new(void)
1697
0
{
1698
0
    FuStructCcgxDmcFwctSegmentationInfo *st = fu_struct_ccgx_dmc_fwct_segmentation_info_new_internal();
1699
0
    st->buf = g_byte_array_sized_new(8);
1700
0
    fu_byte_array_set_size(st->buf, 8, 0x0);
1701
0
    return st;
1702
0
}
1703
/**
1704
 * fu_struct_ccgx_dmc_fwct_segmentation_info_to_string: (skip):
1705
 **/
1706
static gchar *
1707
fu_struct_ccgx_dmc_fwct_segmentation_info_to_string(const FuStructCcgxDmcFwctSegmentationInfo *st)
1708
0
{
1709
0
    g_autoptr(GString) str = g_string_new("FuStructCcgxDmcFwctSegmentationInfo:\n");
1710
0
    g_return_val_if_fail(st != NULL, NULL);
1711
0
    g_string_append_printf(str, "  img_id: 0x%x\n",
1712
0
                           (guint) fu_struct_ccgx_dmc_fwct_segmentation_info_get_img_id(st));
1713
0
    g_string_append_printf(str, "  type: 0x%x\n",
1714
0
                           (guint) fu_struct_ccgx_dmc_fwct_segmentation_info_get_type(st));
1715
0
    g_string_append_printf(str, "  start_row: 0x%x\n",
1716
0
                           (guint) fu_struct_ccgx_dmc_fwct_segmentation_info_get_start_row(st));
1717
0
    g_string_append_printf(str, "  num_rows: 0x%x\n",
1718
0
                           (guint) fu_struct_ccgx_dmc_fwct_segmentation_info_get_num_rows(st));
1719
0
    if (str->len > 0)
1720
0
        g_string_set_size(str, str->len - 1);
1721
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1722
0
}
1723
static gboolean
1724
fu_struct_ccgx_dmc_fwct_segmentation_info_parse_internal(FuStructCcgxDmcFwctSegmentationInfo *st, GError **error)
1725
16.6k
{
1726
16.6k
    if (g_log_get_debug_enabled()) {
1727
0
        g_autofree gchar *str = fu_struct_ccgx_dmc_fwct_segmentation_info_to_string(st);
1728
0
        g_debug("%s", str);
1729
0
    }
1730
16.6k
    return TRUE;
1731
16.6k
}
1732
/**
1733
 * fu_struct_ccgx_dmc_fwct_segmentation_info_parse_stream: (skip):
1734
 **/
1735
FuStructCcgxDmcFwctSegmentationInfo *
1736
fu_struct_ccgx_dmc_fwct_segmentation_info_parse_stream(GInputStream *stream, gsize offset, GError **error)
1737
16.7k
{
1738
16.7k
    g_autoptr(FuStructCcgxDmcFwctSegmentationInfo) st = fu_struct_ccgx_dmc_fwct_segmentation_info_new_internal();
1739
16.7k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 8, NULL, error);
1740
16.7k
    if (st->buf == NULL) {
1741
69
        g_prefix_error(error, "FuStructCcgxDmcFwctSegmentationInfo failed read of 0x%x: ", (guint) 8);
1742
69
        return NULL;
1743
69
    }
1744
16.7k
    if (st->buf->len != 8) {
1745
44
        g_set_error(error,
1746
44
                    FWUPD_ERROR,
1747
44
                    FWUPD_ERROR_INVALID_DATA,
1748
44
                    "FuStructCcgxDmcFwctSegmentationInfo requested 0x%x and got 0x%x",
1749
44
                    (guint) 8,
1750
44
                    (guint) st->buf->len);
1751
44
        return NULL;
1752
44
    }
1753
16.6k
    if (!fu_struct_ccgx_dmc_fwct_segmentation_info_parse_internal(st, error))
1754
0
        return NULL;
1755
16.6k
    return g_steal_pointer(&st);
1756
16.6k
}