From aa16822643e652833e8c368b7724e5b3c0c6d875 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Thu, 5 Feb 2026 14:41:04 +0530 Subject: [PATCH] lib: Add support for off-mode charging splash screen Introduce the infrastructure required to display an off-mode charging notification. This is used when a device boots due to power cable insertion but should remain in a charging state rather than booting the full operating system. Changes: - Add BOOTSPLASH_OFF_MODE_CHARGING to bootsplash_type. - Define platform_is_off_mode_charging_active() with a weak inline fallback to allow platforms to signal off-mode charging status. - Update bmp_logo.c to recognize "off_mode_charging.bmp" and select it as the active logo type when charging is active. - Modify render_bmp.c to handle layout and rendering for the charging logo, including support for footer text if enabled. - Ensure the rendering flow bails out early after displaying the charging notification to prevent standard OS boot splash. BUG=b:473480933 TEST=Able to build google/fatcat. Change-Id: Ief4c65eaf0178ff3d736363c3e56acfe1adba14a Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/91106 Reviewed-by: Kapil Porwal Tested-by: build bot (Jenkins) --- src/include/bootsplash.h | 25 +++++++++++++++++++++++++ src/lib/bmp_logo.c | 6 +++++- src/lib/render_bmp.c | 13 ++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/include/bootsplash.h b/src/include/bootsplash.h index fa13316955..a3d8487968 100644 --- a/src/include/bootsplash.h +++ b/src/include/bootsplash.h @@ -13,6 +13,8 @@ enum bootsplash_type { BOOTSPLASH_CENTER, /* Indicates an optional OEM defined bootsplash logo for footer of the splash screen. */ BOOTSPLASH_FOOTER, + /* Indicates a off-mode charging bootsplash logo. */ + BOOTSPLASH_OFF_MODE_CHARGING, /* It's used to determine the total number of bootsplash types. */ BOOTSPLASH_MAX_NUM, @@ -171,6 +173,29 @@ bool platform_is_low_battery_shutdown_needed(void); static inline bool platform_is_low_battery_shutdown_needed(void) { return false; } #endif +/* + * Platform specific callbacks for off-mode bootsplash handling. + * + * These callbacks allow the platform to determine if the device + * has booted in off-mode charging to render the appropriate user + * notification. + */ +#if CONFIG(PLATFORM_HAS_OFF_MODE_CHARGING_INDICATOR) +/* + * platform_is_off_mode_charging_active - Check if off-mode charging is required. + * + * Returns true if the system should stay in a "charging splash" state + * instead of performing a full OS boot or a complete power-off. + */ +bool platform_is_off_mode_charging_active(void); +#else +/* Inline fallback for platforms without off-mode charging support */ +static inline bool platform_is_off_mode_charging_active(void) +{ + return false; +} +#endif + /* * VGA Mode 12h (640x480 with 16 colors): * As per page 13 of https://www.phatcode.net/res/221/files/vbe20.pdf diff --git a/src/lib/bmp_logo.c b/src/lib/bmp_logo.c index 9dfe15a085..7b0de54720 100644 --- a/src/lib/bmp_logo.c +++ b/src/lib/bmp_logo.c @@ -13,7 +13,8 @@ static const struct cbmem_entry *logo_entry; static const char *bootsplash_list[BOOTSPLASH_MAX_NUM] = { [BOOTSPLASH_LOW_BATTERY] = "low_battery.bmp", [BOOTSPLASH_CENTER] = "logo.bmp", - [BOOTSPLASH_FOOTER] = "footer_logo.bmp" + [BOOTSPLASH_FOOTER] = "footer_logo.bmp", + [BOOTSPLASH_OFF_MODE_CHARGING] = "off_mode_charging.bmp" }; /* @@ -60,6 +61,9 @@ void *bmp_load_logo(size_t *logo_size) if (platform_is_low_battery_shutdown_needed()) type = BOOTSPLASH_LOW_BATTERY; + if (platform_is_off_mode_charging_active()) + type = BOOTSPLASH_OFF_MODE_CHARGING; + return bmp_load_logo_by_type(type, logo_size); } diff --git a/src/lib/render_bmp.c b/src/lib/render_bmp.c index b91015bf89..39242d0d97 100644 --- a/src/lib/render_bmp.c +++ b/src/lib/render_bmp.c @@ -576,7 +576,8 @@ static void get_logo_layout( if (!config || !logo_halignment || !logo_valignment || !logo_bottom_margin) return; - if (logo_type == BOOTSPLASH_LOW_BATTERY || logo_type == BOOTSPLASH_CENTER) { + if (logo_type == BOOTSPLASH_LOW_BATTERY || logo_type == BOOTSPLASH_CENTER || + logo_type == BOOTSPLASH_OFF_MODE_CHARGING) { *logo_halignment = config->halignment; *logo_valignment = config->valignment; /* Override logo alignment if the default screen orientation is not normal */ @@ -710,6 +711,16 @@ void render_logo_to_framebuffer(struct logo_config *config) return; } + /* + * If the device has booted due to cable power insertion aka off-mode then display + * off-mode charging user notification and bail out early. + */ + if (platform_is_off_mode_charging_active()) { + if (load_and_render_logo_to_framebuffer(BOOTSPLASH_OFF_MODE_CHARGING, config) != 0) + printk(BIOS_ERR, "%s: Failed to render off-mode charging logo.\n", __func__); + return; + } + /* Render the main logo */ if (load_and_render_logo_to_framebuffer(BOOTSPLASH_CENTER, config) != 0) { printk(BIOS_ERR, "%s: Failed to render main splash screen logo.\n", __func__);