Frame Buffer

The FrameBuffer device is Linux's new way of accessing the video subsystem.

It works like this: the framebuffer device (typically /dev/fb0) acts like a file. You can open it, read to it and write to it. For example, you can use the Unix cp command to make a screen shot.

But in particular, a program that wants to have direct access to the video RAM can mmap(2). mmap is an interesting system call; it asks the operating system to "map" the contents of a file at a certain position in memory, using the page faulting mechanism to load the file on-demand. Even more interesting, when you mmap the framebuffer device, rather than copying the contents of the video RAM to the process space of your program, the video RAM is directly mapped into the address space of your program. So this actually allows a program to have direct access to the video RAM, without requiring it to run as kernel module or even as "root". It just needs to have the right permissions for /dev/fb0.

To change resolutions (i.e., from 640x480 to 800x600 or vice-versa), you'll probably need to do something with ioctl() and the fb_var_screeninfo struct seen here: http://ibiblio.org/gferg/ldp/Console-Programming-HOWTO/x266.html


MemoryMappedVideo? is a common technique in computers. The primary alternative is to communicate with an external device with a well defined low level hardware-level protocol over a high speed line.

Personal computers with MemoryMappedVideo?: AppleTwo, CommodoreSixtyFour, IbmPc? (original, and all later versions)

That is a different subject in an important way: that is merely the way the hardware works, and the software is talking directly to the hardware without any intervening assistance from the operating system.

The Linux framebuffer, on the other hand, uses the OS to handle virtual memory mapping of the framebuffer into the user space, and perhaps more importantly, to implement a more abstract virtual graphics device. The Linux framebuffer is not a physical hardware device, and accessing it does not require knowledge of the underlying graphics hardware registers that the OS is manipulating to implement the framebuffer.

Originally there was a comment above about the X11 Window System, but that is very different than all other topics on this page. X11 uses a moderately high level protocol to communicate over networks (ethernet and Internet, for instance) to connect graphics/GUI servers and clients. The graphics device may or may not be memory mapped under X11; it all depends on the hardware device, not on X11.


MemoryMappedFiles? are a general way to access and change the contents of disk files by mapping them into regions of the virtual address space, and using virtual memory management paging functions to control physical reads and writes to disk.


EditText of this page (last edited February 4, 2004) or FindPage with title or text search