From nobody Wed Nov 5 22:35:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537520492422642.6386614704699; Fri, 21 Sep 2018 02:01:32 -0700 (PDT) Received: from localhost ([::1]:54622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HJY-0002aw-4J for importer@patchew.org; Fri, 21 Sep 2018 05:01:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HHQ-0000ju-Sh for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3HHN-00077j-3j for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54524) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3HHM-00077O-TB for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:59:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 46F3E308402B for ; Fri, 21 Sep 2018 08:59:12 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-56.phx2.redhat.com [10.3.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7421F17DA3; Fri, 21 Sep 2018 08:59:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 330E699A1F; Fri, 21 Sep 2018 10:59:05 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 10:59:02 +0200 Message-Id: <20180921085905.3038-3-kraxel@redhat.com> In-Reply-To: <20180921085905.3038-1-kraxel@redhat.com> References: <20180921085905.3038-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 21 Sep 2018 08:59:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/5] display/edid: add qemu_edid_size() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- include/hw/display/edid.h | 1 + hw/display/edid-generate.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/hw/display/edid.h b/include/hw/display/edid.h index 63b60015c3..96910ada0f 100644 --- a/include/hw/display/edid.h +++ b/include/hw/display/edid.h @@ -14,5 +14,6 @@ typedef struct qemu_edid_info { =20 void qemu_edid_generate(uint8_t *edid, size_t size, qemu_edid_info *info); +size_t qemu_edid_size(uint8_t *edid); =20 #endif /* EDID_H */ diff --git a/hw/display/edid-generate.c b/hw/display/edid-generate.c index e439b1e893..42ec5df39c 100644 --- a/hw/display/edid-generate.c +++ b/hw/display/edid-generate.c @@ -332,3 +332,17 @@ void qemu_edid_generate(uint8_t *edid, size_t size, edid_fill_modes(edid, xtra3, info->maxx, info->maxy); edid_checksum(edid); } + +size_t qemu_edid_size(uint8_t *edid) +{ + uint32_t exts; + + if (edid[0] !=3D 0x00 || + edid[1] !=3D 0xff) { + /* doesn't look like a valid edid block */ + return 0; + } + + exts =3D edid[126]; + return 128 * (exts + 1); +} --=20 2.9.3