Cannot set video mode on real hardware

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Danyy
Posts: 16
Joined: Mon Sep 21, 2020 11:22 pm
Libera.chat IRC: Danyy

Cannot set video mode on real hardware

Post by Danyy »

I just recently finished tasking in my OS and decided to make a whole rewrite to fix some mistakes. Along the way, I also decided to make it bootable on real hardware. The code got stuck on setting video mode. First I thought the problem was with my set video mode function but it wasn't that. The problem is that my computer doesn't seem to support 1920x1080x32 resolution. The video list ends on 0x11Bh which is 1280x1024x24. My monitor and graphics card both support 1920x1080 and it also works on QEMU. The code also fails on Virtual Box.

Also, note that my computer doesn't have legacy BIOS, it has UEFI and I am running the OS with CSM. I thought the problem may be with that.

I can give you any information that you may need, I didn't post code since it seems to be irrelevant.

TL;DR:

I cannot set video mode because the video mode list on real hardware doesn't include my desired resolution 1920x1080x32 although my hardware should support it. I don't have legacy BIOS, I am running OS with UEFI and CSM.
User avatar
pvc
Member
Member
Posts: 201
Joined: Mon Jan 15, 2018 2:27 pm

Re: Cannot set video mode on real hardware

Post by pvc »

VBE often doesn't support modern resolutions. Try GOP (if your video card supports it).
Danyy
Posts: 16
Joined: Mon Sep 21, 2020 11:22 pm
Libera.chat IRC: Danyy

Re: Cannot set video mode on real hardware

Post by Danyy »

pvc wrote:VBE often doesn't support modern resolutions. Try GOP (if your video card supports it).
Yes but QEMU seems to support it very well

Edit: Is there any way I can make my VBE2 support video mdoes I want.
Last edited by Danyy on Fri May 21, 2021 8:58 am, edited 1 time in total.
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Cannot set video mode on real hardware

Post by Octocontrabass »

QEMU is nicer than hardware in several ways.
Danyy
Posts: 16
Joined: Mon Sep 21, 2020 11:22 pm
Libera.chat IRC: Danyy

Re: Cannot set video mode on real hardware

Post by Danyy »

Octocontrabass wrote:QEMU is nicer than hardware in several ways.
Is there any way I could make real hardware detect the video modes I want
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Cannot set video mode on real hardware

Post by Octocontrabass »

Yes: write a driver for the video card.

There's no way to make the firmware give you additional modes.
Danyy
Posts: 16
Joined: Mon Sep 21, 2020 11:22 pm
Libera.chat IRC: Danyy

Re: Cannot set video mode on real hardware

Post by Danyy »

Octocontrabass wrote:Yes: write a driver for the video card.

There's no way to make the firmware give you additional modes.
so it is impossible lol since I cannot write a driver for every video card
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: Cannot set video mode on real hardware

Post by nullplan »

Danyy wrote:so it is impossible lol since I cannot write a driver for every video card
No, but you can start with a driver for your video card, and then add every card you come across as required. Given that your OS is unlikely to be used outside of you personally, this is probably the way to go. Add a VESA/GOP fallback for people who want to try it out, and make documentation available on how to add video drivers, and that is probably going to be as it gets. Everything more would require vendor support, which you are unlikely to get until you even reach the lofty heights Linux has climbed to (<10% market share). Which is probably still beyond even your wildest dreams.
Carpe diem!
User avatar
pvc
Member
Member
Posts: 201
Joined: Mon Jan 15, 2018 2:27 pm

Re: Cannot set video mode on real hardware

Post by pvc »

IMO, targeting Intel integrated graphics would be a good point to start for several reasons.
  • a lot of machines (from virtually any segment) have it
  • documentation is decent(-ish)
  • differences between models are only minimal (for 2D graphics)
  • potential test machines are extremely cheap (sometimes even free)
Danyy
Posts: 16
Joined: Mon Sep 21, 2020 11:22 pm
Libera.chat IRC: Danyy

Re: Cannot set video mode on real hardware

Post by Danyy »

pvc wrote:IMO, targeting Intel integrated graphics would be a good point to start for several reasons.
  • a lot of machines (from virtually any segment) have it
  • documentation is decent(-ish)
  • differences between models are only minimal (for 2D graphics)
  • potential test machines are extremely cheap (sometimes even free)
