Setting graphics mode to maximum resolution

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.
Post Reply
User avatar
obiwac
Member
Member
Posts: 149
Joined: Fri Jan 27, 2017 12:15 pm
Libera.chat IRC: obiwac
Location: Belgium

Setting graphics mode to maximum resolution

Post by obiwac »

Hello all!

I currently passing my desired resolution (and bbp) to grub with the multiboot header flags. I can read the graphics pointer and draw graphics on the screen.
My question is, how do I ask grub to set the graphics mode to the maximum resolution of the monitor, at specifically 32 bbp, instead of passing it a resolution?

Thanks in advance!
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Setting graphics mode to maximum resolution

Post by iansjack »

Try the line:

GRUB_GFXMODE=auto

in your configuration file. Note that Grub can only set modes supported by VBE.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Setting graphics mode to maximum resolution

Post by Brendan »

Hi,
iansjack wrote:Note that Grub can only set modes supported by VBE.
Note that just because VBE and the video card support a video mode it doesn't mean that the monitor itself supports that video mode. In practice, this means "set graphics mode to max. supported by VBE" is the same as "maximise the possibility that the user will see nothing".

You really want to use EDID to ensure that the video mode is supported by both the video card and the monitor. UEFI does this (or at least it's supposed to) so it shouldn't be a problem for "GRUB on UEFI"; but the BIOS doesn't (and as far as I know GRUB doesn't either) so it will be a disaster for "GRUB on BIOS".

Also note that what you really want is the monitor's native resolution, not the maximum resolution that the monitor can down-scale and make blurry.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
obiwac
Member
Member
Posts: 149
Joined: Fri Jan 27, 2017 12:15 pm
Libera.chat IRC: obiwac
Location: Belgium

Re: Setting graphics mode to maximum resolution

Post by obiwac »

Ok thanks. I'll do a bit more research then.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Setting graphics mode to maximum resolution

Post by onlyonemac »

obiwac wrote:Ok thanks. I'll do a bit more research then.
You'll want to start with figuring out how to set the graphics mode yourself. Then you'll need to find out how to get the maximum and preferred resolutions of the graphics card and monitor, and use this to choose a suitable resolution. Think also about how you're going to handle changing the resolution during operation (if at all) - the user might want to change the resolution without having to reboot the computer, such as when they connect another monitor or if your OS chooses the wrong resolution and they want to change it.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
eryjus
Member
Member
Posts: 286
Joined: Fri Oct 21, 2011 9:47 pm
Libera.chat IRC: eryjus
Location: Tustin, CA USA

Re: Setting graphics mode to maximum resolution

Post by eryjus »

obiwac wrote:Hello all!

I currently passing my desired resolution (and bbp) to grub with the multiboot header flags. I can read the graphics pointer and draw graphics on the screen.
My question is, how do I ask grub to set the graphics mode to the maximum resolution of the monitor, at specifically 32 bbp, instead of passing it a resolution?

Thanks in advance!
I started down this path myself last week. Ultimately I chose to have my stage 3 loader support only 1024x768 while it is collecting info for the kernel and setting the CPU in native mode. The resolution is pretty ubiquitous still even if it letter boxed. As onlyonemac says, I made the choice to support the final resolution later in the OS driver.
Adam

The name is fitting: Century Hobby OS -- At this rate, it's gonna take me that long!
Read about my mistakes and missteps with this iteration: Journal

"Sometimes things just don't make sense until you figure them out." -- Phil Stahlheber
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: Setting graphics mode to maximum resolution

Post by Korona »

Brendan wrote:You really want to use EDID to ensure that the video mode is supported by both the video card and the monitor. UEFI does this (or at least it's supposed to) so it shouldn't be a problem for "GRUB on UEFI"; but the BIOS doesn't (and as far as I know GRUB doesn't either) so it will be a disaster for "GRUB on BIOS".
GRUB reads EDID and sets the mode that is specified by the first detailed timing descriptor (in grub_video_edid_preferred_mode()).
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
User avatar
obiwac
Member
Member
Posts: 149
Joined: Fri Jan 27, 2017 12:15 pm
Libera.chat IRC: obiwac
Location: Belgium

Re: Setting graphics mode to maximum resolution

Post by obiwac »

onlyonemac wrote:
obiwac wrote:Ok thanks. I'll do a bit more research then.
You'll want to start with figuring out how to set the graphics mode yourself. Then you'll need to find out how to get the maximum and preferred resolutions of the graphics card and monitor, and use this to choose a suitable resolution. Think also about how you're going to handle changing the resolution during operation (if at all) - the user might want to change the resolution without having to reboot the computer, such as when they connect another monitor or if your OS chooses the wrong resolution and they want to change it.
I think I won't try to go with something too complicated. I think that for now I'ts ok if the computer has to reboot. I timed it once, and it was like 15 seconds or something. Thanks!
Post Reply