[coreboot-gerrit] Patch set updated for coreboot: drivers/intel/fsp2_0: Add utility to parse framebuffer info

Alexandru Gagniuc (mr.nuke.me@gmail.com) gerrit at coreboot.org
Mon Jan 25 18:04:08 CET 2016


Alexandru Gagniuc (mr.nuke.me at gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13385

-gerrit

commit 4bc2e6e7c6aebf7c636d56e715a293ea2e9f5e39
Author: Alexandru Gagniuc <alexandrux.gagniuc at intel.com>
Date:   Tue Dec 15 15:26:10 2015 -0800

    drivers/intel/fsp2_0: Add utility to parse framebuffer info
    
    If graphics initialization was succesful, FSP silicon_init will add
    a hand-off block containing the description of the framebuffer. Add a
    utility to parse this block to a struct lb_framebuffer entry.
    
    Change-Id: I9efcd9f6e0b867cd23b9c9772604411872754c63
    Signed-off-by: Alexandru Gagniuc <alexandrux.gagniuc at intel.com>
---
 src/drivers/intel/fsp2_0/Makefile.inc       |  1 +
 src/drivers/intel/fsp2_0/graphics.c         | 93 +++++++++++++++++++++++++++++
 src/drivers/intel/fsp2_0/include/fsp/util.h |  2 +
 3 files changed, 96 insertions(+)

diff --git a/src/drivers/intel/fsp2_0/Makefile.inc b/src/drivers/intel/fsp2_0/Makefile.inc
index d210c21..404f251 100644
--- a/src/drivers/intel/fsp2_0/Makefile.inc
+++ b/src/drivers/intel/fsp2_0/Makefile.inc
@@ -3,6 +3,7 @@ romstage-y += hand_off_block.c
 romstage-y += util.c
 romstage-y += memory_init.c
 
+ramstage-y += graphics.c
 ramstage-y += hand_off_block.c
 ramstage-y += notify.c
 ramstage-y += silicon_init.c
diff --git a/src/drivers/intel/fsp2_0/graphics.c b/src/drivers/intel/fsp2_0/graphics.c
new file mode 100644
index 0000000..e7e918b
--- /dev/null
+++ b/src/drivers/intel/fsp2_0/graphics.c
@@ -0,0 +1,93 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Intel Corp.
+ * (Written by Alexandru Gagniuc <alexandrux.gagniuc at intel.com> for Intel Corp.)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <console/console.h>
+#include <fsp/util.h>
+
+enum pixel_format {
+	pixel_rgbx_8bpc = 0,
+	pixel_bgrx_8bpc = 1,
+	pixel_bitmask = 2,		/* defined by <rgb>_mask values */
+};
+
+static const uint8_t uuid_graphics_info[16] = {
+	0xce, 0x2c, 0xf6, 0x39, 0x25, 0x68, 0x69, 0x46,
+	0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07
+};
+
+struct hob_graphics_info {
+	uint64_t framebuffer_base;
+	uint32_t framebuffer_size;
+	uint32_t version;
+	uint32_t horizontal_resolution;
+	uint32_t vertical_resolution;
+	uint32_t pixel_format;		/* See enum pixel_format */
+	uint32_t red_mask;
+	uint32_t green_mask;
+	uint32_t blue_mask;
+	uint32_t reserved_mask;
+	uint32_t pixels_per_scanline;
+} __attribute__((packed));
+
+struct pixel {
+	uint8_t pos;
+	uint8_t size;
+};
+
+static const struct fsp_framebuffer {
+	struct pixel red;
+	struct pixel green;
+	struct pixel blue;
+	struct pixel rsvd;
+} fsp_framebuffer_format_map[] = {
+	[pixel_rgbx_8bpc] = { {0, 8}, {8, 8}, {16, 8}, {24, 8} },
+	[pixel_bgrx_8bpc] = { {16, 8}, {8, 8}, {0, 8}, {24, 8} },
+};
+
+enum cb_err fsp_fill_lb_framebuffer(struct lb_framebuffer *framebuffer)
+{
+	size_t size;
+	const struct hob_graphics_info *ginfo;
+	const struct fsp_framebuffer *fbinfo;
+
+	ginfo = fsp_find_extension_hob_by_uuid(uuid_graphics_info, &size);
+
+	if (!ginfo) {
+		printk(BIOS_ALERT, "Graphics hand-off block not found\n");
+		return CB_ERR;
+	}
+
+	if (ginfo->pixel_format > ARRAY_SIZE(fsp_framebuffer_format_map)) {
+		printk(BIOS_ALERT, "FSP set unknown framebuffer format: %d\n",
+		       ginfo->pixel_format);
+		return CB_ERR;
+	}
+
+	fbinfo = fsp_framebuffer_format_map + ginfo->pixel_format;
+
+	framebuffer->physical_address = ginfo->framebuffer_base;
+	framebuffer->x_resolution = ginfo->horizontal_resolution;
+	framebuffer->y_resolution = ginfo->vertical_resolution;
+	framebuffer->bytes_per_line = ginfo->pixels_per_scanline * 4;
+	framebuffer->bits_per_pixel = 32;
+	framebuffer->red_mask_pos = fbinfo->red.pos;
+	framebuffer->red_mask_size = fbinfo->red.size;
+	framebuffer->green_mask_pos = fbinfo->green.pos;
+	framebuffer->green_mask_size = fbinfo->green.size;
+	framebuffer->blue_mask_pos = fbinfo->blue.pos;
+	framebuffer->blue_mask_size = fbinfo->blue.size;
+	framebuffer->reserved_mask_pos = fbinfo->rsvd.pos;
+	framebuffer->reserved_mask_size = fbinfo->rsvd.pos;
+	framebuffer->tag = LB_TAG_FRAMEBUFFER;
+	framebuffer->size = sizeof(*framebuffer);
+	return CB_SUCCESS;
+}
diff --git a/src/drivers/intel/fsp2_0/include/fsp/util.h b/src/drivers/intel/fsp2_0/include/fsp/util.h
index 4c47987..cdade32 100644
--- a/src/drivers/intel/fsp2_0/include/fsp/util.h
+++ b/src/drivers/intel/fsp2_0/include/fsp/util.h
@@ -13,6 +13,7 @@
 #ifndef _FSP2_0_UTIL_H_
 #define _FSP2_0_UTIL_H_
 
+#include <boot/coreboot_tables.h>
 #include <fsp/info_header.h>
 #include <device/resource.h>
 
@@ -23,6 +24,7 @@
 void fsp_save_hob_list(void *hob_list_ptr);
 const void *fsp_get_hob_list(void);
 const void *fsp_find_extension_hob_by_uuid(const uint8_t *uuid, size_t *size);
+enum cb_err fsp_fill_lb_framebuffer(struct lb_framebuffer *framebuffer);
 /*
  * Hand-off-block utilities which do not depend on CBMEM, but need to be passed
  * the HOB list explicitly.



More information about the coreboot-gerrit mailing list