[PATCH] Arithmetic error fixed in EDID generation

Anton V. Boyarshinov posted 1 patch 5 years, 8 months ago
Test docker-quick@centos7 failed
Test FreeBSD passed
Test checkpatch passed
Test docker-mingw@fedora failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200225200914.3ec2c07b@x230.localdomain
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
hw/display/edid-generate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] Arithmetic error fixed in EDID generation
Posted by Anton V. Boyarshinov 5 years, 8 months ago
To compute screen size in centimeters we should calculate:
pixels/dpi*2.54
but not
pixels*dpi/2540

Using wrong formula we actually get 65 DPI and very small fonts.

Signed-off-by: Anton V. Boyarshinov <boyarsh@altlinux.org>
---
 hw/display/edid-generate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/display/edid-generate.c b/hw/display/edid-generate.c
index 75c945a948..537e063662 100644
--- a/hw/display/edid-generate.c
+++ b/hw/display/edid-generate.c
@@ -360,8 +360,8 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
     edid[20] = 0xa5;
 
     /* screen size: undefined */
-    edid[21] = info->prefx * info->dpi / 2540;
-    edid[22] = info->prefy * info->dpi / 2540;
+    edid[21] = (uint8_t) ((float) info->prefx / info->dpi * 2.54);
+    edid[22] = (uint8_t) ((float) info->prefy / info->dpi * 2.54);
 
     /* display gamma: 2.2 */
     edid[23] = 220 - 100;
-- 
2.21.0