Usefulness of the Linux Framebuffer on the Virtual Console

Ritratto di jdaemon

The Linux Framebuffer is a graphic hardware-independent abstraction low level to show graphics on the monitor. It allows to display image, video, presentation files and more on the console through to the use of specific CLIs which support one. Useful when you have to use OS without X Window System...

Before starting you need to make sure that Framebuffer is currently available. Open any terminal and digit:
dmesg | grep -i vesa
Should see the "vesafb driver" (VESA standard) and the "fbX devices" entries, otherwise you need to enable framebuffer support by setting the bootloader and/or recompiling kernel.

fbX devices have full path /dev/fbX, with X number of graphics device (usually "/dev/fb0" is the first and only).
Assuming that our device is /dev/fb0, test it on either virtual or emulator console!
cp /dev/urandom /dev/fb0
Did you see something? ;)

Now we discover some things can do on a virtual console:

Display Images

fbi [options] image_file
fbi (linux framebuffer imageviewer) directly supports PhotoCD, jpeg, ppm, gif, tiff, xwd, bmp and png files. For other formats fbi tries to use ImageMagick's convert.
fbi is available in the repositories of major GNU/Linux distros.

Play Videos

mplayer -vo fbdev video_file
MPlayer supports MPEG/VOB, AVI, ASF/WMA/WMV, RM, QT/MOV/MP4, Ogg/OGM, MKV, VIVO, FLI, NuppelVideo, yuv4mpeg, FILM and RoQ. You can watch VCD, SVCD, DVD, Blu-ray, 3ivx, DivX 3/4/5, WMV and even movies with H.264 encoded.
It's downloadable from repository or http://www.mplayerhq.hu/design7/news.html

Save Screenshot

fbgrab [options] png_screenshot_file
fbgrab takes a screenshot using the framebuffer device and save it in png format.
To get fbgrab install "fbcat" package from repository in Debian GNU/Linux or the same name as the tool in other distros.
Alternatively you can also use ffmpeg and saving in jpeg format:
ffmpeg -f fbdev -frames:v 1 -r 1 -i /dev/fb0 screenshot.jpeg
finally there is the most raw:
cp /dev/fb0 screenshot
To save.
cp screenshot /dev/fb0
To display the screenshot saved before.

View Presentations

fbgs [-l|-xl|-xxl] [pdf_file|ps_file]
fbgs is a simple wrapper script which takes a PostScript or pdf file as input, renders the pages using ghostscript into a temporary directory and finally calls fbi to display them.
fbgs is contained in fbi package.

StreamCasting

ffmpeg -f fbdev -i /dev/fb0 -r 24 streamcast.avi
ffmpeg records from the framebuffer device /dev/fb0 in avi format.
It's downloadable from repository or http://ffmpeg.org

Surfing graphic web by text-browser

links2 -g http://hacklab.cz
links2 is a text mode WWW browser with ncurses interface. With "-g" option use framebuffer.
It's downloadable from repository or http://links.twibright.com
Alternatively you can also use lynx but images are displayed indirectly:
lynx -image_links http://hacklab.cz
lynx is a general purpose distributed information browser for the World Wide Web. The "-image_links" option toggles inclusion of links for all images.
It's downloadable from repository or http://lynx.isc.org



Enable Linux Framebuffer

Boot Loader
To enable framebuffer in GRUB (GRand Unified Bootloader) need to add the "vga=XXX" option to the kernel line. For GRUB 2 add "set gfxpayload=$GRUB_GFXPAYLOAD_LINUX" and set the "$GRUB_GFXPAYLOAD_LINUX" environment variable in /etc/grub.d/XX_linux.
In LILO (LInux LOader) add a "vga=XXX" line before the image section.[0]

Drivers and Kernel Modules
If the Framebuffer is not available, check that the kernel was compiled with support on.
In kernel config file of /boot directory should be the "CONFIG_FB_VESA=y" built-in entry. If CONFIG_FB_VESA is set to no need to recompile the kernel including the framebuffer support.[1]

In addition to the vesafb driver there are also specific drivers for video cards. Some are: arkfb, aty128fb, atyfb, radeonfb, cirrusfb, cyber2000fb, gx1fb, gxfb, lxfb, kyrofb, matroxfb_base, mb862xxfb, neofb, nvidiafb, pm2fb, pm3fb, s3fb, savagefb, sisfb, tdfxfb, tridentfb, viafb, vt8623fb. They should not be strictly necessary, but if you want to use them uncomment the blacklist lines to configuration files of /etc/modprobe.d system's directory.


NOTES
[0] To do this the best suggest you read a manual of the respective bootloader
[1] To do this the best suggest you read a guide to compiling the kernel

Portale: