/src/fwupd/plugins/ccgx/fu-ccgx-common.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2020 Richard Hughes <richard@hughsie.com> |
3 | | * |
4 | | * SPDX-License-Identifier: LGPL-2.1-or-later |
5 | | */ |
6 | | |
7 | | #include "config.h" |
8 | | |
9 | | #include "fu-ccgx-common.h" |
10 | | |
11 | | gchar * |
12 | | fu_ccgx_version_to_string(guint32 val) |
13 | 11 | { |
14 | | /* 16 bits: application type [LSB] |
15 | | * 8 bits: build number |
16 | | * 4 bits: minor version |
17 | | * 4 bits: major version [MSB] */ |
18 | 11 | return g_strdup_printf("%u.%u.%u", |
19 | 11 | (val >> 28) & 0x0f, |
20 | 11 | (val >> 24) & 0x0f, |
21 | 11 | (val >> 16) & 0xff); |
22 | 11 | } |
23 | | |
24 | | FuCcgxFwMode |
25 | | fu_ccgx_fw_mode_get_alternate(FuCcgxFwMode val) |
26 | 0 | { |
27 | 0 | if (val == FU_CCGX_FW_MODE_FW1) |
28 | 0 | return FU_CCGX_FW_MODE_FW2; |
29 | 0 | if (val == FU_CCGX_FW_MODE_FW2) |
30 | 0 | return FU_CCGX_FW_MODE_FW1; |
31 | 0 | return FU_CCGX_FW_MODE_BOOT; |
32 | 0 | } |