soc/intel/alderlake: Add ADL-P 4+4 with 28W TDP
[coreboot.git] / src / drivers / intel / fsp2_0 / graphics.c
blobb55696b4bc6aadad9b5b5b5db4cde2abb60cfb17
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <boot/coreboot_tables.h>
4 #include <console/console.h>
5 #include <fsp/graphics.h>
6 #include <fsp/util.h>
7 #include <soc/intel/common/vbt.h>
8 #include <types.h>
9 #include <framebuffer_info.h>
11 enum pixel_format {
12 pixel_rgbx_8bpc = 0,
13 pixel_bgrx_8bpc = 1,
14 pixel_bitmask = 2, /* defined by <rgb>_mask values */
17 static const uint8_t fsp_graphics_info_guid[16] = {
18 0xce, 0x2c, 0xf6, 0x39, 0x25, 0x68, 0x69, 0x46,
19 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07
22 struct hob_graphics_info {
23 uint64_t framebuffer_base;
24 uint32_t framebuffer_size;
25 uint32_t version;
26 uint32_t horizontal_resolution;
27 uint32_t vertical_resolution;
28 uint32_t pixel_format; /* See enum pixel_format */
29 uint32_t red_mask;
30 uint32_t green_mask;
31 uint32_t blue_mask;
32 uint32_t reserved_mask;
33 uint32_t pixels_per_scanline;
34 } __packed;
36 struct pixel {
37 uint8_t pos;
38 uint8_t size;
41 static const struct fsp_framebuffer {
42 struct pixel red;
43 struct pixel green;
44 struct pixel blue;
45 struct pixel rsvd;
46 } fsp_framebuffer_format_map[] = {
47 [pixel_rgbx_8bpc] = { {0, 8}, {8, 8}, {16, 8}, {24, 8} },
48 [pixel_bgrx_8bpc] = { {16, 8}, {8, 8}, {0, 8}, {24, 8} },
52 void fsp_report_framebuffer_info(const uintptr_t framebuffer_bar,
53 enum lb_fb_orientation orientation)
55 size_t size;
56 const struct hob_graphics_info *ginfo;
57 const struct fsp_framebuffer *fbinfo;
60 * Pci enumeration happens after silicon init.
61 * After enumeration graphic framebuffer base may be relocated.
63 if (!framebuffer_bar) {
64 printk(BIOS_ALERT, "Framebuffer BAR invalid\n");
65 return;
68 ginfo = fsp_find_extension_hob_by_guid(fsp_graphics_info_guid, &size);
70 if (!ginfo) {
71 printk(BIOS_ALERT, "Graphics hand-off block not found\n");
72 return;
75 if (ginfo->pixel_format >= ARRAY_SIZE(fsp_framebuffer_format_map)) {
76 printk(BIOS_ALERT, "FSP set unknown framebuffer format: %d\n",
77 ginfo->pixel_format);
78 return;
81 fbinfo = fsp_framebuffer_format_map + ginfo->pixel_format;
83 const struct lb_framebuffer fb = {
84 .physical_address = framebuffer_bar,
85 .x_resolution = ginfo->horizontal_resolution,
86 .y_resolution = ginfo->vertical_resolution,
87 .bytes_per_line = ginfo->pixels_per_scanline * 4,
88 .bits_per_pixel = fbinfo->rsvd.size + fbinfo->red.size +
89 fbinfo->green.size + fbinfo->blue.size,
90 .red_mask_pos = fbinfo->red.pos,
91 .red_mask_size = fbinfo->red.size,
92 .green_mask_pos = fbinfo->green.pos,
93 .green_mask_size = fbinfo->green.size,
94 .blue_mask_pos = fbinfo->blue.pos,
95 .blue_mask_size = fbinfo->blue.size,
96 .reserved_mask_pos = fbinfo->rsvd.pos,
97 .reserved_mask_size = fbinfo->rsvd.size,
98 .orientation = orientation,
101 fb_add_framebuffer_info_ex(&fb);