Purpose: So some of you must have heard about a new feature that got introduced since 2.6.29 Linux kernel known as Kernel Mode Setting (KMS).I will not go into the details about the benefits of KMS in this post but rather I will show you how to enable KMS on your Debian system. However I will provide you a list of websites through my del.icio.us account bookmarks which will tell you pros and cons (?) of KMS.

Background

So let’s see briefly what is KMS? KMS is a feature now in Linux kernel which will do the work of setting your screen resolution, depth, colors, etc. Earlier this was done by the XOrg graphics drivers. For example, before the kernel version 2.6.28, when you use to change your screen resolution from your GNOME/KDE, the XOrg driver use to do it. Now the same task is moved into the Linux kernel to speed up the things. Also a noticeable advantage that user can see is the flicker free and quick switch to any VT (Virtual Terminal) that you get by pressing Ctrl+Alt+F1 key. Now one you get KMS running you can almost instantaneously switch back and forth between VT (Ctrl+Alt+F1) and X server (Ctrl+Alt+F7). Also currently not all video drivers (Nvidia, ATI, etc.) have the KMS feature inside the Linux kernel. Only the Intel’s graphics hardware drivers (i915) have KMS feature inside the kernel. But eventually more and more drivers will have this feature. So in this post, I will show you how to enable KMS with the Intel’s i915 driver.

Requirements

So couple of things to remember. Just by upgrading to 2.6.29 kernel or later and configuring it properly,  you cannot have KMS. You also need to make sure that you have relatively new user space installed i.e. XOrg system. Both, the Linux kernel and XOrg system have to work cooperatively to get KMS working. So you need to make sure that you are using xserver-xorg-video-intel package version 2.5.0 or later. Unfortunately currently, Debian Lenny’s (Stable) has version 2.3.2. This means that even if we upgrade to 2.6.29 or later kernel, we won’t have KMS working because we have an old user-space (2.3.2<2.5.0) which is typical of Debian considering it’s main criteria is stability. So we will try to get KMS working on Debian Testing (Squeeze) which has 2.9.0 version for xserver-xorg-video-intel package.

So let’s get started…

Step 1: Download and Install latest kernel

Get the latest version of kernel or at least try to get 2.6.29. I am currently using 2.6.30 kernel which is the default in Debian Testing as of time of this writing. Point your sources.list file to “testing” branch:

# nano /etc/apt/sources.list

Contents:

deb http://mirrors.kernel.org/debian testing main contrib non-free
deb-src http://mirrors.kernel.org/debian testing main contrib non-free
deb http://security.debian.org/ testing/updates main contrib non-free

Save and quit the file. Now install kernel sources using your preferred method:

# apt-get update
# apt-get upgrade
# apt-get install linux-source-2.6.30

Step 2: Configure your kernel for KMS

This is a very important step. First of all remove all the framebuffer drivers from your kernel config. Yes, that right drivers like vesafb, intelfb, etc are not compatible with KMS. Instead when you enable KMS for the Intel’s i915 driver, it will provide it’s own framebuffer drivers called inteldrmfb.Following is a snippet of dmesg once you boot from a KMS enabled kernel:

[    0.327679] [drm] Initialized drm 1.1.0 20060810
[    2.199142] [drm] DAC-6: set mode 640x480 0
[    2.511505] [drm] TV-13: set mode NTSC 480i 0
[    2.722014] [drm] LVDS-8: set mode 1024x768 15
[    2.760091] fb0: inteldrmfb frame buffer device
[    2.760101] [drm] Initialized i915 1.6.0 20080730 for 0000:00:02.0 on minor 0

So let’s start configuring kernel…

Make sure the following are enabled:

CONFIG_DRM_I915=m (or y)
CONFIG_DRM_I915_KMS=y

in

Device Drivers->Graphics Support->Direct Rendering Manager->Intel 830M, 845G, 852GM, 855GM, 865G->i915 Driver->Enable modesetting on intel by default (DRM_I915_KMS)

Note: The option CONFIG_DRM_I915_KMS=y is not necessary to get KMS working. What this option does is just enable the KMS by default. If you are using 2.6.29 or recent kernels just selecting CONFIG_DRM_I915=m (or y) should be sufficient to get KMS working although you will need to re-generate your initrd with certain command line options to enable KMS at the start of the boot process. See Step 4 for more details.

Next make sure that all the FRAMEBUFFER DRIVERS are disabled. Following is a snippet from my kernel config:

