public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Arthur Heymans <arthur@aheymans.xyz>
To: "You\, Benjamin" <benjamin.you@intel.com>
Cc: "edk2-devel\@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH] CorebootPayloadPkg: Use correct BytesPerScanLine
Date: Fri, 26 Jan 2018 10:08:44 +0100	[thread overview]
Message-ID: <87efmdyokj.fsf@aheymans.xyz> (raw)
In-Reply-To: <E748835C6D8DB54B8E8AF33091ECC57C62144D2F@shsmsx102.ccr.corp.intel.com> (Benjamin You's message of "Fri, 26 Jan 2018 08:40:14 +0000")

"You, Benjamin" <benjamin.you@intel.com> writes:

>
> I noticed in coreboot-4.7\src\include\edid.h, there are following comments:
>
> /* 3 variables needed for coreboot framebuffer.
> 	 * In most cases, they are the same as the ha
> 	 * and va variables, but not always, as in the
> 	 * case of a 1366 wide display.
> 	 */
> 	u32 x_resolution;
> 	u32 y_resolution;
> 	u32 bytes_per_line;
>
> And in coreboot-4.7\src\lib\edid.c:
>
> 	edid->bytes_per_line = ALIGN_UP(edid->mode.ha *
> 		div_round_up(fb_bpp, 8), row_byte_alignment);
> 	edid->x_resolution = edid->bytes_per_line / (fb_bpp / 8);
>

This is how x_resolution initially gets set after the EDID is read, but
it is further modified to satisfy the display controllers needs,
e.g. src/northbridge/intel/gm45/gma.c:

edid->bytes_per_line = (edid->bytes_per_line + 63) & ~63;

before it gets send to code that sets up the coreboot tables from which
payloads extract this information:

set_vbe_mode_info_valid(edid, lfb);

There are also other code paths that don't use src/lib/edid.c to set up
the framebuffer.

In src/drivers/intel/gma/hires_fb/gma.adb we have:
            x_resolution         => word32 (fb.Width),
            y_resolution         => word32 (fb.Height),
            bytes_per_line       => 4 * word32 (fb.Stride),


> Above calculations derive x_resolution from the roundup value of 
> bytes_per_line. In case of 1366 display, it would produce a x_resolution of
> 1376, which is larger than 1366 but satisfies the equation of 
> bytes_per_line == (HorizontalResolution * (BitsPerPixel / 8)
>

It is only initialized to that when the EDID is read. The code that
actually sets up the hardware further modifies it or passes on the value
it needs to bytes_per_line.

> It appears this is what Coreboot produces right now. Not sure if there are 
> other cases leading to Coreboot producing framebuffer parameters NOT 
> satisfying the above equation.
>

well given that other code touches edid_bytes_per_lines, there are many
examples where this is not satisfied.

> BTW, do you think the above calculation of x_resolution hides the 
> information of display and should be fixed?
>
>> 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 <arthur@aheymans.xyz>
>> >> Subject: [edk2] [PATCH] CorebootPayloadPkg: Use correct BytesPerScanLine
>> >>
>> >> From: Arthur Heymans <arthur@aheymans.xyz>
>> >>
>> >> 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 <arthur@aheymans.xyz>
>> >>
>> >> 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
>
> Thanks,
>
> - ben

-- 
Arthur Heymans


  reply	other threads:[~2018-01-26  9:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24 10:57 [PATCH] CorebootPayloadPkg: Use correct BytesPerScanLine arthur
2018-01-25  5:34 ` You, Benjamin
2018-01-25  9:03   ` Arthur Heymans
2018-01-26  8:40     ` You, Benjamin
2018-01-26  9:08       ` Arthur Heymans [this message]
2018-01-27  4:11         ` You, Benjamin
2018-01-27 10:17           ` Arthur Heymans
2018-01-27 14:14           ` Nico Huber
2018-01-28  8:49             ` You, Benjamin
2018-01-28 14:33               ` Nico Huber
2018-01-29  1:09                 ` You, Benjamin
2018-01-29  5:36 ` You, Benjamin
2018-01-30  6:15 ` You, Benjamin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87efmdyokj.fsf@aheymans.xyz \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox