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)
This commit is contained in:
Patrick Georgi 2014-12-15 22:52:14 +01:00
parent 46c85d7dfb
commit be71ee5dec
2 changed files with 13 additions and 11 deletions

View File

@ -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;

View File

@ -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 */