qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Akihiko Odaki" <akihiko.odaki@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Thomas Huth" <huth@tuxfamily.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PULL 34/35] edid: Fix clock of Detailed Timing Descriptor
Date: Fri,  4 Mar 2022 15:21:22 +0100	[thread overview]
Message-ID: <20220304142123.956171-35-kraxel@redhat.com> (raw)
In-Reply-To: <20220304142123.956171-1-kraxel@redhat.com>

From: Akihiko Odaki <akihiko.odaki@gmail.com>

The clock field is 16-bits in EDID Detailed Timing Descriptor, but
edid_desc_timing assumed it is 32-bit. Write the 16-bit value if it fits
in 16-bit. Write DisplayID otherwise.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Message-Id: <20220213021529.2248-1-akihiko.odaki@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/edid-generate.c | 66 ++++++++++++++++++--------------------
 1 file changed, 32 insertions(+), 34 deletions(-)

diff --git a/hw/display/edid-generate.c b/hw/display/edid-generate.c
index bccf32af69ce..2cb819675e0b 100644
--- a/hw/display/edid-generate.c
+++ b/hw/display/edid-generate.c
@@ -255,33 +255,31 @@ static void edid_desc_dummy(uint8_t *desc)
     edid_desc_type(desc, 0x10);
 }
 
-static void edid_desc_timing(uint8_t *desc, uint32_t refresh_rate,
+static void edid_desc_timing(uint8_t *desc, const Timings *timings,
                              uint32_t xres, uint32_t yres,
                              uint32_t xmm, uint32_t ymm)
 {
-    Timings timings;
-    generate_timings(&timings, refresh_rate, xres, yres);
-    stl_le_p(desc, timings.clock);
+    stw_le_p(desc, timings->clock);
 
     desc[2] = xres   & 0xff;
-    desc[3] = timings.xblank & 0xff;
+    desc[3] = timings->xblank & 0xff;
     desc[4] = (((xres   & 0xf00) >> 4) |
-               ((timings.xblank & 0xf00) >> 8));
+               ((timings->xblank & 0xf00) >> 8));
 
     desc[5] = yres   & 0xff;
-    desc[6] = timings.yblank & 0xff;
+    desc[6] = timings->yblank & 0xff;
     desc[7] = (((yres   & 0xf00) >> 4) |
-               ((timings.yblank & 0xf00) >> 8));
+               ((timings->yblank & 0xf00) >> 8));
 
-    desc[8] = timings.xfront & 0xff;
-    desc[9] = timings.xsync  & 0xff;
+    desc[8] = timings->xfront & 0xff;
+    desc[9] = timings->xsync  & 0xff;
 
-    desc[10] = (((timings.yfront & 0x00f) << 4) |
-                ((timings.ysync  & 0x00f) << 0));
-    desc[11] = (((timings.xfront & 0x300) >> 2) |
-                ((timings.xsync  & 0x300) >> 4) |
-                ((timings.yfront & 0x030) >> 2) |
-                ((timings.ysync  & 0x030) >> 4));
+    desc[10] = (((timings->yfront & 0x00f) << 4) |
+                ((timings->ysync  & 0x00f) << 0));
+    desc[11] = (((timings->xfront & 0x300) >> 2) |
+                ((timings->xsync  & 0x300) >> 4) |
+                ((timings->yfront & 0x030) >> 2) |
+                ((timings->ysync  & 0x030) >> 4));
 
     desc[12] = xmm & 0xff;
     desc[13] = ymm & 0xff;
@@ -348,13 +346,10 @@ static void init_displayid(uint8_t *did)
     edid_checksum(did + 1, did[2] + 4);
 }
 
