Custom display resolutions in QEMU

04.05.2013 19:19

QEMU emulates a VESA-compliant VGA card that supports a static set of standard and a-bit-less-standard display resolutions. However, this set is far from universal and for example doesn't include the wide-screen 1600x900 resolution on my laptop. This means that running a virtualized OS full-screen would always stretch the display somewhat and give a blurry image.

Here's how I fixed that. Following instructions should pretty much work for adding an arbitrary resolution to QEMU's virtualized graphics card (but only when using -vga std). They are based on this patch.

Fetch QEMU source (I used 1.4.0) and edit roms/vgabios/vbetables-gen.c. For instance, to add 1600x900 I applied this patch:

Update: this patch still works for QEMU release 2.5.0. If you are using a git checkout instead of the release tarball, see comments below.

--- qemu-1.4.0.orig/roms/vgabios/vbetables-gen.c	2013-02-16 00:09:22.000000000 +0100
+++ qemu-1.4.0/roms/vgabios/vbetables-gen.c	2013-05-04 11:46:55.000000000 +0200
@@ -76,6 +76,9 @@
 { 2560, 1600, 16                     , 0x18a},
 { 2560, 1600, 24                     , 0x18b},
 { 2560, 1600, 32                     , 0x18c},
+{ 1600,  900, 16                     , 0x18d},
+{ 1600,  900, 24                     , 0x18e},
+{ 1600,  900, 32                     , 0x18f},
 { 0, },
 };

Now re-build the VGA BIOS binary image (apt-get install bcc first):

$ cd roms/vgabios
$ make stdvga-bios

QEMU's make install will not install the image you just built. Instead, it will use an already built binary they ship with the source. Therefore you have to install it manually:

$ cp VGABIOS-lgpl-latest.stdvga.bin $PREFIX/share/qemu/vgabios-stdvga.bin

Of course, replace $PREFIX with the prefix you used when installing QEMU (/usr/local by default). Now when you start a virtualized OS you should see the resolution you added to vbetables-gen.c (for example as reported by xrandr or under Screen resolution in Windows).

Posted by Tomaž | Categories: Code

Comments

This was very useful, thx.

Posted by core

Thx for sharing first !

Strange I can not find this file:
./roms/vgabios/vbetables-gen.c

- this folder is siply empty:

$ l roms/vgabios/
total 8
drwxr-xr-x 2 root root 4096 Sep 19 13:52 ./
drwxr-xr-x 9 root root 4096 Sep 19 13:52 ../

I use git :
git clone git://git.qemu-project.org/qemu.git

now the branch is 1.5.xxx but checking out 1.4.0 doesnt help either.
The .bin are allready in pc-bios folder:

$ l pc-bios/vgabios*
-rw-r--r-- 1 root root 40448 Sep 19 13:52 pc-bios/vgabios.bin
-rw-r--r-- 1 root root 35840 Sep 19 13:52 pc-bios/vgabios-cirrus.bin
-rw-r--r-- 1 root root 40448 Sep 19 13:52 pc-bios/vgabios-qxl.bin
-rw-r--r-- 1 root root 40448 Sep 19 13:52 pc-bios/vgabios-stdvga.bin
-rw-r--r-- 1 root root 40448 Sep 19 13:52 pc-bios/vgabios-vmware.bin

any ideas how could this be ?

Thanks in advance !
Your UncleVan.

Posted by UncleVan

UncleVan, most likely vgabios code is stored in a different git repository. Check if they are using git submodules or something like that.

I was using the stable qemu-1.4.0.tar.bz2 release.

Posted by Tomaž

I think the code now lives in the SeaBIOS project.

Specifically, the following patch almost worked (resolution showed up but switching to it was garbled).

diff -ur seabios-1.7.3.1.old/vgasrc/bochsvga.c seabios-1.7.3.1/vgasrc/bochsvga.c
--- seabios-1.7.3.1.old/vgasrc/bochsvga.c 2014-08-27 10:31:58.807413368 +0100
+++ seabios-1.7.3.1/vgasrc/bochsvga.c 2014-08-27 11:07:11.586451792 +0100
@@ -54,6 +54,7 @@
{ 0x11D, { MM_DIRECT, 1600, 1200, 15, 8, 16, SEG_GRAPH } },
{ 0x11E, { MM_DIRECT, 1600, 1200, 16, 8, 16, SEG_GRAPH } },
{ 0x11F, { MM_DIRECT, 1600, 1200, 24, 8, 16, SEG_GRAPH } },
+ { 0x120, { MM_DIRECT, 1366, 768, 24, 8, 16, SEG_GRAPH } },
/* BOCHS modes */
{ 0x140, { MM_DIRECT, 320, 200, 32, 8, 16, SEG_GRAPH } },
{ 0x141, { MM_DIRECT, 640, 400, 32, 8, 16, SEG_GRAPH } },
@@ -89,6 +90,7 @@
{ 0x18a, { MM_DIRECT, 2560, 1600, 16, 8, 16, SEG_GRAPH } },
{ 0x18b, { MM_DIRECT, 2560, 1600, 24, 8, 16, SEG_GRAPH } },
{ 0x18c, { MM_DIRECT, 2560, 1600, 32, 8, 16, SEG_GRAPH } },
+ { 0x18d, { MM_DIRECT, 1366, 768, 24, 8, 16, SEG_GRAPH } },
};

static int is_bochsvga_mode(struct vgamode_s *vmode_g)

Any further clues?

(Sorry, couldn't post a link to the SeaBIOS site without triggering the spam filter, but it's on coreboot dot org)

Add a new comment


(No HTML tags allowed. Separate paragraphs with a blank line.)