Coverage Report

Created: 2025-11-24 06:59

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