From nobody Fri Dec 19 16:19:57 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=1615906100; cv=none; d=zohomail.com; s=zohoarc; b=UouhRt3dashidaWPzUFgGgJNUJzmg3hUHFi7kou7lyUIDCPVTngBavKoBN+pENknJ1x0Qw2twnLDfNn9/f1DcD2IUf/kTGib4uCA+F/B5+oX3ug0SYFzq+DebOqk0dIDYo7dGu133m0nTeQ911jFnJdZmSwJLKilKAjpPewgfDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615906100; 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=ZWa0cFKYWCK117AR6dw9Xt+0jt/SqgOE0ZpiGrqpUkQ=; b=a3JzNOeKk4Y611kORzrbpE5VFMdkvHOClDZP3FZXu15AIGfheed/agDg6+upFnlSn6OWlUp4MEViOUx+Bo7Jw5+CGHWsp88iu+dF1rXri0T6/ZCGg+ymVvLEdsMoiTNPyXynWOCjlfMffdyoZfyytJ694ZihAowpaXIBn9lglXQ= 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 1615906100875321.7219582877009; Tue, 16 Mar 2021 07:48:20 -0700 (PDT) Received: from localhost ([::1]:53124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMAzb-0006Sp-IU for importer@patchew.org; Tue, 16 Mar 2021 10:48:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMAqD-0003lQ-2n for qemu-devel@nongnu.org; Tue, 16 Mar 2021 10:38:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lMAq4-0002Fa-F4 for qemu-devel@nongnu.org; Tue, 16 Mar 2021 10:38:35 -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-479-7lXVY4lpP4OZzHiOgGW2IQ-1; Tue, 16 Mar 2021 10:38:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79CF1193248D; Tue, 16 Mar 2021 14:38:22 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-141.ams2.redhat.com [10.36.112.141]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F043F60C13; Tue, 16 Mar 2021 14:38:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 84596180062F; Tue, 16 Mar 2021 15:38:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615905505; 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=ZWa0cFKYWCK117AR6dw9Xt+0jt/SqgOE0ZpiGrqpUkQ=; b=FGCOP/hYegUF2No4dM/gD0pS6hjrnlhFot4IK1ZtWJGdcKrFJgRAXHJsnVdPoiYVc02VE7 cvc+zaC5y9D5hB2NbjrfRdZ06v556M6LyIoXVCqG2RhKQiRnGgWjfe2HKQIJK+d0F5f9SR J9y3zBCKOClQFQIqVPZVBrLE4ZVU0/A= X-MC-Unique: 7lXVY4lpP4OZzHiOgGW2IQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH 7/9] edid: move timing generation into a separate function Date: Tue, 16 Mar 2021 15:38:10 +0100 Message-Id: <20210316143812.2363588-8-kraxel@redhat.com> In-Reply-To: <20210316143812.2363588-1-kraxel@redhat.com> References: <20210316143812.2363588-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, 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_H3=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: Konstantin Nazarov , Gerd Hoffmann 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 --- 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.30.2