All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konstantin Nazarov <mail@knazarov.com>
To: qemu-devel@nongnu.org
Cc: Konstantin Nazarov <mail@knazarov.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Akihiko Odaki <akihiko.odaki@gmail.com>
Subject: [PATCH v3 2/3] edid: allow arbitrary-length checksums
Date: Mon, 15 Mar 2021 14:46:38 +0300	[thread overview]
Message-ID: <20210315114639.91953-2-mail@knazarov.com> (raw)
In-Reply-To: <20210315114639.91953-1-mail@knazarov.com>

Some of the EDID extensions like DisplayID do checksums of their
subsections. Currently checksums can be only applied to the whole
extension blocks which are 128 bytes.

This patch allows to checksum arbitrary parts of EDID, and not only
whole extension blocks.

Based-on: <20210303152948.59943-2-akihiko.odaki@gmail.com>
Signed-off-by: Konstantin Nazarov <mail@knazarov.com>
---
 hw/display/edid-generate.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/display/edid-generate.c b/hw/display/edid-generate.c
index 1e1d89b9a78..530bdbdf06e 100644
--- a/hw/display/edid-generate.c
+++ b/hw/display/edid-generate.c
@@ -158,17 +158,17 @@ static void edid_fill_modes(uint8_t *edid, uint8_t *xtra3, uint8_t *dta,
     }
 }
 
-static void edid_checksum(uint8_t *edid)
+static void edid_checksum(uint8_t *edid, size_t len)
 {
     uint32_t sum = 0;
     int i;
 
-    for (i = 0; i < 127; i++) {
+    for (i = 0; i < len; i++) {
         sum += edid[i];
     }
     sum &= 0xff;
     if (sum) {
-        edid[127] = 0x100 - sum;
+        edid[len] = 0x100 - sum;
     }
 }
 
@@ -452,9 +452,9 @@ void qemu_edid_generate(uint8_t *edid, size_t size,
     /* =============== finish up =============== */
 
     edid_fill_modes(edid, xtra3, dta, info->maxx, info->maxy);
-    edid_checksum(edid);
+    edid_checksum(edid, 127);
     if (dta) {
-        edid_checksum(dta);
+        edid_checksum(dta, 127);
     }
 }
 
-- 
2.24.3 (Apple Git-128)



  reply	other threads:[~2021-03-15 11:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 11:46 [PATCH v3 1/3] edid: move timing generation into a separate function Konstantin Nazarov
2021-03-15 11:46 ` Konstantin Nazarov [this message]
2021-03-15 11:46 ` [PATCH v3 3/3] edid: add support for DisplayID extension (5k resolution) Konstantin Nazarov
2021-03-16 13:32 ` [PATCH v3 1/3] edid: move timing generation into a separate function Gerd Hoffmann
2021-03-16 14:01   ` mail
2021-03-16 14:34     ` Gerd Hoffmann

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=20210315114639.91953-2-mail@knazarov.com \
    --to=mail@knazarov.com \
    --cc=akihiko.odaki@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.