summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Anderson <dianders@chromium.org>2015-10-28 09:18:28 -0700
committerPatrick Georgi <pgeorgi@google.com>2015-11-19 21:37:42 +0100
commitbca67fb7dc02a6342f6a19738bfd25da21369057 (patch)
treee61f4c5ee9349acdcc1f2c9395c4cc14fc14e26a
parent78e226cf36af511bd435d4f6b3f9163fbc8322a0 (diff)
downloadcoreboot-bca67fb7dc02a6342f6a19738bfd25da21369057.tar.xz
edid: Don't half parse (and wrongly print) more detailed timings
The EDID parsing code continued to update _some_ fields of the output edid but not others if "did_detailed_timing" was already set. It also then went on to print out this halfway mix of modes each time, despite the fact that it didn't really update everything. Let's fix that. We'll reduce code changes by using a temporary copy of data in detailed_block() and then we'll copy it back if we decide we should update. BRANCH=none BUG=chrome-os-partner:46998 TEST=No more bogus printouts Change-Id: Idbfa233e0997244c22ef21c892c4473a91621821 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 4d69999cdd7ce3cd2c9332ab3f22ea8eb4b6f2e9 Original-Change-Id: Ia72cac7fda2772f26477e43237678fa30feca584 Original-Signed-off-by: Douglas Anderson <dianders@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/309541 Original-Reviewed-on: https://chromium-review.googlesource.com/309609 Original-Commit-Ready: David Hendricks <dhendrix@chromium.org> Original-Tested-by: David Hendricks <dhendrix@chromium.org> Original-Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-on: http://review.coreboot.org/12444 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
-rw-r--r--src/lib/edid.c125
1 files changed, 67 insertions, 58 deletions
diff --git a/src/lib/edid.c b/src/lib/edid.c
index 8c8ab6f38d..3aebc65e00 100644
--- a/src/lib/edid.c
+++ b/src/lib/edid.c
@@ -91,6 +91,8 @@ static struct {
const char *stereo;
} extra_info;
+static struct edid tmp_edid;
+
static int vbe_valid;
static struct lb_framebuffer edid_fb;
@@ -197,9 +199,10 @@ extract_string(unsigned char *x, int *valid_termination, int len)
/* 1 means valid data */
static int
-detailed_block(struct edid *out, unsigned char *x, int in_extension,
+detailed_block(struct edid *result_edid, unsigned char *x, int in_extension,
struct edid_context *c)
{
+ struct edid *out = &tmp_edid;
int i;
#if 1
printk(BIOS_SPEW, "Hex of detail: ");
@@ -208,6 +211,9 @@ detailed_block(struct edid *out, unsigned char *x, int in_extension,
printk(BIOS_SPEW, "\n");
#endif
+ /* Result might already have some valid fields like mode_is_supported */
+ *out = *result_edid;
+
if (x[0] == 0 && x[1] == 0) {
/* Monitor descriptor block, not detailed timing descriptor. */
if (x[2] != 0) {
@@ -443,63 +449,59 @@ detailed_block(struct edid *out, unsigned char *x, int in_extension,
c->has_valid_descriptor_ordering = 0;
}
- if (! c->did_detailed_timing){
- /* Edid contains pixel clock in terms of 10KHz */
- out->mode.pixel_clock = (x[0] + (x[1] << 8)) * 10;
- /*
- LVDS supports following pixel clocks
- 25000...112000 kHz: single channel
- 80000...224000 kHz: dual channel
- There is some overlap in theoretically supported
- pixel clock between single-channel and dual-channel.
- In practice with current panels all panels
- <= 75200 kHz: single channel
- >= 97750 kHz: dual channel
- We have no samples between those values, so put a
- threshold at 95000 kHz. If we get anything over
- 95000 kHz with single channel, we can make this
- more sofisticated but it's currently not needed.
- */
- out->mode.lvds_dual_channel = (out->mode.pixel_clock >= 95000);
- extra_info.x_mm = (x[12] + ((x[14] & 0xF0) << 4));
- extra_info.y_mm = (x[13] + ((x[14] & 0x0F) << 8));
- out->mode.ha = (x[2] + ((x[4] & 0xF0) << 4));
- out->mode.hbl = (x[3] + ((x[4] & 0x0F) << 8));
- out->mode.hso = (x[8] + ((x[11] & 0xC0) << 2));
- out->mode.hspw = (x[9] + ((x[11] & 0x30) << 4));
- out->mode.hborder = x[15];
- out->mode.va = (x[5] + ((x[7] & 0xF0) << 4));
- out->mode.vbl = (x[6] + ((x[7] & 0x0F) << 8));
- out->mode.vso = ((x[10] >> 4) + ((x[11] & 0x0C) << 2));
- out->mode.vspw = ((x[10] & 0x0F) + ((x[11] & 0x03) << 4));
- out->mode.vborder = x[16];
- /* set up some reasonable defaults for payloads.
- * We observe that most modern chipsets we work with
- * tend to support rgb888 without regard to the
- * panel bits per color or other settings. The rgb888
- * is a convenient layout for software because
- * it avoids the messy bit stuffing of rgb565 or rgb444.
- * It makes a reasonable trade of memory for speed.
- * So, set up the default for
- * 32 bits per pixel
- * rgb888 (i.e. no alpha, but pixels on 32-bit boundaries)
- * The mainboard can modify these if needed, though
- * we have yet to see a case where that will happen.
- * The existing ARM mainboards don't even call this function
- * so this will not affect them.
- */
- out->framebuffer_bits_per_pixel = 32;
-
- out->x_resolution = ALIGN(out->mode.ha *
- ((out->framebuffer_bits_per_pixel + 7) / 8),
- 64) / (out->framebuffer_bits_per_pixel/8);
- out->y_resolution = out->mode.va;
- out->bytes_per_line = ALIGN(out->mode.ha *
- ((out->framebuffer_bits_per_pixel + 7)/8),
- 64);
- printk(BIOS_SPEW, "Did detailed timing\n");
- }
- c->did_detailed_timing = 1;
+ /* Edid contains pixel clock in terms of 10KHz */
+ out->mode.pixel_clock = (x[0] + (x[1] << 8)) * 10;
+ /*
+ LVDS supports following pixel clocks
+ 25000...112000 kHz: single channel
+ 80000...224000 kHz: dual channel
+ There is some overlap in theoretically supported
+ pixel clock between single-channel and dual-channel.
+ In practice with current panels all panels
+ <= 75200 kHz: single channel
+ >= 97750 kHz: dual channel
+ We have no samples between those values, so put a
+ threshold at 95000 kHz. If we get anything over
+ 95000 kHz with single channel, we can make this
+ more sofisticated but it's currently not needed.
+ */
+ out->mode.lvds_dual_channel = (out->mode.pixel_clock >= 95000);
+ extra_info.x_mm = (x[12] + ((x[14] & 0xF0) << 4));
+ extra_info.y_mm = (x[13] + ((x[14] & 0x0F) << 8));
+ out->mode.ha = (x[2] + ((x[4] & 0xF0) << 4));
+ out->mode.hbl = (x[3] + ((x[4] & 0x0F) << 8));
+ out->mode.hso = (x[8] + ((x[11] & 0xC0) << 2));
+ out->mode.hspw = (x[9] + ((x[11] & 0x30) << 4));
+ out->mode.hborder = x[15];
+ out->mode.va = (x[5] + ((x[7] & 0xF0) << 4));
+ out->mode.vbl = (x[6] + ((x[7] & 0x0F) << 8));
+ out->mode.vso = ((x[10] >> 4) + ((x[11] & 0x0C) << 2));
+ out->mode.vspw = ((x[10] & 0x0F) + ((x[11] & 0x03) << 4));
+ out->mode.vborder = x[16];
+ /* set up some reasonable defaults for payloads.
+ * We observe that most modern chipsets we work with
+ * tend to support rgb888 without regard to the
+ * panel bits per color or other settings. The rgb888
+ * is a convenient layout for software because
+ * it avoids the messy bit stuffing of rgb565 or rgb444.
+ * It makes a reasonable trade of memory for speed.
+ * So, set up the default for
+ * 32 bits per pixel
+ * rgb888 (i.e. no alpha, but pixels on 32-bit boundaries)
+ * The mainboard can modify these if needed, though
+ * we have yet to see a case where that will happen.
+ * The existing ARM mainboards don't even call this function
+ * so this will not affect them.
+ */
+ out->framebuffer_bits_per_pixel = 32;
+
+ out->x_resolution = ALIGN(out->mode.ha *
+ ((out->framebuffer_bits_per_pixel + 7) / 8),
+ 64) / (out->framebuffer_bits_per_pixel/8);
+ out->y_resolution = out->mode.va;
+ out->bytes_per_line = ALIGN(out->mode.ha *
+ ((out->framebuffer_bits_per_pixel + 7)/8),
+ 64);
switch ((x[17] & 0x18) >> 3) {
case 0x00:
extra_info.syncmethod = " analog composite";
@@ -556,6 +558,13 @@ detailed_block(struct edid *out, unsigned char *x, int in_extension,
out->mode.phsync, out->mode.pvsync,
extra_info.syncmethod, x[17] & 0x80 ?" interlaced" : "",
extra_info.stereo);
+
+ if (! c->did_detailed_timing) {
+ printk(BIOS_SPEW, "Did detailed timing\n");
+ c->did_detailed_timing = 1;
+ *result_edid = *out;
+ }
+
return 1;
}