Coverage Report

Created: 2025-11-11 06:44

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