From patchwork Thu Sep 27 07:12:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 975567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42LQyt2JpLz9sCK for ; Thu, 27 Sep 2018 17:13:56 +1000 (AEST) Received: from localhost ([::1]:34046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5QUg-0007UA-8X for incoming@patchwork.ozlabs.org; Thu, 27 Sep 2018 03:13:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5QTv-0007Tg-VA for qemu-devel@nongnu.org; Thu, 27 Sep 2018 03:13:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5QTq-0004Lg-U5 for qemu-devel@nongnu.org; Thu, 27 Sep 2018 03:13:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38098) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g5QTn-0004Kg-8z for qemu-devel@nongnu.org; Thu, 27 Sep 2018 03:12:56 -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 47303308A96F for ; Thu, 27 Sep 2018 07:12:53 +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 BCDDA5D9D6; Thu, 27 Sep 2018 07:12:48 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 7CE1A3EBB6; Thu, 27 Sep 2018 09:12:47 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 27 Sep 2018 09:12:42 +0200 Message-Id: <20180927071247.25725-3-kraxel@redhat.com> In-Reply-To: <20180927071247.25725-1-kraxel@redhat.com> References: <20180927071247.25725-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.41]); Thu, 27 Sep 2018 07:12:53 +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] [PULL 2/7] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Message-id: 20180925075646.25114-3-kraxel@redhat.com --- 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 { 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 */ diff --git a/hw/display/edid-generate.c b/hw/display/edid-generate.c index b3e493da19..c80397ea96 100644 --- a/hw/display/edid-generate.c +++ b/hw/display/edid-generate.c @@ -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); +}