summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2014-12-15 22:52:14 +0100
committerPatrick Georgi <pgeorgi@google.com>2014-12-16 21:31:35 +0100
commitbe71ee5dec8f038cdd0e98efe93dadf0128d0f24 (patch)
tree266c419ccd70a23d3080245711d2f6d28e70b7a0 /src/lib
parent46c85d7dfbe6b789f24f724dee189d529c215c76 (diff)
downloadcoreboot-be71ee5dec8f038cdd0e98efe93dadf0128d0f24.tar.xz
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 like that already but we now also commit to that. Change-Id: I5511adf4bf76cdd6a69240491372f220ef1aa687 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: http://review.coreboot.org/7803 Reviewed-by: Marc Jones <marc.jones@se-eng.com> Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/edid.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/lib/edid.c b/src/lib/edid.c
index 2028c707a9..b11083370a 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 = 100000/(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 = 100000/(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 */