-static void qemu_displayid_generate(uint8_t *did, uint32_t refresh_rate,
+static void qemu_displayid_generate(uint8_t *did, const Timings *timings,
                                     uint32_t xres, uint32_t yres,
                                     uint32_t xmm, uint32_t ymm)
 {
-    Timings timings;
-    generate_timings(&timings, refresh_rate, xres, yres);
-
     did[0] = 0x70; /* display id extension */
     did[1] = 0x13; /* version 1.3 */
     did[2] = 23;   /* length */
@@ -364,21 +359,21 @@ static void qemu_displayid_generate(uint8_t *did, uint32_t refresh_rate,
     did[6] = 0x00; /* revision */
     did[7] = 0x14; /* block length */
 
-    did[8]  = timings.clock  & 0xff;
-    did[9]  = (timings.clock & 0xff00) >> 8;
-    did[10] = (timings.clock & 0xff0000) >> 16;
+    did[8]  = timings->clock  & 0xff;
+    did[9]  = (timings->clock & 0xff00) >> 8;
+    did[10] = (timings->clock & 0xff0000) >> 16;
 
     did[11] = 0x88; /* leave aspect ratio undefined */
 
     stw_le_p(did + 12, 0xffff & (xres - 1));
-    stw_le_p(did + 14, 0xffff & (timings.xblank - 1));
-    stw_le_p(did + 16, 0xffff & (timings.xfront - 1));
-    stw_le_p(did + 18, 0xffff & (timings.xsync - 1));
+    stw_le_p(did + 14, 0xffff & (timings->xblank - 1));
+    stw_le_p(did + 16, 0xffff & (timings->xfront - 1));
+    stw_le_p(did + 18, 0xffff & (timings->xsync - 1));
 
     stw_le_p(did + 20, 0xffff & (yres - 1));
-    stw_le_p(did + 22, 0xffff & (timings.yblank - 1));
-    stw_le_p(did + 24, 0xffff & (timings.yfront - 1));
-    stw_le_p(did + 26, 0xffff & (timings.ysync - 1));
+    stw_le_p(did + 22, 0xffff & (timings->yblank - 1));
+    stw_le_p(did + 24, 0xffff & (timings->yfront - 1));
+    stw_le_p(did + 26, 0xffff & (timings->ysync - 1));
 
     edid_checksum(did + 1, did[2] + 4);
 }
@@ -386,6 +381,7 @@ static void qemu_displayid_generate(uint8_t *did, uint32_t refresh_rate,
 void qemu_edid_generate(uint8_t *edid, size_t size,
                         qemu_edid_info *info)
 {
+    Timings timings;
     uint8_t *desc = edid + 54;
     uint8_t *xtra3 = NULL;
     uint8_t *dta = NULL;
@@ -409,9 +405,6 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
     if (!info->prefy) {
         info->prefy = 800;
     }
-    if (info->prefx >= 4096 || info->prefy >= 4096) {
-        large_screen = 1;
-    }
     if (info->width_mm && info->height_mm) {
         width_mm = info->width_mm;
         height_mm = info->height_mm;
@@ -421,6 +414,11 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
         height_mm = qemu_edid_dpi_to_mm(dpi, info->prefy);
     }
 
+    generate_timings(&timings, refresh_rate, info->prefx, info->prefy);
+    if (info->prefx >= 4096 || info->prefy >= 4096 || timings.clock >= 65536) {
+        large_screen = 1;
+    }
+
     /* =============== extensions  =============== */
 
     if (size >= 256) {
@@ -501,7 +499,7 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
 
     if (!large_screen) {
         /* The DTD section has only 12 bits to store the resolution */
-        edid_desc_timing(desc, refresh_rate, info->prefx, info->prefy,
+        edid_desc_timing(desc, &timings, info->prefx, info->prefy,
                          width_mm, height_mm);
         desc = edid_desc_next(edid, dta, desc);
     }
@@ -536,7 +534,7 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
     /* =============== display id extensions =============== */
 
     if (did && large_screen) {
-        qemu_displayid_generate(did, refresh_rate, info->prefx, info->prefy,
+        qemu_displayid_generate(did, &timings, info->prefx, info->prefy,
                                 width_mm, height_mm);
     }
 
-- 
2.35.1



  parent reply	other threads:[~2022-03-04 15:19 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-04 14:20 [PULL 00/35] Kraxel 20220304 patches Gerd Hoffmann
2022-03-04 14:20 ` [PULL 01/35] hw/usb: pacify xhciwmi.exe warning Gerd Hoffmann
2022-03-04 14:20 ` [PULL 02/35] hw/usb/dev-mtp: create directories with a+x mode mask Gerd Hoffmann
2022-03-04 14:20 ` [PULL 03/35] usb/ohci: Move trace point and log ep number to help debugging Gerd Hoffmann
2022-03-04 14:20 ` [PULL 04/35] usb/ohci: Move cancelling async packet to ohci_stop_endpoints() Gerd Hoffmann
2022-03-04 14:20 ` [PULL 05/35] usb/ohci: Move USBPortOps related functions together Gerd Hoffmann
2022-03-04 14:20 ` [PULL 06/35] usb/ohci: Merge ohci_async_cancel_device() into ohci_child_detach() Gerd Hoffmann
2022-03-04 14:20 ` [PULL 07/35] usb/ohci: Don't use packet from OHCIState for isochronous transfers Gerd Hoffmann
2022-03-04 14:20 ` [PULL 08/35] audio: replace open-coded buffer arithmetic Gerd Hoffmann
2022-03-04 14:20 ` [PULL 09/35] audio: move function audio_pcm_hw_clip_out() Gerd Hoffmann
2022-03-04 14:20 ` [PULL 10/35] audio: add function audio_pcm_hw_conv_in() Gerd Hoffmann
2022-03-04 14:20 ` [PULL 11/35] audio: inline function audio_pcm_sw_get_rpos_in() Gerd Hoffmann
2022-03-04 14:21 ` [PULL 12/35] paaudio: increase default latency to 46ms Gerd Hoffmann
2022-03-04 14:21 ` [PULL 13/35] jackaudio: use more jack audio buffers Gerd Hoffmann
2022-03-04 14:21 ` [PULL 14/35] audio: copy playback stream in sequential order Gerd Hoffmann
2022-03-04 14:21 ` [PULL 15/35] audio: add pcm_ops function table for capture backend Gerd Hoffmann
2022-03-04 14:21 ` [PULL 16/35] Revert "audio: fix wavcapture segfault" Gerd Hoffmann
2022-03-04 14:21 ` [PULL 17/35] audio: restore mixing-engine playback buffer size Gerd Hoffmann
2022-03-04 14:21 ` [PULL 18/35] paaudio: reduce effective " Gerd Hoffmann
2022-03-04 14:21 ` [PULL 19/35] dsoundaudio: " Gerd Hoffmann
2022-03-04 14:21 ` [PULL 20/35] ossaudio: " Gerd Hoffmann
2022-03-04 14:21 ` [PULL 21/35] paaudio: fix samples vs. frames mix-up Gerd Hoffmann
2022-03-04 14:21 ` [PULL 22/35] sdlaudio: " Gerd Hoffmann
2022-03-04 14:21 ` [PULL 23/35] hw/usb/redirect.c: Stop using qemu_oom_check() Gerd Hoffmann
2022-03-04 14:21 ` [PULL 24/35] coreaudio: Notify error in coreaudio_init_out Gerd Hoffmann
2022-03-04 14:21 ` [PULL 25/35] hw/i386: Improve bounds checking in OVMF table parsing Gerd Hoffmann
2022-03-04 14:21 ` [PULL 26/35] hw/i386: Replace magic number with field length calculation Gerd Hoffmann
2022-03-04 14:21 ` [PULL 27/35] docs: Add spec of OVMF GUIDed table for SEV guests Gerd Hoffmann
2022-03-04 14:21 ` [PULL 28/35] ui/console: fix crash when using gl context with non-gl listeners Gerd Hoffmann
2022-03-04 14:21 ` [PULL 29/35] ui/console: fix texture leak when calling surface_gl_create_texture() Gerd Hoffmann
2022-03-04 14:21 ` [PULL 30/35] ui: do not create a surface when resizing a GL scanout Gerd Hoffmann
2022-03-04 14:21 ` [PULL 31/35] ui/clipboard: fix use-after-free regression Gerd Hoffmann
2022-03-04 14:21 ` [PULL 32/35] ui/cocoa: Add Services menu Gerd Hoffmann
2022-03-04 14:21 ` [PULL 33/35] softmmu/qdev-monitor: Add virtio-gpu-gl aliases Gerd Hoffmann
2022-03-04 14:21 ` Gerd Hoffmann [this message]
2022-03-04 14:21 ` [PULL 35/35] hw/display/vmware_vga: replace fprintf calls with trace events Gerd Hoffmann
2022-03-05 10:46 ` [PULL 00/35] Kraxel 20220304 patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220304142123.956171-35-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=akihiko.odaki@gmail.com \
    --cc=berrange@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=f4bug@amsat.org \
    --cc=huth@tuxfamily.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).