circle looks like an ellipse on real display

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
prajwal
Member
Member
Posts: 154
Joined: Sat Oct 23, 2004 11:00 pm
Contact:

circle looks like an ellipse on real display

Post by prajwal »

Hi,

I have implemented a basic linear framebuffer graphics driver with support for some basic shapes like rectangles, lines, and circles.

On QEMU emulator - where I am using 800x600x32 resolution - everything looks fine. However, when I boot my OS on a real laptop, with one of the supported resolutions like 800x600x32 or 1024x768x32, the circle looks like an ellipse - stretched horizontally. The same with lines and rectangles - they are stretched horizontally.

Does anyone know why this could be the case - I think I may be committing a known/common mistake that most newbies do while writing linear framebuffer-based graphics driver

PS: I am using grub bootloader and selecting the resolution by setting gfxmode and gfxpayload variables in grub.cfg

Thanks
Prajwal
complexity is the core of simplicity
User avatar
AndrewAPrice
Member
Member
Posts: 2300
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: circle looks like an ellipse on real display

Post by AndrewAPrice »

Possibly the emulator is showing 800x600 in a non-widescreen 4:3 ratio window and the real hardware is stretching 800x600 to be wide screen?
My OS is Perception.
Octocontrabass
Member
Member
Posts: 5562
Joined: Mon Mar 25, 2013 7:01 pm

Re: circle looks like an ellipse on real display

Post by Octocontrabass »

That's exactly what's happening.

You can fix it by choosing a resolution that matches the shape of the laptop's screen. If possible, choose the laptop's native resolution.
rdos
Member
Member
Posts: 3296
Joined: Wed Oct 01, 2008 1:55 pm

Re: circle looks like an ellipse on real display

Post by rdos »

I think that if it is an Intel laptop, you will be out of luck. Several of those only support 4x3 resolutions both using VBE and EFI, even if you have a widescreen display. Not even the BIOS manufacturer will be able to fix this as Intel only want to support operating systems that have their own native Intel display drivers. Additionally, the 4x3 emulation they provide is horribly slow.
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: circle looks like an ellipse on real display

Post by klange »

rdos wrote:I think that if it is an Intel laptop, you will be out of luck. Several of those only support 4x3 resolutions both using VBE and EFI, even if you have a widescreen display. Not even the BIOS manufacturer will be able to fix this as Intel only want to support operating systems that have their own native Intel display drivers. Additionally, the 4x3 emulation they provide is horribly slow.
It's definitely a poor situation on older systems, though it's usually better on EFI - you're far more likely to get native panel resolutions out of GOP. On some BIOS systems, you could patch the VGA BIOS to replace one of the available VBE modes with the native panel resolution and timings.

Luckily, Intel GPUs aren't too hard to write barebones modesetting drivers for, especially if you just want to get one specific display working. Toaru has one just for my old ThinkPad, which has a 1440x900 panel but only offered up to 1280x800 from VBE (at least that's the right aspect ratio!)
User avatar
prajwal
Member
Member
Posts: 154
Joined: Sat Oct 23, 2004 11:00 pm
Contact:

Re: circle looks like an ellipse on real display

Post by prajwal »

It is an intel laptop and uses UEFI. I am relying on grub to initialize the graphics to provide me the linear framebuffer to play with. I am basically picking a resolution that is listed as one of the supported resolutions when I run the "videoinfo" command in the grub command prompt (i.e. pressing 'c' in grub boot menu, entering grub command prompt and run "videoinfo" command to list down all supported resolutions)
Luckily, Intel GPUs aren't too hard to write barebones modesetting drivers for, especially if you just want to get one specific display working. Toaru has one just for my old ThinkPad,
Thanks for that link - I will look into this.

Thanks
Prajwal
complexity is the core of simplicity
rdos
Member
Member
Posts: 3296
Joined: Wed Oct 01, 2008 1:55 pm

Re: circle looks like an ellipse on real display

Post by rdos »

klange wrote:
rdos wrote:I think that if it is an Intel laptop, you will be out of luck. Several of those only support 4x3 resolutions both using VBE and EFI, even if you have a widescreen display. Not even the BIOS manufacturer will be able to fix this as Intel only want to support operating systems that have their own native Intel display drivers. Additionally, the 4x3 emulation they provide is horribly slow.
It's definitely a poor situation on older systems, though it's usually better on EFI - you're far more likely to get native panel resolutions out of GOP.
It's my impression that it is worst on newer systems and works better on older. Which seems to coincidence with Linux having native video drivers, and so Intel no longer feel they need to provide the native resolution of the display through VBE or EFI. They will typically support only 640x480, 800x600 and 1024x768.
klange wrote: On some BIOS systems, you could patch the VGA BIOS to replace one of the available VBE modes with the native panel resolution and timings.

Luckily, Intel GPUs aren't too hard to write barebones modesetting drivers for, especially if you just want to get one specific display working. Toaru has one just for my old ThinkPad, which has a 1440x900 panel but only offered up to 1280x800 from VBE (at least that's the right aspect ratio!)
That's an interesting approach. Does this only work for a very specific Intel GPU, or for a larger range of models?
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: circle looks like an ellipse on real display

Post by devc1 »

My pc with an 1920x1080 display has the same problem (Nvidia QUADRO 2000).

Everything on the screen is stretched without gpu driver (in GOP and VBE mode)
rdos
Member
Member
Posts: 3296
Joined: Wed Oct 01, 2008 1:55 pm

Re: circle looks like an ellipse on real display

Post by rdos »

I have a relatively new AMD laptop with a widescreen display, and GOP has the native resolution. I've not yet seen any AMD BIOS that doesn't support the native resolution. It seems to be an Intel problem. Additionally, AMDs displays are much faster at the same resolution when using LFB.
stack
Posts: 3
Joined: Fri Nov 18, 2022 1:48 pm

Re: circle looks like an ellipse on real display

Post by stack »

It is wise to not assume square pixels, and provide for a way to adjust the pixel aspect ratio.
Post Reply