# Frame buffer hardware drivers
#
# CONFIG_FB_CIRRUS is not set
# CONFIG_FB_PM2 is not set
# CONFIG_FB_CYBER2000 is not set
# CONFIG_FB_ARC is not set
# CONFIG_FB_ASILIANT is not set
# CONFIG_FB_IMSTT is not set
# CONFIG_FB_VGA16 is not set
# CONFIG_FB_VESA is not set
# CONFIG_FB_EFI is not set
# CONFIG_FB_N411 is not set
# CONFIG_FB_HGA is not set
# CONFIG_FB_S1D13XXX is not set
# CONFIG_FB_NVIDIA is not set
# CONFIG_FB_RIVA is not set
# CONFIG_FB_I810 is not set
# CONFIG_FB_LE80578 is not set
# CONFIG_FB_INTEL is not set
# CONFIG_FB_MATROX is not set
.........
# CONFIG_FB_VOODOO1 is not set
# CONFIG_FB_VT8623 is not set
# CONFIG_FB_TRIDENT is not set
# CONFIG_FB_ARK is not set
# CONFIG_FB_PM3 is not set
# CONFIG_FB_CARMINE is not set

However you need to make sure that the Framebuffer console driver is enabled otherwise you will get a blank/black screen upon boot:

# Console display driver support
#
CONFIG_VGA_CONSOLE=y
# CONFIG_VGACON_SOFT_SCROLLBACK is not set
# CONFIG_MDA_CONSOLE is not set
CONFIG_DUMMY_CONSOLE=y
CONFIG_FRAMEBUFFER_CONSOLE=y
# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
# CONFIG_FONTS is not set

That’s all the important things you need to keep in mind regarding the kernel config. Now compile and install your kernel.

Step 3: Install Xorg drivers

Since we enabled KMS for Intel drivers in the kernel config we need to make sure that we install the corresponding XOrg drivers (user-space).

apt-get install xserver-xorg-video-intel

and make you have correct version installed:

dpkg -l | grep video-intel
ii  xserver-xorg-video-intel             2:2.9.0-1                        X.Org X server -- Intel i8xx, i9xx display

As you can see the version is 2.9.0 > 2.5.0. So looks like we are all set.

Step 4: Enable the KMS module


Now we need to make sure that the KMS module kicks in right at the start of the boot process. If you compiled the KMS (CONFIG_DRM_I915_KMS=y) in your kernel then you can skip this step.

If you didn’t compile the above option in your kernel and your kernel requires an initrd to boot, do the following:

# nano /etc/initramfs-tools/modules

and add the following:
# Enable Kernel Modesetting
intel_agp
drm
i915 modeset=1

Save and quite file.

and after that regenerate your initrd for the kernel that you just compiled:

# update-initramfs -k 2.6.30-kms -u

Alternatively if you have initramfs-tools version 0.93.4 or later you need not do the above. Simply give the following parameter on kernel command line in your GRUB boot screen:

video=i915:modeset=1

or you can add this to your /boot/grub/menu.lst file to make the change permanently.

Also you need to remove any instances which are similar to the following in your menu.lst file:

vga=791

I understand that this entire Step 4 might be a bit confusing depending upon whether you are using Debian Stable or Debian Testing/Sid. Feel free to ask questions in the comment section.

Step 5: Finally reboot

Finally you are just one step closer tp bliss i.e. experience the magic of KMS. Reboot your system and cross your fingers.

Changes are that you have a successful boot with KMS module and text appear on your screen as you boot.

You can verify whether the KMS thing worked or not by looking at your dmesg:

# dmesg | grep drm
Output:
[    0.327679] [drm] Initialized drm 1.1.0 20060810
[    2.199142] [drm] DAC-6: set mode 640x480 0
[    2.511505] [drm] TV-13: set mode NTSC 480i 0
[    2.722014] [drm] LVDS-8: set mode 1024x768 15
[    2.760091] fb0: inteldrmfb frame buffer device
[    2.760101] [drm] Initialized i915 1.6.0 20080730 for 0000:00:02.0 on minor 0
[   22.191132] [drm] DAC-6: set mode 640x480 0
[   22.321921] [drm] DAC-6: set mode 640x480 0
[   22.641029] [drm] TV-13: set mode NTSC 480i 0
[   22.809440] [drm] TV-13: set mode NTSC 480i 0
...........

Text similar to above confirms that your KMS module (inteldrmfb) was loaded correctly. It should automatically detect the native screen resolution of your display device and set it to that during the boot process.

Finally once you are in your Graphics environment like GNOME/KDE/LXDE, trying switching to a VT1 as mentioned in the beginning of the post and you will notice a quick and flicker free transition.

That’s it. As promised here are some links for more information regarding this whole KMS thing.

Happy KMS’ing!
Subscribe for testking N10-004 training program and pass your real exam on first attempt. Our testking 220-701 study guide and testking 350-030 dumps contain everything that you must have to learn to pass real exam.

Be Sociable, Share!