From b2893a0169ce603926bf13465432a15c4526de97 Mon Sep 17 00:00:00 2001 From: "Ronald G. Minnich" Date: Tue, 23 Apr 2013 10:59:11 -0700 Subject: Provide support for setting up the framebuffer from EDID Add three functions to edid.c: void set_vbe_mode_info_valid(struct edid *edid, uintptr_t fb_addr) takes an edid and uintptr_t, and fills in a static lb_framebuffer struct as well as setting the static vbe_valid to 1 unless some problem is found in the edid. The intent here is that this could be called from the native graphics setup code on both ARM and x86. int vbe_mode_info_valid(void) returns value of the static vbe_valid. void fill_lb_framebuffer(struct lb_framebuffer *framebuffer) copies the static edid_fb to lb_framebuffer. There is now a common vbe.h in src/include, removed the two special ones. In general, graphics in coreboot is a mess, but graphics is always a mess. We don't have a clean way to try two different ways to turn on a device and use the one that works. One battle at a time. Overall, things are much better. The best part: this code would also work for ARM, which also uses EDID. Change-Id: Id23eb61498b331d44ab064b8fb4cb10f07cff7f3 Signed-off-by: Ronald G. Minnich Signed-off-by: Gabe Black Reviewed-on: http://review.coreboot.org/3636 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/lib/edid.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) (limited to 'src/lib/edid.c') diff --git a/src/lib/edid.c b/src/lib/edid.c index a794489aa0..c4c5e455a6 100644 --- a/src/lib/edid.c +++ b/src/lib/edid.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include static int claims_one_point_oh = 0; static int claims_one_point_two = 0; @@ -68,6 +70,9 @@ static int warning_zero_preferred_refresh = 0; static int conformant = 1; +static int vbe_valid; +static struct lb_framebuffer edid_fb; + static char *manufacturer_name(struct edid *out, unsigned char *x) { out->manuf_name[0] = ((x[0] & 0x7C) >> 2) + '@'; @@ -1226,7 +1231,7 @@ int decode_edid(unsigned char *edid, int size, struct edid *out) } printk(BIOS_SPEW, "Checksum\n"); - do_checksum(edid); + vbe_valid = do_checksum(edid); for(i = 0; i < size; i += 128) nonconformant_extension = parse_extension(out, &edid[i]); /* @@ -1386,3 +1391,67 @@ int decode_edid(unsigned char *edid, int size, struct edid *out) * SPWG also says something strange about the LSB of detailed descriptor 1: * "LSB is set to "1" if panel is DE-timing only. H/V can be ignored." */ +/* + * Take an edid, and create a framebuffer. Set vbe_valid to 1. + */ + +void set_vbe_mode_info_valid(struct edid *edid, uintptr_t fb_addr); +void set_vbe_mode_info_valid(struct edid *edid, uintptr_t fb_addr) +{ + edid_fb.physical_address = fb_addr; + edid_fb.x_resolution = edid->ha; + edid_fb.y_resolution = edid->va; + /* In the case of (e.g.) 24bpp, the convention nowadays + * seems to be to round it up to the nearest reasonable + * boundary, because otherwise the byte-packing is hideous. + * So, for example, in RGB with no alpha, the bytes are still + * packed into 32-bit words, the so-called 32bpp-no-alpha mode. + * Or, in 5:6:5 mode, the bytes are also packed into 32-bit words, + * and in 4:4:4 mode, they are packed into 16-bit words. + * Good call on the hardware guys part. + * It's not clear we're covering all cases here, but + * I'm not sure with grahpics you ever can. + */ + edid_fb.bits_per_pixel = edid->bpp; + switch(edid->bpp){ + case 32: + case 24: + /* packed into 4-byte words */ + edid_fb.bytes_per_line = edid->ha * 4; + edid_fb.red_mask_pos = 16; + edid_fb.red_mask_size = 8; + edid_fb.green_mask_pos = 8; + edid_fb.green_mask_size = 8; + edid_fb.blue_mask_pos = 0; + edid_fb.blue_mask_size = 8; + break; + case 16: + /* packed into 2-byte words */ + edid_fb.bytes_per_line = edid->ha * 2; + edid_fb.red_mask_pos = 12; + edid_fb.red_mask_size = 4; + edid_fb.green_mask_pos = 8; + edid_fb.green_mask_size = 4; + edid_fb.blue_mask_pos = 0; + edid_fb.blue_mask_size = 4; + break; + default: + printk(BIOS_SPEW, "%s: unsupported BPP %d\n", __func__, + edid->bpp); + return; + } + + edid_fb.reserved_mask_pos = 0; + edid_fb.reserved_mask_size = 0; + vbe_valid = 1; +} + +int vbe_mode_info_valid(void) +{ + return vbe_valid; +} + +void fill_lb_framebuffer(struct lb_framebuffer *framebuffer) +{ + *framebuffer = edid_fb; +} -- cgit v1.2.3