免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 619 | 回复: 0
打印 上一主题 下一主题

Enabling the Linux Framebuffer [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-26 11:21 |只看该作者 |倒序浏览

This is only a short guide. See
/usr/src/linux/README
and
/usr/src/linux/Documentation/fb/
for detailed information. There is also a detailed explanation at
http://www.linuxdoc.org/HOWTO/Framebuffer-HOWTO.html
.
  • Make sure that you have the Linux kernel source code in
    /usr/src/linux/
    .
  • Log in as root and cd /usr/src/linux
  • Configure the kernel:
    Run:     make menuconfig
    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.
  • Compile the kernel
    First do:     make dep
    then:     make bzImage
    The new kernel should now be in arch/i386/boot/bzImage.
  • Copy the kernel to the boot directory:     cp arch/i386/boot/bzImage /boot/linux.vesafb
  • Edit /etc/lilo.conf.
    Warning: Keep a backup of
    /etc/lilo.conf
    , and have a rescue disk available. If you make a mistake, the machine may not boot.
    The file
    /etc/lilo.conf
    specifies how the system boots. The precise contents of the file varies from system to system. Here is an example: # 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
    Make a new "image" section that is a copy of the first one, but with   image = /boot/linux.vesafb
    and   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
    Do not change any existing lines in the file; just add new ones.
  • To make the new changes take effect, run the lilo program:     lilo
  • Reboot the system. You should now see a penguin logo while the system is booting. (Or more than one on a multi-processor machine.)
  • 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
    /etc/lilo.conf
    from backup and re-run lilo.
  • Testing: Here's a short program that opens the frame buffer and draws a gradient-filled red square.
    #include
    #include
    #include
    #include
    #include
    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


    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/67519/showart_586760.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP