From nobody Thu Dec 18 17:55:27 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620653032; cv=none; d=zohomail.com; s=zohoarc; b=n4rkLAcJSQcUnu3KlqcrioXM2t0ZhRdJUj4q9cP4zZULXuZqJEIQ5Vg7joB7BYzs/8czMZeBuyzQX4hZHhMzdCnToTT8aatl2EUmBgqkN8BCCVv5R5KKzOAxGuHUPSZ2syzQAAfqqE0QhiUBQH7EbS4Asbo8jNosD49lL0jE4iw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620653032; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s4xVC1mg46YZIJZ3WBD+3gZO8EdwEhmvpVTxNCiAKIo=; b=YUOzqRcQISXPfDHJoAANunO01pAM2z+H+cljY1ZrzdUNLZujV6Ca3Gr4+MUngsL0txqOQ6pqjmEzPG29Jzl/D0EydgIkwoDZlpMNcEmzN45oFLSsQSFxxJfg6U8RtnBk+3oKqhj/QFoMyeniNhqWqTCkwAg074BKfmB05rEfyAY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620653032650528.1715965340097; Mon, 10 May 2021 06:23:52 -0700 (PDT) Received: from localhost ([::1]:43210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lg5t1-0006r8-1C for importer@patchew.org; Mon, 10 May 2021 09:23:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lg5r2-00040L-9f for qemu-devel@nongnu.org; Mon, 10 May 2021 09:21:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lg5r0-0002o9-Et for qemu-devel@nongnu.org; Mon, 10 May 2021 09:21:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-88-_WdcHlerNJuECWOyNlYY9g-1; Mon, 10 May 2021 09:21:43 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B681F1927807; Mon, 10 May 2021 13:21:42 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-11.ams2.redhat.com [10.36.112.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 252215E26A; Mon, 10 May 2021 13:21:33 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 58F6218003B1; Mon, 10 May 2021 15:20:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620652905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s4xVC1mg46YZIJZ3WBD+3gZO8EdwEhmvpVTxNCiAKIo=; b=Ao4VLKEjL8ONgMTa6IqaDkr9dyeqND+1ubNUFnR8lMDnt5cY3iw6/61If5x9+Ixuqld1LR Cv+G7IDsxi83H7lgV9e2/IQdhnsdjLWi5b8gq9OWb1jECLV767/WeJl+QWvuR9kN5/LYEB ouI3prWTX/5D0xjTQmN0HkNb2xHJxwU= X-MC-Unique: _WdcHlerNJuECWOyNlYY9g-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 06/25] edid: move timing generation into a separate function Date: Mon, 10 May 2021 15:20:32 +0200 Message-Id: <20210510132051.2208563-7-kraxel@redhat.com> In-Reply-To: <20210510132051.2208563-1-kraxel@redhat.com> References: <20210510132051.2208563-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.698, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Konstantin Nazarov , Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Konstantin Nazarov The timing generation is currently performed inside the function that fills in the DTD. The DisplayID generation needs it as well, so moving it out to a separate function. Based-on: <20210303152948.59943-2-akihiko.odaki@gmail.com> Signed-off-by: Konstantin Nazarov Message-Id: <20210315114639.91953-1-mail@knazarov.com> Signed-off-by: Gerd Hoffmann Message-id: 20210427150824.638359-1-kraxel@redhat.com Message-Id: <20210427150824.638359-7-kraxel@redhat.com> --- hw/display/edid-generate.c | 68 ++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/hw/display/edid-generate.c b/hw/display/edid-generate.c index 8662218822f6..b70ab1557e50 100644 --- a/hw/display/edid-generate.c +++ b/hw/display/edid-generate.c @@ -45,6 +45,35 @@ static const struct edid_mode { { .xres =3D 640, .yres =3D 480, .byte =3D 35, .bit =3D 5 }, }; =20 +typedef struct Timings { + uint32_t xfront; + uint32_t xsync; + uint32_t xblank; + + uint32_t yfront; + uint32_t ysync; + uint32_t yblank; + + uint64_t clock; +} Timings; + +static void generate_timings(Timings *timings, uint32_t refresh_rate, + uint32_t xres, uint32_t yres) +{ + /* pull some realistic looking timings out of thin air */ + timings->xfront =3D xres * 25 / 100; + timings->xsync =3D xres * 3 / 100; + timings->xblank =3D xres * 35 / 100; + + timings->yfront =3D yres * 5 / 1000; + timings->ysync =3D yres * 5 / 1000; + timings->yblank =3D yres * 35 / 1000; + + timings->clock =3D ((uint64_t)refresh_rate * + (xres + timings->xblank) * + (yres + timings->yblank)) / 10000000; +} + static void edid_ext_dta(uint8_t *dta) { dta[0] =3D 0x02; @@ -227,38 +256,29 @@ static void edid_desc_timing(uint8_t *desc, uint32_t = refresh_rate, uint32_t xres, uint32_t yres, uint32_t xmm, uint32_t ymm) { - /* pull some realistic looking timings out of thin air */ - uint32_t xfront =3D xres * 25 / 100; - uint32_t xsync =3D xres * 3 / 100; - uint32_t xblank =3D xres * 35 / 100; - - uint32_t yfront =3D yres * 5 / 1000; - uint32_t ysync =3D yres * 5 / 1000; - uint32_t yblank =3D yres * 35 / 1000; - - uint64_t clock =3D (uint64_t)refresh_rate * (xres + xblank) * (yres += yblank); - - stl_le_p(desc, clock / 10000000); + Timings timings; + generate_timings(&timings, refresh_rate, xres, yres); + stl_le_p(desc, timings.clock); =20 desc[2] =3D xres & 0xff; - desc[3] =3D xblank & 0xff; + desc[3] =3D timings.xblank & 0xff; desc[4] =3D (((xres & 0xf00) >> 4) | - ((xblank & 0xf00) >> 8)); + ((timings.xblank & 0xf00) >> 8)); =20 desc[5] =3D yres & 0xff; - desc[6] =3D yblank & 0xff; + desc[6] =3D timings.yblank & 0xff; desc[7] =3D (((yres & 0xf00) >> 4) | - ((yblank & 0xf00) >> 8)); + ((timings.yblank & 0xf00) >> 8)); =20 - desc[8] =3D xfront & 0xff; - desc[9] =3D xsync & 0xff; + desc[8] =3D timings.xfront & 0xff; + desc[9] =3D timings.xsync & 0xff; =20 - desc[10] =3D (((yfront & 0x00f) << 4) | - ((ysync & 0x00f) << 0)); - desc[11] =3D (((xfront & 0x300) >> 2) | - ((xsync & 0x300) >> 4) | - ((yfront & 0x030) >> 2) | - ((ysync & 0x030) >> 4)); + desc[10] =3D (((timings.yfront & 0x00f) << 4) | + ((timings.ysync & 0x00f) << 0)); + desc[11] =3D (((timings.xfront & 0x300) >> 2) | + ((timings.xsync & 0x300) >> 4) | + ((timings.yfront & 0x030) >> 2) | + ((timings.ysync & 0x030) >> 4)); =20 desc[12] =3D xmm & 0xff; desc[13] =3D ymm & 0xff; --=20 2.31.1