emb-framebuffer-howto.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 235 行

HTML
235
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/doc/HOWTO-Framebuffer.doc:36 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Enabling the Linux Framebuffer</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Enabling the Linux Framebuffer</h1> <p> This is only a short guide.See <a href="file:/usr/src/linux/README">/usr/src/linux/README</a> and<a href="file:/usr/src/linux/Documentation/fb/">/usr/src/linux/Documentation/fb/</a> for detailed information.There is also a detailed explanation at<a href="http://www.linuxdoc.org/HOWTO/Framebuffer-HOWTO.html">http://www.linuxdoc.org/HOWTO/Framebuffer-HOWTO.html</a>.<p> <ol type=1><li> Make sure that you have the Linux kernel source code in<a href="file:/usr/src/linux/">/usr/src/linux/</a>.<p> <li> Log in as root and <tt>cd</tt> <tt>/usr/src/linux</tt><p> <li> Configure the kernel:<p> Run:<pre>    make menuconfig</pre> <p> Select "Code maturity level options" and set "Prompt fordevelopment and/or incomplete code/drivers".<p> Then select "Console drivers" and set "Support for frame bufferdevices" to built-in (even if it says EXPERIMENTAL). Then configurethe driver. Most modern graphics cards can use the "VESA VGAgraphics console"; use that or a driver that specifically matchesyour video card. Finally, enable "Advanced low level driver options"and make sure that 16 and 32 bpp packed pixel support are enabled. <p> When you are finished, chose exit and save.<p> <li> Compile the kernel<p> First do:<pre>    make dep</pre> then:<pre>    make bzImage</pre> <p> The new kernel should now be in arch/i386/boot/bzImage.<p> <li> Copy the kernel to the boot directory:<pre>    cp arch/i386/boot/bzImage /boot/linux.vesafb</pre> <p> <li> Edit /etc/lilo.conf.<p> <b>Warning:</b> Keep a backup of <a href="file:/etc/lilo.conf">/etc/lilo.conf</a>, and have a rescue diskavailable. If you make a mistake, the machine may not boot.<p> The file <a href="file:/etc/lilo.conf">/etc/lilo.conf</a> specifies how the system boots. Theprecise contents of the file varies from system to system. Here isan example:<pre># LILO configuration fileboot = /dev/hda3delay = 30 image = /boot/vmlinuz  root = /dev/hda3  label = Linux  read-only # Non-UMSDOS filesystems should be mounted read-only for checkingother=/dev/hda1        label=nt        table=/dev/hda</pre> <p> Make a new "image" section that is a copy of the first one, but with<pre>  image = /boot/linux.vesafb </pre> and <pre>  label = Linux-vesafbendcode  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 fileboot = /dev/hda3delay = 30 vga = 791image = /boot/linux.vesafb  root = /dev/hda3  label = Linux-vesafb  read-only # Non-UMSDOS filesystems should be mounted read-only for checkingimage = /boot/vmlinuz  root = /dev/hda3  label = Linux  read-only # Non-UMSDOS filesystems should be mounted read-only for checkingother=/dev/hda1        label=nt        table=/dev/hda</pre> <p> Do not change any existing lines in the file; just add new ones.<p> <li> To make the new changes take effect, run the lilo program:<pre>    lilo</pre> <p> <li> Reboot the system. You should now see a penguin logo while thesystem is booting.(Or more than one on a multi-processor machine.)<p> <li> If it does not boot properly with the new kernel, you can boot withthe old kernel by entering the label of the old image section atthe LILO prompt. (with the example lilo.conf file, the old label isLinux.)<p> If that does not work (probably because of an error in lilo.conf),boot the machine using your rescue disk, restore <a href="file:/etc/lilo.conf">/etc/lilo.conf</a> from backup and re-run lilo.<p> <li> Testing: Here's a short program that opens the frame buffer and draws agradient-filled red square.<p> <pre>#include &lt;unistd.h&gt;#include &lt;stdio.h&gt;#include &lt;fcntl.h&gt;#include &lt;linux/fb.h&gt;#include &lt;sys/mman.h&gt;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, &amp;finfo)) {        printf("Error reading fixed information.\n");        exit(2);    }    // Get variable screen information    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &amp;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 &lt; 300; y++ )        for ( x = 100; x &lt; 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&lt;&lt;11 | g &lt;&lt; 5 | b;                *((unsigned short int*)(fbp + location)) = t;            }        }    munmap(fbp, screensize);    close(fbfd);    return 0;}</pre> </ol><p> <!-- eof --><p><address><hr><div align=center><table width=100% cellspacing=0 border=0><tr><td>Copyright &copy; 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align=right><div align=right>Qt version 3.0.5</div></table></div></address></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?