{lib, drivers/intel}: Move BMP rendering logic out of SoC code

This patch refactors the BMP rendering logic, moving it from
drivers/intel/fsp2_0 to src/lib. This centralizes the code
responsible for rendering BMP images to the framebuffer.

Key changes:
- Move BMP rendering functions (e.g., calculate_logo_coordinates,
  copy_logo_to_framebuffer) and their dependencies to
  src/lib/render_bmp.c and src/lib/render_bmp.h.
- Decouple BMP definitions from UEFI headers by introducing new
  coreboot-specific structures for BMP images and BLT pixels.
- Consolidate bootsplash-related declarations into bootsplash.h,
  including new `fw_splash_vertical_alignment`,
  `fw_splash_horizontal_alignment`, and `struct logo_config`.
- Update `soc_load_logo_by_coreboot` to use the new common
  `load_and_render_logo_to_framebuffer` function and `struct
  logo_config` for rendering.
- Relocate `release_logo` to `src/lib/render_bmp.c` for better
  module structure.
- Update `src/lib/Makefile.mk` to include the new render_bmp.c.

This refactoring improves code organization and reusability, making
BMP rendering accessible without tight coupling to Intel-specific
driver code.

BUG=b:427387842
TEST=Verify firmware splash screen on google/fatcat.

Change-Id: I0e20ea7e44b4b3ccdb2d4aa9b6aa10ed3447ccfc
Signed-off-by: Kapil Porwal <kapilporwal@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88361
Reviewed-by: Subrata Banik <subratabanik@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Kapil Porwal 2025-07-09 10:42:12 +05:30 committed by Matt DeVillier
commit 9a8ba5b39a
8 changed files with 918 additions and 747 deletions

View file

@ -3,6 +3,7 @@
#ifndef __BOOTSPLASH_H__
#define __BOOTSPLASH_H__
#include <boot/coreboot_tables.h>
#include <types.h>
enum bootsplash_type {
@ -27,6 +28,125 @@ void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution,
unsigned int y_resolution, unsigned int bytes_per_line,
unsigned int fb_resolution);
/*
* Specifies the vertical alignment for the splash screen image.
*
* Visual Guide (representing the display area and the [LOGO]):
*
* Each option dictates the vertical placement of the splash image
* within the display's height.
*/
enum fw_splash_vertical_alignment {
/*
* The splash image is centered vertically `(Y-axis - logo_height)/2` on the screen.
* The center of the [LOGO] aligns with the vertical center of the screen.
*
* +---------------+
* | |
* | |
* | [LOGO] | <-- Vertically Centered
* | |
* | |
* +---------------+
*/
FW_SPLASH_VALIGNMENT_CENTER = 0,
/*
* The splash image is aligned to the top edge of the screen.
*
* +---------------+
* | [LOGO] | <-- Top Aligned
* | |
* | |
* | |
* | |
* +---------------+
*/
FW_SPLASH_VALIGNMENT_TOP = 1,
/*
* The splash image is aligned to the bottom edge of the screen.
*
* +---------------+
* | |
* | |
* | |
* | |
* | [LOGO] | <-- Bottom Aligned
* +---------------+
*/
FW_SPLASH_VALIGNMENT_BOTTOM = 2,
/*
* The splash image is placed in the vertical middle `(Y-axis/2)` of the screen
* (without considering the `logo height`). This means the TOP EDGE of the
* [LOGO] aligns with the screen's vertical midpoint line.
*
* +---------------+
* | (Upper Half) |
* | |
* | [LOGO] | <-- [LOGO] aligns at Middle of the Y-axis
* | |
* | (Lower Half) |
* +---------------+
*
* Note: The distinction between CENTER and MIDDLE is relevant as in for MIDDLE
* alignment, it ignores the logo height (i.e., the logo's top edge is placed
* at the screen's Y-midpoint). CENTER alignment, by contrast, would place
* the geometrical center of the logo at the screen's Y-midpoint.
*/
FW_SPLASH_VALIGNMENT_MIDDLE = 3,
};
enum fw_splash_horizontal_alignment {
/*
* The splash image is centered horizontally `(X-axis - logo_width)/2` on the screen.
* The center of the [LOGO] aligns with the horizontal center of the screen.
*
* +-----------------+
* | [LOGO] |
* +-----------------+
*/
FW_SPLASH_HALIGNMENT_CENTER = 0,
/*
* The splash image is aligned to the left edge of the screen.
*
* +-----------------+
* |[LOGO] |
* +-----------------+
*/
FW_SPLASH_HALIGNMENT_LEFT = 1,
/*
* The splash image is aligned to the right edge of the screen.
*
* +-----------------+
* | [LOGO]|
* +-----------------+
*/
FW_SPLASH_HALIGNMENT_RIGHT = 2,
};
struct logo_config {
uintptr_t framebuffer_base;
uint32_t horizontal_resolution;
uint32_t vertical_resolution;
uint32_t bytes_per_scanline;
enum lb_fb_orientation panel_orientation;
enum fw_splash_horizontal_alignment halignment;
enum fw_splash_vertical_alignment valignment;
uint8_t logo_bottom_margin;
};
void render_logo_to_framebuffer(struct logo_config *config);
void load_and_convert_bmp_to_blt(uintptr_t *logo, size_t *logo_size,
uintptr_t *blt, size_t *blt_size, uint32_t *pixel_height, uint32_t *pixel_width,
enum lb_fb_orientation orientation);
void convert_bmp_to_blt(uintptr_t logo, size_t logo_size,
uintptr_t *blt, size_t *blt_size, uint32_t *pixel_height, uint32_t *pixel_width,
enum lb_fb_orientation orientation);
/*
* Allow platform-specific BMP logo overrides via HAVE_CUSTOM_BMP_LOGO config.
* For example: Introduce configurable BMP logo for customization on platforms like ChromeOS