drivers/intel/fsp2_0: Refactor bitmap loading and GOP BLT conversion
This commit refactors the bitmap handling in the FSP2.0 driver to
enhance flexibility. Previously, `fsp_convert_bmp_to_gop_blt()`
directly called `bmp_load_logo()`, tying it to specific, predefined
bitmaps like low-battery or OEM splash logos. This prevented its
use for dynamic bitmap files (e.g., brand logos) at runtime.
To address this, `fsp_convert_bmp_to_gop_blt()` no longer handles
bitmap loading. Instead, a new unified API,
`fsp_load_and_convert_bmp_to_gop_blt()`, is introduced for scenarios
where FSP needs to load and convert a bitmap in a single step
(e.g., via its entrypoint).
This change makes `fsp_convert_bmp_to_gop_blt()` a generic API capable
of converting any provided bitmap into a BLT buffer. SoC layers
(like Alder Lake, Meteor Lake, Panther Lake) can now explicitly load
bitmaps and then pass them to `fsp_convert_bmp_to_gop_blt()`, or use
the new `fsp_load_and_convert_bmp_to_gop_blt()` for combined
operations.
Before:
- `soc_load_logo_by_coreboot()` -> `fsp_convert_bmp_to_gop_blt()`
(loads logo internally)
- `soc_load_logo_by_fsp()` -> `fsp_convert_bmp_to_gop_blt()`
(loads logo internally)
**After:**
- `soc_load_logo_by_coreboot()` -> loads logo
-> `fsp_convert_bmp_to_gop_blt()`
- `soc_load_logo_by_fsp()` -> `fsp_load_and_convert_bmp_to_gop_blt()`
BUG=b:423591644
TEST=Able to build and boot google/fatcat. FW splash screen looks
proper.
Change-Id: Ia20e8d42bca6f40c4eb652eb69e3fce84409fc35
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88014
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
This commit is contained in:
parent
f3f9c0bd8e
commit
f48865ab9a
6 changed files with 71 additions and 30 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#define __SIMPLE_DEVICE__
|
||||
|
||||
#include <bootmode.h>
|
||||
#include <bootsplash.h>
|
||||
#include <console/console.h>
|
||||
#include <cpu/x86/mtrr.h>
|
||||
#include <device/pci_ops.h>
|
||||
|
|
@ -112,12 +113,12 @@ static void copy_logo_to_framebuffer(
|
|||
|
||||
void soc_load_logo_by_coreboot(void)
|
||||
{
|
||||
size_t size;
|
||||
const struct hob_graphics_info *ginfo;
|
||||
struct soc_intel_common_config *config = chip_get_common_soc_structure();
|
||||
efi_uintn_t logo, blt_size;
|
||||
efi_uintn_t blt_buffer_addr;
|
||||
uint32_t logo_size, logo_height, logo_width;
|
||||
uintptr_t logo_ptr;
|
||||
size_t size, logo_ptr_size;
|
||||
efi_uintn_t blt_size, blt_buffer_addr;
|
||||
uint32_t logo_height, logo_width;
|
||||
int temp_mtrr_index = -1;
|
||||
|
||||
/* Find the graphics information HOB */
|
||||
|
|
@ -154,8 +155,16 @@ void soc_load_logo_by_coreboot(void)
|
|||
if (CONFIG(VBOOT_LID_SWITCH) ? !get_lid_switch() : !CONFIG(RUN_FSP_GOP))
|
||||
config->panel_orientation = LB_FB_ORIENTATION_NORMAL;
|
||||
|
||||
logo_ptr = (uintptr_t)bmp_load_logo(&logo_ptr_size);
|
||||
|
||||
if (!logo_ptr || logo_ptr_size < sizeof(efi_bmp_image_header)) {
|
||||
printk(BIOS_ERR, "%s: BMP image (%zu) is less than expected minimum size (%zu).\n",
|
||||
__func__, logo_ptr_size, sizeof(efi_bmp_image_header));
|
||||
return;
|
||||
}
|
||||
|
||||
/* Convert BMP logo to GOP BLT format */
|
||||
fsp_convert_bmp_to_gop_blt(&logo, &logo_size, &blt_buffer_addr, &blt_size,
|
||||
fsp_convert_bmp_to_gop_blt(logo_ptr, logo_ptr_size, &blt_buffer_addr, &blt_size,
|
||||
&logo_height, &logo_width, config->panel_orientation);
|
||||
|
||||
/* Override logo alignment if the default screen orientation is not normal */
|
||||
|
|
|
|||
|
|
@ -398,42 +398,69 @@ static void *fill_blt_buffer(efi_bmp_image_header *header,
|
|||
return gop_blt_ptr;
|
||||
}
|
||||
|
||||
/* Helper function to perform the common BMP to GOP BLT conversion logic */
|
||||
static bool convert_bmp_to_gop_blt_common(uintptr_t logo_ptr, size_t logo_ptr_size,
|
||||
efi_uintn_t *blt_ptr, efi_uintn_t *blt_size, uint32_t *pixel_height,
|
||||
uint32_t *pixel_width, enum lb_fb_orientation orientation)
|
||||
{
|
||||
size_t blt_buffer_size;
|
||||
efi_bmp_image_header *bmp_header;
|
||||
|
||||
bmp_header = (efi_bmp_image_header *)logo_ptr;
|
||||
|
||||
/* Authenticate BMP header and validate size against provided logo_ptr_size */
|
||||
if (!do_bmp_image_authentication(bmp_header) || (bmp_header->Size != logo_ptr_size))
|
||||
return false;
|
||||
|
||||
blt_buffer_size = calculate_blt_buffer_size(bmp_header);
|
||||
if (!blt_buffer_size)
|
||||
return false;
|
||||
|
||||
if (get_color_map_num(bmp_header) < 0)
|
||||
return false;
|
||||
|
||||
bool is_standard_orientation = (orientation == LB_FB_ORIENTATION_NORMAL ||
|
||||
orientation == LB_FB_ORIENTATION_BOTTOM_UP);
|
||||
|
||||
*blt_size = blt_buffer_size;
|
||||
*pixel_height = is_standard_orientation ? bmp_header->PixelHeight : bmp_header->PixelWidth;
|
||||
*pixel_width = is_standard_orientation ? bmp_header->PixelWidth : bmp_header->PixelHeight;
|
||||
*blt_ptr = (uintptr_t)fill_blt_buffer(bmp_header, logo_ptr, blt_buffer_size, orientation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Convert a *.BMP graphics image to a GOP blt buffer */
|
||||
void fsp_convert_bmp_to_gop_blt(efi_uintn_t *logo, uint32_t *logo_size,
|
||||
void fsp_load_and_convert_bmp_to_gop_blt(efi_uintn_t *logo, uint32_t *logo_size,
|
||||
efi_uintn_t *blt_ptr, efi_uintn_t *blt_size, uint32_t *pixel_height, uint32_t *pixel_width,
|
||||
enum lb_fb_orientation orientation)
|
||||
{
|
||||
uintptr_t logo_ptr;
|
||||
size_t logo_ptr_size, blt_buffer_size;
|
||||
efi_bmp_image_header *bmp_header;
|
||||
size_t logo_ptr_size;
|
||||
|
||||
if (!logo || !logo_size || !blt_ptr || !blt_size || !pixel_height || !pixel_width)
|
||||
return;
|
||||
|
||||
logo_ptr = (uintptr_t)bmp_load_logo(&logo_ptr_size);
|
||||
|
||||
if (!logo_ptr || logo_ptr_size < sizeof(efi_bmp_image_header)) {
|
||||
printk(BIOS_ERR, "%s: BMP Image size is too small.\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bmp_header = (efi_bmp_image_header *)logo_ptr;
|
||||
if (!do_bmp_image_authentication(bmp_header) || (bmp_header->Size != logo_ptr_size))
|
||||
if (!logo_ptr || logo_ptr_size < sizeof(efi_bmp_image_header))
|
||||
return;
|
||||
|
||||
blt_buffer_size = calculate_blt_buffer_size(bmp_header);
|
||||
if (!blt_buffer_size)
|
||||
return;
|
||||
|
||||
if (get_color_map_num(bmp_header) < 0)
|
||||
return;
|
||||
|
||||
bool is_standard_orientation = (orientation == LB_FB_ORIENTATION_NORMAL ||
|
||||
orientation == LB_FB_ORIENTATION_BOTTOM_UP);
|
||||
*logo = logo_ptr;
|
||||
*logo_size = logo_ptr_size;
|
||||
*blt_size = blt_buffer_size;
|
||||
*pixel_height = is_standard_orientation ? bmp_header->PixelHeight : bmp_header->PixelWidth;
|
||||
*pixel_width = is_standard_orientation ? bmp_header->PixelWidth : bmp_header->PixelHeight;
|
||||
*blt_ptr = (uintptr_t)fill_blt_buffer(bmp_header, logo_ptr, blt_buffer_size, orientation);
|
||||
|
||||
convert_bmp_to_gop_blt_common(logo_ptr, logo_ptr_size, blt_ptr, blt_size,
|
||||
pixel_height, pixel_width, orientation);
|
||||
}
|
||||
|
||||
/* Convert a *.BMP graphics image (as per input `logo_ptr`) to a GOP blt buffer */
|
||||
void fsp_convert_bmp_to_gop_blt(uintptr_t logo_ptr, size_t logo_ptr_size,
|
||||
efi_uintn_t *blt_ptr, efi_uintn_t *blt_size, uint32_t *pixel_height, uint32_t *pixel_width,
|
||||
enum lb_fb_orientation orientation)
|
||||
{
|
||||
if (!blt_ptr || !blt_size || !pixel_height || !pixel_width)
|
||||
return;
|
||||
|
||||
convert_bmp_to_gop_blt_common(logo_ptr, logo_ptr_size, blt_ptr, blt_size,
|
||||
pixel_height, pixel_width, orientation);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@
|
|||
#include <types.h>
|
||||
|
||||
/* Convert a *.BMP graphics image to a GOP blt buffer */
|
||||
void fsp_convert_bmp_to_gop_blt(efi_uintn_t *logo, uint32_t *logo_size,
|
||||
void fsp_load_and_convert_bmp_to_gop_blt(efi_uintn_t *logo, uint32_t *logo_size,
|
||||
efi_uintn_t *blt_ptr, efi_uintn_t *blt_size, uint32_t *pixel_height, uint32_t *pixel_width,
|
||||
enum lb_fb_orientation orientation);
|
||||
|
||||
/* Convert a *.BMP graphics image (as per input `logo_ptr`) to a GOP blt buffer */
|
||||
void fsp_convert_bmp_to_gop_blt(uintptr_t logo_ptr, size_t logo_ptr_size,
|
||||
efi_uintn_t *blt_ptr, efi_uintn_t *blt_size, uint32_t *pixel_height, uint32_t *pixel_width,
|
||||
enum lb_fb_orientation orientation);
|
||||
|
||||
|
|
|
|||
|
|
@ -1397,7 +1397,7 @@ void soc_load_logo_by_fsp(FSPS_UPD *supd)
|
|||
if (s_cfg->LidStatus == 0)
|
||||
config->panel_orientation = LB_FB_ORIENTATION_NORMAL;
|
||||
|
||||
fsp_convert_bmp_to_gop_blt(&supd->FspsConfig.LogoPtr,
|
||||
fsp_load_and_convert_bmp_to_gop_blt(&supd->FspsConfig.LogoPtr,
|
||||
&supd->FspsConfig.LogoSize,
|
||||
&supd->FspsConfig.BltBufferAddress,
|
||||
&supd->FspsConfig.BltBufferSize,
|
||||
|
|
|
|||
|
|
@ -913,7 +913,7 @@ void soc_load_logo_by_fsp(FSPS_UPD *supd)
|
|||
if (s_cfg->LidStatus == 0)
|
||||
config->panel_orientation = LB_FB_ORIENTATION_NORMAL;
|
||||
|
||||
fsp_convert_bmp_to_gop_blt(&supd->FspsConfig.LogoPtr,
|
||||
fsp_load_and_convert_bmp_to_gop_blt(&supd->FspsConfig.LogoPtr,
|
||||
&supd->FspsConfig.LogoSize,
|
||||
&supd->FspsConfig.BltBufferAddress,
|
||||
&supd->FspsConfig.BltBufferSize,
|
||||
|
|
|
|||
|
|
@ -818,7 +818,7 @@ void soc_load_logo_by_fsp(FSPS_UPD *supd)
|
|||
if (s_cfg->LidStatus == 0)
|
||||
config->panel_orientation = LB_FB_ORIENTATION_NORMAL;
|
||||
|
||||
fsp_convert_bmp_to_gop_blt(&logo, &logo_size,
|
||||
fsp_load_and_convert_bmp_to_gop_blt(&logo, &logo_size,
|
||||
&supd->FspsConfig.BltBufferAddress,
|
||||
&blt_size,
|
||||
&supd->FspsConfig.LogoPixelHeight,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue