view · edit · attach · print · history

The contents of this website are Copyright (c)2004 by Brian Manning <brian at antlinux dot com>. Please do not reuse any of the content on this website without permission from the author.

See also AntLinux.KernelBuildNotes

The following content was culled from the Linux kernel documentation; the kernel source and documentation is always considered authorative, this guide is just a collection of information that I put together for people to use.

VGA modes for PC computers

LILO, GRUB, and syslinux (Linux bootloaders) all want their VGA values in decimal. The Linux kernel wants VGA values in hexadecimal. The bootloaders do the conversion of the vga parameter from decimal to hexadecimal automatically when they load the kernel.

So how do you know which decimal or hexadecimal numbers to use for which video mode?

When you use the vga=### in GRUB, LILO, or syslinux, use the decimal number listed below that represents the video mode you want to use; for example, to obtain a framebuffer screen from the kernel that is 640x480 in size with 16 bits for color (64k colors), the tables below say 0x311 hexadecimal, so the vga parameter should be vga=785.

If you would like to hardcode this value into the kernel, there are a few ways you can do it:

  • From the kernel source:
    • The video mode to be used is selected by a variable which can be specified in a Makefile in the kernel source. In my 2.6.12 source, the file is $KERNEL_SOURCE/arch/i386/boot/Makefile, and the parameter to set is SVGA_MODE=.... When you compile your kernel, this value gets built into the kernel, and no other settings need to be made. This value needs to be set in hexdecimal (according to $KERNEL_SOURCE/Documentation/svga.txt)
  • From a bootloader:
    • by the vga=### option of LILO/Syslinux/GRUB (or another boot loader). This value needs to be in decimal. See ConvertingToHexadecimal.
  • From the rdev utility:
    • you can hardcode the video mode into the kernel by using the 'vidmode' utility (also known as 'rdev -v') which is present in standard Linux utility packages). See man rdev on your Linux system for more info. I'm not sure if you should be using a decimal or hexdecimal number here.

In case you don't have a scientific calculator handy, I've created a page that explains about using the GNU bc command when ConvertingToHexadecimal. You feed bc the decimal number you want to use for the VGA mode, and it spits out a hexadecimal number.

Table 1: Listing of Video Modes and codes

 Colours   640x400 640x480 800x600 1024x768 1152x864 1280x1024 1600x1200
  4 bits |    ?       ?     0x302      ?        ?        ?         ?
  8 bits |  0x300   0x301   0x303    0x305    0x161    0x307     0x31C
 15 bits |    ?     0x310   0x313    0x316    0x162    0x319     0x31D
 16 bits |    ?     0x311   0x314    0x317    0x163    0x31A     0x31E
 decimal |           d785    d788     d791
 24 bits |    ?     0x312   0x315    0x318      ?      0x31B     0x31F
 decimal |           d786    d789     d792
 32 bits |    ?       ?       ?        ?      0x164      ?

Here is a better explanation of VESA framebuffer (from Documentation/fb/vesafb.txt):

Table 2: listing of VESA mode numbers

     | 640x480  800x600  1024x768 1280x1024
 256 |  0x101    0x103    0x105    0x107
 32k |  0x110    0x113    0x116    0x119
 64k |  0x111    0x114    0x117    0x11A
 16M |  0x112    0x115    0x118    0x11B

The video mode number of the Linux kernel is the VESA mode number plus 0x200. So the table for the Kernel mode numbers are:

Table 3: Kernel VESA mode codes

     | 640x480  800x600  1024x768 1280x1024
 256 |  0x301    0x303    0x305    0x307
 32k |  0x310    0x313    0x316    0x319
 64k |  0x311    0x314    0x317    0x31A
 16M |  0x312    0x315    0x318    0x31B

Sources of documentation used to create this page:
$LINUX_KERNEL_SOURCE/Documentation/svga.txt $LINUX_KERNEL_SOURCE/Documentation/fb/vesafb.txt

view · edit · attach · print · history
Page last modified on April 25, 2006, at 09:20 AM