Difference between revisions of "Kernel mode setting"

From ArchWiki
Jump to: navigation, search
m (link fixes)
m (My fonts are too tiny: Add more specific info about larger sizes for Terminus. (If this edit is no good, I recommend removing ", including larger sizes." which doesn't add anything.))
 
(67 intermediate revisions by 27 users not shown)
Line 1: Line 1:
 
[[Category:Graphics]]
 
[[Category:Graphics]]
 
[[Category:Kernel]]
 
[[Category:Kernel]]
[[Category:X Server]]
+
[[Category:X server]]
[[es:Kernel Mode Setting]]
+
[[es:Kernel mode setting]]
[[hu:Kernel Mode Setting]]
+
[[hu:Kernel mode setting]]
[[zh-CN:Kernel Mode Setting]]
+
[[ja:Kernel Mode Setting]]
[[zh-TW:Kernel Mode Setting]]
+
[[ru:Kernel mode setting]]
{{Article summary start|Summary}}
+
[[zh-cn:Kernel mode setting]]
{{Article summary text|Information about configuring the Kernel Mode Setting method.}}
+
[[zh-tw:Kernel mode setting]]
{{Article summary heading|Related}}
+
{{Related articles start}}
{{Article summary wiki|ATI}}
+
{{Related|ATI}}
{{Article summary wiki|Intel}}
+
{{Related|Intel graphics}}
{{Article summary wiki|Nouveau}}
+
{{Related|Nouveau}}
{{Article summary end}}
+
{{Related articles end}}
 +
 
 +
{{Expansion|KMS and rootless X (1.16), see [[Talk:Kernel mode setting]] and [[Xorg#Rootless Xorg (v1.16)]].}}
  
 
Kernel [[Wikipedia:Mode-setting|Mode Setting]] (KMS) is a method for setting display resolution and depth in the kernel space rather than user space.
 
Kernel [[Wikipedia:Mode-setting|Mode Setting]] (KMS) is a method for setting display resolution and depth in the kernel space rather than user space.
Line 18: Line 20:
 
The Linux kernel's implementation of KMS enables native resolution in the framebuffer and allows for instant console (tty) switching.  KMS also enables newer technologies (such as DRI2) which will help reduce artifacts and increase 3D performance, even kernel space power-saving.
 
The Linux kernel's implementation of KMS enables native resolution in the framebuffer and allows for instant console (tty) switching.  KMS also enables newer technologies (such as DRI2) which will help reduce artifacts and increase 3D performance, even kernel space power-saving.
  
{{Note|The proprietary [[NVIDIA|nvidia]] and [[AMD Catalyst|catalyst]] drivers also implement kernel mode-setting, but as they do not use the built-in kernel implementation, they lack an fbdev driver for the high-resolution console.}}
+
{{Note|The proprietary [[NVIDIA]] driver (since 364.12) also implements kernel mode-setting, but it does not use the built-in kernel implementation and it lacks an fbdev driver for the high-resolution console.}}
  
 
== Background ==
 
== Background ==
Previously, setting up the video card was the job of the X server. Because of this, it was not easily possible to have fancy graphics in virtual consoles. Also, each time a switch from X to a virtual console was made ({{Keypress|Ctrl+Alt+F1}}), the server had to give control over the video card to the kernel, which was slow and caused flickering. The same "painful" process happened when the control was given back to the X server ({{Keypress|Ctrl+Alt+F7}}).
+
 
 +
Previously, setting up the video card was the job of the X server. Because of this, it was not easily possible to have fancy graphics in virtual consoles. Also, each time a switch from X to a virtual console was made ({{ic|Ctrl+Alt+F1}}), the server had to give control over the video card to the kernel, which was slow and caused flickering. The same "painful" process happened when the control was given back to the X server ({{ic|Ctrl+Alt+F7}}).
  
 
With Kernel Mode Setting (KMS), the kernel is now able to set the mode of the video card. This makes fancy graphics during bootup, virtual console and X fast switching possible, among other things.
 
With Kernel Mode Setting (KMS), the kernel is now able to set the mode of the video card. This makes fancy graphics during bootup, virtual console and X fast switching possible, among other things.
 +
 
== Installation ==
 
== Installation ==
 +
 
At first, note that for ''any'' method you use, you should ''always'' disable:
 
At first, note that for ''any'' method you use, you should ''always'' disable:
* Any "vga=" options in your bootloader as these will conflict with the native resolution enabled by KMS.
+
 
* Any "video=" lines that enable a framebuffer that conflicts with the driver.
+
* Any {{ic|<nowiki>vga=</nowiki>}} options in your bootloader as these will conflict with the native resolution enabled by KMS.
 +
* Any {{ic|<nowiki>video=</nowiki>}} lines that enable a framebuffer that conflicts with the driver.
 
* Any other framebuffer drivers (such as [[uvesafb]]).
 
* Any other framebuffer drivers (such as [[uvesafb]]).
  
 
=== Late KMS start===
 
=== Late KMS start===
[[Intel]], [[Nouveau]] and [[ATI]] drivers already enable KMS automatically for all chipsets. So you need not install it manually.
 
  
The proprietary [[NVIDIA]] and [[AMD Catalyst]] drivers do not use the open driver stack. In order to use KMS you should replace them with open source drivers.
+
[[Intel]], [[Nouveau]], [[ATI]] and [[AMDGPU]] drivers already enable KMS automatically for all chipsets, so you need not install it manually.
 +
 
 +
The proprietary [[NVIDIA]] driver supports KMS (since 364.12), which has to be [[NVIDIA#DRM kernel mode setting|manually enabled]].
 +
 
 +
The proprietary [[AMD Catalyst]] driver does not support KMS. In order to use KMS you have to replace it with the open-source [[ATI]] driver.
  
 
=== Early KMS start ===
 
=== Early KMS start ===
  
To load KMS as early as possible in boot process, add the module [[radeon]] (for ATI/AMD cards), [[Intel|i915]] (for Intel integrated graphics) or [[nouveau]] (for Nvidia cards) to the {{ic|MODULES}} line in {{ic|/etc/mkinitcpio.conf}}:
+
{{Tip|If you encounter problems with the resolution, you can check whether [[#Forcing modes and EDID|enforcing the mode]] helps.}}
  
{{hc|/etc/mkinitcpio.conf|2=MODULES="i915"
+
KMS is typically initialized after the [[Arch boot process#initramfs|initramfs stage]]. However it is possible to already enable KMS during the initramfs stage. Add the module {{ic|radeon}}/{{ic|amdgpu}} (for ATI/AMD cards), {{ic|i915}} (for Intel integrated graphics) or {{ic|nouveau}} (for Nvidia cards) to the {{ic|MODULES}} line in {{ic|/etc/mkinitcpio.conf}}. For example:
'''or'''
+
MODULES="radeon"
+
'''or'''
+
MODULES="nouveau"}}
+
  
Rebuild your kernel image (refer to the [[mkinitcpio]] article for more info):
+
{{hc|/etc/mkinitcpio.conf|2=MODULES="... i915 ..."}}
  
{{bc|# mkinitcpio -p <name of your kernel preset; e.g. ''linux''>}}
+
{{Note|Intel users might need to add {{ic|intel_agp}} before {{ic|i915}} to suppress the ACPI errors. This might be required for resuming from hibernation to work with changed display configuration!}}
  
==Troubleshooting==
+
If you are using a custom EDID file (not applicable for the built-in resolutions), you should embed it into initramfs as well:
  
===My fonts are too tiny===
+
{{hc|/etc/mkinitcpio.conf|2=
See [[Fonts#Changing_the_default_font | changing the default font]] for how to change your console font to a large font. Terminus font in [community] is available in many sizes, including larger sizes.
+
FILES="/usr/lib/firmware/edid/your_edid.bin"
 +
}}
  
===Issue upon bootloading and dmesg===
+
Rebuild your initial ramdisk image (see [[mkinitcpio]]).
Polling for connected display devices on older systems can be quite expensive. Poll will happen periodically and can in worst cases take several hundred milliseconds, depending on the hardware. This will cause visible stalls, for example in video playback. These stalls might happen even when your video is on HDP output but you have other non HDP outputs in your hw configuration. If you experience stalls in display output occurring every 10 seconds, disabling polling might help.
+
  
If you see an error code of 0x00000010 (2) while booting up, (You will get about 10 lines of text, the last part denoting that error code), then add the following line into {{ic|/etc/modprobe.d/modprobe.conf}}:
+
== Troubleshooting ==
  options drm_kms_helper poll=0
+
 
 +
=== My fonts are too tiny ===
 +
 
 +
See [[Fonts#Console fonts]] for how to change your console font to a large font. The Terminus font ({{Pkg|terminus-font}}) is available in many sizes, such as {{ic|ter-132n}} which is larger.
 +
 
 +
Alternatively, disabling KMS by appending {{ic|nomodeset}} as a kernel parameter will also make fonts readable.
 +
 
 +
=== Problem upon bootloading and dmesg ===
 +
 
 +
Polling for connected display devices on older systems can be quite expensive. Poll will happen periodically and can in worst cases take several hundred milliseconds, depending on the hardware. This will cause visible stalls, for example in video playback. These stalls might happen even when your video is on HDP output but you have other non HDP outputs in your hw configuration. If you experience stalls in display output occurring every 10 seconds, disabling polling might help.
 +
 
 +
If you see an error code of {{ic|0x00000010 (2)}} while booting up, (you will get about 10 lines of text, the last part denoting that error code), use:
 +
 
 +
{{hc|/etc/modprobe.d/modprobe.conf|2=
 +
options drm_kms_helper poll=0
 +
}}
 +
 
 +
== Forcing modes and EDID ==
 +
 
 +
{{Expansion|This section is a WIP. Improvements and corrections are more than welcome}}
 +
 
 +
In case that your monitor/TV is not sending the appropriate [[Wikipedia:EDID|EDID]] or similar problems, you will notice that the native resolution is not automatically configured or no display at all. The kernel has a provision to load the binary EDID data, and provides as well data to set four of the most typical resolutions.
 +
 
 +
If you have the EDID file for your monitor the process is easy. If you do not have, you can either use one of the built-in resolution-EDID binaries (or generate one during kernel compilation, [https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/Documentation/EDID/HOWTO.txt more info here]) or build your own EDID.
 +
 
 +
In case you have an EDID file (e.g. extracted from Windows drivers for your monitor or using {{ic|get-edid}} command from {{Pkg|read-edid}}), create a dir {{ic|edid}} under {{ic|/usr/lib/firmware}}:
 +
 
 +
# mkdir /usr/lib/firmware/edid
 +
 
 +
and then copy your binary into the {{ic|/usr/lib/firmware/edid}} directory.
 +
 
 +
To load it at boot, specify the following in the [[kernel command line]]:
 +
 
 +
  drm_kms_helper.edid_firmware=edid/your_edid.bin
 +
 
 +
You can also specify it only for a specified connection:
 +
 
 +
drm_kms_helper.edid_firmware=VGA-1:edid/your_edid.bin
 +
 
 +
For the four built-in resolutions, see table below for the name to specify:
 +
 
 +
{| class="wikitable"
 +
|-
 +
| '''Resolution''' || '''Name to specify'''
 +
|-
 +
| 1024x768 || edid/1024x768.bin
 +
|-
 +
| 1280x1024 || edid/1280x1024.bin
 +
|-
 +
| 1600x1200 (kernel 3.10 or higher) || edid/1600x1200.bin
 +
|-
 +
| 1680x1050 || edid/1680x1050.bin
 +
|-
 +
| 1920x1080 || edid/1920x1080.bin
 +
|}
 +
 
 +
If you are doing early KMS, you must include the custom EDID file in the [[#Early_KMS_start|initramfs]] or you will run into problems.
 +
 
 +
You can also construct your own EDID with the makefile included in the {{ic|Documentation/EDID}} sources of the kernel. The full information can be read [https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/EDID/HOWTO.txt here] and [https://www.osadl.org/Single-View.111+M591850c02b5.0.html there].
 +
 
 +
{{Warning|The method described below is somehow incomplete because e.g. Xorg does not take into account the resolution specified, so users are encouraged to use the method described above; however, specifying resolution with {{ic|1=video=}} command line may be useful in some scenarios}}
  
==Forcing modes==
 
 
From [http://nouveau.freedesktop.org/wiki/KernelModeSetting the nouveau wiki]:
 
From [http://nouveau.freedesktop.org/wiki/KernelModeSetting the nouveau wiki]:
  
A mode can be forced on the kernel command line. Unfortunately, the command line option video is poorly documented in the DRM case. Bit and pieces on how to use it can be found in
+
A mode can be forced on the kernel command line. Unfortunately, the command line option video is poorly documented in the DRM case. Bits and pieces on how to use it can be found in
  
*http://cgit.freedesktop.org/nouveau/linux-2.6/tree/Documentation/fb/modedb.txt
+
* http://cgit.freedesktop.org/nouveau/linux-2.6/tree/Documentation/fb/modedb.txt
*http://cgit.freedesktop.org/nouveau/linux-2.6/tree/drivers/gpu/drm/drm_fb_helper.c  
+
* http://cgit.freedesktop.org/nouveau/linux-2.6/tree/drivers/gpu/drm/drm_fb_helper.c  
  
 
The format is:  
 
The format is:  
 +
 
  video=<conn>:<xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m][eDd]
 
  video=<conn>:<xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m][eDd]
  
*<conn>: Connector, e.g. DVI-I-1, see your kernel log.
+
* <conn>: Connector, e.g. DVI-I-1, see {{ic|/sys/class/drm/}} for available connectors
*<xres> x <yres>: resolution
+
* <xres> x <yres>: resolution
*M: compute a CVT mode?
+
* M: compute a CVT mode?
*R: reduced blanking?
+
* R: reduced blanking?
*-<bpp>: color depth
+
* -<bpp>: color depth
*@<refresh>: refresh rate
+
* @<refresh>: refresh rate
*i: interlaced (non-CVT mode)
+
* i: interlaced (non-CVT mode)
*m: margins?
+
* m: margins?
*e: output forced to on
+
* e: output forced to on
*d: output forced to off
+
* d: output forced to off
*D: digital output forced to on (e.g. DVI-I connector)  
+
* D: digital output forced to on (e.g. DVI-I connector)  
  
 
You can override the modes of several outputs using "video" several times, for instance, to force DVI to 1024x768 at 85 Hz and TV-out off:  
 
You can override the modes of several outputs using "video" several times, for instance, to force DVI to 1024x768 at 85 Hz and TV-out off:  
 +
 
  video=DVI-I-1:1024x768@85 video=TV-1:d
 
  video=DVI-I-1:1024x768@85 video=TV-1:d
  
==Disabling modesetting==
+
To get the name and current status of connectors, you can use the following shell oneliner:
 +
 
 +
{{hc|<nowiki>$ for p in /sys/class/drm/*/status; do con=${p%/status}; echo -n "${con#*/card?-}: "; cat $p; done</nowiki>|                                                                                       
 +
DVI-I-1: connected
 +
HDMI-A-1: disconnected
 +
VGA-1: disconnected
 +
}}
 +
 
 +
== Disabling modesetting ==
 +
 
 +
You may want to disable KMS for various reasons, such as getting a blank screen or a "no signal" error from the display, when using the Catalyst driver, etc. To disable KMS add {{ic|nomodeset}} as a kernel parameter. See [[Kernel parameters]] for more info.
 +
 
 +
Along with {{ic|nomodeset}} kernel parameter, for Intel graphics card you need to add {{ic|1=i915.modeset=0}} and for Nvidia graphics card  you need to add {{ic|1=nouveau.modeset=0}}. For Nvidia Optimus dual-graphics system, you need to add all the three kernel parameters (i.e. {{ic|1="nomodeset i915.modeset=0 nouveau.modeset=0"}}).
  
You may want to disable KMS for various reasons, such as getting a blank screen or a "no signal" error from the display, when using the Catalyst driver, etc. To disable KMS, add {{ic|nomodeset}} as a kernel parameter. See [[Kernel parameters]] for more info.
+
{{Note|Some [[Xorg]] drivers will not work with KMS disabled. See the wiki page on your specific driver for details.}}

Latest revision as of 16:04, 12 November 2016

Related articles

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: KMS and rootless X (1.16), see Talk:Kernel mode setting and Xorg#Rootless Xorg (v1.16). (Discuss in Talk:Kernel mode setting#)

Kernel Mode Setting (KMS) is a method for setting display resolution and depth in the kernel space rather than user space.

The Linux kernel's implementation of KMS enables native resolution in the framebuffer and allows for instant console (tty) switching. KMS also enables newer technologies (such as DRI2) which will help reduce artifacts and increase 3D performance, even kernel space power-saving.

Note: The proprietary NVIDIA driver (since 364.12) also implements kernel mode-setting, but it does not use the built-in kernel implementation and it lacks an fbdev driver for the high-resolution console.

Background

Previously, setting up the video card was the job of the X server. Because of this, it was not easily possible to have fancy graphics in virtual consoles. Also, each time a switch from X to a virtual console was made (Ctrl+Alt+F1), the server had to give control over the video card to the kernel, which was slow and caused flickering. The same "painful" process happened when the control was given back to the X server (Ctrl+Alt+F7).

With Kernel Mode Setting (KMS), the kernel is now able to set the mode of the video card. This makes fancy graphics during bootup, virtual console and X fast switching possible, among other things.

Installation

At first, note that for any method you use, you should always disable:

  • Any vga= options in your bootloader as these will conflict with the native resolution enabled by KMS.
  • Any video= lines that enable a framebuffer that conflicts with the driver.
  • Any other framebuffer drivers (such as uvesafb).

Late KMS start

Intel, Nouveau, ATI and AMDGPU drivers already enable KMS automatically for all chipsets, so you need not install it manually.

The proprietary NVIDIA driver supports KMS (since 364.12), which has to be manually enabled.

The proprietary AMD Catalyst driver does not support KMS. In order to use KMS you have to replace it with the open-source ATI driver.

Early KMS start

Tip: If you encounter problems with the resolution, you can check whether enforcing the mode helps.

KMS is typically initialized after the initramfs stage. However it is possible to already enable KMS during the initramfs stage. Add the module radeon/amdgpu (for ATI/AMD cards), i915 (for Intel integrated graphics) or nouveau (for Nvidia cards) to the MODULES line in /etc/mkinitcpio.conf. For example:

/etc/mkinitcpio.conf
MODULES="... i915 ..."
Note: Intel users might need to add intel_agp before i915 to suppress the ACPI errors. This might be required for resuming from hibernation to work with changed display configuration!

If you are using a custom EDID file (not applicable for the built-in resolutions), you should embed it into initramfs as well:

/etc/mkinitcpio.conf
FILES="/usr/lib/firmware/edid/your_edid.bin"

Rebuild your initial ramdisk image (see mkinitcpio).

Troubleshooting

My fonts are too tiny

See Fonts#Console fonts for how to change your console font to a large font. The Terminus font (terminus-font) is available in many sizes, such as ter-132n which is larger.

Alternatively, disabling KMS by appending nomodeset as a kernel parameter will also make fonts readable.

Problem upon bootloading and dmesg

Polling for connected display devices on older systems can be quite expensive. Poll will happen periodically and can in worst cases take several hundred milliseconds, depending on the hardware. This will cause visible stalls, for example in video playback. These stalls might happen even when your video is on HDP output but you have other non HDP outputs in your hw configuration. If you experience stalls in display output occurring every 10 seconds, disabling polling might help.

If you see an error code of 0x00000010 (2) while booting up, (you will get about 10 lines of text, the last part denoting that error code), use:

/etc/modprobe.d/modprobe.conf
options drm_kms_helper poll=0

Forcing modes and EDID

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: This section is a WIP. Improvements and corrections are more than welcome (Discuss in Talk:Kernel mode setting#)

In case that your monitor/TV is not sending the appropriate EDID or similar problems, you will notice that the native resolution is not automatically configured or no display at all. The kernel has a provision to load the binary EDID data, and provides as well data to set four of the most typical resolutions.

If you have the EDID file for your monitor the process is easy. If you do not have, you can either use one of the built-in resolution-EDID binaries (or generate one during kernel compilation, more info here) or build your own EDID.

In case you have an EDID file (e.g. extracted from Windows drivers for your monitor or using get-edid command from read-edid), create a dir edid under /usr/lib/firmware:

# mkdir /usr/lib/firmware/edid

and then copy your binary into the /usr/lib/firmware/edid directory.

To load it at boot, specify the following in the kernel command line:

drm_kms_helper.edid_firmware=edid/your_edid.bin

You can also specify it only for a specified connection:

drm_kms_helper.edid_firmware=VGA-1:edid/your_edid.bin

For the four built-in resolutions, see table below for the name to specify:

Resolution Name to specify
1024x768 edid/1024x768.bin
1280x1024 edid/1280x1024.bin
1600x1200 (kernel 3.10 or higher) edid/1600x1200.bin
1680x1050 edid/1680x1050.bin
1920x1080 edid/1920x1080.bin

If you are doing early KMS, you must include the custom EDID file in the initramfs or you will run into problems.

You can also construct your own EDID with the makefile included in the Documentation/EDID sources of the kernel. The full information can be read here and there.

Warning: The method described below is somehow incomplete because e.g. Xorg does not take into account the resolution specified, so users are encouraged to use the method described above; however, specifying resolution with video= command line may be useful in some scenarios

From the nouveau wiki:

A mode can be forced on the kernel command line. Unfortunately, the command line option video is poorly documented in the DRM case. Bits and pieces on how to use it can be found in

The format is:

video=<conn>:<xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m][eDd]
  • <conn>: Connector, e.g. DVI-I-1, see /sys/class/drm/ for available connectors
  • <xres> x <yres>: resolution
  • M: compute a CVT mode?
  • R: reduced blanking?
  • -<bpp>: color depth
  • @<refresh>: refresh rate
  • i: interlaced (non-CVT mode)
  • m: margins?
  • e: output forced to on
  • d: output forced to off
  • D: digital output forced to on (e.g. DVI-I connector)

You can override the modes of several outputs using "video" several times, for instance, to force DVI to 1024x768 at 85 Hz and TV-out off:

video=DVI-I-1:1024x768@85 video=TV-1:d

To get the name and current status of connectors, you can use the following shell oneliner:

$ for p in /sys/class/drm/*/status; do con=${p%/status}; echo -n "${con#*/card?-}: "; cat $p; done
                                                                                         
DVI-I-1: connected
HDMI-A-1: disconnected
VGA-1: disconnected

Disabling modesetting

You may want to disable KMS for various reasons, such as getting a blank screen or a "no signal" error from the display, when using the Catalyst driver, etc. To disable KMS add nomodeset as a kernel parameter. See Kernel parameters for more info.

Along with nomodeset kernel parameter, for Intel graphics card you need to add i915.modeset=0 and for Nvidia graphics card you need to add nouveau.modeset=0. For Nvidia Optimus dual-graphics system, you need to add all the three kernel parameters (i.e. "nomodeset i915.modeset=0 nouveau.modeset=0").

Note: Some Xorg drivers will not work with KMS disabled. See the wiki page on your specific driver for details.