Page 1 of 1

circle looks like an ellipse on real display

Posted: Sun Nov 13, 2022 8:12 am
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

Re: circle looks like an ellipse on real display

Posted: Sun Nov 13, 2022 8:43 am
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?

Re: circle looks like an ellipse on real display

Posted: Sun Nov 13, 2022 4:34 pm
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.

Re: circle looks like an ellipse on real display

Posted: Mon Nov 14, 2022 1:51 am
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.

Re: circle looks like an ellipse on real display

Posted: Mon Nov 14, 2022 3:04 am
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!)

Re: circle looks like an ellipse on real display

Posted: Mon Nov 14, 2022 4:37 am
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

Re: circle looks like an ellipse on real display

Posted: Mon Nov 14, 2022 6:55 am
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?

Re: circle looks like an ellipse on real display

Posted: Mon Nov 14, 2022 8:09 am
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)

Re: circle looks like an ellipse on real display

Posted: Mon Nov 14, 2022 2:42 pm
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.

Re: circle looks like an ellipse on real display

Posted: Mon Nov 21, 2022 3:47 pm
by stack
It is wise to not assume square pixels, and provide for a way to adjust the pixel aspect ratio.