From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=188.166.76.209; helo=mail.aheymans.xyz; envelope-from=arthur@aheymans.xyz; receiver=edk2-devel@lists.01.org Received: from mail.aheymans.xyz (mail.aheymans.xyz [188.166.76.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0D24821D2BEE8 for ; Thu, 25 Jan 2018 00:57:52 -0800 (PST) Received: from x200_coreboot.localdomain (d8D86483E.access.telenet.be [141.134.72.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail.aheymans.xyz (Postfix) with ESMTPSA id 2F407C1FD2; Thu, 25 Jan 2018 10:03:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aheymans.xyz; s=mail; t=1516871000; bh=Fjm4qxlW4G7mHrPx5bIWF57gQnQ/sTN8j/Y9rsm2tIc=; h=From:To:Cc:Subject:References:Date:In-Reply-To; b=OamknzWNcW/wGSfnB4H2ShpjYSgDnOcDZ87t8W8r22ufhGZtOxLmnkVdq6YUtOFlv o5FHaD2yhv7S9ZlAQ1IydZJX3iMyVZH+fHGyh4SjMasPYXcHtD52UmKm8sq22+wpb/ 3cvSuXT9prc+uF/+QrF9zv+LkprGnO4OLhS1+2jE= Received: by x200_coreboot.localdomain (Postfix, from userid 1000) id C203410090C; Thu, 25 Jan 2018 10:03:19 +0100 (CET) From: Arthur Heymans To: "You\, Benjamin" Cc: "edk2-devel\@lists.01.org" References: <20180124105736.14877-1-arthur@aheymans.xyz> Date: Thu, 25 Jan 2018 10:03:19 +0100 In-Reply-To: (Benjamin You's message of "Thu, 25 Jan 2018 05:34:47 +0000") Message-ID: <87mv12gvjc.fsf@aheymans.xyz> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Subject: Re: [PATCH] CorebootPayloadPkg: Use correct BytesPerScanLine X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jan 2018 08:57:54 -0000 Content-Type: text/plain "You, Benjamin" writes: > Hi Arthur, > > Could you please give more details about your case that > HorizontalResolution * (BitsPerPixel / 8) and pFbInfo->BytesPerScanLine > don't match? > On many devices, notably Intel hardware, the STRIDE needs to be 64 byte aligned when used in linear memory mode, which coreboot does. STRIDE is value that used to determine the line to line increment for the display. So what coreboot does when initializing the hardware to align (HorizontalResolution * (BitsPerPixel / 8)), 64 bytes up. > I did a brief search in Coreboot source and found following comments in > coreboot-4.6\src\lib\edid.c: > > /* In the case of (e.g.) 24 framebuffer bits per pixel, the convention > * nowadays seems to be to round it up to the nearest reasonable > * boundary, because otherwise the byte-packing is hideous. > > So it appears framebuffer BitsPerPixel will likely be 16 or 32, and the > following statement in the same file calculates: > > edid->x_resolution = edid->bytes_per_line / (fb_bpp / 8); > > which results in bytes_per_line (already rounded up to be 32 or 64 byte > aligned) matching x_resolution * (fb_bpp / 8). > > There are cases that even if panel bits_per_pixel is 24, the framebuffer > bits_per_pixel is still 32, as shown in > coreboot-4.6\src\drivers\emulation\qemu\bochs.c: > > edid.panel_bits_per_pixel = 24; > edid_set_framebuffer_bits_per_pixel(&edid, 32, 0); > > It would be good if you could help with more details on how the mismatch > happened in your case as I may have missed something. > So long story short 'bytes_per_line' reflects how the actual hardware is set up, while using '(HorizontalResolution * (BitsPerPixel / 8)' is a guess which is only sometimes correct. To give an example (on which this was actually a problem): let's say we have a display 1366 pixel horizontal resolution with 32 bits per pixel. HorizontalResolution * BitsPerPixel / 8 = 5464 But this value is not 64 byte aligned which the hardware expects so. aligned value = ((HorizontalResolution * (BitsPerPixel / 8) + 63) & ~63 = 5504 So tianocore should use the value coreboot provides it instead of trying to compute/guess it. > Thanks, > > - ben > I hope this clarifies it. Arthur >> -----Original Message----- >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of >> arthur@aheymans.xyz >> Sent: Wednesday, January 24, 2018 6:58 PM >> To: edk2-devel@lists.01.org >> Cc: Arthur Heymans >> Subject: [edk2] [PATCH] CorebootPayloadPkg: Use correct BytesPerScanLine >> >> From: Arthur Heymans >> >> Fetch BytesPerScanLine from coreboot table to reflect how the actual >> framebuffer is set up instead of guessing it from the horizontal >> resolution. >> >> This fixes a garbled display when HorizontalResolution * (BitsPerPixel >> / 8) and pFbInfo->BytesPerScanLine don't match. >> >> Contributed-under: TianoCore Contribution Agreement 1.1 >> Signed-off-by: Arthur Heymans >> >> diff --git a/CorebootPayloadPkg/FbGop/FbGop.c >> b/CorebootPayloadPkg/FbGop/FbGop.c >> index 37d6def7f7..6790617033 100644 >> --- a/CorebootPayloadPkg/FbGop/FbGop.c >> +++ b/CorebootPayloadPkg/FbGop/FbGop.c >> @@ -822,7 +822,7 @@ FbGopCheckForVbe ( >> BitsPerPixel = pFbInfo->BitsPerPixel; >> HorizontalResolution = pFbInfo->HorizontalResolution; >> VerticalResolution = pFbInfo->VerticalResolution; >> - BytesPerScanLine = HorizontalResolution * (BitsPerPixel / 8); >> + BytesPerScanLine = pFbInfo->BytesPerScanLine; >> >> ModeBuffer = (FB_VIDEO_MODE_DATA *) AllocatePool ( >> >> >> ModeNumber * sizeof >> (FB_VIDEO_MODE_DATA) >> -- >> 2.16.1 >> >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel <#secure method=pgpmime mode=sign> -- Arthur Heymans