blob: a98f3bbba2cd8d71b71a9c037005be1bc5be6fa0 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -08002
Elyes HAOUAS0edf6a52019-10-26 18:41:47 +02003#include <boot/coreboot_tables.h>
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -08004#include <console/console.h>
Subrata Banik68e642f2023-08-27 20:42:26 +00005#include <elog.h>
Patrick Rudolph92106b12020-02-19 12:54:06 +01006#include <fsp/graphics.h>
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -08007#include <fsp/util.h>
Patrick Georgi82690962017-09-27 15:24:58 +02008#include <soc/intel/common/vbt.h>
Elyes HAOUASbd1683d2019-05-15 21:05:37 +02009#include <types.h>
Patrick Rudolph92106b12020-02-19 12:54:06 +010010#include <framebuffer_info.h>
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -080011
12enum pixel_format {
13 pixel_rgbx_8bpc = 0,
14 pixel_bgrx_8bpc = 1,
15 pixel_bitmask = 2, /* defined by <rgb>_mask values */
16};
17
Lee Leahy5a9ca4d2016-09-28 17:15:00 -070018static const uint8_t fsp_graphics_info_guid[16] = {
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -080019 0xce, 0x2c, 0xf6, 0x39, 0x25, 0x68, 0x69, 0x46,
20 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07
21};
22
23struct hob_graphics_info {
24 uint64_t framebuffer_base;
25 uint32_t framebuffer_size;
26 uint32_t version;
27 uint32_t horizontal_resolution;
28 uint32_t vertical_resolution;
29 uint32_t pixel_format; /* See enum pixel_format */
30 uint32_t red_mask;
31 uint32_t green_mask;
32 uint32_t blue_mask;
33 uint32_t reserved_mask;
34 uint32_t pixels_per_scanline;
Stefan Reinauer6a001132017-07-13 02:20:27 +020035} __packed;
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -080036
37struct pixel {
38 uint8_t pos;
39 uint8_t size;
40};
41
42static const struct fsp_framebuffer {
43 struct pixel red;
44 struct pixel green;
45 struct pixel blue;
46 struct pixel rsvd;
47} fsp_framebuffer_format_map[] = {
48 [pixel_rgbx_8bpc] = { {0, 8}, {8, 8}, {16, 8}, {24, 8} },
49 [pixel_bgrx_8bpc] = { {16, 8}, {8, 8}, {0, 8}, {24, 8} },
50};
51
Subrata Banik68e642f2023-08-27 20:42:26 +000052enum fw_splash_screen_status {
53 FW_SPLASH_SCREEN_DISABLED,
54 FW_SPLASH_SCREEN_ENABLED,
55};
56
Subrata Banik790b5cf2023-10-03 14:51:26 +000057/* Check and report if an external display is attached */
58__weak int fsp_soc_report_external_display(void)
59{
60 /* Default implementation, on-board display enabled */
61 return 0;
62}
63
Subrata Banik68e642f2023-08-27 20:42:26 +000064/*
65 * Update elog with Firmware Splash Screen related information
66 * based on enum fw_splash_screen_status.
67 *
68 * Possible values for input argument are:
69 * TRUE - FSP initializes display when BMP_LOGO config is enabled.
70 * FALSE - Failed to initialize display although BMP_LOGO config is selected.
71 *
72 * Ignore if BMP_LOGO config is not selected.
73 */
74static void update_fw_splash_screen_event(enum fw_splash_screen_status status)
75{
76 if (!CONFIG(BMP_LOGO))
77 return;
78
79 elog_add_event_byte(ELOG_TYPE_FW_SPLASH_SCREEN, status);
80}
Patrick Rudolph92106b12020-02-19 12:54:06 +010081
Tim Wawrzynczak84428f72021-09-14 13:59:33 -060082void fsp_report_framebuffer_info(const uintptr_t framebuffer_bar,
83 enum lb_fb_orientation orientation)
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -080084{
85 size_t size;
86 const struct hob_graphics_info *ginfo;
87 const struct fsp_framebuffer *fbinfo;
88
Patrick Rudolph92106b12020-02-19 12:54:06 +010089 /*
90 * Pci enumeration happens after silicon init.
91 * After enumeration graphic framebuffer base may be relocated.
92 */
93 if (!framebuffer_bar) {
94 printk(BIOS_ALERT, "Framebuffer BAR invalid\n");
Subrata Banik68e642f2023-08-27 20:42:26 +000095 update_fw_splash_screen_event(FW_SPLASH_SCREEN_DISABLED);
Patrick Rudolph92106b12020-02-19 12:54:06 +010096 return;
97 }
98
Lee Leahyac3b0a62016-07-27 07:40:25 -070099 ginfo = fsp_find_extension_hob_by_guid(fsp_graphics_info_guid, &size);
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -0800100
101 if (!ginfo) {
102 printk(BIOS_ALERT, "Graphics hand-off block not found\n");
Subrata Banik68e642f2023-08-27 20:42:26 +0000103 update_fw_splash_screen_event(FW_SPLASH_SCREEN_DISABLED);
Patrick Rudolph92106b12020-02-19 12:54:06 +0100104 return;
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -0800105 }
106
Lee Leahy016d8f72016-05-17 08:40:02 -0700107 if (ginfo->pixel_format >= ARRAY_SIZE(fsp_framebuffer_format_map)) {
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -0800108 printk(BIOS_ALERT, "FSP set unknown framebuffer format: %d\n",
109 ginfo->pixel_format);
Subrata Banik68e642f2023-08-27 20:42:26 +0000110 update_fw_splash_screen_event(FW_SPLASH_SCREEN_DISABLED);
Patrick Rudolph92106b12020-02-19 12:54:06 +0100111 return;
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -0800112 }
113
Subrata Banik68e642f2023-08-27 20:42:26 +0000114 update_fw_splash_screen_event(FW_SPLASH_SCREEN_ENABLED);
Alexandru Gagniucfb22ff42016-02-25 14:22:03 -0800115 fbinfo = fsp_framebuffer_format_map + ginfo->pixel_format;
116
Patrick Rudolph92106b12020-02-19 12:54:06 +0100117 const struct lb_framebuffer fb = {
118 .physical_address = framebuffer_bar,
119 .x_resolution = ginfo->horizontal_resolution,
120 .y_resolution = ginfo->vertical_resolution,
121 .bytes_per_line = ginfo->pixels_per_scanline * 4,
122 .bits_per_pixel = fbinfo->rsvd.size + fbinfo->red.size +
123 fbinfo->green.size + fbinfo->blue.size,
124 .red_mask_pos = fbinfo->red.pos,
125 .red_mask_size = fbinfo->red.size,
126 .green_mask_pos = fbinfo->green.pos,
127 .green_mask_size = fbinfo->green.size,
128 .blue_mask_pos = fbinfo->blue.pos,
129 .blue_mask_size = fbinfo->blue.size,
130 .reserved_mask_pos = fbinfo->rsvd.pos,
131 .reserved_mask_size = fbinfo->rsvd.size,
Tim Wawrzynczak84428f72021-09-14 13:59:33 -0600132 .orientation = orientation,
Subrata Banik790b5cf2023-10-03 14:51:26 +0000133 .flags = {
134 .has_external_display = fsp_soc_report_external_display(),
135 },
Patrick Rudolph92106b12020-02-19 12:54:06 +0100136 };
Aaron Durbinbdb5c8f2017-05-16 21:39:50 -0500137
Patrick Rudolph92106b12020-02-19 12:54:06 +0100138 fb_add_framebuffer_info_ex(&fb);
Lee Leahy5a9ca4d2016-09-28 17:15:00 -0700139}