nullplan wrote:
Danyy wrote:so it is impossible lol since I cannot write a driver for every video card
No, but you can start with a driver for your video card, and then add every card you come across as required. Given that your OS is unlikely to be used outside of you personally, this is probably the way to go. Add a VESA/GOP fallback for people who want to try it out, and make documentation available on how to add video drivers, and that is probably going to be as it gets. Everything more would require vendor support, which you are unlikely to get until you even reach the lofty heights Linux has climbed to (<10% market share). Which is probably still beyond even your wildest dreams.
Ok but isn’t it just making things harder for me. Wouldn’t using UEFI and GOP be easier than writing drivers for my video card. I believe it would be provided that GOP can support higher video modes. Is it *guaranteed* for the GOP to supply higher modes? If not so, how can I even start writing drivers for a video card?
User avatar
zaval
Member
Member
Posts: 656
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: Cannot set video mode on real hardware

Post by zaval »

GOP reports in every case what modes it does support. Being in the loader, you can query that and set to what you like most. You can also query EDID information, using UEFI, but that makes little sense, because again - what GOP supports, it reports itself. If you find through EDID some higher resolutions, that GOP doesn't claim to support - you wouldn't be able to set them without directly manipulating the display controller, what is only possible if you know what to manipulate. Warning: GOP, as any UEFI protocol, works only before ExitBootServices(), so setting the mode through it is only possible in the loader.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Cannot set video mode on real hardware

Post by Octocontrabass »

Danyy wrote:Is it *guaranteed* for the GOP to supply higher modes?
No.
Danyy wrote:If not so, how can I even start writing drivers for a video card?
Start by figuring out which video card it is so you can find documentation.
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Cannot set video mode on real hardware

Post by bzt »

Danyy wrote:Is there any way I could make real hardware detect the video modes I want
Well, yes and no. There is a way to detect video modes without writing a driver, however it will report what the card actually supports, and not necessarily what you want. The best you can do is get the list of supported video modes, then look for the resolution which is the closest to the one you want (but there's no guarantee there will be an exact match).
Danyy wrote:Also, note that my computer doesn't have legacy BIOS, it has UEFI and I am running the OS with CSM.
In that case you definitely will have GOP (in UEFI mode) and both GOP and VBE will report exactly the same video resolutions (because in legacy CSM the VBE function is just a wrapper around GOP).

As for VBE, I don't have a tutorial, but here's a link a working Assembly code in my boot loader. It queries the list of supported modes from VESA VBE, and then sets the mode which is closest to the resolution given in reqwidth and reqheight variables.

For GOP, here's a tutorial. It reports the following modes in my qemu:
Image
On a real machine it will report 20 - 30 modes at least.

Cheers,
bzt
Danyy
Posts: 16
Joined: Mon Sep 21, 2020 11:22 pm
Libera.chat IRC: Danyy

Re: Cannot set video mode on real hardware

Post by Danyy »

bzt wrote:
Danyy wrote:Is there any way I could make real hardware detect the video modes I want
Well, yes and no. There is a way to detect video modes without writing a driver, however it will report what the card actually supports, and not necessarily what you want. The best you can do is get the list of supported video modes, then look for the resolution which is the closest to the one you want (but there's no guarantee there will be an exact match).
Danyy wrote:Also, note that my computer doesn't have legacy BIOS, it has UEFI and I am running the OS with CSM.
In that case you definitely will have GOP (in UEFI mode) and both GOP and VBE will report exactly the same video resolutions (because in legacy CSM the VBE function is just a wrapper around GOP).

As for VBE, I don't have a tutorial, but here's a link a working Assembly code in my boot loader. It queries the list of supported modes from VESA VBE, and then sets the mode which is closest to the resolution given in reqwidth and reqheight variables.

For GOP, here's a tutorial. It reports the following modes in my qemu:
Image
On a real machine it will report 20 - 30 modes at least.

Cheers,
bzt
zaval wrote:GOP reports in every case what modes it does support. Being in the loader, you can query that and set to what you like most. You can also query EDID information, using UEFI, but that makes little sense, because again - what GOP supports, it reports itself. If you find through EDID some higher resolutions, that GOP doesn't claim to support - you wouldn't be able to set them without directly manipulating the display controller, what is only possible if you know what to manipulate. Warning: GOP, as any UEFI protocol, works only before ExitBootServices(), so setting the mode through it is only possible in the loader.
I think I couldn’t clarify. Using VBE I am getting the list of supported video modes and checking the mode that supports 1920x1080x32 and set it, meaning I am not hardcoding any mode. My graphics card being 2080ti and monitor being a 2k monitor, they should support video modes such as 1920x1080x32 but VBE doesn’t report them.

I am asking how I should reach the video modes I want that are already supported my graphics card and that should be reported by VBE but aren't, without writing a driver for my video hard (hopefully)?
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Cannot set video mode on real hardware

Post by Octocontrabass »

Danyy wrote:I am asking how I should reach the video modes I want that are already supported my graphics card and that should be reported by VBE but aren't, without writing a driver for my video hard (hopefully)?
The only way to do it is to write a driver.
Post Reply