Kyösti Mälkki | 4949a3d | 2021-01-09 20:38:43 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <acpi/acpi.h> |
| 4 | #include <bootsplash.h> |
| 5 | #include <cbfs.h> |
| 6 | #include <cbmem.h> |
| 7 | #include <stdint.h> |
Shelley Chen | fddf916 | 2024-01-03 14:00:07 -0800 | [diff] [blame] | 8 | #include <vendorcode/google/chromeos/chromeos.h> |
Kyösti Mälkki | 4949a3d | 2021-01-09 20:38:43 +0200 | [diff] [blame] | 9 | |
| 10 | static const struct cbmem_entry *logo_entry; |
| 11 | |
Shelley Chen | fddf916 | 2024-01-03 14:00:07 -0800 | [diff] [blame] | 12 | #if !CONFIG(HAVE_CUSTOM_BMP_LOGO) |
| 13 | const char *bmp_logo_filename(void) |
| 14 | { |
| 15 | return "logo.bmp"; |
| 16 | } |
| 17 | #endif |
| 18 | |
Subrata Banik | 9c4d85d | 2024-04-02 08:00:14 +0000 | [diff] [blame] | 19 | void *bmp_load_logo(size_t *logo_size) |
Kyösti Mälkki | 4949a3d | 2021-01-09 20:38:43 +0200 | [diff] [blame] | 20 | { |
| 21 | void *logo_buffer; |
| 22 | |
| 23 | /* CBMEM is locked for S3 resume path. */ |
| 24 | if (acpi_is_wakeup_s3()) |
Subrata Banik | 9c4d85d | 2024-04-02 08:00:14 +0000 | [diff] [blame] | 25 | return NULL; |
Kyösti Mälkki | 4949a3d | 2021-01-09 20:38:43 +0200 | [diff] [blame] | 26 | |
| 27 | logo_entry = cbmem_entry_add(CBMEM_ID_FSP_LOGO, 1 * MiB); |
| 28 | if (!logo_entry) |
Subrata Banik | 9c4d85d | 2024-04-02 08:00:14 +0000 | [diff] [blame] | 29 | return NULL; |
Kyösti Mälkki | 4949a3d | 2021-01-09 20:38:43 +0200 | [diff] [blame] | 30 | |
| 31 | logo_buffer = cbmem_entry_start(logo_entry); |
| 32 | if (!logo_buffer) |
Subrata Banik | 9c4d85d | 2024-04-02 08:00:14 +0000 | [diff] [blame] | 33 | return NULL; |
Kyösti Mälkki | 4949a3d | 2021-01-09 20:38:43 +0200 | [diff] [blame] | 34 | |
Shelley Chen | fddf916 | 2024-01-03 14:00:07 -0800 | [diff] [blame] | 35 | *logo_size = cbfs_load(bmp_logo_filename(), logo_buffer, 1 * MiB); |
Subrata Banik | 9c4d85d | 2024-04-02 08:00:14 +0000 | [diff] [blame] | 36 | if (*logo_size == 0) |
| 37 | return NULL; |
| 38 | |
| 39 | return logo_buffer; |
Kyösti Mälkki | 4949a3d | 2021-01-09 20:38:43 +0200 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | void bmp_release_logo(void) |
| 43 | { |
| 44 | if (logo_entry) |
| 45 | cbmem_entry_remove(logo_entry); |
| 46 | logo_entry = NULL; |
| 47 | } |