| 1 |
|
| 2 |
|
| 3 |
#include <boot/coreboot_tables.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <elog.h> |
| 6 |
#include <fsp/graphics.h> |
| 7 |
#include <fsp/util.h> |
| 8 |
#include <soc/intel/common/vbt.h> |
| 9 |
#include <types.h> |
| 10 |
#include <framebuffer_info.h> |
| 11 |
|
| 12 |
enum pixel_format { |
| 13 |
pixel_rgbx_8bpc = 0, |
| 14 |
pixel_bgrx_8bpc = 1, |
| 15 |
pixel_bitmask = 2, |
| 16 |
}; |
| 17 |
|
| 18 |
struct pixel { |
| 19 |
uint8_t pos; |
| 20 |
uint8_t size; |
| 21 |
}; |
| 22 |
|
| 23 |
static const struct fsp_framebuffer { |
| 24 |
struct pixel red; |
| 25 |
struct pixel green; |
| 26 |
struct pixel blue; |
| 27 |
struct pixel rsvd; |
| 28 |
} fsp_framebuffer_format_map[] = { |
| 29 |
[pixel_rgbx_8bpc] = { {0, 8}, {8, 8}, {16, 8}, {24, 8} }, |
| 30 |
[pixel_bgrx_8bpc] = { {16, 8}, {8, 8}, {0, 8}, {24, 8} }, |
| 31 |
}; |
| 32 |
|
| 33 |
enum fw_splash_screen_status { |
| 34 |
FW_SPLASH_SCREEN_DISABLED, |
| 35 |
FW_SPLASH_SCREEN_ENABLED, |
| 36 |
}; |
| 37 |
|
| 38 |
|
| 39 |
__weak int fsp_soc_report_external_display(void) |
| 40 |
{ |
| 41 |
|
| 42 |
return 0; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
static void update_fw_splash_screen_event(enum fw_splash_screen_status status) |
| 56 |
{ |
| 57 |
if (!CONFIG(BMP_LOGO)) |
| 58 |
return; |
| 59 |
|
| 60 |
printk(BIOS_DEBUG, "Firmware Splash Screen : %s\n", |
| 61 |
status ? "Enabled" : "Disabled"); |
| 62 |
|
| 63 |
elog_add_event_byte(ELOG_TYPE_FW_SPLASH_SCREEN, status); |
| 64 |
} |
| 65 |
|
| 66 |
void fsp_report_framebuffer_info(const uintptr_t framebuffer_bar, |
| 67 |
enum lb_fb_orientation orientation) |
| 68 |
{ |
| 69 |
size_t size; |
| 70 |
const struct hob_graphics_info *ginfo; |
| 71 |
const struct fsp_framebuffer *fbinfo; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
if (!framebuffer_bar) { |
| 78 |
printk(BIOS_ALERT, "Framebuffer BAR invalid\n"); |
| 79 |
update_fw_splash_screen_event(FW_SPLASH_SCREEN_DISABLED); |
| 80 |
return; |
| 81 |
} |
| 82 |
|
| 83 |
ginfo = fsp_find_extension_hob_by_guid(fsp_graphics_info_guid, &size); |
| 84 |
|
| 85 |
if (!ginfo) { |
| 86 |
printk(BIOS_ALERT, "Graphics hand-off block not found\n"); |
| 87 |
update_fw_splash_screen_event(FW_SPLASH_SCREEN_DISABLED); |
| 88 |
return; |
| 89 |
} |
| 90 |
|
| 91 |
if (ginfo->pixel_format >= ARRAY_SIZE(fsp_framebuffer_format_map)) { |
| 92 |
printk(BIOS_ALERT, "FSP set unknown framebuffer format: %d\n", |
| 93 |
ginfo->pixel_format); |
| 94 |
update_fw_splash_screen_event(FW_SPLASH_SCREEN_DISABLED); |
| 95 |
return; |
| 96 |
} |
| 97 |
|
| 98 |
update_fw_splash_screen_event(FW_SPLASH_SCREEN_ENABLED); |
| 99 |
fbinfo = fsp_framebuffer_format_map + ginfo->pixel_format; |
| 100 |
|
| 101 |
const struct lb_framebuffer fb = { |
| 102 |
.physical_address = framebuffer_bar, |
| 103 |
.x_resolution = ginfo->horizontal_resolution, |
| 104 |
.y_resolution = ginfo->vertical_resolution, |
| 105 |
.bytes_per_line = ginfo->pixels_per_scanline * 4, |
| 106 |
.bits_per_pixel = fbinfo->rsvd.size + fbinfo->red.size + |
| 107 |
fbinfo->green.size + fbinfo->blue.size, |
| 108 |
.red_mask_pos = fbinfo->red.pos, |
| 109 |
.red_mask_size = fbinfo->red.size, |
| 110 |
.green_mask_pos = fbinfo->green.pos, |
| 111 |
.green_mask_size = fbinfo->green.size, |
| 112 |
.blue_mask_pos = fbinfo->blue.pos, |
| 113 |
.blue_mask_size = fbinfo->blue.size, |
| 114 |
.reserved_mask_pos = fbinfo->rsvd.pos, |
| 115 |
.reserved_mask_size = fbinfo->rsvd.size, |
| 116 |
.orientation = orientation, |
| 117 |
.flags = { |
| 118 |
.has_external_display = fsp_soc_report_external_display(), |
| 119 |
}, |
| 120 |
}; |
| 121 |
|
| 122 |
fb_add_framebuffer_info_ex(&fb); |
| 123 |
} |