From a1dbb4076cdb0356279fd1adda7ae731ab0e3f7b Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Wed, 11 Jun 2025 14:29:16 +0530 Subject: [PATCH] lib: Add support for different bootsplash types This commit introduces an enumerated type `bootsplash_type` to differentiate between various bootsplash logos, such as `BOOTSPLASH_LOW_BATTERY` and `BOOTSPLASH_CENTER`. A `bootsplash_list` array is added to map these types to their corresponding default filenames. A new function, `bmp_get_logo_filename`, is provided to retrieve the correct logo filename based on the specified bootsplash type. This function also handles overriding the `BOOTSPLASH_CENTER` logo name if `CONFIG(HAVE_CUSTOM_BMP_LOGO)` is enabled. The `bmp_load_logo` function is updated to utilize the new `bootsplash_type` and `bmp_get_logo_filename` to dynamically select the appropriate logo for display. This change streamlines logo management and improves flexibility for different boot scenarios. BUG=b:423591644 TEST=Able to build and boot google/fatcat. FW splash screen looks proper. Change-Id: I882deda56b5d30bb15cc7def408c4ea479ffd6ba Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/88052 Tested-by: build bot (Jenkins) Reviewed-by: Kapil Porwal --- src/include/bootsplash.h | 10 ++++++++++ src/lib/bmp_logo.c | 28 +++++++++++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/include/bootsplash.h b/src/include/bootsplash.h index 7a57cd91f4..f935476e44 100644 --- a/src/include/bootsplash.h +++ b/src/include/bootsplash.h @@ -5,6 +5,16 @@ #include +enum bootsplash_type { + /* Indicates a low battery bootsplash logo. */ + BOOTSPLASH_LOW_BATTERY, + /* Indicates a Main OEM defined bootsplash logo for center of the splash screen. */ + BOOTSPLASH_CENTER, + + /* It's used to determine the total number of bootsplash types. */ + BOOTSPLASH_MAX_NUM, +}; + /** * Sets up the framebuffer with the bootsplash.jpg from cbfs. * Returns 0 on success diff --git a/src/lib/bmp_logo.c b/src/lib/bmp_logo.c index bc636a6755..9822ca00f3 100644 --- a/src/lib/bmp_logo.c +++ b/src/lib/bmp_logo.c @@ -9,17 +9,31 @@ static const struct cbmem_entry *logo_entry; -#if !CONFIG(HAVE_CUSTOM_BMP_LOGO) -const char *bmp_logo_filename(void) +/* Mapping of different bootsplash logo name based on bootsplash type */ +static const char *bootsplash_list[BOOTSPLASH_MAX_NUM] = { + [BOOTSPLASH_LOW_BATTERY] = "low_battery.bmp", + [BOOTSPLASH_CENTER] = "logo.bmp" +}; + +/* + * Return the appropriate logo filename based on the bootsplash type. + * This will be the default filename from 'bootsplash_list' or the + * custom one if it was overridden for BOOTSPLASH_OEM. + */ +static const char *bmp_get_logo_filename(enum bootsplash_type type) { - return "logo.bmp"; + /* Override `BOOTSPLASH_CENTER` logo name if required */ + if ((type == BOOTSPLASH_CENTER) && CONFIG(HAVE_CUSTOM_BMP_LOGO)) + return bmp_logo_filename(); + + return bootsplash_list[type]; } -#endif void *bmp_load_logo(size_t *logo_size) { void *logo_buffer; const char *logo_name; + enum bootsplash_type type = BOOTSPLASH_CENTER; /* CBMEM is locked for S3 resume path. */ if (acpi_is_wakeup_s3()) @@ -34,9 +48,9 @@ void *bmp_load_logo(size_t *logo_size) return NULL; if (platform_is_low_battery_shutdown_needed()) - logo_name = "low_battery.bmp"; - else - logo_name = bmp_logo_filename(); + type = BOOTSPLASH_LOW_BATTERY; + + logo_name = bmp_get_logo_filename(type); *logo_size = cbfs_load(logo_name, logo_buffer, 1 * MiB); if (*logo_size == 0)