Linux GOP initialization is wrong

David Santamaría Rogado howl.nsp at gmail.com
Mon Apr 27 23:58:11 UTC 2020


This is related to the issues at least on some devices for panel
orientation quirks where added.

My tests have been done over a Lenovo ideapad D330.

This devices like the other ones that need panel orientation quirks,
shows the initramfs with wrong stride and x and y swapped. By applying
the panel orientation quirks this gets solved but many parts of the
systems components needs to be patched. Hans has done a great job with
plymouth, mutter... but always appears a new problem derived as for
example vnc desktop sharing with this devices doesn't work and the
output is send messed up.

The strange thing is that bootloaders like GRUB or rEFInd seems to be
able to handle this and they paint themselves right, despite when
booting Windows directly Windows paints itself right and booted with
GRUB or rEFInd the first second also paint itself wrong. Haven't
tested this too much but the interesting thing is in the next
paragraph.

I decided to get the UEFI GOP video modes and found that the D330 have
these ones:
Mode 0: 1200x1920
Mode 1: 640x480
Mode 2: 800x600
Mode 3: 1024x768
Mode 4: 1920x1200 (this is the default one started by the firmware)
Mode 5: 480x640
Mode 6: 600x800
Mode 7: 768x1024

So I thought that Linux is taking the first mode despite is not the
active one and that's why the display is messed up.

Playing a little I could modify the GOP video mode before booting with
the UEFI Shell by simple using the mode 150 101. This causes GOP video
mode 5 to be switched to video mode 0, the first one. Booting now
makes initramfs messages to be correctly rendered but in the wrong
orientation.

A look at drivers/firmware/efi/libstub/gop.c seems to be what is
happening, the first available video mode is used despite it could not
be the active one in GOP and the active mode is not switched to the
discovered one by Linux. Both GRUB and rEFInd are able to respect the
video mode that GOP has active so it's possible to boot them landscape
and portrait while being correctly rendered.

I think the video mode should not be the first discovered one but the
active one, or at least, the highest resolution video mode that
respects the orientation.

I still have to test what Windows do if I try to boot it with the
video mode 0 active instead the default firmware mode 5, but I guess
it just select the highest resolution available where the x > y, and I
don't think this is the perfect approach, if some manufacturer wants
to make a portrait booting device it only will be possible by
respecting when the resolution is portrait or landscape while
searching the highest of them.


More information about the dri-devel mailing list