[coreboot-gerrit] New patch to review for coreboot: e432fb3 edid: remove float use

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Mon Dec 15 22:58:36 CET 2014


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7803

-gerrit

commit e432fb30c22517194b84d87863d79ac2b778defd
Author: Patrick Georgi <pgeorgi at google.com>
Date:   Mon Dec 15 22:52:14 2014 +0100

    edid: remove float use
    
    First, we don't want floats in our code base.
    Second, the calculation of the aspect ratio was wacky,
    using a value guaranteed to be 0 for aspect ratio calculation.
    
    While at it, define the aspect_* fields to be in tenths, to
    provide some additional resolution. They were that way before,
    but we now also specify it somewhere.
    
    Change-Id: I5511adf4bf76cdd6a69240491372f220ef1aa687
    Signed-off-by: Patrick Georgi <pgeorgi at google.com>
---
 src/include/edid.h |  1 +
 src/lib/edid.c     | 23 ++++++++++++-----------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/include/edid.h b/src/include/edid.h
index 867a82f..9a1fda5 100644
--- a/src/include/edid.h
+++ b/src/include/edid.h
@@ -89,6 +89,7 @@ struct edid {
 	u32 bytes_per_line;
 	/* it is unlikely we need these things. */
 	/* if one of these is non-zero, use that one. */
+	/* they're aspect * 10 to provide some additional resolution */
 	unsigned int aspect_landscape;
 	unsigned int aspect_portrait;
 	const char *range_class;
diff --git a/src/lib/edid.c b/src/lib/edid.c
index 2028c70..f0af620 100644
--- a/src/lib/edid.c
+++ b/src/lib/edid.c
@@ -330,8 +330,8 @@ detailed_block(struct edid *out, unsigned char *x, int in_extension)
 
 				if (x[12] & 0xfc) {
 					int raw_offset = (x[12] & 0xfc) >> 2;
-					printk(BIOS_SPEW, "Real max dotclock: %.2fMHz\n",
-					       (x[9] * 10) - (raw_offset * 0.25));
+					printk(BIOS_SPEW, "Real max dotclock: %dKHz\n",
+					       (x[9] * 10000) - (raw_offset * 250));
 					if (raw_offset >= 40)
 						warning_excessive_dotclock_correction = 1;
 				}
@@ -1109,15 +1109,16 @@ int decode_edid(unsigned char *edid, int size, struct edid *out)
 		out->xsize_cm = edid[0x15];
 		out->ysize_cm = edid[0x16];
 	} else if (claims_one_point_four && (edid[0x15] || edid[0x16])) {
-		if (edid[0x15]) {
-			printk(BIOS_SPEW, "Aspect ratio is %f (landscape)\n",
-			       100.0/(edid[0x16] + 99));
-			/* truncated to integer %. We try to avoid floating point */
-			out->aspect_landscape = 10000 /(edid[0x16] + 99);
-		} else {
-			printk(BIOS_SPEW, "Aspect ratio is %f (portrait)\n",
-			       100.0/(edid[0x15] + 99));
-			out->aspect_portrait = 10000 /(edid[0x16] + 99);
+		if (edid[0x15]) { /* edid[0x15] != 0 && edid[0x16] == 0 */
+			unsigned int ratio = 1000000/(edid[0x15] + 99);
+			printk(BIOS_SPEW, "Aspect ratio is %u.%03u (landscape)\n",
+			       ratio / 1000, ratio % 1000);
+			out->aspect_landscape = ratio / 100;
+		} else { /* edid[0x15] == 0 && edid[0x16] != 0 */
+			unsigned int ratio = 1000000/(edid[0x16] + 99);
+			printk(BIOS_SPEW, "Aspect ratio is %u.%03u (portrait)\n",
+			       ratio / 1000, ratio % 1000);
+			out->aspect_portrait = ratio / 100;
 		}
 	} else {
 		/* Either or both can be zero for 1.3 and before */



More information about the coreboot-gerrit mailing list