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)