qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Arithmetic error in EDID generation fixed
@ 2020-02-26 12:20 Anton V. Boyarshinov
  2020-03-02  7:24 ` Gerd Hoffmann
  2020-03-02  7:45 ` Stefan Weil
  0 siblings, 2 replies; 3+ messages in thread
From: Anton V. Boyarshinov @ 2020-02-26 12:20 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: shaba, qemu-devel

To calculate 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>
---
Changes from v1: get rid of casts

 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..e58472fde5 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] = info->prefx * 254 / 100 / info->dpi;
+    edid[22] = info->prefy * 254 / 100 / info->dpi;
 
     /* display gamma: 2.2 */
     edid[23] = 220 - 100;
-- 
2.21.0




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Arithmetic error in EDID generation fixed
  2020-02-26 12:20 [PATCH v2] Arithmetic error in EDID generation fixed Anton V. Boyarshinov
@ 2020-03-02  7:24 ` Gerd Hoffmann
  2020-03-02  7:45 ` Stefan Weil
  1 sibling, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2020-03-02  7:24 UTC (permalink / raw)
  To: Anton V. Boyarshinov; +Cc: shaba, qemu-devel

On Wed, Feb 26, 2020 at 03:20:54PM +0300, Anton V. Boyarshinov wrote:
> To calculate 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.

Added to vga patch queu.

thanks,
  Gerd



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Arithmetic error in EDID generation fixed
  2020-02-26 12:20 [PATCH v2] Arithmetic error in EDID generation fixed Anton V. Boyarshinov
  2020-03-02  7:24 ` Gerd Hoffmann
@ 2020-03-02  7:45 ` Stefan Weil
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Weil @ 2020-03-02  7:45 UTC (permalink / raw)
  To: Anton V. Boyarshinov, Gerd Hoffmann; +Cc: shaba, qemu-devel


Am 26.02.20 um 13:20 schrieb Anton V. Boyarshinov:
> To calculate 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>
> ---
> Changes from v1: get rid of casts
>
>  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..e58472fde5 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 */
Gerd, is this comment still correct?
> -    edid[21] = info->prefx * info->dpi / 2540;
> -    edid[22] = info->prefy * info->dpi / 2540;
> +    edid[21] = info->prefx * 254 / 100 / info->dpi;
> +    edid[22] = info->prefy * 254 / 100 / info->dpi;


The fix is good, but can be improved:

According to the standard, the values are "rounded to the nearest
centimeter". Currently they are not rounded, but truncated. So this
would be a better approximation:

edid[21] = (info->prefx * 254 / info->dpi + 50) / 100;

...


Regards,

Stefan





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-02  7:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-26 12:20 [PATCH v2] Arithmetic error in EDID generation fixed Anton V. Boyarshinov
2020-03-02  7:24 ` Gerd Hoffmann
2020-03-02  7:45 ` Stefan Weil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).