drivers/intel: Add horizontal logo alignment for splash screen

This commit adds horizontal alignment support for splash screen
logos into the existing helper function `calculate_logo_coordinates()`.
Updated helper function determines the X-coordinate for
logo placement based on specified horizontal alignment (left, right,
or center).

The `soc_load_logo_by_coreboot()` function is updated to utilize this
helper for footer logo placement when the panel orientation is
rotated (`LB_FB_ORIENTATION_RIGHT_UP`, `LB_FB_ORIENTATION_LEFT_UP`,
or `LB_FB_ORIENTATION_BOTTOM_UP`).

A new enum, `fw_splash_horizontal_alignment`, is defined in
`intelblocks/cfg.h` to explicitly represent these horizontal alignment
options, complete with descriptive comments and ASCII art.

This enhancement provides greater flexibility in positioning splash
screen elements, especially useful for rotated displays (for the footer
firmware splash screen).

BUG=b:423591644
TEST=Able to rotate the firmware splash screen (including footer logo)
while using portrait panel.

Change-Id: I23ae6d06e1df9cad1b2907a5c02b619dc831d468
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88030
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Subrata Banik 2025-06-10 19:39:22 +05:30
commit dfeaead9f2
2 changed files with 75 additions and 7 deletions

View file

@ -45,25 +45,43 @@ static void program_igd_lmembar(uint32_t base)
}
/*
* Calculates the destination coordinates for the logo based on alignment settings.
* Calculates the destination coordinates for the logo based on both horizontal and
* vertical alignment settings.
*
* horizontal_resolution: The horizontal resolution of the display panel.
* vertical_resolution: The vertical resolution of the display panel.
* logo_width: The width of the logo bitmap.
* logo_height: The height of the logo bitmap.
* valignment: The vertical alignment setting.
* halignment: The horizontal alignment setting. Use FW_SPLASH_HALIGNMENT_NONE
* if only vertical alignment is specified.
* valignment: The vertical alignment setting. Use FW_SPLASH_VALIGNMENT_NONE
* if only horizontal alignment is specified.
*
* Returning `struct logo_coordinates` that contains the calculated x and y coordinates
* for rendering the logo.
*/
static struct logo_coordinates calculate_logo_coordinates(
uint32_t horizontal_resolution, uint32_t vertical_resolution,
uint32_t logo_width, uint32_t logo_height, enum fw_splash_vertical_alignment valignment)
uint32_t logo_width, uint32_t logo_height,
enum fw_splash_vertical_alignment valignment,
enum fw_splash_horizontal_alignment halignment)
{
struct logo_coordinates coords;
/* Always horizontally centered */
coords.x = (horizontal_resolution - logo_width) / 2;
/* Calculate X coordinate */
switch (halignment) {
case FW_SPLASH_HALIGNMENT_LEFT:
coords.x = 0;
break;
case FW_SPLASH_HALIGNMENT_RIGHT:
coords.x = horizontal_resolution - logo_width;
break;
default: /* FW_SPLASH_HALIGNMENT_CENTER (default) */
coords.x = (horizontal_resolution - logo_width) / 2;
break;
}
/* Calculate Y coordinate */
switch (valignment) {
case FW_SPLASH_VALIGNMENT_MIDDLE:
coords.y = vertical_resolution / 2;
@ -173,7 +191,8 @@ void soc_load_logo_by_coreboot(void)
/* Calculate logo destination coordinates */
struct logo_coordinates logo_coords = calculate_logo_coordinates(horizontal_resolution,
vertical_resolution, logo_width, logo_height, config->logo_valignment);
vertical_resolution, logo_width, logo_height, config->logo_valignment,
FW_SPLASH_HALIGNMENT_CENTER);
/* Copy the logo to the framebuffer */
copy_logo_to_framebuffer(framebuffer_bar, bytes_per_scanline, blt_buffer_addr, logo_width,
@ -199,8 +218,27 @@ void soc_load_logo_by_coreboot(void)
fsp_convert_bmp_to_gop_blt(logo_ptr, logo_ptr_size, &blt_buffer_addr, &blt_size,
&logo_height, &logo_width, config->panel_orientation);
enum fw_splash_horizontal_alignment halignment = FW_SPLASH_HALIGNMENT_CENTER;
enum fw_splash_vertical_alignment valignment = FW_SPLASH_VALIGNMENT_CENTER;
/* Calculate logo destination coordinates */
switch (config->panel_orientation) {
case LB_FB_ORIENTATION_RIGHT_UP:
halignment = FW_SPLASH_HALIGNMENT_LEFT;
break;
case LB_FB_ORIENTATION_LEFT_UP:
halignment = FW_SPLASH_HALIGNMENT_RIGHT;
break;
case LB_FB_ORIENTATION_BOTTOM_UP:
valignment = FW_SPLASH_VALIGNMENT_TOP;
break;
default: /* LB_FB_ORIENTATION_NORMAL (default) */
valignment = FW_SPLASH_VALIGNMENT_BOTTOM;
break;
}
logo_coords = calculate_logo_coordinates(horizontal_resolution,
vertical_resolution, logo_width, logo_height, FW_SPLASH_VALIGNMENT_BOTTOM);
vertical_resolution, logo_width, logo_height, valignment, halignment);
/* Copy the logo to the framebuffer */
copy_logo_to_framebuffer(framebuffer_bar, bytes_per_scanline, blt_buffer_addr,

View file

@ -83,6 +83,36 @@ enum fw_splash_vertical_alignment {
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,
};
/*
* This structure will hold data required by common blocks.
* These are soc specific configurations which will be filled by soc.