Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 2 | |
Elyes HAOUAS | 0edf6a5 | 2019-10-26 18:41:47 +0200 | [diff] [blame] | 3 | #include <boot/coreboot_tables.h> |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 4 | #include <console/console.h> |
Subrata Banik | 68e642f | 2023-08-27 20:42:26 +0000 | [diff] [blame^] | 5 | #include <elog.h> |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 6 | #include <fsp/graphics.h> |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 7 | #include <fsp/util.h> |
Patrick Georgi | 8269096 | 2017-09-27 15:24:58 +0200 | [diff] [blame] | 8 | #include <soc/intel/common/vbt.h> |
Elyes HAOUAS | bd1683d | 2019-05-15 21:05:37 +0200 | [diff] [blame] | 9 | #include <types.h> |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 10 | #include <framebuffer_info.h> |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 11 | |
| 12 | enum pixel_format { |
| 13 | pixel_rgbx_8bpc = 0, |
| 14 | pixel_bgrx_8bpc = 1, |
| 15 | pixel_bitmask = 2, /* defined by <rgb>_mask values */ |
| 16 | }; |
| 17 | |
Lee Leahy | 5a9ca4d | 2016-09-28 17:15:00 -0700 | [diff] [blame] | 18 | static const uint8_t fsp_graphics_info_guid[16] = { |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 19 | 0xce, 0x2c, 0xf6, 0x39, 0x25, 0x68, 0x69, 0x46, |
| 20 | 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07 |
| 21 | }; |
| 22 | |
| 23 | struct 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 Reinauer | 6a00113 | 2017-07-13 02:20:27 +0200 | [diff] [blame] | 35 | } __packed; |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 36 | |
| 37 | struct pixel { |
| 38 | uint8_t pos; |
| 39 | uint8_t size; |
| 40 | }; |
| 41 | |
| 42 | static 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 Banik | 68e642f | 2023-08-27 20:42:26 +0000 | [diff] [blame^] | 52 | enum fw_splash_screen_status { |
| 53 | FW_SPLASH_SCREEN_DISABLED, |
| 54 | FW_SPLASH_SCREEN_ENABLED, |
| 55 | }; |
| 56 | |
| 57 | /* |
| 58 | * Update elog with Firmware Splash Screen related information |
| 59 | * based on enum fw_splash_screen_status. |
| 60 | * |
| 61 | * Possible values for input argument are: |
| 62 | * TRUE - FSP initializes display when BMP_LOGO config is enabled. |
| 63 | * FALSE - Failed to initialize display although BMP_LOGO config is selected. |
| 64 | * |
| 65 | * Ignore if BMP_LOGO config is not selected. |
| 66 | */ |
| 67 | static void update_fw_splash_screen_event(enum fw_splash_screen_status status) |
| 68 | { |
| 69 | if (!CONFIG(BMP_LOGO)) |
| 70 | return; |
| 71 | |
| 72 | elog_add_event_byte(ELOG_TYPE_FW_SPLASH_SCREEN, status); |
| 73 | } |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 74 | |
Tim Wawrzynczak | 84428f7 | 2021-09-14 13:59:33 -0600 | [diff] [blame] | 75 | void fsp_report_framebuffer_info(const uintptr_t framebuffer_bar, |
| 76 | enum lb_fb_orientation orientation) |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 77 | { |
| 78 | size_t size; |
| 79 | const struct hob_graphics_info *ginfo; |
| 80 | const struct fsp_framebuffer *fbinfo; |
| 81 | |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 82 | /* |
| 83 | * Pci enumeration happens after silicon init. |
| 84 | * After enumeration graphic framebuffer base may be relocated. |
| 85 | */ |
| 86 | if (!framebuffer_bar) { |
| 87 | printk(BIOS_ALERT, "Framebuffer BAR invalid\n"); |
Subrata Banik | 68e642f | 2023-08-27 20:42:26 +0000 | [diff] [blame^] | 88 | update_fw_splash_screen_event(FW_SPLASH_SCREEN_DISABLED); |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 89 | return; |
| 90 | } |
| 91 | |
Lee Leahy | ac3b0a6 | 2016-07-27 07:40:25 -0700 | [diff] [blame] | 92 | ginfo = fsp_find_extension_hob_by_guid(fsp_graphics_info_guid, &size); |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 93 | |
| 94 | if (!ginfo) { |
| 95 | printk(BIOS_ALERT, "Graphics hand-off block not found\n"); |
Subrata Banik | 68e642f | 2023-08-27 20:42:26 +0000 | [diff] [blame^] | 96 | update_fw_splash_screen_event(FW_SPLASH_SCREEN_DISABLED); |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 97 | return; |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 98 | } |
| 99 | |
Lee Leahy | 016d8f7 | 2016-05-17 08:40:02 -0700 | [diff] [blame] | 100 | if (ginfo->pixel_format >= ARRAY_SIZE(fsp_framebuffer_format_map)) { |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 101 | printk(BIOS_ALERT, "FSP set unknown framebuffer format: %d\n", |
| 102 | ginfo->pixel_format); |
Subrata Banik | 68e642f | 2023-08-27 20:42:26 +0000 | [diff] [blame^] | 103 | update_fw_splash_screen_event(FW_SPLASH_SCREEN_DISABLED); |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 104 | return; |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 105 | } |
| 106 | |
Subrata Banik | 68e642f | 2023-08-27 20:42:26 +0000 | [diff] [blame^] | 107 | update_fw_splash_screen_event(FW_SPLASH_SCREEN_ENABLED); |
Alexandru Gagniuc | fb22ff4 | 2016-02-25 14:22:03 -0800 | [diff] [blame] | 108 | fbinfo = fsp_framebuffer_format_map + ginfo->pixel_format; |
| 109 | |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 110 | const struct lb_framebuffer fb = { |
| 111 | .physical_address = framebuffer_bar, |
| 112 | .x_resolution = ginfo->horizontal_resolution, |
| 113 | .y_resolution = ginfo->vertical_resolution, |
| 114 | .bytes_per_line = ginfo->pixels_per_scanline * 4, |
| 115 | .bits_per_pixel = fbinfo->rsvd.size + fbinfo->red.size + |
| 116 | fbinfo->green.size + fbinfo->blue.size, |
| 117 | .red_mask_pos = fbinfo->red.pos, |
| 118 | .red_mask_size = fbinfo->red.size, |
| 119 | .green_mask_pos = fbinfo->green.pos, |
| 120 | .green_mask_size = fbinfo->green.size, |
| 121 | .blue_mask_pos = fbinfo->blue.pos, |
| 122 | .blue_mask_size = fbinfo->blue.size, |
| 123 | .reserved_mask_pos = fbinfo->rsvd.pos, |
| 124 | .reserved_mask_size = fbinfo->rsvd.size, |
Tim Wawrzynczak | 84428f7 | 2021-09-14 13:59:33 -0600 | [diff] [blame] | 125 | .orientation = orientation, |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 126 | }; |
Aaron Durbin | bdb5c8f | 2017-05-16 21:39:50 -0500 | [diff] [blame] | 127 | |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 128 | fb_add_framebuffer_info_ex(&fb); |
Lee Leahy | 5a9ca4d | 2016-09-28 17:15:00 -0700 | [diff] [blame] | 129 | } |