diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-08 12:31:36 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-08 12:31:36 -0600 |
commit | d796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch) | |
tree | 6e3dcca4f77e20ec8966c666aac7c35bd4704053 /doc/framebuffer-howto.doc | |
download | tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip |
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'doc/framebuffer-howto.doc')
-rw-r--r-- | doc/framebuffer-howto.doc | 250 |
1 files changed, 250 insertions, 0 deletions
diff --git a/doc/framebuffer-howto.doc b/doc/framebuffer-howto.doc new file mode 100644 index 000000000..4c855ddfc --- /dev/null +++ b/doc/framebuffer-howto.doc @@ -0,0 +1,250 @@ +/**************************************************************************** +** +** Windowsystem-specific pages +** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.QPL +** included in the packaging of this file. Licensees holding valid Qt +** Commercial licenses may use this file in accordance with the Qt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +/*! +\page emb-framebuffer-howto.html + +\title Enabling the Linux Framebuffer + +This is only a short guide. +See \l file:/usr/src/linux/README and +\l file:/usr/src/linux/Documentation/fb/ for detailed information. +There is also a detailed explanation at +\l http://www.linuxdoc.org/HOWTO/Framebuffer-HOWTO.html. + +\list 1 +\i Make sure that you have the Linux kernel source code in +\l file:/usr/src/linux/. + +\i Log in as root and \c cd \c /usr/src/linux + +\i Configure the kernel: + + Run: +\code + make menuconfig +\endcode + + Select "Code maturity level options" and set "Prompt for + development and/or incomplete code/drivers". + + Then select "Console drivers" and set "Support for frame buffer + devices" to built-in (even if it says EXPERIMENTAL). Then configure + the driver. Most modern graphics cards can use the "VESA VGA + graphics console"; use that or a driver that specifically matches + your video card. Finally, enable "Advanced low level driver options" + and make sure that 16 and 32 bpp packed pixel support are enabled. + + When you are finished, chose exit and save. + +\i Compile the kernel + + First do: +\code + make dep +\endcode + then: +\code + make bzImage +\endcode + + The new kernel should now be in arch/i386/boot/bzImage. + +\i Copy the kernel to the boot directory: +\code + cp arch/i386/boot/bzImage /boot/linux.vesafb +\endcode + +\i Edit /etc/lilo.conf. + + \warning Keep a backup of \l file:/etc/lilo.conf, and have a rescue disk + available. If you make a mistake, the machine may not boot. + + The file \l file:/etc/lilo.conf specifies how the system boots. The + precise contents of the file varies from system to system. Here is + an example: +\code +# LILO configuration file +boot = /dev/hda3 +delay = 30 +image = /boot/vmlinuz + root = /dev/hda3 + label = Linux + read-only # Non-UMSDOS filesystems should be mounted read-only for checking +other=/dev/hda1 + label=nt + table=/dev/hda +\endcode + + Make a new "image" section that is a copy of the first one, but with +\code + image = /boot/linux.vesafb +\endcode + and +\code + label = Linux-vesafb +\endcode + Place it just above the first image section. + + Add a line before the image section saying \c{vga = 791}. (Meaning + 1024x768, 16 bpp.) + + With the above example, lilo.conf would now be: +\code +# LILO configuration file +boot = /dev/hda3 +delay = 30 +vga = 791 +image = /boot/linux.vesafb + root = /dev/hda3 + label = Linux-vesafb + read-only # Non-UMSDOS filesystems should be mounted read-only for checking +image = /boot/vmlinuz + root = /dev/hda3 + label = Linux + read-only # Non-UMSDOS filesystems should be mounted read-only for checking +other=/dev/hda1 + label=nt + table=/dev/hda +\endcode + +Do not change any existing lines in the file; just add new ones. + +\i To make the new changes take effect, run the lilo program: +\code + lilo +\endcode + +\i Reboot the system. You should now see a penguin logo while the + system is booting. + (Or more than one on a multi-processor machine.) + +\i If it does not boot properly with the new kernel, you can boot with + the old kernel by entering the label of the old image section at + the LILO prompt. (with the example lilo.conf file, the old label is + Linux.) + + If that does not work (probably because of an error in lilo.conf), + boot the machine using your rescue disk, restore \l + file:/etc/lilo.conf from backup and re-run lilo. + +\i Testing: Here's a short program that opens the frame buffer and draws a + gradient-filled red square. + +\code +#include <unistd.h> +#include <stdio.h> +#include <fcntl.h> +#include <linux/fb.h> +#include <sys/mman.h> + +int main() +{ + int fbfd = 0; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + long int screensize = 0; + char *fbp = 0; + int x = 0, y = 0; + long int location = 0; + + // Open the file for reading and writing + fbfd = open("/dev/fb0", O_RDWR); + if (!fbfd) { + printf("Error: cannot open framebuffer device.\n"); + exit(1); + } + printf("The framebuffer device was opened successfully.\n"); + + // Get fixed screen information + if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) { + printf("Error reading fixed information.\n"); + exit(2); + } + + // Get variable screen information + if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { + printf("Error reading variable information.\n"); + exit(3); + } + + printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel ); + + // Figure out the size of the screen in bytes + screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; + + // Map the device to memory + fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, + fbfd, 0); + if ((int)fbp == -1) { + printf("Error: failed to map framebuffer device to memory.\n"); + exit(4); + } + printf("The framebuffer device was mapped to memory successfully.\n"); + + x = 100; y = 100; // Where we are going to put the pixel + + // Figure out where in memory to put the pixel + for ( y = 100; y < 300; y++ ) + for ( x = 100; x < 300; x++ ) { + + location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) + + (y+vinfo.yoffset) * finfo.line_length; + + if ( vinfo.bits_per_pixel == 32 ) { + *(fbp + location) = 100; // Some blue + *(fbp + location + 1) = 15+(x-100)/2; // A little green + *(fbp + location + 2) = 200-(y-100)/5; // A lot of red + *(fbp + location + 3) = 0; // No transparency + } else { //assume 16bpp + int b = 10; + int g = (x-100)/6; // A little green + int r = 31-(y-100)/16; // A lot of red + unsigned short int t = r<<11 | g << 5 | b; + *((unsigned short int*)(fbp + location)) = t; + } + + } + munmap(fbp, screensize); + close(fbfd); + return 0; +} +\endcode +\endlist + +*/ |