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