OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 6:40 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 7:39 am 
Offline

Joined: Mon Sep 21, 2020 11:22 pm
Posts: 16
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.


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 8:45 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
VBE often doesn't support modern resolutions. Try GOP (if your video card supports it).


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 8:52 am 
Offline

Joined: Mon Sep 21, 2020 11:22 pm
Posts: 16
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.

Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 8:57 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5103
QEMU is nicer than hardware in several ways.


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 9:07 am 
Offline

Joined: Mon Sep 21, 2020 11:22 pm
Posts: 16
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


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 9:22 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5103
Yes: write a driver for the video card.

There's no way to make the firmware give you additional modes.


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 9:25 am 
Offline

Joined: Mon Sep 21, 2020 11:22 pm
Posts: 16
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


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 11:07 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
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!


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 12:14 pm 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
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)


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 3:58 pm 
Offline

Joined: Mon Sep 21, 2020 11:22 pm
Posts: 16
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?


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 4:33 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 641
Location: Ukraine, Bachmut
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).


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 9:06 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5103
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.


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Fri May 21, 2021 9:56 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Sat May 22, 2021 1:10 am 
Offline

Joined: Mon Sep 21, 2020 11:22 pm
Posts: 16
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)?


Top
 Profile  
 
 Post subject: Re: Cannot set video mode on real hardware
PostPosted: Sat May 22, 2021 1:52 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5103
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 255 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group