]> git.proxmox.com Git - mirror_qemu.git/commitdiff
display/edid: add qemu_edid_size()
authorGerd Hoffmann <kraxel@redhat.com>
Tue, 25 Sep 2018 07:56:43 +0000 (09:56 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 27 Sep 2018 06:07:51 +0000 (08:07 +0200)
Helper function to figure the size of a edid blob, by checking how many
extensions are present.  Both the base edid blob and the extensions are
128 bytes in size.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20180925075646.25114-3-kraxel@redhat.com

hw/display/edid-generate.c
include/hw/display/edid.h

index b3e493da1909a14c1a0f052f3767e58e017aeda1..c80397ea969bac9c7195b87f0b864d6ac4c7c882 100644 (file)
@@ -423,3 +423,17 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
         edid_checksum(dta);
     }
 }
+
+size_t qemu_edid_size(uint8_t *edid)
+{
+    uint32_t exts;
+
+    if (edid[0] != 0x00 ||
+        edid[1] != 0xff) {
+        /* doesn't look like a valid edid block */
+        return 0;
+    }
+
+    exts = edid[126];
+    return 128 * (exts + 1);
+}
index 63b60015c361460fbe6250a1f2c12a23d9dabd5d..96910ada0f030518adddb6626b0581dc1c434479 100644 (file)
@@ -14,5 +14,6 @@ typedef struct qemu_edid_info {
 
 void qemu_edid_generate(uint8_t *edid, size_t size,
                         qemu_edid_info *info);
+size_t qemu_edid_size(uint8_t *edid);
 
 #endif /* EDID_H */