Framebuffer

From LQWiki
Jump to navigation Jump to search

A framebuffer is a block of memory that holds one frame (one whole display or picture) of pixel data.

In the Linux kernel, there is a framebuffer device available. This device provides a hardware independent API for graphics devices. Applications see a framebuffer and can manipulate it though this API. It is accessed through a special device, normally /dev/fb* (e.g. /dev/fb0). It behaves much like other memory devices in linux, in that you can also read and write it with normal tools. For example copying the framebuffer to a file (effectively making a raw screenshot) can be done with:

cat /dev/fb0 > somefile

The main application of this in the Linux kernel is allowing the Tux logo at boot and a high resolution text console (a "Framebuffer console" -- the module for this is called fbcon). It's also for use on platforms which don't support a standard text mode. Other applications can also use it to get graphics without X or some other library, this is especially interesting for embedded devices.

Drivers

These drivers are normally located in kernel/drivers/video. There are general drivers, like vesafb (which supports VESA BIOS extensions 2.0 capable videocards) and vga16fb (VGA compatible videocards). There are also different ones for specific videocards/chipsets (which do some basic 2D hardware acceleration to make it faster -- most of the hardware acceleration is left to do by the applications that use it).

Try

modprobe -l | grep fb

to see a few on your system.

Configuring framebuffer console

  • Kernel boot parameters, vga=ask and friends
  • fbset
  • video modes
  • etc

XFree86

XFree86 can also use the Linux framebuffer device. There is a special XFree86 driver, called fbdev, which uses the framebuffer device. This allows XFree86 to support even more videocards (specially with the vesafb). Note however that this driver is un-accelerated, meaning it doesn't make use of specific extra graphics hardware on your video card, so graphics rendering can be slow. Many other XFree86 videocard drivers can also use the Linux framebuffer device (without losing hardware acceleration). This is done by adding:

Option "UseFBDev" "True"

to the Device section of the XF86Config file. Check the manual page of the XFree86 driver to see if it supports this. There isn't a difference in performence between using the framebuffer device and not. The difference lies in the implementation of the driver (using the fbdev device moves videomode and colormap handling into the kernel). So it's mainly a developer thing -- users normally don't care. It just makes XFree86 use a 'clean' API to access the hardware, instead of it's own code that directly accesses the hardware.

Other applications

There are many other applications that can use the framebuffer device. Some of these are:

  • SDL can also output to it (so every application using SDL can theoretically run on it)
  • MPlayer can use it to display videos directly on the linux console.
  • DirectFB - A library which is a layer on top of the linux framebuffer device which does hardware acceleration, windowing, and input
  • GGI - It also has a output target for this

3D hardware acceleration

There are also some projects with the goal of adding 3d hardware acceleration to the linux framebuffer device.

Other Docs

See also:

  • man fbdev